From: Dimitrios Eftaxiopoulos Date: Sun, 23 Mar 2014 23:00:27 +0000 (+0000) Subject: Import mathgl_2.2.2.1.orig.tar.gz X-Git-Tag: archive/raspbian/2.4.4-3+rpi1~1^2^2^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6783f8f9ade349ce5c362890e993d92a3083962f;p=mathgl.git Import mathgl_2.2.2.1.orig.tar.gz [dgit import orig mathgl_2.2.2.1.orig.tar.gz] --- 6783f8f9ade349ce5c362890e993d92a3083962f diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..7c587e5 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,9 @@ +Author of MathGL: + +Alexey Balakin + +Some extensions was written by: +Dmitriy Kulagin - cmake script +Mikhail Vidassov - U3D/PDF/OBJ export +Mikhail Barg - Pascal/Delphi interface +Sergey Plis - Forth interface \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4ae50a5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,536 @@ +cmake_minimum_required(VERSION 2.8.9) + +project( MathGL ) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: + None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) +endif(NOT CMAKE_BUILD_TYPE) + +set(CMAKE_VERBOSE_MAKEFILE ON) +set(MathGL_VERSION_MAJOR 2) +set(MathGL_VERSION_MINOR 2.2) +set(MathGL_SOVERSION 7.2.0) + + +MACRO(MGL_DEPENDENT_OPTION option doc default depends1 force1 depends2 force2) + IF(${option}_ISSET MATCHES "^${option}_ISSET$") + SET(${option}_AVAILABLE 1) + IF(${force1}) + FOREACH(d ${depends1}) + STRING(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + IF(${CMAKE_DEPENDENT_OPTION_DEP}) + ELSE(${CMAKE_DEPENDENT_OPTION_DEP}) + SET(${option}_AVAILABLE 0) + SET(depends1_AVAILABLE 1) + ENDIF(${CMAKE_DEPENDENT_OPTION_DEP}) + ENDFOREACH(d) + ENDIF(${force1}) + IF(${force2}) + FOREACH(d ${depends2}) + STRING(REGEX REPLACE " +" ";" CMAKE_DEPENDENT_OPTION_DEP "${d}") + IF(${CMAKE_DEPENDENT_OPTION_DEP}) + ELSE(${CMAKE_DEPENDENT_OPTION_DEP}) + SET(${option}_AVAILABLE 0) + SET(depends2_AVAILABLE 1) + ENDIF(${CMAKE_DEPENDENT_OPTION_DEP}) + ENDFOREACH(d) + ENDIF(${force2}) + IF(${option}_AVAILABLE) + OPTION(${option} "${doc}" "${default}") + SET(${option} "${${option}}" CACHE BOOL "${doc}" FORCE) + ELSE(${option}_AVAILABLE) + IF(${option} MATCHES "^${option}$") + ELSE(${option} MATCHES "^${option}$") + SET(${option} "${${option}}" CACHE INTERNAL "${doc}") + ENDIF(${option} MATCHES "^${option}$") + IF(depends1_AVAILABLE) + SET(${option} OFF) + ELSEIF(depends2_AVAILABLE) + SET(${option} ON) + ENDIF(depends1_AVAILABLE) + ENDIF(${option}_AVAILABLE) + ELSE(${option}_ISSET MATCHES "^${option}_ISSET$") + SET(${option} "${${option}_ISSET}") + ENDIF(${option}_ISSET MATCHES "^${option}_ISSET$") +ENDMACRO(MGL_DEPENDENT_OPTION) +include(CMakeDependentOption) + +set(MGL_LIB_INSTALL_DIR "lib" CACHE STRING "Set library install directory") + +option(enable-double "Enable double precision in MathGL library" ON) +option(enable-simple "Slightly increase drawing speed but disable mglDataA class") +option(enable-mpi "Enable mpi") +option(enable-opengl "Enable OpenGL support" ON) +option(enable-all-docs "Enable all documentation building") +#option(enable-doc "Enable documentation building") +option(enable-all "Enable all core features") +option(enable-all-widgets "Enable all Widgets") +option(enable-all-swig "Enable all SWIG based interfaces") +option(enable-pthread "Enable POSIX threads support" OFF) +option(enable-openmp "Enable OpenMP support" ON) +option(enable-lgpl "Enable only LGPL part of MathGL") +option(enable-mgl2 "Use names 'libmgl2-*' instead of 'libmgl-*'") +#option(enable-ltdl "Enable loading modules support") +CMAKE_DEPENDENT_OPTION(enable-doc-site "Enable HTML documentation for website" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-html "Enable HTML documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-info "Enable INFO documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-pdf-ru "Enable Russian PDF documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-pdf-en "Enable English PDF documentation" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-prc "Enable PDF samples for HTML docs" OFF "NOT enable-all-docs" ON) +CMAKE_DEPENDENT_OPTION(enable-doc-json "Enable JSON samples for HTML docs" OFF "NOT enable-all-docs" ON) +option(enable-texi2html "Use texi2html (obsolete package) instead of texi2any" OFF) + +CMAKE_DEPENDENT_OPTION(enable-zlib "Enable zlib support" ON "NOT enable-all" ON) +CMAKE_DEPENDENT_OPTION(enable-png "Enable png support" ON "NOT enable-all" ON) +CMAKE_DEPENDENT_OPTION(enable-jpeg "Enable jpeg support" OFF "NOT enable-all" ON) +MGL_DEPENDENT_OPTION(enable-gsl "Enable gsl support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) +MGL_DEPENDENT_OPTION(enable-hdf4 "Enable hdf4 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) +MGL_DEPENDENT_OPTION(enable-hdf5 "Enable hdf5 support" OFF "NOT enable-lgpl" ON "NOT enable-all" ON) +CMAKE_DEPENDENT_OPTION(enable-pdf "Enable pdf support" OFF "NOT enable-all" ON) +CMAKE_DEPENDENT_OPTION(enable-gif "Enable gif support" OFF "NOT enable-all" ON) +CMAKE_DEPENDENT_OPTION(enable-glut "Enable glut support" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-fltk "Enable fltk widget" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-wx "Enable wxWidget widget" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-qt4 "Enable Qt4 widget" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-qt5 "Enable Qt5 widget" OFF "NOT enable-all-widgets" ON) +CMAKE_DEPENDENT_OPTION(enable-qt5asqt "Set Qt5 as default libmgl-qt" ON "enable-qt5" OFF) + +if(enable-qt4 OR enable-qt5) +set(enable-qt ON) +endif(enable-qt4 OR enable-qt5) + +CMAKE_DEPENDENT_OPTION(enable-json-sample "Enable JSON sample" ON "enable-qt" OFF) +MGL_DEPENDENT_OPTION(enable-python "Enable python interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) +MGL_DEPENDENT_OPTION(enable-lua "Enable Lua (v.5.1) interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) +MGL_DEPENDENT_OPTION(enable-octave "Enable octave interface" OFF "NOT enable-lgpl" ON "NOT enable-all-swig" ON) +MGL_DEPENDENT_OPTION(enable-octave-install "Octave interface will install for all users" ON "NOT enable-lgpl" ON "NOT enable-all-swig" ON) + +include_directories( ${MathGL_SOURCE_DIR}/include ${MathGL_BINARY_DIR}/include) +set(MGL_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/include/mgl2") +set(MGL_CGI_PATH "${CMAKE_INSTALL_PREFIX}/share/mathgl" CACHE STRING "Set CGI install directory") + +if(NOT WIN32) +# set(MGL_CGI_PATH "${CMAKE_INSTALL_PREFIX}/share/mathgl") + set(MGL_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/mathgl") + set(MGL_DOC_PATH "${CMAKE_INSTALL_PREFIX}/share/doc/mathgl") + set(MGL_MAN_PATH "${CMAKE_INSTALL_PREFIX}/share/man") + set(MGL_INFO_PATH "${CMAKE_INSTALL_PREFIX}/share/info") + set(MGL_FONT_PATH "${MGL_DATA_PATH}/fonts") + install(DIRECTORY fonts/ DESTINATION ${MGL_FONT_PATH} + PATTERN ".svn" EXCLUDE + PATTERN "*.vfm") +endif(NOT WIN32) + +include(CheckFunctionExists) +include(CMakePushCheckState) +include(TestBigEndian) + +TEST_BIG_ENDIAN(WORDS_BIGENDIAN) +if(WORDS_BIGENDIAN) + ADD_DEFINITIONS("-DWORDS_BIGENDIAN") +endif(WORDS_BIGENDIAN) + +CHECK_FUNCTION_EXISTS(sin MGL_SIN) +CHECK_FUNCTION_EXISTS(memrchr HAVE_MEMRCHR) +if(NOT MGL_SIN) + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) + CHECK_FUNCTION_EXISTS(sin MGL_SIN_M) + cmake_pop_check_state() + if(MGL_SIN_M) + set(M_LIB m) + elseif(MGL_SIN_M) + message(SEND_ERROR "Math library not found") + endif(MGL_SIN_M) +endif(NOT MGL_SIN) +if(HAVE_MEMRCHR) + ADD_DEFINITIONS("-DHAVE_MEMRCHR") +endif(HAVE_MEMRCHR) + +if(enable-double) + set(MGL_USE_DOUBLE 1) +else(enable-double) + set(MGL_USE_DOUBLE 0) +endif(enable-double) + +if(enable-qt4 OR enable-qt5) + set(MGL_HAVE_QT 1) +endif(enable-qt4 OR enable-qt5) + +if(enable-simple) + set(MGL_NO_DATA_A 1) +message(STATUS "Class mglDataA is switched off.") +else(enable-simple) + set(MGL_NO_DATA_A 0) +endif(enable-simple) + +if(enable-openmp) + find_package(OpenMP) + if(OPENMP_FOUND) + set(MGL_HAVE_OMP 1) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + else(OPENMP_FOUND) + message(SEND_ERROR "Couldn't find OpenMP. You can enable POSIX threads instead.") + set(MGL_HAVE_OMP 0) + endif(OPENMP_FOUND) +else(enable-openmp) + set(MGL_HAVE_OMP 0) +endif(enable-openmp) + +if(enable-mpi) + set(MGL_HAVE_MPI 1) + find_package(MPI REQUIRED) + set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS}) + set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS}) + include_directories(${MPI_INCLUDE_PATH}) +else(enable-mpi) + set(MGL_HAVE_MPI 0) +endif(enable-mpi) + +if(enable-pthread) + set(MGL_HAVE_PTHREAD 1) + include(FindThreads) + if(NOT CMAKE_USE_PTHREADS_INIT) + message(SEND_ERROR "Couldn't find POSIX threads library.") + endif(NOT CMAKE_USE_PTHREADS_INIT) +else(enable-pthread) + set(MGL_HAVE_PTHREAD 0) +endif(enable-pthread) + +if(enable-gsl) + set(MGL_HAVE_GSL 1) + find_library(GSL_LIB gsl) + find_library(GSL_CBLAS_LIB gslcblas) + find_path(GSL_INCLUDE_DIR gsl/gsl_fft_complex.h) + if(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR) + message(SEND_ERROR "${GSL_LIB}") + message(SEND_ERROR "${GSL_CBLAS_LIB}") + message(SEND_ERROR "${GSL_INCLUDE_DIR}") + message(SEND_ERROR "Couldn't find GSL libraries.") + endif(NOT GSL_LIB OR NOT GSL_CBLAS_LIB OR NOT GSL_INCLUDE_DIR) +else(enable-gsl) + set(MGL_HAVE_GSL 0) +endif(enable-gsl) + +#if(enable-all OR enable-ltdl) +# set(MGL_HAVE_LTDL 1) +# find_library(LTDL_LIB ltdl) +# find_path(LTDL_INCLUDE_DIR ltdl.h) +# if(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR) +# message(SEND_ERROR "${LTDL_LIB}") +# message(SEND_ERROR "${LTDL_INCLUDE_DIR}") +# message(SEND_ERROR "Couldn't find LTDL library.") +# endif(NOT LTDL_LIB OR NOT LTDL_INCLUDE_DIR) +#else(enable-all OR enable-ltdl) +# set(MGL_HAVE_LTDL 0) +#endif(enable-all OR enable-ltdl) + +if(enable-hdf4) + set(MGL_HAVE_HDF4 1) + find_library(HDF4_LIB df) + find_library(HDF4MF_LIB mfhdf) + find_path(HDF4_INCLUDE_DIR hdf/mfhdf.h) + if(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR) + message(SEND_ERROR "${HDF4_LIB}") + message(SEND_ERROR "${HDF4MF_LIB}") + message(SEND_ERROR "${HDF4_INCLUDE_DIR}") + message(SEND_ERROR "Couldn't find HDF4 libraries.") + endif(NOT HDF4_LIB OR NOT HDF4MF_LIB OR NOT HDF4_INCLUDE_DIR) +else(enable-hdf4) + set(MGL_HAVE_HDF4 0) +endif(enable-hdf4) + +if(enable-hdf5) + set(MGL_HAVE_HDF5 1) + include(FindHDF5) + if(NOT HDF5_FOUND) + message(SEND_ERROR "Couldn't find HDF5 library.") + endif(NOT HDF5_FOUND) +else(enable-hdf5) + set(MGL_HAVE_HDF5 0) +endif(enable-hdf5) + +if(enable-jpeg) + set(MGL_HAVE_JPEG 1) + include(FindJPEG) + if(NOT JPEG_FOUND) + message(SEND_ERROR "Couldn't find JPEG library.") + endif(NOT JPEG_FOUND) +else(enable-jpeg) + set(MGL_HAVE_JPEG 0) +endif(enable-jpeg) + + +if(enable-zlib) + set(MGL_HAVE_ZLIB 1) + include(FindZLIB) + if(NOT ZLIB_FOUND) + message(SEND_ERROR "Couldn't find ZLib library.") + endif(NOT ZLIB_FOUND) +else(enable-zlib) + set(MGL_HAVE_ZLIB 0) +endif(enable-zlib) + +if(enable-png) + set(MGL_HAVE_PNG 1) + if(NOT MGL_HAVE_ZLIB) + message(SEND_ERROR "You have to enable ZLib if you plan to use PNG export.") + endif(NOT MGL_HAVE_ZLIB) + include(FindPNG) + if(NOT PNG_FOUND) + message(SEND_ERROR "Couldn't find PNG library.") + endif(NOT PNG_FOUND) +else(enable-png) + set(MGL_HAVE_PNG 0) +endif(enable-png) + + +if(enable-pdf) + set(MGL_HAVE_PDF 1) + if(NOT MGL_HAVE_PNG) + message(SEND_ERROR "You have to enable PNG if you plan to use PDF export.") + endif(NOT MGL_HAVE_PNG) + find_library(HPDF_LIB hpdf) + if(NOT HPDF_LIB) + message(SEND_ERROR "Couldn't find libHaru or libhpdf.") + endif(NOT HPDF_LIB) + find_path(HPDF_INCLUDE_DIR hpdf_u3d.h) + if(NOT HPDF_INCLUDE_DIR) + message(SEND_ERROR "Couldn't find headers of 3d-enabled version of libhpdf.") + endif(NOT HPDF_INCLUDE_DIR) +else(enable-pdf) + set(MGL_HAVE_PDF 0) +endif(enable-pdf) + +if(enable-gif) + set(MGL_HAVE_GIF 1) + include(FindGIF) + if(NOT GIF_FOUND) + message(SEND_ERROR "Couldn't find GIF library.") + endif(NOT GIF_FOUND) +else(enable-gif) + set(MGL_HAVE_GIF 0) +endif(enable-gif) + +if(enable-opengl) + set(MGL_HAVE_OPENGL 1) + include(FindOpenGL) + if(NOT OPENGL_FOUND) + message(SEND_ERROR "Couldn't find OpenGL libraries.") + endif(NOT OPENGL_FOUND) +else(enable-opengl) + set(MGL_HAVE_OPENGL 0) +endif(enable-opengl) + +if(enable-glut) + set(MGL_HAVE_GLUT 1) + if(NOT MGL_HAVE_OPENGL) + message(SEND_ERROR "You have to enable OpenGL if you plan to use GLUT.") + endif(NOT MGL_HAVE_OPENGL) + include(FindGLUT) + if(NOT GLUT_FOUND) + message(SEND_ERROR "Couldn't find GLUT library.") + endif(NOT GLUT_FOUND) +else(enable-glut) + set(MGL_HAVE_GLUT 0) +endif(enable-glut) + +if(enable-fltk) + set(MGL_HAVE_FLTK 1) + include(FindFLTK) + if(NOT FLTK_FOUND) + message(SEND_ERROR "Couldn't find FLTK library.") + endif(NOT FLTK_FOUND) +else(enable-fltk) + set(MGL_HAVE_FLTK 0) +endif(enable-fltk) + +if(enable-wx) + set(MGL_HAVE_WX 1) + FIND_PACKAGE(wxWidgets COMPONENTS base core gl) + if(NOT wxWidgets_FOUND) + message(SEND_ERROR "Couldn't find wxWidgets library.") + endif(NOT wxWidgets_FOUND) +else(enable-wx) + set(MGL_HAVE_WX 0) +endif(enable-wx) + +if(enable-python) + set(MGL_HAVE_SWIG 1) + set(MGL_HAVE_PYTHON 1) + set(Python_ADDITIONAL_VERSIONS 2.7) + FIND_PACKAGE(PythonInterp) + if(NOT PYTHONINTERP_FOUND) + message(SEND_ERROR "Couldn't find python interpreter.") + endif(NOT PYTHONINTERP_FOUND) + FIND_PACKAGE(PythonLibs) + if(NOT PYTHONLIBS_FOUND) + message(SEND_ERROR "Couldn't find python development libraries.") + endif(NOT PYTHONLIBS_FOUND) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print numpy.get_include()" + OUTPUT_VARIABLE NUMPY_INCLUDE_PATH + RESULT_VARIABLE NUMPY_ERR + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT NUMPY_INCLUDE_PATH) + message(SEND_ERROR "Couldn't find numpy.") + endif(NOT NUMPY_INCLUDE_PATH) +else(enable-python) + set(MGL_HAVE_PYTHON 0) +endif(enable-python) + +if(enable-lua) + set(MGL_HAVE_SWIG 1) + set(MGL_HAVE_LUA 1) + INCLUDE(FindLua51) + if(NOT LUA51_FOUND) + message(SEND_ERROR "Couldn't find Lua 5.1 library.") + endif(NOT LUA51_FOUND) +else(enable-lua) + set(MGL_HAVE_LUA 0) +endif(enable-lua) + + +if(enable-octave) + set(MGL_HAVE_SWIG 1) + set(MGL_HAVE_OCTAVE 1) + find_program(oct_prog octave-config) + if(NOT oct_prog) + message(SEND_ERROR "Couldn't find octave-config needed for octave interfaces compiling.") + endif(NOT oct_prog) + find_program(oct_exec octave) + if(NOT oct_exec) + message(SEND_ERROR "Couldn't find octave needed for octave interfaces compiling.") + endif(NOT oct_exec) + find_program(oct_mk mkoctfile) + if(NOT oct_mk) + message(SEND_ERROR "Couldn't find mkoctfile needed for octave interfaces compiling.") + endif(NOT oct_mk) + find_program(oct_tar tar) + if(NOT oct_tar) + message(SEND_ERROR "Couldn't find tar needed for octave interfaces creation.") + endif(NOT oct_tar) +else(enable-octave) + set(MGL_HAVE_OCTAVE 0) +endif(enable-octave) + +if(enable-doc-info) + set(MGL_HAVE_DOC_INFO 1) + find_program(findmi makeinfo) + if(NOT findmi) + message(SEND_ERROR "Couldn't find makeinfo needed for documentation building.") + endif(NOT findmi) +else(enable-doc-info) + set(MGL_HAVE_DOC_INFO 0) +endif(enable-doc-info) + +if(enable-doc-html OR enable-doc-site) + if(enable-texi2html) + find_program(findth texi2html) + if(NOT findth) + message(SEND_ERROR "Couldn't find texi2html needed for documentation building.") + endif(NOT findth) + else(enable-texi2html) + find_program(findth texi2any) + if(NOT findth) + message(SEND_ERROR "Couldn't find texi2any needed for documentation building.") + endif(NOT findth) + endif(enable-texi2html) +endif(enable-doc-html OR enable-doc-site) + +if(enable-texi2html) + set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/doc_en.html) + set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/doc_ru.html) + set(th_opt ) +else(enable-texi2html) + set(th_opt --html) + set(site_en ${CMAKE_BINARY_DIR}/texinfo/doc_en/index.html) + set(site_ru ${CMAKE_BINARY_DIR}/texinfo/doc_ru/index.html) +endif(enable-texi2html) + +if(enable-doc-html) + set(MGL_HAVE_DOC_HTML 1) +else(enable-doc-html) + set(MGL_HAVE_DOC_HTML 0) +endif(enable-doc-html) + + +if(enable-doc-site) + set(MGL_HAVE_DOC_SITE 1) +else(enable-doc-site) + set(MGL_HAVE_DOC_SITE 0) +endif(enable-doc-site) + +if(enable-doc-pdf-ru) + set(MGL_HAVE_DOC_PDF_RU 1) + find_program(findtp texi2pdf) + if(NOT findtp) + message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.") + endif(NOT findtp) +else(enable-doc-pdf-ru) + set(MGL_HAVE_DOC_PDF_RU 0) +endif(enable-doc-pdf-ru) + +if(enable-doc-pdf-en) + set(MGL_HAVE_DOC_PDF_EN 1) + find_program(findtp texi2pdf) + if(NOT findtp) + message(SEND_ERROR "Couldn't find texi2pdf needed for documentation building.") + endif(NOT findtp) +else(enable-doc-pdf-en) + set(MGL_HAVE_DOC_PDF_EN 0) +endif(enable-doc-pdf-en) + +if(enable-doc-json) + set(MGL_HAVE_DOC_JSON 1) +else(enable-doc-json) + set(MGL_HAVE_DOC_JSON 0) +endif(enable-doc-json) + +if(enable-doc-prc) + set(MGL_HAVE_DOC_PRC 1) + if(NOT enable-pdf) + message(SEND_ERROR "You need to enable pdf support for MathGL.") + endif(NOT enable-pdf) +else(enable-doc-prc) + set(MGL_HAVE_DOC_PRC 0) +endif(enable-doc-prc) + +if(MGL_HAVE_SWIG) + FIND_PACKAGE(SWIG) + if(NOT SWIG_FOUND) + message(SEND_ERROR "Couldn't find swig needed for interfaces compiling.") + endif(NOT SWIG_FOUND) + INCLUDE(${SWIG_USE_FILE}) +endif(MGL_HAVE_SWIG) + +if(UNIX) + add_definitions(-DNO_COLOR_ARRAY) +endif(UNIX) + +if(WIN32) + add_definitions(-DWIN32) +endif(WIN32) + +add_subdirectory( src ) +add_subdirectory( widgets ) +add_subdirectory( include ) +if(NOT enable-lgpl) + add_subdirectory( udav ) + add_subdirectory( json ) + add_subdirectory( lang ) + add_subdirectory( utils ) +# add_subdirectory( mgllab ) +endif(NOT enable-lgpl) + +if(NOT MSVC AND NOT BORLAND) + add_subdirectory( examples ) + + if(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN ) + add_subdirectory( texinfo ) + endif(MGL_HAVE_DOC_HTML OR MGL_HAVE_DOC_SITE OR MGL_HAVE_DOC_INFO OR MGL_HAVE_DOC_PDF_RU OR MGL_HAVE_DOC_PDF_EN ) + +endif(NOT MSVC AND NOT BORLAND) diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/COPYING_LGPL b/COPYING_LGPL new file mode 100644 index 0000000..65c5ca8 --- /dev/null +++ b/COPYING_LGPL @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/ChangeLog b/ChangeLog new file mode 120000 index 0000000..74b6820 --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +ChangeLog.txt \ No newline at end of file diff --git a/ChangeLog.txt b/ChangeLog.txt new file mode 100644 index 0000000..fd83c6e --- /dev/null +++ b/ChangeLog.txt @@ -0,0 +1,219 @@ +2.2.2.1 Released 19 March 2014 + +* Compatibility changes for MS VisualStudio 2010 and early. +* Function SetRange(v1,v2) ignore NAN values now. +* Add enable-json-sample for building json-samples on demand only. +* Update docs. + + +2.2.2 Released 10 March 2014 + +* Add mgl_region_3d() to draw region (or ribbon) between 2 curves. Correspondingly extend mglGraph::Region() function and MGL command 'region'. +* Allow LGPL for MathGL widgets. +* Improve export to TeX. +* Add missing functions to Fortran interface. +* Bugfix for legend with enabled lighting. +* Minor bugfixes and memory leaks. + + +2.2.1 Released 22 January 2014 + +* Add Qt5 support. +* Add Pascal interface. +* Improve JavaScript interface. +* Add function AddRange(char dir, mreal v1, mreal v2) and extend corresponding MGL commands '[xyzc]range'. +* Add 'hypot' function for known functions in formula parsing. +* Add style '~' to disable colorbar or axis labels. NOTE, axis style '_' is obsolete and should be replaced by '~'. +* Change Aspect() if Ax=NAN. Now, Ay and Az set the ratio to optimal aspect (not exact value as previously). +* Disable changes by View(),Zoom(),Perspective() for position of Title(), Legend(), Colorbar(). +* Partial support of perspective in CalcXYZ(). +* Speed up PDE solving. +* Add complex versions of PDE, QO2d, QO3d. +* Correct filled background for Box() in curved coordinates. +* Allow nx=1 for Stem and Error. +* Bugfix for drawing single axis. +* Bugfix for missing options parsing for some of MGL commands. +* Bugfix for .pmin suffix in MGL. Add mglData::MaximalNeg() and mglData::MinimalPos() functions. Add .nmin and .nmax suffixes. +* Bugfix for colorbar labels. +* Force using python 2.7 by default due to bug in Ubuntu. Debian sid works well with python 3.* too. +* Minor bugfixes and memory leaks. + + +2.2 Released 11 November 2013 + +* Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized). +* Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data. +* Add OHLC() plot for drawing Open-High-Low-Close diagram +* Add wxMathGL widget. +* Add interface for Lua v.5.1. +* Add mask for face drawing if one of symbols "-+=;oOsS~<>jdD*^" is specified in color scheme. This work only for export in bitmap images. +* Add Quality=8 for dots drawing (extremely fast). +* Add styles '4','6','8' for Cone() and Cones() to produce square, hex-, octo-prism. +* Add style 't' for Cones() to produce tubes (cylinders). +* Add style '^' for Legend() to left/right align legend if its coordinates are right/left from the center +* Add style '<', '^', '>' for aligning/centering boxes in Bars(), Barh(), BoxPlot(), Cones(). Also this plots become centered by default if nx sizes are the same for all data. +* Add Dots() function which set independently both color and alpha of dots +* Improve automatic axis position. Add style '^' for inverse automatic axis position. +* Improve tick labeling. Add style TuneTicks&4 for zero filling of tick labels. +* Add mglData::Refill() for filling by interpolation of parametrically dependent data +* Add transparency for Area() and Region() plots. +* Add mgl_clf_chr() function and extend 'clf' command. +* Fourier now perform true inverse Fourier transform (instead of backward one). +* Improve/change lighting from local sources. Add SetDiffuse() function. +* C functions now return NULL if HMDT data cannot be created for given input argument(s). +* Enable line width for Mesh() and Fall() plots. +* Replace +INF and -INF by NAN in textual formula output. +* Add manual compression of JSON. +* Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev). +* Bugfix for cleaning unused points. +* Fix 'setsize' command at UDAV starting. +* Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions. +* Minor bugfixes. +* Update docs. + +2.1.3.1 Released 8 May 2013 + +* Compatibility changes for MS VS. +* Bugfixes for cmake options enable-double=OFF, enable-zlib=OFF. +* Enable mouse actions for Firefox in JS sample. + +2.1.3 Released 2 May 2013 + +* Functions SinFFT, CosFFT, Hankel and so on, become multi-threaded +* Use DFT instead of FFT if GSL support is disabled (much slow!). +* Add Join() function for joining mglData arrays +* Add Roots() function for root finding of nonlinear equation using provided guess(es) +* Add mglExprC for parsing formula with complex numbers +* Correctly read #QNAN values in data files +* Speed up Dots() drawing +* Add flag to disable tick labels at axis origin (see SetOriginTick()) +* Add MGL commands 'origintick', 'tickshift' +* WriteJSON now use zlib if filename end at 'z' (like "test.jsonz") +* Make separate libmgl-mpi +* Add SetAutoRanges() function (duplicate corresponding options) +* Add JSON sample usage via QtWebKit (thanks to DATADVANCE) +* Bugfixes and memory leaks + +2.1.2 Released 28 January 2013 + +* Exclude "local" functions from resulting library. +* String in MGL script now can be concatenated with another string or data/numbers (like 'max(u)=',u.max,' a.u.'). +* Bugfix for colors in 3D PDF. +* Bugfix for drawing in MPI mode. +* If Aspect() function have NAN argument(s) then it try to select optimal aspect ratio. +* Option 'size' in Legend() now change only text size (not mark size). +* Option 'meshnum' now influence on Boxs() and Belt() functions +* Adjust marks drawing (line width and dots). +* Minor improvements and bugfixes. + +2.1.1 Released 24 December 2012 + +* Bugfix for SetRange(val,val) function +* Exclude export MGL to CPP +* MGL parsing now produce errors for any wrong list of arguments +* Add help message to mgl.cgi +* Improve text rotation at View() +* Make compatible with GIF library v.5.0. +* Bugfix for making MPI interface. +* Bugfix for running in Win32 mode. +* Update docs and MGL samples + +2.1 Released 13 December 2012 + +* Add class mglDataC for complex data arrays. +* Add mglData::Solve() for finding x-value where dat(x)=val. +* Add mglData::Clean() for removing rows with duplicate values for given column. +* Add Vect3() plot for drawing vectors on slice of 3d vector field. +* Add Table() function for drawing table with data values. +* Add ZoomAxis() for zooming/shifting axis range as whole. +* Add WriteJSON() function for exporting in JSON format suitable for later drawing by JavaScript +* Add JavaScript code for visualizing JSON data. +* Add mgl.cgi tool which return PNG image for CGI request in form of MGL script. +* Add MGL commands 'errbox', 'face' + +* Color can be specified as its RGB[A] values, i.e. like "{xFFFFFF}" or "{xFFFFFFFF}". +* Color in color scheme may have position in range [0,1]. Format is {CN,pos} or {xFFFFFF,pos}. +* Now pen width for marks is proportional to pen width of line multiplied by size of marks. +* Now you can use different font-faces in the plot simultaneously. +* Now Legend() automatically use several columns if it contain too many legend entries. +* Add style '-' for legend for drawing them horizontally. +* Vectors is drawn now even if only starting or ending points are placed in bounding box. +* Strongly rewrite the algorithm of vector field plotting. + +* Grid lines for NAN origin values are always located at far-away edges. +* Try correctly place axis and tick labels even for axis with inverse range (i.e. for v2 mglCanvas --> mglCanvasW --> mglCanvasQT, mglCanvasFL + | + ---------> mglCanvasGL --> mglCanvasGLUT + +(b) C&Fortran interface for plotting and data handlinng functions + +(c) Unified "inline" classes (mglGraph, mglData, mglWindow, ...), which + contain only inline members, which call C-functions. This make + MathGL completely cross-platform, i.e. the same binary files can be + used in any compiler (MinGW, MSVS, Borland, ...). Moreover it give + the same classes for all interfaces (Python/Octave/...). + +(d) MGL scripts use mglGraph's functions but give some extra + capabilities for axis setup or textual plot editing + +2. There is unified class mglGraph instead of set of mglGraphZB, + mglGraphPS, ... The quality<->speed level of plot is specified by + SetQuality() function. + +3. There is abstract class mglDataA which allow to derive classes with + its own data representation. However, I recommend to use mglData for + usual cases -- it have large set of built in functions. + +4. All plotting functions now have unified interface for arguments: + data objects or numbers; string with style; string with options. + Options (the same as ones in MGL v.1.*) allows one to make fine + tuning of plot. I.e. easily set the range of coordinates, plot + position, font size and so on. + +5. The last big change is style representation. There are differences + for colors and for text style: + +* Colors may have "brighted" version everywhere -- just specify '{cN}' + instead of 'c'. Here 'c' is base color id, 'N' is digit 1,2...9 for + brightness. Also the transparency can be changed by adding '{AN}'. + +* Text styles is reverted now -- to be unified with any other styles. + Color is placed firstly, then separator ':', and after it font styles + (bold, italic, wire, ...). + +Also there are a lot of other (not so general) changes and improvements. diff --git a/brush.ods b/brush.ods new file mode 100644 index 0000000..ae9110c Binary files /dev/null and b/brush.ods differ diff --git a/cmake-qt4.txt b/cmake-qt4.txt new file mode 100644 index 0000000..462e1f8 --- /dev/null +++ b/cmake-qt4.txt @@ -0,0 +1,10 @@ +set(MGL_HAVE_QT4 1) +if(enable-json-sample) +FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui QtNetwork QtWebKit) +else(enable-json-sample) +FIND_PACKAGE(Qt4 4.8 REQUIRED QtCore QtGui) +endif(enable-json-sample) +if(NOT QT4_FOUND) + message(SEND_ERROR "Couldn't find Qt4 library.") +endif(NOT QT4_FOUND) +include(${QT_USE_FILE}) diff --git a/cmake-qt5.txt b/cmake-qt5.txt new file mode 100644 index 0000000..49caf21 --- /dev/null +++ b/cmake-qt5.txt @@ -0,0 +1,26 @@ +set(MGL_HAVE_QT5 1) +find_package(Qt5Core REQUIRED) +find_package(Qt5Widgets REQUIRED) +find_package(Qt5Gui REQUIRED) +find_package(Qt5PrintSupport REQUIRED) +if(NOT Qt5Core_FOUND) + message(SEND_ERROR "Couldn't find Qt5 Core library.") +endif(NOT Qt5Core_FOUND) +if(NOT Qt5Gui_FOUND) + message(SEND_ERROR "Couldn't find Qt5 Gui library.") +endif(NOT Qt5Gui_FOUND) +if(NOT Qt5PrintSupport_FOUND) + message(SEND_ERROR "Couldn't find Qt5 PrintSupport library.") +endif(NOT Qt5PrintSupport_FOUND) +if(enable-json-sample) +find_package(Qt5Network REQUIRED) +find_package(Qt5WebKit REQUIRED) +if(NOT Qt5Network_FOUND) + message(SEND_ERROR "Couldn't find Qt5 Network library.") +endif(NOT Qt5Network_FOUND) +if(NOT Qt5WebKit_FOUND) + message(SEND_ERROR "Couldn't find Qt5 WebKit library.") +endif(NOT Qt5WebKit_FOUND) +endif(enable-json-sample) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/emblem.mgl b/emblem.mgl new file mode 100644 index 0000000..6c330c8 --- /dev/null +++ b/emblem.mgl @@ -0,0 +1,40 @@ +setsize 1000 500 +text 0.95 0.8 'MathGL' ':RiA' -4 +text 0.05 0.15 'library\n for scientific graphics' ':LiA' -2.5 +#rect 0.05 0.9 2 1.5 1.34 2 'w' +xtick -3:ytick -3:ztick -3 +subplot 1 1 0 '^_' + +stickplot 3 0 60 20:box +new y 50: fill y '-cos(pi*x-pi/4)' +new x 50: fill x '-sin(pi*x-pi/4)' +new z 50: fill z '2*x^2-1' + +area x y z 'lG' +plot x y z 'B2s' + +stickplot 3 1 60 20:box + +new aa 50 40 +modify aa '0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))' +mirror aa 'y' +light on :alpha on +surf aa 'BbcyrR';alpha 0.8 +cont aa 'y' + +stickplot 3 2 60 20:box +rotate 0 20 + +new a 61 51 40 +modify a '-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 - 0.1)' + +alpha on:light off +cloud a 'wyrRk' + +stop +cut 0 -1 -1 1 0 1.1 +surf3 a -1 'BbcyrR' +contf3 a 'x' -1 +contf3 a 'y' -1 +contf3 a 'z' 0 +contf3 a 'z' 39 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..0d0edaa --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,34 @@ +if(MGL_HAVE_GSL) + include_directories(${GSL_INCLUDE_DIR}) +endif(MGL_HAVE_GSL) + +add_executable(mgl_example wnd_samples.cpp full_test.cpp samples.cpp) +target_link_libraries(mgl_example mgl) + +if(MGL_HAVE_FLTK) + include_directories(${FLTK_INCLUDE_DIR}) + add_executable(mgl_fltk_example wnd_samples.cpp fltk_example.cpp) + target_link_libraries(mgl_fltk_example mgl-fltk) +endif(MGL_HAVE_FLTK) + +if(MGL_HAVE_GLUT) + add_executable(mgl_glut_example wnd_samples.cpp glut_example.cpp) + target_link_libraries(mgl_glut_example mgl-glut) +endif(MGL_HAVE_GLUT) + +if(MGL_HAVE_WX) + include(${wxWidgets_USE_FILE}) + add_executable(mgl_wx_example wnd_samples.cpp wx_example.cpp) + target_link_libraries(mgl_wx_example mgl-wx) +endif(MGL_HAVE_WX) + +if(enable-qt) + add_executable(mgl_qt_example wnd_samples.cpp qt_example.cpp ${MGL_MOC_EX_FILES}) + if(enable-qt5) + include(../cmake-qt5.txt) + target_link_libraries(mgl_qt_example mgl-qt5) + else(enable-qt5) + include(../cmake-qt4.txt) + target_link_libraries(mgl_qt_example mgl-qt4) + endif(enable-qt5) +endif(enable-qt) diff --git a/examples/fltk_example.cpp b/examples/fltk_example.cpp new file mode 100644 index 0000000..52cce1d --- /dev/null +++ b/examples/fltk_example.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** + * fltk_example.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/fltk.h" +//----------------------------------------------------------------------------- +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#include +#else +#include +#endif +void long_calculations() // just delay which correspond to simulate calculations +{ +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) + Sleep(1000); +#else + sleep(1); // which can be very long +#endif +} +//----------------------------------------------------------------------------- +#if defined(PTHREAD_SAMPLE1) // first variant of multi-threading usage of mglFLTK window +mglFLTK *gr=NULL; +void *calc(void *) +{ + mglPoint pnt; + for(int i=0;i<10;i++) // do calculation + { + long_calculations(); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + if(gr) + { + gr->Clf(); // make new drawing + gr->Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr->Puts(mglPoint(),str); + gr->Update(); // update window + } + } + exit(0); +} +int main(int argc,char **argv) +{ + static pthread_t thr; + pthread_create(&thr,0,calc,0); + pthread_detach(thr); + gr = new mglFLTK; + gr->Run(); return 0; +} +#elif defined(PTHREAD_SAMPLE2) // another variant of multi-threading usage of mglFLTK window. Work only if pthread was enabled for MathGL +mglPoint pnt; // some global variable for changeable data +int main(int argc,char **argv) +{ + mglFLTK gr("test"); + gr.RunThr(); // <-- need MathGL version which use pthread + for(int i=0;i<10;i++) // do calculation + { + long_calculations();// which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + gr.Clf(); // make new drawing + gr.Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[3] = '0'+i; + gr.Update(); // update window + } + return 0; // finish calculations and close the window +} +#else // just default samples +int test_wnd(mglGraph *gr); +int sample(mglGraph *gr); +int sample_1(mglGraph *gr); +int sample_2(mglGraph *gr); +int sample_3(mglGraph *gr); +int sample_d(mglGraph *gr); +//----------------------------------------------------------------------------- +int main(int argc,char **argv) +{ + mglFLTK *gr; + char key = 0; + if(argc>1) key = argv[1][0]!='-' ? argv[1][0]:argv[1][1]; + else printf("You may specify argument '1', '2', '3' or 'd' for viewing examples of 1d, 2d, 3d or dual plotting\n"); + switch(key) + { + case '1': gr = new mglFLTK(sample_1,"1D plots"); break; + case '2': gr = new mglFLTK(sample_2,"2D plots"); break; + case '3': gr = new mglFLTK(sample_3,"3D plots"); break; + case 'd': gr = new mglFLTK(sample_d,"Dual plots"); break; + case 't': gr = new mglFLTK(test_wnd,"Testing"); break; + default: gr = new mglFLTK(sample,"Drop and waves"); break; + } + gr->Run(); return 0; +} +#endif diff --git a/examples/full_test.cpp b/examples/full_test.cpp new file mode 100644 index 0000000..594a9dd --- /dev/null +++ b/examples/full_test.cpp @@ -0,0 +1,400 @@ +/*************************************************************************** + * full_test.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#if !defined(_MSC_VER) && !defined(__BORLANDC__) +#include +#endif +#include +#include "mgl2/mgl.h" +#include "mgl2/eval.h" +//----------------------------------------------------------------------------- +void mgl_create_cpp_font(HMGL gr, const wchar_t *how); +//----------------------------------------------------------------------------- +struct mglSample /// Structure for list of samples +{ + const char *name; + void (*func)(mglGraph*); + const char *mgl; +}; +extern mglSample samp[]; +extern const char *mmgl_dat_prepare; +//----------------------------------------------------------------------------- +int mgl_cmd_smp(const void *a, const void *b) +{ + const mglSample *aa = (const mglSample *)a; + const mglSample *bb = (const mglSample *)b; + return strcmp(aa->name, bb->name); +} +//----------------------------------------------------------------------------- +int type = 0; +int dotest = 0; +int width = 800; +int height = 600; +int big = 0; +int srnd = 0; +int use_mgl = 0; +int verbose = 0; +int quality = MGL_DRAW_NORM; +//----------------------------------------------------------------------------- +void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0); +void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0); +void mgls_prepare3d(mglData *a, mglData *b=0); +void mgls_prepare2v(mglData *a, mglData *b); +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez); +//----------------------------------------------------------------------------- +void save(mglGraph *gr,const char *name,const char *suf); +void smgl_stfa(mglGraph *gr); // STFA sample +void smgl_text(mglGraph *gr); // text drawing +void smgl_surf(mglGraph *gr); +#include +#include +void test(mglGraph *gr) +{ + union {unsigned long b;double d;float f;} t; t.b=0; + t.d = NAN; printf("NANd: %g --> %lx\t",t.d,t.b); t.b=0; + t.f = NAN; printf("NANf: %g --> %lx\n",t.f,t.b); t.b=0; + + t.d = INFINITY; printf("INFd: %g --> %lx\t",t.d,t.b); t.b=0; + t.f = INFINITY; printf("INFf: %g --> %lx\n",t.f,t.b); t.b=0; + +const unsigned long mgl_nan[2] = {0x7fffffffffffffff, 0x7fffffff}; +#define NANd (*(double*)mgl_nan) +#define NANf (*(float*)(mgl_nan+1)) + t.d = NANd; printf("NANd: %g --> %lx\t",t.d,t.b); t.b=0; + t.f = NANf; printf("NANf: %g --> %lx\n",t.f,t.b); t.b=0; + + +const unsigned long mgl_inf[2] = {0x7ff0000000000000, 0x7f800000}; +#define INFd (*(double*)mgl_inf) +#define INFf (*(float*)(mgl_inf+1)) + t.d = INFd; printf("INFd: %g --> %lx\t",t.d,t.b); t.b=0; + t.f = INFf; printf("INFf: %g --> %lx\n",t.f,t.b); t.b=0; + + return; + + mglData y(50); + y.Modify("sin(10*x) + 10"); + gr->SetRange('y', y); + gr->Box(); + gr->Axis(); + gr->Plot(y); + y.Save("test.dat"); + return; + + + mglParse par; + setlocale(LC_CTYPE, ""); + par.Execute(gr,"new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'\n\ + new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'\n\ + new z 50 40 '0.8*cos(pi*(y+1)/2)'\nlight on\n\ + title 'parametric form':rotate 50 60:box\n\ + surf x y z ''\nwrite '1.tex'"); +// par.Execute(gr,"light on:addlegend 'r' 'r':legend"); +} +//----------------------------------------------------------------------------- +#if !defined(_MSC_VER) && !defined(__BORLANDC__) +static struct option longopts[] = +{ + { "mini", no_argument, &big, 3 }, + { "big", no_argument, &big, 1 }, + { "web", no_argument, &big, 2 }, + { "bps", no_argument, &type, 8 }, + { "help", no_argument, NULL, '?' }, + { "height", required_argument, NULL, 'h' }, + { "png", no_argument, &type, 0 }, + { "eps", no_argument, &type, 1 }, + { "gif", no_argument, &type, 6 }, + { "jpeg", no_argument, &type, 4 }, + { "kind", required_argument, NULL, 'k' }, + { "list", no_argument, NULL, 'l' }, + { "mgl", no_argument, &use_mgl, 1 }, + { "none", no_argument, &type, 7 }, + { "obj", no_argument, &type, 11 }, + { "obj_old",no_argument, &type, 10 }, + { "off", no_argument, &type, 12 }, + { "prc", no_argument, &type, 5 }, + { "pdf", no_argument, &type, 9 }, + { "solid", no_argument, &type, 3 }, + { "srnd", no_argument, &srnd, 1 }, + { "svg", no_argument, &type, 2 }, + { "stl", no_argument, &type, 13 }, + { "tex", no_argument, &type, 14 }, + { "json", no_argument, &type, 15 }, + { "jsonz", no_argument, &type, 16 }, + { "test", no_argument, &dotest, 1 }, + { "font", no_argument, &dotest, 2 }, + { "time", no_argument, &dotest, 3 }, + { "thread", required_argument, NULL, 't' }, + { "verbose",no_argument, &verbose, 1 }, + { "width", required_argument, NULL, 'w' }, + { "quality",required_argument, NULL, 'q' }, + { NULL, 0, NULL, 0 } +}; +//----------------------------------------------------------------------------- +void usage() +{ + puts ( +// "--png - output png\n" + "--width=num - png picture width\n" + "--height=num - png picture height\n" + "--mini - png picture is 200x150\n" + "--big - png picture is 1920x1440\n" + "--web - png picture is 640x480\n" + "--prc - output prc\n" + "--pdf - output pdf\n" + "--eps - output EPS\n" + "--tex - output LaTeX\n" + "--jpeg - output JPEG\n" + "--json - output JSON\n" + "--jsonz - output JSONz\n" + "--solid - output solid PNG\n" + "--svg - output SVG\n" + "--obj - output obj/mtl\n" + "--obj_old - output obj/mtl in old way\n" + "--off - output off\n" + "--stl - output stl\n" + "--none - none output\n" + "--srnd - use the same random numbers in any run\n" + "--list - print list of sample names\n" + "--kind=name - produce only this sample\n" + "--thread=num - number of threads used\n" + "--mgl - use MGL scripts for samples\n" + "--test - run in test mode\n" + "--time - measure execution time for all samples\n" + "--font - write current font as C++ file\n" + "--quality=val - use specified quality for plot(s)\n" + ); +} +#endif +//----------------------------------------------------------------------------- +void save(mglGraph *gr,const char *name,const char *suf="") +{ + // return; + char buf[128]; + switch(type) + { + case 1: // EPS + snprintf(buf,128,"%s%s.eps",name,suf); + gr->WriteEPS(buf); + break; + case 2: // SVG + snprintf(buf,128,"%s%s.svg",name,suf); + gr->WriteSVG(buf); break; + case 3: // PNG + snprintf(buf,128,"%s%s.png",name,suf); + gr->WritePNG(buf,0,true); break; + case 4: // JPEG + snprintf(buf,128,"%s%s.jpg",name,suf); + gr->WriteJPEG(buf); break; + case 5: // PRC + snprintf(buf,128,"%s%s.prc",name,suf); + gr->WritePRC(buf,"",false); break; + case 6: // GIF + snprintf(buf,128,"%s%s.gif",name,suf); + gr->WriteGIF(buf); break; + case 7: gr->Finish(); // none + break; + case 8: // EPS to PNG + snprintf(buf,128,"%s%s.png",name,suf); + gr->WritePNG(buf,0,false); + break; + case 9: // PDF + snprintf(buf,128,"%s%s.prc",name,suf); + gr->WritePRC(buf); remove(buf); break; + case 10: // old OBJ + snprintf(buf,128,"%s%s.obj",name,suf); + gr->WriteOBJold(buf); break; + case 11: // OBJ + snprintf(buf,128,"%s%s.obj",name,suf); + gr->WriteOBJ(buf); break; + case 12: // OFF + snprintf(buf,128,"%s%s.off",name,suf); + gr->WriteOFF(buf); break; + case 13: // STL + snprintf(buf,128,"%s%s.stl",name,suf); + gr->WriteSTL(buf); break; + case 14: // TeX + snprintf(buf,128,"%s%s.tex",name,suf); + gr->WriteTEX(buf); break; + case 15: // JSON + snprintf(buf,128,"%s%s.json",name,suf); + gr->WriteJSON(buf); break; + case 16: // JSON + snprintf(buf,128,"%s%s.jsonz",name,suf); + gr->WriteJSON(buf,"",true); break; + default:// PNG (no alpha) +#if MGL_HAVE_PNG + snprintf(buf,128,"%s%s.png",name,suf); + gr->WritePNG(buf,0,false); break; +#else + snprintf(buf,128,"%s%s.bmp",name,suf); + gr->WriteBMP(buf); break; +#endif + } +} +//----------------------------------------------------------------------------- +int main(int argc,char **argv) +{ + const char *suf = ""; + char name[256]="", *tmp; + int ch; + time_t st,en; time(&st); + mglGraph *gr = NULL; + mglSample *s=samp; +#if !defined(_MSC_VER) && !defined(__BORLANDC__) + while(( ch = getopt_long_only(argc, argv, "", longopts, NULL)) != -1) + switch(ch) + { + case 0: break; + case 'w': width =atoi(optarg); break; + case 'h': height=atoi(optarg); break; + case 'q': quality =atoi(optarg); break; + case 'k': strncpy(name, optarg,256); + tmp=strchr(name,'.'); if(tmp) *tmp=0; + tmp=strchr(name,'-'); if(tmp) *tmp=0; + break; + case 't': mgl_set_num_thr(atoi(optarg)); break; + case 'l': + while(s->name[0]) { printf("%s ",s->name); s++; } + printf("\n"); return 0; + case '?': + default: usage(); return 0; + } +#endif + + if(dotest==1) printf("Global (before):%s\n",mglGlobalMess.c_str()); + gr = new mglGraph; + if( type==11|| type==12|| type==5 || type==9) width=height; + switch(big) + { + case 1: gr->SetSize(1920,1440); suf = "-lg"; break; + case 2: gr->SetSize(640,480); break; + case 3: gr->SetSize(192,144); suf = "-sm"; break; + default: gr->SetSize(width,height); + } + gr->SetQuality(quality); + + if(dotest==1) + { + mgl_set_test_mode(true); test(gr); + time(&en); printf("time is %g sec\n",difftime(en,st)); + gr->WritePNG("test.png","",false); + gr->WriteEPS("test.eps"); + printf("Messages:%s\n",gr->Message()); + printf("Global:%s\n",mglGlobalMess.c_str()); + delete gr; return 0; + } + else if(dotest==2) + { mgl_create_cpp_font(gr->Self(), L"!-~,¡-ÿ,̀-̏,Α-ω,ϑ,ϕ,ϖ,ϰ,ϱ,ϵ,А-я,ℏ,ℑ,ℓ,ℜ,←-↙,∀-∯,≠-≯,⟂"); + delete gr; return 0; } + else if(dotest==3) + { + int qual[7]={0,1,2,4,5,6,8}; + size_t ll=strlen(mmgl_dat_prepare)+1; + mglParse par; + par.AllowSetSize(true); setlocale(LC_CTYPE, ""); + FILE *fp = fopen(big?"time_big.texi":"time.texi","w"); + fprintf(fp,"@multitable @columnfractions .16 .12 .12 .12 .12 .12 .12 .12\n"); + fprintf(fp,"@headitem Name"); + for(int i=0;i<7;i++) fprintf(fp," @tab q=%d",qual[i]); + clock_t beg,end; + while(s->name[0]) // all samples + { + char *buf = new char[strlen(s->mgl)+ll]; + strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); + fprintf(fp,"\n@item %s",s->name); + + printf("%s",s->name); + for(int i=0;i<7;i++) + { + gr->DefaultPlotParam(); + gr->SetQuality(qual[i]); gr->Clf(); + beg = clock(); + if(!use_mgl) s->func(gr); + else par.Execute(gr,buf); + gr->Finish(); + end = clock(); + fprintf(fp," @tab %.3g",double(end-beg)/CLOCKS_PER_SEC); + printf("\t%d->%g",qual[i],double(end-beg)/CLOCKS_PER_SEC); + fflush(fp); fflush(stdout); + } + printf("\n"); delete []buf; s++; + } + fprintf(fp,"\n@end multitable\n"); fclose(fp); + } + + if(type==15 || type==16) big=3; // save mini version for json + + if(srnd) mgl_srnd(1); + gr->VertexColor(false); gr->Compression(false); + if(name[0]==0) + { + while(s->name[0]) // all samples + { + gr->DefaultPlotParam(); gr->Clf(); + if(use_mgl) + { + mglParse par; + par.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + char *buf = new char[strlen(s->mgl)+strlen(mmgl_dat_prepare)+1]; + strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); + printf("\n-------\n%s\n-------\n",verbose?buf:s->mgl); + par.Execute(gr,buf); delete []buf; + const char *mess = gr->Message(); + if(*mess) printf("Warnings: %s\n-------\n",mess); + } + else s->func(gr); + save(gr, s->name, suf); + printf("%s ",s->name); fflush(stdout); s++; + } + printf("\n"); + } + else // manual sample + { + mglSample tst; tst.name=name; + int i=0; + for(i=0;samp[i].name[0];i++); // determine the number of samples + s = (mglSample *) bsearch(&tst, samp, i, sizeof(mglSample), mgl_cmd_smp); + if(s) + { + gr->DefaultPlotParam(); gr->Clf(); + if(use_mgl) + { + mglParse par; + par.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + char *buf = new char[strlen(s->mgl)+strlen(mmgl_dat_prepare)+1]; + strcpy(buf,s->mgl); strcat(buf,mmgl_dat_prepare); + printf("\n-------\n%s\n-------\n",verbose?buf:s->mgl); + par.Execute(gr,buf); delete []buf; + const char *mess = gr->Message(); + if(*mess) printf("Warnings: %s\n-------\n",mess); + } + else s->func(gr); + save(gr, s->name, suf); + } + else printf("no sample %s\n",name); + } + delete gr; return 0; +} +//----------------------------------------------------------------------------- diff --git a/examples/glut_example.cpp b/examples/glut_example.cpp new file mode 100644 index 0000000..4018362 --- /dev/null +++ b/examples/glut_example.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * glut_example.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/glut.h" +//----------------------------------------------------------------------------- +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#include +#else +#include +#endif +void long_calculations() // just delay which correspond to simulate calculations +{ +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) + Sleep(1000); +#else + sleep(1); // which can be very long +#endif +} +//----------------------------------------------------------------------------- +#if defined(PTHREAD_SAMPLE) +mglGLUT *gr=NULL; +void *calc(void *) +{ + mglPoint pnt; + for(int i=0;i<10;i++) // do calculation + { + sleep(1); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); +printf("i=%d, gr=%p\n",i,gr); fflush(stdout); + if(gr) + { + gr->Clf(); // make new drawing + gr->Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr->Puts(mglPoint(),str); + gr->Update(); // update window + } + } + exit(0); +} +int main(int argc,char **argv) +{ + static pthread_t thr; + pthread_create(&thr,0,calc,0); + pthread_detach(thr); + gr = new mglGLUT; +printf("Create gr=%p\n",gr); fflush(stdout); + gr->Run(); return 0; +} +#else +int test_wnd(mglGraph *gr); +int sample(mglGraph *gr); +int sample_m(mglGraph *gr); +int sample_1(mglGraph *gr); +int sample_2(mglGraph *gr); +int sample_3(mglGraph *gr); +int sample_d(mglGraph *gr); +//----------------------------------------------------------------------------- +typedef int (*draw_func)(mglGraph *gr); +int main(int argc,char **argv) +{ + char key = 0; + if(argc>1) key = argv[1][0]!='-' ? argv[1][0] : argv[1][1]; + else printf("You may specify argument '1', '2', '3' or 'd' for viewing examples of 1d, 2d, 3d or dual plotting\n"); + mglGLUT *gr; + switch(key) + { + case '1': gr = new mglGLUT(sample_1, "1D plots"); break; + case '2': gr = new mglGLUT(sample_2, "2D plots"); break; + case '3': gr = new mglGLUT(sample_3, "3D plots"); break; + case 'd': gr = new mglGLUT(sample_d, "Dual plots"); break; + case 't': gr = new mglGLUT(test_wnd, "Testing"); break; + default: gr = new mglGLUT(sample, "Example of molecules"); break; + } + return 0; +} +#endif \ No newline at end of file diff --git a/examples/mpi_test.cpp b/examples/mpi_test.cpp new file mode 100644 index 0000000..7d32780 --- /dev/null +++ b/examples/mpi_test.cpp @@ -0,0 +1,39 @@ +#include +#include +#include +#define MCW MPI_COMM_WORLD + +int main(int argc, char *argv[]) +{ + // initialize MPI + int rank=0, numproc=1; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD,&numproc); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + if(rank==0) printf("Use %d processes.\n", numproc); + + // initialize data similarly for all ranks + mglData a(128,128); + mglGraphMPI gr; + // do the same plot for its own range + char buf[64]; + sprintf(buf,"xrange %g %g",2.*rank/numproc-1,2.*(rank+1)/numproc-1); + gr.Fill(a,"sin(2*pi*x)",buf); + // plot data in each rank + gr.Rotate(40,60); + gr.Surf(a,"",buf); + // collect information + if(rank!=0) gr.MPI_Send(0); + else for(int i=1;i * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/qt.h" +//----------------------------------------------------------------------------- +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#include +#else +#include +#endif +void long_calculations() // just delay which correspond to simulate calculations +{ +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) + Sleep(1000); +#else + sleep(1); // which can be very long +#endif +} +//----------------------------------------------------------------------------- +#if defined(PTHREAD_SAMPLE1) // first variant of multi-threading usage of mglQT window +mglQT *gr=NULL; +void *calc(void *) +{ + mglPoint pnt; + for(int i=0;i<10;i++) // do calculation + { + long_calculations(); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + if(gr) + { + gr->Clf(); // make new drawing + gr->Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr->Puts(mglPoint(),str); + gr->Update(); // update window + } + } + exit(0); +} +int main(int argc,char **argv) +{ + static pthread_t thr; + pthread_create(&thr,0,calc,0); + pthread_detach(thr); + gr = new mglQT; + gr->Run(); return 0; +} +#elif defined(PTHREAD_SAMPLE2) // another variant of multi-threading usage of mglQT window. Work only if pthread was enabled for MathGL +class Foo : public mglDraw +{ + mglPoint pnt; // some result of calculation +public: + mglWnd *Gr; // graphics to be updated + int Draw(mglGraph *gr); + void Calc(); +}; +void Foo::Calc() +{ + for(int i=0;i<30;i++) // do calculation + { + long_calculations(); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + Gr->Update(); // update window + } +} +int Foo::Draw(mglGraph *gr) +{ + gr->Line(mglPoint(),pnt,"Ar2"); + gr->Box(); + return 0; +} +int main(int argc,char **argv) +{ + Foo *foo = new Foo; + mglQT gr(foo,"MathGL examples"); + foo->Gr = &gr; + foo->Run(); // <-- need MathGL version which use pthread + return gr.Run(); +} +#else // just default samples +int test_wnd(mglGraph *gr); +int sample(mglGraph *gr); +int sample_1(mglGraph *gr); +int sample_2(mglGraph *gr); +int sample_3(mglGraph *gr); +int sample_d(mglGraph *gr); +//----------------------------------------------------------------------------- +int main(int argc,char **argv) +{ + mglQT *gr; + char key = 0; + if(argc>1) key = argv[1][0]!='-' ? argv[1][0]:argv[1][1]; + else printf("You may specify argument '1', '2', '3' or 'd' for viewing examples of 1d, 2d, 3d or dual plotting\n"); + switch(key) + { + case '1': gr = new mglQT(sample_1,"1D plots"); break; + case '2': gr = new mglQT(sample_2,"2D plots"); break; + case '3': gr = new mglQT(sample_3,"3D plots"); break; + case 'd': gr = new mglQT(sample_d,"Dual plots"); break; + case 't': gr = new mglQT(test_wnd,"Testing"); break; + default: gr = new mglQT(sample,"Drop and waves"); break; + } + gr->Run(); return 0; +} +#endif diff --git a/examples/samples.cpp b/examples/samples.cpp new file mode 100644 index 0000000..e3f4048 --- /dev/null +++ b/examples/samples.cpp @@ -0,0 +1,2759 @@ +/*************************************************************************** + * samples.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/mgl.h" +//----------------------------------------------------------------------------- +void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0); +void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0); +void mgls_prepare3d(mglData *a, mglData *b=0); +void mgls_prepare2v(mglData *a, mglData *b); +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez); +extern int big; +//----------------------------------------------------------------------------- +struct mglSample /// Structure for list of samples +{ + const char *name; + void (*func)(mglGraph*); + const char *mgl; +}; +//----------------------------------------------------------------------------- +// MGL functions for preparing data +//----------------------------------------------------------------------------- +const char *mmgl_dat_prepare = "\nstop\n\nfunc 'prepare1d'\n\ +new y 50 3\nmodify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)'\n\ +modify y 'sin(2*pi*x)' 1\nmodify y 'cos(2*pi*x)' 2\n\ +new x1 50 'x'\nnew x2 50 '0.05-0.03*cos(pi*x)'\n\ +new y1 50 '0.5-0.3*cos(pi*x)'\nnew y2 50 '-0.3*sin(pi*x)'\n\ +return\n\nfunc 'prepare2d'\n\ +new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\ +new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\ +return\n\nfunc 'prepare3d'\n\ +new c 61 50 40 '-2*(x^2+y^2+z^4-z^2)+0.2'\n\ +new d 61 50 40 '1-2*tanh((x+y)*(x+y))'\n\ +return\n\nfunc 'prepare2v'\n\ +new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\ +new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))'\n\ +return\n\nfunc 'prepare3v'\n\ +define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5)\n\ +define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5)\n\ +new ex 10 10 10 '0.2*x/$1-0.2*x/$2'\n\ +new ey 10 10 10 '0.2*y/$1-0.2*y/$2'\n\ +new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2'\nreturn\n"; +//----------------------------------------------------------------------------- +// Sample functions (v.2.*) +//----------------------------------------------------------------------------- +const char *mmgl_fexport=""; +#define splot1(b) {(b).Norm(-1,1,true);gr->Rotate(70,60);gr->Box();gr->Surf3(b);} +void smgl_fexport(mglGraph *gr) // test file export +{ + gr->SubPlot(3,2,0); + double d,x1,x2,x0,y=0.95; + d=0.3, x0=0.2, x1=0.5, x2=0.6; + gr->Line(mglPoint(x0,1-0*d),mglPoint(x1,1-0*d),"k-"); gr->Puts(mglPoint(x2,y-0*d),"Solid '-'",":rL"); + gr->Line(mglPoint(x0,1-1*d),mglPoint(x1,1-1*d),"k|"); gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'",":rL"); + gr->Line(mglPoint(x0,1-2*d),mglPoint(x1,1-2*d),"k;"); gr->Puts(mglPoint(x2,y-2*d),"Dash ';'",":rL"); + gr->Line(mglPoint(x0,1-3*d),mglPoint(x1,1-3*d),"k="); gr->Puts(mglPoint(x2,y-3*d),"Small dash '='",":rL"); + gr->Line(mglPoint(x0,1-4*d),mglPoint(x1,1-4*d),"kj"); gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'",":rL"); + gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki"); gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL"); + gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:"); gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL"); + gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k "); gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL"); + + d=0.25; x1=-1; x0=-0.8; y = -0.05; + gr->Mark(mglPoint(x1,5*d),"k."); gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL"); + gr->Mark(mglPoint(x1,4*d),"k+"); gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL"); + gr->Mark(mglPoint(x1,3*d),"kx"); gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL"); + gr->Mark(mglPoint(x1,2*d),"k*"); gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL"); + gr->Mark(mglPoint(x1,d),"ks"); gr->Puts(mglPoint(x0,y+d),"'s'",":rL"); + gr->Mark(mglPoint(x1,0),"kd"); gr->Puts(mglPoint(x0,y),"'d'",":rL"); + gr->Mark(mglPoint(x1,-d,0),"ko"); gr->Puts(mglPoint(x0,y-d),"'o'",":rL"); + gr->Mark(mglPoint(x1,-2*d,0),"k^"); gr->Puts(mglPoint(x0,y-2*d),"'\\^'",":rL"); + gr->Mark(mglPoint(x1,-3*d,0),"kv"); gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL"); + gr->Mark(mglPoint(x1,-4*d,0),"k<"); gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL"); + gr->Mark(mglPoint(x1,-5*d,0),"k>"); gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL"); + + d=0.25; x1=-0.5; x0=-0.3; y = -0.05; + gr->Mark(mglPoint(x1,5*d),"k#."); gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL"); + gr->Mark(mglPoint(x1,4*d),"k#+"); gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL"); + gr->Mark(mglPoint(x1,3*d),"k#x"); gr->Puts(mglPoint(x0,y+3*d),"'\\#x'",":rL"); + gr->Mark(mglPoint(x1,2*d),"k#*"); gr->Puts(mglPoint(x0,y+2*d),"'\\#*'",":rL"); + gr->Mark(mglPoint(x1,d),"k#s"); gr->Puts(mglPoint(x0,y+d),"'\\#s'",":rL"); + gr->Mark(mglPoint(x1,0),"k#d"); gr->Puts(mglPoint(x0,y),"'\\#d'",":rL"); + gr->Mark(mglPoint(x1,-d,0),"k#o"); gr->Puts(mglPoint(x0,y-d),"'\\#o'",":rL"); + gr->Mark(mglPoint(x1,-2*d,0),"k#^"); gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'",":rL"); + gr->Mark(mglPoint(x1,-3*d,0),"k#v"); gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL"); + gr->Mark(mglPoint(x1,-4*d,0),"k#<"); gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL"); + gr->Mark(mglPoint(x1,-5*d,0),"k#>"); gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL"); + + gr->SubPlot(3,2,1); + double a=0.1,b=0.4,c=0.5; + gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A"); gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL"); + gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V"); gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'",":rL"); + gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K"); gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'",":rL"); + gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I"); gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'",":rL"); + gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D"); gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'",":rL"); + gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S"); gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'",":rL"); + gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O"); gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'",":rL"); + gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T"); gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'",":rL"); + gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_"); gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none",":rL"); + gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS"); gr->Puts(mglPoint(c,-0.8),"Style 'AS'",":rL"); + gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A"); gr->Puts(mglPoint(c,-1),"Style '\\_A'",":rL"); + + a=-1; b=-0.7; c=-0.6; + gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA"); gr->Puts(mglPoint(c,1),"Style 'AA'",":rL"); + gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV"); gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL"); + gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK"); gr->Puts(mglPoint(c,0.6),"Style 'KK'",":rL"); + gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII"); gr->Puts(mglPoint(c,0.4),"Style 'II'",":rL"); + gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD"); gr->Puts(mglPoint(c,0.2),"Style 'DD'",":rL"); + gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS"); gr->Puts(mglPoint(c,0),"Style 'SS'",":rL"); + gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO"); gr->Puts(mglPoint(c,-0.2),"Style 'OO'",":rL"); + gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT"); gr->Puts(mglPoint(c,-0.4),"Style 'TT'",":rL"); + gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__"); gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'",":rL"); + gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA"); gr->Puts(mglPoint(c,-0.8),"Style 'VA'",":rL"); + gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV"); gr->Puts(mglPoint(c,-1),"Style 'AV'",":rL"); + + gr->SubPlot(3,2,2); + //#LENUQ + gr->FaceZ(mglPoint(-1, -1), 0.4, 0.3, "L#"); gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-1), 0.4, 0.3, "E#"); gr->Puts(mglPoint(-0.4,-0.9), "E", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-1), 0.4, 0.3, "N#"); gr->Puts(mglPoint(0, -0.9), "N", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, -1), 0.4, 0.3, "U#"); gr->Puts(mglPoint(0.4,-0.9), "U", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, -1), 0.4, 0.3, "Q#"); gr->Puts(mglPoint(0.8,-0.9), "Q", "w:C", -1.4); + //#lenuq + gr->FaceZ(mglPoint(-1, -0.7), 0.4, 0.3, "l#"); gr->Puts(mglPoint(-0.8,-0.6), "l", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.7), 0.4, 0.3, "e#"); gr->Puts(mglPoint(-0.4,-0.6), "e", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.7), 0.4, 0.3, "n#"); gr->Puts(mglPoint(0, -0.6), "n", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.7), 0.4, 0.3, "u#"); gr->Puts(mglPoint(0.4,-0.6), "u", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.7), 0.4, 0.3, "q#"); gr->Puts(mglPoint(0.8,-0.6), "q", "k:C", -1.4); + //#CMYkP + gr->FaceZ(mglPoint(-1, -0.4), 0.4, 0.3, "C#"); gr->Puts(mglPoint(-0.8,-0.3), "C", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.4), 0.4, 0.3, "M#"); gr->Puts(mglPoint(-0.4,-0.3), "M", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.4), 0.4, 0.3, "Y#"); gr->Puts(mglPoint(0, -0.3), "Y", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.4), 0.4, 0.3, "k#"); gr->Puts(mglPoint(0.4,-0.3), "k", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.4), 0.4, 0.3, "P#"); gr->Puts(mglPoint(0.8,-0.3), "P", "w:C", -1.4); + //#cmywp + gr->FaceZ(mglPoint(-1, -0.1), 0.4, 0.3, "c#"); gr->Puts(mglPoint(-0.8, 0), "c", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.1), 0.4, 0.3, "m#"); gr->Puts(mglPoint(-0.4, 0), "m", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.1), 0.4, 0.3, "y#"); gr->Puts(mglPoint(0, 0), "y", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.1), 0.4, 0.3, "w#"); gr->Puts(mglPoint(0.4, 0), "w", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.1), 0.4, 0.3, "p#"); gr->Puts(mglPoint(0.8, 0), "p", "k:C", -1.4); + //#BGRHW + gr->FaceZ(mglPoint(-1, 0.2), 0.4, 0.3, "B#"); gr->Puts(mglPoint(-0.8, 0.3), "B", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.2), 0.4, 0.3, "G#"); gr->Puts(mglPoint(-0.4, 0.3), "G", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.2), 0.4, 0.3, "R#"); gr->Puts(mglPoint(0, 0.3), "R", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.2), 0.4, 0.3, "H#"); gr->Puts(mglPoint(0.4, 0.3), "H", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.2), 0.4, 0.3, "W#"); gr->Puts(mglPoint(0.8, 0.3), "W", "w:C", -1.4); + //#bgrhw + gr->FaceZ(mglPoint(-1, 0.5), 0.4, 0.3, "b#"); gr->Puts(mglPoint(-0.8, 0.6), "b", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.5), 0.4, 0.3, "g#"); gr->Puts(mglPoint(-0.4, 0.6), "g", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.5), 0.4, 0.3, "r#"); gr->Puts(mglPoint(0, 0.6), "r", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.5), 0.4, 0.3, "h#"); gr->Puts(mglPoint(0.4, 0.6), "h", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.5), 0.4, 0.3, "w#"); gr->Puts(mglPoint(0.8, 0.6), "w", "k:C", -1.4); + //#brighted + gr->FaceZ(mglPoint(-1, 0.8), 0.4, 0.3, "{r1}#"); gr->Puts(mglPoint(-0.8, 0.9), "\\{r1\\}", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.8), 0.4, 0.3, "{r3}#"); gr->Puts(mglPoint(-0.4, 0.9), "\\{r3\\}", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.8), 0.4, 0.3, "{r5}#"); gr->Puts(mglPoint(0, 0.9), "\\{r5\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.8), 0.4, 0.3, "{r7}#"); gr->Puts(mglPoint(0.4, 0.9), "\\{r7\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.8), 0.4, 0.3, "{r9}#"); gr->Puts(mglPoint(0.8, 0.9), "\\{r9\\}", "k:C", -1.4); + // HEX + gr->FaceZ(mglPoint(-1, -1.3), 1, 0.3, "{xff9966}#"); gr->Puts(mglPoint(-0.5,-1.2), "\\{xff9966\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0, -1.3), 1, 0.3, "{x83CAFF}#"); gr->Puts(mglPoint( 0.5,-1.2), "\\{x83CAFF\\}", "k:C", -1.4); + + gr->SubPlot(3,2,3); + char stl[3]="r1", txt[4]="'1'"; + for(int i=0;i<10;i++) + { + txt[1]=stl[1]='0'+i; + gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl); + gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L"); + } + + gr->SubPlot(3,2,4); gr->Title("TriPlot sample"); gr->Rotate(50,60); + double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; + double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; + mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); + gr->TriPlot(tt,uu,vv,ww,"b"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + + gr->SubPlot(3,2,5); + mglData r(4); r.Fill(1,4); + gr->SetRanges(1,4,1,4); gr->Axis(); + gr->Mark(r,r,"s"); + gr->Plot(r,"b"); + + gr->WriteJPEG("fexport.jpg"); + gr->WritePNG("fexport.png"); + gr->WriteBMP("fexport.bmp"); + gr->WriteTGA("fexport.tga"); + gr->WriteEPS("fexport.eps"); + gr->WriteSVG("fexport.svg"); + gr->WriteGIF("fexport.gif"); + + gr->WriteXYZ("fexport.xyz"); + gr->WriteSTL("fexport.stl"); + gr->WriteOFF("fexport.off"); + gr->WriteTEX("fexport.tex"); + gr->WriteOBJ("fexport.obj"); + gr->WritePRC("fexport.prc"); +} +//----------------------------------------------------------------------------- +const char *mmgl_refill="new x 10 '0.5+rnd':cumsum x 'x':norm x -1 1\n" +"copy y sin(pi*x)/2\nsubplot 1 1 0 '<_':title 'Refill sample'\nbox:axis:plot x y 'o '\n" +"new r 100:refill r x y\nplot r 'r'\nfplot 'sin(pi*x)/2' 'B:'"; +void smgl_refill(mglGraph *gr) +{ + mglData x(10), y(10), r(100); + x.Modify("0.5+rnd"); x.CumSum("x"); x.Norm(-1,1); + y.Modify("sin(pi*v)/2",x); + if(big!=3) { gr->SubPlot(1,1,0,"<_"); gr->Title("Refill sample"); } + gr->Axis(); gr->Box(); gr->Plot(x,y,"o "); + gr->Refill(r,x,y); // or you can use r.Refill(x,y,-1,1); + gr->Plot(r,"r"); gr->FPlot("sin(pi*x)/2","B:"); +} +//----------------------------------------------------------------------------- +const char *mmgl_correl="new a 100 'exp(-10*x^2)'\n" +"new b 100 'exp(-10*(x+0.5)^2)'\n" +"yrange 0 1\nsubplot 1 2 0 '_':title 'Input fields'\n" +"plot a:plot b:box:axis\n" +"correl r a b 'x'\nnorm r 0 1:swap r 'x' # make it human readable\n" +"subplot 1 2 1 '_':title 'Correlation of a and b'\n" +"plot r 'r':axis:box\nline 0.5 0 0.5 1 'B|'\n"; +void smgl_correl(mglGraph *gr) +{ + mglData a(100),b(100); + gr->Fill(a,"exp(-10*x^2)"); gr->Fill(b,"exp(-10*(x+0.5)^2)"); + gr->SetRange('y',0,1); + gr->SubPlot(1,2,0,"_"); gr->Title("Input fields"); + gr->Plot(a); gr->Plot(b); gr->Axis(); gr->Box(); + mglData r = a.Correl(b,"x"); + r.Norm(0,1); r.Swap("x"); // make it human readable + gr->SubPlot(1,2,1,"_"); gr->Title("Correlation of a and b"); + gr->Plot(r,"r"); gr->Axis(); gr->Box(); + gr->Line(mglPoint(0.5,0),mglPoint(0.5,1),"B|"); +} +//----------------------------------------------------------------------------- +const char *mmgl_mask="new a 10 10 'x'\n" +"subplot 5 4 0 '':title '\"-\" mask':dens a '3-'\n" +"subplot 5 4 1 '':title '\"+\" mask':dens a '3+'\n" +"subplot 5 4 2 '':title '\"=\" mask':dens a '3='\n" +"subplot 5 4 3 '':title '\";\" mask':dens a '3;'\n" +"subplot 5 4 4 '':title '\";I\" mask':dens a '3;I'\n" +"subplot 5 4 5 '':title '\"o\" mask':dens a '3o'\n" +"subplot 5 4 6 '':title '\"O\" mask':dens a '3O'\n" +"subplot 5 4 7 '':title '\"s\" mask':dens a '3s'\n" +"subplot 5 4 8 '':title '\"S\" mask':dens a '3S'\n" +"subplot 5 4 9 '':title '\";/\" mask':dens a '3;/'\n" +"subplot 5 4 10 '':title '\"~\" mask':dens a '3~'\n" +"subplot 5 4 11 '':title '\"<\" mask':dens a '3<'\n" +"subplot 5 4 12 '':title '\">\" mask':dens a '3>'\n" +"subplot 5 4 13 '':title '\"j\" mask':dens a '3j'\n" +"subplot 5 4 14 '':title '\"-;\\\" mask':dens a '3;\\ '\n" +"subplot 5 4 15 '':title '\"d\" mask':dens a '3d'\n" +"subplot 5 4 16 '':title '\"D\" mask':dens a '3D'\n" +"subplot 5 4 17 '':title '\"*\" mask':dens a '3*'\n" +"subplot 5 4 18 '':title '\"^\" mask':dens a '3^'\n" +"subplot 5 4 19 '':title 'manual mask'\n" +"mask '+' 'ff00182424f80000':dens a '3+'"; +void smgl_mask(mglGraph *gr) +{ + mglData a(10,10); a.Fill(-1,1); + gr->SubPlot(5,4,0,""); gr->Title("'-' mask"); gr->Dens(a,"3-"); + gr->SubPlot(5,4,1,""); gr->Title("'+' mask"); gr->Dens(a,"3+"); + gr->SubPlot(5,4,2,""); gr->Title("'=' mask"); gr->Dens(a,"3="); + gr->SubPlot(5,4,3,""); gr->Title("';' mask"); gr->Dens(a,"3;"); + gr->SubPlot(5,4,4,""); gr->Title("';I' mask"); gr->Dens(a,"3;I"); + gr->SubPlot(5,4,5,""); gr->Title("'o' mask"); gr->Dens(a,"3o"); + gr->SubPlot(5,4,6,""); gr->Title("'O' mask"); gr->Dens(a,"3O"); + gr->SubPlot(5,4,7,""); gr->Title("'s' mask"); gr->Dens(a,"3s"); + gr->SubPlot(5,4,8,""); gr->Title("'S' mask"); gr->Dens(a,"3S"); + gr->SubPlot(5,4,9,""); gr->Title("';/' mask"); gr->Dens(a,"3;/"); + gr->SubPlot(5,4,10,""); gr->Title("'~' mask"); gr->Dens(a,"3~"); + gr->SubPlot(5,4,11,""); gr->Title("'<' mask"); gr->Dens(a,"3<"); + gr->SubPlot(5,4,12,""); gr->Title("'>' mask"); gr->Dens(a,"3>"); + gr->SubPlot(5,4,13,""); gr->Title("'j' mask"); gr->Dens(a,"3j"); + gr->SubPlot(5,4,14,""); gr->Title("';\\\\' mask"); gr->Dens(a,"3;\\"); + gr->SubPlot(5,4,15,""); gr->Title("'d' mask"); gr->Dens(a,"3d"); + gr->SubPlot(5,4,16,""); gr->Title("'D' mask"); gr->Dens(a,"3D"); + gr->SubPlot(5,4,17,""); gr->Title("'*' mask"); gr->Dens(a,"3*"); + gr->SubPlot(5,4,18,""); gr->Title("'^' mask"); gr->Dens(a,"3^"); + gr->SubPlot(5,4,19,""); gr->Title("manual mask"); + gr->SetMask('+', "ff00182424f80000"); gr->Dens(a,"3+"); +} +//----------------------------------------------------------------------------- +const char *mmgl_export="new a 100 100 'x^2*y':new b 100 100\n" +"export a 'test_data.png' 'BbcyrR' -1 1\n" +"import b 'test_data.png' 'BbcyrR' -1 1\n" +"subplot 2 1 0 '':title 'initial':box:dens a\n" +"subplot 2 1 1 '':title 'imported':box:dens b"; +void smgl_export(mglGraph *gr) // basic data operations +{ + mglData a(100,100), b; gr->Fill(a,"x^2*y"); + a.Export("test_data.png","BbcyrR"); + b.Import("test_data.png","BbcyrR",-1,1); + gr->SubPlot(2,1,0,""); gr->Title("initial"); gr->Box(); gr->Dens(a); + gr->SubPlot(2,1,1,""); gr->Title("imported"); gr->Box(); gr->Dens(b); +} +//----------------------------------------------------------------------------- +const char *mmgl_data1="new a 40 50 60 'exp(-x^2-4*y^2-16*z^2)'\n" +"light on:alpha on\n" +"copy b a:diff b 'x':subplot 5 3 0:call 'splot'\n" +"copy b a:diff2 b 'x':subplot 5 3 1:call 'splot'\n" +"copy b a:cumsum b 'x':subplot 5 3 2:call 'splot'\n" +"copy b a:integrate b 'x':subplot 5 3 3:call 'splot'\n" +"mirror b 'x':subplot 5 3 4:call 'splot'\n" +"copy b a:diff b 'y':subplot 5 3 5:call 'splot'\n" +"copy b a:diff2 b 'y':subplot 5 3 6:call 'splot'\n" +"copy b a:cumsum b 'y':subplot 5 3 7:call 'splot'\n" +"copy b a:integrate b 'y':subplot 5 3 8:call 'splot'\n" +"mirror b 'y':subplot 5 3 9:call 'splot'\n" +"copy b a:diff b 'z':subplot 5 3 10:call 'splot'\n" +"copy b a:diff2 b 'z':subplot 5 3 11:call 'splot'\n" +"copy b a:cumsum b 'z':subplot 5 3 12:call 'splot'\n" +"copy b a:integrate b 'z':subplot 5 3 13:call 'splot'\n" +"mirror b 'z':subplot 5 3 14:call 'splot'\n" +"stop\nfunc splot 0\n" +"title 'max=',b.max:norm b -1 1 on:rotate 70 60:box:surf3 b\n" +"return\n"; +#define splot1(b) {(b).Norm(-1,1,true);gr->Rotate(70,60);gr->Box();gr->Surf3(b);} +void smgl_data1(mglGraph *gr) // basic data operations +{ + mglData a(40,50,60),b; gr->Fill(a,"exp(-x^2-4*y^2-16*z^2)"); + gr->Light(true); gr->Alpha(true); + b.Set(a); b.Diff("x"); gr->SubPlot(5,3,0); splot1(b); + b.Set(a); b.Diff2("x"); gr->SubPlot(5,3,1); splot1(b); + b.Set(a); b.CumSum("x"); gr->SubPlot(5,3,2); splot1(b); + b.Set(a); b.Integral("x");gr->SubPlot(5,3,3); splot1(b); + b.Mirror("x"); gr->SubPlot(5,3,4); splot1(b); + b.Set(a); b.Diff("y"); gr->SubPlot(5,3,5); splot1(b); + b.Set(a); b.Diff2("y"); gr->SubPlot(5,3,6); splot1(b); + b.Set(a); b.CumSum("y"); gr->SubPlot(5,3,7); splot1(b); + b.Set(a); b.Integral("y");gr->SubPlot(5,3,8); splot1(b); + b.Mirror("y"); gr->SubPlot(5,3,9); splot1(b); + b.Set(a); b.Diff("z"); gr->SubPlot(5,3,10);splot1(b); + b.Set(a); b.Diff2("z"); gr->SubPlot(5,3,11);splot1(b); + b.Set(a); b.CumSum("z"); gr->SubPlot(5,3,12);splot1(b); + b.Set(a); b.Integral("z");gr->SubPlot(5,3,13);splot1(b); + b.Mirror("z"); gr->SubPlot(5,3,14);splot1(b); +} +//----------------------------------------------------------------------------- +const char *mmgl_data2="new a 40 50 60 'exp(-x^2-4*y^2-16*z^2)'\n" +"light on:alpha on\n" +"copy b a:sinfft b 'x':subplot 5 3 0:call 'splot'\n" +"copy b a:cosfft b 'x':subplot 5 3 1:call 'splot'\n" +"copy b a:hankel b 'x':subplot 5 3 2:call 'splot'\n" +"copy b a:swap b 'x':subplot 5 3 3:call 'splot'\n" +"copy b a:smooth b 'x':subplot 5 3 4:call 'splot'\n" +"copy b a:sinfft b 'y':subplot 5 3 5:call 'splot'\n" +"copy b a:cosfft b 'y':subplot 5 3 6:call 'splot'\n" +"copy b a:hankel b 'y':subplot 5 3 7:call 'splot'\n" +"copy b a:swap b 'y':subplot 5 3 8:call 'splot'\n" +"copy b a:smooth b 'y':subplot 5 3 9:call 'splot'\n" +"copy b a:sinfft b 'z':subplot 5 3 10:call 'splot'\n" +"copy b a:cosfft b 'z':subplot 5 3 11:call 'splot'\n" +"copy b a:hankel b 'z':subplot 5 3 12:call 'splot'\n" +"copy b a:swap b 'z':subplot 5 3 13:call 'splot'\n" +"copy b a:smooth b 'z':subplot 5 3 14:call 'splot'\n" +"stop\nfunc splot 0\n" +"title 'max=',b.max:norm b -1 1 on:rotate 70 60:box\n" +"surf3 b 0.5:surf3 b -0.5\nreturn\n"; +#define splot2(b) {(b).Norm(-1,1,true);gr->Rotate(70,60);gr->Box();gr->Surf3(0.5,b);gr->Surf3(-0.5,b);} +void smgl_data2(mglGraph *gr) // data transforms +{ + mglData a(40,50,60),b; gr->Fill(a,"exp(-x^2-4*y^2-16*z^2)"); + gr->Light(true); gr->Alpha(true); + b.Set(a); b.SinFFT("x"); gr->SubPlot(5,3,0); splot2(b); + b.Set(a); b.CosFFT("x"); gr->SubPlot(5,3,1); splot2(b); + b.Set(a); b.Hankel("x"); gr->SubPlot(5,3,2); splot2(b); + b.Set(a); b.Swap("x"); gr->SubPlot(5,3,3); splot2(b); + b.Set(a); b.Smooth("x"); gr->SubPlot(5,3,4); splot2(b); + b.Set(a); b.SinFFT("y"); gr->SubPlot(5,3,5); splot2(b); + b.Set(a); b.CosFFT("y"); gr->SubPlot(5,3,6); splot2(b); + b.Set(a); b.Hankel("y"); gr->SubPlot(5,3,7); splot2(b); + b.Set(a); b.Swap("y"); gr->SubPlot(5,3,8); splot2(b); + b.Set(a); b.Smooth("y"); gr->SubPlot(5,3,9); splot2(b); + b.Set(a); b.SinFFT("z"); gr->SubPlot(5,3,10);splot2(b); + b.Set(a); b.CosFFT("z"); gr->SubPlot(5,3,11);splot2(b); + b.Set(a); b.Hankel("z"); gr->SubPlot(5,3,12);splot2(b); + b.Set(a); b.Swap("z"); gr->SubPlot(5,3,13);splot2(b); + b.Set(a); b.Smooth("z"); gr->SubPlot(5,3,14);splot2(b); +} +//----------------------------------------------------------------------------- +const char *mmgl_param1="new x 100 'sin(pi*x)'\nnew y 100 'cos(pi*x)'\n" +"new z 100 'sin(2*pi*x)'\nnew c 100 'cos(2*pi*x)'\n\n" +"subplot 4 3 0:rotate 40 60:box:plot x y z\n" +"subplot 4 3 1:rotate 40 60:box:area x y z\n" +"subplot 4 3 2:rotate 40 60:box:tens x y z c\n" +"subplot 4 3 3:rotate 40 60:box:bars x y z\n" +"subplot 4 3 4:rotate 40 60:box:stem x y z\n" +"subplot 4 3 5:rotate 40 60:box:textmark x y z c*2 '\\alpha'\n" +"subplot 4 3 6:rotate 40 60:box:tube x y z c/10\n" +"subplot 4 3 7:rotate 40 60:box:mark x y z c 's'\n" +"subplot 4 3 8:box:error x y z/10 c/10\n" +"subplot 4 3 9:rotate 40 60:box:step x y z\n" +"subplot 4 3 10:rotate 40 60:box:torus x z 'z';light on\n" +"subplot 4 3 11:rotate 40 60:box:label x y z '%z'\n"; +void smgl_param1(mglGraph *gr) // 1d parametric plots +{ + mglData x(100), y(100), z(100), c(100); + gr->Fill(x,"sin(pi*x)"); gr->Fill(y,"cos(pi*x)"); + gr->Fill(z,"sin(2*pi*x)"); gr->Fill(c,"cos(2*pi*x)"); + + gr->SubPlot(4,3,0); gr->Rotate(40,60); gr->Box(); gr->Plot(x,y,z); + gr->SubPlot(4,3,1); gr->Rotate(40,60); gr->Box(); gr->Area(x,y,z); + gr->SubPlot(4,3,2); gr->Rotate(40,60); gr->Box(); gr->Tens(x,y,z,c); + gr->SubPlot(4,3,3); gr->Rotate(40,60); gr->Box(); gr->Bars(x,y,z); + gr->SubPlot(4,3,4); gr->Rotate(40,60); gr->Box(); gr->Stem(x,y,z); + gr->SubPlot(4,3,5); gr->Rotate(40,60); gr->Box(); gr->TextMark(x,y,z,c*2,"\\alpha"); + gr->SubPlot(4,3,6); gr->Rotate(40,60); gr->Box(); gr->Tube(x,y,z,c/10,"","light on"); + gr->SubPlot(4,3,7); gr->Rotate(40,60); gr->Box(); gr->Mark(x,y,z,c,"s"); + gr->SubPlot(4,3,8); gr->Rotate(40,60); gr->Box(); gr->Error(x,y,z/10,c/10); + gr->SubPlot(4,3,9); gr->Rotate(40,60); gr->Box(); gr->Step(x,y,z); + gr->SubPlot(4,3,10);gr->Rotate(40,60); gr->Box(); gr->Torus(x,z,"z","light on"); + gr->SubPlot(4,3,11);gr->Rotate(40,60); gr->Box(); gr->Label(x,y,z,"%z"); +} +//----------------------------------------------------------------------------- +const char *mmgl_param2="new x 100 100 'sin(pi*(x+y)/2)*cos(pi*y/2)'\n" +"new y 100 100 'cos(pi*(x+y)/2)*cos(pi*y/2)'\n" +"new z 100 100 'sin(pi*y/2)'\nnew c 100 100 'cos(pi*x)'\n\n" +"subplot 4 4 0:rotate 40 60:box:surf x y z\n" +"subplot 4 4 1:rotate 40 60:box:surfc x y z c\n" +"subplot 4 4 2:rotate 40 60:box:surfa x y z c;alpha 1\n" +"subplot 4 4 3:rotate 40 60:box:mesh x y z;meshnum 10\n" +"subplot 4 4 4:rotate 40 60:box:tile x y z;meshnum 10\n" +"subplot 4 4 5:rotate 40 60:box:tiles x y z c;meshnum 10\n" +"subplot 4 4 6:rotate 40 60:box:axial x y z;alpha 0.5;light on\n" +"subplot 4 4 7:rotate 40 60:box:cont x y z\n" +"subplot 4 4 8:rotate 40 60:box:contf x y z;light on:contv x y z;light on\n" +"subplot 4 4 9:rotate 40 60:box:belt x y z 'x';meshnum 10;light on\n" +"subplot 4 4 10:rotate 40 60:box:dens x y z;alpha 0.5\n" +"subplot 4 4 11:rotate 40 60:box\n" +"fall x y z 'g';meshnum 10:fall x y z 'rx';meshnum 10\n" +"subplot 4 4 12:rotate 40 60:box:belt x y z '';meshnum 10;light on\n" +"subplot 4 4 13:rotate 40 60:box:boxs x y z '';meshnum 10;light on\n" +"subplot 4 4 14:rotate 40 60:box:boxs x y z '#';meshnum 10;light on\n" +"subplot 4 4 15:rotate 40 60:box:boxs x y z '@';meshnum 10;light on\n"; +void smgl_param2(mglGraph *gr) // 2d parametric plots +{ + mglData x(100,100), y(100,100), z(100,100), c(100,100); + gr->Fill(x,"sin(pi*(x+y)/2)*cos(pi*y/2)"); gr->Fill(y,"cos(pi*(x+y)/2)*cos(pi*y/2)"); + gr->Fill(z,"sin(pi*y/2)"); gr->Fill(c,"cos(pi*x)"); + + gr->SubPlot(4,4,0); gr->Rotate(40,60); gr->Box(); gr->Surf(x,y,z); + gr->SubPlot(4,4,1); gr->Rotate(40,60); gr->Box(); gr->SurfC(x,y,z,c); + gr->SubPlot(4,4,2); gr->Rotate(40,60); gr->Box(); gr->SurfA(x,y,z,c,"","alpha 1"); + gr->SubPlot(4,4,3); gr->Rotate(40,60); gr->Box(); gr->Mesh(x,y,z,"","meshnum 10"); + gr->SubPlot(4,4,4); gr->Rotate(40,60); gr->Box(); gr->Tile(x,y,z,"","meshnum 10"); + gr->SubPlot(4,4,5); gr->Rotate(40,60); gr->Box(); gr->TileS(x,y,z,c,"","meshnum 10"); + gr->SubPlot(4,4,6); gr->Rotate(40,60); gr->Box(); gr->Axial(x,y,z,"","alpha 0.5;light on"); + gr->SubPlot(4,4,7); gr->Rotate(40,60); gr->Box(); gr->Cont(x,y,z); + gr->SubPlot(4,4,8); gr->Rotate(40,60); gr->Box(); gr->ContF(x,y,z,"","light on"); gr->ContV(x,y,z,"","light on"); + gr->SubPlot(4,4,9); gr->Rotate(40,60); gr->Box(); gr->Belt(x,y,z,"x","meshnum 10;light on"); + gr->SubPlot(4,4,10);gr->Rotate(40,60); gr->Box(); gr->Dens(x,y,z,"","alpha 0.5"); + gr->SubPlot(4,4,11);gr->Rotate(40,60); gr->Box(); + gr->Fall(x,y,z,"g","meshnum 10"); gr->Fall(x,y,z,"rx","meshnum 10"); + gr->SubPlot(4,4,12); gr->Rotate(40,60); gr->Box(); gr->Belt(x,y,z,"","meshnum 10;light on"); + gr->SubPlot(4,4,13); gr->Rotate(40,60); gr->Box(); gr->Boxs(x,y,z,"","meshnum 10;light on"); + gr->SubPlot(4,4,14); gr->Rotate(40,60); gr->Box(); gr->Boxs(x,y,z,"#","meshnum 10"); + gr->SubPlot(4,4,15); gr->Rotate(40,60); gr->Box(); gr->Boxs(x,y,z,"@","meshnum 10;light on"); +} +//----------------------------------------------------------------------------- +const char *mmgl_param3="new x 50 50 50 '(x+2)/3*sin(pi*y/2)'\n" +"new y 50 50 50 '(x+2)/3*cos(pi*y/2)'\nnew z 50 50 50 'z'\n" +"new c 50 50 50 '-2*(x^2+y^2+z^4-z^2)+0.2'\n" +"new d 50 50 50 '1-2*tanh(2*(x+y)^2)'\n\n" +"alpha on:light on\n" +"subplot 4 3 0:rotate 40 60:box:surf3 x y z c\n" +"subplot 4 3 1:rotate 40 60:box:surf3c x y z c d\n" +"subplot 4 3 2:rotate 40 60:box:surf3a x y z c d\n" +"subplot 4 3 3:rotate 40 60:box:cloud x y z c\n" +"subplot 4 3 4:rotate 40 60:box:cont3 x y z c:cont3 x y z c 'x':cont3 x y z c 'z'\n" +"subplot 4 3 5:rotate 40 60:box:contf3 x y z c:contf3 x y z c 'x':contf3 x y z c 'z'\n" +"subplot 4 3 6:rotate 40 60:box:dens3 x y z c:dens3 x y z c 'x':dens3 x y z c 'z'\n" +"subplot 4 3 7:rotate 40 60:box:dots x y z c;meshnum 15\n" +"subplot 4 3 8:rotate 40 60:box:densx c '' 0:densy c '' 0:densz c '' 0\n" +"subplot 4 3 9:rotate 40 60:box:contx c '' 0:conty c '' 0:contz c '' 0\n" +"subplot 4 3 10:rotate 40 60:box:contfx c '' 0:contfy c '' 0:contfz c '' 0\n"; +void smgl_param3(mglGraph *gr) // 3d parametric plots +{ + mglData x(50,50,50), y(50,50,50), z(50,50,50), c(50,50,50), d(50,50,50); + gr->Fill(x,"(x+2)/3*sin(pi*y/2)"); gr->Fill(y,"(x+2)/3*cos(pi*y/2)"); gr->Fill(z,"z"); + gr->Fill(c,"-2*(x^2+y^2+z^4-z^2)+0.2"); gr->Fill(d,"1-2*tanh(2*(x+y)^2)"); + + gr->Light(true); gr->Alpha(true); + gr->SubPlot(4,3,0); gr->Rotate(40,60); gr->Box(); gr->Surf3(x,y,z,c); + gr->SubPlot(4,3,1); gr->Rotate(40,60); gr->Box(); gr->Surf3C(x,y,z,c,d); + gr->SubPlot(4,3,2); gr->Rotate(40,60); gr->Box(); gr->Surf3A(x,y,z,c,d); + gr->SubPlot(4,3,3); gr->Rotate(40,60); gr->Box(); gr->Cloud(x,y,z,c); + gr->SubPlot(4,3,4); gr->Rotate(40,60); gr->Box(); gr->Cont3(x,y,z,c); gr->Cont3(x,y,z,c,"x"); gr->Cont3(x,y,z,c,"z"); + gr->SubPlot(4,3,5); gr->Rotate(40,60); gr->Box(); gr->ContF3(x,y,z,c);gr->ContF3(x,y,z,c,"x");gr->ContF3(x,y,z,c,"z"); + gr->SubPlot(4,3,6); gr->Rotate(40,60); gr->Box(); gr->Dens3(x,y,z,c); gr->Dens3(x,y,z,c,"x"); gr->Dens3(x,y,z,c,"z"); + gr->SubPlot(4,3,7); gr->Rotate(40,60); gr->Box(); gr->Dots(x,y,z,c,"","meshnum 15"); + gr->SubPlot(4,3,8); gr->Rotate(40,60); gr->Box(); gr->DensX(c,"",0); gr->DensY(c,"",0); gr->DensZ(c,"",0); + gr->SubPlot(4,3,9); gr->Rotate(40,60); gr->Box(); gr->ContX(c,"",0); gr->ContY(c,"",0); gr->ContZ(c,"",0); + gr->SubPlot(4,3,10);gr->Rotate(40,60); gr->Box(); gr->ContFX(c,"",0); gr->ContFY(c,"",0); gr->ContFZ(c,"",0); +} +//----------------------------------------------------------------------------- +const char *mmgl_paramv="new x 20 20 20 '(x+2)/3*sin(pi*y/2)'\n" +"new y 20 20 20 '(x+2)/3*cos(pi*y/2)'\nnew z 20 20 20 'z+x'\n" +"new ex 20 20 20 'x'\nnew ey 20 20 20 'x^2+y'\nnew ez 20 20 20 'y^2+z'\n\n" +"new x1 50 50 '(x+2)/3*sin(pi*y/2)'\n" +"new y1 50 50 '(x+2)/3*cos(pi*y/2)'\n" +"new e1 50 50 'x'\nnew e2 50 50 'x^2+y'\n\n" +"subplot 3 3 0:rotate 40 60:box:vect x1 y1 e1 e2\n" +"subplot 3 3 1:rotate 40 60:box:flow x1 y1 e1 e2\n" +"subplot 3 3 2:rotate 40 60:box:pipe x1 y1 e1 e2\n" +"subplot 3 3 3:rotate 40 60:box:dew x1 y1 e1 e2\n" +"subplot 3 3 4:rotate 40 60:box:vect x y z ex ey ez\n" +"subplot 3 3 5:rotate 40 60:box\n" +"vect3 x y z ex ey ez:vect3 x y z ex ey ez 'x':vect3 x y z ex ey ez 'z'\n" +"grid3 x y z z '{r9}':grid3 x y z z '{g9}x':grid3 x y z z '{b9}z'\n" +"subplot 3 3 6:rotate 40 60:box:flow x y z ex ey ez\n" +"subplot 3 3 7:rotate 40 60:box:pipe x y z ex ey ez\n"; +void smgl_paramv(mglGraph *gr) // parametric plots for vector field +{ + mglData x(20,20,20), y(20,20,20), z(20,20,20), ex(20,20,20), ey(20,20,20), ez(20,20,20); + gr->Fill(x,"(x+2)/3*sin(pi*y/2)"); gr->Fill(y,"(x+2)/3*cos(pi*y/2)"); gr->Fill(z,"x+z"); + gr->Fill(ex,"x"); gr->Fill(ey,"x^2+y"); gr->Fill(ez,"y^2+z"); + mglData x1(20,20), y1(20,20), e1(20,20), e2(20,20); + gr->Fill(x1,"(x+2)/3*sin(pi*y/2)"); gr->Fill(y1,"(x+2)/3*cos(pi*y/2)"); + gr->Fill(e1,"x"); gr->Fill(e2,"x^2+y"); + + gr->SubPlot(3,3,0); gr->Rotate(40,60); gr->Box(); gr->Vect(x1,y1,e1,e2); + gr->SubPlot(3,3,1); gr->Rotate(40,60); gr->Box(); gr->Flow(x1,y1,e1,e2); + gr->SubPlot(3,3,2); gr->Rotate(40,60); gr->Box(); gr->Pipe(x1,y1,e1,e2); + gr->SubPlot(3,3,3); gr->Rotate(40,60); gr->Box(); gr->Dew(x1,y1,e1,e2); + gr->SubPlot(3,3,4); gr->Rotate(40,60); gr->Box(); gr->Vect(x,y,z,ex,ey,ez); + gr->SubPlot(3,3,5); gr->Rotate(40,60); gr->Box(); + gr->Vect3(x,y,z,ex,ey,ez); gr->Vect3(x,y,z,ex,ey,ez,"x"); gr->Vect3(x,y,z,ex,ey,ez,"z"); + gr->Grid3(x,y,z,z,"{r9}"); gr->Grid3(x,y,z,z,"{g9}x"); gr->Grid3(x,y,z,z,"{b9}z"); + gr->SubPlot(3,3,6); gr->Rotate(40,60); gr->Box(); gr->Flow(x,y,z,ex,ey,ez); + gr->SubPlot(3,3,7); gr->Rotate(40,60); gr->Box(); gr->Pipe(x,y,z,ex,ey,ez); +} +//----------------------------------------------------------------------------- +const char *mmgl_solve="zrange 0 1\nnew x 20 30 '(x+2)/3*cos(pi*y)'\n" +"new y 20 30 '(x+2)/3*sin(pi*y)'\nnew z 20 30 'exp(-6*x^2-2*sin(pi*y)^2)'\n\n" +"subplot 2 1 0:title 'Cartesian space':rotate 30 -40\naxis 'xyzU':box\nxlabel 'x':ylabel 'y'\n" +"origin 1 1:grid 'xy'\nmesh x y z\n\n" +"# section along 'x' direction\nsolve u x 0.5 'x'\nvar v u.nx 0 1\n" +"evaluate yy y u v\nevaluate xx x u v\nevaluate zz z u v\nplot xx yy zz 'k2o'\n\n" +"# 1st section along 'y' direction\nsolve u1 x -0.5 'y'\nvar v1 u1.nx 0 1\n" +"evaluate yy y v1 u1\nevaluate xx x v1 u1\nevaluate zz z v1 u1\nplot xx yy zz 'b2^'\n\n" +"# 2nd section along 'y' direction\nsolve u2 x -0.5 'y' u1\n" +"evaluate yy y v1 u2\nevaluate xx x v1 u2\nevaluate zz z v1 u2\nplot xx yy zz 'r2v'\n\n" +"subplot 2 1 1:title 'Accompanied space'\nranges 0 1 0 1:origin 0 0\n" +"axis:box:xlabel 'i':ylabel 'j':grid2 z 'h'\n\n" +"plot u v 'k2o':line 0.4 0.5 0.8 0.5 'kA'\n" +"plot v1 u1 'b2^':line 0.5 0.15 0.5 0.3 'bA'\n" +"plot v1 u2 'r2v':line 0.5 0.7 0.5 0.85 'rA'\n"; +void smgl_solve(mglGraph *gr) // solve and evaluate +{ + gr->SetRange('z',0,1); + mglData x(20,30), y(20,30), z(20,30), xx,yy,zz; + gr->Fill(x,"(x+2)/3*cos(pi*y)"); + gr->Fill(y,"(x+2)/3*sin(pi*y)"); + gr->Fill(z,"exp(-6*x^2-2*sin(pi*y)^2)"); + + gr->SubPlot(2,1,0); gr->Title("Cartesian space"); gr->Rotate(30,-40); + gr->Axis("xyzU"); gr->Box(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->SetOrigin(1,1); gr->Grid("xy"); + gr->Mesh(x,y,z); + + // section along 'x' direction + mglData u = x.Solve(0.5,'x'); + mglData v(u.nx); v.Fill(0,1); + xx = x.Evaluate(u,v); yy = y.Evaluate(u,v); zz = z.Evaluate(u,v); + gr->Plot(xx,yy,zz,"k2o"); + + // 1st section along 'y' direction + mglData u1 = x.Solve(-0.5,'y'); + mglData v1(u1.nx); v1.Fill(0,1); + xx = x.Evaluate(v1,u1); yy = y.Evaluate(v1,u1); zz = z.Evaluate(v1,u1); + gr->Plot(xx,yy,zz,"b2^"); + + // 2nd section along 'y' direction + mglData u2 = x.Solve(-0.5,'y',u1); + xx = x.Evaluate(v1,u2); yy = y.Evaluate(v1,u2); zz = z.Evaluate(v1,u2); + gr->Plot(xx,yy,zz,"r2v"); + + gr->SubPlot(2,1,1); gr->Title("Accompanied space"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(0,0); + gr->Axis(); gr->Box(); gr->Label('x',"i"); gr->Label('y',"j"); + gr->Grid(z,"h"); + + gr->Plot(u,v,"k2o"); gr->Line(mglPoint(0.4,0.5),mglPoint(0.8,0.5),"kA"); + gr->Plot(v1,u1,"b2^"); gr->Line(mglPoint(0.5,0.15),mglPoint(0.5,0.3),"bA"); + gr->Plot(v1,u2,"r2v"); gr->Line(mglPoint(0.5,0.7),mglPoint(0.5,0.85),"rA"); +} +//----------------------------------------------------------------------------- +const char *mmgl_triangulation="new x 100 '2*rnd-1':new y 100 '2*rnd-1':copy z x^2-y^2\n" +"new g 30 30:triangulate d x y\n" +"title 'Triangulation'\nrotate 50 60:box:light on\n" +"triplot d x y z:triplot d x y z '#k'\ndatagrid g x y z:mesh g 'm'\n"; +void smgl_triangulation(mglGraph *gr) // surface triangulation +{ + mglData x(100), y(100), z(100); + gr->Fill(x,"2*rnd-1"); gr->Fill(y,"2*rnd-1"); gr->Fill(z,"v^2-w^2",x,y); + mglData d = mglTriangulation(x,y), g(30,30); + + if(big!=3) gr->Title("Triangulation"); + gr->Rotate(40,60); gr->Box(); gr->Light(true); + gr->TriPlot(d,x,y,z); gr->TriPlot(d,x,y,z,"#k"); + + gr->DataGrid(g,x,y,z); gr->Mesh(g,"m"); +} +//----------------------------------------------------------------------------- +const char *mmgl_alpha="call 'prepare2d'\nsubplot 2 2 0:title 'default':rotate 50 60:box\nsurf a\n" +"subplot 2 2 1:title 'light on':rotate 50 60:box\nlight on:surf a\n" +"subplot 2 2 3:title 'light on; alpha on':rotate 50 60:box\nalpha on:surf a\n" +"subplot 2 2 2:title 'alpha on':rotate 50 60:box\nlight off:surf a\n"; +void smgl_alpha(mglGraph *gr) // alpha and lighting +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("default"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a); + gr->SubPlot(2,2,1); gr->Title("light on"); gr->Rotate(50,60); + gr->Box(); gr->Light(true); gr->Surf(a); + gr->SubPlot(2,2,3); gr->Title("alpha on; light on"); gr->Rotate(50,60); + gr->Box(); gr->Alpha(true); gr->Surf(a); + gr->SubPlot(2,2,2); gr->Title("alpha on"); gr->Rotate(50,60); + gr->Box(); gr->Light(false); gr->Surf(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_schemes="call 'sch' 0 'kw'\ncall 'sch' 1 'wk'\ncall 'sch' 2 'kHCcw'\ncall 'sch' 3 'kBbcw'\n" +"call 'sch' 4 'kRryw'\ncall 'sch' 5 'kGgew'\ncall 'sch' 6 'BbwrR'\ncall 'sch' 7 'BbwgG'\n" +"call 'sch' 8 'GgwmM'\ncall 'sch' 9 'UuwqR'\ncall 'sch' 10 'QqwcC'\ncall 'sch' 11 'CcwyY'\n" +"call 'sch' 12 'bcwyr'\ncall 'sch' 13 'bwr'\ncall 'sch' 14 'BbcyrR'\ncall 'sch' 15 'UbcyqR'\n" +"call 'sch' 16 'BbcwyrR'\ncall 'sch' 17 'bgr'\ncall 'sch' 18 'BbcyrR|'\ncall 'sch' 19 'b\\{g,0.3\\}r'\n" +"stop\nfunc 'sch' 2\nsubplot 2 10 $1 '<>_^' 0.2 0:fsurf 'x' $2\n" +"text 0.07+0.5*mod($1,2) 0.92-0.1*int($1/2) $2 'A'\nreturn\n"; +void smgl_schemes(mglGraph *gr) // Color table +{ + mglData a(256,2); a.Fill(-1,1); + gr->SubPlot(2,10,0,NULL,0.2); gr->Dens(a,"kw"); gr->Puts(0.07, 0.92, "'kw'", "A"); + gr->SubPlot(2,10,1,NULL,0.2); gr->Dens(a,"wk"); gr->Puts(0.57, 0.92, "'wk'", "A"); + gr->SubPlot(2,10,2,NULL,0.2); gr->Dens(a,"kHCcw"); gr->Puts(0.07, 0.82, "'kHCcw'", "A"); + gr->SubPlot(2,10,3,NULL,0.2); gr->Dens(a,"kBbcw"); gr->Puts(0.57, 0.82, "'kBbcw'", "A"); + gr->SubPlot(2,10,4,NULL,0.2); gr->Dens(a,"kRryw"); gr->Puts(0.07, 0.72, "'kRryw'", "A"); + gr->SubPlot(2,10,5,NULL,0.2); gr->Dens(a,"kGgew"); gr->Puts(0.57, 0.72, "'kGgew'", "A"); + gr->SubPlot(2,10,6,NULL,0.2); gr->Dens(a,"BbwrR"); gr->Puts(0.07, 0.62, "'BbwrR'", "A"); + gr->SubPlot(2,10,7,NULL,0.2); gr->Dens(a,"BbwgG"); gr->Puts(0.57, 0.62, "'BbwgG'", "A"); + gr->SubPlot(2,10,8,NULL,0.2); gr->Dens(a,"GgwmM"); gr->Puts(0.07, 0.52, "'GgwmM'", "A"); + gr->SubPlot(2,10,9,NULL,0.2); gr->Dens(a,"UuwqR"); gr->Puts(0.57, 0.52, "'UuwqR'", "A"); + gr->SubPlot(2,10,10,NULL,0.2); gr->Dens(a,"QqwcC"); gr->Puts(0.07, 0.42, "'QqwcC'", "A"); + gr->SubPlot(2,10,11,NULL,0.2); gr->Dens(a,"CcwyY"); gr->Puts(0.57, 0.42, "'CcwyY'", "A"); + gr->SubPlot(2,10,12,NULL,0.2); gr->Dens(a,"bcwyr"); gr->Puts(0.07, 0.32, "'bcwyr'", "A"); + gr->SubPlot(2,10,13,NULL,0.2); gr->Dens(a,"bwr"); gr->Puts(0.57, 0.32, "'bwr'", "A"); + gr->SubPlot(2,10,14,NULL,0.2); gr->Dens(a,"BbcyrR"); gr->Puts(0.07, 0.22, "'BbcyrR'", "A"); + gr->SubPlot(2,10,15,NULL,0.2); gr->Dens(a,"UbcyqR"); gr->Puts(0.57, 0.22, "'UbcyqR'", "A"); + gr->SubPlot(2,10,16,NULL,0.2); gr->Dens(a,"BbcwyrR"); gr->Puts(0.07, 0.12, "'BbcwyrR'", "A"); + gr->SubPlot(2,10,17,NULL,0.2); gr->Dens(a,"bgr"); gr->Puts(0.57, 0.12, "'bgr'", "A"); + gr->SubPlot(2,10,18,NULL,0.2); gr->Dens(a,"BbcyrR|"); gr->Puts(0.07, 0.02, "'BbcyrR|'", "A"); + gr->SubPlot(2,10,19,NULL,0.2); gr->Dens(a,"b{g,0.3}r"); gr->Puts(0.57, 0.02, "'b\\{g,0.3\\}r'", "A"); +} +//----------------------------------------------------------------------------- +const char *mmgl_curvcoor="origin -1 1 -1\nsubplot 2 2 0:title 'Cartesian':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n" +"axis 'y*sin(pi*x)' 'y*cos(pi*x)' '':subplot 2 2 1:title 'Cylindrical':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n" +"axis '2*y*x' 'y*y - x*x' '':subplot 2 2 2:title 'Parabolic':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n" +"axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z':subplot 2 2 3:title 'Spiral':rotate 50 60:fplot '2*t-1' '0.5' '0' '2r':axis:grid\n"; +void smgl_curvcoor(mglGraph *gr) // curvilinear coordinates +{ + gr->SetOrigin(-1,1,-1); + + gr->SubPlot(2,2,0); gr->Title("Cartesian"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)",0); + gr->SubPlot(2,2,1); gr->Title("Cylindrical"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("2*y*x","y*y - x*x",0); + gr->SubPlot(2,2,2); gr->Title("Parabolic"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z"); + gr->SubPlot(2,2,3); gr->Title("Spiral"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + gr->SetFunc(0,0,0); // set to default Cartesian +} +//----------------------------------------------------------------------------- +const char *mmgl_style=""; +void smgl_style(mglGraph *gr) // pen styles +{ + gr->SubPlot(2,2,0); + double d,x1,x2,x0,y=0.95; + d=0.3, x0=0.2, x1=0.5, x2=0.6; + gr->Line(mglPoint(x0,1-0*d),mglPoint(x1,1-0*d),"k-"); gr->Puts(mglPoint(x2,y-0*d),"Solid '-'",":rL"); + gr->Line(mglPoint(x0,1-1*d),mglPoint(x1,1-1*d),"k|"); gr->Puts(mglPoint(x2,y-1*d),"Long Dash '|'",":rL"); + gr->Line(mglPoint(x0,1-2*d),mglPoint(x1,1-2*d),"k;"); gr->Puts(mglPoint(x2,y-2*d),"Dash ';'",":rL"); + gr->Line(mglPoint(x0,1-3*d),mglPoint(x1,1-3*d),"k="); gr->Puts(mglPoint(x2,y-3*d),"Small dash '='",":rL"); + gr->Line(mglPoint(x0,1-4*d),mglPoint(x1,1-4*d),"kj"); gr->Puts(mglPoint(x2,y-4*d),"Dash-dot 'j'",":rL"); + gr->Line(mglPoint(x0,1-5*d),mglPoint(x1,1-5*d),"ki"); gr->Puts(mglPoint(x2,y-5*d),"Small dash-dot 'i'",":rL"); + gr->Line(mglPoint(x0,1-6*d),mglPoint(x1,1-6*d),"k:"); gr->Puts(mglPoint(x2,y-6*d),"Dots ':'",":rL"); + gr->Line(mglPoint(x0,1-7*d),mglPoint(x1,1-7*d),"k "); gr->Puts(mglPoint(x2,y-7*d),"None ' '",":rL"); + + d=0.25; x1=-1; x0=-0.8; y = -0.05; + gr->Mark(mglPoint(x1,5*d),"k."); gr->Puts(mglPoint(x0,y+5*d),"'.'",":rL"); + gr->Mark(mglPoint(x1,4*d),"k+"); gr->Puts(mglPoint(x0,y+4*d),"'+'",":rL"); + gr->Mark(mglPoint(x1,3*d),"kx"); gr->Puts(mglPoint(x0,y+3*d),"'x'",":rL"); + gr->Mark(mglPoint(x1,2*d),"k*"); gr->Puts(mglPoint(x0,y+2*d),"'*'",":rL"); + gr->Mark(mglPoint(x1,d),"ks"); gr->Puts(mglPoint(x0,y+d),"'s'",":rL"); + gr->Mark(mglPoint(x1,0),"kd"); gr->Puts(mglPoint(x0,y),"'d'",":rL"); + gr->Mark(mglPoint(x1,-d,0),"ko"); gr->Puts(mglPoint(x0,y-d),"'o'",":rL"); + gr->Mark(mglPoint(x1,-2*d,0),"k^"); gr->Puts(mglPoint(x0,y-2*d),"'\\^'",":rL"); + gr->Mark(mglPoint(x1,-3*d,0),"kv"); gr->Puts(mglPoint(x0,y-3*d),"'v'",":rL"); + gr->Mark(mglPoint(x1,-4*d,0),"k<"); gr->Puts(mglPoint(x0,y-4*d),"'<'",":rL"); + gr->Mark(mglPoint(x1,-5*d,0),"k>"); gr->Puts(mglPoint(x0,y-5*d),"'>'",":rL"); + + d=0.25; x1=-0.5; x0=-0.3; y = -0.05; + gr->Mark(mglPoint(x1,5*d),"k#."); gr->Puts(mglPoint(x0,y+5*d),"'\\#.'",":rL"); + gr->Mark(mglPoint(x1,4*d),"k#+"); gr->Puts(mglPoint(x0,y+4*d),"'\\#+'",":rL"); + gr->Mark(mglPoint(x1,3*d),"k#x"); gr->Puts(mglPoint(x0,y+3*d),"'\\#x'",":rL"); + gr->Mark(mglPoint(x1,2*d),"k#*"); gr->Puts(mglPoint(x0,y+2*d),"'\\#*'",":rL"); + gr->Mark(mglPoint(x1,d),"k#s"); gr->Puts(mglPoint(x0,y+d),"'\\#s'",":rL"); + gr->Mark(mglPoint(x1,0),"k#d"); gr->Puts(mglPoint(x0,y),"'\\#d'",":rL"); + gr->Mark(mglPoint(x1,-d,0),"k#o"); gr->Puts(mglPoint(x0,y-d),"'\\#o'",":rL"); + gr->Mark(mglPoint(x1,-2*d,0),"k#^"); gr->Puts(mglPoint(x0,y-2*d),"'\\#\\^'",":rL"); + gr->Mark(mglPoint(x1,-3*d,0),"k#v"); gr->Puts(mglPoint(x0,y-3*d),"'\\#v'",":rL"); + gr->Mark(mglPoint(x1,-4*d,0),"k#<"); gr->Puts(mglPoint(x0,y-4*d),"'\\#<'",":rL"); + gr->Mark(mglPoint(x1,-5*d,0),"k#>"); gr->Puts(mglPoint(x0,y-5*d),"'\\#>'",":rL"); + + gr->SubPlot(2,2,1); + double a=0.1,b=0.4,c=0.5; + gr->Line(mglPoint(a,1),mglPoint(b,1),"k-A"); gr->Puts(mglPoint(c,1),"Style 'A' or 'A\\_'",":rL"); + gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"k-V"); gr->Puts(mglPoint(c,0.8),"Style 'V' or 'V\\_'",":rL"); + gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"k-K"); gr->Puts(mglPoint(c,0.6),"Style 'K' or 'K\\_'",":rL"); + gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"k-I"); gr->Puts(mglPoint(c,0.4),"Style 'I' or 'I\\_'",":rL"); + gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"k-D"); gr->Puts(mglPoint(c,0.2),"Style 'D' or 'D\\_'",":rL"); + gr->Line(mglPoint(a,0),mglPoint(b,0),"k-S"); gr->Puts(mglPoint(c,0),"Style 'S' or 'S\\_'",":rL"); + gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"k-O"); gr->Puts(mglPoint(c,-0.2),"Style 'O' or 'O\\_'",":rL"); + gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"k-T"); gr->Puts(mglPoint(c,-0.4),"Style 'T' or 'T\\_'",":rL"); + gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-_"); gr->Puts(mglPoint(c,-0.6),"Style '\\_' or none",":rL"); + gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-AS"); gr->Puts(mglPoint(c,-0.8),"Style 'AS'",":rL"); + gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-_A"); gr->Puts(mglPoint(c,-1),"Style '\\_A'",":rL"); + + a=-1; b=-0.7; c=-0.6; + gr->Line(mglPoint(a,1),mglPoint(b,1),"kAA"); gr->Puts(mglPoint(c,1),"Style 'AA'",":rL"); + gr->Line(mglPoint(a,0.8),mglPoint(b,0.8),"kVV"); gr->Puts(mglPoint(c,0.8),"Style 'VV'",":rL"); + gr->Line(mglPoint(a,0.6),mglPoint(b,0.6),"kKK"); gr->Puts(mglPoint(c,0.6),"Style 'KK'",":rL"); + gr->Line(mglPoint(a,0.4),mglPoint(b,0.4),"kII"); gr->Puts(mglPoint(c,0.4),"Style 'II'",":rL"); + gr->Line(mglPoint(a,0.2),mglPoint(b,0.2),"kDD"); gr->Puts(mglPoint(c,0.2),"Style 'DD'",":rL"); + gr->Line(mglPoint(a,0),mglPoint(b,0),"kSS"); gr->Puts(mglPoint(c,0),"Style 'SS'",":rL"); + gr->Line(mglPoint(a,-0.2),mglPoint(b,-0.2),"kOO"); gr->Puts(mglPoint(c,-0.2),"Style 'OO'",":rL"); + gr->Line(mglPoint(a,-0.4),mglPoint(b,-0.4),"kTT"); gr->Puts(mglPoint(c,-0.4),"Style 'TT'",":rL"); + gr->Line(mglPoint(a,-0.6),mglPoint(b,-0.6),"k-__"); gr->Puts(mglPoint(c,-0.6),"Style '\\_\\_'",":rL"); + gr->Line(mglPoint(a,-0.8),mglPoint(b,-0.8),"k-VA"); gr->Puts(mglPoint(c,-0.8),"Style 'VA'",":rL"); + gr->Line(mglPoint(a,-1),mglPoint(b,-1),"k-AV"); gr->Puts(mglPoint(c,-1),"Style 'AV'",":rL"); + + gr->SubPlot(2,2,2); + //#LENUQ + gr->FaceZ(mglPoint(-1, -1), 0.4, 0.3, "L#"); gr->Puts(mglPoint(-0.8,-0.9), "L", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-1), 0.4, 0.3, "E#"); gr->Puts(mglPoint(-0.4,-0.9), "E", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-1), 0.4, 0.3, "N#"); gr->Puts(mglPoint(0, -0.9), "N", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, -1), 0.4, 0.3, "U#"); gr->Puts(mglPoint(0.4,-0.9), "U", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, -1), 0.4, 0.3, "Q#"); gr->Puts(mglPoint(0.8,-0.9), "Q", "w:C", -1.4); + //#lenuq + gr->FaceZ(mglPoint(-1, -0.7), 0.4, 0.3, "l#"); gr->Puts(mglPoint(-0.8,-0.6), "l", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.7), 0.4, 0.3, "e#"); gr->Puts(mglPoint(-0.4,-0.6), "e", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.7), 0.4, 0.3, "n#"); gr->Puts(mglPoint(0, -0.6), "n", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.7), 0.4, 0.3, "u#"); gr->Puts(mglPoint(0.4,-0.6), "u", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.7), 0.4, 0.3, "q#"); gr->Puts(mglPoint(0.8,-0.6), "q", "k:C", -1.4); + //#CMYkP + gr->FaceZ(mglPoint(-1, -0.4), 0.4, 0.3, "C#"); gr->Puts(mglPoint(-0.8,-0.3), "C", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.4), 0.4, 0.3, "M#"); gr->Puts(mglPoint(-0.4,-0.3), "M", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.4), 0.4, 0.3, "Y#"); gr->Puts(mglPoint(0, -0.3), "Y", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.4), 0.4, 0.3, "k#"); gr->Puts(mglPoint(0.4,-0.3), "k", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.4), 0.4, 0.3, "P#"); gr->Puts(mglPoint(0.8,-0.3), "P", "w:C", -1.4); + //#cmywp + gr->FaceZ(mglPoint(-1, -0.1), 0.4, 0.3, "c#"); gr->Puts(mglPoint(-0.8, 0), "c", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,-0.1), 0.4, 0.3, "m#"); gr->Puts(mglPoint(-0.4, 0), "m", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,-0.1), 0.4, 0.3, "y#"); gr->Puts(mglPoint(0, 0), "y", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, -0.1), 0.4, 0.3, "w#"); gr->Puts(mglPoint(0.4, 0), "w", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, -0.1), 0.4, 0.3, "p#"); gr->Puts(mglPoint(0.8, 0), "p", "k:C", -1.4); + //#BGRHW + gr->FaceZ(mglPoint(-1, 0.2), 0.4, 0.3, "B#"); gr->Puts(mglPoint(-0.8, 0.3), "B", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.2), 0.4, 0.3, "G#"); gr->Puts(mglPoint(-0.4, 0.3), "G", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.2), 0.4, 0.3, "R#"); gr->Puts(mglPoint(0, 0.3), "R", "w:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.2), 0.4, 0.3, "H#"); gr->Puts(mglPoint(0.4, 0.3), "H", "w:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.2), 0.4, 0.3, "W#"); gr->Puts(mglPoint(0.8, 0.3), "W", "w:C", -1.4); + //#bgrhw + gr->FaceZ(mglPoint(-1, 0.5), 0.4, 0.3, "b#"); gr->Puts(mglPoint(-0.8, 0.6), "b", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.5), 0.4, 0.3, "g#"); gr->Puts(mglPoint(-0.4, 0.6), "g", "k:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.5), 0.4, 0.3, "r#"); gr->Puts(mglPoint(0, 0.6), "r", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.5), 0.4, 0.3, "h#"); gr->Puts(mglPoint(0.4, 0.6), "h", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.5), 0.4, 0.3, "w#"); gr->Puts(mglPoint(0.8, 0.6), "w", "k:C", -1.4); + //#brighted + gr->FaceZ(mglPoint(-1, 0.8), 0.4, 0.3, "{r1}#"); gr->Puts(mglPoint(-0.8, 0.9), "\\{r1\\}", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.6,0.8), 0.4, 0.3, "{r3}#"); gr->Puts(mglPoint(-0.4, 0.9), "\\{r3\\}", "w:C", -1.4); + gr->FaceZ(mglPoint(-0.2,0.8), 0.4, 0.3, "{r5}#"); gr->Puts(mglPoint(0, 0.9), "\\{r5\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0.2, 0.8), 0.4, 0.3, "{r7}#"); gr->Puts(mglPoint(0.4, 0.9), "\\{r7\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0.6, 0.8), 0.4, 0.3, "{r9}#"); gr->Puts(mglPoint(0.8, 0.9), "\\{r9\\}", "k:C", -1.4); + // HEX + gr->FaceZ(mglPoint(-1, -1.3), 1, 0.3, "{xff9966}#"); gr->Puts(mglPoint(-0.5,-1.2), "\\{xff9966\\}", "k:C", -1.4); + gr->FaceZ(mglPoint(0, -1.3), 1, 0.3, "{x83CAFF}#"); gr->Puts(mglPoint( 0.5,-1.2), "\\{x83CAFF\\}", "k:C", -1.4); + + gr->SubPlot(2,2,3); + char stl[3]="r1", txt[4]="'1'"; + for(int i=0;i<10;i++) + { + txt[1]=stl[1]='0'+i; + gr->Line(mglPoint(-1,0.2*i-1),mglPoint(1,0.2*i-1),stl); + gr->Puts(mglPoint(1.05,0.2*i-1),txt,":L"); + } +} +//----------------------------------------------------------------------------- +const char *mmgl_text="call 'prepare1d'\nsubplot 2 2 0 ''\ntext 0 1 'Text can be in ASCII and in Unicode'\n" +"text 0 0.6 'It can be \\wire{wire}, \\big{big} or #r{colored}'\n" +"text 0 0.2 'One can change style in string: \\b{bold}, \\i{italic, \\b{both}}'\n" +"text 0 -0.2 'Easy to \\a{overline} or \\u{underline}'\n" +"text 0 -0.6 'Easy to change indexes ^{up} _{down} @{center}'\n" +"text 0 -1 'It parse TeX: \\int \\alpha \\cdot \\\n\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx'\n" +"subplot 2 2 1 ''\n text 0 0.5 '\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}' '@' -2\n" +"text 0 -0.5 'Text can be printed\\n{}on several lines'\n" +"subplot 2 2 2 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k'\ntext y 'Another string drawn above a curve' 'Tr'\n" +"subplot 2 2 3 '':line -1 -1 1 -1 'rA':text 0 -1 1 -1 'Horizontal'\n" +"line -1 -1 1 1 'rA':text 0 0 1 1 'At angle' '@'\nline -1 -1 -1 1 'rA':text -1 0 -1 1 'Vertical'\n"; +void smgl_text(mglGraph *gr) // text drawing +{ + if(big!=3) gr->SubPlot(2,2,0,""); + gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode"); + gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}"); + gr->Puts(mglPoint(0,0.2),"One can change style in string: " + "\\b{bold}, \\i{italic, \\b{both}}"); + gr->Puts(mglPoint(0,-0.2),"Easy to \\a{overline} or " + "\\u{underline}"); + gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}"); + gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot " + "\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx"); + if(big==3) return; + + gr->SubPlot(2,2,1,""); + gr->Puts(mglPoint(0,0.5), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", "@", -2); + gr->Puts(mglPoint(0,-0.5),"Text can be printed\non several lines"); + + gr->SubPlot(2,2,2,""); + mglData y; mgls_prepare1d(&y); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k"); + gr->Text(y,"Another string drawn above a curve","Tr"); + + gr->SubPlot(2,2,3,""); + gr->Line(mglPoint(-1,-1),mglPoint(1,-1),"rA"); gr->Puts(mglPoint(0,-1),mglPoint(1,-1),"Horizontal"); + gr->Line(mglPoint(-1,-1),mglPoint(1,1),"rA"); gr->Puts(mglPoint(0,0),mglPoint(1,1),"At angle","@"); + gr->Line(mglPoint(-1,-1),mglPoint(-1,1),"rA"); gr->Puts(mglPoint(-1,0),mglPoint(-1,1),"Vertical"); +} +//----------------------------------------------------------------------------- +const char *mmgl_text2="call 'prepare1d'\n" +"subplot 1 3 0 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k'\ntext y 'Another string drawn above a curve' 'Tr'\n" +"subplot 1 3 1 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:C'\ntext y 'Another string drawn above a curve' 'Tr:C'\n" +"subplot 1 3 2 '':box:plot y(:,0)\ntext y 'This is very very long string drawn along a curve' 'k:R'\ntext y 'Another string drawn above a curve' 'Tr:R'\n"; +void smgl_text2(mglGraph *gr) // text drawing +{ + mglData y; mgls_prepare1d(&y); + if(big!=3) gr->SubPlot(1,3,0,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k"); + gr->Text(y,"Another string drawn above a curve","Tr"); + if(big==3) return; + + gr->SubPlot(1,3,1,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k:C"); + gr->Text(y,"Another string drawn above a curve","Tr:C"); + + gr->SubPlot(1,3,2,""); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve","k:R"); + gr->Text(y,"Another string drawn above a curve","Tr:R"); +} +//----------------------------------------------------------------------------- +const char *mmgl_fonts="define d 0.25\nloadfont 'STIX':text 0 1.1 'default font (STIX)'\nloadfont 'adventor':text 0 1.1-d 'adventor font'\n" +"loadfont 'bonum':text 0 1.1-2*d 'bonum font'\nloadfont 'chorus':text 0 1.1-3*d 'chorus font'\nloadfont 'cursor':text 0 1.1-4*d 'cursor font'\n" +"loadfont 'heros':text 0 1.1-5*d 'heros font'\nloadfont 'heroscn':text 0 1.1-6*d 'heroscn font'\nloadfont 'pagella':text 0 1.1-7*d 'pagella font'\n" +"loadfont 'schola':text 0 1.1-8*d 'schola font'\nloadfont 'termes':text 0 1.1-9*d 'termes font'\nloadfont ''\n"; +void smgl_fonts(mglGraph *gr) // font typefaces +{ + double h=1.1, d=0.25; + gr->LoadFont("STIX"); gr->Puts(mglPoint(0,h), "default font (STIX)"); + gr->LoadFont("adventor"); gr->Puts(mglPoint(0,h-d), "adventor font"); + gr->LoadFont("bonum"); gr->Puts(mglPoint(0,h-2*d), "bonum font"); + gr->LoadFont("chorus"); gr->Puts(mglPoint(0,h-3*d), "chorus font"); + gr->LoadFont("cursor"); gr->Puts(mglPoint(0,h-4*d), "cursor font"); + gr->LoadFont("heros"); gr->Puts(mglPoint(0,h-5*d), "heros font"); + gr->LoadFont("heroscn"); gr->Puts(mglPoint(0,h-6*d), "heroscn font"); + gr->LoadFont("pagella"); gr->Puts(mglPoint(0,h-7*d), "pagella font"); + gr->LoadFont("schola"); gr->Puts(mglPoint(0,h-8*d), "schola font"); + gr->LoadFont("termes"); gr->Puts(mglPoint(0,h-9*d), "termes font"); + gr->LoadFont(""); +} +//----------------------------------------------------------------------------- +const char *mmgl_bars="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd':origin 0 0 0\n" +"subplot 3 2 0 '':title 'Bars plot (default)':box:bars ys\nsubplot 3 2 1 '':title '2 colors':box:bars ys 'cbgGyr'\n" +"subplot 3 2 4 '':title '\"\\#\" style':box:bars ys '#'\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 3 2 5:title '3d variant':rotate 50 60:box:bars xc yc z 'r'\n" +"ranges -1 1 -3 3:subplot 3 2 2 '':title '\"a\" style':box:bars ys 'a'\nsubplot 3 2 3 '':title '\"f\" style':box:bars ys 'f'\n"; +void smgl_bars(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)"); } + gr->Box(); gr->Bars(ys); + if(big==3) return; + gr->SubPlot(3,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Bars(ys,"cbgGyr"); + gr->SubPlot(3,2,4,""); gr->Title("'\\#' style"); gr->Box(); gr->Bars(ys,"#"); + gr->SubPlot(3,2,5); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Bars(xc,yc,z,"r"); + gr->SetRanges(-1,1,-3,3); // increase range since summation can exceed [-1,1] + gr->SubPlot(3,2,2,""); gr->Title("'a' style"); gr->Box(); gr->Bars(ys,"a"); + gr->SubPlot(3,2,3,""); gr->Title("'f' style"); gr->Box(); gr->Bars(ys,"f"); +} +//----------------------------------------------------------------------------- +const char *mmgl_barh="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd':origin 0 0 0\n" +"subplot 2 2 0 '':title 'Barh plot (default)':box:barh ys\nsubplot 2 2 1 '':title '2 colors':box:barh ys 'cbgGyr'\n" +"ranges -3 3 -1 1:subplot 2 2 2 '':title '\"a\" style':box:barh ys 'a'\nsubplot 2 2 3 '': title '\"f\" style':box:barh ys 'f'\n"; +void smgl_barh(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); } + gr->Box(); gr->Barh(ys); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Barh(ys,"cbgGyr"); + gr->SetRanges(-3,3,-1,1); // increase range since summation can exceed [-1,1] + gr->SubPlot(2,2,2,""); gr->Title("'a' style"); gr->Box(); gr->Barh(ys,"a"); + gr->SubPlot(2,2,3,""); gr->Title("'f' style"); gr->Box(); gr->Barh(ys,"f"); +} +//----------------------------------------------------------------------------- +const char *mmgl_area="call 'prepare1d'\norigin 0 0 0\nsubplot 2 2 0 '':title 'Area plot (default)':box:area y\n" +"subplot 2 2 1 '':title '2 colors':box:area y 'cbgGyr'\nsubplot 2 2 2 '':title '\"!\" style':box:area y '!'\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 3:title '3d variant':rotate 50 60:box\n" +"area xc yc z 'r'\narea xc -yc z 'b#'\n"; +void smgl_area(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)"); } + gr->Box(); gr->Area(y); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Area(y,"cbgGyr"); + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Area(y,"!"); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Area(xc,yc,z,"r"); + yc.Modify("-sin(pi*(2*x-1))"); gr->Area(xc,yc,z,"b#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_plot="call 'prepare1d'\nsubplot 2 2 0 '':title 'Plot plot (default)':box:plot y\n" +"subplot 2 2 2 '':title ''!' style; 'rgb' palette':box:plot y 'o!rgb'\nsubplot 2 2 3 '':title 'just markers':box:plot y ' +'\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:plot xc yc z 'rs'\n"; +void smgl_plot(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)"); } + gr->Box(); gr->Plot(y); + if(big==3) return; + gr->SubPlot(2,2,2,""); gr->Title("'!' style; 'rgb' palette"); gr->Box(); gr->Plot(y,"o!rgb"); + gr->SubPlot(2,2,3,""); gr->Title("just markers"); gr->Box(); gr->Plot(y," +"); + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Plot(xc,yc,z,"rs"); +} +//----------------------------------------------------------------------------- +const char *mmgl_tens="call 'prepare1d'\nsubplot 2 2 0 '':title 'Tens plot (default)':box:tens y(:,0) y(:,1)\n" +"subplot 2 2 2 '':title '\" \" style':box:tens y(:,0) y(:,1) 'o '\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\n" +"subplot 2 2 1:title '3d variant':rotate 50 60:box:tens xc yc z z 's'\n"; +void smgl_tens(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)"); } + gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1)); + if(big==3) return; + gr->SubPlot(2,2,2,""); gr->Title("' ' style"); gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o "); + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Tens(xc,yc,z,z,"s"); +} +//----------------------------------------------------------------------------- +const char *mmgl_region="call 'prepare1d'\ncopy y1 y(:,1):copy y2 y(:,2)\n" +"subplot 2 2 0 '':title 'Region plot (default)':box:region y1 y2:plot y1 'k2':plot y2 'k2'\n" +"subplot 2 2 1 '':title '2 colors':box:region y1 y2 'yr':plot y1 'k2':plot y2 'k2'\n" +"subplot 2 2 2 '':title '\"!\" style':box:region y1 y2 '!':plot y1 'k2':plot y2 'k2'\n" +"subplot 2 2 3 '':title '\"i\" style':box:region y1 y2 'ir':plot y1 'k2':plot y2 'k2'\n"; +void smgl_region(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData y1 = y.SubData(-1,1), y2 = y.SubData(-1,2); gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)"); } + gr->Box(); gr->Region(y1,y2); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); gr->Box(); gr->Region(y1,y2,"yr"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Region(y1,y2,"!"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + gr->SubPlot(2,2,3,""); gr->Title("'i' style"); gr->Box(); gr->Region(y1,y2,"ir"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); +} +//----------------------------------------------------------------------------- +const char *mmgl_stem="call 'prepare1d'\norigin 0 0 0:subplot 2 2 0 '':title 'Stem plot (default)':box:stem y\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:stem xc yc z 'rx'\n" +"subplot 2 2 2 '':title '\"!\" style':box:stem y 'o!rgb'\n"; +void smgl_stem(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)"); } + gr->Box(); gr->Stem(y); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Stem(xc,yc,z,"rx"); + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Stem(y,"o!rgb"); +} +//----------------------------------------------------------------------------- +const char *mmgl_step="call 'prepare1d'\norigin 0 0 0:subplot 2 2 0 '':title 'Step plot (default)':box:step y\n" +"new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'\nsubplot 2 2 1:title '3d variant':rotate 50 60:box:step xc yc z 'r'\n" +"subplot 2 2 2 '':title '\"!\" style':box:step y 's!rgb'\n"; +void smgl_step(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)"); } + gr->Box(); gr->Step(y); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Step(xc,yc,z,"r"); + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); gr->Box(); gr->Step(y,"s!rgb"); +} +//----------------------------------------------------------------------------- +const char *mmgl_boxplot="new a 10 7 '(2*rnd-1)^3/2'\nsubplot 1 1 0 '':title 'Boxplot plot':box:boxplot a\n"; +void smgl_boxplot(mglGraph *gr) // flow threads and density plot +{ + mglData a(10,7); a.Modify("(2*rnd-1)^3/2"); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot"); } + gr->Box(); gr->BoxPlot(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_ohlc="new o 10 '0.5*sin(pi*x)'\nnew c 10 '0.5*sin(pi*(x+2/9))'\n" +"new l 10 '0.3*rnd-0.8'\nnew h 10 '0.3*rnd+0.5'\n" +"subplot 1 1 0 '':title 'OHLC plot':box:ohlc o h l c\n"; +void smgl_ohlc(mglGraph *gr) // flow threads and density plot +{ + mglData o(10), h(10), l(10), c(10); + gr->Fill(o,"0.5*sin(pi*x)"); gr->Fill(c,"0.5*sin(pi*(x+2/9))"); + gr->Fill(l,"0.3*rnd-0.8"); gr->Fill(h,"0.3*rnd+0.5"); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("OHLC plot"); } + gr->Box(); gr->OHLC(o,h,l,c); +} +//----------------------------------------------------------------------------- +const char *mmgl_type0="call 'prepare2d'\nalpha on:light on:transptype 0:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n" +"subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n" +"subplot 2 2 3:rotate 50 60:axial a:box"; +void smgl_type0(mglGraph *gr) // TranspType = 0 +{ + gr->Alpha(true); gr->Light(true); + mglData a; mgls_prepare2d(&a); + gr->SetTranspType(0); gr->Clf(); + gr->SubPlot(2,2,0); gr->Rotate(50,60); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(50,60); gr->Dens(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(50,60); gr->Cont(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(50,60); gr->Axial(a); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_type1="call 'prepare2d'\nalpha on:light on:transptype 1:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n" +"subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n" +"subplot 2 2 3:rotate 50 60:axial a:box"; +void smgl_type1(mglGraph *gr) // TranspType = 1 +{ + gr->Alpha(true); gr->Light(true); + mglData a; mgls_prepare2d(&a); + gr->SetTranspType(1); gr->Clf(); + gr->SubPlot(2,2,0); gr->Rotate(50,60); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(50,60); gr->Dens(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(50,60); gr->Cont(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(50,60); gr->Axial(a); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_type2="call 'prepare2d'\nalpha on:light on:transptype 2:clf\nsubplot 2 2 0:rotate 50 60:surf a:box\n" +"subplot 2 2 1:rotate 50 60:dens a:box\nsubplot 2 2 2:rotate 50 60:cont a:box\n" +"subplot 2 2 3:rotate 50 60:axial a:box"; +void smgl_type2(mglGraph *gr) // TranspType = 2 +{ + gr->Alpha(true); gr->Light(true); + mglData a; mgls_prepare2d(&a); + gr->SetTranspType(2); gr->Clf(); + gr->SubPlot(2,2,0); gr->Rotate(50,60); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(50,60); gr->Dens(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(50,60); gr->Cont(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(50,60); gr->Axial(a); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_molecule="alpha on:light on\n" +"subplot 2 2 0 '':title 'Methane, CH_4':rotate 60 120\n" +"sphere 0 0 0 0.25 'k':drop 0 0 0 0 0 1 0.35 'h' 1 2:sphere 0 0 0.7 0.25 'g'\n" +"drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2:sphere -0.66 0 -0.23 0.25 'g'\n" +"drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2:sphere 0.33 0.57 -0.23 0.25 'g'\n" +"drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2:sphere 0.33 -0.57 -0.23 0.25 'g'\n" +"subplot 2 2 1 '':title 'Water, H{_2}O':rotate 60 100\n" +"sphere 0 0 0 0.25 'r':drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2:sphere 0.3 0.5 0 0.25 'g'\n" +"drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2:sphere 0.3 -0.5 0 0.25 'g'\n" +"subplot 2 2 2 '':title 'Oxygen, O_2':rotate 60 120\n" +"drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2:sphere 0 0.5 0 0.25 'r'\n" +"drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2:sphere 0 -0.5 0 0.25 'r'\n" +"subplot 2 2 3 '':title 'Ammonia, NH_3':rotate 60 120\n" +"sphere 0 0 0 0.25 'b':drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2\n" +"sphere 0.33 0.57 0 0.25 'g':drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2\n" +"sphere 0.33 -0.57 0 0.25 'g':drop 0 0 0 -0.65 0 0 0.32 'n' 1 2\n" +"sphere -0.65 0 0 0.25 'g'\n"; +void smgl_molecule(mglGraph *gr) // example of moleculas +{ + gr->VertexColor(false); gr->Compression(false); // per-vertex colors and compression are detrimental to transparency + gr->DoubleSided(false); // we do not get into atoms, while rendering internal surface has negative impact on trasparency + gr->Alpha(true); gr->Light(true); + + gr->SubPlot(2,2,0,""); gr->Title("Methane, CH_4"); + gr->StartGroup("Methane"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"k"); + gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2); + gr->Sphere(mglPoint(0,0,0.7),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g"); + gr->EndGroup(); + + gr->SubPlot(2,2,1,""); gr->Title("Water, H_{2}O"); + gr->StartGroup("Water"); + gr->Rotate(60,100); + gr->StartGroup("Water_O"); + gr->Sphere(mglPoint(0,0,0),0.25,"r"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_1"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_1"); + gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_2"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_2"); + gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g"); + gr->EndGroup(); + gr->EndGroup(); + + gr->SubPlot(2,2,2,""); gr->Title("Oxygen, O_2"); + gr->StartGroup("Oxygen"); + gr->Rotate(60,120); + gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,0.5,0),0.25,"r"); + gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,-0.5,0),0.25,"r"); + gr->EndGroup(); + + gr->SubPlot(2,2,3,""); gr->Title("Ammonia, NH_3"); + gr->StartGroup("Ammonia"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"b"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2); + gr->Sphere(mglPoint(-0.65,0,0),0.25,"g"); + gr->EndGroup(); + gr->DoubleSided( true ); // put back +} +//----------------------------------------------------------------------------- +const char *mmgl_error2="new x0 10 'rnd':new ex 10 '0.1'\nnew y0 10 'rnd':new ey 10 '0.1'\nranges 0 1 0 1\n" +"subplot 4 3 0 '':box:error x0 y0 ex ey '#+@'\n" +"subplot 4 3 1 '':box:error x0 y0 ex ey '#x@'\n" +"subplot 4 3 2 '':box:error x0 y0 ex ey '#s@'; alpha 0.5\n" +"subplot 4 3 3 '':box:error x0 y0 ex ey 's@'\n" +"subplot 4 3 4 '':box:error x0 y0 ex ey 'd@'\n" +"subplot 4 3 5 '':box:error x0 y0 ex ey '#d@'; alpha 0.5\n" +"subplot 4 3 6 '':box:error x0 y0 ex ey '+@'\n" +"subplot 4 3 7 '':box:error x0 y0 ex ey 'x@'\n" +"subplot 4 3 8 '':box:error x0 y0 ex ey 'o@'\n" +"subplot 4 3 9 '':box:error x0 y0 ex ey '#o@'; alpha 0.5\n" +"subplot 4 3 10 '':box:error x0 y0 ex ey '#.@'\n" +"subplot 4 3 11 '':box:error x0 y0 ex ey; alpha 0.5\n"; +void smgl_error2(mglGraph *gr) +{ + mglData x0(10), y0(10), ex(10), ey(10); + for(int i=0;i<10;i++) + { x0.a[i] = mgl_rnd(); y0.a[i] = mgl_rnd(); ey.a[i] = ex.a[i] = 0.1; } + gr->SetRanges(0,1,0,1); gr->Alpha(true); + gr->SubPlot(4,3,0,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#+@"); + gr->SubPlot(4,3,1,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#x@"); + gr->SubPlot(4,3,2,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#s@","alpha 0.5"); + gr->SubPlot(4,3,3,""); gr->Box(); gr->Error(x0,y0,ex,ey,"s@"); + gr->SubPlot(4,3,4,""); gr->Box(); gr->Error(x0,y0,ex,ey,"d@"); + gr->SubPlot(4,3,5,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#d@","alpha 0.5"); + gr->SubPlot(4,3,6,""); gr->Box(); gr->Error(x0,y0,ex,ey,"+@"); + gr->SubPlot(4,3,7,""); gr->Box(); gr->Error(x0,y0,ex,ey,"x@"); + gr->SubPlot(4,3,8,""); gr->Box(); gr->Error(x0,y0,ex,ey,"o@"); + gr->SubPlot(4,3,9,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#o@","alpha 0.5"); + gr->SubPlot(4,3,10,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#.@"); + gr->SubPlot(4,3,11,""); gr->Box(); gr->Error(x0,y0,ex,ey); +} +//----------------------------------------------------------------------------- +const char *mmgl_error="call 'prepare1d'\nnew y 50 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2)'\n" +"new x0 10 'x + 0.1*rnd-0.05':new ex 10 '0.1':new ey 10 '0.2'\n" +"new y0 10 '0.7*sin(pi*x-pi) + 0.5*cos(3*pi*(x+1)/2) + 0.2*sin(pi*(x+1)/2) + 0.2*rnd-0.1'\n" +"subplot 2 2 0 '':title 'Error plot (default)':box:plot y:error x0 y0 ex ey 'k'\n" +"subplot 2 2 1 '':title '\"!\" style; no e_x':box:plot y:error x0 y0 ey 'o!rgb'\n" +"subplot 2 2 2 '':title '\"\\@\" style':alpha on:box:plot y:error x0 y0 ex ey '@'; alpha 0.5\n" +"subplot 2 2 3:title '3d variant':rotate 50 60:axis\n" +"for $1 0 9\n\terrbox 2*rnd-1 2*rnd-1 2*rnd-1 0.2 0.2 0.2 'bo'\nnext\n"; +void smgl_error(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData x0(10), y0(10), ex0(10), ey0(10); + double x; + for(int i=0;i<10;i++) + { + x = i/9.; + x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05; + y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1; + ey0.a[i]=0.2; ex0.a[i]=0.1; + } + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)"); } + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"ko"); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("'!' style; no e_x"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ey0,"o!rgb"); + gr->SubPlot(2,2,2,""); gr->Title("'\\@' style"); gr->Alpha(true); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5"); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + for(int i=0;i<10;i++) + gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1), mglPoint(0.2,0.2,0.2),"bo"); + gr->Axis(); +} +//----------------------------------------------------------------------------- +const char *mmgl_chart="new ch 7 2 'rnd+0.1':light on\n" +"subplot 2 2 0:title 'Chart plot (default)':rotate 50 60:box:chart ch\n" +"subplot 2 2 1:title '\"\\#\" style':rotate 50 60:box:chart ch '#'\n" +"subplot 2 2 2:title 'Pie chart; \" \" color':rotate 50 60:\n" +"axis '(y+1)/2*cos(pi*x)' '(y+1)/2*sin(pi*x)' '':box:chart ch 'bgr cmy#'\n" +"subplot 2 2 3:title 'Ring chart; \" \" color':rotate 50 60:\n" +"axis '(y+2)/3*cos(pi*x)' '(y+2)/3*sin(pi*x)' '':box:chart ch 'bgr cmy#'\n"; +void smgl_chart(mglGraph *gr) +{ + mglData ch(7,2); for(int i=0;i<7*2;i++) ch.a[i]=mgl_rnd()+0.1; + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Chart plot (default)"); } + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Chart(ch); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"#"); + gr->SubPlot(2,2,2); gr->Title("Pie chart; ' ' color"); + gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); + gr->SubPlot(2,2,3); gr->Title("Ring chart; ' ' color"); + gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_mark="call 'prepare1d'\nsubplot 1 1 0 '':title 'Mark plot (default)':box:mark y y1 's'\n"; +void smgl_mark(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)"); } + gr->Box(); gr->Mark(y,y1,"s"); +} +//----------------------------------------------------------------------------- +const char *mmgl_radar="new yr 10 3 '0.4*sin(pi*(x+1.5+y/2)+0.1*rnd)'\n" +"subplot 1 1 0 '':title 'Radar plot (with grid, \"\\#\")':radar yr '#'\n"; +void smgl_radar(mglGraph *gr) +{ + mglData yr(10,3); yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd"); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')"); } + gr->Radar(yr,"#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_candle="new y 30 'sin(pi*x/2)^2':copy y1 y/2:copy y2 (y+1)/2\n" +"subplot 1 1 0 '':title 'Candle plot (default)'\nyrange 0 1:box:candle y y1 y2\n"; +void smgl_candle(mglGraph *gr) +{ + mglData y(30); gr->Fill(y,"sin(pi*x/2)^2"); + mglData y1(30); gr->Fill(y1,"v/2",y); + mglData y2(30); gr->Fill(y2,"(1+v)/2",y); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)"); } + gr->SetRange('y',0,1); gr->Box(); gr->Candle(y,y1,y2); +} +//----------------------------------------------------------------------------- +const char *mmgl_textmark="call 'prepare1d'\nsubplot 1 1 0 '':title 'TextMark plot (default)':box:textmark y y1 '\\gamma' 'r'\n"; +void smgl_textmark(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)"); } + gr->Box(); gr->TextMark(y,y1,"\\gamma","r"); +} +//----------------------------------------------------------------------------- +const char *mmgl_tube="call 'prepare1d'\nlight on\n" +"new yc 50 'sin(pi*x)':new xc 50 'cos(pi*x)':new z 50 'x':divto y1 20\n" +"subplot 2 2 0 '':title 'Tube plot (default)':box:tube y 0.05\n" +"subplot 2 2 1 '':title 'variable radius':box:tube y y1\n" +"subplot 2 2 2 '':title '\"\\#\" style':box:tube y 0.05 '#'\n" +"subplot 2 2 3:title '3d variant':rotate 50 60:box:tube xc yc z y2 'r'\n"; +void smgl_tube(mglGraph *gr) +{ + mglData y,y1,y2; mgls_prepare1d(&y,&y1,&y2); y1/=20; + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)"); } + gr->Light(true); gr->Box(); gr->Tube(y,0.05); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("variable radius"); gr->Box(); gr->Tube(y,y1); + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Tube(y,0.05,"#"); + mglData yc(50), xc(50), z(50); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); gr->Tube(xc,yc,z,y2,"r"); +} +//----------------------------------------------------------------------------- +const char *mmgl_tape="call 'prepare1d'\nnew yc 50 'sin(pi*x)':new xc 50 'cos(pi*x)':new z 50 'x'\n" +"subplot 2 2 0 '':title 'Tape plot (default)':box:tape y:plot y 'k'\n" +"subplot 2 2 1:title '3d variant, 2 colors':rotate 50 60:light on\n" +"box:plot xc yc z 'k':tape xc yc z 'rg'\n" +"subplot 2 2 2:title '3d variant, x only':rotate 50 60\n" +"box:plot xc yc z 'k':tape xc yc z 'xr':tape xc yc z 'xr#'\n" +"subplot 2 2 3:title '3d variant, z only':rotate 50 60\n" +"box:plot xc yc z 'k':tape xc yc z 'zg':tape xc yc z 'zg#'\n"; +void smgl_tape(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData xc(50), yc(50), z(50); + yc.Modify("sin(pi*(2*x-1))"); + xc.Modify("cos(pi*2*x-pi)"); z.Fill(-1,1); + if(big!=3) { gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)"); } + gr->Box(); gr->Tape(y); gr->Plot(y,"k"); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("3d variant, 2 colors"); gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"rg"); + gr->SubPlot(2,2,2); gr->Title("3d variant, x only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"xr"); gr->Tape(xc,yc,z,"xr#"); + gr->SubPlot(2,2,3); gr->Title("3d variant, z only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"zg"); gr->Tape(xc,yc,z,"zg#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_fog="call 'prepare2d'\ntitle 'Fog sample':rotate 50 60:light on:fog 1\nbox:surf a:cont a 'y'\n"; +void smgl_fog(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Fog sample"); + gr->Light(true); gr->Rotate(50,60); gr->Fog(1); gr->Box(); + gr->Surf(a); gr->Cont(a,"y"); +} +//----------------------------------------------------------------------------- +const char *mmgl_map="new a 50 40 'x':new b 50 40 'y':zrange -2 2:text 0 0 '\\to'\n" +"subplot 2 1 0:text 0 1.1 '\\{x, y\\}' '' -2:box:map a b 'brgk'\n" +"subplot 2 1 1:text 0 1.1 '\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}' '' -2\n" +"box:fill a '(x^3+y^3)/2':fill b '(x-y)/2':map a b 'brgk'\n"; +void smgl_map(mglGraph *gr) // example of mapping +{ + mglData a(50, 40), b(50, 40); + gr->Puts(mglPoint(0, 0), "\\to", ":C", -1.4); + gr->SetRanges(-1,1,-1,1,-2,2); + + gr->SubPlot(2, 1, 0); + gr->Fill(a,"x"); gr->Fill(b,"y"); + gr->Puts(mglPoint(0, 1.1), "\\{x, y\\}", ":C", -2); gr->Box(); + gr->Map(a, b, "brgk"); + + gr->SubPlot(2, 1, 1); + gr->Fill(a,"(x^3+y^3)/2"); gr->Fill(b,"(x-y)/2"); + gr->Puts(mglPoint(0, 1.1), "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", ":C", -2); + gr->Box(); + gr->Map(a, b, "brgk"); +} +//----------------------------------------------------------------------------- +const char *mmgl_stfa="new a 2000:new b 2000\nfill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\\\n" +"cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)'\n" +"subplot 1 2 0 '<_':title 'Initial signal':plot a:axis:xlabel '\\i t'\n" +"subplot 1 2 1 '<_':title 'STFA plot':stfa a b 64:axis:ylabel '\\omega' 0:xlabel '\\i t'\n"; +void smgl_stfa(mglGraph *gr) // STFA sample +{ + mglData a(2000), b(2000); + gr->Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\ + cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)"); + gr->SubPlot(1, 2, 0,"<_"); gr->Title("Initial signal"); + gr->Plot(a); + gr->Axis(); + gr->Label('x', "\\i t"); + + gr->SubPlot(1, 2, 1,"<_"); gr->Title("STFA plot"); + gr->STFA(a, b, 64); + gr->Axis(); + gr->Label('x', "\\i t"); + gr->Label('y', "\\omega", 0); +} +//----------------------------------------------------------------------------- +const char *mmgl_qo2d="define $1 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)'\n" +"subplot 1 1 0 '<_':title 'Beam and ray tracing'\n" +"ray r $1 -0.7 -1 0 0 0.5 0 0.02 2:plot r(0) r(1) 'k'\naxis:xlabel '\\i x':ylabel '\\i z'\n" +"new re 128 'exp(-48*x^2)':new im 128\nnew xx 1:new yy 1\nqo2d a $1 re im r 1 30 xx yy\n" +"crange 0 1:dens xx yy a 'wyrRk':fplot '-x' 'k|'\n" +"text 0 0.85 'absorption: (x+y)/2 for x+y>0'\ntext 0.7 -0.05 'central ray'"; +void smgl_qo2d(mglGraph *gr) +{ + mglData r, xx, yy, a, im(128), re(128); + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); + if(big!=3) {gr->SubPlot(1,1,0,"<_"); gr->Title("Beam and ray tracing");} + gr->Plot(r.SubData(0), r.SubData(1), "k"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i y"); + // now start beam tracing + gr->Fill(re,"exp(-48*x^2)"); + a = mglQO2d(ham, re, im, r, xx, yy, 1, 30); + gr->SetRange('c',0, 1); + gr->Dens(xx, yy, a, "wyrRk"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.85), "absorption: (x+y)/2 for x+y>0"); + gr->Puts(mglPoint(0.7, -0.05), "central ray"); +} +//----------------------------------------------------------------------------- +const char *mmgl_pde="new re 128 'exp(-48*(x+0.7)^2)':new im 128\n" +"pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30\ntranspose a\n" +"subplot 1 1 0 '<_':title 'PDE solver'\n" +"axis:xlabel '\\i x':ylabel '\\i z'\ncrange 0 1:dens a 'wyrRk'\n" +"fplot '-x' 'k|'\n" +"text 0 0.95 'Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0\\n{}absorption: (x+z)/2 for x+z>0'"; +void smgl_pde(mglGraph *gr) // PDE sample +{ + mglData a,re(128),im(128); + gr->Fill(re,"exp(-48*(x+0.7)^2)"); + a = gr->PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30); + a.Transpose("yxz"); + if(big!=3) {gr->SubPlot(1,1,0,"<_"); gr->Title("PDE solver"); } + gr->SetRange('c',0,1); gr->Dens(a,"wyrRk"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.95), "Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0\nabsorption: (x+z)/2 for x+z>0"); +} +//----------------------------------------------------------------------------- +const char *mmgl_conta="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box\ncont3 c 'x':cont3 c:cont3 c 'z'"; +void smgl_conta(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("Cont3 sample"); + gr->Rotate(50,60); gr->Box(); + gr->Cont3(c,"x"); gr->Cont3(c); gr->Cont3(c,"z"); +} +//----------------------------------------------------------------------------- +const char *mmgl_contfa="call 'prepare3d'\ntitle 'Cont3 sample':rotate 50 60:box:light on\n" +"contf3 c 'x':contf3 c:contf3 c 'z'\ncont3 c 'xk':cont3 c 'k':cont3 c 'zk'\n"; +void smgl_contfa(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("ContF3 sample"); + gr->Rotate(50,60); gr->Light(true); gr->Box(); + gr->ContF3(c,"x"); gr->ContF3(c); gr->ContF3(c,"z"); + gr->Cont3(c,"kx"); gr->Cont3(c,"k"); gr->Cont3(c,"kz"); +} +//----------------------------------------------------------------------------- +const char *mmgl_densa="call 'prepare3d'\ntitle 'Dens3 sample':rotate 50 60:alpha on:alphadef 0.7\n" +"origin 0 0 0:box:axis '_xyz'\ndens3 c 'x':dens3 c ':y':dens3 c 'z'"; +void smgl_densa(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("Dens3 sample"); + gr->Rotate(50,60); gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Dens3(c,"x"); gr->Dens3(c); gr->Dens3(c,"z"); +} +//----------------------------------------------------------------------------- +const char *mmgl_dens_xyz="call 'prepare3d'\ntitle 'Dens[XYZ] sample':rotate 50 60:box\n" +"densx {sum c 'x'} '' -1:densy {sum c 'y'} '' 1:densz {sum c 'z'} '' -1"; +void smgl_dens_xyz(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("Dens[XYZ] sample"); + gr->Rotate(50,60); gr->Box(); gr->DensX(c.Sum("x"),0,-1); + gr->DensY(c.Sum("y"),0,1); gr->DensZ(c.Sum("z"),0,-1); +} +//----------------------------------------------------------------------------- +const char *mmgl_cont_xyz="call 'prepare3d'\ntitle 'Cont[XYZ] sample':rotate 50 60:box\n" +"contx {sum c 'x'} '' -1:conty {sum c 'y'} '' 1:contz {sum c 'z'} '' -1"; +void smgl_cont_xyz(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("Cont[XYZ] sample"); + gr->Rotate(50,60); gr->Box(); gr->ContX(c.Sum("x"),"",-1); + gr->ContY(c.Sum("y"),"",1); gr->ContZ(c.Sum("z"),"",-1); +} +//----------------------------------------------------------------------------- +const char *mmgl_contf_xyz="call 'prepare3d'\ntitle 'ContF[XYZ] sample':rotate 50 60:box\n" +"contfx {sum c 'x'} '' -1:contfy {sum c 'y'} '' 1:contfz {sum c 'z'} '' -1"; +void smgl_contf_xyz(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) gr->Title("ContF[XYZ] sample"); + gr->Rotate(50,60); gr->Box(); gr->ContFX(c.Sum("x"),"",-1); + gr->ContFY(c.Sum("y"),"",1); gr->ContFZ(c.Sum("z"),"",-1); +} +//----------------------------------------------------------------------------- +const char *mmgl_cloud="call 'prepare3d'\nsubplot 2 2 0:title 'Cloud plot':rotate 50 60:alpha on:box:cloud c 'wyrRk'\n" +"subplot 2 2 1:title '\"i\" style':rotate 50 60:box:cloud c 'iwyrRk'\n" +"subplot 2 2 2:title '\".\" style':rotate 50 60:box:cloud c '.wyrRk'\n" +"subplot 2 2 3:title 'meshnum 10':rotate 50 60:box:cloud c 'wyrRk'; meshnum 10\n"; +void smgl_cloud(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Cloud plot"); } + gr->Rotate(50,60); gr->Alpha(true); + gr->Box(); gr->Cloud(c,"wyrRk"); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'i' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"iwyrRk"); + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,".wyrRk"); + gr->SubPlot(2,2,3); gr->Title("meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"wyrRk","meshnum 10"); +} +//----------------------------------------------------------------------------- +const char *mmgl_cont="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\nsubplot 2 2 0:title 'Cont plot (default)':rotate 50 60:box:cont a\n" +"subplot 2 2 1:title 'manual levels':rotate 50 60:box:cont v a\n" +"subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:cont a '_'\n" +"subplot 2 2 3 '':title '\"t\" style':box:cont a 't'\n"; +void smgl_cont(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Cont plot (default)"); } + gr->Rotate(50,60); gr->Box(); gr->Cont(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->Cont(v,a); + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->Cont(a,"_"); + gr->SubPlot(2,2,3,""); gr->Title("'t' style"); + gr->Box(); gr->Cont(a,"t"); +} +//----------------------------------------------------------------------------- +const char *mmgl_contf="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n" +"new a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n" +"subplot 2 2 0:title 'ContF plot (default)':rotate 50 60:box:contf a\n" +"subplot 2 2 1:title 'manual levels':rotate 50 60:box:contf v a\n" +"subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contf a '_'\n" +"subplot 2 2 3:title 'several slices':rotate 50 60:box:contf a1\n"; +void smgl_contf(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContF plot (default)"); } + gr->Rotate(50,60); gr->Box(); gr->ContF(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContF(v,a); + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a,"_"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a1); +} +//----------------------------------------------------------------------------- +const char *mmgl_contd="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n" +"new a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n" +"subplot 2 2 0:title 'ContD plot (default)':rotate 50 60:box:contd a\n" +"subplot 2 2 1:title 'manual levels':rotate 50 60:box:contd v a\n" +"subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contd a '_'\n" +"subplot 2 2 3:title 'several slices':rotate 50 60:box:contd a1\n"; +void smgl_contd(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContD plot (default)"); } + gr->Rotate(50,60); gr->Box(); gr->ContD(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContD(v,a); + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a,"_"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a1); +} +//----------------------------------------------------------------------------- +const char *mmgl_contv="call 'prepare2d'\nlist v -0.5 -0.15 0 0.15 0.5\n" +"subplot 2 2 0:title 'ContV plot (default)':rotate 50 60:box:contv a\n" +"subplot 2 2 1:title 'manual levels':rotate 50 60:box:contv v a\n" +"subplot 2 2 2:title '\"\\_\" style':rotate 50 60:box:contv a '_'\n" +"subplot 2 2 3:title 'ContV and ContF':rotate 50 60:light on:box\ncontv a:contf a:cont a 'k'\n"; +void smgl_contv(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("ContV plot (default)"); } + gr->Rotate(50,60); gr->Box(); gr->ContV(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContV(v,a); + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContV(a,"_"); + gr->SubPlot(2,2,3); gr->Title("ContV and ContF"); + gr->Rotate(50,60); gr->Box(); gr->Light(true); + gr->ContV(a); gr->ContF(a); gr->Cont(a,"k"); +} +//----------------------------------------------------------------------------- +const char *mmgl_torus="call 'prepare1d'\nsubplot 2 2 0:title 'Torus plot (default)':light on:rotate 50 60:box:torus y1 y2\n" +"subplot 2 2 1:title '\"x\" style':light on:rotate 50 60:box:torus y1 y2 'x'\n" +"subplot 2 2 2:title '\"z\" style':light on:rotate 50 60:box:torus y1 y2 'z'\n" +"subplot 2 2 3:title '\"\\#\" style':light on:rotate 50 60:box:torus y1 y2 '#'\n"; +void smgl_torus(mglGraph *gr) +{ + mglData y1,y2; mgls_prepare1d(0,&y1,&y2); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Torus plot (default)"); } + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'x' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"x"); + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"z"); + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2,"#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_axial="call 'prepare2d'\nsubplot 2 2 0:title 'Axial plot (default)':light on:alpha on:rotate 50 60:box:axial a\n" +"subplot 2 2 1:title '\"x\" style;\".\" style':light on:rotate 50 60:box:axial a 'x.'\n" +"subplot 2 2 2:title '\"z\" style':light on:rotate 50 60:box:axial a 'z'\n" +"subplot 2 2 3:title '\"\\#\" style':light on:rotate 50 60:box:axial a '#'\n"; +void smgl_axial(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Axial plot (default)"); } + gr->Light(true); gr->Alpha(true); gr->Rotate(50,60); gr->Box(); gr->Axial(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'x' style; '.'style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"x."); + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"z"); + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); gr->Box(); gr->Axial(a,"#"); +} +//----------------------------------------------------------------------------- +const char *mmgl_several_light="call 'prepare2d'\ntitle 'Several light sources':rotate 50 60:light on\n" +"light 1 0 1 0 'c':light 2 1 0 0 'y':light 3 0 -1 0 'm'\nbox:surf a 'h'\n"; +void smgl_several_light(mglGraph *gr) // several light sources +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Several light sources"); + gr->Rotate(50,60); gr->Light(true); gr->AddLight(1,mglPoint(0,1,0),'c'); + gr->AddLight(2,mglPoint(1,0,0),'y'); gr->AddLight(3,mglPoint(0,-1,0),'m'); + gr->Box(); gr->Surf(a,"h"); +} +//----------------------------------------------------------------------------- +const char *mmgl_light="light on:quality 6\ncall 'prepare2d'\n" +"subplot 2 2 0:title 'Default':rotate 50 60:box:surf a\nline -1 -0.7 1.7 -1 -0.7 0.7 'BA'\n\n" +"light 0 1 0 1 -2 -1 -1\nsubplot 2 2 1:title 'Local':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n\n" +"diffuse 0\nsubplot 2 2 2:title 'no diffuse':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n\n" +"diffuse 0.5:light 0 1 0 1 -2 -1 -1 'w' 0\n" +"subplot 2 2 3:title 'diffusive only':rotate 50 60:box:surf a\n" +"line 1 0 1 -1 -1 0 'BAO'\n"; +void smgl_light(mglGraph *gr) // local light sources +{ + mglData a; mgls_prepare2d(&a); + if(big==3) + { gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); return; } + int qual = gr->GetQuality(); + gr->Light(true); gr->SetQuality(6); + gr->SubPlot(2,2,0); gr->Title("Default"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(-1,-0.7,1.7),mglPoint(-1,-0.7,0.7),"BA"); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1)); + gr->SubPlot(2,2,1); gr->Title("Local"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0); + gr->SubPlot(2,2,2); gr->Title("no diffuse"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0.5); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1),'w',0); + gr->SubPlot(2,2,3); gr->Title("diffusive only"); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetQuality(qual); +} +//----------------------------------------------------------------------------- +const char *mmgl_surf3="call 'prepare3d'\nlight on:alpha on\n" +"subplot 2 2 0:title 'Surf3 plot (default)'\nrotate 50 60:box:surf3 c\n" +"subplot 2 2 1:title '\"\\#\" style'\nrotate 50 60:box:surf3 c '#'\n" +"subplot 2 2 2:title '\".\" style'\nrotate 50 60:box:surf3 c '.'\n"; +void smgl_surf3(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Surf3 plot (default)"); } + gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3(c); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"#"); + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"."); +} +//----------------------------------------------------------------------------- +const char *mmgl_surf3a="call 'prepare3d'\ntitle 'Surf3A plot':rotate 50 60:light on:alpha on:box:surf3a c d"; +void smgl_surf3a(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + if(big!=3) gr->Title("Surf3A plot"); + gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3A(c,d); +} +//----------------------------------------------------------------------------- +const char *mmgl_surf3c="call 'prepare3d'\ntitle 'Surf3C plot':rotate 50 60:light on:alpha on:box:surf3c c d"; +void smgl_surf3c(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + if(big!=3) gr->Title("Surf3C plot"); + gr->Rotate(50,60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3C(c,d); +} +//----------------------------------------------------------------------------- +const char *mmgl_cut="call 'prepare2d'\ncall 'prepare3d'\nsubplot 2 2 0:title 'Cut on (default)':rotate 50 60:light on:box:surf a; zrange -1 0.5\n" +"subplot 2 2 1:title 'Cut off':rotate 50 60:box:surf a; zrange -1 0.5; cut off\n" +"subplot 2 2 2:title 'Cut in box':rotate 50 60:box:alpha on\ncut 0 -1 -1 1 0 1.1:surf3 c\ncut 0 0 0 0 0 0\t# restore back\n" +"subplot 2 2 3:title 'Cut by formula':rotate 50 60:box\ncut '(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)':surf3 c"; +void smgl_cut(mglGraph *gr) // cutting +{ + mglData a,c,v(1); mgls_prepare2d(&a); mgls_prepare3d(&c); v.a[0]=0.5; + gr->SubPlot(2,2,0); gr->Title("Cut on (default)"); gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Surf(a,"","zrange -1 0.5"); + gr->SubPlot(2,2,1); gr->Title("Cut off"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a,"","zrange -1 0.5; cut off"); + gr->SubPlot(2,2,2); gr->Title("Cut in box"); gr->Rotate(50,60); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->Alpha(true); gr->Box(); gr->Surf3(c); + gr->SetCutBox(mglPoint(0), mglPoint(0)); // switch it off + gr->SubPlot(2,2,3); gr->Title("Cut by formula"); gr->Rotate(50,60); + gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)"); + gr->Box(); gr->Surf3(c); gr->CutOff(""); // switch it off +} +//----------------------------------------------------------------------------- +const char *mmgl_traj="call 'prepare1d'\nsubplot 1 1 0 '':title 'Traj plot':box:plot x1 y:traj x1 y y1 y2\n"; +void smgl_traj(mglGraph *gr) +{ + mglData x,y,y1,y2; mgls_prepare1d(&y,&y1,&y2,&x); + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Traj plot");} + gr->Box(); gr->Plot(x,y); gr->Traj(x,y,y1,y2); +} +//----------------------------------------------------------------------------- +const char *mmgl_mesh="call 'prepare2d'\ntitle 'Mesh plot':rotate 50 60:box:mesh a\n"; +void smgl_mesh(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Mesh plot"); + gr->Rotate(50,60); gr->Box(); gr->Mesh(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_fall="call 'prepare2d'\ntitle 'Fall plot':rotate 50 60:box:fall a\n"; +void smgl_fall(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Fall plot"); + gr->Rotate(50,60); gr->Box(); gr->Fall(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_surf="call 'prepare2d'\nsubplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a\n" +"subplot 2 2 1:title '\"\\#\" style; meshnum 10':rotate 50 60:box:surf a '#'; meshnum 10\n" +"subplot 2 2 2:title '\".\" style':rotate 50 60:box:surf a '.'\n" +"new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'\nnew y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'\nnew z 50 40 '0.8*cos(pi*(y+1)/2)'\n" +"subplot 2 2 3:title 'parametric form':rotate 50 60:box:surf x y z 'BbwrR'\n"; +void smgl_surf(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Surf plot (default)"); } + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'\\#' style; meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"#","meshnum 10"); + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"."); + gr->SubPlot(2,2,3); gr->Title("parametric form"); + mglData x(50,40),y(50,40),z(50,40); + gr->Fill(x,"0.8*sin(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(y,"0.8*cos(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(z,"0.8*cos(pi*(y+1)/2)"); + gr->Rotate(50,60); gr->Box(); gr->Surf(x,y,z,"BbwrR"); +} +//----------------------------------------------------------------------------- +const char *mmgl_parser="title 'MGL parser sample'\ncall 'sample'\nstop\nfunc 'sample'\n" +"new dat 100 'sin(2*pi*(x+1))'\nplot dat; xrange 0 1\nbox\naxis\n" +"xlabel 'x'\nylabel 'y'\nbox\nfor $0 -1 1 0.1\nif $0<0\n" +"line 0 0 -1 $0 'r':else:line 0 0 -1 $0 'g'\nendif\nnext"; +void smgl_parser(mglGraph *gr) // example of MGL parsing +{ + gr->Title("MGL parser sample"); + double a[100]; // let a_i = sin(4*pi*x), x=0...1 + for(int i=0;i<100;i++)a[i]=sin(4*M_PI*i/99); + mglParse *parser = new mglParse; + mglData *d = parser->AddVar("dat"); + d->Set(a,100); // set data to variable + parser->Execute(gr, "plot dat; xrange 0 1\nbox\naxis"); + // you may break script at any line do something + // and continue after that + parser->Execute(gr, "xlabel 'x'\nylabel 'y'\nbox"); + // also you may use cycles or conditions in script + parser->Execute(gr, "for $0 -1 1 0.1\nif $0<0\n" + "line 0 0 -1 $0 'r':else:line 0 0 -1 $0 'g'\n" + "endif\nnext"); + delete parser; +} +//----------------------------------------------------------------------------- +const char *mmgl_belt="call 'prepare2d'\ntitle 'Belt plot':rotate 50 60:box:belt a\n"; +void smgl_belt(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Belt plot"); + gr->Rotate(50,60); gr->Box(); gr->Belt(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_dens="call 'prepare2d'\nnew a1 30 40 3 '0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)'\n" +"subplot 2 2 0 '':title 'Dens plot (default)':box:dens a\n" +"subplot 2 2 1:title '3d variant':rotate 50 60:box:dens a\n" +"subplot 2 2 2 '':title '\"\\#\" style; meshnum 10':box:dens a '#'; meshnum 10\n" +"subplot 2 2 3:title 'several slices':rotate 50 60:box:dens a1\n"; +void smgl_dens(mglGraph *gr) +{ + mglData a,a1(30,40,3); mgls_prepare2d(&a); + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Dens plot (default)");} + gr->Box(); gr->Dens(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a); + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style; meshnum 10"); + gr->Box(); gr->Dens(a,"#","meshnum 10"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a1); +} +//----------------------------------------------------------------------------- +const char *mmgl_surfc="call 'prepare2d'\ntitle 'SurfC plot':rotate 50 60:light on:box:surfc a b\n"; +void smgl_surfc(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + if(big!=3) gr->Title("SurfC plot"); gr->Rotate(50,60); + gr->Light(true); gr->Box(); gr->SurfC(a,b); +} +//----------------------------------------------------------------------------- +const char *mmgl_surfa="call 'prepare2d'\ntitle 'SurfA plot':rotate 50 60:light on:alpha on:box:surfa a b\n"; +void smgl_surfa(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + if(big!=3) gr->Title("SurfA plot"); gr->Rotate(50,60); + gr->Alpha(true); gr->Light(true); gr->Box(); gr->SurfA(a,b); +} +//----------------------------------------------------------------------------- +const char *mmgl_tile="call 'prepare2d'\ntitle 'Tile plot':rotate 50 60:box:tile a\n"; +void smgl_tile(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) gr->Title("Tile plot"); + gr->Rotate(40,60); gr->Box(); gr->Tile(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_tiles="call 'prepare2d'\nsubplot 1 1 0 '':title 'Tiles plot':box:tiles a b\n"; +void smgl_tiles(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("TileS plot");} + gr->Box(); gr->TileS(a,b); +} +//----------------------------------------------------------------------------- +const char *mmgl_boxs="call 'prepare2d'\norigin 0 0 0\nsubplot 2 2 0:title 'Boxs plot (default)':rotate 40 60:light on:box:boxs a\n" +"subplot 2 2 1:title '\"\\@\" style':rotate 50 60:box:boxs a '@'\n" +"subplot 2 2 2:title '\"\\#\" style':rotate 50 60:box:boxs a '#'\n" +"subplot 2 2 3:title 'compare with Tile':rotate 50 60:box:tile a\n"; +void smgl_boxs(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SetOrigin(0,0,0); gr->Light(true); + if(big!=3) {gr->SubPlot(2,2,0); gr->Title("Boxs plot (default)");} + gr->Rotate(40,60); gr->Box(); gr->Boxs(a); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("'\\@' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"@"); + gr->SubPlot(2,2,2); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"#"); + gr->SubPlot(2,2,3); gr->Title("compare with Tile"); + gr->Rotate(50,60); gr->Box(); gr->Tile(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_fit="new rnd 100 '0.4*rnd+0.1+sin(2*pi*x)'\nnew in 100 '0.3+sin(2*pi*x)'\n" +"list ini 1 1 3:fit res rnd 'a+b*sin(c*x)' 'abc' ini\n" +"title 'Fitting sample':yrange -2 2:box:axis:plot rnd '. '\n" +"plot res 'r':plot in 'b'\ntext -0.9 -1.3 'fitted:' 'r:L'\n" +"putsfit 0 -1.8 'y = ' 'r':text 0 2.2 'initial: y = 0.3+sin(2\\pi x)' 'b'\n"; +void smgl_fit(mglGraph *gr) // nonlinear fitting +{ + mglData rnd(100), in(100), res; + gr->Fill(rnd,"0.4*rnd+0.1+sin(2*pi*x)"); + gr->Fill(in,"0.3+sin(2*pi*x)"); + double ini[3] = {1,1,3}; + mglData Ini(3,ini); + res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); + if(big!=3) gr->Title("Fitting sample"); + gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); + gr->Axis(); gr->Plot(res, "r"); gr->Plot(in, "b"); + gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); + gr->PutsFit(mglPoint(0, -1.8), "y = ", "r"); + gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b"); +// gr->SetRanges(mglPoint(-1,-1,-1),mglPoint(1,1,1)); gr->SetOrigin(0,0,0); +} +//----------------------------------------------------------------------------- +const char *mmgl_vecta="call 'prepare3v'\nsubplot 2 1 0:title 'Vect3 sample':rotate 50 60\n" +"origin 0 0 0:box:axis '_xyz'\nvect3 ex ey ez 'x':vect3 ex ey ez:vect3 ex ey ez 'z'\n" +"subplot 2 1 1:title '\"f\" style':rotate 50 60\n" +"origin 0 0 0:box:axis '_xyz'\nvect3 ex ey ez 'fx':vect3 ex ey ez 'f':vect3 ex ey ez 'fz'\n" +"grid3 ex 'Wx':grid3 ex 'W':grid3 ex 'Wz'\n"; +void smgl_vecta(mglGraph *gr) +{ + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + if(big!=3) { gr->SubPlot(2,1,0); gr->Title("Vect3 sample"); } + gr->Rotate(50,60); gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"x"); gr->Vect3(ex,ey,ez); gr->Vect3(ex,ey,ez,"z"); + if(big==3) return; + gr->SubPlot(2,1,1); gr->Title("'f' style"); + gr->Rotate(50,60); gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"fx"); gr->Vect3(ex,ey,ez,"f"); gr->Vect3(ex,ey,ez,"fz"); + gr->Grid3(ex,"Wx"); gr->Grid3(ex,"W"); gr->Grid3(ex,"Wz"); +} +//----------------------------------------------------------------------------- +const char *mmgl_vect="call 'prepare2v'\ncall 'prepare3v'\nsubplot 3 2 0 '':title 'Vect plot (default)':box:vect a b\n" +"subplot 3 2 1 '':title '\".\" style; \"=\" style':box:vect a b '.='\n" +"subplot 3 2 2 '':title '\"f\" style':box:vect a b 'f'\n" +"subplot 3 2 3 '':title '\">\" style':box:vect a b '>'\n" +"subplot 3 2 4 '':title '\"<\" style':box:vect a b '<'\n" +"subplot 3 2 5:title '3d variant':rotate 50 60:box:vect ex ey ez\n"; +void smgl_vect(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + if(big!=3) {gr->SubPlot(3,2,0,""); gr->Title("Vect plot (default)");} + gr->Box(); gr->Vect(a,b); + if(big==3) return; + gr->SubPlot(3,2,1,""); gr->Title("'.' style; '=' style"); gr->Box(); gr->Vect(a,b,"=."); + gr->SubPlot(3,2,2,""); gr->Title("'f' style"); gr->Box(); gr->Vect(a,b,"f"); + gr->SubPlot(3,2,3,""); gr->Title("'>' style"); gr->Box(); gr->Vect(a,b,">"); + gr->SubPlot(3,2,4,""); gr->Title("'<' style"); gr->Box(); gr->Vect(a,b,"<"); + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(3,2,5); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Vect(ex,ey,ez); +} +//----------------------------------------------------------------------------- +const char *mmgl_flow="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':title 'Flow plot (default)':box:flow a b\n" +"subplot 2 2 1 '':title '\"v\" style':box:flow a b 'v'\n" +"subplot 2 2 2 '':title 'from edges only':box:flow a b '#'\n" +"subplot 2 2 3:title '3d variant':rotate 50 60:box:flow ex ey ez\n"; +void smgl_flow(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Flow plot (default)");} + gr->Box(); gr->Flow(a,b); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("'v' style"); gr->Box(); gr->Flow(a,b,"v"); + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Flow(a,b,"#"); + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Flow(ex,ey,ez); +} +//----------------------------------------------------------------------------- +const char *mmgl_pipe="call 'prepare2v'\ncall 'prepare3v'\nsubplot 2 2 0 '':title 'Pipe plot (default)':light on:box:pipe a b\n" +"subplot 2 2 1 '':title '\"i\" style':box:pipe a b 'i'\n" +"subplot 2 2 2 '':title 'from edges only':box:pipe a b '#'\n" +"subplot 2 2 3:title '3d variant':rotate 50 60:box:pipe ex ey ez '' 0.1\n"; +void smgl_pipe(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Pipe plot (default)");} + gr->Light(true); gr->Box(); gr->Pipe(a,b); + if(big==3) return; + gr->SubPlot(2,2,1,""); gr->Title("'i' style"); gr->Box(); gr->Pipe(a,b,"i"); + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); gr->Box(); gr->Pipe(a,b,"#"); + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Pipe(ex,ey,ez,"",0.1); +} +//----------------------------------------------------------------------------- +const char *mmgl_dew="call 'prepare2v'\nsubplot 1 1 0 '':title 'Dew plot':light on:box:dew a b\n"; +void smgl_dew(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Dew plot");} + gr->Box(); gr->Light(true); gr->Dew(a,b); +} +//----------------------------------------------------------------------------- +const char *mmgl_grad="call 'prepare2d'\nsubplot 1 1 0 '':title 'Grad plot':box:grad a:dens a '{u8}w{q8}'\n"; +void smgl_grad(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + if(big!=3) {gr->SubPlot(1,1,0,""); gr->Title("Grad plot");} + gr->Box(); gr->Grad(a); gr->Dens(a,"{u8}w{q8}"); +} +//----------------------------------------------------------------------------- +const char *mmgl_cones="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\nlight on:origin 0 0 0\n" +"subplot 3 2 0:title 'Cones plot':rotate 50 60:box:cones ys\n" +"subplot 3 2 1:title '2 colors':rotate 50 60:box:cones ys 'cbgGyr'\n" +"subplot 3 2 2:title '\"\\#\" style':rotate 50 60:box:cones ys '#'\n" +"subplot 3 2 3:title '\"a\" style':rotate 50 60:zrange -2 2:box:cones ys 'a'\n" +"subplot 3 2 4:title '\"t\" style':rotate 50 60:box:cones ys 't'\n" +"subplot 3 2 5:title '\"4\" style':rotate 50 60:box:cones ys '4'\n"; +void smgl_cones(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->Light(true); gr->SetOrigin(0,0,0); + if(big!=3) { gr->SubPlot(3,2,0); gr->Title("Cones plot"); } + gr->Rotate(50,60); gr->Box(); gr->Cones(ys); + if(big==3) return; + gr->SubPlot(3,2,1); gr->Title("2 colors"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"cbgGyr"); + gr->SubPlot(3,2,2); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"#"); + gr->SubPlot(3,2,3); gr->Title("'a' style"); + gr->SetRange('z',-2,2); // increase range since summation can exceed [-1,1] + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"a"); + gr->SubPlot(3,2,4); gr->Title("'t' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"t"); + gr->SubPlot(3,2,5); gr->Title("'4' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"4"); +} +//----------------------------------------------------------------------------- +const char *mmgl_aspect="subplot 2 2 0:box:text -1 1.1 'Just box' ':L'\ninplot 0.2 0.5 0.7 1 off:box:text 0 1.2 'InPlot example'\n" +"subplot 2 2 1:title 'Rotate only':rotate 50 60:box\nsubplot 2 2 2:title 'Rotate and Aspect':rotate 50 60:aspect 1 1 2:box\n" +"subplot 2 2 3:title 'Aspect in other direction':rotate 50 60:aspect 1 2 2:box\n"; +void smgl_aspect(mglGraph *gr) // transformation +{ + gr->SubPlot(2,2,0); gr->Box(); + gr->Puts(mglPoint(-1,1.1),"Just box",":L"); + gr->InPlot(0.2,0.5,0.7,1,false); gr->Box(); + gr->Puts(mglPoint(0,1.2),"InPlot example"); + gr->SubPlot(2,2,1); gr->Title("Rotate only"); + gr->Rotate(50,60); gr->Box(); + gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); + gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); + gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_inplot="subplot 3 2 0:title 'StickPlot'\nstickplot 3 0 20 30:box 'r':text 0 0 '0' 'r'\n" +"stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g'\nstickplot 3 2 20 30:box 'b':text 0 0 '2' 'b'\n" +"subplot 3 2 3 '':title 'ColumnPlot'\ncolumnplot 3 0:box 'r':text 0 0 '0' 'r'\n" +"columnplot 3 1:box 'g':text 0 0 '1' 'g'\ncolumnplot 3 2:box 'b':text 0 0 '2' 'b'\n" +"subplot 3 2 4 '':title 'GridPlot'\ngridplot 2 2 0:box 'r':text 0 0 '0' 'r'\n" +"gridplot 2 2 1:box 'g':text 0 0 '1' 'g'\ngridplot 2 2 2:box 'b':text 0 0 '2' 'b'\n" +"gridplot 2 2 3:box 'm':text 0 0 '3' 'm'\nsubplot 3 2 5 '':title 'InPlot':box\n" +"inplot 0.4 1 0.6 1 on:box 'r'\nmultiplot 3 2 1 2 1 '':title 'MultiPlot':box\n"; +void smgl_inplot(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("StickPlot"); + gr->StickPlot(3, 0, 20, 30); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->StickPlot(3, 1, 20, 30); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->StickPlot(3, 2, 20, 30); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,3,""); gr->Title("ColumnPlot"); + gr->ColumnPlot(3, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ColumnPlot(3, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ColumnPlot(3, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,4,""); gr->Title("GridPlot"); + gr->GridPlot(2, 2, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->GridPlot(2, 2, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->GridPlot(2, 2, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); + gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); + gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_combined="call 'prepare2v'\ncall 'prepare3d'\nnew v 10:fill v -0.5 1:copy d sqrt(a^2+b^2)\n" +"subplot 2 2 0:title 'Surf + Cont':rotate 50 60:light on:box:surf a:cont a 'y'\n" +"subplot 2 2 1 '':title 'Flow + Dens':light off:box:flow a b 'br':dens d\n" +"subplot 2 2 2:title 'Mesh + Cont':rotate 50 60:box:mesh a:cont a '_'\n" +"subplot 2 2 3:title 'Surf3 + ContF3':rotate 50 60:light on\n" +"box:contf3 v c 'z' 0:contf3 v c 'x':contf3 v c\ncut 0 -1 -1 1 0 1.1\ncontf3 v c 'z' c.nz-1:surf3 c -0.5\n"; +void smgl_combined(mglGraph *gr) // flow threads and density plot +{ + mglData a,b,d; mgls_prepare2v(&a,&b); d = a; + for(int i=0;iSubPlot(2,2,1,""); gr->Title("Flow + Dens"); + gr->Flow(a,b,"br"); gr->Dens(d); gr->Box(); + gr->SubPlot(2,2,0); gr->Title("Surf + Cont"); gr->Rotate(50,60); + gr->Light(true); gr->Surf(a); gr->Cont(a,"y"); gr->Box(); + gr->SubPlot(2,2,2); gr->Title("Mesh + Cont"); gr->Rotate(50,60); + gr->Box(); gr->Mesh(a); gr->Cont(a,"_"); + gr->SubPlot(2,2,3); gr->Title("Surf3 + ContF3");gr->Rotate(50,60); + gr->Box(); gr->ContF3(v,c,"z",0); gr->ContF3(v,c,"x"); gr->ContF3(v,c); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->ContF3(v,c,"z",c.nz-1); gr->Surf3(-0.5,c); +} +//----------------------------------------------------------------------------- +const char *mmgl_axis="subplot 2 2 0:title 'Axis origin, Grid':origin 0 0:axis:grid:fplot 'x^3'\n" +"subplot 2 2 1:title '2 axis':ranges -1 1 -1 1:origin -1 -1:axis:ylabel 'axis_1':fplot 'sin(pi*x)' 'r2'\n" +"ranges 0 1 0 1:origin 1 1:axis:ylabel 'axis_2':fplot 'cos(pi*x)'\n" +"subplot 2 2 3:title 'More axis':origin nan nan:xrange -1 1:axis:xlabel 'x' 0:ylabel 'y_1' 0:fplot 'x^2' 'k'\n" +"yrange -1 1:origin -1.3 -1:axis 'y' 'r':ylabel '#r{y_2}' 0.2:fplot 'x^3' 'r'\n\n" +"subplot 2 2 2:title '4 segments, inverted axis':origin 0 0:\n" +"inplot 0.5 1 0.5 1 on:ranges 0 10 0 2:axis\nfplot 'sqrt(x/2)':xlabel 'W' 1:ylabel 'U' 1\n" +"inplot 0 0.5 0.5 1 on:ranges 1 0 0 2:axis 'x':fplot 'sqrt(x)+x^3':xlabel '\\tau' 1\n" +"inplot 0.5 1 0 0.5 on:ranges 0 10 4 0:axis 'y':fplot 'x/4':ylabel 'L' -1\n" +"inplot 0 0.5 0 0.5 on:ranges 1 0 4 0:fplot '4*x^2'\n"; +void smgl_axis(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Axis origin, Grid"); gr->SetOrigin(0,0); + gr->Axis(); gr->Grid(); gr->FPlot("x^3"); + + gr->SubPlot(2,2,1); gr->Title("2 axis"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1,-1,-1); // first axis + gr->Axis(); gr->Label('y',"axis 1",0); gr->FPlot("sin(pi*x)","r2"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(1,1,1); // second axis + gr->Axis(); gr->Label('y',"axis 2",0); gr->FPlot("cos(pi*x)"); + + gr->SubPlot(2,2,3); gr->Title("More axis"); gr->SetOrigin(NAN,NAN); gr->SetRange('x',-1,1); + gr->Axis(); gr->Label('x',"x",0); gr->Label('y',"y_1",0); gr->FPlot("x^2","k"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1.3,-1); // second axis + gr->Axis("y","r"); gr->Label('y',"#r{y_2}",0.2); gr->FPlot("x^3","r"); + + gr->SubPlot(2,2,2); gr->Title("4 segments, inverted axis"); gr->SetOrigin(0,0); + gr->InPlot(0.5,1,0.5,1); gr->SetRanges(0,10,0,2); gr->Axis(); + gr->FPlot("sqrt(x/2)"); gr->Label('x',"W",1); gr->Label('y',"U",1); + gr->InPlot(0,0.5,0.5,1); gr->SetRanges(1,0,0,2); gr->Axis("x"); + gr->FPlot("sqrt(x)+x^3"); gr->Label('x',"\\tau",-1); + gr->InPlot(0.5,1,0,0.5); gr->SetRanges(0,10,4,0); gr->Axis("y"); + gr->FPlot("x/4"); gr->Label('y',"L",-1); + gr->InPlot(0,0.5,0,0.5); gr->SetRanges(1,0,4,0); gr->FPlot("4*x^2"); +} +//----------------------------------------------------------------------------- +const char *mmgl_ticks="subplot 3 2 0:title 'Usual axis':axis\n" +"subplot 3 2 1:title 'Too big/small range':ranges -1000 1000 0 0.001:axis\n" +"subplot 3 2 3:title 'Too narrow range':ranges 100 100.1 10 10.01:axis\n" +"subplot 3 2 4:title 'Disable ticks tuning':tuneticks off:axis\n" +"subplot 3 2 2:title 'Manual ticks':ranges -pi pi 0 2:\n" +"xtick -pi '\\pi' -pi/2 '-\\pi/2' 0 '0' 0.886 'x^*' pi/2 '\\pi/2' pi 'pi'\n" +"# or you can use:\n#list v -pi -pi/2 0 0.886 pi/2 pi:xtick v '-\\pi\\n-\\pi/2\\n{}0\\n{}x^*\\n\\pi/2\\n\\pi'\n" +"axis:grid:fplot '2*cos(x^2)^2' 'r2'\n" +"subplot 3 2 5:title 'Time ticks':xrange 0 3e5:ticktime 'x':axis\n"; +void smgl_ticks(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("Usual axis"); gr->Axis(); + gr->SubPlot(3,2,1); gr->Title("Too big/small range"); + gr->SetRanges(-1000,1000,0,0.001); gr->Axis(); + gr->SubPlot(3,2,3); gr->Title("Too narrow range"); + gr->SetRanges(100,100.1,10,10.01); gr->Axis(); + gr->SubPlot(3,2,4); gr->Title("Disable ticks tuning"); + gr->SetTuneTicks(0); gr->Axis(); + + gr->SubPlot(3,2,2); gr->Title("Manual ticks"); gr->SetRanges(-M_PI,M_PI, 0, 2); + double val[]={-M_PI, -M_PI/2, 0, 0.886, M_PI/2, M_PI}; + gr->SetTicksVal('x', mglData(6,val), "-\\pi\n-\\pi/2\n0\nx^*\n\\pi/2\n\\pi"); + gr->Axis(); gr->Grid(); gr->FPlot("2*cos(x^2)^2", "r2"); + + gr->SubPlot(3,2,5); gr->Title("Time ticks"); gr->SetRange('x',0,3e5); + gr->SetTicksTime('x',0); gr->Axis(); +} +//----------------------------------------------------------------------------- +const char *mmgl_box="subplot 2 2 0:title 'Box (default)':rotate 50 60:box\n" +"subplot 2 2 1:title 'colored':rotate 50 60:box 'r'\n" +"subplot 2 2 2:title 'with faces':rotate 50 60:box '@'\n" +"subplot 2 2 3:title 'both':rotate 50 60:box '@cm'\n"; +void smgl_box(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Box (default)"); gr->Rotate(50,60); gr->Box(); + gr->SubPlot(2,2,1); gr->Title("colored"); gr->Rotate(50,60); gr->Box("r"); + gr->SubPlot(2,2,2); gr->Title("with faces"); gr->Rotate(50,60); gr->Box("@"); + gr->SubPlot(2,2,3); gr->Title("both"); gr->Rotate(50,60); gr->Box("@cm"); +} +//----------------------------------------------------------------------------- +const char *mmgl_loglog="subplot 2 2 0 '<_':title 'Semi-log axis':ranges 0.01 100 -1 1:axis 'lg(x)' '' ''\n" +"axis:grid 'xy' 'g':fplot 'sin(1/x)':xlabel 'x' 0:ylabel 'y = sin 1/x' 0\n" +"subplot 2 2 1 '<_':title 'Log-log axis':ranges 0.01 100 0.1 100:axis 'lg(x)' 'lg(y)' ''\n" +"axis:fplot 'sqrt(1+x^2)':xlabel 'x' 0:ylabel 'y = \\sqrt{1+x^2}' 0\n" +"subplot 2 2 2 '<_':title 'Minus-log axis':ranges -100 -0.01 -100 -0.1:axis '-lg(-x)' '-lg(-y)' ''\n" +"axis:fplot '-sqrt(1+x^2)':xlabel 'x' 0:ylabel 'y = -\\sqrt{1+x^2}' 0\n" +"subplot 2 2 3 '<_':title 'Log-ticks':ranges 0.01 100 0 100:axis 'sqrt(x)' '' ''\n" +"axis:fplot 'x':xlabel 'x' 1:ylabel 'y = x' 0\n"; +void smgl_loglog(mglGraph *gr) // log-log axis +{ + gr->SubPlot(2,2,0,"<_"); gr->Title("Semi-log axis"); gr->SetRanges(0.01,100,-1,1); gr->SetFunc("lg(x)",""); + gr->Axis(); gr->Grid("xy","g"); gr->FPlot("sin(1/x)"); gr->Label('x',"x",0); gr->Label('y', "y = sin 1/x",0); + gr->SubPlot(2,2,1,"<_"); gr->Title("Log-log axis"); gr->SetRanges(0.01,100,0.1,100); gr->SetFunc("lg(x)","lg(y)"); + gr->Axis(); gr->FPlot("sqrt(1+x^2)"); gr->Label('x',"x",0); gr->Label('y', "y = \\sqrt{1+x^2}",0); + gr->SubPlot(2,2,2,"<_"); gr->Title("Minus-log axis"); gr->SetRanges(-100,-0.01,-100,-0.1); gr->SetFunc("-lg(-x)","-lg(-y)"); + gr->Axis(); gr->FPlot("-sqrt(1+x^2)"); gr->Label('x',"x",0); gr->Label('y', "y = -\\sqrt{1+x^2}",0); + gr->SubPlot(2,2,3,"<_"); gr->Title("Log-ticks"); gr->SetRanges(0.1,100,0,100); gr->SetFunc("sqrt(x)",""); + gr->Axis(); gr->FPlot("x"); gr->Label('x',"x",1); gr->Label('y', "y = x",0); +} +//----------------------------------------------------------------------------- +const char *mmgl_venn="list x -0.3 0 0.3:list y 0.3 -0.3 0.3:list e 0.7 0.7 0.7\n" +"subplot 1 1 0:title 'Venn-like diagram'\ntransptype 1:alpha on:error x y e e '!rgb@#o'"; +void smgl_venn(mglGraph *gr) +{ + double xx[3]={-0.3,0,0.3}, yy[3]={0.3,-0.3,0.3}, ee[3]={0.7,0.7,0.7}; + mglData x(3,xx), y(3,yy), e(3,ee); + gr->SubPlot(1,1,0); gr->Title("Venn-like diagram"); + gr->SetTranspType(1); gr->Alpha(true); gr->Error(x,y,e,e,"!rgb@#o","alpha 0.1"); +} +//----------------------------------------------------------------------------- +const char *mmgl_stereo="call 'prepare2d'\nlight on\nsubplot 2 1 0:rotate 50 60+1:box:surf a\nsubplot 2 1 1:rotate 50 60-1:box:surf a\n"; +void smgl_stereo(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Light(true); + gr->SubPlot(2,1,0); gr->Rotate(50,60+1); + gr->Box(); gr->Surf(a); + gr->SubPlot(2,1,1); gr->Rotate(50,60-1); + gr->Box(); gr->Surf(a); +} +//----------------------------------------------------------------------------- +const char *mmgl_hist="new x 10000 '2*rnd-1':new y 10000 '2*rnd-1':copy z exp(-6*(x^2+y^2))\n" +"hist xx x z:norm xx 0 1:hist yy y z:norm yy 0 1\nmultiplot 3 3 3 2 2 '':ranges -1 1 -1 1 0 1:box:dots x y z 'wyrRk'\n" +"multiplot 3 3 0 2 1 '':ranges -1 1 0 1:box:bars xx\nmultiplot 3 3 5 1 2 '':ranges 0 1 -1 1:box:barh yy\n" +"subplot 3 3 2:text 0.5 0.5 'Hist and\\n{}MultiPlot\\n{}sample' 'a' -3\n"; +void smgl_hist(mglGraph *gr) +{ + mglData x(10000), y(10000), z(10000); gr->Fill(x,"2*rnd-1"); gr->Fill(y,"2*rnd-1"); gr->Fill(z,"exp(-6*(v^2+w^2))",x,y); + mglData xx=gr->Hist(x,z), yy=gr->Hist(y,z); xx.Norm(0,1); yy.Norm(0,1); + gr->MultiPlot(3,3,3,2,2,""); gr->SetRanges(-1,1,-1,1,0,1); gr->Box(); gr->Dots(x,y,z,"wyrRk"); + gr->MultiPlot(3,3,0,2,1,""); gr->SetRanges(-1,1,0,1); gr->Box(); gr->Bars(xx); + gr->MultiPlot(3,3,5,1,2,""); gr->SetRanges(0,1,-1,1); gr->Box(); gr->Barh(yy); + gr->SubPlot(3,3,2); gr->Puts(mglPoint(0.5,0.5),"Hist and\nMultiPlot\nsample","a",-3); +} +//----------------------------------------------------------------------------- +const char *mmgl_primitives="subplot 2 2 0 '':title 'Line, Curve, Rhomb, Ellipse' '' -1.5\n" +"line -1 -1 -0.5 1 'qAI'\ncurve -0.6 -1 1 1 0 1 1 1 'rA'\nball 0 -0.5 '*':ball 1 -0.1 '*'\n" +"rhomb 0 0.4 1 0.9 0.2 'b#'\nrhomb 0 0 1 0.4 0.2 'cg@'\n" +"ellipse 0 -0.5 1 -0.1 0.2 'u#'\nellipse 0 -1 1 -0.6 0.2 'm@'\n\n" +"light on\nsubplot 2 2 1:title 'Face[xyz]':rotate 50 60:box\n" +"facex 1 0 -1 1 1 'r':facey -1 -1 -1 1 1 'g':facez 1 -1 -1 -1 1 'b'\n" +"face -1 -1 1 -1 1 1 1 -1 0 1 1 1 'bmgr'\n\n" +"subplot 2 2 3 '':title 'Cone'\n" +"cone -0.7 -0.3 0 -0.7 0.7 0.5 0.2 0.1 'b':text -0.7 -0.7 'no edges\\n(default)'\n" +"cone 0 -0.3 0 0 0.7 0.5 0.2 0.1 'g@':text 0 -0.7 'with edges\\n('\\@' style)'\n" +"cone 0.7 -0.3 0 0.7 0.7 0.5 0.2 0.1 'ry':text 0.7 -0.7 '\"arrow\" with\\n{}gradient'\n\n" +"subplot 2 2 2 '':title 'Sphere and Drop'\nline -0.9 0 1 0.9 0 1\n" +"text -0.9 0.4 'sh=0':drop -0.9 0 0 1 0.5 'r' 0:ball -0.9 0 1 'k'\n" +"text -0.3 0.6 'sh=0.33':drop -0.3 0 0 1 0.5 'r' 0.33:ball -0.3 0 1 'k'\n" +"text 0.3 0.8 'sh=0.67':drop 0.3 0 0 1 0.5 'r' 0.67:ball 0.3 0 1 'k'\n" +"text 0.9 1. 'sh=1':drop 0.9 0 0 1 0.5 'r' 1:ball 0.9 0 1 'k'\n\n" +"text -0.9 -1.1 'asp=0.33':drop -0.9 -0.7 0 1 0.5 'b' 0 0.33\n" +"text -0.3 -1.1 'asp=0.67':drop -0.3 -0.7 0 1 0.5 'b' 0 0.67\n" +"text 0.3 -1.1 'asp=1':drop 0.3 -0.7 0 1 0.5 'b' 0 1\n" +"text 0.9 -1.1 'asp=1.5':drop 0.9 -0.7 0 1 0.5 'b' 0 1.5\n"; +void smgl_primitives(mglGraph *gr) // flag # +{ + gr->SubPlot(2,2,0,""); gr->Title("Line, Curve, Rhomb, Ellipse","",-1.5); + gr->Line(mglPoint(-1,-1),mglPoint(-0.5,1),"qAI"); + gr->Curve(mglPoint(-0.6,-1),mglPoint(1,1),mglPoint(0,1),mglPoint(1,1),"rA"); + gr->Rhomb(mglPoint(0,0.4),mglPoint(1,0.9),0.2,"b#"); + gr->Rhomb(mglPoint(0,0),mglPoint(1,0.4),0.2,"cg@"); + gr->Ellipse(mglPoint(0,-0.5),mglPoint(1,-0.1),0.2,"u#"); + gr->Ellipse(mglPoint(0,-1),mglPoint(1,-0.6),0.2,"m@"); + gr->Mark(mglPoint(0,-0.5),"*"); gr->Mark(mglPoint(1,-0.1),"*"); + + gr->Light(true); + gr->SubPlot(2,2,1); gr->Title("Face[xyz]"); gr->Rotate(50,60); gr->Box(); + gr->FaceX(mglPoint(1,0,-1),1,1,"r"); + gr->FaceY(mglPoint(-1,-1,-1),1,1,"g"); + gr->FaceZ(mglPoint(1,-1,-1),-1,1,"b"); + gr->Face(mglPoint(-1,-1,1),mglPoint(-1,1,1),mglPoint(1,-1,0),mglPoint(1,1,1),"bmgr"); + + gr->SubPlot(2,2,3,""); gr->Title("Cone"); + gr->Cone(mglPoint(-0.7,-0.3),mglPoint(-0.7,0.7,0.5),0.2,0.1,"b"); + gr->Puts(mglPoint(-0.7,-0.7),"no edges\n(default)"); + gr->Cone(mglPoint(0,-0.3),mglPoint(0,0.7,0.5),0.2,0.1,"g@"); + gr->Puts(mglPoint(0,-0.7),"with edges\n('\\@' style)"); + gr->Cone(mglPoint(0.7,-0.3),mglPoint(0.7,0.7,0.5),0.2,0,"ry"); + gr->Puts(mglPoint(0.7,-0.7),"'arrow' with\ngradient"); + + gr->SubPlot(2,2,2,""); gr->Title("Sphere and Drop"); gr->Alpha(false); + gr->Puts(mglPoint(-0.9,0.4),"sh=0"); gr->Ball(mglPoint(-0.9,0,1),'k'); + gr->Drop(mglPoint(-0.9,0),mglPoint(0,1),0.5,"r",0); + gr->Puts(mglPoint(-0.3,0.6),"sh=0.33"); gr->Ball(mglPoint(-0.3,0,1),'k'); + gr->Drop(mglPoint(-0.3,0),mglPoint(0,1),0.5,"r",0.33); + gr->Puts(mglPoint(0.3,0.8),"sh=0.67"); gr->Ball(mglPoint(0.3,0,1),'k'); + gr->Drop(mglPoint(0.3,0),mglPoint(0,1),0.5,"r",0.67); + gr->Puts(mglPoint(0.9,1),"sh=1"); gr->Ball(mglPoint(0.9,0,1),'k'); + gr->Drop(mglPoint(0.9,0),mglPoint(0,1),0.5,"r",1); + gr->Line(mglPoint(-0.9,0,1),mglPoint(0.9,0,1),"b"); + + gr->Puts(mglPoint(-0.9,-1.1),"asp=0.33"); + gr->Drop(mglPoint(-0.9,-0.7),mglPoint(0,1),0.5,"b",0,0.33); + gr->Puts(mglPoint(-0.3,-1.1),"asp=0.67"); + gr->Drop(mglPoint(-0.3,-0.7),mglPoint(0,1),0.5,"b",0,0.67); + gr->Puts(mglPoint(0.3,-1.1),"asp=1"); + gr->Drop(mglPoint(0.3,-0.7),mglPoint(0,1),0.5,"b",0,1); + gr->Puts(mglPoint(0.9,-1.1),"asp=1.5"); + gr->Drop(mglPoint(0.9,-0.7),mglPoint(0,1),0.5,"b",0,1.5); +} +//----------------------------------------------------------------------------- +const char *mmgl_table="new ys 10 3 '0.8*sin(pi*(x+y/4+1.25))+0.2*rnd'\n" +"subplot 2 2 0:title 'Table sample':box\ntable ys 'y_1\\n{}y_2\\n{}y_3'\n\n" +"subplot 2 2 1:title 'no borders, colored'\ntable ys 'y_1\\n{}y_2\\n{}y_3' 'r|'\n\n" +"subplot 2 2 2:title 'no font decrease'\ntable ys 'y_1\\n{}y_2\\n{}y_3' '#'\n\n" +"subplot 2 2 3:title 'manual width and position':box\n" +"table 0.5 0.95 ys 'y_1\\n{}y_2\\n{}y_3' '#';value 0.7\n"; +void smgl_table(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Table plot"); } + gr->Table(ys,"y_1\ny_2\ny_3"); gr->Box(); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("no borders, colored"); + gr->Table(ys,"y_1\ny_2\ny_3","r|"); + gr->SubPlot(2,2,2); gr->Title("no font decrease"); + gr->Table(ys,"y_1\ny_2\ny_3","#"); + gr->SubPlot(2,2,3); gr->Title("manual width, position"); + gr->Table(0.5, 0.95, ys,"y_1\ny_2\ny_3","#", "value 0.7"); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_label="new ys 10 '0.2*rnd-0.8*sin(pi*x)'\n" +"subplot 1 1 0 '':title 'Label plot':box:plot ys ' *':label ys 'y=%y'\n"; +void smgl_label(mglGraph *gr) +{ + mglData ys(10); ys.Modify("0.8*sin(pi*2*x)+0.2*rnd"); + if(big!=3) { gr->SubPlot(1,1,0,""); gr->Title("Label plot"); } + gr->Box(); gr->Plot(ys," *"); gr->Label(ys,"y=%y"); +} +//----------------------------------------------------------------------------- +const char *mmgl_colorbar="call 'prepare2d'\nnew v 9 'x'\nsubplot 2 2 0:title 'Colorbar out of box':box\n" +"colorbar '<':colorbar '>':colorbar '_':colorbar '^'\n" +"subplot 2 2 1:title 'Colorbar near box':box\n" +"colorbar 'I':colorbar '_I':colorbar '^I'\n" +"subplot 2 2 2:title 'manual colors':box:contd v a\n" +"colorbar v '<':colorbar v '>':colorbar v '_':colorbar v '^'\n" +"subplot 2 2 3:title '':text -0.5 1.55 'Color positions' ':C' -2\n" +"colorbar 'bwr>' 0.25 0:text -0.9 1.2 'Default'\n" +"colorbar 'b{w,0.3}r>' 0.5 0:text -0.1 1.2 'Manual'\ncrange 0.01 1e3\n" +"colorbar '>' 0.75 0:text 0.65 1.2 'Normal scale':colorbar '>':text 1.35 1.2 'Log scale'\n"; +void smgl_colorbar(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Colorbar out of box"); gr->Box(); + gr->Colorbar("<"); gr->Colorbar(">"); gr->Colorbar("_"); gr->Colorbar("^"); + gr->SubPlot(2,2,1); gr->Title("Colorbar near box"); gr->Box(); + gr->Colorbar("Colorbar(">I"); gr->Colorbar("_I"); gr->Colorbar("^I"); + gr->SubPlot(2,2,2); gr->Title("manual colors"); + mglData a,v; mgls_prepare2d(&a,0,&v); + gr->Box(); gr->ContD(v,a); + gr->Colorbar(v,"<"); gr->Colorbar(v,">"); gr->Colorbar(v,"_"); gr->Colorbar(v,"^"); + + gr->SubPlot(2,2,3); gr->Title(" "); + gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2); + gr->Colorbar("bwr>",0.25,0); gr->Puts(mglPoint(-0.9,1.2),"Default"); + gr->Colorbar("b{w,0.3}r>",0.5,0); gr->Puts(mglPoint(-0.1,1.2),"Manual"); + + gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2); + gr->SetRange('c',0.01,1e3); + gr->Colorbar(">",0.75,0); gr->Puts(mglPoint(0.65,1.2),"Normal scale"); + gr->SetFunc("","","","lg(c)"); + gr->Colorbar(">"); gr->Puts(mglPoint(1.35,1.2),"Log scale"); +} +//----------------------------------------------------------------------------- +const char *mmgl_legend="addlegend 'sin(\\pi {x^2})' 'b':addlegend 'sin(\\pi x)' 'g*'\n" +"addlegend 'sin(\\pi \\sqrt{x})' 'rd':addlegend 'jsut text' ' ':addlegend 'no indent for this' ''\n" +"subplot 2 2 0 '':title 'Legend (default)':box:legend\n" +"legend 3 'A#':text 0.75 0.65 'Absolute position' 'A'\n" +"subplot 2 2 2 '':title 'coloring':box:legend 0 'r#':legend 1 'Wb#':legend 2 'ygr#'\n" +"subplot 2 2 3 '':title 'manual position':box\n" +"legend 0.5 1:text 0.5 0.55 'at x=0.5, y=1' 'a'\n" +"legend 1 '#-':text 0.75 0.25 'Horizontal legend' 'a'\n"; +void smgl_legend(mglGraph *gr) +{ + gr->AddLegend("sin(\\pi {x^2})","b"); + gr->AddLegend("sin(\\pi x)","g*"); + gr->AddLegend("sin(\\pi \\sqrt{x})","rd"); + gr->AddLegend("just text"," "); + gr->AddLegend("no indent for this",""); + if(big!=3) {gr->SubPlot(2,2,0,""); gr->Title("Legend (default)");} + gr->Box(); gr->Legend(); + if(big==3) return; + gr->Legend(3,"A#"); + gr->Puts(mglPoint(0.75,0.65),"Absolute position","A"); + gr->SubPlot(2,2,2,""); gr->Title("coloring"); gr->Box(); + gr->Legend(0,"r#"); gr->Legend(1,"Wb#"); gr->Legend(2,"ygr#"); + gr->SubPlot(2,2,3,""); gr->Title("manual position"); gr->Box(); + gr->Legend(0.5,1); + gr->Puts(mglPoint(0.5,0.55),"at x=0.5, y=1","a"); + gr->Legend(1,"#-"); + gr->Puts(mglPoint(0.75,0.25),"Horizontal legend","a"); +} +//----------------------------------------------------------------------------- +const char *mmgl_dat_diff="ranges 0 1 0 1 0 1:new a 30 40 'x*y'\n" +"subplot 2 2 0:title 'a(x,y)':rotate 60 40:surf a:box\n" +"subplot 2 2 1:title 'da/dx':rotate 60 40:diff a 'x':surf a:box\n" +"subplot 2 2 2:title '\\int da/dx dxdy':rotate 60 40:integrate a 'xy':surf a:box\n" +"subplot 2 2 3:title '\\int {d^2}a/dxdy dx':rotate 60 40:diff2 a 'y':surf a:box\n"; +void smgl_dat_diff(mglGraph *gr) // differentiate +{ + gr->SetRanges(0,1,0,1,0,1); + mglData a(30,40); a.Modify("x*y"); + gr->SubPlot(2,2,0); gr->Title("a(x,y)"); gr->Rotate(60,40); + gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Title("da/dx"); gr->Rotate(60,40); + a.Diff("x"); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Title("\\int da/dx dxdy"); gr->Rotate(60,40); + a.Integral("xy"); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("\\int {d^2}a/dxdy dx"); gr->Rotate(60,40); + a.Diff2("y"); gr->Surf(a); gr->Box(); +} +//----------------------------------------------------------------------------- +const char *mmgl_dat_extra="subplot 2 2 0 '':title 'Envelop sample':new d1 1000 'exp(-8*x^2)*sin(10*pi*x)'\n" +"axis:plot d1 'b':envelop d1 'x':plot d1 'r'\n" +"subplot 2 2 1 '':title 'Smooth sample':ranges 0 1 0 1\nnew y0 30 '0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd'\n" +"copy y1 y0:smooth y1 'x3':plot y1 'r';legend '\"3\" style'\ncopy y2 y0:smooth y2 'x5':plot y2 'g';legend '\"5\" style'\n" +"copy y3 y0:smooth y3 'x':plot y3 'b';legend 'default'\nplot y0 '{m7}:s';legend 'none'\nlegend:box\n" +"subplot 2 2 2:title 'Sew sample':rotate 50 60:light on:alpha on\nnew d2 100 100 'mod((y^2-(1-x)^2)/2,0.1)'\n" +"box:surf d2 'b':sew d2 'xy' 0.1:surf d2 'r'\n" +"subplot 2 2 3:title 'Resize sample (interpolation)'\nnew x0 10 'rnd':new v0 10 'rnd'\n" +"resize x1 x0 100:resize v1 v0 100\nplot x0 v0 'b+ ':plot x1 v1 'r-':label x0 v0 '%n'\n"; +void smgl_dat_extra(mglGraph *gr) // differentiate +{ + gr->SubPlot(2,2,0,""); gr->Title("Envelop sample"); + mglData d1(1000); gr->Fill(d1,"exp(-8*x^2)*sin(10*pi*x)"); + gr->Axis(); gr->Plot(d1, "b"); + d1.Envelop('x'); gr->Plot(d1, "r"); + + gr->SubPlot(2,2,1,""); gr->Title("Smooth sample"); + mglData y0(30),y1,y2,y3; + gr->SetRanges(0,1,0,1); + gr->Fill(y0, "0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd"); + + y1=y0; y1.Smooth("x3"); + y2=y0; y2.Smooth("x5"); + y3=y0; y3.Smooth("x"); + + gr->Plot(y0,"{m7}:s", "legend 'none'"); //gr->AddLegend("none","k"); + gr->Plot(y1,"r", "legend ''3' style'"); + gr->Plot(y2,"g", "legend ''5' style'"); + gr->Plot(y3,"b", "legend 'default'"); + gr->Legend(); gr->Box(); + + gr->SubPlot(2,2,2); gr->Title("Sew sample"); + mglData d2(100, 100); gr->Fill(d2, "mod((y^2-(1-x)^2)/2,0.1)"); + gr->Rotate(50, 60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf(d2, "b"); + d2.Sew("xy", 0.1); gr->Surf(d2, "r"); + + gr->SubPlot(2,2,3); gr->Title("Resize sample (interpolation)"); + mglData x0(10), v0(10), x1, v1; + gr->Fill(x0,"rnd"); gr->Fill(v0,"rnd"); + x1 = x0.Resize(100); v1 = v0.Resize(100); + gr->Plot(x0,v0,"b+ "); gr->Plot(x1,v1,"r-"); + gr->Label(x0,v0,"%n"); +} +//----------------------------------------------------------------------------- +const char *mmgl_ternary="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n" +"new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n" +"new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n" +"subplot 2 2 0:title 'Ordinary axis 3D':rotate 50 60\nbox:axis:grid\n" +"plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':zlabel 'Z'\n\n" +"subplot 2 2 1:title 'Ternary axis (x+y+t=1)':ternary 1\nbox:axis:grid 'xyz' 'B;'\n" +"plot x y 'r2':plot rx ry 'q^ ':cont a:line 0.5 0 0 0.75 'g2'\nxlabel 'B':ylabel 'C':tlabel 'A'\n\n" +"subplot 2 2 2:title 'Quaternary axis 3D':rotate 50 60:ternary 2\nbox:axis:grid 'xyz' 'B;'\n" +"plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':tlabel 'A':zlabel 'D'\n\n" +"subplot 2 2 3:title 'Ternary axis 3D':rotate 50 60:ternary 1\nbox:axis:grid 'xyz' 'B;'\n" +"plot x y z 'r2':surf a '#'\nxlabel 'B':ylabel 'C':tlabel 'A':zlabel 'Z'\n"; +void smgl_ternary(mglGraph *gr) // flag # +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + gr->SubPlot(2,2,0); gr->Title("Ordinary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"B",1); gr->Label('y',"C",1); gr->Label('z',"Z",1); + + gr->SubPlot(2,2,1); gr->Title("Ternary axis (x+y+t=1)"); + gr->Ternary(1); + gr->Plot(x,y,"r2"); gr->Plot(rx,ry,"q^ "); gr->Cont(a); + gr->Line(mglPoint(0.5,0), mglPoint(0,0.75), "g2"); + gr->Axis(); gr->Grid("xyz","B;"); + gr->Label('x',"B"); gr->Label('y',"C"); gr->Label('t',"A"); + + gr->SubPlot(2,2,2); gr->Title("Quaternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(2); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"D",1); + + gr->SubPlot(2,2,3); gr->Title("Ternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(1); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"Z",1); +} +//----------------------------------------------------------------------------- +const char *mmgl_projection="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n" +"new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n" +"new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n" +"title 'Projection sample':ternary 4:rotate 50 60\nbox:axis:grid\n" +"plot x y z 'r2':surf a '#'\nxlabel 'X':ylabel 'Y':zlabel 'Z'\n"; +void smgl_projection(mglGraph *gr) // flag # +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + if(big!=3) gr->Title("Projection sample"); + gr->Ternary(4); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"X",1); gr->Label('y',"Y",1); gr->Label('z',"Z",1); +} +//----------------------------------------------------------------------------- +const char *mmgl_projection5="ranges 0 1 0 1 0 1\nnew x 50 '0.25*(1+cos(2*pi*x))'\n" +"new y 50 '0.25*(1+sin(2*pi*x))'\nnew z 50 'x'\nnew a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)'\n" +"new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx\nlight on\n\n" +"title 'Projection sample (ternary)':ternary 5:rotate 50 60\nbox:axis:grid\n" +"plot x y z 'r2':surf a '#'\nxlabel 'X':ylabel 'Y':zlabel 'Z'\n"; +void smgl_projection5(mglGraph *gr) // flag # +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + if(big!=3) gr->Title("Projection sample (ternary)"); + gr->Ternary(5); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"X",1); gr->Label('y',"Y",1); gr->Label('z',"Z",1); +} +//----------------------------------------------------------------------------- +const char *mmgl_triplot="list q 0 1 2 3 | 4 5 6 7 | 0 2 4 6 | 1 3 5 7 | 0 4 1 5 | 2 6 3 7\n" +"list xq -1 1 -1 1 -1 1 -1 1\nlist yq -1 -1 1 1 -1 -1 1 1\nlist zq -1 -1 -1 -1 1 1 1 1\nlight on\n" +"subplot 2 2 0:title 'QuadPlot sample':rotate 50 60\n" +"quadplot q xq yq zq 'yr'\nquadplot q xq yq zq '#k'\n" +"subplot 2 2 2:title 'QuadPlot coloring':rotate 50 60\n" +"quadplot q xq yq zq yq 'yr'\nquadplot q xq yq zq '#k'\n" +"list t 0 1 2 | 0 1 3 | 0 2 3 | 1 2 3\n" +"list xt -1 1 0 0\nlist yt -1 -1 1 0\nlist zt -1 -1 -1 1\n" +"subplot 2 2 1:title 'TriPlot sample':rotate 50 60\n" +"triplot t xt yt zt 'b'\ntriplot t xt yt zt '#k'\n" +"subplot 2 2 3:title 'TriPlot coloring':rotate 50 60\n" +"triplot t xt yt zt yt 'cb'\ntriplot t xt yt zt '#k'\ntricont t xt yt zt 'B'\n"; +void smgl_triplot(mglGraph *gr) +{ + double q[] = {0,1,2,3, 4,5,6,7, 0,2,4,6, 1,3,5,7, 0,4,1,5, 2,6,3,7}; + double xc[] = {-1,1,-1,1,-1,1,-1,1}, yc[] = {-1,-1,1,1,-1,-1,1,1}, zc[] = {-1,-1,-1,-1,1,1,1,1}; + mglData qq(6,4,q), xx(8,xc), yy(8,yc), zz(8,zc); + gr->Light(true); //gr->Alpha(true); + gr->SubPlot(2,2,0); gr->Title("QuadPlot sample"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + gr->SubPlot(2,2,2); gr->Title("QuadPlot coloring"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,yy,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + + double t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; + double xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; + mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); + gr->SubPlot(2,2,1); gr->Title("TriPlot sample"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,"b"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->SubPlot(2,2,3); gr->Title("TriPlot coloring"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,vv,"cb"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->TriCont(tt,uu,vv,ww,"B"); +} +//----------------------------------------------------------------------------- +const char *mmgl_dots="new t 1000 'pi*(rnd-0.5)':new f 1000 '2*pi*rnd'\n" +"copy x 0.9*cos(t)*cos(f):copy y 0.9*cos(t)*sin(f):copy z 0.6*sin(t)\n" +"title 'Dots sample':rotate 50 60\nbox:dots x y z\n"; +void smgl_dots(mglGraph *gr) +{ + int i, n=1000; + mglData x(n),y(n),z(n); + for(i=0;iTitle("Dots sample"); + gr->Rotate(50,60); gr->Box(); gr->Dots(x,y,z); +} +//----------------------------------------------------------------------------- +/*void smgl_surf3_rgbd(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Rotate(40,60); gr->VertexColor(true); + gr->Box(); gr->Surf3(c,"bgrd"); +}*/ +//----------------------------------------------------------------------------- +const char *mmgl_mirror="new a 31 41 '-pi*x*exp(-(y+1)^2-4*x^2)'\n" +"subplot 2 2 0:title 'Options for coordinates':alpha on:light on:rotate 40 60:box\n" +"surf a 'r';yrange 0 1:surf a 'b';yrange 0 -1\n" +"subplot 2 2 1:title 'Option \"meshnum\"':rotate 40 60:box\n" +"mesh a 'r'; yrange 0 1:mesh a 'b';yrange 0 -1; meshnum 5\n" +"subplot 2 2 2:title 'Option \"alpha\"':rotate 40 60:box\n" +"surf a 'r';yrange 0 1; alpha 0.7:surf a 'b';yrange 0 -1; alpha 0.3\n" +"subplot 2 2 3 '<_':title 'Option \"legend\"'\n" +"fplot 'x^3' 'r'; legend 'y = x^3':fplot 'cos(pi*x)' 'b'; legend 'y = cos \\pi x'\n" +"box:axis:legend 2\n"; +void smgl_mirror(mglGraph *gr) // flag # +{ + mglData a(31,41); + gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)"); + + if(big!=3) { gr->SubPlot(2,2,0); gr->Title("Options for coordinates"); } + gr->Alpha(true); gr->Light(true); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1"); + if(big==3) return; + gr->SubPlot(2,2,1); gr->Title("Option 'meshnum'"); + gr->Rotate(40,60); gr->Box(); + gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5"); + gr->SubPlot(2,2,2); gr->Title("Option 'alpha'"); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1; alpha 0.7"); gr->Surf(a,"b","yrange 0 -1; alpha 0.3"); + gr->SubPlot(2,2,3,"<_"); gr->Title("Option 'legend'"); + gr->FPlot("x^3","r","legend 'y = x^3'"); gr->FPlot("cos(pi*x)","b","legend 'y = cos \\pi x'"); + gr->Box(); gr->Axis(); gr->Legend(2,""); +} +//----------------------------------------------------------------------------- +mglSample samp[] = { + {"alpha", smgl_alpha, mmgl_alpha }, + {"area", smgl_area, mmgl_area}, + {"aspect", smgl_aspect, mmgl_aspect }, + {"axial", smgl_axial, mmgl_axial }, + {"axis", smgl_axis, mmgl_axis}, + {"barh", smgl_barh, mmgl_barh}, + {"bars", smgl_bars, mmgl_bars}, + {"belt", smgl_belt, mmgl_belt}, + {"box", smgl_box, mmgl_box}, + {"boxplot", smgl_boxplot, mmgl_boxplot}, + {"boxs", smgl_boxs, mmgl_boxs}, + {"candle", smgl_candle, mmgl_candle}, + {"chart", smgl_chart, mmgl_chart}, + {"cloud", smgl_cloud, mmgl_cloud }, + {"colorbar", smgl_colorbar, mmgl_colorbar}, + {"combined", smgl_combined, mmgl_combined }, + {"cones", smgl_cones, mmgl_cones}, + {"cont", smgl_cont, mmgl_cont}, + {"cont_xyz", smgl_cont_xyz, mmgl_cont_xyz}, + {"conta", smgl_conta, mmgl_conta}, + {"contd", smgl_contd, mmgl_contd}, + {"contf", smgl_contf, mmgl_contf}, + {"contf_xyz", smgl_contf_xyz, mmgl_contf_xyz}, + {"contfa", smgl_contfa, mmgl_contfa}, + {"contv", smgl_contv, mmgl_contv}, + {"correl", smgl_correl, mmgl_correl}, +// {"crust", smgl_crust, mmgl_crust}, // TODO: open after triangulation + {"curvcoor", smgl_curvcoor, mmgl_curvcoor}, + {"cut", smgl_cut, mmgl_cut}, + {"dat_diff", smgl_dat_diff, mmgl_dat_diff}, + {"dat_extra", smgl_dat_extra, mmgl_dat_extra }, + {"data1", smgl_data1, mmgl_data1}, + {"data2", smgl_data2, mmgl_data2}, + {"dens", smgl_dens, mmgl_dens}, + {"dens_xyz", smgl_dens_xyz, mmgl_dens_xyz}, + {"densa", smgl_densa, mmgl_densa}, + {"dew", smgl_dew, mmgl_dew}, + {"dots", smgl_dots, mmgl_dots}, + {"error", smgl_error, mmgl_error}, + {"error2", smgl_error2, mmgl_error2}, + {"export", smgl_export, mmgl_export}, + {"fall", smgl_fall, mmgl_fall}, + {"fexport", smgl_fexport, mmgl_fexport}, + {"fit", smgl_fit, mmgl_fit}, + {"flow", smgl_flow, mmgl_flow}, + {"fog", smgl_fog, mmgl_fog}, + {"fonts", smgl_fonts, mmgl_fonts}, + {"grad", smgl_grad, mmgl_grad}, + {"hist", smgl_hist, mmgl_hist}, + {"inplot", smgl_inplot, mmgl_inplot}, + {"label", smgl_label, mmgl_label}, + {"legend", smgl_legend, mmgl_legend }, + {"light", smgl_light, mmgl_light}, + {"loglog", smgl_loglog, mmgl_loglog}, + {"map", smgl_map, mmgl_map}, + {"mark", smgl_mark, mmgl_mark}, + {"mask", smgl_mask, mmgl_mask}, + {"mesh", smgl_mesh, mmgl_mesh}, + {"mirror", smgl_mirror, mmgl_mirror }, + {"molecule", smgl_molecule, mmgl_molecule }, + {"ohlc", smgl_ohlc, mmgl_ohlc}, + {"param1", smgl_param1, mmgl_param1}, + {"param2", smgl_param2, mmgl_param2}, + {"param3", smgl_param3, mmgl_param3}, + {"paramv", smgl_paramv, mmgl_paramv}, + {"parser", smgl_parser, mmgl_parser}, + {"pde", smgl_pde, mmgl_pde}, + {"pipe", smgl_pipe, mmgl_pipe}, + {"plot", smgl_plot, mmgl_plot}, + {"primitives", smgl_primitives, mmgl_primitives }, + {"projection", smgl_projection, mmgl_projection }, + {"projection5", smgl_projection5, mmgl_projection5 }, + {"qo2d", smgl_qo2d, mmgl_qo2d}, + {"radar", smgl_radar, mmgl_radar}, + {"refill", smgl_refill, mmgl_refill}, + {"region", smgl_region, mmgl_region}, + {"schemes", smgl_schemes, mmgl_schemes }, + {"several_light", smgl_several_light, mmgl_several_light }, + {"solve", smgl_solve, mmgl_solve}, + {"stem", smgl_stem, mmgl_stem}, + {"step", smgl_step, mmgl_step}, + {"stereo", smgl_stereo, mmgl_stereo}, + {"stfa", smgl_stfa, mmgl_stfa}, + {"style", smgl_style, mmgl_style }, + {"surf", smgl_surf, mmgl_surf}, + {"surf3", smgl_surf3, mmgl_surf3}, + {"surf3a", smgl_surf3a, mmgl_surf3a}, + {"surf3c", smgl_surf3c, mmgl_surf3c}, + {"surfa", smgl_surfa, mmgl_surfa}, + {"surfc", smgl_surfc, mmgl_surfc}, + {"table", smgl_table, mmgl_table}, + {"tape", smgl_tape, mmgl_tape}, + {"tens", smgl_tens, mmgl_tens}, + {"ternary", smgl_ternary, mmgl_ternary }, + {"text", smgl_text, mmgl_text}, + {"text2", smgl_text2, mmgl_text2}, + {"textmark", smgl_textmark, mmgl_textmark}, + {"ticks", smgl_ticks, mmgl_ticks}, + {"tile", smgl_tile, mmgl_tile}, + {"tiles", smgl_tiles, mmgl_tiles}, + {"torus", smgl_torus, mmgl_torus }, + {"traj", smgl_traj, mmgl_traj}, + {"triangulation",smgl_triangulation, mmgl_triangulation }, + {"triplot", smgl_triplot, mmgl_triplot}, + {"tube", smgl_tube, mmgl_tube}, + {"type0", smgl_type0, mmgl_type0}, + {"type1", smgl_type1, mmgl_type1}, + {"type2", smgl_type2, mmgl_type2}, + {"vect", smgl_vect, mmgl_vect}, + {"vecta", smgl_vecta, mmgl_vecta}, + {"venn", smgl_venn, mmgl_venn}, +{"", NULL, NULL}}; +//----------------------------------------------------------------------------- diff --git a/examples/wnd_samples.cpp b/examples/wnd_samples.cpp new file mode 100644 index 0000000..2839a9b --- /dev/null +++ b/examples/wnd_samples.cpp @@ -0,0 +1,518 @@ +/*************************************************************************** + * wnd_sample.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#include "mgl2/mgl.h" +//----------------------------------------------------------------------------- +void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0); +void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0); +void mgls_prepare3d(mglData *a, mglData *b=0); +void mgls_prepare2v(mglData *a, mglData *b); +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez); +//----------------------------------------------------------------------------- +int test_wnd(mglGraph *gr) +{ +mgl_set_test_mode(true); +// gr->SetQuality(6); + gr->NewFrame(); // 0 + gr->Box(); + gr->EndFrame(); + gr->NewFrame(); // 1 + gr->Axis(); + gr->EndFrame(); + gr->NewFrame(); // 2 + gr->Label('x',"XXXX",0); + gr->Label('y',"YYYY",0); + gr->EndFrame(); + gr->NewFrame(); // 3 + gr->Puts(mglPoint(0,0),"0"); + gr->EndFrame(); + + gr->Clf(); + gr->ShowFrame(0); + gr->ShowFrame(1); + gr->ShowFrame(2); + gr->ShowFrame(3); +// gr->Puts(mglPoint(0,1),"1"); + gr->Finish(); + return 0; +} +//----------------------------------------------------------------------------- +int sample(mglGraph *gr) +{ + gr->Rotate(20,40); + gr->SetRanges(-2,2,-2,2,-1,3); + gr->FSurf("cos(2*pi*(x^2+y^2))/(x^2+y^2+1)^2/(x^2+y^2<4)"); + gr->Drop(mglPoint(0,0,3),mglPoint(0,0,-1),0.7,"b"); + return 0; +} +//----------------------------------------------------------------------------- +int sample_m(mglGraph *gr) +{ +// gr->Rotate(0,0); gr->Axis(); gr->Box(); return 0; +// gr->Alpha(true); gr->Light(true); + + gr->SubPlot(2,2,0); + gr->Puts(mglPoint(0,1.1),"Methane, CH_4",0,-2); gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"k"); + gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2); + gr->Sphere(mglPoint(0,0,0.7),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g"); + + gr->SubPlot(2,2,1); + gr->Puts(mglPoint(0,1.1),"Water, H{_2}O",0,-2); gr->Rotate(60,100); + gr->Sphere(mglPoint(0,0,0),0.25,"r"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g"); + + gr->SubPlot(2,2,2); + gr->Puts(mglPoint(0,1.1),"Oxygen, O_2",0,-2); gr->Rotate(60,120); + gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,0.5,0),0.25,"r"); + gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,-0.5,0),0.25,"r"); + + gr->SubPlot(2,2,3); + gr->Puts(mglPoint(0,1.1),"Ammonia, NH_3",0,-2); gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"b"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2); + gr->Sphere(mglPoint(-0.65,0,0),0.25,"g"); + return 0; +} +//----------------------------------------------------------------------------- +int sample_1(mglGraph *gr) +{ + mglData a(50,15),d(50),d1(50),d2(50); + d.Modify("0.7*sin(2*pi*x) + 0.5*cos(3*pi*x) + 0.2*sin(pi*x)"); + d1.Modify("cos(2*pi*x)"); + d2.Modify("sin(2*pi*x)"); + a.Modify("pow(x,4*y)"); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Simple plot of one curve"); + gr->Plot(d); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Three curves with manual styles"); + gr->Plot(d,"b"); + gr->Plot(d1,"ri"); + gr->Plot(d2,"m|^"); + gr->Plot(d,"l o"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Three curves with automatic styles"); + gr->Plot(d); + gr->Plot(d1); + gr->Plot(d2); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Curves from matrix"); + gr->Plot(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Parametrical curves in 2D"); + gr->Plot(d1,d2,"b"); + gr->Plot(d1,d,"ri"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Parametrical curves in 3D"); + gr->Rotate(60,40); + gr->Box(); gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); gr->Label('z',"z"); + gr->Plot(d1,d2,d,"b"); + gr->EndFrame(); + + gr->NewFrame(); + gr->SubPlot(2,2,0); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Area plot"); + gr->Area(d); + gr->SubPlot(2,2,1); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Step plot"); + gr->Step(d); + gr->SubPlot(2,2,2); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Stem plot"); + gr->Stem(d); + gr->SubPlot(2,2,3); + gr->Box(); gr->Axis("xy"); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Puts(mglPoint(0,1.2,1),"Bars plot"); + gr->Bars(d); + gr->EndFrame(); + + gr->NewFrame(); + gr->SubPlot(2,2,0); + gr->Puts(mglPoint(0,1.2,1),"Area plot in 3D"); + gr->Rotate(60,40); + gr->Box(); gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Area(d1,d2,d); + gr->SubPlot(2,2,1); + gr->Puts(mglPoint(0,1.2,1),"Step plot in 3D"); + gr->Rotate(60,40); + gr->Box(); gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Step(d1,d2,d); + gr->SubPlot(2,2,2); + gr->Puts(mglPoint(0,1.2,1),"Stem plot in 3D"); + gr->Rotate(60,40); + gr->Box(); gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Stem(d1,d2,d); + gr->SubPlot(2,2,3); + gr->Puts(mglPoint(0,1.2,1),"Bars plot in 3D"); + gr->Rotate(60,40); + gr->Box(); gr->Axis(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->Bars(d1,d2,d); + gr->EndFrame(); + return gr->GetNumFrame(); +} +//----------------------------------------------------------------------------- +int sample_2(mglGraph *gr) +{ + mglData a(50,50),b(50,50),c(50,50),d(50,50),m(50,50),c1(50,50,7), + d1(50),d2(50); + d1.Modify("2*x*x-1"); d2.Modify("sin(pi*(x-0.5))"); + a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))"); + b.Modify("(2+sin(2*pi*x))*cos(2*pi*y)/3"); + c.Modify("(2+sin(2*pi*x))*sin(2*pi*y)/3"); + d.Modify("cos(2*pi*x)"); + m.Modify("cos(pi*x)"); + c1.Modify("(2-z)*(2*x-1)^2 + (z+1)*(2*y-1)^2"); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Simple surface"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(a); +// gr->Colorbar(); + gr->EndFrame(); + + gr->NewFrame(); + gr->SubPlot(2,2,0); + gr->Puts(mglPoint(0,1.2,1),"Gray color scheme 'kw'"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(a,"kw"); + gr->SubPlot(2,2,1); + gr->Puts(mglPoint(0,1.2,1),"Hot color scheme 'wyrRk'"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(a,"wyrRk"); + gr->SubPlot(2,2,2); + gr->Puts(mglPoint(0,1.2,1),"Along coordiantes 'rgbd'"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(a,"rgbd"); + gr->SubPlot(2,2,3); + gr->Puts(mglPoint(0,1.2,1),"Bicolor scheme 'BbwrR'"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(a,"BbwrR"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis(); + gr->Puts(mglPoint(0,1.2,1),"Density plot"); + gr->Dens(a); + gr->InPlot(0.6,1,0.6,1,false); // new axis in upper right corner + gr->Box(); gr->Axis(); + gr->Puts(mglPoint(0,1.2,1),"... with bicolor"); + gr->Dens(a,"BbwrR"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Mesh lines (previous scheme by default)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Mesh(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Surface of boxes"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Boxs(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Contour plot"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Cont(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Contour isosurface y-rotation"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Axial(a,":y"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Contour isosurface x-rotation"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Axial(a,"x"); + a.Transpose(); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Surface and contours"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Cont(a,"BbcyrR_"); + gr->Surf(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Parametrical surface (1)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Mesh(d1,d2,b); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Parametrical surface (vase)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(b,c,m); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Parametrical surface (torus)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf(b,c,d); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Contours for 3-tensor"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Cont(c1); + gr->EndFrame(); + return gr->GetNumFrame(); +} +//----------------------------------------------------------------------------- +int sample_3(mglGraph *gr) +{ + mglData a(50,50,50),b(50,50,50), c(50,50,50),d(50,50,50), d1(50),d2(50),d3(50); + d1.Modify("cos(2*pi*x)"); + d2.Modify("sin(2*pi*x)"); + d3.Modify("2*x*x-1"); + a.Modify("(-2*((2*x-1)^2 + (2*y-1)^2 + (2*z-1)^4 - (2*z-1)^2 + 0.1))"); + b.Modify("-2*((2*x-1)^2 + (2*y-1)^2)"); + c.Modify("exp(-8*((2*x-1)^2+(2*y-1)^2)/(1+z*z*4))"); + d.Modify("cos(32*z*((2*x-1)^2+(2*y-1)^2)/(1+z*z*4))"); +// c.Modify("0.5*sin(2*pi*x)*sin(3*pi*y)*sin(3*pi*z) + 0.5*cos(4*pi*(x*y*z-(x*y+y*z+z*x)/2))"); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Isosurface (try lightning!)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf3(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Isosurface with 'rgbd' scheme"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf3(a,"rgbd"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Cloud plot (switch alpha !!!)"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Cloud(a); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Density at central slices"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Dens3(a,"x"); gr->Dens3(a); gr->Dens3(a,"z"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Puts(mglPoint(0,1.2,1),"Contours at central slices"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Cont3(a,"x"); gr->Cont3(a); gr->Cont3(a,"z"); + gr->EndFrame(); + + gr->NewFrame(); + gr->SubPlot(2,1,0); + gr->Puts(mglPoint(0,1.2,1),"Gauss difraction"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->SetRange('c',0,1); + gr->Surf3(0.5,c,"g"); + gr->SubPlot(2,1,1); + gr->Puts(mglPoint(0,1.2,1),"and its phase"); + gr->Rotate(40,60); + gr->Box(); gr->Axis(); + gr->Surf3A(sin(M_PI/4),d,c,"q"); + gr->Surf3A(-sin(M_PI/4),d,c,"q"); + gr->EndFrame(); + + return gr->GetNumFrame(); +} +//----------------------------------------------------------------------------- +int sample_d(mglGraph *gr) +{ + mglData a(50,50),b(50,50); + mglData cx(50,50,50),cy(50,50,50),cz(50,50,50); + a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))"); + b.Modify("0.6*cos(2*pi*x)*cos(3*pi*y) + 0.4*cos(3*pi*(x*y))"); + cx.Modify("0.01*(x-0.3)/pow((x-0.3)^2+(y-0.5)^2+(z-0.5)^2,1.5) - 0.01*(x-0.7)/pow((x-0.7)^2+(y-0.5)^2+(z-0.5)^2,1.5)"); + cy.Modify("0.01*(y-0.5)/pow((x-0.3)^2+(y-0.5)^2+(z-0.5)^2,1.5) - 0.01*(y-0.5)/pow((x-0.7)^2+(y-0.5)^2+(z-0.5)^2,1.5)"); + cz.Modify("0.01*(z-0.5)/pow((x-0.3)^2+(y-0.5)^2+(z-0.5)^2,1.5) - 0.01*(z-0.5)/pow((x-0.7)^2+(y-0.5)^2+(z-0.5)^2,1.5)"); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); + gr->Puts(mglPoint(0,1.2,1),"Vector field (color ~ \\sqrt{a^2})","rC",8); + gr->Vect(a,b,"","value 50"); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); + gr->Puts(mglPoint(0,1.2,1),"Vector field (length ~ \\sqrt{a^2})","rC",8); + gr->Vect(a,b); + gr->EndFrame(); + + gr->NewFrame(); + gr->Box(); gr->Axis("xy"); + gr->Puts(mglPoint(0,1.2,1),"Flow chart (blue - source)","rC",8); + gr->Flow(a,b); + gr->EndFrame(); + + return gr->GetNumFrame(); +} +//----------------------------------------------------------------------------- +void mgls_prepare1d(mglData *y, mglData *y1, mglData *y2, mglData *x1, mglData *x2) +{ + long n=50; + if(y) y->Create(n,3); + if(x1) x1->Create(n); if(x2) x2->Create(n); + if(y1) y1->Create(n); if(y2) y2->Create(n); +#pragma omp parallel for + for(long i=0;ia[i] = 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx); + y->a[i+n] = sin(2*M_PI*xx); + y->a[i+2*n] = cos(2*M_PI*xx); + } + if(y1) y1->a[i] = 0.5+0.3*cos(2*M_PI*xx); + if(y2) y2->a[i] = 0.3*sin(2*M_PI*xx); + if(x1) x1->a[i] = xx*2-1; + if(x2) x2->a[i] = 0.05+0.03*cos(2*M_PI*xx); + } +} +//----------------------------------------------------------------------------- +void mgls_prepare2d(mglData *a, mglData *b, mglData *v) +{ + long n=50,m=40; + if(a) a->Create(n,m); if(b) b->Create(n,m); + if(v) { v->Create(9); v->Fill(-1,1); } +#pragma omp parallel for collapse(2) + for(long j=0;ja[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +//----------------------------------------------------------------------------- +void mgls_prepare3d(mglData *a, mglData *b) +{ + long n=61,m=50,l=40; + if(a) a->Create(n,m,l); if(b) b->Create(n,m,l); +#pragma omp parallel for collapse(3) + for(long k=0;ka[i0] = -2*(x*x + y*y + z*z*z*z - z*z - 0.1); + if(b) b->a[i0] = 1-2*tanh((x+y)*(x+y)); + } +} +//----------------------------------------------------------------------------- +void mgls_prepare2v(mglData *a, mglData *b) +{ + long n=20,m=30; + if(a) a->Create(n,m); if(b) b->Create(n,m); +#pragma omp parallel for collapse(2) + for(long j=0;ja[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +//----------------------------------------------------------------------------- +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez) +{ + long n=10; + if(!ex || !ey || !ez) return; + ex->Create(n,n,n); ey->Create(n,n,n); ez->Create(n,n,n); +#pragma omp parallel for collapse(3) + for(long k=0;ka[i0]=z*y*r2*r2; + ey->a[i0]=x*y*r2*r2+1; + ez->a[i0]=y*x*r2*r2;*/ +/* ex->a[i0]=3*z; + ey->a[i0]=1; + ez->a[i0]=-3*x;*/ + double r1 = pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5); + double r2 = pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5); + ex->a[i0]=0.2*x/r1 - 0.2*x/r2; + ey->a[i0]=0.2*y/r1 - 0.2*y/r2; + ez->a[i0]=0.2*(z-0.3)/r1 - 0.2*(z+0.3)/r2; + } +} +//----------------------------------------------------------------------------- diff --git a/examples/wx_example.cpp b/examples/wx_example.cpp new file mode 100644 index 0000000..2c064ff --- /dev/null +++ b/examples/wx_example.cpp @@ -0,0 +1,80 @@ +/*************************************************************************** + * wx_example.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/wx.h" +//----------------------------------------------------------------------------- +int test_wnd(mglGraph *gr); +int sample(mglGraph *gr); +int sample_1(mglGraph *gr); +int sample_2(mglGraph *gr); +int sample_3(mglGraph *gr); +int sample_d(mglGraph *gr); +//----------------------------------------------------------------------------- +class testApp : public wxApp +{ +public: + virtual bool OnInit(); +}; +//----------------------------------------------------------------------------- +class testFrame: public wxFrame +{ +public: + testFrame(wxFrame *frame, const wxString& title); + ~testFrame() {} +private: + enum { idMenuQuit = 1000 }; + void OnClose(wxCloseEvent& ) { Destroy(); } + void OnQuit(wxCommandEvent& ) { Destroy(); } + + wxScrolledWindow *scroll; + wxMathGL *mgl; + DECLARE_EVENT_TABLE() +}; +//----------------------------------------------------------------------------- +IMPLEMENT_APP(testApp) +//----------------------------------------------------------------------------- +bool testApp::OnInit() +{ + testFrame* frame = new testFrame(0L, _("MathGL + wxWidgets sample")); + frame->Show(); + return true; +} +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(testFrame, wxFrame) + EVT_CLOSE(testFrame::OnClose) + EVT_MENU(idMenuQuit, testFrame::OnQuit) +END_EVENT_TABLE() +//----------------------------------------------------------------------------- +testFrame::testFrame(wxFrame *frame, const wxString& title) : wxFrame(frame, -1, title) +{ + // create a menu bar + wxMenuBar* mbar = new wxMenuBar(); + wxMenu* fileMenu = new wxMenu(_T("")); + fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application")); + mbar->Append(fileMenu, _("&File")); + SetMenuBar(mbar); + SetSize(800,620); + + scroll = new wxScrolledWindow(this); + mgl = new wxMathGL(scroll); + mgl->SetDraw(mgl_draw_graph,(void*)sample); + mgl->Update(); +} +//----------------------------------------------------------------------------- diff --git a/fonts/STIX.vfm b/fonts/STIX.vfm new file mode 100644 index 0000000..b07ac2d Binary files /dev/null and b/fonts/STIX.vfm differ diff --git a/fonts/STIX_b.vfm b/fonts/STIX_b.vfm new file mode 100644 index 0000000..6bec32c Binary files /dev/null and b/fonts/STIX_b.vfm differ diff --git a/fonts/STIX_bi.vfm b/fonts/STIX_bi.vfm new file mode 100644 index 0000000..9ce6241 Binary files /dev/null and b/fonts/STIX_bi.vfm differ diff --git a/fonts/STIX_i.vfm b/fonts/STIX_i.vfm new file mode 100644 index 0000000..ea51c6c Binary files /dev/null and b/fonts/STIX_i.vfm differ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..cbde2e5 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,35 @@ +configure_file(${MathGL_SOURCE_DIR}/include/config.h.in ${MathGL_BINARY_DIR}/include/mgl2/config.h) + +install(DIRECTORY mgl2/ DESTINATION ${MGL_INCLUDE_PATH} + PATTERN ".svn" EXCLUDE + PATTERN "fltk.h" EXCLUDE + PATTERN "glut.h" EXCLUDE + PATTERN "wx.h" EXCLUDE + PATTERN "qt.h" EXCLUDE + PATTERN "qmathgl.h" EXCLUDE + PATTERN "window.h" EXCLUDE + PATTERN "*old.h" EXCLUDE + PATTERN "*~" EXCLUDE + PATTERN "*.fs" + PATTERN "*.pas" + PATTERN "*.h") + +install(FILES ${MathGL_BINARY_DIR}/include/mgl2/config.h DESTINATION ${MGL_INCLUDE_PATH}) +if(MGL_HAVE_FLTK) + install(FILES mgl2/fltk.h DESTINATION ${MGL_INCLUDE_PATH}) +endif(MGL_HAVE_FLTK) +if(MGL_HAVE_GLUT) + install(FILES mgl2/glut.h DESTINATION ${MGL_INCLUDE_PATH}) +endif(MGL_HAVE_GLUT) +if(MGL_HAVE_WX) + install(FILES mgl2/wx.h DESTINATION ${MGL_INCLUDE_PATH}) +endif(MGL_HAVE_WX) +if(MGL_HAVE_QT) + install(FILES mgl2/qt.h mgl2/qmathgl.h DESTINATION ${MGL_INCLUDE_PATH}) +endif(MGL_HAVE_QT) + +#if(MGL_HAVE_FLTK AND MGL_HAVE_WX AND MGL_HAVE_QT) +if(MGL_HAVE_FLTK AND MGL_HAVE_QT AND MGL_HAVE_WX) + install(FILES mgl2/window.h DESTINATION ${MGL_INCLUDE_PATH}) +#endif(MGL_HAVE_FLTK AND MGL_HAVE_WX AND MGL_HAVE_QT) +endif(MGL_HAVE_FLTK AND MGL_HAVE_QT AND MGL_HAVE_WX) diff --git a/include/config.h.in b/include/config.h.in new file mode 100644 index 0000000..f5171a5 --- /dev/null +++ b/include/config.h.in @@ -0,0 +1,24 @@ +#ifndef _MGL_CONFIG_H_ +#define _MGL_CONFIG_H_ + +#define MGL_USE_DOUBLE ${MGL_USE_DOUBLE} +#define MGL_NO_DATA_A ${MGL_NO_DATA_A} + +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define MGL_HAVE_PTHREAD 0 +#else +#define MGL_HAVE_PTHREAD ${MGL_HAVE_PTHREAD} +#endif +#define MGL_HAVE_ZLIB ${MGL_HAVE_ZLIB} +#define MGL_HAVE_PNG ${MGL_HAVE_PNG} +#define MGL_HAVE_GSL ${MGL_HAVE_GSL} +#define MGL_HAVE_OPENGL ${MGL_HAVE_OPENGL} +#define MGL_HAVE_OMP ${MGL_HAVE_OMP} +#define MGL_HAVE_JPEG ${MGL_HAVE_JPEG} +#define MGL_HAVE_GIF ${MGL_HAVE_GIF} +#define MGL_HAVE_PDF ${MGL_HAVE_PDF} +#define MGL_HAVE_HDF4 ${MGL_HAVE_HDF4} +#define MGL_HAVE_HDF5 ${MGL_HAVE_HDF5} +#define MGL_FONT_PATH "${MGL_FONT_PATH}" + +#endif diff --git a/include/mgl2/abstract.h b/include/mgl2/abstract.h new file mode 100644 index 0000000..90d8808 --- /dev/null +++ b/include/mgl2/abstract.h @@ -0,0 +1,108 @@ +/*************************************************************************** + * thread.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_ABSTRACT_H_ +#define _MGL_ABSTRACT_H_ + +#include "mgl2/define.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +#include +#include "mgl2/type.h" +//----------------------------------------------------------------------------- +class mglBase; +class mglData; +class mglDataC; +class mglParser; +class mglFormula; +class mglFormulaC; +class mglFont; +typedef mglBase* HMGL; +typedef mglData* HMDT; +typedef mglDataC* HADT; +typedef mglParser* HMPR; +typedef mglFormula* HMEX; +typedef mglFormulaC* HAEX; +//----------------------------------------------------------------------------- +#if MGL_NO_DATA_A +#define mglDataA mglData +typedef const mglData* HCDT; +#include "mgl2/data.h" +#else +//----------------------------------------------------------------------------- +/// Callback function for asking user a question. Result shouldn't exceed 1024. +extern MGL_EXPORT void (*mgl_ask_func)(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +/// Abstract class for data array +class MGL_EXPORT mglDataA +{ +public: + virtual ~mglDataA() {} + virtual mreal v(long i,long j=0,long k=0) const = 0; + virtual mreal vthr(long i) const = 0; + virtual long GetNx() const = 0; + virtual long GetNy() const = 0; + virtual long GetNz() const = 0; + inline long GetNN() const { return GetNx()*GetNy()*GetNz(); } + virtual mreal Maximal() const = 0; + virtual mreal Minimal() const = 0; + virtual mreal dvx(long i,long j=0,long k=0) const = 0; +// { return i>0 ? (i0 ? (j0 ? (kjdD*^" correspondingly +extern uint64_t mgl_mask_val[16]; +#define MGL_MASK_ID "-+=;oOsS~<>jdD*^" +#define MGL_SOLID_MASK 0xffffffffffffffff +//----------------------------------------------------------------------------- +#else +typedef void *HMGL; +typedef void *HMDT; +typedef void *HADT; +typedef void *HMEX; +typedef void *HAEX; +typedef void *HMPR; +typedef const void *HCDT; +#endif + +#if MGL_SRC +#define _Da_(d) (*((const mglDataA *)(d))) +#define _DA_(a) ((const mglDataA *)*(a)) +#define _GR_ ((mglBase *)(*gr)) +//#define _D_(d) *((mglData *)*(d)) +#define _DM_(a) ((mglData *)*(a)) +#define _DT_ ((mglData *)*d) +#endif + +#endif diff --git a/include/mgl2/addon.h b/include/mgl2/addon.h new file mode 100644 index 0000000..aeed679 --- /dev/null +++ b/include/mgl2/addon.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * addon.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_ADDON_H_ +#define _MGL_ADDON_H_ +//----------------------------------------------------------------------------- +#include "mgl2/define.h" +#ifdef __cplusplus +//----------------------------------------------------------------------------- +/// Explicit scheme for 1 step of axial diffraction +void MGL_EXPORT mgl_difr_axial(dual *a,int n,int step,dual q,int Border,dual *tmp,int kk, double di); +void MGL_EXPORT mgl_difr_axial_old(dual *a,int n,int step,dual q,int Border,dual *tmp1,dual *tmp2,int kk, double di); // restore for backward compatibility +/// Explicit scheme for 1 step of plane diffraction +void MGL_EXPORT mgl_difr_grid(dual *a,int n,int step,dual q,int Border,dual *tmp,int kk); +void MGL_EXPORT mgl_difr_grid_old(dual *a,int n,int step,dual q,int Border,dual *tmp1,dual *tmp2,int kk); // restore for backward compatibility +//----------------------------------------------------------------------------- +extern "C" { +#endif +/// Get random number with Gaussian distribution +double MGL_EXPORT mgl_gauss_rnd(); +/// Fill frequencies for FFT +void MGL_EXPORT mgl_fft_freq(double *freq,long nn); + +/// Remove double spaces from the string +void MGL_EXPORT mgl_strcls(char *str); +/// Get position of substring or return -1 if not found +int MGL_EXPORT mgl_strpos(const char *str,char *fnd); +/// Get position of symbol or return -1 if not found +int MGL_EXPORT mgl_chrpos(const char *str,char fnd); + +/// Get uncommented string from file (NOTE: it is not thread safe!!!) +MGL_EXPORT char *mgl_fgetstr(FILE *fp); +/// Get parameters from uncommented strings of file (NOTE: it is not thread safe!!!) +void MGL_EXPORT mgl_fgetpar(FILE *fp, const char *str, ...); +/// Check if symbol denote true +int MGL_EXPORT mgl_istrue(char ch); +/// Print test message +void MGL_EXPORT mgl_test(const char *str, ...); +/// Print info message +void MGL_EXPORT mgl_info(const char *str, ...); +/// Locate next data block (block started by -----) +MGL_EXPORT FILE *mgl_next_data(const char *fname,int p); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/mgl2/base.h b/include/mgl2/base.h new file mode 100644 index 0000000..452e2c8 --- /dev/null +++ b/include/mgl2/base.h @@ -0,0 +1,527 @@ +/*************************************************************************** + * base.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_BASE_H_ +#define _MGL_BASE_H_ +//#if !defined(_MSC_VER) && !defined(__BORLANDC__) +#include "mgl2/abstract.h" + +#ifdef __cplusplus +#include +#include + +#if MGL_HAVE_PTHREAD +#include +#define MGL_PUSH(a,v,m) {pthread_mutex_lock(&m); a.push_back(v); pthread_mutex_unlock(&m);} +#else +#define MGL_PUSH(a,v,m) a.push_back(v); +#endif + +#define MGL_TO_WCS(str,code) if(str){size_t s=mbstowcs(0,str,0); wchar_t *wcs=new wchar_t[s+1]; mbstowcs(wcs,str,s); wcs[s]=0; code; delete []wcs;} +//----------------------------------------------------------------------------- +inline mreal mgl_d(mreal v,mreal v1,mreal v2) { return v2!=v1?(v-v1)/(v2-v1):NAN; } +//----------------------------------------------------------------------------- +mglPoint GetX(HCDT x, int i, int j, int k=0); +mglPoint GetY(HCDT y, int i, int j, int k=0); +mglPoint GetZ(HCDT z, int i, int j, int k=0); +//----------------------------------------------------------------------------- +/// Structure for transformation matrix +struct MGL_EXPORT mglMatrix +{ + mreal b[9]; + mreal x,y,z,pf; + bool norot; // flag to disable pnts rotation + mglMatrix() { memset(this,0,sizeof(mglMatrix)); clear(); } + void Rotate(mreal tetz,mreal tetx,mreal tety); + void RotateN(mreal Tet,mreal x,mreal y,mreal z); + inline void clear() { x=y=z=pf=0; memset(b,0,9*sizeof(mreal)); b[0]=b[4]=b[8]=1; norot=false; } + inline mglMatrix &operator=(const mglMatrix &a) + { x=a.x; y=a.y; z=a.z; pf=a.pf; memcpy(b,a.b,9*sizeof(mreal)); norot=false; return *this; } +}; +inline bool operator==(const mglMatrix &a, const mglMatrix &b) +{ return b.x==a.x&&b.y==a.y&&b.z==a.z&&b.pf==a.pf&&!memcmp(b.b,a.b,9*sizeof(mreal));} +inline bool operator!=(const mglMatrix &a, const mglMatrix &b) +{ return b.x!=a.x||b.y!=a.y||b.z!=a.z||b.pf!=a.pf||memcmp(b.b,a.b,9*sizeof(mreal)); } +//----------------------------------------------------------------------------- +/// Structure for simplest primitives +struct MGL_EXPORT mglPrim // NOTE: use float for reducing memory size +{ + // NOTE: n4 is used as mark; n3 -- as pen style for type=0,1,4 + // NOTE: n3 is used as position of txt,font in Ptxt for type=6 + long n1,n2,n3,n4; ///< coordinates of corners + short type; ///< primitive type (0-point, 1-line, 2-trig, 3-quad, 4-glyph, 6-text) + short angl; ///< rotation angle for mask + int id; ///< object id + float z; ///< z-position + float w; ///< width (if applicable) or ftet + union + { + struct + { + float s; ///< size (if applicable) or fscl + float p; + }; + uint64_t m; + }; + mglPrim(int t=0) { n1=n2=n3=n4=id=0; z=s=w=p=0; type=t; } +}; +bool operator<(const mglPrim &a,const mglPrim &b); +bool operator>(const mglPrim &a,const mglPrim &b); +//----------------------------------------------------------------------------- +/// Structure for group of primitives +struct MGL_EXPORT mglGroup +{ + std::vector p; ///< list of primitives (not filled!!!) + int Id; ///< Current list of primitives + std::string Lbl; ///< Group label + mglGroup(const char *lbl="", int id=0) { Lbl=lbl; Id=id; } +}; +//----------------------------------------------------------------------------- +/// Structure for text label +struct MGL_EXPORT mglText +{ + std::wstring text; + std::string stl; + mreal val; + mglText(const wchar_t *txt=L"", const char *fnt="", mreal v=0) { text=txt; stl=fnt; val=v; } + mglText(const std::wstring &txt, mreal v=0) { text=txt; val=v; } +}; +//----------------------------------------------------------------------------- +/// Structure for internal point representation +struct MGL_EXPORT mglPnt // NOTE: use float for reducing memory size +{ + float xx,yy,zz; // original coordinates + float x,y,z; // coordinates + float c,t,ta; // index in color scheme + float u,v,w; // normales + float r,g,b,a; // RGBA color + short sub; // subplot id and rotation information (later will be in subplot) + mglPnt() { xx=yy=zz=x=y=z=c=t=ta=u=v=w=r=g=b=a=sub=0; } +}; +inline mglPnt operator+(const mglPnt &a, const mglPnt &b) +{ mglPnt c=a; + c.x+=b.x; c.y+=b.y; c.z+=b.z; c.u+=b.u; c.v+=b.v; c.w+=b.w; + c.r+=b.r; c.g+=b.g; c.b+=b.b; c.a+=b.a; return c; } +inline mglPnt operator-(const mglPnt &a, const mglPnt &b) +{ mglPnt c=a; + c.x-=b.x; c.y-=b.y; c.z-=b.z; c.u-=b.u; c.v-=b.v; c.w-=b.w; + c.r-=b.r; c.g-=b.g; c.b-=b.b; c.a-=b.a; return c; } +inline mglPnt operator*(const mglPnt &a, float b) +{ mglPnt c=a; + c.x*=b; c.y*=b; c.z*=b; c.u*=b; c.v*=b; c.w*=b; + c.r*=b; c.g*=b; c.b*=b; c.a*=b; return c; } +inline mglPnt operator*(float b, const mglPnt &a) +{ mglPnt c=a; + c.x*=b; c.y*=b; c.z*=b; c.u*=b; c.v*=b; c.w*=b; + c.r*=b; c.g*=b; c.b*=b; c.a*=b; return c; } +//----------------------------------------------------------------------------- +/// Structure for glyph representation +struct MGL_EXPORT mglGlyph +{ + long nt, nl; ///< number of triangles and lines + short *trig, *line; ///< vertexes of triangles and lines + + mglGlyph() { nl=nt=0; trig=line=0; } + mglGlyph(const mglGlyph &a) { nl=nt=0; trig=line=0; *this=a; } + mglGlyph(long Nt, long Nl) { nl=nt=0; trig=line=0; Create(Nt,Nl); } + ~mglGlyph() { if(trig) delete []trig; if(line) delete []line; } + + void Create(long Nt, long Nl); + bool operator==(const mglGlyph &g); + inline mglGlyph &operator=(const mglGlyph &a) + { Create(a.nt, a.nl); memcpy(trig, a.trig, 6*nt*sizeof(short)); + memcpy(line, a.line, 2*nl*sizeof(short)); return *this; } +}; +//----------------------------------------------------------------------------- +#define MGL_TEXTURE_COLOURS 512 +/// Structure for texture (color scheme + palette) representation +struct MGL_EXPORT mglTexture +{ + mglColor col[MGL_TEXTURE_COLOURS]; ///< Colors itself + long n; ///< Number of initial colors along u + + char Sch[260]; ///< Color scheme used + int Smooth; ///< Type of texture (smoothing and so on) + mreal Alpha; ///< Transparency + + mglTexture() { n=Smooth=0; Alpha=1; } + mglTexture(const char *cols, int smooth=0,mreal alpha=1) + { n=0; Set(cols,smooth,alpha); } + void Clear() { n=0; } + void Set(const char *cols, int smooth=0,mreal alpha=1); + void Set(HCDT val, const char *cols); + void GetC(mreal u,mreal v,mglPnt &p) const; + mglColor GetC(mreal u,mreal v=0) const; + inline bool IsSame(const mglTexture &t) const + { return n==t.n && !memcmp(col,t.col,MGL_TEXTURE_COLOURS*sizeof(mglColor)); } + void GetRGBA(unsigned char *f) const; + void GetRGBAPRC(unsigned char *f) const; + void GetRGBAOBJ(unsigned char *f) const; // Export repeating border colors, since OBJ by default wraps textures and we need an extra boundary to work around implementation quirks +}; +//----------------------------------------------------------------------------- +const mglColor NC(-1,-1,-1); +const mglColor BC( 0, 0, 0); +const mglColor WC( 1, 1, 1); +const mglColor RC( 1, 0, 0); +//----------------------------------------------------------------------------- +/// Structure active points +struct MGL_EXPORT mglActivePos +{ + int x,y; ///< coordinates of active point + int id; ///< object id for active point + int n; ///< position of active point in command (object id) +}; +//----------------------------------------------------------------------------- +/// Base class for canvas which handle all basic drawing +class MGL_EXPORT mglBase +{ +public: + mglBase(); + virtual ~mglBase(); + + bool Stop; ///< Flag that execution should be terminated. + mglPoint Min; ///< Lower edge of bounding box for graphics. + mglPoint Max; ///< Upper edge of bounding box for graphics. + mreal ZMin; ///< Adjusted minimal z-value 1D plots + std::string Mess; ///< Buffer for receiving messages + int ObjId; ///< object id for mglPrim + int HighId; ///< object id to be highlited + std::vector Grp; ///< List of groups with names -- need for export + std::vector Act; ///< Position of active points + std::string PlotId; ///< Id of plot for saving filename (in GLUT window for example) + + mreal CDef; ///< Default (current) color in texture + mreal AlphaDef; ///< Default value of alpha channel (transparency) + mreal BarWidth; ///< Relative width of rectangles in Bars(). + int MeshNum; ///< Set approximate number of lines in Mesh and Grid. By default (=0) it draw all lines. + int FaceNum; ///< Set approximate number of visible faces and lines. By default (=0) it draw everything. + char Arrow1, Arrow2;///< Style of arrows at end and at start of curve + long InUse; ///< Smart pointer (number of users) + uint32_t Flag; ///< Flags for controlling drawing + + inline bool get(uint32_t fl) const { return Flag&fl; } + inline void set(uint32_t fl) { Flag |= fl; } + inline void clr(uint32_t fl) { Flag &=~fl; } + inline void set(bool v,uint32_t fl) { Flag = v ? Flag|fl : Flag&(~fl); } + + /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image! + inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1)) { AMin = p1; AMax = p2; } + /// Set values of mglGraph::Min and mglGraph::Max + inline void SetRanges(mreal x1, mreal x2, mreal y1, mreal y2, mreal z1=0, mreal z2=0, mreal c1=0, mreal c2=0) + { SetRanges(mglPoint(x1,y1,z1,c1),mglPoint(x2,y2,z2,c2)); } + void SetRanges(mglPoint v1, mglPoint v2); + /// Set values of mglGraph::Cmin and mglGraph::Cmax as minimal and maximal values of data a + void CRange(HCDT a, bool add = false, mreal fact=0); + void CRange(mreal v1,mreal v2,bool add=false); + /// Set values of mglGraph::Min.x and mglGraph::Max.x as minimal and maximal values of data a + void XRange(HCDT a, bool add = false, mreal fact=0); + void XRange(mreal v1,mreal v2,bool add=false); + /// Set values of mglGraph::Min.x and mglGraph::Max.x as minimal and maximal values of data a + void YRange(HCDT a, bool add = false, mreal fact=0); + void YRange(mreal v1,mreal v2,bool add=false); + /// Set values of mglGraph::Min.x and mglGraph::Max.x as minimal and maximal values of data a + void ZRange(HCDT a, bool add = false, mreal fact=0); + void ZRange(mreal v1,mreal v2,bool add=false); + /// Set ranges for automatic variables + void SetAutoRanges(mreal x1, mreal x2, mreal y1=0, mreal y2=0, mreal z1=0, mreal z2=0, mreal c1=0, mreal c2=0); + /// Set axis origin + void SetOrigin(mreal x0, mreal y0, mreal z0=NAN, mreal c0=NAN); + /// Save ranges into internal variable and put parsed + mreal SaveState(const char *opt); + /// Load ranges from internal variable + void LoadState(); + /// Increase ZMin + mreal AdjustZMin() { ZMin /= MGL_FEPSILON; return Max.z - ZMin*(Max.z-Min.z); } + + /// Safetly set the transformation formulas for coordinate. + void SetFunc(const char *EqX, const char *EqY, const char *EqZ=0, const char *EqA=0); + /// Set one of predefined transformation rule + void SetCoor(int how); + /// Safetly set the cutting off condition (formula). + void CutOff(const char *EqCut); + /// Set to draw Ternary axis (triangle like axis, grid and so on) + void Ternary(int tern); + + /// Set cutting for points outside of bounding box + inline void SetCut(bool val) { set(val, MGL_ENABLE_CUT); } + /// Set additional cutting box + inline void SetCutBox(mreal x1, mreal y1, mreal z1, mreal x2, mreal y2, mreal z2) + { CutMin=mglPoint(x1,y1,z1); CutMax=mglPoint(x2,y2,z2); } + inline void SetCutBox(mglPoint v1, mglPoint v2) { CutMin=v1; CutMax=v2; } + /// Reset mask to solid state + inline void ResetMask() { mask = MGL_SOLID_MASK; MaskAn = DefMaskAn; } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { DefMaskAn = angle; } + + /// Set the using of light on/off. + virtual bool Light(bool enable) + { bool t=get(MGL_ENABLE_LIGHT); set(enable,MGL_ENABLE_LIGHT); return t; } + /// Set ambient light brightness + virtual void SetAmbient(mreal bright=0.5); + /// Set diffusive light brightness + virtual void SetDiffuse(mreal bright=0.5); + /// Use diffusive light (only for local light sources) + inline void SetDifLight(bool dif) { SetDiffuse(dif?0.5:0); } + /// Set the transparency on/off. + virtual bool Alpha(bool enable) + { bool t=get(MGL_ENABLE_ALPHA); set(enable,MGL_ENABLE_ALPHA); return t; } + /// Set default value of alpha-channel + inline void SetAlphaDef(mreal val) { AlphaDef=val; } + /// Set default palette + inline void SetPalette(const char *colors) + { Txt[0].Set(mgl_have_color(colors)?colors:MGL_DEF_PAL,-1); } + inline long GetNumPal(long id) const { return Txt[labs(id)/256].n; } + /// Set default color scheme + inline void SetDefScheme(const char *colors) + { Txt[1].Set(mgl_have_color(colors)?colors:MGL_DEF_SCH); } + + /// Set number of mesh lines + inline void SetMeshNum(int val) { MeshNum=val; } + /// Set relative width of rectangles in Bars, Barh, BoxPlot + inline void SetBarWidth(mreal val) { BarWidth=val; } + /// Set size of marks + inline void SetMarkSize(mreal val) { MarkSize=0.02*val; } + /// Set size of arrows + inline void SetArrowSize(mreal val) { ArrowSize=0.03*val; } + + /// Set warning code ant fill Message + void SetWarn(int code, const char *who); + int inline GetWarn() const { return WarnCode; } + + virtual void StartAutoGroup (const char *)=0; + void StartGroup(const char *name, int id); + virtual void EndGroup()=0; // { LoadState(); } + /// Highlight group + inline void Highlight(int id) { HighId=id; } + + /// Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72) + virtual void SetFontSizePT(mreal pt, int dpi=72){ FontSize = pt*27.f/dpi; } + /// Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt) + inline void SetFontSizeCM(mreal cm, int dpi=72) { SetFontSizePT(cm*28.45f,dpi); } + /// Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt) + inline void SetFontSizeIN(mreal in, int dpi=72) { SetFontSizePT(in*72.27f,dpi); } + /// Set font typeface. Note that each mglFont instance can be used with ONLY ONE mglGraph instance at a moment of time! + void SetFont(mglFont *f); + /// Get current typeface. Note that this variable can be deleted at next SetFont() call! + inline mglFont *GetFont() { return fnt; } + /// Restore font + void RestoreFont(); + /// Load font from file + void LoadFont (const char *name, const char *path=NULL); + /// Copy font from another mglGraph instance + void CopyFont(mglBase *gr); + /// Set default font size + inline void SetFontSize(mreal val) { FontSize=val>0 ? val:-FontSize*val; } + inline mreal GetFontSize() const { return FontSize; } + mreal TextWidth(const char *text, const char *font, mreal size) const; + mreal TextWidth(const wchar_t *text, const char *font, mreal size) const; + mreal TextHeight(const char *font, mreal size) const; + inline mreal FontFactor() const { return font_factor; } + virtual mreal GetRatio() const; + virtual int GetWidth() const; + virtual int GetHeight() const; + + /// Set to use or not text rotation + inline void SetRotatedText(bool val) { set(val,MGL_ENABLE_RTEXT); } + /// Set default font style and color + void SetFontDef(const char *font); + /// Set to use or not text rotation + inline void SetTickRotate(bool val) { set(val,MGL_TICKS_ROTATE); } + /// Set to use or not text rotation + inline void SetTickSkip(bool val) { set(val,MGL_TICKS_SKIP); } + + /// Add string to legend + void AddLegend(const char *text,const char *style); + void AddLegend(const wchar_t *text,const char *style); + /// Clear saved legend string + inline void ClearLegend() { Leg.clear(); } + + /// Set plot quality + virtual void SetQuality(int qual=MGL_DRAW_NORM) { Quality=qual; } + inline int GetQuality() const { return Quality; } + inline void SetDrawReg(long nx=1, long ny=1, long m=0) { dr_x=nx; dr_y=ny; dr_p=m; } + + // ~~~~~~~~~~~~~~~~~~~~~~ Developer functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /// Add point to the Pnt and return its position + inline long AddPnt(mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1) + { return AddPnt(&B,p,c,n,a,scl); } + long AddPnt(const mglMatrix *M, mglPoint p, mreal c=-1, mglPoint n=mglPoint(NAN), mreal a=-1, int scl=1); + long CopyNtoC(long k, mreal c); + long CopyProj(long from, mglPoint p, mglPoint n); + virtual void Reserve(long n); ///< Allocate n-cells for Pnt and return current position + /// Set to reduce accuracy of points (to reduce size of output files) + inline void SetReduceAcc(bool val) { set(val, MGL_REDUCEACC); } + /// Add glyph of current font to the Glf and return its position + long AddGlyph(int s, long j); + /// Add active point as k-th element of Pnt + void AddActive(long k,int n=0); + /// Clear unused points and primitives + void ClearUnused(); + + inline mreal GetPenWidth() { return PenWidth; } + + inline const mglMatrix *GetB() const { return &B; } + inline mglPoint GetPntP(long i) const + { const mglPnt &p=Pnt[i]; return mglPoint(p.x,p.y,p.z); } + inline mglPoint GetPntN(long i) const + { const mglPnt &p=Pnt[i]; return mglPoint(p.u,p.v,p.w); } + inline mglColor GetPntC(long i) const + { const mglPnt &p=Pnt[i]; return mglColor(p.r,p.g,p.b,p.a); } + inline float GetClrC(long i) const { return Pnt[i].c; } + inline const mglGlyph &GetGlf(long i) const { return Glf[i]; } + inline long GetGlfNum() const { return Glf.size(); } + inline const mglPnt &GetPnt(long i) const { return Pnt[i]; } + inline long GetPntNum() const { return Pnt.size(); } + inline mglPrim &GetPrm(long i) { return Prm[i]; } + inline long GetPrmNum() const { return Prm.size(); } + inline const mglText &GetPtx(long i) const { return Ptx[i]; } + inline long GetPtxNum() const { return Ptx.size(); } + inline const mglTexture &GetTxt(long i) const { return Txt[i]; } + inline long GetTxtNum() const { return Txt.size(); } + /// Scale coordinates and cut off some points + virtual bool ScalePoint(const mglMatrix *M, mglPoint &p, mglPoint &n, bool use_nan=true) const; + + virtual mreal GetOrgX(char dir, bool inv=false) const=0; ///< Get Org.x (parse NAN value) + virtual mreal GetOrgY(char dir, bool inv=false) const=0; ///< Get Org.y (parse NAN value) + virtual mreal GetOrgZ(char dir, bool inv=false) const=0; ///< Get Org.z (parse NAN value) + + /// Get color depending on single variable z, which should be scaled if scale=true + inline mreal GetC(long s,mreal z,bool scale = true) const + { return s+(scale?GetA(z):(z>0?z/MGL_FEPSILON:0)); } + /// Get alpha value depending on single variable a + mreal GetA(mreal a) const; + /// Set pen/palette + char SetPenPal(const char *stl, long *id=0, bool pal=true); + /// Add texture (like color scheme) and return the position of first color + long AddTexture(const char *cols, int smooth=0); +// inline mreal AddTexture(char col) { return AddTexture(mglColor(col)); } + mreal AddTexture(mglColor col); + inline void DefColor(mglColor col) { CDef = AddTexture(col); } + /// Set mask for face coloring + void SetMask(const char *mask); + /// Set next color from palette + mreal NextColor(long &id); + mreal NextColor(long id, long sh); + + virtual void mark_plot(long p, char type, mreal size=1)=0; + virtual void arrow_plot(long p1, long p2, char st)=0; + virtual void line_plot(long p1, long p2)=0; + virtual void trig_plot(long p1, long p2, long p3)=0; + virtual void quad_plot(long p1, long p2, long p3, long p4)=0; + virtual void Glyph(mreal x, mreal y, mreal f, int style, long icode, mreal col)=0; + virtual float GetGlyphPhi(const mglPnt &q, float phi)=0; + virtual mreal text_plot(long p,const wchar_t *text,const char *fnt,mreal size=-1,mreal sh=0,mreal col=-('k'),bool rot=true)=0; + void vect_plot(long p1, long p2, mreal s=1); + inline mreal mark_size() { return MarkSize*font_factor; } +// inline char last_color() { return last_style[1]; } + inline const char *last_line() { return last_style; } + void resort(); ///< Resort primitives in creation order (need for export in 3D formats) + +protected: + mglPoint OMin; ///< Lower edge for original axis (before scaling) + mglPoint OMax; ///< Upper edge for original axis (before scaling) + mglPoint AMin; ///< Lower edge for axis scaling + mglPoint AMax; ///< Upper edge for axis scaling + mglPoint FMin; ///< Actual lower edge after transformation formulas. + mglPoint FMax; ///< Actual upper edge after transformation formulas. + mglPoint Org; ///< Center of axis cross section. + int WarnCode; ///< Warning code + std::vector Pnt; ///< Internal points + std::vector Prm; ///< Primitives (lines, triangles and so on) -- need for export + std::vector Sub; ///< InPlot regions {n1=x1,n2=x2,n3=y1,n4=y2,id} + std::vector Ptx; ///< Text labels for mglPrim + std::vector Leg; ///< Text labels for legend + std::vector Glf; ///< Glyphs data + std::vector Txt; ///< Pointer to textures +#if MGL_HAVE_PTHREAD + pthread_mutex_t mutexPnt, mutexTxt, mutexLeg, mutexGlf, mutexAct, mutexDrw; + pthread_mutex_t mutexSub, mutexPrm, mutexPtx, mutexStk, mutexGrp; +#endif + + int TernAxis; ///< Flag that Ternary axis is used + unsigned PDef; ///< Pen bit mask + mreal pPos; ///< Current position in pen mask + mreal PenWidth; ///< Pen width for further line plotting (must be >0 !!!) +// long numT; ///< Number of textures + mreal AmbBr; ///< Default ambient light brightness + mreal DifBr; ///< Default diffusive light brightness + + mglMatrix Bp; ///< Transformation matrix for View() and Zoom() + mglMatrix B; ///< Transformation matrix + mglMatrix B1; ///< Transformation matrix for colorbar + + mglFont *fnt; ///< Class for printing vector text + mreal FontSize; ///< The size of font for tick and axis labels + char FontDef[32]; ///< Font specification (see mglGraph::Puts). Default is Roman with align at center. + int Quality; ///< Quality of plot (0x0-pure, 0x1-fast; 0x2-fine; 0x4 - low memory) + + mglFormula *fx; ///< Transformation formula for x direction. + mglFormula *fy; ///< Transformation formula for y direction. + mglFormula *fz; ///< Transformation formula for z direction. + mglFormula *fa; ///< Transformation formula for coloring. + mglFormula *fc; ///< Cutting off condition (formula). + + long CurrPal; ///< Current palette index + mreal MarkSize; ///< The size of marks for 1D plots. + mreal ArrowSize; ///< The size of arrows. + char last_style[64];///< Last pen style + mreal font_factor; ///< Font scaling factor + + long dr_x, dr_y, dr_p; ///< default drawing region for quality&4 mode + + virtual void LightScale(const mglMatrix *M)=0; ///< Scale positions of light sources + + // block for SaveState() + mglPoint MinS; ///< Saved lower edge of bounding box for graphics. + mglPoint MaxS; ///< Saved upper edge of bounding box for graphics. + mreal MSS, ASS, FSS, ADS, MNS, LSS; ///< Saved state + mreal PrevState; ///< Previous value of SaveState() + long CSS; ///< Saved flags + bool saved; ///< State is saved + std::string leg_str;///< text to be save in legend + + union + { + uint64_t mask; ///< Mask to be used for coloring + unsigned char mask_ch[8]; + }; + int MaskAn; ///< Mask rotation angle in degrees + int DefMaskAn; ///< Default mask rotation angle in degrees + +private: + + mglPoint CutMin; ///< Lower edge of bounding box for cut off. + mglPoint CutMax; ///< Upper edge of bounding box for cut off. + + bool RecalcCRange(); ///< Recalculate internal parameter for correct coloring. + void RecalcBorder(); ///< Recalculate internal parameter for correct transformation rules. + bool SetFBord(mreal x,mreal y,mreal z); ///< Set internal boundng box depending on transformation formula + void ClearEq(); ///< Clear the used variables for axis transformation +}; +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_dim0(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *name, bool less=false); +bool MGL_EXPORT mgl_check_dim1(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *name, bool less=false); +bool MGL_EXPORT mgl_check_dim2(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *name, bool less=false); +bool MGL_EXPORT mgl_check_dim3(HMGL gr, bool both, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *name); +bool MGL_EXPORT mgl_check_vec3(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *name); +bool MGL_EXPORT mgl_check_trig(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *name, int d=3); +bool MGL_EXPORT mgl_isboth(HCDT x, HCDT y, HCDT z, HCDT a); +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/base_cf.h b/include/mgl2/base_cf.h new file mode 100644 index 0000000..76d5276 --- /dev/null +++ b/include/mgl2/base_cf.h @@ -0,0 +1,205 @@ +/*************************************************************************** + * base_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_BASE_CF_H_ +#define _MGL_BASE_CF_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Get last warning code +int MGL_EXPORT mgl_get_warn(HMGL gr); +int MGL_EXPORT mgl_get_warn_(uintptr_t *gr); +/// Set warning code ant fill message +void MGL_EXPORT mgl_set_warn(HMGL gr, int code, const char *text); +void MGL_EXPORT mgl_set_warn_(uintptr_t *gr, int *code, const char *text,int); +/// Set buffer for warning messages +MGL_EXPORT const char *mgl_get_mess(HMGL gr); + +/// Set name of plot for saving filename +void MGL_EXPORT mgl_set_plotid(HMGL gr, const char *id); +void MGL_EXPORT mgl_set_plotid_(uintptr_t *gr, const char *id,int); +/// Get name of plot for saving filename +MGL_EXPORT const char *mgl_get_plotid(HMGL gr); + +/// Get plot quality +int MGL_EXPORT mgl_get_quality(HMGL gr); +int MGL_EXPORT mgl_get_quality_(uintptr_t *gr); +/// Set plot quality +void MGL_EXPORT mgl_set_quality(HMGL gr, int qual); +void MGL_EXPORT mgl_set_quality_(uintptr_t *gr, int *qual); +/// Set drawing region for Quality&4 +void MGL_EXPORT mgl_set_draw_reg(HMGL gr, long nx, long ny, long m); +void MGL_EXPORT mgl_set_draw_reg_(uintptr_t *gr, int *nx, int *ny, int *m); + +/// Is frames +int MGL_EXPORT mgl_is_frames(HMGL gr); +/// Get bit-value flag of HMGL state (for advanced users only) +int MGL_EXPORT mgl_get_flag(HMGL gr, uint32_t flag); +int MGL_EXPORT mgl_get_flag_(uintptr_t *gr, unsigned long *flag); +/// Set bit-value flag of HMGL state (for advanced users only) +void MGL_EXPORT mgl_set_flag(HMGL gr, int val, uint32_t flag); +void MGL_EXPORT mgl_set_flag_(uintptr_t *gr, int *val, unsigned long *flag); +/// Change counter of HMGL uses (for advanced users only). Non-zero counter prevent automatic object removing. +long MGL_EXPORT mgl_use_graph(HMGL gr, int inc); +long MGL_EXPORT mgl_use_graph_(uintptr_t *gr, int *inc); +void MGL_EXPORT mgl_set_rdc_acc(HMGL gr, int reduce); // TODO +void MGL_EXPORT mgl_set_rdc_acc_(uintptr_t *gr, int *reduce); + +/// Start group of objects +void MGL_EXPORT mgl_start_group(HMGL gr, const char *name); +void MGL_EXPORT mgl_start_group_(uintptr_t *gr, const char *name,int); +/// End group of objects +void MGL_EXPORT mgl_end_group(HMGL gr); +void MGL_EXPORT mgl_end_group_(uintptr_t *gr); +/// Highlight objects with given id +void MGL_EXPORT mgl_highlight(HMGL gr, int id); +void MGL_EXPORT mgl_highlight_(uintptr_t *gr, int *id); + +/// Set default palette +void MGL_EXPORT mgl_set_palette(HMGL gr, const char *colors); +void MGL_EXPORT mgl_set_palette_(uintptr_t *gr, const char *colors, int); +void MGL_EXPORT mgl_set_pal_color_(uintptr_t *gr, int *n, mreal *r, mreal *g, mreal *b); +void MGL_EXPORT mgl_set_pal_num_(uintptr_t *gr, int *num); +/// Sets RGB values for color with given id +void MGL_EXPORT mgl_set_color(char id, double r, double g, double b); +void MGL_EXPORT mgl_set_color_(char *id, mreal *r, mreal *g, mreal *b, int); +/// Set default color scheme +void MGL_EXPORT mgl_set_def_sch(HMGL gr, const char *sch); +void MGL_EXPORT mgl_set_def_sch_(uintptr_t *gr, const char *sch,int); +/// Set mask for face coloring as array of type 'unsigned char[8]' +void MGL_EXPORT mgl_set_mask(char id, const char *mask); +void MGL_EXPORT mgl_set_mask_(const char *id, const char *mask,int,int); +/// Set mask for face coloring as unsigned long number +void MGL_EXPORT mgl_set_mask_val(char id, uint64_t mask); +void MGL_EXPORT mgl_set_mask_val_(const char *id, uint64_t *mask,int); +/// Set default mask rotation angle +void MGL_EXPORT mgl_set_mask_angle(HMGL gr, int angle); +void MGL_EXPORT mgl_set_mask_angle_(uintptr_t *gr, int *angle); + +/// Set default value of alpha-channel +void MGL_EXPORT mgl_set_alpha_default(HMGL gr, double alpha); +void MGL_EXPORT mgl_set_alpha_default_(uintptr_t *gr, mreal *alpha); +/// Set relative width of rectangles in Bars, Barh, BoxPlot +void MGL_EXPORT mgl_set_bar_width(HMGL gr, double width); +void MGL_EXPORT mgl_set_bar_width_(uintptr_t *gr, mreal *width); +/// Set number of mesh lines (use 0 to draw all of them) +void MGL_EXPORT mgl_set_meshnum(HMGL gr, int num); +void MGL_EXPORT mgl_set_meshnum_(uintptr_t *gr, int *num); +/// Set number of visible faces (use 0 to draw all of them) +void MGL_EXPORT mgl_set_facenum(HMGL gr, int num); +void MGL_EXPORT mgl_set_facenum_(uintptr_t *gr, int *num); +/// Clear unused points and primitives. Useful only in combination with mgl_set_facenum(). +void MGL_EXPORT mgl_clear_unused(HMGL gr); +void MGL_EXPORT mgl_clear_unused_(uintptr_t *gr); + +/// Set ambient light brightness +void MGL_EXPORT mgl_set_ambbr(HMGL gr, double i); +void MGL_EXPORT mgl_set_ambbr_(uintptr_t *gr, mreal *i); +/// Set diffusive light brightness +void MGL_EXPORT mgl_set_difbr(HMGL gr, double i); +void MGL_EXPORT mgl_set_difbr_(uintptr_t *gr, mreal *i); +/// Use diffusive light (only for local light sources) -- OBSOLETE +void MGL_EXPORT mgl_set_light_dif(HMGL gr, int enable); +void MGL_EXPORT mgl_set_light_dif_(uintptr_t *gr, int *enable); + +/// Set cutting for points outside of bounding box +void MGL_EXPORT mgl_set_cut(HMGL gr, int cut); +void MGL_EXPORT mgl_set_cut_(uintptr_t *gr, int *cut); +/// Set additional cutting box +void MGL_EXPORT mgl_set_cut_box(HMGL gr, double x1,double y1,double z1,double x2,double y2,double z2); +void MGL_EXPORT mgl_set_cut_box_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2); +/// Set the cutting off condition (formula) +void MGL_EXPORT mgl_set_cutoff(HMGL gr, const char *EqC); +void MGL_EXPORT mgl_set_cutoff_(uintptr_t *gr, const char *EqC, int); + +/// Set values of axis range +void MGL_EXPORT mgl_set_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2); +void MGL_EXPORT mgl_set_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2); +/// Set range in direction dir as [v1, v2] +void MGL_EXPORT mgl_set_range_val(HMGL gr, char dir, double v1,double v2); +void MGL_EXPORT mgl_set_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int); +/// Add [v1, v2] to the current range in direction dir +void MGL_EXPORT mgl_add_range_val(HMGL gr, char dir, double v1,double v2); +void MGL_EXPORT mgl_add_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int); +/// Set range in direction dir as minimal and maximal values of data a +void MGL_EXPORT mgl_set_range_dat(HMGL gr, char dir, HCDT a, int add); +void MGL_EXPORT mgl_set_range_dat_(uintptr_t *gr, const char *dir, uintptr_t *a, int *add,int); +/// Set ranges for automatic variables +void MGL_EXPORT mgl_set_auto_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2, double c1, double c2); +void MGL_EXPORT mgl_set_auto_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2, mreal *c1, mreal *c2); +/// Set axis range scaling -- simplified way to shift/zoom axis range -- need to redraw whole image! +void MGL_EXPORT mgl_zoom_axis(HMGL gr, double x1,double y1,double z1,double c1,double x2,double y2,double z2,double c2); +void MGL_EXPORT mgl_zoom_axis_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *c1, mreal *x2, mreal *y2, mreal *z2, mreal *c2); + +/// Set axis origin +void MGL_EXPORT mgl_set_origin(HMGL gr, double x0, double y0, double z0); +void MGL_EXPORT mgl_set_origin_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0); +/// Set the transformation formulas for coordinate +void MGL_EXPORT mgl_set_func(HMGL gr, const char *EqX,const char *EqY,const char *EqZ,const char *EqA); +void MGL_EXPORT mgl_set_func_(uintptr_t *gr, const char *EqX, const char *EqY, const char *EqZ, const char *EqA, int, int, int, int); +/// Set one of predefined transformation rule +void MGL_EXPORT mgl_set_coor(HMGL gr, int how); +void MGL_EXPORT mgl_set_coor_(uintptr_t *gr, int *how); +/// Set to draw Ternary axis (triangle like axis, grid and so on) +void MGL_EXPORT mgl_set_ternary(HMGL gr, int enable); +void MGL_EXPORT mgl_set_ternary_(uintptr_t *gr, int *enable); + +/// Set to use or not tick labels rotation +void MGL_EXPORT mgl_set_tick_rotate(HMGL gr, int enable); +void MGL_EXPORT mgl_set_tick_rotate_(uintptr_t *gr, int *enable); +/// Set to use or not tick labels skipping +void MGL_EXPORT mgl_set_tick_skip(HMGL gr, int enable); +void MGL_EXPORT mgl_set_tick_skip_(uintptr_t *gr, int *enable); + +/// Set default font for all new HMGL objects +void MGL_EXPORT mgl_def_font(const char *name, const char *path); +void MGL_EXPORT mgl_def_font_(const char *name, const char *path,int,int); +/// Set default size of marks (locally you can use "size" option) +void MGL_EXPORT mgl_set_mark_size(HMGL gr, double size); +void MGL_EXPORT mgl_set_mark_size_(uintptr_t *gr, mreal *size); +/// Set default size of arrows (locally you can use "size" option) +void MGL_EXPORT mgl_set_arrow_size(HMGL gr, double size); +void MGL_EXPORT mgl_set_arrow_size_(uintptr_t *gr, mreal *size); +/// Set default font size +void MGL_EXPORT mgl_set_font_size(HMGL gr, double size); +void MGL_EXPORT mgl_set_font_size_(uintptr_t *gr, mreal *size); +/// Set default font style and color +void MGL_EXPORT mgl_set_font_def(HMGL gr, const char *fnt); +void MGL_EXPORT mgl_set_font_def_(uintptr_t *gr, const char *fnt, int); +/// Set to use or not text rotation +void MGL_EXPORT mgl_set_rotated_text(HMGL gr, int enable); +void MGL_EXPORT mgl_set_rotated_text_(uintptr_t *gr, int *enable); +/// Load font from file +void MGL_EXPORT mgl_load_font(HMGL gr, const char *name, const char *path); +void MGL_EXPORT mgl_load_font_(uintptr_t *gr, char *name, char *path, int l, int n); +/// Copy font from another mglGraph instance +void MGL_EXPORT mgl_copy_font(HMGL gr, HMGL gr_from); +void MGL_EXPORT mgl_copy_font_(uintptr_t *gr, uintptr_t *gr_from); +/// Restore font (load default font for new HMGL objects) +void MGL_EXPORT mgl_restore_font(HMGL gr); +void MGL_EXPORT mgl_restore_font_(uintptr_t *gr); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/canvas.h b/include/mgl2/canvas.h new file mode 100644 index 0000000..8a1c084 --- /dev/null +++ b/include/mgl2/canvas.h @@ -0,0 +1,471 @@ +/*************************************************************************** + * canvas.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef MGL_CANVAS_H +#define MGL_CANVAS_H +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +struct GifFileType; +//----------------------------------------------------------------------------- +/// Structure for drawing axis and ticks +struct MGL_EXPORT mglAxis +{ + mglAxis() { dv=ds=d=v0=v1=v2=o=sh=0; ns=f=ch=0; pos = 't'; inv=false; } + mglAxis(const mglAxis &aa) + { dv=aa.dv; ds=aa.ds; d=aa.d; dir=aa.dir; sh=aa.sh; + v0=aa.v0; v1=aa.v1; v2=aa.v2; o=aa.o; pos=aa.pos; + a = aa.a; b = aa.b; org=aa.org; txt=aa.txt; inv=aa.inv; + ns=aa.ns; f=aa.f; ch=aa.ch; t=aa.t; } + inline void AddLabel(const wchar_t *lbl, mreal v) + { txt.push_back(mglText(lbl,"",v)); } + inline void AddLabel(const std::wstring &lbl, mreal v) + { txt.push_back(mglText(lbl,v)); } + + mreal dv,ds; ///< Actual step for ticks and subticks. + mreal d; ///< Step for axis ticks (if positive) or its number (if negative). + int ns; ///< Number of axis subticks. + std::wstring t; ///< Tick template (set "" to use default one ("%.2g" in simplest case)) + mglPoint dir; ///< Axis direction + mglPoint a,b; ///< Directions of over axis + mglPoint org; + mreal v0; ///< Center of axis cross section + mreal v1; ///< Minimal axis range. + mreal v2; ///< Maximal axis range. + mreal o; ///< Point of starting ticks numbering (if NAN then Org is used). + int f; ///< Flag 0x1 - time, 0x2 - manual, 0x4 - fixed dv + std::vector txt; ///< Axis labels + char ch; ///< Character of axis (like 'x','y','z','c') + char pos; ///< Text position ('t' by default, or 'T' for opposite) + mreal sh; ///< Extra shift of ticks and axis labels + bool inv; ///< Inverse automatic origin position +}; +//----------------------------------------------------------------------------- +/// Structure for light source +struct MGL_EXPORT mglLight +{ + mglLight() { n=false; a=b=0; } + bool n; ///< Availability of light sources + mglPoint d; ///< Direction of light sources + mglPoint r; ///< Position of light sources (NAN for infinity) + mglPoint q; ///< Actual position of light sources (filled by LightScale() function) + mglPoint p; ///< Actual direction of light sources (filled by LightScale() function) + mreal a; ///< Aperture of light sources + mreal b; ///< Brightness of light sources + mglColor c; ///< Color of light sources +}; +//----------------------------------------------------------------------------- +class mglCanvas; +/// Structure for light source +struct MGL_EXPORT mglDrawReg +{ + union + { + uint64_t PDef; + unsigned char m[8]; + }; + int angle; ///< mask rotation values in degrees + int ObjId; + mreal PenWidth, pPos; + int x1,x2,y1,y2; + void set(mglCanvas *gr, int nx, int ny, int m); +}; +//----------------------------------------------------------------------------- +/// Structure contains everything for drawing +struct MGL_EXPORT mglDrawDat +{ + std::vector Pnt; ///< Internal points + std::vector Prm; ///< Primitives (lines, triangles and so on) -- need for export + std::vector Ptx; ///< Text labels for mglPrim + std::vector Glf; ///< Glyphs data + std::vector Txt; ///< Pointer to textures +}; +//----------------------------------------------------------------------------- +union mglRGBA { uint32_t c; unsigned char r[4]; }; +//----------------------------------------------------------------------------- +/// Class contains all functionality for creating different mathematical plots +class MGL_EXPORT mglCanvas : public mglBase +{ +friend struct mglPrim; +friend struct mglDrawReg; +public: +using mglBase::Light; + + mglCanvas(int w=800, int h=600); + virtual ~mglCanvas(); + + /// Set default parameter for plotting + void DefaultPlotParam(); + + /// Set angle of view indepently from mglCanvas::Rotate() + virtual void View(mreal tetx,mreal tetz,mreal tety=0); + /// Zoom in or zoom out (if Zoom(0, 0, 1, 1)) a part of picture + virtual void Zoom(mreal x1, mreal y1, mreal x2, mreal y2); + /// Restore image after View() and Zoom() + inline void Restore() { Zoom(0,0,1,1); } + + /// Clear transformation matrix. + inline void Identity(bool rel=false) { InPlot(0,1,0,1,rel); } + inline void Identity(mglMatrix &M, bool rel=false) { InPlot(M,0,1,0,1,rel); } + /// Push transformation matrix into stack + void Push(); + /// Set PlotFactor + inline void SetPlotFactor(mreal val) + { if(val<=0) {B.pf=1.55; set(MGL_AUTO_FACTOR);} else {B.pf=val; clr(MGL_AUTO_FACTOR);} } + /// Get PlotFactor + inline mreal GetPlotFactor() { return B.pf; } + /// Pop transformation matrix from stack + inline void Pop() { B = stack.back(); stack.pop_back(); } + /// Clear up the frame + virtual void Clf(mglColor back=NC); + + /// Put further plotting in cell of stick rotated on angles tet, phi + void StickPlot(int num, int i, mreal tet, mreal phi); + /// Put further plotting in some region of whole frame surface. + inline void InPlot(mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true) + { InPlot(B,x1,x2,y1,y2,rel); } + void InPlot(mreal x1,mreal x2,mreal y1,mreal y2, const char *style); + void InPlot(mglMatrix &M,mreal x1,mreal x2,mreal y1,mreal y2,bool rel=true); + /// Add title for current subplot/inplot + void Title(const char *title,const char *stl="#",mreal size=-2); + void Title(const wchar_t *title,const char *stl="#",mreal size=-2); + /// Set aspect ratio for further plotting. + void Aspect(mreal Ax,mreal Ay,mreal Az); + /// Rotate a further plotting. + void Rotate(mreal TetX,mreal TetZ,mreal TetY=0); + /// Rotate a further plotting around vector {x,y,z}. + void RotateN(mreal Tet,mreal x,mreal y,mreal z) ; + /// Set perspective (in range [0,1)) for plot. Set to zero for switching off. + void Perspective(mreal a) { Bp.pf = fabs(a); } + + /// Set size of frame in pixels. Normally this function is called internaly. + virtual void SetSize(int w,int h); + /// Get ratio (mreal width)/(mreal height). + mreal GetRatio() const; + /// Get bitmap data prepared for saving to file + virtual unsigned char **GetRGBLines(long &w, long &h, unsigned char *&f, bool alpha=false); + /// Get RGB bitmap of current state image. + virtual const unsigned char *GetBits(); + /// Get RGBA bitmap of current state image. + const unsigned char *GetRGBA() { Finish(); return G4; } + /// Get width of the image + int GetWidth() const { return Width; } + /// Get height of the image + int GetHeight() const { return Height; } + /// Combine plots from 2 canvases. Result will be saved into this. + void Combine(const mglCanvas *gr); + + inline mreal GetDelay() const { return Delay; } + inline void SetDelay(mreal d) { Delay=d; } + + /// Calculate 3D coordinate {x,y,z} for screen point {xs,ys} + mglPoint CalcXYZ(int xs, int ys, bool real=false) const; + /// Calculate screen point {xs,ys} for 3D coordinate {x,y,z} + void CalcScr(mglPoint p, int *xs, int *ys) const; + mglPoint CalcScr(mglPoint p) const; + /// Set object/subplot id + inline void SetObjId(long id) { ObjId = id; } + /// Get object id + inline int GetObjId(long xs,long ys) const { return OI[xs+Width*ys]; } + /// Get subplot id + int GetSplId(long xs,long ys) const; + /// Check if there is active point or primitive (n=-1) + int IsActive(int xs, int ys,int &n); + + /// Create new frame. + virtual int NewFrame(); + /// Finish frame drawing + virtual void EndFrame(); + /// Get the number of created frames + inline int GetNumFrame() const { return CurFrameId; } + /// Reset frames counter (start it from zero) + virtual void ResetFrames(); + /// Delete primitives for i-th frame + virtual void DelFrame(long i); + /// Get drawing data for i-th frame. + void GetFrame(long i); + /// Set drawing data for i-th frame. This work as EndFrame() but don't add frame to GIF image. + virtual void SetFrame(long i); + /// Add drawing data from i-th frame to the current drawing + void ShowFrame(long i); + + /// Start write frames to cinema using GIF format + void StartGIF(const char *fname, int ms=100); + /// Stop writing cinema using GIF format + void CloseGIF(); + /// Finish plotting. Normally this function is called internaly. + virtual void Finish(); + /// Export points and primitives in file using MGLD format + bool ExportMGLD(const char *fname, const char *descr=0); + /// Import points and primitives from file using MGLD format + bool ImportMGLD(const char *fname, bool add=false); + /// Export in JSON format suitable for later drawing by JavaScript + bool WriteJSON(const char *fname, bool force_zlib=false); + std::string GetJSON(); + + /// Set the transparency type + inline void SetTranspType(int val) + { Flag=(Flag&(~3)) + (val&3); SetAxisStl(val==2?"w-":"k-"); } + /// Set the fog distance or switch it off (if d=0). + virtual void Fog(mreal d, mreal dz=0.25); + /// Switch on/off the specified light source. + virtual void Light(int n, bool enable); + /// Add a light source. + virtual void AddLight(int n,mglPoint r, mglPoint d, char c='w', mreal bright=0.5, mreal ap=0); + inline void AddLight(int n,mglPoint d, char c='w', mreal bright=0.5, mreal ap=0) + { AddLight(n,mglPoint(NAN),d,c,bright,ap); } + + /// Set ticks position and text (\n separated). Use n=0 to disable this feature. + void SetTicksVal(char dir, const char *lbl, bool add=false); + void SetTicksVal(char dir, HCDT v, const char *lbl, bool add=false); + void SetTicksVal(char dir, HCDT v, const char **lbl, bool add=false); + void SetTicksVal(char dir, const wchar_t *lbl, bool add=false); + void SetTicksVal(char dir, HCDT v, const wchar_t *lbl, bool add=false); + void SetTicksVal(char dir, HCDT v, const wchar_t **lbl, bool add=false); + /// Set templates for ticks + void SetTickTempl(char dir, const wchar_t *t); + void SetTickTempl(char dir, const char *t); + /// Set time templates for ticks + void SetTickTime(char dir, mreal d=0, const char *t=""); + /// Set the ticks parameters + void SetTicks(char dir, mreal d=0, int ns=0, mreal org=NAN); + /// Auto adjust ticks + void AdjustTicks(const char *dir="xyzc", bool force=false); + /// Tune ticks + inline void SetTuneTicks(int tune, mreal pos=1.15) + { TuneTicks = tune; FactorPos = pos; } + /// Set ticks styles + void SetAxisStl(const char *stl="k", const char *tck=0, const char *sub=0); + /// Set ticks length + void SetTickLen(mreal tlen, mreal stt=1.); + + /// Draws bounding box outside the plotting volume with color c. + void Box(const char *col=0, bool ticks=true); + /// Draw axises with ticks in directions determined by string parameter dir. + void Axis(const char *dir="xyzt", const char *stl="", const char *opt=""); + /// Draw grid lines perpendicular to direction determined by string parameter dir. + void Grid(const char *dir="xyzt",const char *pen="B-", const char *opt=""); + /// Print the label text for axis dir. + void Label(char dir, const char *text, mreal pos=0, const char *opt=""); + void Labelw(char dir, const wchar_t *text, mreal pos=0, const char *opt=""); + + /// Draw colorbar at edge of axis + void Colorbar(const char *sch=0); + void Colorbar(const char *sch, mreal x, mreal y, mreal w, mreal h); + /// Draw colorbar at edge of axis for manual colors + void Colorbar(HCDT v, const char *sch=0); + void Colorbar(HCDT v, const char *sch, mreal x, mreal y, mreal w, mreal h); + + /// Draw legend of accumulated strings at position (x, y) by font with size + inline void Legend(mreal x, mreal y, const char *font="#", const char *opt="") + { Legend(Leg,x,y,font,opt); } + /// Draw legend of accumulated strings by font with size + inline void Legend(int where=0x3, const char *font="#", const char *opt="") + { Legend(Leg,(where&1)?1:0,(where&2)?1:0,font,opt); } + /// Draw legend of accumulated strings by font with size + inline void Legend(const std::vector &leg, int where=3, const char *font="#", const char *opt="") + { Legend(leg,(where&1)?1:0,(where&2)?1:0,font,opt); } + /// Draw legend strings text at position (x, y) by font with size + void Legend(const std::vector &leg, mreal x, mreal y, const char *font="#", const char *opt=""); + /// Number of marks in legend sample + inline void SetLegendMarks(int num=1) { LegendMarks = num>0?num:1; } + + /// Draw table for values val along given direction with row labels text at given position + void Table(mreal x, mreal y, HCDT val, const wchar_t *text, const char *fnt, const char *opt); + + void StartAutoGroup (const char *); + void EndGroup(); + /// Set extra shift for tick and axis labels + inline void SetTickShift(mglPoint p) + { ax.sh = p.x; ay.sh = p.y; az.sh = p.z; ac.sh = p.c; } + /// Get rotation angle for glyph + float GetGlyphPhi(const mglPnt &q, float phi); + + // Following arrays are open for advanced users only. It is not recommended to change them directly + float *Z; ///< Height for given level in Z-direction (size 3*width*height) + unsigned char *C; ///< Picture for given level in Z-direction (size 3*4*width*height) + int *OI; ///< ObjId arrays (size width*height) + /// Plot point p with color c + void pnt_plot(long x,long y,mreal z,const unsigned char c[4], int obj_id); + void pnt_fast(long x,long y,mreal z,const unsigned char c[4], int obj_id); + /// preparing primitives for 2d export or bitmap drawing (0 default, 1 for 2d vector, 2 for 3d vector) + void PreparePrim(int fast); + inline uint32_t GetPntCol(long i) { return pnt_col[i]; } + inline uint32_t GetPrmCol(long i) { return prm_col[i]; } + +protected: + mreal Delay; ///< Delay for animation in seconds + // NOTE: Z should be float for reducing space and for compatibility reasons + unsigned char *G4; ///< Final picture in RGBA format. Prepared in Finish(). + unsigned char *G; ///< Final picture in RGB format. Prepared in Finish(). + std::vector DrwDat; ///< Set of ALL drawing data for each frames + + int LegendMarks; ///< Number of marks in the Legend + unsigned char BDef[4]; ///< Background color + mglAxis ax,ay,az,ac;///< Axis parameters + + int TuneTicks; ///< Draw tuned ticks with extracted common component + mreal FactorPos; ///< Position of axis ticks factor (0 at Min, 1 at Max, 1.1 is default) + mreal TickLen; ///< Length of tiks (subticks length is sqrt(1+st_t)=1.41... times smaller) + char AxisStl[32]; ///< Axis line style. Default is "k" + char TickStl[32]; ///< Tick line style. Default is "k" + char SubTStl[32]; ///< Subtick line style. Default is "k" + mreal st_t; ///< Subtick-to-tick ratio (ls=lt/sqrt(1+st_t)). Default is 1. + + int CurFrameId; ///< Number of automaticle created frames + int Width; ///< Width of the image + int Height; ///< Height of the image + int Depth; ///< Depth of the image + mreal inW, inH; ///< Width and height of last InPlot + mreal inX, inY; ///< Coordinates of last InPlot + mglLight light[10]; ///< Light sources + mreal FogDist; ///< Inverse fog distance (fog ~ exp(-FogDist*Z)) + mreal FogDz; ///< Relative shift of fog + + /// Auto adjust ticks + void AdjustTicks(mglAxis &aa, bool ff); + /// Prepare labels for ticks + void LabelTicks(mglAxis &aa); + /// Draw axis + void DrawAxis(mglAxis &aa, bool text=true, char arr=0,const char *stl="",const char *opt=""); + /// Draw axis grid lines + void DrawGrid(mglAxis &aa); + /// Update axis ranges + inline void UpdateAxis() + { ax.v0=Org.x; ay.v0=Org.y; az.v0=Org.z; ac.v0=Org.c; + ax.v1=Min.x; ay.v1=Min.y; az.v1=Min.z; ac.v1=Min.c; + ax.v2=Max.x; ay.v2=Max.y; az.v2=Max.z; ac.v2=Max.c; } + + /// Clear ZBuffer only + void ClfZB(bool force=false); + /// Scale coordinates and cut off some points + bool ScalePoint(const mglMatrix *M, mglPoint &p, mglPoint &n, bool use_nan=true) const; + void LightScale(const mglMatrix *M); ///< Additionally scale positions of light sources + /// Push drawing data (for frames only). NOTE: can be VERY large + long PushDrwDat(); + /// Retur color for primitive depending lighting + uint32_t GetColor(const mglPrim &p); + + mreal GetOrgX(char dir, bool inv=false) const; ///< Get Org.x (parse NAN value) + mreal GetOrgY(char dir, bool inv=false) const; ///< Get Org.y (parse NAN value) + mreal GetOrgZ(char dir, bool inv=false) const; ///< Get Org.z (parse NAN value) + + void mark_plot(long p, char type, mreal size=1); + void arrow_plot(long p1, long p2, char st); + void line_plot(long p1, long p2); + void trig_plot(long p1, long p2, long p3); + void quad_plot(long p1, long p2, long p3, long p4); + void Glyph(mreal x, mreal y, mreal f, int style, long icode, mreal col); + mreal text_plot(long p,const wchar_t *text,const char *fnt,mreal size=-1,mreal sh=0,mreal col=-('k'), bool rot=true); + + void add_prim(mglPrim &a); ///< add primitive to list + void arrow_draw(const mglPnt &p1, const mglPnt &p2, char st, mreal size, const mglDrawReg *d); + virtual void mark_draw(const mglPnt &p, char type, mreal size, mglDrawReg *d); + virtual void line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + virtual void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d); + virtual void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d); + virtual void pnt_draw(const mglPnt &p, const mglDrawReg *d); + void arrow_draw(long n1, long n2, char st, float ll); + void arrow_plot_3d(long n1, long n2, char st, float ll); + void glyph_draw(const mglPrim &P, mglDrawReg *d); + bool IsSame(const mglPrim &pr,mreal wp,mglColor cp,int st); + + // restore normalized coordinates from screen ones + mglPoint RestorePnt(mglPoint ps, bool norm=false) const; + + // functions for multi-threading + void pxl_pntcol(long id, long n, const void *); + void pxl_prmcol(long id, long n, const void *); + void pxl_combine(long id, long n, const void *); + void pxl_memcpy(long id, long n, const void *); + void pxl_backgr(long id, long n, const void *); + void pxl_primdr(long id, long n, const void *); + void pxl_dotsdr(long id, long n, const void *); + void pxl_primpx(long id, long n, const void *); + void pxl_transform(long id, long n, const void *); + void pxl_setz(long id, long n, const void *); + void pxl_setz_adv(long id, long n, const void *); + void pxl_other(long id, long n, const void *p); + /// Put drawing from other mglCanvas (for multithreading, like subplots) + void PutDrawReg(mglDrawReg *d, const mglCanvas *gr); + +private: + std::vector pnt_col, prm_col; +// mreal _tetx,_tety,_tetz; // extra angles + std::vector stack; ///< stack for transformation matrices + GifFileType *gif; + mreal fscl,ftet; ///< last scale and rotation for glyphs + long forg; ///< original point (for directions) + size_t grp_counter; ///< Counter for StartGroup(); EndGroup(); + mglMatrix Bt; ///< temporary matrix for text + + /// Draw generic colorbar + void colorbar(HCDT v, const mreal *s, int where, mreal x, mreal y, mreal w, mreal h, bool text); + /// Draw labels for ticks + void DrawLabels(mglAxis &aa, bool inv=false, const mglMatrix *M=0); + /// Get label style + char GetLabelPos(mreal c, long kk, mglAxis &aa); + /// Draw tick + void tick_draw(mglPoint o, mglPoint d1, mglPoint d2, int f); + mreal FindOptOrg(char dir, int ind) const; + /// Transform mreal color and alpha to bits format + unsigned char* col2int(const mglPnt &p, unsigned char *r, int obj_id); + /// Combine colors in 2 plane. + void combine(unsigned char *c1, const unsigned char *c2); + /// Fast drawing of line between 2 points + void fast_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + + /// Additionally scale points p for positioning in image + void PostScale(const mglMatrix *M, mglPoint &p) const; + /// Scale points p for projection to the face number nface in image + long ProjScale(int nface, long p, bool text=false); + /// Set coordinate and add the point, return its id + long setPp(mglPnt &q, const mglPoint &p); + + // functions for glyph drawing + void glyph_fill(const mglMatrix *M, const mglPnt &p, mreal f, const mglGlyph &g, const mglDrawReg *d); + void glyph_wire(const mglMatrix *M, const mglPnt &p, mreal f, const mglGlyph &g, const mglDrawReg *d); + void glyph_line(const mglMatrix *M, const mglPnt &p, mreal f, bool solid, const mglDrawReg *d); + + // fill pixel for given primitive + void mark_pix(long i,long j,const mglPnt &p, char type, mreal size, mglDrawReg *d); + void arrow_pix(long i,long j,const mglPnt &p1, const mglPnt &p2, char st, mreal size, const mglDrawReg *d); + void line_pix(long i,long j,const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + void trig_pix(long i,long j,const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d); + void quad_pix(long i,long j,const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d); + void glyph_pix(long i,long j,const mglPrim &P, mglDrawReg *d); + void pnt_pix(long i,long j,const mglPnt &p, const mglDrawReg *d); + void glyph_fpix(long i,long j,const mglMatrix *M, const mglPnt &p, mreal f, const mglGlyph &g, const mglDrawReg *d); + void glyph_wpix(long i,long j,const mglMatrix *M, const mglPnt &p, mreal f, const mglGlyph &g, const mglDrawReg *d); + void glyph_lpix(long i,long j,const mglMatrix *M, const mglPnt &p, mreal f, bool solid, const mglDrawReg *d); + + +}; +//----------------------------------------------------------------------------- +struct mglThreadG +{ + mglCanvas *gr; // grapher + void (mglCanvas::*f)(long i, long n, const void *); + unsigned id; // thread id + long n; // total number of iteration + const void *p; // external parameter +}; +/// Start several thread for the task +void mglStartThread(void (mglCanvas::*func)(long i, long n), mglCanvas *gr, long n); +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/canvas_cf.h b/include/mgl2/canvas_cf.h new file mode 100644 index 0000000..de04e43 --- /dev/null +++ b/include/mgl2/canvas_cf.h @@ -0,0 +1,492 @@ +/*************************************************************************** + * canvas_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef MGL_CANVAS_CF_H +#define MGL_CANVAS_CF_H +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Create HMGL object with specified sizes +HMGL MGL_EXPORT mgl_create_graph(int width, int height); +uintptr_t MGL_EXPORT mgl_create_graph_(int *width, int *height); +/// Delete HMGL object +void MGL_EXPORT mgl_delete_graph(HMGL gr); +void MGL_EXPORT mgl_delete_graph_(uintptr_t *gr); +/// Set size of frame in pixels. Normally this function is called internally. +void MGL_EXPORT mgl_set_size(HMGL gr, int width, int height); +void MGL_EXPORT mgl_set_size_(uintptr_t *gr, int *width, int *height); +/// Set default parameters for plotting +void MGL_EXPORT mgl_set_def_param(HMGL gr); +void MGL_EXPORT mgl_set_def_param_(uintptr_t *gr); +/// Combine plots from 2 canvases. Result will be saved into gr +void MGL_EXPORT mgl_combine_gr(HMGL gr, HMGL gr2); +void MGL_EXPORT mgl_combine_gr_(uintptr_t *gr, uintptr_t *gr2); +/// Force preparing the image. It can be useful for OpenGL mode mostly. +void MGL_EXPORT mgl_finish(HMGL gr); +void MGL_EXPORT mgl_finish_(uintptr_t *gr); + +/// Set tick length +void MGL_EXPORT mgl_set_tick_len(HMGL gr, double len, double stt); +void MGL_EXPORT mgl_set_tick_len_(uintptr_t *gr, mreal *len, mreal *stt); +/// Set axis and ticks style +void MGL_EXPORT mgl_set_axis_stl(HMGL gr, const char *stl, const char *tck, const char *sub); +void MGL_EXPORT mgl_set_axis_stl_(uintptr_t *gr, const char *stl, const char *tck, const char *sub, int,int,int); + +/// Auto adjust ticks +void MGL_EXPORT mgl_adjust_ticks(HMGL gr, const char *dir); +void MGL_EXPORT mgl_adjust_ticks_(uintptr_t *gr, const char *dir, int); +/// Set the ticks parameters +void MGL_EXPORT mgl_set_ticks(HMGL gr, char dir, double d, int ns, double org); +void MGL_EXPORT mgl_set_ticks_(uintptr_t *gr, char *dir, mreal *d, int *ns, mreal *org, int); +/// Set ticks text (\n separated). Use "" to disable this feature. +void MGL_EXPORT mgl_set_ticks_str(HMGL gr, char dir, const char *lbl, int add); +void MGL_EXPORT mgl_set_ticks_str_(uintptr_t *gr, const char *dir, const char *lbl, int *add,int,int); +void MGL_EXPORT mgl_set_ticks_wcs(HMGL gr, char dir, const wchar_t *lbl, int add); +/// Set ticks position and text (\n separated). Use "" to disable this feature. +void MGL_EXPORT mgl_set_ticks_val(HMGL gr, char dir, HCDT val, const char *lbl, int add); +void MGL_EXPORT mgl_set_ticks_val_(uintptr_t *gr, const char *dir, uintptr_t *val, const char *lbl, int *add,int,int); +void MGL_EXPORT mgl_set_ticks_valw(HMGL gr, char dir, HCDT val, const wchar_t *lbl, int add); +/// Tune ticks +void MGL_EXPORT mgl_tune_ticks(HMGL gr, int tune, double fact_pos); +void MGL_EXPORT mgl_tune_ticks_(uintptr_t *gr, int *tune, mreal *fact_pos); +/// Set templates for ticks +void MGL_EXPORT mgl_set_tick_templ(HMGL gr, char dir, const char *templ); +void MGL_EXPORT mgl_set_tick_templ_(uintptr_t *gr, const char *dir, const char *templ,int,int); +void MGL_EXPORT mgl_set_tick_templw(HMGL gr, char dir, const wchar_t *templ); +/// Set time templates for ticks +void MGL_EXPORT mgl_set_ticks_time(HMGL gr, char dir, double d, const char *t); +void MGL_EXPORT mgl_set_ticks_time_(uintptr_t *gr, const char *dir, mreal *d, const char *t,int,int); +/// Set additional shift of tick labels +void MGL_EXPORT mgl_set_tick_shift(HMGL gr, double sx, double sy, double sz, double sc); +void MGL_EXPORT mgl_set_tick_shift_(uintptr_t *gr, mreal *sx, mreal *sy, mreal *sz, mreal *sc); + +/// Draws bounding box outside the plotting volume +void MGL_EXPORT mgl_box(HMGL gr); +void MGL_EXPORT mgl_box_(uintptr_t *gr); +/// Draws bounding box outside the plotting volume with color c +void MGL_EXPORT mgl_box_str(HMGL gr, const char *col, int ticks); +void MGL_EXPORT mgl_box_str_(uintptr_t *gr, const char *col, int *ticks, int); +/// Draw axises with ticks in direction(s) dir. +void MGL_EXPORT mgl_axis(HMGL gr, const char *dir, const char *stl, const char *opt); +void MGL_EXPORT mgl_axis_(uintptr_t *gr, const char *dir, const char *stl, const char *opt,int,int,int); +/// Draw grid lines perpendicular to direction(s) dir. +void MGL_EXPORT mgl_axis_grid(HMGL gr, const char *dir,const char *pen, const char *opt); +void MGL_EXPORT mgl_axis_grid_(uintptr_t *gr, const char *dir,const char *pen, const char *opt,int,int,int); +/// Print the label text for axis dir. +void MGL_EXPORT mgl_label(HMGL gr, char dir, const char *text, double pos, const char *opt); +void MGL_EXPORT mgl_label_(uintptr_t *gr, const char *dir, const char *text, mreal *pos, const char *opt,int,int,int); +void MGL_EXPORT mgl_labelw(HMGL gr, char dir, const wchar_t *text, double pos, const char *opt); + +/// Draw colorbar at edge of axis +void MGL_EXPORT mgl_colorbar(HMGL gr, const char *sch); +void MGL_EXPORT mgl_colorbar_(uintptr_t *gr, const char *sch,int); +/// Draw colorbar at manual position +void MGL_EXPORT mgl_colorbar_ext(HMGL gr, const char *sch, double x, double y, double w, double h); +void MGL_EXPORT mgl_colorbar_ext_(uintptr_t *gr, const char *sch, mreal *x, mreal *y, mreal *w, mreal *h, int); +/// Draw colorbar with manual colors at edge of axis +void MGL_EXPORT mgl_colorbar_val(HMGL gr, HCDT dat, const char *sch); +void MGL_EXPORT mgl_colorbar_val_(uintptr_t *gr, uintptr_t *dat, const char *sch,int); +/// Draw colorbar with manual colors at manual position +void MGL_EXPORT mgl_colorbar_val_ext(HMGL gr, HCDT dat, const char *sch,double x, double y, double w, double h); +void MGL_EXPORT mgl_colorbar_val_ext_(uintptr_t *gr, uintptr_t *dat, const char *sch, mreal *x, mreal *y, mreal *w, mreal *h, int); + +/// Add string to legend +void MGL_EXPORT mgl_add_legend(HMGL gr, const char *text,const char *style); +void MGL_EXPORT mgl_add_legend_(uintptr_t *gr, const char *text,const char *style,int,int); +void MGL_EXPORT mgl_add_legendw(HMGL gr, const wchar_t *text,const char *style); +/// Clear saved legend string +void MGL_EXPORT mgl_clear_legend(HMGL gr); +void MGL_EXPORT mgl_clear_legend_(uintptr_t *gr); +/// Draw legend of accumulated strings at position {x,y} +void MGL_EXPORT mgl_legend_pos(HMGL gr, double x, double y, const char *font, const char *opt); +void MGL_EXPORT mgl_legend_pos_(uintptr_t *gr, mreal *x, mreal *y, const char *font, const char *opt,int,int); +/// Draw legend of accumulated strings +void MGL_EXPORT mgl_legend(HMGL gr, int where, const char *font, const char *opt); +void MGL_EXPORT mgl_legend_(uintptr_t *gr, int *where, const char *font, const char *opt,int,int); +/// Set number of marks in legend sample +void MGL_EXPORT mgl_set_legend_marks(HMGL gr, int num); +void MGL_EXPORT mgl_set_legend_marks_(uintptr_t *gr, int *num); + +/// Show current image +void MGL_EXPORT mgl_show_image(HMGL gr, const char *viewer, int keep); +void MGL_EXPORT mgl_show_image_(uintptr_t *gr, const char *viewer, int *keep, int); +/// Write the frame in file (depending extension, write current frame if fname is empty) +void MGL_EXPORT mgl_write_frame(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_frame_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using BMP format +void MGL_EXPORT mgl_write_tga(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_tga_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using BMP format +void MGL_EXPORT mgl_write_bmp(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_bmp_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using JPEG format +void MGL_EXPORT mgl_write_jpg(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_jpg_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using PNG format with transparency +void MGL_EXPORT mgl_write_png(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_png_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using PNG format without transparency +void MGL_EXPORT mgl_write_png_solid(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_png_solid_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using PostScript format as bitmap +void MGL_EXPORT mgl_write_bps(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_bps_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using PostScript format +void MGL_EXPORT mgl_write_eps(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_eps_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using SVG format +void MGL_EXPORT mgl_write_svg(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_svg_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using LaTeX format +void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_tex_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using OBJ format +void MGL_EXPORT mgl_write_obj(HMGL gr, const char *fname,const char *descr, int use_png); +void MGL_EXPORT mgl_write_obj_(uintptr_t *gr, const char *fname,const char *descr, int *use_png,int,int); +/// Write the frame in file using OBJ format (old version) +void MGL_EXPORT mgl_write_obj_old(HMGL gr, const char *fname,const char *descr, int use_png); +void MGL_EXPORT mgl_write_obj_old_(uintptr_t *gr, const char *fname,const char *descr, int *use_png,int,int); +/// Write the frame in file using STL format (faces only) +void MGL_EXPORT mgl_write_stl(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_stl_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Write the frame in file using OFF format +void MGL_EXPORT mgl_write_off(HMGL gr, const char *fname,const char *descr, int colored); +void MGL_EXPORT mgl_write_off_(uintptr_t *gr, const char *fname,const char *descr,int *colored,int,int); +/// Write the frame in file using XYZ format +void MGL_EXPORT mgl_write_xyz(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_xyz_(uintptr_t *gr, const char *fname,const char *descr,int,int); + +/*void MGL_EXPORT mgl_write_x3d(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_x3d_(uintptr_t *gr, const char *fname,const char *descr,int,int); +void MGL_EXPORT mgl_write_wgl(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_wgl_(uintptr_t *gr, const char *fname,const char *descr,int,int);*/ + +/// Write the frame in file using PRC format +void MGL_EXPORT mgl_write_prc(HMGL gr, const char *fname,const char *descr, int make_pdf); +void MGL_EXPORT mgl_write_prc_(uintptr_t *gr, const char *fname,const char *descr, int *make_pdf,int,int); +/// Write the frame in file using GIF format (only for current frame!) +void MGL_EXPORT mgl_write_gif(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_gif_(uintptr_t *gr, const char *fname,const char *descr,int,int); + +/// Start write frames to cinema using GIF format +void MGL_EXPORT mgl_start_gif(HMGL gr, const char *fname,int ms); +void MGL_EXPORT mgl_start_gif_(uintptr_t *gr, const char *fname,int *ms,int); +/// Stop writing cinema using GIF format +void MGL_EXPORT mgl_close_gif(HMGL gr); +void MGL_EXPORT mgl_close_gif_(uintptr_t *gr); + +/// Export points and primitives in file using MGLD format +void MGL_EXPORT mgl_export_mgld(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_export_mgld_(uintptr_t *gr, const char *fname,const char *descr,int,int); +/// Import points and primitives from file using MGLD format +void MGL_EXPORT mgl_import_mgld(HMGL gr, const char *fname, int add); +void MGL_EXPORT mgl_import_mgld_(uintptr_t *gr, const char *fname, int *add, int); +/// Export in JSON format suitable for later drawing by JavaScript +void MGL_EXPORT mgl_write_json(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_json_(uintptr_t *gr, const char *fname,const char *descr,int,int); +void MGL_EXPORT mgl_write_json_z(HMGL gr, const char *fname,const char *descr); +void MGL_EXPORT mgl_write_json_z_(uintptr_t *gr, const char *fname,const char *descr,int,int); +MGL_EXPORT const char *mgl_get_json(HMGL gr); + +/// Get RGB values of current bitmap +MGL_EXPORT const unsigned char *mgl_get_rgb(HMGL gr); +MGL_EXPORT const unsigned char *mgl_get_rgb_(uintptr_t *gr); +/// Get RGBA values of current bitmap +MGL_EXPORT const unsigned char *mgl_get_rgba(HMGL gr); +MGL_EXPORT const unsigned char *mgl_get_rgba_(uintptr_t *gr); +/// Set object/subplot id +void MGL_EXPORT mgl_set_obj_id(HMGL gr, int id); +void MGL_EXPORT mgl_set_obj_id_(uintptr_t *gr, int *id); +/// Get object id +int MGL_EXPORT mgl_get_obj_id(HMGL gr, int x, int y); +int MGL_EXPORT mgl_get_obj_id_(uintptr_t *gr, int *x, int *y); +/// Get subplot id +int MGL_EXPORT mgl_get_spl_id(HMGL gr, int x, int y); +int MGL_EXPORT mgl_get_spl_id_(uintptr_t *gr, int *x, int *y); +/// Get width of the image +int MGL_EXPORT mgl_get_width(HMGL gr); +int MGL_EXPORT mgl_get_width_(uintptr_t *gr); +/// Get height of the image +int MGL_EXPORT mgl_get_height(HMGL gr); +int MGL_EXPORT mgl_get_height_(uintptr_t *gr); +/// Calculate 3D coordinate {x,y,z} for screen point {xs,ys} +void MGL_EXPORT mgl_calc_xyz(HMGL gr, int xs, int ys, mreal *x, mreal *y, mreal *z); +void MGL_EXPORT mgl_calc_xyz_(uintptr_t *gr, int *xs, int *ys, mreal *x, mreal *y, mreal *z); +/// Calculate screen point {xs,ys} for 3D coordinate {x,y,z} +void MGL_EXPORT mgl_calc_scr(HMGL gr, double x, double y, double z, int *xs, int *ys); +void MGL_EXPORT mgl_calc_scr_(uintptr_t *gr, mreal *x, mreal *y, mreal *z, int *xs, int *ys); +/// Check if {xs,ys} is close to active point with accuracy d, and return its position or -1 +long MGL_EXPORT mgl_is_active(HMGL gr, int xs, int ys, int d); +long MGL_EXPORT mgl_is_active_(uintptr_t *gr, int *xs, int *ys, int *d); + +/// Create new frame. +int MGL_EXPORT mgl_new_frame(HMGL gr); +int MGL_EXPORT mgl_new_frame_(uintptr_t *gr); +/// Finish frame drawing +void MGL_EXPORT mgl_end_frame(HMGL gr); +void MGL_EXPORT mgl_end_frame_(uintptr_t *gr); +/// Get the number of created frames +int MGL_EXPORT mgl_get_num_frame(HMGL gr); +int MGL_EXPORT mgl_get_num_frame_(uintptr_t *gr); +/// Reset frames counter (start it from zero) +void MGL_EXPORT mgl_reset_frames(HMGL gr); +void MGL_EXPORT mgl_reset_frames_(uintptr_t *gr); +/// Get drawing data for i-th frame (work if MGL_VECT_FRAME is set on) +void MGL_EXPORT mgl_get_frame(HMGL gr, int i); +void MGL_EXPORT mgl_get_frame_(uintptr_t *gr, int *i); +/// Set drawing data for i-th frame (work if MGL_VECT_FRAME is set on) +void MGL_EXPORT mgl_set_frame(HMGL gr, int i); +void MGL_EXPORT mgl_set_frame_(uintptr_t *gr, int *i); +/// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) +void MGL_EXPORT mgl_show_frame(HMGL gr, int i); +void MGL_EXPORT mgl_show_frame_(uintptr_t *gr, int *i); +/// Delete primitives for i-th frame (work if MGL_VECT_FRAME is set on) +void MGL_EXPORT mgl_del_frame(HMGL gr, int i); +void MGL_EXPORT mgl_del_frame_(uintptr_t *gr, int *i); + +/// Set the transparency type (0 - usual, 1 - glass, 2 - lamp) +void MGL_EXPORT mgl_set_transp_type(HMGL gr, int kind); +void MGL_EXPORT mgl_set_transp_type_(uintptr_t *gr, int *kind); +/// Set the transparency on/off. +void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable); +void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable); +/// Set the fog distance or switch it off (if d=0). +void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz); +void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *dist, mreal *dz); +/// Set the using of light on/off. +void MGL_EXPORT mgl_set_light(HMGL gr, int enable); +void MGL_EXPORT mgl_set_light_(uintptr_t *gr, int *enable); +/// Switch on/off the specified light source. +void MGL_EXPORT mgl_set_light_n(HMGL gr, int n, int enable); +void MGL_EXPORT mgl_set_light_n_(uintptr_t *gr, int *n, int *enable); + +/// Add white light source at infinity. +void MGL_EXPORT mgl_add_light(HMGL gr, int n, double x, double y, double z); +void MGL_EXPORT mgl_add_light_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z); +/// Add light source at infinity (more settings). +void MGL_EXPORT mgl_add_light_ext(HMGL gr, int n, double x, double y, double z, char c, double br, double ap); +void MGL_EXPORT mgl_add_light_ext_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z, char *c, mreal *br, mreal *ap, int); +/// Add local light source. +void MGL_EXPORT mgl_add_light_loc(HMGL gr, int n, double x, double y, double z, double dx, double dy, double dz, char c, double br, double ap); +void MGL_EXPORT mgl_add_light_loc_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z, mreal *dx, mreal *dy, mreal *dz, char *c, mreal *br, mreal *ap, int); + +/// Pop transformation matrix from stack +void MGL_EXPORT mgl_mat_pop(HMGL gr); +void MGL_EXPORT mgl_mat_pop_(uintptr_t *gr); +/// Push transformation matrix into stack +void MGL_EXPORT mgl_mat_push(HMGL gr); +void MGL_EXPORT mgl_mat_push_(uintptr_t *gr); + +/// Clear up the frame +void MGL_EXPORT mgl_clf(HMGL gr); +void MGL_EXPORT mgl_clf_(uintptr_t *gr); +/// Clear up the frame and fill background by specified color +void MGL_EXPORT mgl_clf_rgb(HMGL gr, double r, double g, double b); +void MGL_EXPORT mgl_clf_rgb_(uintptr_t *gr, mreal *r, mreal *g, mreal *b); +/// Clear up the frame and fill background by specified color +void MGL_EXPORT mgl_clf_chr(HMGL gr, char col); +void MGL_EXPORT mgl_clf_chr_(uintptr_t *gr, const char *col, int); + +/// Put further plotting in some region of whole frame. +void MGL_EXPORT mgl_subplot(HMGL gr, int nx,int ny,int m,const char *style); +void MGL_EXPORT mgl_subplot_(uintptr_t *gr, int *nx,int *ny,int *m, const char *s,int); +/// Put further plotting in some region of whole frame and shift it by distance {dx,dy}. +void MGL_EXPORT mgl_subplot_d(HMGL gr, int nx,int ny,int m,const char *style, double dx, double dy); +void MGL_EXPORT mgl_subplot_d_(uintptr_t *gr, int *nx,int *ny,int *m, mreal *dx, mreal *dy); +/// Like MGL_EXPORT mgl_subplot() but "join" several cells +void MGL_EXPORT mgl_multiplot(HMGL gr, int nx,int ny,int m,int dx,int dy,const char *style); +void MGL_EXPORT mgl_multiplot_(uintptr_t *gr, int *nx,int *ny,int *m,int *dx,int *dy, const char *s,int); +/// Put further plotting in a region of whole frame. +void MGL_EXPORT mgl_inplot(HMGL gr, double x1,double x2,double y1,double y2); +void MGL_EXPORT mgl_inplot_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2); +/// Put further plotting in a region of current subplot/inplot. +void MGL_EXPORT mgl_relplot(HMGL gr, double x1,double x2,double y1,double y2); +void MGL_EXPORT mgl_relplot_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2); +/// Put further plotting in column cell of previous subplot/inplot. +void MGL_EXPORT mgl_columnplot(HMGL gr, int num, int ind, double d); +void MGL_EXPORT mgl_columnplot_(uintptr_t *gr, int *num, int *i, mreal *d); +/// Put further plotting in matrix cell of previous subplot/inplot. +void MGL_EXPORT mgl_gridplot(HMGL gr, int nx, int ny, int m, double d); +void MGL_EXPORT mgl_gridplot_(uintptr_t *gr, int *nx, int *ny, int *m, mreal *d); +/// Put further plotting in cell of stick rotated on angles tet, phi. +void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int ind, double tet, double phi); +void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi); +/// Add title for current subplot/inplot. +void MGL_EXPORT mgl_title(HMGL gr, const char *title, const char *stl, double size); +void MGL_EXPORT mgl_title_(uintptr_t *gr, const char *title, const char *stl, mreal *size, int,int); +void MGL_EXPORT mgl_titlew(HMGL gr, const wchar_t *title, const char *stl, double size); +/// Set factor of plot size +void MGL_EXPORT mgl_set_plotfactor(HMGL gr, double val); +void MGL_EXPORT mgl_set_plotfactor_(uintptr_t *gr, mreal *val); + +/// Set aspect ratio for further plotting. +void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az); +void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az); +/// Rotate a further plotting. +void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY); +void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY); +/// Rotate a further plotting around vector {x,y,z}. +void MGL_EXPORT mgl_rotate_vector(HMGL gr, double Tet,double x,double y,double z); +void MGL_EXPORT mgl_rotate_vector_(uintptr_t *gr, mreal *Tet, mreal *x, mreal *y, mreal *z); +/// Set perspective (in range [0,1)) for plot. Set to zero for switching off. +void MGL_EXPORT mgl_perspective(HMGL gr, double val); +void MGL_EXPORT mgl_perspective_(uintptr_t *gr, double val); +/// Set angle of view independently from Rotate(). +void MGL_EXPORT mgl_view(HMGL gr, double TetX,double TetZ,double TetY); +void MGL_EXPORT mgl_view_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY); +/// Zoom in/out a part of picture (use mgl_zoom(0, 0, 1, 1) for restore default) +void MGL_EXPORT mgl_zoom(HMGL gr, double x1, double y1, double x2, double y2); +void MGL_EXPORT mgl_zoom_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *x2, mreal *y2); + +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_draw_thr(void *); +/// Callback function for mouse click +void MGL_EXPORT mgl_set_click_func(HMGL gr, void (*func)(void *p)); + +/// Set delay for animation in seconds +void MGL_EXPORT mgl_wnd_set_delay(HMGL gr, double dt); +void MGL_EXPORT mgl_wnd_set_delay_(uintptr_t *gr, mreal *dt); +/// Get delay for animation in seconds +double MGL_EXPORT mgl_wnd_get_delay(HMGL gr); +double MGL_EXPORT mgl_wnd_get_delay_(uintptr_t *gr); +/// Set window properties +void MGL_EXPORT mgl_setup_window(HMGL gr, int clf_upd, int showpos); +void MGL_EXPORT mgl_setup_window_(uintptr_t *gr, int *clf_upd, int *showpos); +/// Switch on/off transparency (do not overwrite user settings) +void MGL_EXPORT mgl_wnd_toggle_alpha(HMGL gr); +void MGL_EXPORT mgl_wnd_toggle_alpha_(uintptr_t *gr); +/// Switch on/off lighting (do not overwrite user settings) +void MGL_EXPORT mgl_wnd_toggle_light(HMGL gr); +void MGL_EXPORT mgl_wnd_toggle_light_(uintptr_t *gr); +/// Switch on/off zooming by mouse +void MGL_EXPORT mgl_wnd_toggle_zoom(HMGL gr); +void MGL_EXPORT mgl_wnd_toggle_zoom_(uintptr_t *gr); +/// Switch on/off rotation by mouse +void MGL_EXPORT mgl_wnd_toggle_rotate(HMGL gr); +void MGL_EXPORT mgl_wnd_toggle_rotate_(uintptr_t *gr); +/// Switch off all zooming and rotation +void MGL_EXPORT mgl_wnd_toggle_no(HMGL gr); +void MGL_EXPORT mgl_wnd_toggle_no_(uintptr_t *gr); +/// Update picture by calling user drawing function +void MGL_EXPORT mgl_wnd_update(HMGL gr); +void MGL_EXPORT mgl_wnd_update_(uintptr_t *gr); +/// Reload user data and update picture +void MGL_EXPORT mgl_wnd_reload(HMGL gr); +void MGL_EXPORT mgl_wnd_reload_(uintptr_t *gr); +/// Adjust size of bitmap to window size +void MGL_EXPORT mgl_wnd_adjust(HMGL gr); +void MGL_EXPORT mgl_wnd_adjust_(uintptr_t *gr); +/// Show next frame (if one) +void MGL_EXPORT mgl_wnd_next_frame(HMGL gr); +void MGL_EXPORT mgl_wnd_next_frame_(uintptr_t *gr); +/// Show previous frame (if one) +void MGL_EXPORT mgl_wnd_prev_frame(HMGL gr); +void MGL_EXPORT mgl_wnd_prev_frame_(uintptr_t *gr); +/// Run slideshow (animation) of frames +void MGL_EXPORT mgl_wnd_animation(HMGL gr); +void MGL_EXPORT mgl_wnd_animation_(uintptr_t *gr); +/// Get last mouse position +void MGL_EXPORT mgl_get_last_mouse_pos(HMGL gr, mreal *x, mreal *y, mreal *z); +void MGL_EXPORT mgl_get_last_mouse_pos_(uintptr_t *gr, mreal *x, mreal *y, mreal *z); +//----------------------------------------------------------------------------- +/// Create HMPR object for parsing MGL scripts +HMPR MGL_EXPORT mgl_create_parser(); +uintptr_t MGL_EXPORT mgl_create_parser_(); +/// Change counter of HMPR uses (for advanced users only). Non-zero counter prevent automatic object removing. +long MGL_EXPORT mgl_use_parser(HMPR p, int inc); +long MGL_EXPORT mgl_use_parser_(uintptr_t* , int *inc); +/// Delete HMPR object +void MGL_EXPORT mgl_delete_parser(HMPR p); +void MGL_EXPORT mgl_delete_parser_(uintptr_t* p); +/// Set value for parameter $N +void MGL_EXPORT mgl_parser_add_param(HMPR p, int id, const char *str); +void MGL_EXPORT mgl_parser_add_param_(uintptr_t* p, int *id, const char *str, int); +void MGL_EXPORT mgl_parser_add_paramw(HMPR p, int id, const wchar_t *str); + +/// Find variable with given name or add a new one +/// NOTE !!! You must not delete obtained data arrays !!! +HMDT MGL_EXPORT mgl_parser_add_var(HMPR p, const char *name); +uintptr_t MGL_EXPORT mgl_parser_add_var_(uintptr_t* p, const char *name, int); +HMDT MGL_EXPORT mgl_parser_add_varw(HMPR p, const wchar_t *name); +/// Find variable with given name or return NULL if no one +/// NOTE !!! You must not delete obtained data arrays !!! +HMDT MGL_EXPORT mgl_parser_find_var(HMPR p, const char *name); +uintptr_t MGL_EXPORT mgl_parser_find_var_(uintptr_t* p, const char *name, int); +HMDT MGL_EXPORT mgl_parser_find_varw(HMPR p, const wchar_t *name); + +/// Delete variable with name +void MGL_EXPORT mgl_parser_del_var(HMPR p, const char *name); +void MGL_EXPORT mgl_parser_del_var_(uintptr_t* p, const char *name, int); +void MGL_EXPORT mgl_parser_del_varw(HMPR p, const wchar_t *name); +/// Delete all data variables +void MGL_EXPORT mgl_parser_del_all(HMPR p); +void MGL_EXPORT mgl_parser_del_all_(uintptr_t *p); + +/// Parse and draw single line of the MGL script +int MGL_EXPORT mgl_parse_line(HMGL gr, HMPR p, const char *str, int pos); +int MGL_EXPORT mgl_parse_line_(uintptr_t* gr, uintptr_t* p, const char *str, int *pos, int); +int MGL_EXPORT mgl_parse_linew(HMGL gr, HMPR p, const wchar_t *str, int pos); +/// Execute and draw script from the file +void MGL_EXPORT mgl_parse_file(HMGL gr, HMPR p, FILE *fp, int print); +/// Execute MGL script text with '\n' separated lines +void MGL_EXPORT mgl_parse_text(HMGL gr, HMPR p, const char *str); +void MGL_EXPORT mgl_parse_text_(uintptr_t* gr, uintptr_t* p, const char *str, int); +void MGL_EXPORT mgl_parse_textw(HMGL gr, HMPR p, const wchar_t *str); + +/// Restore once flag +void MGL_EXPORT mgl_parser_restore_once(HMPR p); +void MGL_EXPORT mgl_parser_restore_once_(uintptr_t* p); +/// Allow changing size of the picture +void MGL_EXPORT mgl_parser_allow_setsize(HMPR p, int a); +void MGL_EXPORT mgl_parser_allow_setsize_(uintptr_t* p, int *a); +/// Allow reading/saving files +void MGL_EXPORT mgl_parser_allow_file_io(HMPR p, int a); +void MGL_EXPORT mgl_parser_allow_file_io_(uintptr_t* p, int *a); +/// Set flag to stop script parsing +void MGL_EXPORT mgl_parser_stop(HMPR p); +void MGL_EXPORT mgl_parser_stop_(uintptr_t* p); + +/// Return type of command: 0 - not found, 1 - data plot, 2 - other plot, +/// 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program +/// 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot +/// 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform +int MGL_EXPORT mgl_parser_cmd_type(HMPR pr, const char *name); +int MGL_EXPORT mgl_parser_cmd_type_(uintptr_t* p, const char *name, int); +/// Return description of MGL command +MGL_EXPORT const char *mgl_parser_cmd_desc(HMPR pr, const char *name); +/// Return string of command format (command name and its argument[s]) +MGL_EXPORT const char *mgl_parser_cmd_frmt(HMPR pr, const char *name); +/// Get name of command with nmber n +MGL_EXPORT const char *mgl_parser_cmd_name(HMPR pr, long id); +/// Get number of defined commands +long MGL_EXPORT mgl_parser_cmd_num(HMPR pr); + +/// Return result of formula evaluation +HMDT MGL_EXPORT mgl_parser_calc(HMPR pr, const char *formula); +uintptr_t MGL_EXPORT mgl_parser_calc_(uintptr_t *pr, const char *formula,int); +HMDT MGL_EXPORT mgl_parser_calcw(HMPR pr, const wchar_t *formula); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/canvas_wnd.h b/include/mgl2/canvas_wnd.h new file mode 100644 index 0000000..6000a35 --- /dev/null +++ b/include/mgl2/canvas_wnd.h @@ -0,0 +1,79 @@ +/*************************************************************************** + * window.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_CANVAS_WND_H_ +#define _MGL_CANVAS_WND_H_ + +#include "mgl2/canvas.h" +#include "mgl2/wnd.h" +//----------------------------------------------------------------------------- +/// Base class for windows containing MathGL graphics +class MGL_EXPORT mglCanvasWnd : public mglCanvas +{ +public: + mglPoint LastMousePos; ///< Last mouse position + void (*ClickFunc)(void *par); ///< Callback function on click + + mglCanvasWnd(); + virtual ~mglCanvasWnd(); + + void SetSize(int w,int h); + void EndFrame(); + void SetFrame(long i); + void DelFrame(long i); + const unsigned char *GetBits(); + inline int GetNumFig() const { return NumFig; } + inline int GetCurFig() const { return CurFig; } + void SetCurFig(int c); + void ResetFrames(); + inline mglPoint GetMousePos() const { return LastMousePos;} + inline void SetMousePos(mglPoint p) { LastMousePos=p; } + inline void Setup(bool clf_upd=true, bool showpos=false) + { set(showpos,MGL_SHOW_POS); set(clf_upd,MGL_CLF_ON_UPD); } + + virtual void ToggleAlpha()=0; ///< Switch on/off transparency (do not overwrite user settings) + virtual void ToggleLight()=0; ///< Switch on/off lighting (do not overwrite user settings) + virtual void ToggleZoom()=0; ///< Switch on/off zooming by mouse + virtual void ToggleRotate()=0; ///< Switch on/off rotation by mouse + virtual void ToggleNo()=0; ///< Switch off all zooming and rotation + virtual void Update()=0; ///< Update picture by calling user drawing function + virtual void Adjust()=0; ///< Adjust size of bitmap to window size + virtual void GotoFrame(int d)=0;///< Show arbitrary frame (use relative step) + virtual void NextFrame() {GotoFrame(+1);} ///< Show next frame (if one) + virtual void PrevFrame() {GotoFrame(-1);} ///< Show previous frame (if one) + virtual void Animation()=0; ///< Run slideshow (animation) of frames + void ReLoad(); ///< Reload user data and update picture + /// Create a window for plotting based on callback function (can be NULL). + virtual void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), + const char *title, void *par=NULL, + void (*reload)(void *p)=NULL, bool maximize=false)=0; + void SetDrawFunc(int (*draw)(mglBase *gr, void *p), void *par=NULL, void (*reload)(void *p)=NULL); + +private: + int CurFig; ///< Current figure in the list. + + unsigned char *GG; ///< images for all frames (may be too LARGE !!!) + int NumFig; ///< Number of figures in the list. If 0 then no list and mglCanvas::DrawFunc will called for each drawing. + void (*LoadFunc)(void *par); + void *FuncPar; ///< Parameters for drawing function mglCanvas::DrawFunc. + /// Drawing function for window procedure. It should return the number of frames. + int (*DrawFunc)(mglBase *gr, void *par); +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/cont.h b/include/mgl2/cont.h new file mode 100644 index 0000000..7028840 --- /dev/null +++ b/include/mgl2/cont.h @@ -0,0 +1,160 @@ +/*************************************************************************** + * cont.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_CONT_H_ +#define _MGL_CONT_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Print text along the curve in parametric form {x,y,z} +void MGL_EXPORT mgl_text_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *text, const char *font, const char *opt); +void MGL_EXPORT mgl_text_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z,const char *text,const char *font, const char *opt,int,int l,int n); +void MGL_EXPORT mgl_textw_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const wchar_t *text, const char *font, const char *opt); +/// Print text along the curve in parametric form {x,y} +void MGL_EXPORT mgl_text_xy(HMGL gr, HCDT x, HCDT y, const char *text, const char *font, const char *opt); +void MGL_EXPORT mgl_text_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *text, const char *font, const char *opt,int, int l,int n); +void MGL_EXPORT mgl_textw_xy(HMGL gr, HCDT x, HCDT y, const wchar_t *text, const char *font, const char *opt); +/// Print text along the curve +void MGL_EXPORT mgl_text_y(HMGL gr, HCDT y, const char *text, const char *font, const char *opt); +void MGL_EXPORT mgl_text_y_(uintptr_t *gr, uintptr_t *y, const char *text, const char *font, const char *opt,int, int l,int n); +void MGL_EXPORT mgl_textw_y(HMGL gr, HCDT y, const wchar_t *text, const char *font, const char *opt); + +void MGL_EXPORT mgl_cont_gen(HMGL gr, double val, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl); +void MGL_EXPORT mgl_contf_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl); +//void MGL_EXPORT mgl_contv_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl); +//void MGL_EXPORT mgl_axial_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl); + +/// Draw manual contour lines for 2d data specified parametrically +void MGL_EXPORT mgl_cont_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_cont_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw manual contour lines for 2d data +void MGL_EXPORT mgl_cont_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_cont_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw contour lines for 2d data specified parametrically +void MGL_EXPORT mgl_cont_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_cont_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw contour lines for 2d data +void MGL_EXPORT mgl_cont(HMGL gr, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_cont_(uintptr_t *gr, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw manual solid contours for 2d data specified parametrically +void MGL_EXPORT mgl_contf_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contf_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw manual solid contours for 2d data +void MGL_EXPORT mgl_contf_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contf_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw solid contours for 2d data specified parametrically +void MGL_EXPORT mgl_contf_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contf_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw solid contours for 2d data +void MGL_EXPORT mgl_contf(HMGL gr, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contf_(uintptr_t *gr, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw manual solid contours for 2d data specified parametrically with manual colors +void MGL_EXPORT mgl_contd_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contd_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw manual solid contours for 2d data with manual colors +void MGL_EXPORT mgl_contd_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contd_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw solid contours for 2d data specified parametrically with manual colors +void MGL_EXPORT mgl_contd_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contd_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw solid contours for 2d data with manual colors +void MGL_EXPORT mgl_contd(HMGL gr, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contd_(uintptr_t *gr, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw manual contour tubes for 2d data specified parametrically +void MGL_EXPORT mgl_contv_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contv_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw manual contour tubes for 2d data +void MGL_EXPORT mgl_contv_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contv_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw contour tubes for 2d data specified parametrically +void MGL_EXPORT mgl_contv_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contv_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw contour tubes for 2d data +void MGL_EXPORT mgl_contv(HMGL gr, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_contv_(uintptr_t *gr, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw manual axial-symmetric isosurfaces for 2d data specified parametrically +void MGL_EXPORT mgl_axial_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_axial_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw manual axial-symmetric isosurfaces for 2d data +void MGL_EXPORT mgl_axial_val(HMGL gr, HCDT v, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_axial_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw axial-symmetric isosurfaces for 2d data specified parametrically +void MGL_EXPORT mgl_axial_xy(HMGL gr, HCDT x, HCDT y, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_axial_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw axial-symmetric isosurfaces for 2d data +void MGL_EXPORT mgl_axial(HMGL gr, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_axial_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int,int); + +/// Draw surface of curve {r,z} rotatation around axis +void MGL_EXPORT mgl_torus(HMGL gr, HCDT r, HCDT z, const char *col, const char *opt); +void MGL_EXPORT mgl_torus_(uintptr_t *gr, uintptr_t *r, uintptr_t *z, const char *pen, const char *opt,int,int); + +/// Draw grid lines for density plot at slice for 3d data specified parametrically +void MGL_EXPORT mgl_grid3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_grid3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw grid lines for density plot at slice for 3d data +void MGL_EXPORT mgl_grid3(HMGL gr, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_grid3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); + +/// Draw density plot at slice for 3d data specified parametrically +void MGL_EXPORT mgl_dens3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_dens3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw density plot at slice for 3d data +void MGL_EXPORT mgl_dens3(HMGL gr, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_dens3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); + +/// Draw manual contour lines at slice for 3d data specified parametrically +void MGL_EXPORT mgl_cont3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_cont3_xyz_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw manual contour lines at slice for 3d data +void MGL_EXPORT mgl_cont3_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_cont3_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw contour lines at slice for 3d data specified parametrically +void MGL_EXPORT mgl_cont3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_cont3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw contour lines at slice for 3d data +void MGL_EXPORT mgl_cont3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_cont3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); + +/// Draw manual solid contours at slice for 3d data specified parametrically +void MGL_EXPORT mgl_contf3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_contf3_xyz_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw manual solid contours at slice for 3d data +void MGL_EXPORT mgl_contf3_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_contf3_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw solid contours at slice for 3d data specified parametrically +void MGL_EXPORT mgl_contf3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_contf3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw solid contours at slice for 3d data +void MGL_EXPORT mgl_contf3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_contf3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int,int); + +//----------------------------------------------------------------------------- +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/data.h b/include/mgl2/data.h new file mode 100644 index 0000000..81aec44 --- /dev/null +++ b/include/mgl2/data.h @@ -0,0 +1,624 @@ +/*************************************************************************** + * data.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_DATA_H_ +#define _MGL_DATA_H_ + +#include "mgl2/data_cf.h" +#include "mgl2/pde.h" +#ifdef __cplusplus +//----------------------------------------------------------------------------- +#include +#include +//----------------------------------------------------------------------------- +/// Class for working with data array +#if MGL_NO_DATA_A +class MGL_EXPORT mglData +#else +class MGL_EXPORT mglData : public mglDataA +#endif +{ +public: + + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + mreal *a; ///< data array + std::string id; ///< column (or slice) names + bool link; ///< use external data (i.e. don't free it) + + /// Initiate by other mglData variable + inline mglData(const mglData &d) { a=0; mgl_data_set(this,&d); } // NOTE: must be constructor for mglData& to exclude copy one + inline mglData(const mglDataA *d) { a=0; mgl_data_set(this, d); } + inline mglData(bool, mglData *d) // NOTE: Variable d will be deleted!!! + { if(d) + { nx=d->nx; ny=d->ny; nz=d->nz; a=d->a; d->a=0; + id=d->id; link=d->link; delete d; } + else { a=0; Create(1); } } + /// Initiate by flat array + inline mglData(int size, const float *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const float *d) { a=0; Set(d,cols,rows); } + inline mglData(int size, const double *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const double *d) { a=0; Set(d,cols,rows); } + inline mglData(const double *d, int size) { a=0; Set(d,size); } + inline mglData(const double *d, int rows, int cols) { a=0; Set(d,cols,rows); } + /// Read data from file + inline mglData(const char *fname) { a=0; Read(fname); } + /// Allocate the memory for data array and initialize it zero + inline mglData(long xx=1,long yy=1,long zz=1) { a=0; Create(xx,yy,zz); } + /// Delete the array + virtual ~mglData() { if(!link && a) delete []a; } + inline mreal GetVal(long i, long j=0, long k=0) + { return mgl_data_get_value(this,i,j,k);} + inline void SetVal(mreal f, long i, long j=0, long k=0) + { mgl_data_set_value(this,f,i,j,k); } + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + + /// Link external data array (don't delete it at exit) + inline void Link(mreal *A, long NX, long NY=1, long NZ=1) + { mgl_data_link(this,A,NX,NY,NZ); } + inline void Link(mglData &d) { Link(d.a,d.nx,d.ny,d.nz); } + /// Allocate memory and copy the data from the gsl_vector + inline void Set(gsl_vector *m) { mgl_data_set_vector(this,m); } + /// Allocate memory and copy the data from the gsl_matrix + inline void Set(gsl_matrix *m) { mgl_data_set_matrix(this,m); } + + /// Allocate memory and copy the data from the (float *) array + inline void Set(const float *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_float(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (double *) array + inline void Set(const double *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_double(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (float **) array + inline void Set(float const * const *A,long N1,long N2) + { mgl_data_set_float2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (double **) array + inline void Set(double const * const *A,long N1,long N2) + { mgl_data_set_double2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (float ***) array + inline void Set(float const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_float3(this,A,N1,N2,N3); } + /// Allocate memory and copy the data from the (double ***) array + inline void Set(double const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_double3(this,A,N1,N2,N3); } + /// Allocate memory and scanf the data from the string + inline void Set(const char *str,long NX,long NY=1,long NZ=1) + { mgl_data_set_values(this,str,NX,NY,NZ); } + /// Import data from abstract type + inline void Set(HCDT dat) { mgl_data_set(this, dat); } + inline void Set(const mglDataA &dat) { mgl_data_set(this, &dat); } + /// Allocate memory and copy data from std::vector + inline void Set(const std::vector &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + /// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Linear(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear_ext(this,x,y,z, &(dif.x),&(dif.y), &(dif.z)); } + /// Interpolate by line the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { mreal res=mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + + /// Get information about the data (sizes and momentum) to string + inline const char *PrintInfo() const { return mgl_data_info(this); } + /// Print information about the data (sizes and momentum) to FILE (for example, stdout) + inline void PrintInfo(FILE *fp) const + { if(fp) { fprintf(fp,"%s",mgl_data_info(this)); fflush(fp); } } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + /// Get maximal value of the data which is less than 0 + inline mreal MaximalNeg() const { return mgl_data_neg_max(this); } + /// Get minimal value of the data which is larger than 0 + inline mreal MinimalPos() const { return mgl_data_pos_min(this); } + /// Get maximal value of the data and its position + inline mreal Maximal(long &i,long &j,long &k) const + { return mgl_data_max_int(this,&i,&j,&k); } + /// Get minimal value of the data and its position + inline mreal Minimal(long &i,long &j,long &k) const + { return mgl_data_min_int(this,&i,&j,&k); } + /// Get maximal value of the data and its approximated position + inline mreal Maximal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_max_real(this,&x,&y,&z); } + /// Get minimal value of the data and its approximated position + inline mreal Minimal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_min_real(this,&x,&y,&z); } + /// Get "energy" and find first (median) and second (width) momenta of data + inline mreal Momentum(char dir,mreal &m,mreal &w) const + { return mgl_data_momentum_val(this,dir,&m,&w,0,0); } + /// Get "energy and find 4 momenta of data: median, width, skewness, kurtosis + inline mreal Momentum(char dir,mreal &m,mreal &w,mreal &s,mreal &k) const + { return mgl_data_momentum_val(this,dir,&m,&w,&s,&k); } + /// Find position (after specified in i,j,k) of first nonzero value of formula + inline mreal Find(const char *cond, long &i, long &j, long &k) const + { return mgl_data_first(this,cond,&i,&j,&k); } + /// Find position (before specified in i,j,k) of last nonzero value of formula + inline mreal Last(const char *cond, long &i, long &j, long &k) const + { return mgl_data_last(this,cond,&i,&j,&k); } + /// Find position of first in direction 'dir' nonzero value of formula + inline long Find(const char *cond, char dir, long i=0, long j=0, long k=0) const + { return mgl_data_find(this,cond,dir,i,j,k); } + /// Find if any nonzero value of formula + inline bool FindAny(const char *cond) const + { return mgl_data_find_any(this,cond); } + + /// Copy data from other mglData variable + inline mglData &operator=(const mglData &d) + { if(this!=&d) Set(d.a,d.nx,d.ny,d.nz); return *this; } + inline mreal operator=(mreal val) + { for(long i=0;i=nx || j>=ny || k>=nz) printf("Wrong index in mglData"); + return a[i+nx*(j+ny*k)]; } +#endif + inline mreal vthr(long i) const { return a[i]; } + // add for speeding up !!! + inline mreal dvx(long i,long j=0,long k=0) const + { register long i0=i+nx*(j+ny*k); + return i>0? (i0? (j0? (k(const mglDataA &b, const mglDataA &d) +{ return b.Minimal()>d.Minimal(); } +#endif +//----------------------------------------------------------------------------- +#ifndef SWIG +mreal mglLinear(const mreal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z); +mreal mglSpline3(const mreal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z,mreal *dx=0, mreal *dy=0, mreal *dz=0); +#endif +//----------------------------------------------------------------------------- +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for amplitude and phase +inline mglData mglTransformA(const mglDataA &am, const mglDataA &ph, const char *tr) +{ return mglData(true,mgl_transform_a(&am,&ph,tr)); } +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for real and imaginary parts +inline mglData mglTransform(const mglDataA &re, const mglDataA &im, const char *tr) +{ return mglData(true,mgl_transform(&re,&im,tr)); } +/// Apply Fourier transform for the data and save result into it +inline void mglFourier(mglData &re, mglData &im, const char *dir) +{ mgl_data_fourier(&re,&im,dir); } +/// Short time Fourier analysis for real and imaginary parts. Output is amplitude of partial Fourier (result will have size {dn, floor(nx/dn), ny} for dir='x' +inline mglData mglSTFA(const mglDataA &re, const mglDataA &im, long dn, char dir='x') +{ return mglData(true, mgl_data_stfa(&re,&im,dn,dir)); } +//----------------------------------------------------------------------------- +/// Saves result of PDE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini +inline mglData mglPDE(mglBase *gr, const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100,const char *opt="") +{ return mglData(true, mgl_pde_solve(gr,ham, &ini_re, &ini_im, dz, k0,opt)); } +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO2d(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0)); } +inline mglData mglQO2d(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy)); } +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO3d(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0, 0)); } +inline mglData mglQO3d(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz)); } +/// Finds ray with starting point r0, p0 (and prepares ray data for mglQO2d) +inline mglData mglRay(const char *ham, mglPoint r0, mglPoint p0, mreal dt=0.1, mreal tmax=10) +{ return mglData(true, mgl_ray_trace(ham, r0.x, r0.y, r0.z, p0.x, p0.y, p0.z, dt, tmax)); } +/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du +inline mglData mglJacobian(const mglDataA &x, const mglDataA &y) +{ return mglData(true, mgl_jacobian_2d(&x, &y)); } +/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} +inline mglData mglJacobian(const mglDataA &x, const mglDataA &y, const mglDataA &z) +{ return mglData(true, mgl_jacobian_3d(&x, &y, &z)); } +/// Do something like Delone triangulation +inline mglData mglTriangulation(const mglDataA &x, const mglDataA &y, const mglDataA &z) +{ return mglData(true,mgl_triangulation_3d(&x,&y,&z)); } +inline mglData mglTriangulation(const mglDataA &x, const mglDataA &y) +{ return mglData(true,mgl_triangulation_2d(&x,&y)); } +//----------------------------------------------------------------------------- +/// Wrapper class expression evaluating +class MGL_EXPORT mglExpr +{ + HMEX ex; +public: + mglExpr(const char *expr) { ex = mgl_create_expr(expr); } + ~mglExpr() { mgl_delete_expr(ex); } + /// Return value of expression for given x,y,z variables + inline double Eval(double x, double y=0, double z=0) + { return mgl_expr_eval(ex,x,y,z); } + /// Return value of expression differentiation over variable dir for given x,y,z variables + inline double Diff(char dir, double x, double y=0, double z=0) + { return mgl_expr_diff(ex,dir, x,y,z); } +#ifndef SWIG + /// Return value of expression for given variables + inline double Eval(mreal var[26]) + { return mgl_expr_eval_v(ex,var); } + /// Return value of expression differentiation over variable dir for given variables + inline double Diff(char dir, mreal var[26]) + { return mgl_expr_diff_v(ex,dir, var); } +#endif +}; +//----------------------------------------------------------------------------- +#ifndef SWIG +/// Structure for handling named mglData (used by mglParse class). +class MGL_EXPORT mglVar : public mglData +{ +public: + std::wstring s; ///< Data name + void *o; ///< Pointer to external object + mglVar *next; ///< Pointer to next instance in list + mglVar *prev; ///< Pointer to previous instance in list + bool temp; ///< This is temporary variable + void (*func)(void *); ///< Callback function for destroying + + mglVar(std::wstring name=L""):mglData() + { o=0; next=prev=0; func=0; temp=false; s=name; } + mglVar(mglVar **head, std::wstring name=L""):mglData() + { o=0; next=*head; prev=0; *head=this; func=0; temp=false; s=name; } + mglVar(mglVar **head, const mglData &dat, std::wstring name):mglData(dat) + { o=0; next=*head; prev=0; *head=this; func=0; temp=false; s=name; } + mglVar(mglVar **head, HCDT dat, std::wstring name):mglData(dat) + { o=0; next=*head; prev=0; *head=this; func=0; temp=false; s=name; } + mglVar(mglVar *v, std::wstring name, bool link=true):mglData() // NOTE: use carefully due to Link()! + { if(!v) throw mglWarnZero; + if(link) Link(*v); else Set(*v); + o=0; temp=false; s=name; func = v->func; + prev = v; next = v->next; v->next = this; + if(next) next->prev = this; } + virtual ~mglVar() + { + if(func) func(o); + if(prev) prev->next = next; + if(next) next->prev = prev; + } + /// Make copy which link on the same data but have different name. NOTE: use carefully due to Link()! + inline void Duplicate(std::wstring name) + { mglVar *v=new mglVar(name); v->Link(*this); v->MoveAfter(this); } + /// Move variable after var and copy func from var (if func is 0) + inline void MoveAfter(mglVar *var) + { + if(prev) prev->next = next; + if(next) next->prev = prev; + prev = next = 0; + if(var) + { + prev = var; next = var->next; + var->next = this; + if(func==0) func = var->func; + } + if(next) next->prev = this; + } +}; +#endif +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/data_cf.h b/include/mgl2/data_cf.h new file mode 100644 index 0000000..224ef76 --- /dev/null +++ b/include/mgl2/data_cf.h @@ -0,0 +1,477 @@ +/*************************************************************************** + * data_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_DATA_CF_H_ +#define _MGL_DATA_CF_H_ +//----------------------------------------------------------------------------- +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +#include +#include +#else +#ifdef __cplusplus +struct gsl_vector; +struct gsl_matrix; +#else +typedef void gsl_vector; +typedef void gsl_matrix; +#endif +#endif +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Set seed for random numbers +void MGL_EXPORT mgl_srnd(long seed); +void MGL_EXPORT mgl_srnd_(int *seed); +/// Get random number +double MGL_EXPORT mgl_rnd(); +double MGL_EXPORT mgl_rnd_(); +/// Get integer power of x +double MGL_EXPORT mgl_ipow(double x,int n); +double MGL_EXPORT mgl_ipow_(mreal *x,int *n); +/// Get number of seconds since 1970 for given string +double MGL_EXPORT mgl_get_time(const char *time, const char *fmt); +double MGL_EXPORT mgl_get_time_(const char *time, const char *fmt,int,int); + +/// Create HMDT object +HMDT MGL_EXPORT mgl_create_data(); +uintptr_t MGL_EXPORT mgl_create_data_(); +/// Create HMDT object with specified sizes +HMDT MGL_EXPORT mgl_create_data_size(long nx, long ny, long nz); +uintptr_t MGL_EXPORT mgl_create_data_size_(int *nx, int *ny, int *nz); +/// Create HMDT object with data from file +HMDT MGL_EXPORT mgl_create_data_file(const char *fname); +uintptr_t MGL_EXPORT mgl_create_data_file_(const char *fname, int len); +/// Delete HMDT object +void MGL_EXPORT mgl_delete_data(HMDT dat); +void MGL_EXPORT mgl_delete_data_(uintptr_t *dat); +/// Get information about the data (sizes and momentum) to string +MGL_EXPORT const char *mgl_data_info(HCDT dat); + +/// Rearange data dimensions +void MGL_EXPORT mgl_data_rearrange(HMDT dat, long mx,long my,long mz); +void MGL_EXPORT mgl_data_rearrange_(uintptr_t *dat, int *mx, int *my, int *mz); +/// Link external data array (don't delete it at exit) +void MGL_EXPORT mgl_data_link(HMDT dat, mreal *A,long mx,long my,long mz); +void MGL_EXPORT mgl_data_link_(uintptr_t *d, mreal *A, int *nx,int *ny,int *nz); +/// Allocate memory and copy the data from the (float *) array +void MGL_EXPORT mgl_data_set_float(HMDT dat, const float *A,long mx,long my,long mz); +void MGL_EXPORT mgl_data_set_float_(uintptr_t *dat, const float *A,int *NX,int *NY,int *NZ); +void MGL_EXPORT mgl_data_set_float1_(uintptr_t *d, const float *A,int *N1); +/// Allocate memory and copy the data from the (double *) array +void MGL_EXPORT mgl_data_set_double(HMDT dat, const double *A,long mx,long my,long mz); +void MGL_EXPORT mgl_data_set_double_(uintptr_t *dat, const double *A,int *NX,int *NY,int *NZ); +void MGL_EXPORT mgl_data_set_double1_(uintptr_t *d, const double *A,int *N1); +/// Allocate memory and copy the data from the (float **) array +void MGL_EXPORT mgl_data_set_float2(HMDT d, float const * const *A,long N1,long N2); +void MGL_EXPORT mgl_data_set_float2_(uintptr_t *d, const float *A,int *N1,int *N2); +/// Allocate memory and copy the data from the (double **) array +void MGL_EXPORT mgl_data_set_double2(HMDT d, double const * const *A,long N1,long N2); +void MGL_EXPORT mgl_data_set_double2_(uintptr_t *d, const double *A,int *N1,int *N2); +/// Allocate memory and copy the data from the (float ***) array +void MGL_EXPORT mgl_data_set_float3(HMDT d, float const * const * const *A,long N1,long N2,long N3); +void MGL_EXPORT mgl_data_set_float3_(uintptr_t *d, const float *A,int *N1,int *N2,int *N3); +/// Allocate memory and copy the data from the (double ***) array +void MGL_EXPORT mgl_data_set_double3(HMDT d, double const * const * const *A,long N1,long N2,long N3); +void MGL_EXPORT mgl_data_set_double3_(uintptr_t *d, const double *A,int *N1,int *N2,int *N3); +/// Import data from abstract type +void MGL_EXPORT mgl_data_set(HMDT dat, HCDT a); +void MGL_EXPORT mgl_data_set_(uintptr_t *dat, uintptr_t *a); +/// Allocate memory and copy the data from the gsl_vector +void MGL_EXPORT mgl_data_set_vector(HMDT dat, gsl_vector *v); +/// Allocate memory and copy the data from the gsl_matrix +void MGL_EXPORT mgl_data_set_matrix(HMDT dat, gsl_matrix *m); +/// Set value of data element [i,j,k] +void MGL_EXPORT mgl_data_set_value(HMDT dat, mreal v, long i, long j, long k); +void MGL_EXPORT mgl_data_set_value_(uintptr_t *d, mreal *v, int *i, int *j, int *k); +/// Get value of data element [i,j,k] +mreal MGL_EXPORT mgl_data_get_value(HCDT dat, long i, long j, long k); +mreal MGL_EXPORT mgl_data_get_value_(uintptr_t *d, int *i, int *j, int *k); +/// Allocate memory and scanf the data from the string +void MGL_EXPORT mgl_data_set_values(HMDT dat, const char *val, long nx, long ny, long nz); +void MGL_EXPORT mgl_data_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l); + +/// Read data array from HDF file (parse HDF4 and HDF5 files) +int MGL_EXPORT mgl_data_read_hdf(HMDT d,const char *fname,const char *data); +int MGL_EXPORT mgl_data_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n); +/// Save data to HDF file +void MGL_EXPORT mgl_data_save_hdf(HCDT d,const char *fname,const char *data,int rewrite); +void MGL_EXPORT mgl_data_save_hdf_(uintptr_t *d, const char *fname, const char *data, int *rewrite,int l,int n); +/// Put HDF data names into buf as '\t' separated. +int MGL_EXPORT mgl_datas_hdf(const char *fname, char *buf, long size); +/// Read data from tab-separated text file with auto determining size +int MGL_EXPORT mgl_data_read(HMDT dat, const char *fname); +int MGL_EXPORT mgl_data_read_(uintptr_t *d, const char *fname,int l); +/// Read data from text file with size specified at beginning of the file +int MGL_EXPORT mgl_data_read_mat(HMDT dat, const char *fname, long dim); +int MGL_EXPORT mgl_data_read_mat_(uintptr_t *dat, const char *fname, int *dim, int); +/// Read data from text file with specifeid size +int MGL_EXPORT mgl_data_read_dim(HMDT dat, const char *fname,long mx,long my,long mz); +int MGL_EXPORT mgl_data_read_dim_(uintptr_t *dat, const char *fname,int *mx,int *my,int *mz,int); +/// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to +int MGL_EXPORT mgl_data_read_range(HMDT d, const char *templ, double n1, double n2, double step, int as_slice); +int MGL_EXPORT mgl_data_read_range_(uintptr_t *d, const char *fname, mreal *n1, mreal *n2, mreal *step, int *as_slice,int l); +/// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") +int MGL_EXPORT mgl_data_read_all(HMDT dat, const char *templ, int as_slice); +int MGL_EXPORT mgl_data_read_all_(uintptr_t *d, const char *fname, int *as_slice,int l); +/// Save whole data array (for ns=-1) or only ns-th slice to text file +void MGL_EXPORT mgl_data_save(HCDT dat, const char *fname,long ns); +void MGL_EXPORT mgl_data_save_(uintptr_t *dat, const char *fname,int *ns,int); +/// Export data array (for ns=-1) or only ns-th slice to PNG file according color scheme +void MGL_EXPORT mgl_data_export(HCDT dat, const char *fname, const char *scheme,mreal v1,mreal v2,long ns); +void MGL_EXPORT mgl_data_export_(uintptr_t *dat, const char *fname, const char *scheme,mreal *v1,mreal *v2,int *ns,int,int); +/// Import data array from PNG file according color scheme +void MGL_EXPORT mgl_data_import(HMDT dat, const char *fname, const char *scheme,mreal v1,mreal v2); +void MGL_EXPORT mgl_data_import_(uintptr_t *dat, const char *fname, const char *scheme,mreal *v1,mreal *v2,int,int); + +/// Create or recreate the array with specified size and fill it by zero +void MGL_EXPORT mgl_data_create(HMDT dat, long nx,long ny,long nz); +void MGL_EXPORT mgl_data_create_(uintptr_t *dat, int *nx,int *ny,int *nz); +/// Transpose dimensions of the data (generalization of Transpose) +void MGL_EXPORT mgl_data_transpose(HMDT dat, const char *dim); +void MGL_EXPORT mgl_data_transpose_(uintptr_t *dat, const char *dim,int); +/// Normalize the data to range [v1,v2] +void MGL_EXPORT mgl_data_norm(HMDT dat, mreal v1,mreal v2,long sym,long dim); +void MGL_EXPORT mgl_data_norm_(uintptr_t *dat, mreal *v1,mreal *v2,int *sym,int *dim); +/// Normalize the data to range [v1,v2] slice by slice +void MGL_EXPORT mgl_data_norm_slice(HMDT dat, mreal v1,mreal v2,char dir,long keep_en,long sym); +void MGL_EXPORT mgl_data_norm_slice_(uintptr_t *dat, mreal *v1,mreal *v2,char *dir,int *keep_en,int *sym,int l); +/// Get sub-array of the data with given fixed indexes +HMDT MGL_EXPORT mgl_data_subdata(HCDT dat, long xx,long yy,long zz); +uintptr_t MGL_EXPORT mgl_data_subdata_(uintptr_t *dat, int *xx,int *yy,int *zz); +/// Get sub-array of the data with given fixed indexes (like indirect access) +HMDT MGL_EXPORT mgl_data_subdata_ext(HCDT dat, HCDT xx, HCDT yy, HCDT zz); +uintptr_t MGL_EXPORT mgl_data_subdata_ext_(uintptr_t *dat, uintptr_t *xx,uintptr_t *yy,uintptr_t *zz); +/// Get column (or slice) of the data filled by formulas of named columns +HMDT MGL_EXPORT mgl_data_column(HCDT dat, const char *eq); +uintptr_t MGL_EXPORT mgl_data_column_(uintptr_t *dat, const char *eq,int l); +/// Set names for columns (slices) +void MGL_EXPORT mgl_data_set_id(HMDT d, const char *id); +void MGL_EXPORT mgl_data_set_id_(uintptr_t *dat, const char *id,int l); +/// Equidistantly fill the data to range [x1,x2] in direction dir +void MGL_EXPORT mgl_data_fill(HMDT dat, mreal x1,mreal x2,char dir); +void MGL_EXPORT mgl_data_fill_(uintptr_t *dat, mreal *x1,mreal *x2,const char *dir,int); +/// Modify the data by specified formula assuming x,y,z in range [r1,r2] +void MGL_EXPORT mgl_data_fill_eq(HMGL gr, HMDT dat, const char *eq, HCDT vdat, HCDT wdat,const char *opt); +void MGL_EXPORT mgl_data_fill_eq_(uintptr_t *gr, uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,const char *opt, int, int); +/// Fill dat by interpolated values of vdat parametrically depended on xdat for x in range [x1,x2] +void MGL_EXPORT mgl_data_refill_x(HMDT dat, HCDT xdat, HCDT vdat, mreal x1, mreal x2, long sl); +void MGL_EXPORT mgl_data_refill_x_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *vdat, mreal *x1, mreal *x2, long *sl); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat for x,y in range [x1,x2]*[y1,y2] +void MGL_EXPORT mgl_data_refill_xy(HMDT dat, HCDT xdat, HCDT ydat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, long sl); +void MGL_EXPORT mgl_data_refill_xy_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, long *sl); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [x1,x2]*[y1,y2]*[z1,z2] +void MGL_EXPORT mgl_data_refill_xyz(HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2); +void MGL_EXPORT mgl_data_refill_xyz_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2); +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range +void MGL_EXPORT mgl_data_refill_gr(HMGL gr, HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, long sl, const char *opt); +void MGL_EXPORT mgl_data_refill_gr_(uintptr_t *gr, uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, long *sl, const char *opt,int); +/// Set the data by triangulated surface values assuming x,y,z in range [r1,r2] +void MGL_EXPORT mgl_data_grid(HMGL gr, HMDT d, HCDT xdat, HCDT ydat, HCDT zdat,const char *opt); +void MGL_EXPORT mgl_data_grid_(uintptr_t *gr, uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, const char *opt,int); +/// Set the data by triangulated surface values assuming x,y,z in range [x1,x2]*[y1,y2] +void MGL_EXPORT mgl_data_grid_xy(HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, mreal x1, mreal x2, mreal y1, mreal y2); +void MGL_EXPORT mgl_data_grid_xy_(uintptr_t *dat, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2); +/// Put value to data element(s) +void MGL_EXPORT mgl_data_put_val(HMDT dat, mreal val, long i, long j, long k); +void MGL_EXPORT mgl_data_put_val_(uintptr_t *dat, mreal *val, int *i, int *j, int *k); +/// Put array to data element(s) +void MGL_EXPORT mgl_data_put_dat(HMDT dat, HCDT val, long i, long j, long k); +void MGL_EXPORT mgl_data_put_dat_(uintptr_t *dat, uintptr_t *val, int *i, int *j, int *k); +/// Modify the data by specified formula +void MGL_EXPORT mgl_data_modify(HMDT dat, const char *eq,long dim); +void MGL_EXPORT mgl_data_modify_(uintptr_t *dat, const char *eq,int *dim,int); +/// Modify the data by specified formula +void MGL_EXPORT mgl_data_modify_vw(HMDT dat, const char *eq,HCDT vdat,HCDT wdat); +void MGL_EXPORT mgl_data_modify_vw_(uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,int); +/// Reduce size of the data +void MGL_EXPORT mgl_data_squeeze(HMDT dat, long rx,long ry,long rz,long smooth); +void MGL_EXPORT mgl_data_squeeze_(uintptr_t *dat, int *rx,int *ry,int *rz,int *smooth); + +/// Get maximal value of the data +mreal MGL_EXPORT mgl_data_max(HCDT dat); +mreal MGL_EXPORT mgl_data_max_(uintptr_t *dat); +/// Get maximal value of the data which is less than 0 +mreal MGL_EXPORT mgl_data_neg_max(HCDT dat); +mreal MGL_EXPORT mgl_data_neg_max_(uintptr_t *dat); +/// Get minimal value of the data +mreal MGL_EXPORT mgl_data_min(HCDT dat); +mreal MGL_EXPORT mgl_data_min_(uintptr_t *dat); +/// Get minimal value of the data which is larger than 0 +mreal MGL_EXPORT mgl_data_pos_min(HCDT dat); +mreal MGL_EXPORT mgl_data_pos_min_(uintptr_t *dat); +/// Returns pointer to data element [i,j,k] +MGL_EXPORT mreal *mgl_data_value(HMDT dat, long i,long j,long k); +/// Returns pointer to internal data array +MGL_EXPORT mreal *mgl_data_data(HMDT dat); + +/// Gets the x-size of the data. +long MGL_EXPORT mgl_data_get_nx(HCDT d); +long MGL_EXPORT mgl_data_get_nx_(uintptr_t *d); +/// Gets the y-size of the data. +long MGL_EXPORT mgl_data_get_ny(HCDT d); +long MGL_EXPORT mgl_data_get_ny_(uintptr_t *d); +/// Gets the z-size of the data. +long MGL_EXPORT mgl_data_get_nz(HCDT d); +long MGL_EXPORT mgl_data_get_nz_(uintptr_t *d); + +/// Find position (after specified in i,j,k) of first nonzero value of formula +mreal MGL_EXPORT mgl_data_first(HCDT dat, const char *cond, long *i, long *j, long *k); +mreal MGL_EXPORT mgl_data_first_(uintptr_t *dat, const char *cond, int *i, int *j, int *k, int); +/// Find position (before specified in i,j,k) of last nonzero value of formula +mreal MGL_EXPORT mgl_data_last(HCDT dat, const char *cond, long *i, long *j, long *k); +mreal MGL_EXPORT mgl_data_last_(uintptr_t *dat, const char *cond, int *i, int *j, int *k, int); +/// Find position of first in direction 'dir' nonzero value of formula +long MGL_EXPORT mgl_data_find(HCDT dat, const char *cond, char dir, long i, long j, long k); +int MGL_EXPORT mgl_data_find_(uintptr_t *dat, const char *cond, char *dir, int *i, int *j, int *k, int,int); +/// Find if any nonzero value of formula +int MGL_EXPORT mgl_data_find_any(HCDT dat, const char *cond); +int MGL_EXPORT mgl_data_find_any_(uintptr_t *dat, const char *cond, int); +/// Get maximal value of the data and its position +mreal MGL_EXPORT mgl_data_max_int(HCDT dat, long *i, long *j, long *k); +mreal MGL_EXPORT mgl_data_max_int_(uintptr_t *dat, int *i, int *j, int *k); +/// Get maximal value of the data and its approximated position +mreal MGL_EXPORT mgl_data_max_real(HCDT dat, mreal *x, mreal *y, mreal *z); +mreal MGL_EXPORT mgl_data_max_real_(uintptr_t *dat, mreal *x, mreal *y, mreal *z); +/// Get minimal value of the data and its position +mreal MGL_EXPORT mgl_data_min_int(HCDT dat, long *i, long *j, long *k); +mreal MGL_EXPORT mgl_data_min_int_(uintptr_t *dat, int *i, int *j, int *k); +/// Get minimal value of the data and its approximated position +mreal MGL_EXPORT mgl_data_min_real(HCDT dat, mreal *x, mreal *y, mreal *z); +mreal MGL_EXPORT mgl_data_min_real_(uintptr_t *dat, mreal *x, mreal *y, mreal *z); +/// Get "energy and find 4 momenta of data: median, width, skewness, kurtosis +mreal MGL_EXPORT mgl_data_momentum_val(HCDT d, char dir, mreal *m, mreal *w, mreal *s, mreal *k); +mreal MGL_EXPORT mgl_data_momentum_val_(uintptr_t *dat, char *dir, mreal *m, mreal *w, mreal *s, mreal *k,int); + +/// Get the data which is direct multiplication (like, d[i,j] = this[i]*a[j] and so on) +HMDT MGL_EXPORT mgl_data_combine(HCDT dat1, HCDT dat2); +uintptr_t MGL_EXPORT mgl_data_combine_(uintptr_t *dat1, uintptr_t *dat2); +/// Extend data dimensions +void MGL_EXPORT mgl_data_extend(HMDT dat, long n1, long n2); +void MGL_EXPORT mgl_data_extend_(uintptr_t *dat, int *n1, int *n2); +/// Insert data rows/columns/slices +void MGL_EXPORT mgl_data_insert(HMDT dat, char dir, long at, long num); +void MGL_EXPORT mgl_data_insert_(uintptr_t *dat, const char *dir, int *at, int *num, int); +/// Delete data rows/columns/slices +void MGL_EXPORT mgl_data_delete(HMDT dat, char dir, long at, long num); +void MGL_EXPORT mgl_data_delete_(uintptr_t *dat, const char *dir, int *at, int *num, int); +/// Joind another data array +void MGL_EXPORT mgl_data_join(HMDT dat, HCDT d); +void MGL_EXPORT mgl_data_join_(uintptr_t *dat, uintptr_t *d); + +/// Smooth the data on specified direction or directions +void MGL_EXPORT mgl_data_smooth(HMDT d, const char *dirs, mreal delta); +void MGL_EXPORT mgl_data_smooth_(uintptr_t *dat, const char *dirs, mreal *delta,int); +/// Get array which is result of summation in given direction or directions +HMDT MGL_EXPORT mgl_data_sum(HCDT dat, const char *dir); +uintptr_t MGL_EXPORT mgl_data_sum_(uintptr_t *dat, const char *dir,int); +/// Get array which is result of maximal values in given direction or directions +HMDT MGL_EXPORT mgl_data_max_dir(HCDT dat, const char *dir); +uintptr_t MGL_EXPORT mgl_data_max_dir_(uintptr_t *dat, const char *dir,int); +/// Get array which is result of minimal values in given direction or directions +HMDT MGL_EXPORT mgl_data_min_dir(HCDT dat, const char *dir); +uintptr_t MGL_EXPORT mgl_data_min_dir_(uintptr_t *dat, const char *dir,int); +/// Cumulative summation the data in given direction or directions +void MGL_EXPORT mgl_data_cumsum(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_cumsum_(uintptr_t *dat, const char *dir,int); +/// Integrate (cumulative summation) the data in given direction or directions +void MGL_EXPORT mgl_data_integral(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_integral_(uintptr_t *dat, const char *dir,int); +/// Differentiate the data in given direction or directions +void MGL_EXPORT mgl_data_diff(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_diff_(uintptr_t *dat, const char *dir,int); +/// Differentiate the parametrically specified data along direction v1 with v2,v3=const (v3 can be NULL) +void MGL_EXPORT mgl_data_diff_par(HMDT dat, HCDT v1, HCDT v2, HCDT v3); +void MGL_EXPORT mgl_data_diff_par_(uintptr_t *dat, uintptr_t *v1, uintptr_t *v2, uintptr_t *v3); +/// Double-differentiate (like Laplace operator) the data in given direction +void MGL_EXPORT mgl_data_diff2(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_diff2_(uintptr_t *dat, const char *dir,int); +/// Swap left and right part of the data in given direction (useful for Fourier spectrum) +void MGL_EXPORT mgl_data_swap(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_swap_(uintptr_t *dat, const char *dir,int); +/// Roll data along direction dir by num slices +void MGL_EXPORT mgl_data_roll(HMDT dat, char dir, long num); +void MGL_EXPORT mgl_data_roll_(uintptr_t *dat, const char *dir, int *num, int); +/// Mirror the data in given direction (useful for Fourier spectrum) +void MGL_EXPORT mgl_data_mirror(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_mirror_(uintptr_t *dat, const char *dir,int); +/// Sort rows (or slices) by values of specified column +void MGL_EXPORT mgl_data_sort(HMDT dat, long idx, long idy); +void MGL_EXPORT mgl_data_sort_(uintptr_t *dat, int *idx, int *idy); + +/// Apply Hankel transform +void MGL_EXPORT mgl_data_hankel(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_hankel_(uintptr_t *dat, const char *dir,int); +/// Apply Sin-Fourier transform +void MGL_EXPORT mgl_data_sinfft(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_sinfft_(uintptr_t *dat, const char *dir,int); +/// Apply Cos-Fourier transform +void MGL_EXPORT mgl_data_cosfft(HMDT dat, const char *dir); +void MGL_EXPORT mgl_data_cosfft_(uintptr_t *dat, const char *dir,int); +/// Fill data by 'x'/'k' samples for Hankel ('h') or Fourier ('f') transform +void MGL_EXPORT mgl_data_fill_sample(HMDT dat, const char *how); +void MGL_EXPORT mgl_data_fill_sample_(uintptr_t *dat, const char *how,int); +/// Find correlation between 2 data arrays +HMDT MGL_EXPORT mgl_data_correl(HCDT dat1, HCDT dat2, const char *dir); +uintptr_t MGL_EXPORT mgl_data_correl_(uintptr_t *dat1, uintptr_t *dat2, const char *dir,int); + +/// Allocate and prepare data for Fourier transform by nthr threads +MGL_EXPORT void *mgl_fft_alloc(long n, void **space, long nthr); +MGL_EXPORT void *mgl_fft_alloc_thr(long n); +/// Free data for Fourier transform +void MGL_EXPORT mgl_fft_free(void *wt, void **ws, long nthr); +void MGL_EXPORT mgl_fft_free_thr(void *wt); +/// Make Fourier transform of data x of size n and step s between points +void MGL_EXPORT mgl_fft(double *x, long s, long n, const void *wt, void *ws, int inv); +/// Clear internal data for speeding up FFT and Hankel transforms +void MGL_EXPORT mgl_clear_fft(); + +/// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +mreal MGL_EXPORT mgl_data_spline(HCDT dat, mreal x,mreal y,mreal z); +mreal MGL_EXPORT mgl_data_spline_(uintptr_t *dat, mreal *x,mreal *y,mreal *z); +/// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +mreal MGL_EXPORT mgl_data_linear(HCDT dat, mreal x,mreal y,mreal z); +mreal MGL_EXPORT mgl_data_linear_(uintptr_t *dat, mreal *x,mreal *y,mreal *z); +/// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +mreal MGL_EXPORT mgl_data_spline_ext(HCDT dat, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz); +mreal MGL_EXPORT mgl_data_spline_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz); +/// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +mreal MGL_EXPORT mgl_data_linear_ext(HCDT dat, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz); +mreal MGL_EXPORT mgl_data_linear_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz); +/// Return an approximated x-value (root) when dat(x) = val +mreal MGL_EXPORT mgl_data_solve_1d(HCDT dat, mreal val, int spl, long i0); +mreal MGL_EXPORT mgl_data_solve_1d_(uintptr_t *dat, mreal *val, int *spl, int *i0); +/// Return an approximated value (root) when dat(x) = val +HMDT MGL_EXPORT mgl_data_solve(HCDT dat, mreal val, char dir, HCDT i0, int norm); +uintptr_t MGL_EXPORT mgl_data_solve_(uintptr_t *dat, mreal *val, const char *dir, uintptr_t *i0, int *norm,int); + +/// Get trace of the data array +HMDT MGL_EXPORT mgl_data_trace(HCDT d); +uintptr_t MGL_EXPORT mgl_data_trace_(uintptr_t *d); +/// Resize the data to new sizes +HMDT MGL_EXPORT mgl_data_resize(HCDT dat, long mx,long my,long mz); +uintptr_t MGL_EXPORT mgl_data_resize_(uintptr_t *dat, int *mx,int *my,int *mz); +/// Resize the data to new sizes of box [x1,x2]*[y1,y2]*[z1,z2] +HMDT MGL_EXPORT mgl_data_resize_box(HCDT dat, long mx,long my,long mz,mreal x1,mreal x2,mreal y1,mreal y2,mreal z1,mreal z2); +uintptr_t MGL_EXPORT mgl_data_resize_box_(uintptr_t *dat, int *mx,int *my,int *mz,mreal *x1,mreal *x2,mreal *y1,mreal *y2,mreal *z1,mreal *z2); +/// Create n-th points distribution of this data values in range [v1, v2] +HMDT MGL_EXPORT mgl_data_hist(HCDT dat, long n, mreal v1, mreal v2, long nsub); +uintptr_t MGL_EXPORT mgl_data_momentum_(uintptr_t *dat, char *dir, const char *how, int,int); +/// Create n-th points distribution of this data values in range [v1, v2] with weight w +HMDT MGL_EXPORT mgl_data_hist_w(HCDT dat, HCDT weight, long n, mreal v1, mreal v2, long nsub); +uintptr_t MGL_EXPORT mgl_data_hist_(uintptr_t *dat, int *n, mreal *v1, mreal *v2, int *nsub); +/// Get momentum (1D-array) of data along direction 'dir'. String looks like "x1" for median in x-direction, "x2" for width in x-dir and so on. +HMDT MGL_EXPORT mgl_data_momentum(HCDT dat, char dir, const char *how); +uintptr_t MGL_EXPORT mgl_data_hist_w_(uintptr_t *dat, uintptr_t *weight, int *n, mreal *v1, mreal *v2, int *nsub); +/// Get array which values is result of interpolation this for coordinates from other arrays +HMDT MGL_EXPORT mgl_data_evaluate(HCDT dat, HCDT idat, HCDT jdat, HCDT kdat, int norm); +uintptr_t MGL_EXPORT mgl_data_evaluate_(uintptr_t *dat, uintptr_t *idat, uintptr_t *jdat, uintptr_t *kdat, int *norm); +/// Set as the data envelop +void MGL_EXPORT mgl_data_envelop(HMDT dat, char dir); +void MGL_EXPORT mgl_data_envelop_(uintptr_t *dat, const char *dir, int); +/// Remove phase jump +void MGL_EXPORT mgl_data_sew(HMDT dat, const char *dirs, mreal da); +void MGL_EXPORT mgl_data_sew_(uintptr_t *dat, const char *dirs, mreal *da, int); +/// Crop the data +void MGL_EXPORT mgl_data_crop(HMDT dat, long n1, long n2, char dir); +void MGL_EXPORT mgl_data_crop_(uintptr_t *dat, int *n1, int *n2, const char *dir,int); +/// Remove rows with duplicate values in column id +void MGL_EXPORT mgl_data_clean(HMDT dat, long id); +void MGL_EXPORT mgl_data_clean_(uintptr_t *dat, int *id); + +/// Multiply the data by other one for each element +void MGL_EXPORT mgl_data_mul_dat(HMDT dat, HCDT d); +void MGL_EXPORT mgl_data_mul_dat_(uintptr_t *dat, uintptr_t *d); +/// Divide the data by other one for each element +void MGL_EXPORT mgl_data_div_dat(HMDT dat, HCDT d); +void MGL_EXPORT mgl_data_div_dat_(uintptr_t *dat, uintptr_t *d); +/// Add the other data +void MGL_EXPORT mgl_data_add_dat(HMDT dat, HCDT d); +void MGL_EXPORT mgl_data_add_dat_(uintptr_t *dat, uintptr_t *d); +/// Subtract the other data +void MGL_EXPORT mgl_data_sub_dat(HMDT dat, HCDT d); +void MGL_EXPORT mgl_data_sub_dat_(uintptr_t *dat, uintptr_t *d); +/// Multiply each element by the number +void MGL_EXPORT mgl_data_mul_num(HMDT dat, mreal d); +void MGL_EXPORT mgl_data_mul_num_(uintptr_t *dat, mreal *d); +/// Divide each element by the number +void MGL_EXPORT mgl_data_div_num(HMDT dat, mreal d); +void MGL_EXPORT mgl_data_div_num_(uintptr_t *dat, mreal *d); +/// Add the number +void MGL_EXPORT mgl_data_add_num(HMDT dat, mreal d); +void MGL_EXPORT mgl_data_add_num_(uintptr_t *dat, mreal *d); +/// Subtract the number +void MGL_EXPORT mgl_data_sub_num(HMDT dat, mreal d); +void MGL_EXPORT mgl_data_sub_num_(uintptr_t *dat, mreal *d); + +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for amplitude and phase +HMDT MGL_EXPORT mgl_transform_a(HCDT am, HCDT ph, const char *tr); +uintptr_t MGL_EXPORT mgl_transform_a_(uintptr_t *am, uintptr_t *ph, const char *tr, int); +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for real and imaginary parts +HMDT MGL_EXPORT mgl_transform(HCDT re, HCDT im, const char *tr); +uintptr_t MGL_EXPORT mgl_transform_(uintptr_t *re, uintptr_t *im, const char *tr, int); +/// Apply Fourier transform for the data and save result into it +void MGL_EXPORT mgl_data_fourier(HMDT re, HMDT im, const char *dir); +void MGL_EXPORT mgl_data_fourier_(uintptr_t *re, uintptr_t *im, const char *dir, int l); +/// Short time Fourier analysis for real and imaginary parts. Output is amplitude of partial Fourier (result will have size {dn, floor(nx/dn), ny} for dir='x' +HMDT MGL_EXPORT mgl_data_stfa(HCDT re, HCDT im, long dn, char dir); +uintptr_t MGL_EXPORT mgl_data_stfa_(uintptr_t *re, uintptr_t *im, int *dn, char *dir, int); + +/// Do something like Delone triangulation for 3d points +HMDT MGL_EXPORT mgl_triangulation_3d(HCDT x, HCDT y, HCDT z); +uintptr_t MGL_EXPORT mgl_triangulation_3d_(uintptr_t *x, uintptr_t *y, uintptr_t *z); +/// Do Delone triangulation for 2d points +HMDT MGL_EXPORT mgl_triangulation_2d(HCDT x, HCDT y); +uintptr_t MGL_EXPORT mgl_triangulation_2d_(uintptr_t *x, uintptr_t *y); + +/// Find root for nonlinear equation +mreal MGL_EXPORT mgl_find_root(mreal (*func)(mreal val, void *par), mreal ini, void *par); +/// Find root for nonlinear equation defined by textual formula +mreal MGL_EXPORT mgl_find_root_txt(const char *func, mreal ini, char var_id); +mreal MGL_EXPORT mgl_find_root_txt_(const char *func, mreal *ini, const char *var_id,int,int); +/// Find roots for nonlinear equation defined by textual formula +HMDT MGL_EXPORT mgl_data_roots(const char *func, HCDT ini, char var_id); +uintptr_t MGL_EXPORT mgl_data_roots_(const char *func, uintptr_t *ini, const char *var_id,int,int); + +//----------------------------------------------------------------------------- +/// Create HMEX object for expression evaluating +HMEX MGL_EXPORT mgl_create_expr(const char *expr); +uintptr_t MGL_EXPORT mgl_create_expr_(const char *expr, int); +/// Delete HMEX object +void MGL_EXPORT mgl_delete_expr(HMEX ex); +void MGL_EXPORT mgl_delete_expr_(uintptr_t *ex); +/// Return value of expression for given x,y,z variables +double MGL_EXPORT mgl_expr_eval(HMEX ex, double x, double y,double z); +double MGL_EXPORT mgl_expr_eval_(uintptr_t *ex, mreal *x, mreal *y, mreal *z); +/// Return value of expression for given variables +double MGL_EXPORT mgl_expr_eval_v(HMEX ex, mreal *vars); +/// Return value of expression differentiation over variable dir for given x,y,z variables +double MGL_EXPORT mgl_expr_diff(HMEX ex, char dir, double x, double y,double z); +double MGL_EXPORT mgl_expr_diff_(uintptr_t *ex, const char *dir, mreal *x, mreal *y, mreal *z, int); +/// Return value of expression differentiation over variable dir for given variables +double MGL_EXPORT mgl_expr_diff_v(HMEX ex, char dir, mreal *vars); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/datac.h b/include/mgl2/datac.h new file mode 100644 index 0000000..14218d9 --- /dev/null +++ b/include/mgl2/datac.h @@ -0,0 +1,439 @@ +/*************************************************************************** + * data.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_DATAC_H_ +#define _MGL_DATAC_H_ + +#include "mgl2/data.h" +#include "mgl2/datac_cf.h" +#ifdef __cplusplus +//----------------------------------------------------------------------------- +#include +#include +#define mgl2 mreal(2) +#define mgl3 mreal(3) +#define mgl4 mreal(4) +//----------------------------------------------------------------------------- +/// Class for working with data array +class MGL_EXPORT mglDataC : public mglDataA +{ +public: + + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + dual *a; ///< data array + std::string id; ///< column (or slice) names + bool link; ///< use external data (i.e. don't free it) + + /// Initiate by other mglData variable + inline mglDataC(const mglDataC &d) { a=0; mgl_datac_set(this,&d); } // NOTE: must be constructor for mglDataC& to exclude copy one + inline mglDataC(const mglDataA *d) { a=0; mgl_datac_set(this, d); } + inline mglDataC(bool, mglDataC *d) // NOTE: Variable d will be deleted!!! + { if(d) + { nx=d->nx; ny=d->ny; nz=d->nz; a=d->a; d->a=0; + id=d->id; link=d->link; delete d; } + else { a=0; Create(1); } } + /// Initiate by flat array + inline mglDataC(int size, const dual *d) { a=0; Set(d,size); } + inline mglDataC(int rows, int cols, const dual *d) { a=0; Set(d,cols,rows); } + inline mglDataC(int size, const double *d) { a=0; Set(d,size); } + inline mglDataC(int rows, int cols, const double *d) { a=0; Set(d,cols,rows); } + inline mglDataC(int size, const float *d) { a=0; Set(d,size); } + inline mglDataC(int rows, int cols, const float *d) { a=0; Set(d,cols,rows); } + /// Read data from file + inline mglDataC(const char *fname) { a=0; Read(fname); } + /// Allocate the memory for data array and initialize it zero + inline mglDataC(long xx=1,long yy=1,long zz=1) { a=0; Create(xx,yy,zz); } + /// Delete the array + virtual ~mglDataC() { if(!link && a) delete []a; } + inline dual GetVal(long i, long j=0, long k=0) + { return mgl_datac_get_value(this,i,j,k);} + inline void SetVal(dual f, long i, long j=0, long k=0) + { mgl_datac_set_value(this,f,i,j,k); } + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + + /// Link external data array (don't delete it at exit) + inline void Link(dual *A, long NX, long NY=1, long NZ=1) + { mgl_datac_link(this,A,NX,NY,NZ); } + inline void Link(mglDataC &d) { Link(d.a,d.nx,d.ny,d.nz); } + /// Allocate memory and copy the data from the gsl_vector + inline void Set(gsl_vector *m) { mgl_datac_set_vector(this,m); } + /// Allocate memory and copy the data from the gsl_matrix + inline void Set(gsl_matrix *m) { mgl_datac_set_matrix(this,m); } + + /// Allocate memory and copy the data from the (float *) array + inline void Set(const float *A,long NX,long NY=1,long NZ=1) + { mgl_datac_set_float(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (double *) array + inline void Set(const double *A,long NX,long NY=1,long NZ=1) + { mgl_datac_set_double(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (complex *) array + inline void Set(const dual *A,long NX,long NY=1,long NZ=1) + { mgl_datac_set_complex(this,A,NX,NY,NZ); } + /// Allocate memory and scanf the data from the string + inline void Set(const char *str,long NX,long NY=1,long NZ=1) + { mgl_datac_set_values(this,str,NX,NY,NZ); } + /// Import data from abstract type + inline void Set(HCDT dat) { mgl_datac_set(this, dat); } + inline void Set(const mglDataA &dat) { mgl_datac_set(this, &dat); } + inline void Set(const mglDataA &re, const mglDataA &im) { mgl_datac_set_ri(this, &re, &im); } + inline void Set(HCDT re, HCDT im) { mgl_datac_set_ri(this, re, im); } + inline void SetAmpl(const mglDataA &l, const mglDataA &phase) + { mgl_datac_set_ap(this, &l, &phase); } + /// Allocate memory and copy data from std::vector + inline void Set(const std::vector &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i &d) + { if(d.size()<1) return; + Create(d.size()); for(long i=0;i1?nx-1:1; dif.y/=ny>1?ny-1:1; dif.z/=nz>1?nz-1:1; + return val; + } + /// Return an approximated x-value (root) when dat(x) = val + inline mreal Solve(mreal val, bool use_spline=true, long i0=0) const + { return mgl_data_solve_1d(this, val, use_spline, i0); } + /// Return an approximated value (root) when dat(x) = val + inline mglData Solve(mreal val, char dir, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, 0, norm)); } + inline mglData Solve(mreal val, char dir, const mglData &i0, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, &i0, norm)); } + + /// Print information about the data (sizes and momentum) to string + inline const char *PrintInfo() const { return mgl_data_info(this); } + /// Print information about the data (sizes and momentum) to FILE (for example, stdout) + inline void PrintInfo(FILE *fp) const + { if(fp) { fprintf(fp,"%s",mgl_data_info(this)); fflush(fp); } } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + /// Get maximal value of the data and its position + inline mreal Maximal(long &i,long &j,long &k) const + { return mgl_data_max_int(this,&i,&j,&k); } + /// Get minimal value of the data and its position + inline mreal Minimal(long &i,long &j,long &k) const + { return mgl_data_min_int(this,&i,&j,&k); } + /// Get maximal value of the data and its approximated position + inline mreal Maximal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_max_real(this,&x,&y,&z); } + /// Get minimal value of the data and its approximated position + inline mreal Minimal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_min_real(this,&x,&y,&z); } + + /// Copy data from other mglData variable + inline mglDataC &operator=(const mglData &d) + { Set(&d); return *this; } + /// Copy data from other mglDataC variable + inline mglDataC &operator=(const mglDataC &d) + { if(this!=&d) Set(d.a,d.nx,d.ny,d.nz); return *this; } + inline dual operator=(dual val) + { for(long i=0;i=nx || j>=ny || k>=nz) printf("Wrong index in mglData"); + return abs(a[i+nx*(j+ny*k)]); } +#else + { return abs(a[i+nx*(j+ny*k)]); } +#endif + inline mreal vthr(long i) const { return abs(a[i]); } + // add for speeding up !!! + inline mreal dvx(long i,long j=0,long k=0) const + { register long i0=i+nx*(j+ny*k); + return i>0? abs(i0? abs(j0? abs(k=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglDataC mglQO2dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100) +{ return mglDataC(true, mgl_qo2d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0)); } +inline mglDataC mglQO2dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100) +{ return mglDataC(true, mgl_qo2d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy)); } +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglDataC mglQO3dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mreal r=1, mreal k0=100) +{ return mglDataC(true, mgl_qo3d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0, 0)); } +inline mglDataC mglQO3dc(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, const mglDataA &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100) +{ return mglDataC(true, mgl_qo3d_solve_c(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz)); } +//----------------------------------------------------------------------------- +#define _DN_(a) ((mglDataC *)*(a)) +#define _DC_ ((mglDataC *)*d) +//----------------------------------------------------------------------------- +#ifndef SWIG +/// Wrapper class expression evaluating +class MGL_EXPORT mglExprC +{ + HAEX ex; +public: + mglExprC(const char *expr) { ex = mgl_create_cexpr(expr); } + ~mglExprC() { mgl_delete_cexpr(ex); } + /// Return value of expression for given x,y,z variables + inline dual Eval(dual x, dual y=0, dual z=0) + { return mgl_cexpr_eval(ex,x,y,z); } + /// Return value of expression for given x,y,z,u,v,w variables + inline dual Eval(dual x, dual y, dual z, dual u, dual v, dual w) + { + dual var[26]; + var['x'-'a']=x; var['y'-'a']=y; var['z'-'a']=z; + var['u'-'a']=u; var['v'-'a']=v; var['w'-'a']=w; + return mgl_cexpr_eval_v(ex,var); } + /// Return value of expression for given variables + inline dual Eval(dual var[26]) + { return mgl_cexpr_eval_v(ex,var); } +}; +#endif +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/datac_cf.h b/include/mgl2/datac_cf.h new file mode 100644 index 0000000..b932e43 --- /dev/null +++ b/include/mgl2/datac_cf.h @@ -0,0 +1,259 @@ +/*************************************************************************** + * data_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_DATAC_CF_H_ +#define _MGL_DATAC_CF_H_ +//----------------------------------------------------------------------------- +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +#include +#include +#else +struct gsl_vector; +struct gsl_matrix; +#endif +//----------------------------------------------------------------------------- +#ifdef __cplusplus +class mglDataC; +typedef mglDataC* HADT; +extern "C" { +#else +typedef void *HADT; +#endif + +/// Set seed for random numbers +void MGL_EXPORT mgl_srnd(long seed); +/// Get random number +double MGL_EXPORT mgl_rnd(); +/// Get integer power of x +dual MGL_EXPORT mgl_ipowc(dual x,int n); +dual MGL_EXPORT mgl_ipowc_(dual *x,int *n); +/// Get exp(i*a) +dual MGL_EXPORT mgl_expi(dual a); + +/// Create HMDT object +HADT MGL_EXPORT mgl_create_datac(); +uintptr_t MGL_EXPORT mgl_create_datac_(); +/// Create HMDT object with specified sizes +HADT MGL_EXPORT mgl_create_datac_size(long nx, long ny, long nz); +uintptr_t MGL_EXPORT mgl_create_datac_size_(int *nx, int *ny, int *nz); +/// Create HMDT object with data from file +HADT MGL_EXPORT mgl_create_datac_file(const char *fname); +uintptr_t MGL_EXPORT mgl_create_datac_file_(const char *fname, int len); +/// Delete HMDT object +void MGL_EXPORT mgl_delete_datac(HADT dat); +void MGL_EXPORT mgl_delete_datac_(uintptr_t *dat); + +/// Rearange data dimensions +void MGL_EXPORT mgl_datac_rearrange(HADT dat, long mx,long my,long mz); +void MGL_EXPORT mgl_datac_rearrange_(uintptr_t *dat, int *mx, int *my, int *mz); +/// Link external data array (don't delete it at exit) +void MGL_EXPORT mgl_datac_link(HADT dat, dual *A,long mx,long my,long mz); +void MGL_EXPORT mgl_datac_link_(uintptr_t *d, dual *A, int *nx,int *ny,int *nz); +/// Allocate memory and copy the data from the (float *) array +void MGL_EXPORT mgl_datac_set_float(HADT dat, const float *A,long mx,long my,long mz); +void MGL_EXPORT mgl_datac_set_float_(uintptr_t *dat, const float *A,int *NX,int *NY,int *NZ); +/// Allocate memory and copy the data from the (double *) array +void MGL_EXPORT mgl_datac_set_double(HADT dat, const double *A,long mx,long my,long mz); +void MGL_EXPORT mgl_datac_set_double_(uintptr_t *dat, const double *A,int *NX,int *NY,int *NZ); +/// Allocate memory and copy the data from the (dual *) array +void MGL_EXPORT mgl_datac_set_complex(HADT dat, const dual *A,long mx,long my,long mz); +void MGL_EXPORT mgl_datac_set_complex_(uintptr_t *d, const dual *A,int *NX,int *NY,int *NZ); +/// Import data from abstract type +void MGL_EXPORT mgl_datac_set(HADT dat, HCDT a); +void MGL_EXPORT mgl_datac_set_(uintptr_t *dat, uintptr_t *a); +/// Allocate memory and copy the data from the gsl_vector +void MGL_EXPORT mgl_datac_set_vector(HADT dat, gsl_vector *v); +/// Allocate memory and copy the data from the gsl_matrix +void MGL_EXPORT mgl_datac_set_matrix(HADT dat, gsl_matrix *m); +/// Set value of data element [i,j,k] +void MGL_EXPORT mgl_datac_set_value(HADT dat, dual v, long i, long j, long k); +void MGL_EXPORT mgl_datac_set_value_(uintptr_t *d, dual *v, int *i, int *j, int *k); +/// Get value of data element [i,j,k] +dual MGL_EXPORT mgl_datac_get_value(HCDT dat, long i, long j, long k); +dual MGL_EXPORT mgl_datac_get_value_(uintptr_t *d, int *i, int *j, int *k); +/// Allocate memory and scanf the data from the string +void MGL_EXPORT mgl_datac_set_values(HADT dat, const char *val, long nx, long ny, long nz); +void MGL_EXPORT mgl_datac_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l); + +/// Returns pointer to internal data array +MGL_EXPORT dual *mgl_datac_data(HADT dat); +/// Returns pointer to data element [i,j,k] +MGL_EXPORT dual *mgl_datac_value(HADT dat, long i,long j,long k); + +/// Set the data from HCDT objects for real and imaginary parts +void MGL_EXPORT mgl_datac_set_ri(HADT dat, HCDT re, HCDT im); +void MGL_EXPORT mgl_datac_set_ri_(uintptr_t *dat, uintptr_t *re, uintptr_t *im); +/// Set the data from HCDT objects as amplitude and phase of complex data +void MGL_EXPORT mgl_datac_set_ap(HADT dat, HCDT abs, HCDT phi); +void MGL_EXPORT mgl_datac_set_ap_(uintptr_t *dat, uintptr_t *abs, uintptr_t *phi); + +/// Read data from tab-separated text file with auto determining size +int MGL_EXPORT mgl_datac_read(HADT dat, const char *fname); +int MGL_EXPORT mgl_datac_read_(uintptr_t *d, const char *fname,int l); +/// Read data from text file with size specified at beginning of the file +int MGL_EXPORT mgl_datac_read_mat(HADT dat, const char *fname, long dim); +int MGL_EXPORT mgl_datac_read_mat_(uintptr_t *dat, const char *fname, int *dim, int); +/// Read data from text file with specifeid size +int MGL_EXPORT mgl_datac_read_dim(HADT dat, const char *fname,long mx,long my,long mz); +int MGL_EXPORT mgl_datac_read_dim_(uintptr_t *dat, const char *fname,int *mx,int *my,int *mz,int); +/// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to +int MGL_EXPORT mgl_datac_read_range(HADT d, const char *templ, double from, double to, double step, int as_slice); +int MGL_EXPORT mgl_datac_read_range_(uintptr_t *d, const char *fname, mreal *from, mreal *to, mreal *step, int *as_slice,int l); +/// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") +int MGL_EXPORT mgl_datac_read_all(HADT dat, const char *templ, int as_slice); +int MGL_EXPORT mgl_datac_read_all_(uintptr_t *d, const char *fname, int *as_slice,int l); +/// Save whole data array (for ns=-1) or only ns-th slice to text file +void MGL_EXPORT mgl_datac_save(HCDT dat, const char *fname,long ns); +void MGL_EXPORT mgl_datac_save_(uintptr_t *dat, const char *fname,int *ns,int); + +/// Read data array from HDF file (parse HDF4 and HDF5 files) +int MGL_EXPORT mgl_datac_read_hdf(HADT d,const char *fname,const char *data); +int MGL_EXPORT mgl_datac_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n); +/// Save data to HDF file +void MGL_EXPORT mgl_datac_save_hdf(HCDT d,const char *fname,const char *data,int rewrite); +void MGL_EXPORT mgl_datac_save_hdf_(uintptr_t *d, const char *fname, const char *data, int *rewrite,int l,int n); + +/// Create or recreate the array with specified size and fill it by zero +void MGL_EXPORT mgl_datac_create(HADT dat, long nx,long ny,long nz); +void MGL_EXPORT mgl_datac_create_(uintptr_t *dat, int *nx,int *ny,int *nz); +/// Transpose dimensions of the data (generalization of Transpose) +void MGL_EXPORT mgl_datac_transpose(HADT dat, const char *dim); +void MGL_EXPORT mgl_datac_transpose_(uintptr_t *dat, const char *dim,int); +/// Set names for columns (slices) +void MGL_EXPORT mgl_datac_set_id(HADT d, const char *id); +void MGL_EXPORT mgl_datac_set_id_(uintptr_t *dat, const char *id,int l); +/// Equidistantly fill the data to range [x1,x2] in direction dir +void MGL_EXPORT mgl_datac_fill(HADT dat, dual x1,dual x2,char dir); +void MGL_EXPORT mgl_datac_fill_(uintptr_t *dat, dual *x1,dual *x2,const char *dir,int); +/// Modify the data by specified formula assuming x,y,z in range [r1,r2] +void MGL_EXPORT mgl_datac_fill_eq(HMGL gr, HADT dat, const char *eq, HCDT vdat, HCDT wdat,const char *opt); +void MGL_EXPORT mgl_datac_fill_eq_(uintptr_t *gr, uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,const char *opt, int, int); +/// Modify the data by specified formula +void MGL_EXPORT mgl_datac_modify(HADT dat, const char *eq,long dim); +void MGL_EXPORT mgl_datac_modify_(uintptr_t *dat, const char *eq,int *dim,int); +/// Modify the data by specified formula +void MGL_EXPORT mgl_datac_modify_vw(HADT dat, const char *eq,HCDT vdat,HCDT wdat); +void MGL_EXPORT mgl_datac_modify_vw_(uintptr_t *dat, const char *eq, uintptr_t *vdat, uintptr_t *wdat,int); + +/// Put value to data element(s) +void MGL_EXPORT mgl_datac_put_val(HADT dat, dual val, long i, long j, long k); +void MGL_EXPORT mgl_datac_put_val_(uintptr_t *dat, dual *val, int *i, int *j, int *k); +/// Put array to data element(s) +void MGL_EXPORT mgl_datac_put_dat(HADT dat, HCDT val, long i, long j, long k); +void MGL_EXPORT mgl_datac_put_dat_(uintptr_t *dat, uintptr_t *val, int *i, int *j, int *k); + +/// Reduce size of the data +void MGL_EXPORT mgl_datac_squeeze(HADT dat, long rx,long ry,long rz,long smooth); +void MGL_EXPORT mgl_datac_squeeze_(uintptr_t *dat, int *rx,int *ry,int *rz,int *smooth); +/// Extend data dimensions +void MGL_EXPORT mgl_datac_extend(HADT dat, long n1, long n2); +void MGL_EXPORT mgl_datac_extend_(uintptr_t *dat, int *n1, int *n2); +/// Insert data rows/columns/slices +void MGL_EXPORT mgl_datac_insert(HADT dat, char dir, long at, long num); +void MGL_EXPORT mgl_datac_insert_(uintptr_t *dat, const char *dir, int *at, int *num, int); +/// Delete data rows/columns/slices +void MGL_EXPORT mgl_datac_delete(HADT dat, char dir, long at, long num); +void MGL_EXPORT mgl_datac_delete_(uintptr_t *dat, const char *dir, int *at, int *num, int); +/// Joind another data array +void MGL_EXPORT mgl_datac_join(HADT dat, HCDT d); +void MGL_EXPORT mgl_datac_join_(uintptr_t *dat, uintptr_t *d); + +/// Smooth the data on specified direction or directions +void MGL_EXPORT mgl_datac_smooth(HADT d, const char *dirs, mreal delta); +void MGL_EXPORT mgl_datac_smooth_(uintptr_t *dat, const char *dirs, mreal *delta,int); +/// Cumulative summation the data in given direction or directions +void MGL_EXPORT mgl_datac_cumsum(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_cumsum_(uintptr_t *dat, const char *dir,int); +/// Integrate (cumulative summation) the data in given direction or directions +void MGL_EXPORT mgl_datac_integral(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_integral_(uintptr_t *dat, const char *dir,int); +/// Differentiate the data in given direction or directions +void MGL_EXPORT mgl_datac_diff(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_diff_(uintptr_t *dat, const char *dir,int); +/// Double-differentiate (like Laplace operator) the data in given direction +void MGL_EXPORT mgl_datac_diff2(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_diff2_(uintptr_t *dat, const char *dir,int); +/// Swap left and right part of the data in given direction (useful for Fourier spectrum) +void MGL_EXPORT mgl_datac_swap(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_swap_(uintptr_t *dat, const char *dir,int); +/// Roll data along direction dir by num slices +void MGL_EXPORT mgl_datac_roll(HADT dat, char dir, long num); +void MGL_EXPORT mgl_datac_roll_(uintptr_t *dat, const char *dir, int *num, int); +/// Mirror the data in given direction (useful for Fourier spectrum) +void MGL_EXPORT mgl_datac_mirror(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_mirror_(uintptr_t *dat, const char *dir,int); +/// Crop the data +void MGL_EXPORT mgl_datac_crop(HADT dat, long n1, long n2, char dir); +void MGL_EXPORT mgl_datac_crop_(uintptr_t *dat, int *n1, int *n2, const char *dir,int); + +/// Apply Hankel transform +void MGL_EXPORT mgl_datac_hankel(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_hankel_(uintptr_t *dat, const char *dir,int); +/// Apply Fourier transform +void MGL_EXPORT mgl_datac_fft(HADT dat, const char *dir); +void MGL_EXPORT mgl_datac_fft_(uintptr_t *dat, const char *dir,int); +/// Find correlation between 2 data arrays +HADT MGL_EXPORT mgl_datac_correl(HCDT dat1, HCDT dat2, const char *dir); +uintptr_t MGL_EXPORT mgl_datac_correl_(uintptr_t *dat1, uintptr_t *dat2, const char *dir,int); +/// Calculate one step of diffraction by finite-difference method with parameter q +void MGL_EXPORT mgl_datac_diffr(HADT dat, const char *how, mreal q); +void MGL_EXPORT mgl_datac_diffr_(uintptr_t *d, const char *how, double q,int l); + +HMDT MGL_EXPORT mgl_datac_real(HCDT dat); +uintptr_t MGL_EXPORT mgl_datac_real_(uintptr_t *dat); +HMDT MGL_EXPORT mgl_datac_imag(HCDT dat); +uintptr_t MGL_EXPORT mgl_datac_imag_(uintptr_t *dat); +HMDT MGL_EXPORT mgl_datac_abs(HCDT dat); +uintptr_t MGL_EXPORT mgl_datac_abs_(uintptr_t *dat); +HMDT MGL_EXPORT mgl_datac_arg(HCDT dat); +uintptr_t MGL_EXPORT mgl_datac_arg_(uintptr_t *dat); + +/// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +dual MGL_EXPORT mgl_datac_linear(HCDT d, mreal x,mreal y,mreal z); +dual MGL_EXPORT mgl_datac_linear_(uintptr_t *d, mreal *x,mreal *y,mreal *z); +/// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +dual MGL_EXPORT mgl_datac_linear_ext(HCDT d, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz); +dual MGL_EXPORT mgl_datac_linear_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz); +/// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +dual MGL_EXPORT mgl_datac_spline(HCDT dat, mreal x,mreal y,mreal z); +dual MGL_EXPORT mgl_datac_spline_(uintptr_t *dat, mreal *x,mreal *y,mreal *z); +/// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +dual MGL_EXPORT mgl_datac_spline_ext(HCDT dat, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz); +dual MGL_EXPORT mgl_datac_spline_ext_(uintptr_t *dat, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz); + +//----------------------------------------------------------------------------- +/// Create HAEX object for expression evaluating +HAEX MGL_EXPORT mgl_create_cexpr(const char *expr); +uintptr_t MGL_EXPORT mgl_create_cexpr_(const char *expr, int); +/// Delete HAEX object +void MGL_EXPORT mgl_delete_cexpr(HAEX ex); +void MGL_EXPORT mgl_delete_cexpr_(uintptr_t *ex); +/// Return value of expression for given x,y,z variables +dual MGL_EXPORT mgl_cexpr_eval(HAEX ex, dual x, dual y,dual z); +dual MGL_EXPORT mgl_cexpr_eval_(uintptr_t *ex, dual *x, dual *y, dual *z); +/// Return value of expression for given variables +dual MGL_EXPORT mgl_cexpr_eval_v(HAEX ex, dual *vars); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/define.h b/include/mgl2/define.h new file mode 100644 index 0000000..554490f --- /dev/null +++ b/include/mgl2/define.h @@ -0,0 +1,301 @@ +/*************************************************************************** + * define.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_DEFINE_H_ +#define _MGL_DEFINE_H_ +//----------------------------------------------------------------------------- +#include "mgl2/config.h" +#ifndef SWIG + +#include "mgl2/dllexport.h" +#ifdef MGL_SRC +#if MGL_HAVE_OMP +#include +#endif +#endif + +#endif + +#define MGL_VER2 2.2 // minor version of MathGL 2.* (like 1.3 for v.2.1.3) +//----------------------------------------------------------------------------- +#ifdef WIN32 //_MSC_VER needs this before math.h +#define _USE_MATH_DEFINES +#endif + +#ifdef MGL_SRC +#if MGL_HAVE_ZLIB +#include +#ifndef Z_BEST_COMPRESSION +#define Z_BEST_COMPRESSION 9 +#endif +#else +#define gzFile FILE* +#define gzread(fp,buf,size) fread(buf,1,size,fp) +#define gzopen fopen +#define gzclose fclose +#define gzprintf fprintf +#define gzgets(fp,str,size) fgets(str,size,fp) +#define gzgetc fgetc +#endif +#endif + +#if (defined(_MSC_VER) && (_MSC_VER<1600)) || defined(__BORLANDC__) +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int32_t; +typedef signed long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +typedef unsigned long long uint64_t; +#else +#include +#endif +#if defined(__BORLANDC__) +typedef unsigned long uintptr_t; +#endif + +#include +#include +#include +#include +#include + +#if defined(_MSC_VER) || defined(__BORLANDC__) +#define fmin(a,b) ((a)<(b))?(a):(b) +#define fmax(a,b) ((a)>(b))?(a):(b) +#endif + +#if defined(_MSC_VER) +#define collapse(a) // MSVS don't support OpenMP 3.* +#define strtoull _strtoui64 +#define hypot _hypot +#define getcwd _getcwd +#define chdir _chdir // BORLAND has chdir +#define snprintf _snprintf +#endif + +#if defined(_MSC_VER) || defined(__BORLANDC__) +#include +#include + +#ifdef WIN32 +const unsigned long long mgl_nan[2] = {0x7fffffffffffffff, 0x7fffffff}; +const unsigned long long mgl_inf[2] = {0x7ff0000000000000, 0x7f800000}; +#else +const unsigned long mgl_nan[2] = {0x7fffffffffffffff, 0x7fffffff}; +const unsigned long mgl_inf[2] = {0x7ff0000000000000, 0x7f800000}; +#endif + +#define NANd (*(double*)mgl_nan) +#define NANf (*(float*)(mgl_nan+1)) +#define INFd (*(double*)mgl_inf) +#define INFf (*(float*)(mgl_inf+1)) + +#if !defined(NAN) +#if MGL_USE_DOUBLE +#define NAN NANd +#else +#define NAN NANf +#endif +#endif + +#if !defined(INFINITY) +#if MGL_USE_DOUBLE +#define INFINITY INFd +#else +#define INFINITY INFf +#endif +#endif + +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 /* pi */ +#endif +//----------------------------------------------------------------------------- +#ifdef WIN32 +#define mglprintf _snwprintf +#else +#define mglprintf swprintf +#endif +//#define FLT_EPS 1.1920928955078125e-07 +//----------------------------------------------------------------------------- +#if MGL_USE_DOUBLE +typedef double mreal; +#define MGL_EPSILON (1.+1e-10) +#else +typedef float mreal; +#define MGL_EPSILON (1.+1e-5) +#endif +#define MGL_FEPSILON (1.+1e-5) +//----------------------------------------------------------------------------- +#ifndef MGL_CMAP_COLOR +#define MGL_CMAP_COLOR 32 +#endif +//----------------------------------------------------------------------------- +#ifndef MGL_DEF_VIEWER +#define MGL_DEF_VIEWER "evince" +#endif +//----------------------------------------------------------------------------- +#define mgl_min(a,b) (((a)>(b)) ? (b) : (a)) +#define mgl_max(a,b) (((a)>(b)) ? (a) : (b)) +#define mgl_isnan(a) ((a)!=(a)) +//#define mgl_isnum(a) ((a)==(a) && 2*(a)!=(a)) +#define mgl_isnum(a) ((a)==(a)) +#define mgl_isfin(a) ((a)-(a)==0.) +#define mgl_isbad(a) ((a)-(a)!=0.) +//----------------------------------------------------------------------------- +#define SMOOTH_NONE 0 +#define SMOOTH_LINE_3 1 +#define SMOOTH_LINE_5 2 +#define SMOOTH_QUAD_5 3 +//----------------------------------------------------------------------------- +#define MGL_HIST_IN 0 +#define MGL_HIST_SUM 1 +#define MGL_HIST_UP 2 +#define MGL_HIST_DOWN 3 +//----------------------------------------------------------------------------- +enum{ // types of predefined curvelinear coordinate systems + mglCartesian = 0, // no transformation + mglPolar, + mglSpherical, + mglParabolic, + mglParaboloidal, + mglOblate, + mglProlate, + mglElliptic, + mglToroidal, + mglBispherical, + mglBipolar, + mglLogLog, + mglLogX, + mglLogY +}; +//----------------------------------------------------------------------------- +// types of drawing +#define MGL_DRAW_WIRE 0 // fastest, no faces +#define MGL_DRAW_FAST 1 // fast, no color interpolation +#define MGL_DRAW_NORM 2 // high quality, slower +#define MGL_DRAW_LMEM 4 // low memory usage (direct to pixel) +#define MGL_DRAW_DOTS 8 // draw dots instead of primitives +#define MGL_DRAW_NONE 9 // no ouput (for testing only) +//----------------------------------------------------------------------------- +enum{ // Codes for warnings/messages + mglWarnNone = 0,// Everything OK + mglWarnDim, // Data dimension(s) is incompatible + mglWarnLow, // Data dimension(s) is too small + mglWarnNeg, // Minimal data value is negative + mglWarnFile, // No file or wrong data dimensions + mglWarnMem, // Not enough memory + mglWarnZero, // Data values are zero + mglWarnLeg, // No legend entries + mglWarnSlc, // Slice value is out of range + mglWarnCnt, // Number of contours is zero or negative + mglWarnOpen, // Couldn't open file + mglWarnLId, // Light: ID is out of range + mglWarnSize, // Setsize: size(s) is zero or negative + mglWarnFmt, // Format is not supported for that build + mglWarnTern, // Axis ranges are incompatible + mglWarnNull, // Pointer is NULL + mglWarnSpc, // Not enough space for plot + mglScrArg, // Wrong argument(s) in MGL script + mglScrCmd, // Wrong command in MGL script + mglScrLong, // Too long line in MGL script + mglScrStr, // Unbalanced ' in MGL script + mglWarnEnd // Maximal number of warnings (must be last) +}; +//----------------------------------------------------------------------------- +#define MGL_DEF_PAL "bgrcmyhlnqeupH" // default palette +#define MGL_DEF_SCH "BbcyrR" // default palette +#define MGL_COLORS "kwrgbcymhWRGBCYMHlenpquLENPQU" +//----------------------------------------------------------------------------- +#define MGL_TRANSP_NORM 0x000000 +#define MGL_TRANSP_GLASS 0x000001 +#define MGL_TRANSP_LAMP 0x000002 +#define MGL_ENABLE_CUT 0x000004 ///< Flag which determines how points outside bounding box are drown. +#define MGL_ENABLE_RTEXT 0x000008 ///< Use text rotation along axis +#define MGL_AUTO_FACTOR 0x000010 ///< Enable autochange PlotFactor +#define MGL_ENABLE_ALPHA 0x000020 ///< Flag that Alpha is used +#define MGL_ENABLE_LIGHT 0x000040 ///< Flag of using lightning +#define MGL_TICKS_ROTATE 0x000080 ///< Allow ticks rotation +#define MGL_TICKS_SKIP 0x000100 ///< Allow ticks rotation +// flags for internal use only +#define MGL_DISABLE_SCALE 0x000200 ///< Temporary flag for disable scaling (used for axis) +#define MGL_FINISHED 0x000400 ///< Flag that final picture (i.e. mglCanvas::G) is ready +#define MGL_USE_GMTIME 0x000800 ///< Use gmtime instead of localtime +#define MGL_SHOW_POS 0x001000 ///< Switch to show or not mouse click position +#define MGL_CLF_ON_UPD 0x002000 ///< Clear plot before Update() +#define MGL_NOSUBTICKS 0x004000 ///< Disable subticks drawing (for bounding box) +//#define MGL_DIFFUSIVE 0x008000 ///< Use diffusive light instead of specular +#define MGL_VECT_FRAME 0x010000 ///< Use DrwDat to remember all data of frames +#define MGL_REDUCEACC 0x020000 ///< Reduce accuracy of points (to reduc size of output files) +#define MGL_PREFERVC 0x040000 ///< Prefer vertex color instead of texture if output format supports +#define MGL_ONESIDED 0x080000 ///< Render only front side of surfaces if output format supports (for debugging) +#define MGL_NO_ORIGIN 0x100000 ///< Don't draw tick labels at axis origin +//----------------------------------------------------------------------------- +#ifdef __cplusplus +//----------------------------------------------------------------------------- +extern float mgl_cos[360]; ///< contain cosine with step 1 degree +//----------------------------------------------------------------------------- +#include +typedef std::complex dual; +//----------------------------------------------------------------------------- +extern "C" { +#else +#include +#if MGL_USE_DOUBLE +typedef double _Complex dual; +#else +typedef float _Complex dual; +#endif +#endif +/// Find length of wchar_t string (bypass standard wcslen bug) +double MGL_EXPORT mgl_hypot(double x, double y); +/// Find length of wchar_t string (bypass standard wcslen bug) +size_t MGL_EXPORT mgl_wcslen(const wchar_t *str); +/// Get RGB values for given color id or fill by -1 if no one found +void MGL_EXPORT mgl_chrrgb(char id, float rgb[3]); +/// Check if string contain color id and return its number +long MGL_EXPORT mgl_have_color(const char *stl); +/// Find symbol in string excluding {} and return its position or NULL +const char *mglchr(const char *str, char ch); +/// Find any symbol from chr in string excluding {} and return its position or NULL +const char *mglchrs(const char *str, const char *chr); +/// Set number of thread for plotting and data handling (for pthread version only) +void MGL_EXPORT mgl_set_num_thr(int n); +void MGL_EXPORT mgl_set_num_thr_(int *n); +void MGL_EXPORT mgl_test_txt(const char *str, ...); +void MGL_EXPORT mgl_set_test_mode(int enable); +/// Remove spaces at begining and at the end of the string +void MGL_EXPORT mgl_strtrim(char *str); +void MGL_EXPORT mgl_wcstrim(wchar_t *str); +/** Change register to lowercase (only for ANSI symbols) */ +void MGL_EXPORT mgl_strlwr(char *str); +void MGL_EXPORT mgl_wcslwr(wchar_t *str); +/// Convert wchar_t* string into char* one +void MGL_EXPORT mgl_wcstombs(char *dst, const wchar_t *src, int size); +/// Clear internal data for speeding up FFT and Hankel transforms +void MGL_EXPORT mgl_clear_fft(); +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/include/mgl2/eval.h b/include/mgl2/eval.h new file mode 100644 index 0000000..65dcb95 --- /dev/null +++ b/include/mgl2/eval.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * eval.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_EVAL_H_ +#define _MGL_EVAL_H_ +//----------------------------------------------------------------------------- +#include "mgl2/define.h" +/// types of errors +#define MGL_ERR_LOG 1 +#define MGL_ERR_ARC 2 +#define MGL_ERR_SQRT 3 +/// size of var array +const int MGL_VS = 'z'-'a'+1; +//----------------------------------------------------------------------------- +/// Class for evaluating formula specified by the string +class MGL_EXPORT mglFormula // îáúåêò äëÿ ââîäà è âû÷èñëåíèÿ ôîðìóë +{ +public: + /// Evaluates the formula for 'x','r'=\a x, 'y','n'=\a y, 'z','t'=\a z, 'u'=\a u + mreal Calc(mreal x,mreal y=0,mreal z=0,mreal u=0) const; + /// Evaluates the formula for 'x, y, z, u, v, w' + mreal Calc(mreal x,mreal y,mreal z,mreal u,mreal v,mreal w) const; + /// Evaluates the formula for variables var + mreal Calc(const mreal var[MGL_VS]) const; + /// Evaluates the formula for 'x','r'=\a x, 'y','n'=\a y, 'z','t'=\a z, 'u'=\a u + mreal CalcD(char diff, mreal x,mreal y=0,mreal z=0,mreal u=0) const; + /// Evaluates the formula for 'x, y, z, u, v, w' + mreal CalcD(char diff, mreal x,mreal y,mreal z,mreal u,mreal v,mreal w) const; + /// Evaluates the derivates of the formula for variables var respect to variable diff + mreal CalcD(const mreal var[MGL_VS], char diff) const; + /// Return error code + int GetError() const; + /// Parse the formula str and create formula-tree + mglFormula(const char *str); + /// Clean up formula-tree + ~mglFormula(); +protected: + mreal CalcIn(const mreal *a1) const; + mreal CalcDIn(int id, const mreal *a1) const; + mglFormula *Left,*Right; // first and second argument of the function + int Kod; // the function ID + mreal Res; // the number or the variable ID + static int Error; +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/evalc.h b/include/mgl2/evalc.h new file mode 100644 index 0000000..34d8115 --- /dev/null +++ b/include/mgl2/evalc.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * evalc.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_EVALC_H_ +#define _MGL_EVALC_H_ +//----------------------------------------------------------------------------- +#include "mgl2/eval.h" +//----------------------------------------------------------------------------- +/// Class for evaluating formula specified by the string +class MGL_EXPORT mglFormulaC // ������ ��� ����� � ���������� ������ +{ +public: + /// Evaluates the formula for 'x','r'=\a x, 'y','n'=\a y, 'z','t'=\a z, 'u'=\a u + dual Calc(dual x,dual y=0,dual z=0,dual u=0) const; + /// Evaluates the formula for 'x, y, z, u, v, w' + dual Calc(dual x,dual y,dual z,dual u,dual v,dual w) const; + /// Evaluates the formula for variables var + dual Calc(const dual var[MGL_VS]) const; + /// Return error code + int GetError() const; + /// Parse the formula str and create formula-tree + mglFormulaC(const char *str); + /// Clean up formula-tree + virtual ~mglFormulaC(); +protected: + dual CalcIn(const dual *a1) const; + mglFormulaC *Left,*Right; // first and second argument of the function + int Kod; // the function ID + dual Res; // the number or the variable ID + static int Error; +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/fit.h b/include/mgl2/fit.h new file mode 100644 index 0000000..1ea4598 --- /dev/null +++ b/include/mgl2/fit.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * fit.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_FIT_H_ +#define _MGL_FIT_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +//----------------------------------------------------------------------------- +extern int mglFitPnts; ///< Number of output points in fitting +extern char mglFitRes[1024]; ///< Last fitted formula +HMDT MGL_EXPORT mgl_fit_1(HMGL gr, HCDT y, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_2(HMGL gr, HCDT z, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_3(HMGL gr, HCDT a, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xy(HMGL gr, HCDT x, HCDT y, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xyza(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_ys(HMGL gr, HCDT y, HCDT s, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xys(HMGL gr, HCDT x, HCDT y, HCDT s, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xyzs(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT s, const char *eq, const char *vars, HMDT ini, const char *opt); +HMDT MGL_EXPORT mgl_fit_xyzas(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, HCDT s, const char *eq, const char *vars, HMDT ini, const char *opt); + +MGL_EXPORT const char *mgl_get_fit(HMGL gr); + +HMDT MGL_EXPORT mgl_hist_x(HMGL gr, HCDT x, HCDT a, const char *opt); +HMDT MGL_EXPORT mgl_hist_xy(HMGL gr, HCDT x, HCDT y, HCDT a, const char *opt); +HMDT MGL_EXPORT mgl_hist_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *opt); + +void MGL_EXPORT mgl_puts_fit(HMGL gr, double x, double y, double z, const char *prefix, const char *font, double size); +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_fit_1_(uintptr_t* gr, uintptr_t* y, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_2_(uintptr_t* gr, uintptr_t* z, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_3_(uintptr_t* gr, uintptr_t* a, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xy_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xyz_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xyza_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_ys_(uintptr_t* gr, uintptr_t* y, uintptr_t* ss, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xys_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* ss, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xyzs_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* ss, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); +uintptr_t MGL_EXPORT mgl_fit_xyzas_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, uintptr_t* ss, const char *eq, const char *vars, uintptr_t *ini, const char *opt,int, int l, int n); + +uintptr_t MGL_EXPORT mgl_hist_x_(uintptr_t* gr, uintptr_t* x, uintptr_t* a, const char *opt,int); +uintptr_t MGL_EXPORT mgl_hist_xy_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* a, const char *opt,int); +uintptr_t MGL_EXPORT mgl_hist_xyz_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, const char *opt,int); + +void MGL_EXPORT mgl_puts_fit_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, const char *prefix, const char *font, mreal *size, int l, int n); +//----------------------------------------------------------------------------- +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/fltk.h b/include/mgl2/fltk.h new file mode 100644 index 0000000..b1ba719 --- /dev/null +++ b/include/mgl2/fltk.h @@ -0,0 +1,179 @@ +/*************************************************************************** + * window.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#ifndef _MGL_FLTK_H_ +#define _MGL_FLTK_H_ + +#include +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +/// Creates FLTK window for plotting +HMGL MGL_EXPORT mgl_create_graph_fltk(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)); +uintptr_t MGL_EXPORT mgl_create_graph_fltk_(const char *title, int); +/// Run main FLTK loop for event handling. +int MGL_EXPORT mgl_fltk_run(); +int MGL_EXPORT mgl_fltk_run_(); +/// Run main FLTK loop for event handling in separate thread. +int MGL_EXPORT mgl_fltk_thr(); +#ifdef __cplusplus +} +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +/// Wrapper class for windows displaying graphics +class MGL_EXPORT mglFLTK : public mglWnd +{ +public: + mglFLTK(const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_fltk(0,title,0,0); } + mglFLTK(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*load)(void *p)=0) : mglWnd() + { gr = mgl_create_graph_fltk(draw,title,par,load); } + mglFLTK(int (*draw)(mglGraph *gr), const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_fltk(draw?mgl_draw_graph:0,title,(void*)draw,0); } + mglFLTK(mglDraw *draw, const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_fltk(draw?mgl_draw_class:0,title,draw,mgl_reload_class); + mgl_set_click_func(gr, mgl_click_class); } + int Run() { return mgl_fltk_run(); } ///< Run main loop for event handling + int RunThr() { return mgl_fltk_thr(); } ///< Run main loop for event handling in separate thread +}; +//----------------------------------------------------------------------------- +#ifdef __MWERKS__ +# define FL_DLL +#endif + +#include +#include +#include +#include +#include +#include +class mglCanvas; +//----------------------------------------------------------------------------- +/// Class is FLTK widget which display MathGL graphics +class MGL_EXPORT Fl_MathGL : public Fl_Widget +{ +public: + Fl_Valuator *tet_val; ///< pointer to external tet-angle validator + Fl_Valuator *phi_val; ///< pointer to external phi-angle validator + + Fl_MathGL(int x, int y, int w, int h, const char *label=0); + ~Fl_MathGL(); + + /// Update (redraw) plot + virtual void update(); + /// Set angles for additional plot rotation + inline void set_angle(mreal t, mreal p){ tet = t; phi = p; } + /// Set bitwise flags for general state (1-Alpha, 2-Light) + inline void set_flag(int f) { flag = f; } + /// Set flags for handling mouse + void set_graph(HMGL gr); ///< Set grapher object + inline void set_graph(mglGraph *Gr) + { set_graph(Gr->Self()); } + /// Get pointer to grapher + inline HMGL get_graph() { return (HMGL)gr; } + /// Set drawing functions and its parameter + inline void set_draw(int (*func)(mglBase *gr, void *par), void *par) + { if(draw_cl) delete draw_cl; draw_cl=0; draw_func=func; draw_par=par; } + inline void set_draw(mglDraw *dr) { if(draw_cl) delete draw_cl; draw_cl=dr; draw_func=0; } + inline void set_draw(int (*dr)(mglGraph *gr)) + { set_draw(dr?mgl_draw_graph:0,(void*)dr); } + void set_state(bool z, bool r) { zoom = z; rotate = r; } + /// Set zoom in/out region + inline void set_zoom(mreal X1, mreal Y1, mreal X2, mreal Y2) + { x1 = X1; x2 = X2; y1 = Y1; y2 = Y2; update(); } + /// Get zoom region + inline void get_zoom(mreal *X1, mreal *Y1, mreal *X2, mreal *Y2) + { *X1 = x1; *X2 = x2; *Y1 = y1; *Y2 = y2; } + /// Set popup menu pointer + inline void set_popup(const Fl_Menu_Item *pmenu, Fl_Widget *wdg, void *v) + { popup = pmenu; wpar = wdg; vpar = v; } + inline void zoom_region(mreal xx1,mreal xx2,mreal yy1, mreal yy2) + { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } + +protected: + mglCanvas *gr; ///< pointer to grapher + void *draw_par; ///< Parameters for drawing function mglCanvasWnd::DrawFunc. + /// Drawing function for window procedure. It should return the number of frames. + int (*draw_func)(mglBase *gr, void *par); + mglDraw *draw_cl; + + const Fl_Menu_Item *popup; ///< pointer to popup menu items + Fl_Widget *wpar; ///< widget for popup menu + void *vpar; ///< parameter for popup menu + mreal tet,phi; ///< rotation angles + bool rotate; ///< flag for handle mouse + bool zoom; ///< flag for zoom by mouse + bool wire; + mreal x1,x2,y1,y2; ///< zoom region + int flag; ///< bitwise flag for general state (1-Alpha, 2-Light) + int x0,y0,xe,ye; ///< mouse position + char pos[128]; + + virtual void draw(); ///< quick drawing function + int handle(int code); ///< handle mouse events + void resize(int x, int y, int w, int h); ///< resize control +}; +//----------------------------------------------------------------------------- +class MGL_EXPORT Fl_MGLView : public Fl_Window +{ +public: + Fl_MathGL *FMGL; ///< Control which draw graphics + Fl_Scroll *scroll; + Fl_Menu_Bar *menu; + + void *par; ///< Parameter for handling animation + void (*next)(void*); ///< Callback function for next frame + void (*prev)(void*); ///< Callback function for prev frame + mreal (*delay)(void*); ///< Callback function for delay + void (*reload)(void*); ///< Callback function for reloading + + void toggle_alpha() { toggle(alpha, alpha_bt, "Graphics/Alpha"); } + void toggle_light() { toggle(light, light_bt, "Graphics/Light"); } + void toggle_sshow() { toggle(sshow, anim_bt, "Graphics/Slideshow"); } + void toggle_grid() { toggle(grid, grid_bt, "Graphics/Grid"); } + void toggle_zoom() { toggle(zoom, zoom_bt); } + void toggle_rotate(){ toggle(rotate, rotate_bt); } + void setoff_zoom() { setoff(zoom, zoom_bt); } + void setoff_rotate(){ setoff(rotate, rotate_bt); } + bool is_sshow() { return sshow; } + void adjust() + { mgl_set_size(FMGL->get_graph(),scroll->w(),scroll->h()); FMGL->size(scroll->w(),scroll->h()); update(); } + + Fl_MGLView(int x, int y, int w, int h, const char *label=0); + ~Fl_MGLView(); + void update(); ///< Update picture by calling user drawing function +protected: + Fl_Button *alpha_bt, *light_bt, *rotate_bt, *anim_bt, *zoom_bt, *grid_bt; +// Fl_Counter *tet, *phi; + + int grid, alpha, light; ///< Current states of wire, alpha, light switches (toggle buttons) + int sshow, rotate, zoom;///< Current states of slideshow, rotate, zoom switches (toggle buttons) + + void toggle(int &val, Fl_Button *b, const char *txt=NULL); + void setoff(int &val, Fl_Button *b, const char *txt=NULL); +}; +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ask_fltk(const wchar_t *quest, wchar_t *res); +void MGL_EXPORT mgl_makemenu_fltk(Fl_Menu_ *m, Fl_MGLView *w); +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/font.h b/include/mgl2/font.h new file mode 100644 index 0000000..2666c09 --- /dev/null +++ b/include/mgl2/font.h @@ -0,0 +1,134 @@ +/*************************************************************************** + * font.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#ifndef _MGL_FONT_H_ +#define _MGL_FONT_H_ + +#include "mgl2/define.h" +#include +//----------------------------------------------------------------------------- +#define MGL_FONT_BOLD 0x01000000 // This value is used binary +#define MGL_FONT_ITAL 0x02000000 // This value is used binary +#define MGL_FONT_BOLD_ITAL 0x03000000 +#define MGL_FONT_WIRE 0x04000000 +#define MGL_FONT_OLINE 0x08000000 // This value is used binary +#define MGL_FONT_ULINE 0x10000000 +#define MGL_FONT_ZEROW 0x20000000 // internal codes +#define MGL_FONT_UPPER 0x40000000 +#define MGL_FONT_LOWER 0x80000000 +#define MGL_FONT_ROMAN 0xfcffffff +#define MGL_FONT_MASK 0x00ffffff +#define MGL_COLOR_MASK 0xffffff00 +#define MGL_FONT_STYLE 0x3f000000 +//----------------------------------------------------------------------------- +#ifdef WIN32 // a man ask to use built-in font under Windows +#define MGL_DEF_FONT_NAME 0 +#else +#define MGL_DEF_FONT_NAME "STIX" +#endif +//----------------------------------------------------------------------------- +struct MGL_EXPORT mglTeXsymb { unsigned kod; const wchar_t *tex; }; +const float mgl_fgen = 4*14; +/// Get font color, style and align for internal parser +char mglGetStyle(const char *how, int *font, int *align=0); +class mglBase; +//----------------------------------------------------------------------------- +/// Class for font typeface and text plotting procedures +class MGL_EXPORT mglFont +{ +public: + mglBase *gr; ///< mglBase class used for drawing characters + mglFont(const char *name=0, const char *path=0); + ~mglFont(); + bool parse; ///< Parse LaTeX symbols + + /// Load font data to memory. Normally used by constructor. + bool Load(const char *base, const char *path=0); + /// Free memory + void Clear(); + /// Copy data from other font + void Copy(mglFont *); + /// Restore default font + void Restore(); + /// Return true if font is loaded + inline bool Ready() const { return numg!=0; } + + /// Get height of text + float Height(int font) const; + /// Get height of text + float Height(const char *how) const; + /// Print text string for font specified by string + float Puts(const char *str,const char *how,float col) const; + /// Get width of text string for font specified by string + float Width(const char *str,const char *how) const; + /// Print text string for font specified by string + float Puts(const wchar_t *str,const char *how,float col) const; + /// Get width of text string for font specified by string + float Width(const wchar_t *str,const char *how) const; + + /// Get internal code for symbol + long Internal(unsigned s) const; + /// Return number of glyphs + inline unsigned GetNumGlyph() const { return numg; }; + /// Return some of pointers + inline const short *GetTr(int s, long j) const { return Buf+tr[s][j]; } + inline const short *GetLn(int s, long j) const { return Buf+ln[s][j]; } + inline int GetNt(int s, long j) const { return numt[s][j]; } + inline int GetNl(int s, long j) const { return numl[s][j]; } + inline short GetWidth(int s, long j) const { return width[s][j]; } + inline float GetFact(int s) const { return fact[s]; } +protected: + wchar_t *id; ///< Unicode ID for glyph + int *tr[4]; ///< Shift of glyph description by triangles (for solid font) + int *ln[4]; ///< Shift of glyph description by lines (for wire font) + short *numt[4]; ///< Number of triangles in glyph description (for solid font) + short *numl[4]; ///< Number of lines in glyph description (for wire font) + short *width[4];///< Width of glyph for wire font + float fact[4]; ///< Divider for width of glyph + unsigned numg; ///< Number of glyphs + short *Buf; ///< Buffer for glyph descriptions + long numb; ///< Buffer size + + /// Print text string for font specified by integer constant + float Puts(const wchar_t *str,int font,int align, float col) const; + /// Get width of text string for font specified by integer constant + float Width(const wchar_t *str,int font=0) const; + /// Replace TeX symbols by its UTF code and add font styles + void Convert(const wchar_t *str, unsigned *res) const; + + /// Draw string recursively + /* x,y - position, f - factor, style: 0x1 - italic, 0x2 - bold, 0x4 - overline, 0x8 - underline, 0x10 - empty (not draw) */ + float Puts(const unsigned *str, float x,float y,float f,int style,float col) const; + /// Parse LaTeX command + unsigned Parse(const wchar_t *s) const; + /// Get symbol for character ch with given font style + unsigned Symbol(char ch) const; +private: + float get_ptr(long &i,unsigned *str, unsigned **b1, unsigned **b2,float &w1,float &w2, float f1, float f2, int st) const; + bool read_data(const char *fname, float *ff, short *wdt, short *numl, int *posl, short *numt, int *post, std::vector &buf); + void main_copy(); + bool read_main(const char *fname, std::vector &buf); + void mem_alloc(); + bool read_def(); + void draw_ouline(int st, float x, float y, float f, float g, float ww, float ccol) const; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/include/mgl2/glut.h b/include/mgl2/glut.h new file mode 100644 index 0000000..9a5c539 --- /dev/null +++ b/include/mgl2/glut.h @@ -0,0 +1,82 @@ +/*************************************************************************** + * glut.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#ifndef _MGL_GLUT_H_ +#define _MGL_GLUT_H_ +#ifdef __cplusplus +#include +//----------------------------------------------------------------------------- +extern "C" { +#endif +void _mgl_key_up(unsigned char ch,int ,int ); +HMGL MGL_EXPORT mgl_create_graph_glut(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)); + + +/// Switch on/off transparency (do not overwrite user settings) +void MGL_EXPORT mgl_glut_toggle_alpha(HMGL gr); +/// Switch on/off lighting (do not overwrite user settings) +void MGL_EXPORT mgl_glut_toggle_light(HMGL gr); +/// Switch off all zooming and rotation +void MGL_EXPORT mgl_glut_toggle_no(HMGL gr); +/// Update picture by calling user drawing function +void MGL_EXPORT mgl_glut_update(HMGL gr); +/// Reload user data and update picture +void MGL_EXPORT mgl_glut_reload(HMGL gr); +/// Show next frame (if one) +void MGL_EXPORT mgl_glut_next_frame(HMGL gr); +/// Show previous frame (if one) +void MGL_EXPORT mgl_glut_prev_frame(HMGL gr); +/// Run slideshow (animation) of frames +void MGL_EXPORT mgl_glut_animation(HMGL gr); + +#ifdef __cplusplus +} +//----------------------------------------------------------------------------- +class MGL_EXPORT mglGLUT: public mglGraph +{ +public: + mglGLUT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=0, void (*load)(void *p)=0) : mglGraph(-1) + { gr = mgl_create_graph_glut(draw,title,par,load); } + mglGLUT(int (*draw)(mglGraph *gr), const char *title="MathGL") : mglGraph(-1) + { gr = mgl_create_graph_glut(draw?mgl_draw_graph:0,title,(void*)draw,0); } + mglGLUT(mglDraw *draw=0, const char *title="MathGL") : mglGraph(-1) + { gr = mgl_create_graph_glut(draw?mgl_draw_class:0,title,draw,mgl_reload_class); } + + inline void ToggleAlpha() ///< Switch on/off transparency (do not overwrite user settings) + { mgl_glut_toggle_alpha(gr); } + inline void ToggleLight() ///< Switch on/off lighting (do not overwrite user settings) + { mgl_glut_toggle_light(gr); } + inline void ToggleNo() ///< Switch off all zooming and rotation + { mgl_glut_toggle_no(gr); } + inline void Update() ///< Update picture by calling user drawing function + { mgl_glut_update(gr); } + inline void ReLoad() ///< Reload user data and update picture + { mgl_glut_reload(gr); } + inline void NextFrame() ///< Show next frame (if one) + { mgl_glut_next_frame(gr); } + inline void PrevFrame() ///< Show previous frame (if one) + { mgl_glut_prev_frame(gr); } + inline void Animation() ///< Run slideshow (animation) of frames + { mgl_glut_animation(gr); } + inline int Run() {return 0;}; ///< Run main loop for event handling (placed for similarity to mglWnd) +}; +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/gsl.fs b/include/mgl2/gsl.fs new file mode 100644 index 0000000..5681829 --- /dev/null +++ b/include/mgl2/gsl.fs @@ -0,0 +1,1276 @@ +\ GNU Scientific Library interface Mon Sep 12 14:40:15 MDT 2005 +\ Copyright (C) 2007, Sergey Plis +\ +\ This program is free software; you can redistribute it and/or modify +\ it under the terms of the GNU General Public License as published by +\ the Free Software Foundation; either version 2 of the License, or +\ (at your option) any later version. +\ +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\needs float import float +warning off +\needs locals| include locals.fs +warning on +\needs atlas include atlas.fs +\needs callback include callback.fs +\needs vectors include vectors.fs +\needs complex include complex.fb + +Module GSL + +\ stole the hash function from hash.fs of bigforth +| &14 Value Hashbits +| 1 Hashbits << Value Hashlen + +Label (hash ( SI:string -- AX:key ) :R DX push + .b lods $1F # AX and AX CX mov DX DX xor CX 1 # shr + b IF SI ) AH mov SI inc THEN CX dec + 0>= IF BEGIN .w SI ) DX mov 2 # SI add CX dec + DX AX *2 I) AX lea 0< UNTIL THEN + & Hashbits A#) CX mov AX DX mov AX shr DX AX add + & Hashlen A#) CX mov CX dec CX AX and DX pop ret +| Code Hash ( string -- key ) + R: SI push AX SI mov (hash rel) call SI pop + Next end-code + +also dos also complex also float also atlas also vectors + +s" libptcblas.so" getlib 0<> +[IF] + library libblas libptcblas.so depends libatlas +[ELSE] + library libblas libcblas.so depends libatlas +[THEN] + +library libgsl libgsl.so.0 depends libblas + +legacy off + +\ some functions +libgsl gsl_log1p df (fp) gsl_log1p ( df -- df ) +libgsl gsl_acosh df (fp) gsl_acosh ( df -- df ) + +\ error handling Wed Sep 21 23:04:06 MDT 2005 +libgsl gsl_set_error_handler ptr (int) gsl_set_error_handler +( function -- function ) +libgsl gsl_strerror int (ptr) gsl_strerror + +callback 4:0 (void) int int int int callback; +: cstr-fstr ( addr -- addr len ) + 0 + begin 2dup + c@ 0 = not while + 1+ + repeat ; + +| : .bold-red ." " ; +| : .red ." " ; +| : .reset ." " ; +| : cb-test + cr + \ .bold-red + ." GSL ERROR: " cr + \ .reset cr + 10 spaces gsl_strerror cstr-fstr type cr + drop \ ." at line: " . cr + drop \ ." of file: " cstr-fstr type cr + 10 spaces cstr-fstr type cr + \ .red + -1 abort" failed at" ; +' cb-test 4:0 c_plus + +\ 1 2 c_plus 2:1call . +| variable old_handler +c_plus gsl_set_error_handler old_handler ! + +0 Constant GSL_SUCCESS + +\ random number generation Mon Sep 12 22:06:01 MDT 2005 + +libgsl gsl_rng_types_setup (ptr) gsl_rng_types_setup ( -- *gsl_rng_type) +libgsl gsl_rng_env_setup (ptr) gsl_rng_env_setup ( -- *gsl_rng) +libgsl gsl_rng_alloc int (int) gsl_rng_alloc ( *gsl_rng_type -- *gsl_rng ) +libgsl gsl_rng_name int (int) gsl_rng_name ( *gsl_rng -- string ) +libgsl gsl_rng_set int int (void) gsl_rng_set ( *gsl_rng int -- ) +libgsl gsl_rng_uniform int (fp) gsl_rng_uniform ( *gsl_rng -- df ) +libgsl gsl_rng_uniform_pos int (fp) gsl_rng_uniform_pos ( *gsl_rng -- df ) +libgsl gsl_rng_uniform_int int int (int) gsl_rng_uniform_int ( *gsl_rng n --n ) +libgsl gsl_rng_get int (int) gsl_rng_get ( *gsl_rng -- int ) +libgsl gsl_rng_max int (int) gsl_rng_max ( *gsl_rng -- int ) +libgsl gsl_rng_min int (int) gsl_rng_min ( *gsl_rng -- int ) +libgsl gsl_rng_clone int (int) gsl_rng_clone ( *gsl_rng -- *gsl_rng ) +libgsl gsl_rng_free int (int) gsl_rng_free ( *gsl_rng -- ) + + + +\ random number distributions Tue Sep 13 00:44:35 MDT 2005 +\ Gaussian +libgsl gsl_ran_gaussian df int (fp) gsl_ran_gaussian ( *gsl_rng df -- df ) +libgsl gsl_ran_gaussian_ratio_method df int (fp) gsl_ran_gaussian_ratio_method ( *gsl_rng df -- df ) +libgsl gsl_ran_gaussian_pdf df df (fp) gsl_ran_gaussian_pdf ( df df -- df ) +\ sigma = 1 +libgsl gsl_ran_ugaussian int (fp) gsl_ran_ugaussian ( *gsl_rng -- df ) +libgsl gsl_ran_ugaussian_ratio_method int (fp) gsl_ran_ugaussian_ratio_method ( *gsl_rng -- df ) +libgsl gsl_ran_ugaussian_pdf df (fp) gsl_ran_ugaussian_pdf ( df df -- df ) +libgsl gsl_ran_discrete_preproc int int (int) gsl_ran_discrete_preproc ( int int -- int ) +libgsl gsl_ran_discrete int int (int) gsl_ran_discrete +libgsl gsl_ran_discrete_free int (void) gsl_ran_discrete_free +libgsl gsl_ran_shuffle int int ptr ptr (void) gsl_ran_shuffle +\ cdf P(x) = \int_{-\infty}^{x} p(x)dx Q(x) = \int_{x}^{\infty} p(x)dx +libgsl gsl_cdf_gaussian_P df df (fp) gsl_cdf_gaussian_P ( df df -- df ) +libgsl gsl_cdf_gaussian_Q df df (fp) gsl_cdf_gaussian_Q ( df df -- df ) +libgsl gsl_cdf_gaussian_Pinv df df (fp) gsl_cdf_gaussian_Pinv ( df df -- df ) +libgsl gsl_cdf_gaussian_Qinv df df (fp) gsl_cdf_gaussian_Qinv ( df df -- df ) +\ sigma = 1 cdf +libgsl gsl_cdf_ugaussian_P df (fp) gsl_cdf_ugaussian_P ( df -- df ) +libgsl gsl_cdf_ugaussian_Q df (fp) gsl_cdf_ugaussian_Q ( df -- df ) +libgsl gsl_cdf_ugaussian_Pinv df (fp) gsl_cdf_ugaussian_Pinv ( df -- df ) +libgsl gsl_cdf_ugaussian_Qinv df (fp) gsl_cdf_ugaussian_Qinv ( df -- df ) + + +\ statistics Tue Sep 13 01:17:35 MDT 2005 +libgsl gsl_stats_mean int int int (fp) gsl_stats_mean ( array{ step size -- df ) +libgsl gsl_stats_variance int int int (fp) gsl_stats_variance ( array{ step size -- df ) +libgsl gsl_stats_variance_m df int int int (fp) gsl_stats_variance_m ( df array{ step size -- df ) +libgsl gsl_stats_sd int int int (fp) gsl_stats_sd ( array{ step size -- df ) +libgsl gsl_stats_sd_m df int int int (fp) gsl_stats_sd_m ( df array{ step size -- df ) +libgsl gsl_stats_skew int int int (fp) gsl_stats_skew ( array{ step size -- df ) +libgsl gsl_stats_kurtosis int int int (fp) gsl_stats_kurtosis ( array{ step size -- df ) +libgsl gsl_stats_lag1_autocorrelation int int int (fp) gsl_stats_lag1_autocorrelation +( array{ step size -- df ) +libgsl gsl_stats_max int int int (fp) gsl_stats_max ( array{ step size -- df ) +libgsl gsl_stats_min int int int (fp) gsl_stats_min ( array{ step size -- df ) +libgsl gsl_stats_max_index int int int (int) gsl_stats_max_index ( array{ step size -- n ) +libgsl gsl_stats_min_index int int int (int) gsl_stats_min_index ( array{ step size -- n ) + +\ vectors and matrices Wed Sep 14 00:15:36 MDT 2005 + +\ Vectors +libgsl gsl_block_alloc int (int) gsl_block_alloc ( n -- addr ) +libgsl gsl_block_calloc int (int) gsl_block_calloc ( n -- addr ) +libgsl gsl_block_free int (int) gsl_block_free ( n -- addr ) + +libgsl gsl_vector_alloc int (int) gsl_vector_alloc ( n -- addr ) +libgsl gsl_vector_calloc int (int) gsl_vector_calloc ( n -- addr ) +libgsl gsl_vector_alloc_from_vector int int int ptr (int) gsl_vector_alloc_from_vector +libgsl gsl_vector_free int (void) gsl_vector_free ( addr -- ) +libgsl gsl_vector_get int int (fp) gsl_vector_get ( addr i -- df ) +libgsl gsl_vector_set df int int (void/fp) gsl_vector_set ( df addr i -- ) +libgsl gsl_vector_set_all df int (void) gsl_vector_set_all ( df addr -- ) +libgsl gsl_vector_set_zero int (void) gsl_vector_set_zero ( addr -- ) +libgsl gsl_vector_memcpy int int (int) gsl_vector_memcpy ( dest_addr src_addr -- n ) + +libgsl gsl_vector_add int int (int) gsl_vector_add ( addr addr -- n ) +libgsl gsl_vector_sub int int (int) gsl_vector_sub ( addr addr -- n ) +libgsl gsl_vector_mul int int (int) gsl_vector_mul ( addr addr -- n ) +libgsl gsl_vector_div int int (int) gsl_vector_div ( addr addr -- n ) +libgsl gsl_vector_scale df int (int) gsl_vector_scale ( df addr -- n ) +libgsl gsl_vector_add_constant df int (int) gsl_vector_add_constant ( df addr -- n ) +libgsl gsl_vector_max int (fp) gsl_vector_max ( addr -- df ) +libgsl gsl_vector_min int (fp) gsl_vector_min ( addr -- df ) +libgsl gsl_vector_max_index int (fp) gsl_vector_max_index ( addr -- df ) +libgsl gsl_vector_min_index int (fp) gsl_vector_min_index ( addr -- df ) +libgsl gsl_vector_subvector int int int (int) gsl_vector_subvector +\ Vector properties +libgsl gsl_vector_isnull ptr (int) gsl_vector_isnull +libgsl gsl_vector_ispos ptr (int) gsl_vector_ispos +libgsl gsl_vector_isneg ptr (int) gsl_vector_isneg + +\ permutations +libgsl gsl_permutation_alloc int (int) gsl_permutation_alloc ( n -- *gsl_prm) +libgsl gsl_permutation_calloc int (int) gsl_permutation_calloc ( n -- *gsl_prm) +libgsl gsl_permutation_init int (void) gsl_permutation_init ( *gsl_prm -- ) +libgsl gsl_permutation_free int (void) gsl_permutation_free ( *gsl_prm -- ) +libgsl gsl_permutation_get int int (int) gsl_permutation_get ( *gsl_prm i -- n) + +\ Matrices +\ Allocation +libgsl gsl_matrix_alloc int int (int) gsl_matrix_alloc +libgsl gsl_matrix_calloc int int (int) gsl_matrix_calloc +libgsl gsl_matrix_alloc_from_block [ 5 ] ints (int) gsl_matrix_alloc_from_block +libgsl gsl_matrix_alloc_from_matrix [ 5 ] ints (int) gsl_matrix_alloc_from_matrix +libgsl gsl_matrix_free ( *gsl_matrix -- ) int (void) gsl_matrix_free +\ Accessing matrix elements +libgsl gsl_matrix_get int int int (fp) gsl_matrix_get ( *m i j -- df ) +libgsl gsl_matrix_set df int int int (void) gsl_matrix_set ( df *m i j -- ) +libgsl gsl_matrix_ptr int int int (int) gsl_matrix_ptr ( *m i j -- *[i,j] ) +\ Initializing matrix elements +libgsl gsl_matrix_set_all df int (void) gsl_matrix_set_all ( *m df -- n ) +libgsl gsl_matrix_set_zero df int (void) gsl_matrix_set_zero ( *m df -- n ) +libgsl gsl_matrix_set_identity df int (void) gsl_matrix_set_identity ( *m df -- n ) +\ Reading and writing matrices +libgsl gsl_matrix_fwrite ptr ptr (int) gsl_matrix_fwrite +libgsl gsl_matrix_fread ptr ptr (int) gsl_matrix_fread +libgsl gsl_matrix_fprintf ptr ptr ptr (int) gsl_matrix_fprintf +libgsl gsl_matrix_fscanf ptr ptr (int) gsl_matrix_fscanf +\ Copying matrices +libgsl gsl_matrix_memcpy int int (int) gsl_matrix_memcpy ( *m *m -- n ) +libgsl gsl_matrix_swap int int (int) gsl_matrix_swap ( *m *m -- n ) +\ Copying Rows and columns +libgsl gsl_matrix_get_row int int int (int) gsl_matrix_get_row +libgsl gsl_matrix_set_row int int int (int) gsl_matrix_set_row +libgsl gsl_matrix_get_col int int int (int) gsl_matrix_get_col +libgsl gsl_matrix_set_col int int int (int) gsl_matrix_set_col +\ Exchanging rows and columns +libgsl gsl_matrix_swap_rows int int ptr (int) gsl_matrix_swap_rows +libgsl gsl_matrix_swap_columns int int ptr (int) gsl_matrix_swap_columns +libgsl gsl_matrix_swap_rowcol int int ptr (int) gsl_matrix_swap_rowcol +libgsl gsl_matrix_transpose_memcpy int int (int) gsl_matrix_transpose_memcpy +libgsl gsl_matrix_transpose int (int) gsl_matrix_transpose +\ Matrix operations +libgsl gsl_matrix_add int int (int) gsl_matrix_add +libgsl gsl_matrix_sub int int (int) gsl_matrix_sub +libgsl gsl_matrix_mul_elements int int (int) gsl_matrix_mul_elements +libgsl gsl_matrix_div_elements int int (int) gsl_matrix_div_elements +libgsl gsl_matrix_scale df int (int) gsl_matrix_scale +libgsl gsl_matrix_add_constant df int (int) gsl_matrix_add_constant +\ Finding maximum and minimum elements of matrices +libgsl gsl_matrix_max ptr (fp) gsl_matrix_max +libgsl gsl_matrix_min ptr (fp) gsl_matrix_min +libgsl gsl_matrix_minmax ptr ptr ptr (void) gsl_matrix_minmax +libgsl gsl_matrix_min_index ptr ptr ptr (void) gsl_matrix_min_index +libgsl gsl_matrix_max_index ptr ptr ptr (void) gsl_matrix_max_index +libgsl gsl_matrix_minmax_index ptr ptr ptr ptr ptr (void) gsl_matrix_minmax_index +\ Matrix properties +libgsl gsl_matrix_isnull ptr (int) gsl_matrix_isnull +libgsl gsl_matrix_ispos ptr (int) gsl_matrix_ispos +libgsl gsl_matrix_isneg ptr (int) gsl_matrix_isneg +\ libgsl gsl_matrix_isnonneg ptr (int) gsl_matrix_isnonneg + + +libgsl gsl_matrix_submatrix int int int int int (int) gsl_matrix_submatrix ( *gsl_matrix k1 k2 n1 n2 -- n ) +libgsl gsl_matrix_row int int (int) gsl_matrix_row ( *gsl_matrix idx -- *gsl_vector ) +libgsl gsl_matrix_column int int (int) gsl_matrix_column ( *gsl_matrix idx -- *gsl_vector ) +libgsl gsl_matrix_diagonal int (int) gsl_matrix_diagonal ( *gsl_matrix -- *gsl_vector ) + + +\ BLAS Wed Sep 14 16:10:34 MDT 2005 +\ libblas cblas_dgemm int int df int int int +\ int df int int int int int int (void/fp) cblas_dgemm +libblas cblas_dgemv int int int int df int +int df int int int int (void/fp) cblas_dgemv +libgsl gsl_blas_ddot int int int (int) gsl_blas_ddot +( *gsl_vector *gsl_vector df -- n ) +libgsl gsl_blas_dgemm int df int int df int int (int/fp) gsl_blas_dgemm +libgsl gsl_blas_dger int int int df (int/fp) gsl_blas_dger +( alpha *gsl_vector *gsl_vector *gsl_matrix -- n ) ( A=\alpha x y^T+A ) +libgsl gsl_blas_dgemv int df int int df int (int/fp) gsl_blas_dgemv +( n alpha *gsl_matrix *gsl_vector beta *gsl_vector -- n ) + +\ Linear ALgebra Wed Sep 14 13:39:22 MDT 2005 + +libgsl gsl_linalg_LU_decomp int int int (int) gsl_linalg_LU_decomp +( *gsl_matrix *gsl_permutation *variable -- n ) +libgsl gsl_linalg_LU_invert int int int (int) gsl_linalg_LU_invert +( *gsl_matrix *gsl_permutation *gsl_matrix -- n ) +libgsl gsl_linalg_SV_decomp int int int int (int) gsl_linalg_SV_decomp +( *gsl_matrix *gsl_matrix *gsl_vector *gsl_vector -- n ) +libgsl gsl_linalg_SV_decomp_mod int int int int int (int) gsl_linalg_SV_decomp_mod +( *gsl_matrix *gsl_matrix *gsl_matrix *gsl_vector *gsl_vector -- n ) + +\ ----------------------------------------------------------------------------- +\ *** Ordinary Differential Equations *** +\ --- ODE system +struct{ + cell func \ (* function) + \ (double t, const double y[], double dydt[], void * params); + cell jac \ (* jacobian) + \ (double t, const double y[], double * dfdy, double dfdt[], + \ void * params); + cell dim \ dimension; + cell params \ * params; +} gsl_odeiv_system +\ constants related to ODE + 1 constant GSL_ODEIV_HADJ_INC + 0 constant GSL_ODEIV_HADJ_NIL +-1 constant GSL_ODEIV_HADJ_DEC + +callback gsl_odeiv_func4:1 (int) df int int int callback; +callback gsl_odeiv_jac5:1 (int) df int int int int callback; + +\ --- Stepping Functions +libgsl gsl_odeiv_step_alloc ptr int (ptr) gsl_odeiv_step_alloc +( *step_type int -- *step ) +libgsl gsl_odeiv_step_reset ptr (int) gsl_odeiv_step_reset ( *step -- r ) +libgsl gsl_odeiv_step_free ptr (void) gsl_odeiv_step_free ( *step -- ) +libgsl gsl_odeiv_step_name ptr (ptr) gsl_odeiv_step_name ( *step -- *str0 ) +libgsl gsl_odeiv_step_order ptr (int) gsl_odeiv_step_order ( *step -- order) +libgsl gsl_odeiv_step_apply int int int int int df df int (int) gsl_odeiv_step_apply +( -- ) +\ --- Available algorithms +libgsl _gsl_odeiv_step_rk2 (int) gsl_odeiv_step_rk2 +libgsl _gsl_odeiv_step_rk4 (int) gsl_odeiv_step_rk4 +libgsl _gsl_odeiv_step_rkf45 (int) gsl_odeiv_step_rkf45 +libgsl _gsl_odeiv_step_rkck (int) gsl_odeiv_step_rkck +libgsl _gsl_odeiv_step_rk8pd (int) gsl_odeiv_step_rk8pd +libgsl _gsl_odeiv_step_rk2imp (int) gsl_odeiv_step_rk2imp +libgsl _gsl_odeiv_step_rk4imp (int) gsl_odeiv_step_rk4imp +libgsl _gsl_odeiv_step_bsimp (int) gsl_odeiv_step_bsimp +libgsl _gsl_odeiv_step_gear1 (int) gsl_odeiv_step_gear1 +libgsl _gsl_odeiv_step_gear2 (int) gsl_odeiv_step_gear2 + +: gsl_odeiv_step_rk2 [func'] _gsl_odeiv_step_rk2 @ ; +: gsl_odeiv_step_rk4 [func'] _gsl_odeiv_step_rk4 @ ; +: gsl_odeiv_step_rkf45 [func'] _gsl_odeiv_step_rkf45 @ ; +: gsl_odeiv_step_rkck [func'] _gsl_odeiv_step_rkck @ ; +: gsl_odeiv_step_rk8pd [func'] _gsl_odeiv_step_rk8pd @ ; +: gsl_odeiv_step_rk2imp [func'] _gsl_odeiv_step_rk2imp @ ; +: gsl_odeiv_step_rk4imp [func'] _gsl_odeiv_step_rk4imp @ ; +: gsl_odeiv_step_bsimp [func'] _gsl_odeiv_step_bsimp @ ; +: gsl_odeiv_step_gear1 [func'] _gsl_odeiv_step_gear1 @ ; +: gsl_odeiv_step_gear2 [func'] _gsl_odeiv_step_gear2 @ ; + +\ --- Adaptive Step-size Control +libgsl gsl_odeiv_control_standard_new df df df df (ptr) gsl_odeiv_control_standard_new ( a_dydt a_y eps_rel eps_abs -- *control ) +libgsl gsl_odeiv_control_y_new df df (int) gsl_odeiv_control_y_new +( eps_abs eps_rel -- *control ) +libgsl gsl_odeiv_control_yp_new df df (ptr) gsl_odeiv_control_yp_new +( eps_abs eps_rel -- *control ) +libgsl gsl_odeiv_control_free ptr (void) gsl_odeiv_control_free ( *control -- ) +libgsl gsl_odeiv_control_name ptr (ptr) gsl_odeiv_control_name ( *c -- *str0 ) + +\ --- Evolution +libgsl gsl_odeiv_evolve_alloc int (int) gsl_odeiv_evolve_alloc +( #dimensions -- evolution_func ) +libgsl gsl_odeiv_evolve_apply int int df int int int int int (int) gsl_odeiv_evolve_apply +( -- ) +libgsl gsl_odeiv_evolve_reset ptr (int) gsl_odeiv_evolve_reset ( *e -- r ) +libgsl gsl_odeiv_evolve_free ptr (void) gsl_odeiv_evolve_free ( *e -- ) +\ ----------------------------------------------------------------------------- +\ *** Fast Fourier Transform *** +\ -- real +libgsl gsl_fft_real_wavetable_alloc int (ptr) gsl_fft_real_wavetable_alloc +libgsl gsl_fft_real_wavetable_free ptr (void) gsl_fft_real_wavetable_free +libgsl gsl_fft_real_workspace_alloc int (ptr) gsl_fft_real_workspace_alloc +libgsl gsl_fft_real_workspace_free ptr (void) gsl_fft_real_workspace_free +\ in-place +libgsl gsl_fft_real_transform ptr int int ptr ptr (int) gsl_fft_real_transform +libgsl gsl_fft_real_unpack ptr ptr int int (int) gsl_fft_real_unpack + +\ -- halfcomplex +\ - mixed radix +libgsl gsl_fft_hc_wtbl_alloc int (ptr) gsl_fft_halfcomplex_wavetable_alloc +libgsl gsl_fft_hc_wtbl_free ptr (void) gsl_fft_halfcomplex_wavetable_free +libgsl gsl_fft_hc_backward ptr int int ptr ptr (int) gsl_fft_halfcomplex_backward +libgsl gsl_fft_hc_inverse ptr int int ptr ptr (int) gsl_fft_halfcomplex_inverse +libgsl gsl_fft_hc_transform ptr int int ptr ptr (int) gsl_fft_halfcomplex_transform +libgsl gsl_fft_hc_unpack ptr ptr int int (int) gsl_fft_halfcomplex_unpack +\ - radix2 +libgsl gsl_fft_hc_r2_unpack ptr ptr int int (int) gsl_fft_halfcomplex_radix2_unpack +libgsl gsl_fft_hc_r2_backward ptr int int (int) gsl_fft_halfcomplex_radix2_backward +libgsl gsl_fft_hc_r2_inverse ptr int int (int) gsl_fft_halfcomplex_radix2_inverse +libgsl gsl_fft_hc_r2_transform ptr int int (int) gsl_fft_halfcomplex_radix2_transform + + +| hashlen 32 vector fftpre( +struct{ + cell next + cell size + cell workspace + cell r_wavetable + cell hc_wavetable +} gsl_fft_precomputes +| create $buf 255 allot +| : 2str dup >r abs s>d <# #s r> sign #> $buf 0place ; +| : s>hash ( n -- key ) 2str $buf hash ; +| : (cache-fft) ( n -- addr ) + sizeof gsl_fft_precomputes allocate throw >r + 0 r@ gsl_fft_precomputes next ! + dup r@ gsl_fft_precomputes size ! + dup gsl_fft_real_workspace_alloc r@ gsl_fft_precomputes workspace ! + dup gsl_fft_real_wavetable_alloc r@ gsl_fft_precomputes r_wavetable ! + gsl_fft_hc_wtbl_alloc r@ gsl_fft_precomputes hc_wavetable ! + r> ; +| : cache-fft ( size -- addr ) + dup s>hash + fftpre( over )@ 0= if + swap (cache-fft) + fftpre( rot dup >r )! + fftpre( r> )@ + else + swap (cache-fft) + swap fftpre( over )@ + over gsl_fft_precomputes next ! + fftpre( rot dup >r )! + fftpre( r> )@ + then ; +\ in case not found addr is just the size +| : find-fft-cache ( n -- addr 0/1 ) + dup s>hash fftpre( swap )@ dup + begin while + 2dup gsl_fft_precomputes size @ = + if nip true exit then + gsl_fft_precomputes next @ dup + repeat ; + +legacy on + +\ Structures + +struct{ + cell name + cell max + cell min + cell size + cell set + cell get + cell get_double +} gsl_rng_type + +struct{ + cell type + cell state +} gsl_rng + +struct{ + cell size + cell data +} gsl_block + +struct{ + cell size + cell stride + cell data + cell block + cell owner +} gsl_vector + +' gsl_block alias gsl_permutation + +struct{ + cell size1 + cell size2 + cell tda + cell data + cell block + cell owner +} gsl_matrix + +\ random number generation functions +: 0-len dup 1- 0 begin 1+ 2dup + c@ 0= until nip ; +: )gsl-rng ( addr i -- *gsl_rng_type ) + cells + @ ; + +\ setting up all available random number generators +gsl_rng_types_setup value gsl_rng_array( +0 value gsl_rng_default +: gsl-free ( -- ) + gsl_rng_default gsl_rng_free ; + +: borosh13 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 0 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: cmrg ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 1 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: coveyou ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 2 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: fishman18 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 3 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: fishman20 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 4 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: fishman2x ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 5 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: gfsr4 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 6 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: knuthran ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 7 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: knuthran2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 8 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: lecuyer21 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 9 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: minstd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 10 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: mrg ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 11 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: mt19937 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 12 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: mt19937_1999 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 13 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: mt19937_1998 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 14 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: r250 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 15 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ran0 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 16 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ran1 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 17 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ran2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 18 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ran3 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 19 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: rand ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 20 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: rand48 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 21 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random128-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 22 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random128-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 23 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random128-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 24 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random256-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 25 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random256-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 26 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random256-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 27 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random32-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 28 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random32-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 29 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random32-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 30 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random64-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 31 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random64-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 32 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random64-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 33 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random8-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 34 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random8-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 35 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random8-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 36 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random-bsd ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 37 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random-glibc2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 38 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: random-libc5 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 39 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: randu ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 40 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranf ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 41 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlux ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 42 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlux389 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 43 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlxd1 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 44 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlxd2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 45 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlxs0 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 46 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlxs1 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 47 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranlxs2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 48 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: ranmar ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 49 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: slatec ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 50 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: taus ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 51 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: taus2 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 52 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: taus113 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 53 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: transputer ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 54 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: tt800 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 55 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: uni ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 56 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: uni32 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 57 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: vax ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 58 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: waterman14 ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 59 )gsl-rng gsl_rng_alloc to gsl_rng_default ; +: zuf ( -- *gsl_rng ) gsl_rng_default 0<> if gsl-free then + gsl_rng_array( 60 )gsl-rng gsl_rng_alloc to gsl_rng_default ; + +\ words for actual generation of random numbers +: gsl-randomg ( -- n ) + gsl_rng_default gsl_rng_get ; +: gsl-randomu /* -- f \in [0,1) */ + gsl_rng_default gsl_rng_uniform ; +: gsl-randomu+ /* -- f \in (0,1) */ + gsl_rng_default gsl_rng_uniform_pos ; +: gsl-random-up ( n -- f \in [0,n] ) + gsl_rng_default swap gsl_rng_uniform_int ; +: gsl-set-seed ( n -- ) + gsl_rng_default swap gsl_rng_set ; +: gsl-clone ( -- *gsl_rng ) + gsl_rng_default gsl_rng_clone ; +: gsl-gaussian ( -- df ) + gsl_rng_default !1 gsl_ran_gaussian ; +: gsl-discrete ( *gsl_ran_discrete -- n ) + gsl_rng_default swap gsl_ran_discrete ; + +\ vectors and matrices +0 constant GSL_VECTOR_TYPE +1 constant GSL_MATRIX_TYPE +: gsltypeof ' >body cell + @ ; + +: fvector ( n -- | -- id addr ) + create + gsl_vector_calloc , + GSL_VECTOR_TYPE , + does> @ ; + +\ allocate a nameless vector +: :] ( # -- addr ) gsl_vector_calloc ; +\ allocate a nameless matrix +: :]] ( # # -- addr ) gsl_matrix_calloc ; + +: ]@ ( addr i -- df ) gsl_vector_get ; +: ]! ( df addr i -- ) gsl_vector_set ; +: ]data ( addr -- *data ) gsl_vector data @ ; +: ]stride ( addr -- *data ) gsl_vector stride @ ; +: ]fill ( df addr -- ) gsl_vector_set_all ; +: ]erase ( addr -- ) gsl_vector_set_zero ; +: ]+ ( *gsl_vector *gsl_vector -- ) gsl_vector_add drop ; +: ]- ( *gsl_vector *gsl_vector -- ) gsl_vector_sub drop ; +: ]e*! ( *gsl_vector *gsl_vector -- ) gsl_vector_mul drop ; +: ]size ( *gsl_vector -- n ) gsl_vector size @ ; +: ]outer* ( *gsl_vector *gsl_vector -- *gsl_matrix ) + over ]size over ]size gsl_matrix_calloc dup >r !1 + gsl_blas_dger drop r> ; +\ no control for divizion by zero (I get segfaults) +: ]/ ( *gsl_vector *gsl_vector -- ) gsl_vector_div throw ; +: ]clone ( *gsl_vector -- *gsl_vector ) + dup gsl_vector size @ gsl_vector_alloc + dup -rot swap gsl_vector_memcpy drop ; + +: ]add ( *gsl_vector *gsl_vector -- *gsl_vector ) + ]clone dup -rot swap ]+ ; +: ]sub ( *gsl_vector *gsl_vector -- *gsl_vector ) + swap ]clone dup -rot swap ]- ; +: ]mul ( *gsl_vector *gsl_vector -- *gsl_vector ) + swap ]clone dup -rot swap ]e*! ; +: ]div ( *gsl_vector *gsl_vector -- *gsl_vector ) + swap ]clone dup -rot swap ]/ ; + +: ]*c ( df *gsl_vector -- ) gsl_vector_scale drop ; +: ]+c ( df *gsl_vector -- ) gsl_vector_add_constant drop ; +: ]max ( *gsl_vector -- ) gsl_vector_max ; +: ]min ( *gsl_vector -- ) gsl_vector_min ; +: ]imax ( *gsl_vector -- ) gsl_vector_max_index ; +: ]imin ( *gsl_vector -- ) gsl_vector_min_index ; +: ]copy] ( *gsl_vector_dest *gsl_vector_src -- ) gsl_vector_memcpy drop ; +: ]negate !-1.0 ]*c ; +: ]ones ( n -- *gsl_vector ) :] dup 1e ]fill ; + +: ]]slice ( *gsl_matrix x y n m -- *gsl_matrix ) + gsl_matrix_alloc_from_matrix ; +: ]slice ( *gsl_vector offset length stride -- *gsl_vector ) + gsl_vector_alloc_from_vector ; + +: ]null? ( *gsl_vector -- 0/-1 ) gsl_vector_isnull negate ; +: ]pos? ( *gsl_vector -- 0/-1 ) gsl_vector_ispos negate ; +: ]neg? ( *gsl_vector -- 0/-1 ) gsl_vector_isneg negate ; + +\ FFT 19jan08sp +: ]fft! ( *gsl_vector -- ) + dup ]size >r dup ]stride >r ]data r> r> + dup find-fft-cache if + dup gsl_fft_precomputes r_wavetable @ + swap gsl_fft_precomputes workspace @ + else + drop + dup cache-fft + dup gsl_fft_precomputes r_wavetable @ + swap gsl_fft_precomputes workspace @ + then + gsl_fft_real_transform throw ; +: ]fft ( *gsl_vector -- *gsl_vector ) + ]clone dup ]fft! ; +: ]ifft! ( *gsl_vector -- ) + dup ]size >r dup ]stride >r ]data r> r> + dup find-fft-cache if + dup gsl_fft_precomputes hc_wavetable @ + swap gsl_fft_precomputes workspace @ + else + drop + dup cache-fft + dup gsl_fft_precomputes hc_wavetable @ + swap gsl_fft_precomputes workspace @ + then + gsl_fft_hc_inverse throw ; +: ]ifft ( *gsl_vector -- *gsl_vector ) + ]clone dup ]ifft! ; +\ multiply two half complex vectors +\ store result in the first +: ]hc*! ( *gsl_vector *gsl_vector -- ) + 2dup 0 ]@ 0 ]@ f* over 0 ]! + dup ]size dup %1 and not + 1 do + 2dup + dup i ]@ i 1+ ]@ + dup i ]@ i 1+ ]@ z* + over dup i 1+ ]! i ]! + 2 +loop + dup ]size %1 and not if + 2dup + dup ]size 1- dup >r ]@ dup r@ ]@ f* r> ]! + then + 2drop ; + +\ pseudomatrices and vectors +: pvector ( *data n -- *gsl_vector ) + sizeof gsl_vector allocate throw + dup >r dup 1 swap gsl_vector stride ! + gsl_vector size ! r@ + gsl_vector data ! r@ + 0 swap gsl_vector owner ! r> ; + +: pmatrix! ( *data tda n m *pmatrix -- *gsl_matrix ) + dup >r gsl_matrix size2 ! + r@ gsl_matrix size1 ! + r@ gsl_matrix tda ! + r@ gsl_matrix data ! + 0 r@ gsl_matrix owner ! + r> ; + +: pmatrix ( *data tda n m -- *gsl_matrix ) + sizeof gsl_matrix allocate throw + dup 0 swap gsl_matrix owner ! + pmatrix! ; + +\ permutations + +: fpermutation ( n -- | -- id addr ) + create + gsl_permutation_calloc , + does> @ ; +: }@ ( *gsl_permutation i -- n ) gsl_permutation_get ; +: }data ( *gsl_permutation -- *data ) gsl_block data @ ; +: }size ( *gsl_permutation -- *data ) gsl_block size @ ; +: }free ( *gsl_permutation -- ) gsl_permutation_free ; +: }sign ( *gsl_permutation -- 1/-1 ) + 1 over dup }size 0 do + dup i }@ i <> if swap negate swap then + loop drop ; + +\ matrices + +: fmatrix ( n m -- | -- id addr ) + create + gsl_matrix_calloc , + GSL_MATRIX_TYPE , + does> @ ; + +: free_pseudomatrix ( pmatrix/pvector -- ) free throw ; + +create free_matrix ' free_pseudomatrix , ' gsl_matrix_free , +create free_vector ' free_pseudomatrix , ' gsl_vector_free , + +: ]]free ( *gsl_matrix -- ) + dup gsl_matrix owner @ + cells free_matrix + @ execute ; +: ]free ( addr -- ) + dup gsl_vector owner @ + cells free_vector + @ execute ; +: ]]@ ( *gsl_matrix i j -- df ) gsl_matrix_get ; +: ]]*@ ( *gsl_matrix i j -- *[i,j] ) gsl_matrix_ptr ; +: ]]! ( *gsl_matrix i j df -- ) gsl_matrix_set ; +: ]]fill ( addr df -- ) gsl_matrix_set_all ; +: ]]size1 gsl_matrix size1 @ ; +: ]]size2 gsl_matrix size2 @ ; +: ]]dim ( *gsl_matrix -- m n ) dup ]]size1 swap ]]size2 ; +: ]]dim. ( *gsl_matrix -- ) ]]dim swap . ." x" . cr ; +: ]]data ( *gsl_matrix -- addr) gsl_matrix data @ ; +: ]]tda gsl_matrix tda @ ; +: ]]block gsl_matrix block @ ; +: ]]owner gsl_matrix owner @ ; +: ]]copy]] ( *gsl_matrix_dest *gsl_matrix_src -- ) gsl_matrix_memcpy drop ; +: ]]'copy]] ( *gsl_matrix_dest *gsl_matrix_src -- ) gsl_matrix_transpose_memcpy drop ; +\ : ]]row ( *gsl_matrix idx -- *gsl_vector ) gsl_matrix_row ; +\ : ]]col ( *gsl_matrix idx -- *gsl_vector ) gsl_matrix_column ; +: ]]>] ( *gsl_vector *gsl_matrix i -- ) gsl_matrix_get_col drop ; +: ]]>]' ( *gsl_vector *gsl_matrix i -- ) gsl_matrix_get_row drop ; +: ]>]] ( *gsl_matrix *gsl_vector i -- ) swap gsl_matrix_set_col drop ; +: ]'>]] ( *gsl_matrix *gsl_vector i -- ) swap gsl_matrix_set_row drop ; + +: ]]max gsl_matrix_max ; +: ]]min gsl_matrix_min ; +: ]]add! ( *gsl_matrix *gsl_matrix -- ) + gsl_matrix_add drop ; +: ]]sub! ( *gsl_matrix *gsl_matrix -- ) + gsl_matrix_sub drop ; +: ]]e*! ( *gsl_matrix *gsl_matrix -- ) + gsl_matrix_mul_elements drop ; +: ]]*c ( *gsl_matrix df -- ) + gsl_matrix_scale drop ; +: ]]+c ( df *gsl_matrix -- ) gsl_matrix_add_constant drop ; +: ]]clone ( *gsl_matrix -- *gsl_matrix ) + dup dup gsl_matrix size1 @ swap gsl_matrix size2 @ + gsl_matrix_alloc + dup -rot swap gsl_matrix_memcpy drop ; +: ]]negate !-1.0 ]]*c ; + +: ]]+ ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + ]]clone dup -rot swap ]]add! ; + +: ]]- ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + swap ]]clone dup -rot swap ]]sub! ; +: ]]null? ( *gsl_matrix -- 0/-1 ) gsl_matrix_isnull negate ; +: ]]pos? ( *gsl_matrix -- 0/-1 ) gsl_matrix_ispos negate ; +: ]]neg? ( *gsl_matrix -- 0/-1 ) gsl_matrix_isneg negate ; + +\ blas + +\ constants +101 Constant CblasRowMajor +102 Constant CblasColMajor +111 Constant CblasNoTrans +112 Constant CblasTrans +113 Constant CblasConjTrans +121 Constant CblasUpper +122 Constant CblasLower +131 Constant CblasNonUnit +132 Constant CblasUnit +141 Constant CblasLeft +142 Constant CblasRight + +: action? ( *gsl_matrix *gsl_matrix n n n -- ) + dup 0= if + drop + 2swap 2dup + ]]size2 swap ]]size1 swap + exit + then + dup 1 = if + drop + 2swap 2dup + ]]size2 swap ]]size2 swap + exit + then + 2 = if + 2swap 2dup + ]]size1 swap ]]size1 swap + exit + then + 3 = if + 2swap 2dup + ]]size1 swap ]]size2 swap + exit + then ; + +create samemattable ' noop , ' ]]clone , +: samemat ( *gsl_matrix *gsl_matrix -- 1/0 *gsl_matrix ) + dup -rot = abs dup -rot cells samemattable + @ execute ; macro + +: ]]mul ( *gsl_matrix *gsl_matrix n n n -- *gsl_matrix ) + !1 !0 action? + gsl_matrix_alloc dup >r + gsl_blas_dgemm drop r> ; +: ]]* ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + 2dup samemat dup rot 2>r nip + CblasNoTrans CblasNoTrans 0 ]]mul + 2r> if ]]free else drop then ; +: ]]'* ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + 2dup samemat dup rot 2>r nip + CblasTrans CblasNoTrans 1 ]]mul + 2r> if ]]free else drop then ; +: ]]*' ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + 2dup samemat dup rot 2>r nip + CblasNoTrans CblasTrans 2 ]]mul + 2r> if ]]free else drop then ; +: ]]'*' ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + 2dup samemat dup rot 2>r nip + CblasTrans CblasTrans 3 ]]mul + 2r> if ]]free else drop then ; + +: ]]mul! ( n n *gsl_matrix *gsl_matrix *gsl_matrix -- ) + !1 !0 gsl_blas_dgemm drop ; +: ]]*! ( *gsl_matrix *gsl_matrix *gsl_matrix -- ) + >r CblasNoTrans CblasNoTrans 2swap r> ]]mul! ; +: ]]'*! ( *gsl_matrix *gsl_matrix *gsl_matrix -- ) + >r CblasTrans CblasNoTrans 2swap r> ]]mul! ; +: ]]*'! ( *gsl_matrix *gsl_matrix *gsl_matrix -- ) + >r CblasNoTrans CblasTrans 2swap r> ]]mul! ; + + +: ]]*] ( *gsl_matrix *gsl_vector -- *gsl_vector ) + over ]]size1 gsl_vector_alloc >r + CblasNoTrans -rot r@ !1 !0 gsl_blas_dgemv drop r> ; +: ]]'*] ( *gsl_matrix *gsl_vector -- *gsl_vector ) + over ]]size1 gsl_vector_alloc >r + CblasTrans -rot r@ !1 !0 gsl_blas_dgemv drop r> ; + +: ]]i ( *gsl_matrix -- ) + dup dup ]]size1 swap ]]size2 <> if + abort" ERROR: Not a square matrix!" + then + dup ]]size1 0 do + dup i i !1 ]]! + loop drop ; +: identity ( n -- *gsl_matrix ) + dup gsl_matrix_calloc dup ]]i ; +: min-identity ( *gsl_matrix -- *gsl_matrix ) + dup ]]size1 swap ]]size2 min identity ; +: left/right' ( *gsl_matrix *gsl_matrix -- *gsl_matrix ) + over ]]size1 over ]]size1 > if + swap ]]*' exit + else + ]]'* exit + then ; + +\ original matrix remains intact +: ]]' ( *gsl_matrix -- *gsl_matrix ) + dup min-identity dup >r + left/right' + r> ]]free ; +: ]]T! ( *gsl_matrix -- ) + gsl_matrix_transpose drop ; + +: ]]T ( *gsl_matrix -- *gsl_matrix ) + dup ]]dim swap gsl_matrix_alloc dup rot gsl_matrix_transpose_memcpy drop ; + +: ]]2T ( *gsl_matr *gsl_matrix -- ) + gsl_matrix_transpose_memcpy drop ; + +: ]]+! ( *gsl_matrix i j df -- ) >r 2dup r@ ]]@ f+ r> ]]! ; +: ]]scale! ( *gsl_matrix i j df -- ) >r 2dup r@ ]]@ f* r> ]]! ; +: ]]data_ij ( *gsl_matrix i j -- addr) + rot >r swap r@ ]]tda dfloats * swap dfloats + r> ]]data + ; +\ Cross product can be either calculated through determinant: +: ]x ( *gsl_vector *gsl_vector -- *gsl_vector ) + 3 gsl_vector_alloc + { x1[ x2[ x3[ | + x1[ 2 ]@ fnegate x2[ 1 ]@ f* x1[ 1 ]@ x2[ 2 ]@ f* f+ x3[ 0 ]! + x1[ 2 ]@ x2[ 0 ]@ f* x1[ 0 ]@ fnegate x2[ 2 ]@ f* f+ x3[ 1 ]! + x1[ 1 ]@ fnegate x2[ 0 ]@ f* x1[ 0 ]@ x2[ 1 ]@ f* f+ x3[ 2 ]! + x3[ } ; +\ or using algebraic form when first vector in the product is +\ rewritten in a matrix form: +\ a x b = [C_a] b +\ [ 0 -a[2] a[1] ] +\ [C_a] = [ a[2] 0 -a[0] ] +\ [-a[1] a[0] 0 ] +\ a function to convert a vector into such matrix: +: ]>[x] ( ] -- ]] ) + [IFDEF] debug + dup ]size 3 <> abort" Not a 3D vector!" + [THEN] + 3 3 :]] dup >r + swap 2dup 2 ]@ fdup dup fnegate 0 1 ]]! 1 0 ]]! + 2dup 1 ]@ fdup dup fnegate 2 0 ]]! 0 2 ]]! + 0 ]@ fdup dup fnegate 1 2 ]]! 2 1 ]]! r> ; +: ]. ( *gsl_vector *gsl_vector -- f:dot_product ) + { x1[ x2[ | + 0 0 sp@ x1[ x2[ rot gsl_blas_ddot drop fd>f } ; +: ]total ( *gsl_vector -- f:sum ) + dup ]size gsl_vector_alloc dup !1 ]fill dup rot ]. ]free ; +\ probability normalize - assures sum is unity +: ]pnormalize ( *gsl_vector - ) + dup ]total 1/f ]*c ; +: |]| ( *gsl_vector -- f:norm ) dup ]. fsqrt ; +\ assures vector norm is unity +: ]normalize ( *gsl_vector - ) + dup |]| 1/f ]*c ; +: ]distance ( *gsl-vector *gsl-vector -- f ) + ]sub dup |]| ]free ; +: ]+! ( *gsl_vector i df -- ) + 2dup ]@ f+ ]! ; +: ]*! ( *gsl_vector i df -- ) + 2dup ]@ f* ]! ; + +: ]]*]m ( *gsl_matrix *gsl_vector -- *gsl_vector ) + over ]]size1 gsl_vector_calloc + { m[[ x[ y[ | + m[[ ]]size1 0 do + m[[ ]]size2 0 do + m[[ j i ]]@ x[ i ]@ f* y[ j ]+! + loop + loop y[ } ; + +: >#rows ( -- ) + swap ]]size1 >= abort" number of rows is bigger than available!" ; +: >#cols ( -- ) + swap ]]size2 >= abort" number of columns is bigger than available!" ; + +: ]]row ( *gsl_matrix n -- *gsl_vector ) + 2dup >#rows + sizeof gsl_vector allocate throw + dup 1 swap gsl_vector stride ! >r + over ]]size2 r@ gsl_vector size ! + 0 ]]data_ij r@ gsl_vector data ! + 0 r@ gsl_vector owner ! r> ; +\ assumes all dimensions are set correctly +: ]]row! ( *gsl_vector *gsl_matrix n -- ) + rot >r 2dup >#rows 0 ]]data_ij r> gsl_vector data ! ; +: ]]col ( *gsl_matrix n -- *gsl_vector ) + 2dup >#cols + sizeof gsl_vector allocate throw >r + over ]]tda r@ gsl_vector stride ! + over ]]size1 r@ gsl_vector size ! + over ]]block r@ gsl_vector block ! + 0 swap ]]data_ij r@ gsl_vector data ! + 0 r@ gsl_vector owner ! r> ; +: ]]rfill ( f:n *gsl_matrix i -- ) ]]row dup ]fill ]free ; +: ]]cfill ( f:n *gsl_matrix i -- ) ]]col dup ]fill ]free ; + + +: ]]submat ( *gsl_matrix n1 n2 m1 m2 -- *gsl_matrix ) + { m[[ n1 n2 m1 m2 | + sizeof gsl_matrix allocate throw >r + n2 n1 - 1+ r@ gsl_matrix size1 ! + m2 m1 - 1+ r@ gsl_matrix size2 ! + m[[ n1 m1 ]]data_ij r@ gsl_matrix data ! + m[[ ]]tda r@ gsl_matrix tda ! + 0 r@ gsl_matrix owner ! r> } ; + +: ?square ( *gsl_matrix -- ) + dup ]]size1 swap ]]size2 <> abort" ERROR: Not a square matrix!" ; +: ]]diag ( *gsl_matrix n1 n2 -- *gsl_vector ) + rot dup ?square -rot + sizeof gsl_vector allocate throw { d[ | + over - d[ gsl_vector size ! + 2dup dup ]]data_ij d[ gsl_vector data ! drop + dup ]]tda d[ gsl_vector stride ! + ]]block d[ gsl_vector block ! + 0 d[ gsl_vector owner ! + d[ } ; + +\ with input matrix replaced by the result +: ]]gsl-svd ( *gsl_matrix -- *gsl_matrix *gsl_vector ) + dup ]]size2 dup dup gsl_matrix_calloc + swap dup gsl_vector_calloc swap + gsl_vector_calloc + { mV vS vW | + mV vS vW gsl_linalg_SV_decomp drop + vW ]free + mV vS } ; +\ seems to be 30% faster +: ]]gsl-svdm ( *gsl_matrix -- *gsl_matrix *gsl_vector ) + dup ]]size2 dup ( a n n -- ) + dup dup gsl_matrix_calloc swap ( a n a n -- ) + dup gsl_matrix_calloc rot dup ( a a a n n -- ) + gsl_vector_calloc swap + gsl_vector_calloc + { mX mV vS vW | + mX mV vS vW gsl_linalg_SV_decomp_mod drop + vW ]free mX ]]free + mV vS } ; + + +: ]]alu ( *gsl_matrix -- *gsl_permutation ) ( matrix replaced with its lu ) + { a[[ | + CblasRowMajor a[[ ]]size1 a[[ ]]size2 a[[ ]]data a[[ ]]size1 dup + gsl_permutation_alloc dup >r }data + clapack_dgetrf throw r> } ; +: ]]ainv ( *gsl_matrix *gsl_permutation -- ) + \ LU of a matrix replaced with its inverse + { a[[ t{ | + CblasRowMajor a[[ ]]size2 a[[ ]]data a[[ ]]size1 t{ }data + clapack_dgetri throw } ; +: ]]ainvert ( *gsl_matrix -- *gsl_matrix ) + [IFDEF] отладка + dup ?square + [THEN] + ]]clone dup dup >r ]]alu dup >r ]]ainv r> }free r> ; +: ]]det ( *gsl_matrix -- f:determinant ) + [IFDEF] отладка + dup ?square + [THEN] + ]]clone dup ]]alu >r 1e0 + dup ]]size1 0 do dup i dup ]]@ f* loop ]]free + \ compute permutation sign + r> }sign s>f f* }free ; +\ calculates the work needed for dgesvd_ ( see man dgesvd ) +: lwork ( m n -- c ) + 2dup max -rot min 3 * over + swap 5 * max ; +\ this svd returns U MxM so eats a lot of memory +: ]]asvda ( *gsl_matrix -- *gsl_matrix *gsl_matrix *gsl_vector ) + ]]clone { A[[ | + A[[ ]]size1 dup gsl_matrix_alloc + A[[ ]]size2 dup gsl_matrix_alloc + A[[ ]]size1 A[[ ]]size2 min gsl_vector_alloc + 8 cells allocate throw + { U[[ V[[ W[ p[ | + ascii A p[ 0 cells + ! p[ 0 cells + + ascii A p[ 1 cells + ! p[ 1 cells + + A[[ ]]size1 p[ 2 cells + ! p[ 2 cells + + A[[ ]]size2 p[ 3 cells + ! p[ 3 cells + + A[[ ]]data + p[ 2 cells + + W[ ]data + U[[ ]]data + U[[ ]]size1 p[ 4 cells + ! p[ 4 cells + + V[[ ]]data + V[[ ]]size1 p[ 5 cells + ! p[ 5 cells + + A[[ ]]size1 A[[ ]]size2 lwork + dup gsl_vector_alloc dup >r + ]data swap p[ 6 cells + ! p[ 6 cells + + p[ 7 cells + + dgesvd_ + r> ]free p[ free throw A[[ ]]free + U[[ V[[ W[ } } ; + +\ performs A=U*S*V^T +\ A = MxN, where M>N, pass it A^T +\ returns U^T (MxN), V(NxN) and vector of N eigenvalues +: ]]asvdO ( *gsl_matrix -- *gsl_matrix *gsl_matrix *gsl_vector ) + { A[[ | + A[[ ]]size2 A[[ ]]size1 min dup gsl_matrix_alloc + A[[ ]]size1 A[[ ]]size2 min gsl_vector_alloc + 8 cells allocate throw + { V[[ W[ p[ | + ascii O p[ 0 cells + ! p[ 0 cells + + ascii S p[ 1 cells + ! p[ 1 cells + + A[[ ]]size2 p[ 2 cells + ! p[ 2 cells + + A[[ ]]size1 p[ 3 cells + ! p[ 3 cells + + A[[ ]]data + p[ 2 cells + + W[ ]data + 0 + p[ 2 cells + + V[[ ]]data + V[[ ]]size2 p[ 5 cells + ! p[ 5 cells + + A[[ ]]size2 A[[ ]]size1 lwork + dup gsl_vector_alloc dup >r + ]data swap p[ 6 cells + ! p[ 6 cells + + p[ 7 cells + + dgesvd_ + r> ]free p[ free throw + A[[ V[[ W[ } } ; + + +: ]diag[[ ( *gsl_vector -- *gsl_matrix ) + dup ]size dup dup gsl_matrix_calloc swap + 0 do + 2dup swap i ]@ i i ]]! + loop nip ; + +: ]print\ ( *gsl_vector -- ) + dup ]size 0 do dup i ]@ fx. loop drop ; +: ]print ( *gsl_vector -- ) ]print\ cr ; +: ]]print ( *gsl_matrix -- ) + cr precision swap + 5 set-precision + dup ]]size1 0 do + \ i . ." : " + dup ]]size2 0 do + dup + j i ]]@ fs. + loop + cr + loop + drop set-precision ; +: ]]row-print ( *gsl_matrix i -- ) + cr + over gsl_matrix size2 @ 0 do + 2dup + i ]]@ f. + loop + cr 2drop ; + +: ]]col-print ( *gsl_matrix i -- ) + cr + over gsl_matrix size1 @ 0 do + 2dup + i swap ]]@ f. + loop + cr 2drop ; + +: ]]nthrow ( *gsl_matrix n -- addr ) + over ]]tda * dfloats swap ]]data + ; + +: ]]randomize ( *gsl_matrix -- ) + dup dup ]]size1 swap ]]size2 * 0 do + dup + gsl-randomu + ]]data i dfloats + df! + loop drop ; +: ]randomize ( *gsl_vector -- ) + dup ]size 0 do + dup + gsl-randomu + i ]! + loop drop ; +: ]mean ( *gsl_vector -- f ) + dup ]stride swap dup ]size swap ]data + rot rot gsl_stats_mean ; + +: ]variance ( *gsl_vector -- f ) + dup ]stride swap dup ]size swap ]data + rot rot gsl_stats_variance ; + +: ]sd ( *gsl_vector -- f ) + dup ]stride swap dup ]size swap ]data + rot rot gsl_stats_sd ; + +: ]skew ( *gsl_vector -- f ) + dup ]stride swap dup ]size swap ]data + rot rot gsl_stats_skew ; + +: ]kurtosis ( *gsl_vector -- f ) + dup ]stride swap dup ]size swap ]data + rot rot gsl_stats_kurtosis ; + +: ]]gsl-lu ( *gsl_matrix -- *gsl_matrix *gsl_permutation ) + 1 sp@ rot ]]clone dup >r dup ]]size1 gsl_permutation_calloc dup >r rot + gsl_linalg_LU_decomp drop r> r> swap rot drop ; + +: ]]gsl-invert ( *gsl_matrix -- *gsl_matrix ) + ]]clone dup dup ]]gsl-lu 2dup >r >r rot + gsl_linalg_LU_invert drop r> ]]free r> }free ; + +' ]]ainvert alias ]]invert +' ]]asvdO alias ]]svd + +: ]]save ( *gsl_matrix *gsl_matrix_cfa fid -- ) + -rot { m[[ name[[ | + >r + name[[ >name count 1+ nip 0 m[[ ]]size2 m[[ ]]size1 0 + sp@ 5 cells r@ write-file throw + 2drop 2drop drop + name[[ >name count 1+ r@ write-file throw + m[[ ]]size1 m[[ ]]size2 * dfloats m[[ ]]T dup s>f ]]data swap + r> write-file throw f>s ]]free } ; + +\ these words do not work with float matrices but are needed for +\ scientific calculations, that's why they are in this module + +: _hmatrix ( n m size -- addr ) + rot over * 2 pick * [ 2 cells ] literal + + allocate throw dup [ 2 cells ] literal + >r + rot over ! [ 1 cells ] literal + ! r> ; +: hmatrix ( n m size -- ) + create + rot over * 2 pick * [ 2 cells ] literal + allocate throw dup , + rot over ! [ 1 cells ] literal + ! + does> @ [ 2 cells ] literal + ; +: }}row-size ( hmatrix -- ) [ 2 cells ] literal - @ ; +: freeHmatrix ( hmatrix -- ) [ 2 cells ] literal - free throw ; +: }} ( addr i j -- addr[i][j] ) \ word to fetch 2-D array addresses + >R >R \ indices to return stack temporarily + DUP CELL- CELL- 2@ \ &a[0][0] size m + R> * R> + * + + + ALIGNED ; +: h->[[ ( hmatrix -- gsl_matrix ) + dup }}row-size 3 swap gsl_matrix_alloc + dup ]]size2 0 do + 3 0 do + 2dup swap i j }} w@ s>f i j ]]! + loop + loop nip ; + +\ some sequencing code +: arange ( f:start f:end f:step -- x[ ) + f-rot + fswap fdup f>r f- fover f/ f>s :] fr> + dup ]size 0 do + dup fover i s>f f* fover f+ i ]! + loop ; +: product ( x[ -- f:P ) + !1 dup ]size 0 do + dup i ]@ f* + loop drop ; + +\ initializing random number generator to some value in order to have +\ it available upon loading of gsl +mt19937 +: )randperm ( *v( -- ) + gsl_rng_default swap + dup )size over )type 8 / gsl_ran_shuffle ; + +previous previous previous previous previous + +Module; diff --git a/include/mgl2/mathgl.fs b/include/mgl2/mathgl.fs new file mode 100644 index 0000000..bbc3fd8 --- /dev/null +++ b/include/mgl2/mathgl.fs @@ -0,0 +1,472 @@ +Module mathgl +also dos + +library libmgl libmgl.so +library libmgl-glut libmgl-glut.so +library libmgl-fltk libmgl-fltk.so +library libmgl-qt libmgl-qt.so +library libmgl-wx libmgl-wx.so + +legacy off + +libmgl mgl_create_graph_gl (ptr) mgl_create_graph_gl +libmgl mgl_create_graph_zb int int (ptr) mgl_create_graph_zb +libmgl mgl_create_graph_ps int int (ptr) mgl_create_graph_ps +libmgl mgl_fortran_func ptr ptr (int) mgl_fortran_func +libmgl-glut mgl_create_graph_glut ptr ptr ptr (ptr) mgl_create_graph_glut +libmgl-fltk mgl_create_graph_fltk ptr ptr ptr (ptr) mgl_create_graph_fltk +libmgl-qt mgl_create_graph_qt ptr ptr ptr (ptr) mgl_create_graph_qt +\ libmgl-glut mgl_create_graph_glut_dr ptr ptr (ptr) mgl_create_graph_glut_dr +\ libmgl-fltk mgl_create_graph_fltk_dr ptr ptr (ptr) mgl_create_graph_fltk_dr +\ libmgl-qt mgl_create_graph_qt_dr ptr ptr (ptr) mgl_create_graph_qt_dr +libmgl mgl_create_graph_idtf (ptr) mgl_create_graph_idtf +libmgl-fltk mgl_fltk_run (void) mgl_fltk_run +libmgl-qt mgl_qt_run (void) mgl_qt_run +libmgl mgl_set_show_mouse_pos int ptr (void) mgl_set_show_mouse_pos +libmgl mgl_get_last_mouse_pos sf sf sf ptr (void) mgl_get_last_mouse_pos +libmgl mgl_update ptr (void) mgl_update +libmgl mgl_delete_graph ptr (void) mgl_delete_graph +libmgl mgl_create_data (ptr) mgl_create_data +libmgl mgl_create_data_size int int int (ptr) mgl_create_data_size +libmgl mgl_create_data_file ptr (ptr) mgl_create_data_file +libmgl mgl_delete_data ptr (void) mgl_delete_data +libmgl mgl_create_parser (ptr) mgl_create_parser +libmgl mgl_delete_parser ptr (void) mgl_delete_parser +libmgl mgl_add_param ptr int ptr (void) mgl_add_param +libmgl mgl_add_paramw ptr int ptr (void) mgl_add_paramw +libmgl mgl_add_var ptr ptr (ptr) mgl_add_var +libmgl mgl_find_var ptr ptr (ptr) mgl_find_var +libmgl mgl_parse int ptr ptr ptr (int) mgl_parse +libmgl mgl_parsew int ptr ptr ptr (int) mgl_parsew +libmgl mgl_parse_text ptr ptr ptr (void) mgl_parse_text +libmgl mgl_parsew_text ptr ptr ptr (void) mgl_parsew_text +libmgl mgl_restore_once ptr (void) mgl_restore_once +libmgl mgl_parser_allow_setsize int ptr (void) mgl_parser_allow_setsize +libmgl mgl_set_def_param ptr (void) mgl_set_def_param +libmgl mgl_set_palette ptr ptr (void) mgl_set_palette +libmgl mgl_set_pal_color sf sf sf int ptr (void) mgl_set_pal_color +libmgl mgl_set_pal_num int ptr (void) mgl_set_pal_num +libmgl mgl_set_rotated_text int ptr (void) mgl_set_rotated_text +libmgl mgl_set_cut int ptr (void) mgl_set_cut +libmgl mgl_set_cut_box sf sf sf sf sf sf ptr (void) mgl_set_cut_box +libmgl mgl_set_tick_len sf ptr (void) mgl_set_tick_len +libmgl mgl_set_bar_width sf ptr (void) mgl_set_bar_width +libmgl mgl_set_base_line_width sf ptr (void) mgl_set_base_line_width +libmgl mgl_set_mark_size sf ptr (void) mgl_set_mark_size +libmgl mgl_set_arrow_size sf ptr (void) mgl_set_arrow_size +libmgl mgl_set_font_size sf ptr (void) mgl_set_font_size +libmgl mgl_set_font_def ptr ptr (void) mgl_set_font_def +libmgl mgl_set_alpha_default sf ptr (void) mgl_set_alpha_default +libmgl mgl_set_size int int ptr (void) mgl_set_size +libmgl mgl_set_axial_dir ptr ptr (void) mgl_set_axial_dir +libmgl mgl_set_meshnum int ptr (void) mgl_set_meshnum +libmgl mgl_set_zoom sf sf sf sf ptr (void) mgl_set_zoom +libmgl mgl_set_plotfactor sf ptr (void) mgl_set_plotfactor +libmgl mgl_set_draw_face int ptr (void) mgl_set_draw_face +libmgl mgl_set_scheme ptr ptr (void) mgl_set_scheme +libmgl mgl_load_font ptr ptr ptr (void) mgl_load_font +libmgl mgl_copy_font ptr ptr (void) mgl_copy_font +libmgl mgl_restore_font ptr (void) mgl_restore_font +libmgl mgl_show_image int ptr ptr (void) mgl_show_image +libmgl mgl_write_frame ptr ptr ptr (void) mgl_write_frame +libmgl mgl_write_bmp ptr ptr ptr (void) mgl_write_bmp +libmgl mgl_write_jpg ptr ptr ptr (void) mgl_write_jpg +libmgl mgl_write_png ptr ptr ptr (void) mgl_write_png +libmgl mgl_write_png_solid ptr ptr ptr (void) mgl_write_png_solid +libmgl mgl_write_eps ptr ptr ptr (void) mgl_write_eps +libmgl mgl_write_svg ptr ptr ptr (void) mgl_write_svg +libmgl mgl_write_idtf ptr ptr ptr (void) mgl_write_idtf +libmgl mgl_write_gif ptr ptr ptr (void) mgl_write_gif +libmgl mgl_start_gif int ptr ptr (void) mgl_start_gif +libmgl mgl_close_gif ptr (void) mgl_close_gif +libmgl mgl_get_rgb ptr (ptr) mgl_get_rgb +libmgl mgl_get_rgba ptr (ptr) mgl_get_rgba +libmgl mgl_get_width ptr (int) mgl_get_width +libmgl mgl_get_height ptr (int) mgl_get_height +libmgl mgl_new_frame ptr (int) mgl_new_frame +libmgl mgl_end_frame ptr (void) mgl_end_frame +libmgl mgl_get_num_frame ptr (int) mgl_get_num_frame +libmgl mgl_reset_frames ptr (void) mgl_reset_frames +libmgl mgl_set_transp_type int ptr (void) mgl_set_transp_type +libmgl mgl_set_transp int ptr (void) mgl_set_transp +libmgl mgl_set_alpha int ptr (void) mgl_set_alpha +libmgl mgl_set_fog sf sf ptr (void) mgl_set_fog +libmgl mgl_set_light int ptr (void) mgl_set_light +libmgl mgl_set_light_n int int ptr (void) mgl_set_light_n +libmgl mgl_add_light ptr sf sf sf int ptr (void) mgl_add_light +libmgl mgl_add_light_rgb sf sf sf sf int sf sf sf int ptr (void) mgl_add_light_rgb +libmgl mgl_set_ambbr sf ptr (void) mgl_set_ambbr +libmgl mgl_identity ptr (void) mgl_identity +libmgl mgl_clf ptr (void) mgl_clf +libmgl mgl_flush ptr (void) mgl_flush +libmgl mgl_clf_rgb sf sf sf ptr (void) mgl_clf_rgb +libmgl mgl_subplot int int int ptr (void) mgl_subplot +libmgl mgl_subplot_d sf sf int int int ptr (void) mgl_subplot_d +libmgl mgl_inplot sf sf sf sf ptr (void) mgl_inplot +libmgl mgl_relplot sf sf sf sf ptr (void) mgl_relplot +libmgl mgl_columnplot int int ptr (void) mgl_columnplot +libmgl mgl_aspect sf sf sf ptr (void) mgl_aspect +libmgl mgl_rotate sf sf sf ptr (void) mgl_rotate +libmgl mgl_rotate_vector sf sf sf sf ptr (void) mgl_rotate_vector +libmgl mgl_perspective sf ptr (void) mgl_perspective +libmgl mgl_set_ticks sf sf sf ptr (void) mgl_set_ticks +libmgl mgl_set_subticks int int int ptr (void) mgl_set_subticks +libmgl mgl_set_ticks_dir sf int sf ptr ptr (void) mgl_set_ticks_dir +\ libmgl mgl_set_ticks_val ... ptr double val int ptr ptr (void) mgl_set_ticks_val +libmgl mgl_set_ticks_vals ptr sf int ptr ptr (void) mgl_set_ticks_vals +libmgl mgl_set_caxis sf sf ptr (void) mgl_set_caxis +libmgl mgl_set_axis sf sf sf sf sf sf sf sf sf ptr (void) mgl_set_axis +libmgl mgl_set_axis_3d sf sf sf sf sf sf ptr (void) mgl_set_axis_3d +libmgl mgl_set_axis_2d sf sf sf sf ptr (void) mgl_set_axis_2d +libmgl mgl_set_origin sf sf sf ptr (void) mgl_set_origin +libmgl mgl_set_tick_origin sf sf sf ptr (void) mgl_set_tick_origin +libmgl mgl_set_crange int ptr ptr (void) mgl_set_crange +libmgl mgl_set_xrange int ptr ptr (void) mgl_set_xrange +libmgl mgl_set_yrange int ptr ptr (void) mgl_set_yrange +libmgl mgl_set_zrange int ptr ptr (void) mgl_set_zrange +libmgl mgl_set_auto sf sf sf sf sf sf ptr (void) mgl_set_auto +libmgl mgl_set_func ptr ptr ptr ptr (void) mgl_set_func +libmgl mgl_set_ternary int ptr (void) mgl_set_ternary +libmgl mgl_set_cutoff ptr ptr (void) mgl_set_cutoff +libmgl mgl_box int ptr (void) mgl_box +libmgl mgl_box_str int ptr ptr (void) mgl_box_str +libmgl mgl_box_rgb int sf sf sf ptr (void) mgl_box_rgb +libmgl mgl_axis ptr ptr (void) mgl_axis +libmgl mgl_axis_grid ptr ptr ptr (void) mgl_axis_grid +libmgl mgl_label ptr ptr ptr (void) mgl_label +libmgl mgl_label_ext sf sf int ptr ptr ptr (void) mgl_label_ext +libmgl mgl_tune_ticks sf int ptr (void) mgl_tune_ticks +libmgl mgl_set_xttw ptr ptr (void) mgl_set_xttw +libmgl mgl_set_yttw ptr ptr (void) mgl_set_yttw +libmgl mgl_set_zttw ptr ptr (void) mgl_set_zttw +libmgl mgl_set_cttw ptr ptr (void) mgl_set_cttw +libmgl mgl_set_xtt ptr ptr (void) mgl_set_xtt +libmgl mgl_set_ytt ptr ptr (void) mgl_set_ytt +libmgl mgl_set_ztt ptr ptr (void) mgl_set_ztt +libmgl mgl_set_ctt ptr ptr (void) mgl_set_ctt +libmgl mgl_ball sf sf sf ptr (void) mgl_ball +libmgl mgl_ball_rgb sf sf sf sf sf sf sf ptr (void) mgl_ball_rgb +libmgl mgl_ball_str ptr sf sf sf ptr (void) mgl_ball_str +libmgl mgl_line int ptr sf sf sf sf sf sf ptr (void) mgl_line +libmgl mgl_facex sf sf ptr sf sf sf sf sf ptr (void) mgl_facex +libmgl mgl_facey sf sf ptr sf sf sf sf sf ptr (void) mgl_facey +libmgl mgl_facez sf sf ptr sf sf sf sf sf ptr (void) mgl_facez +libmgl mgl_curve int ptr sf sf sf sf sf sf sf sf sf sf sf sf ptr (void) mgl_curve +libmgl mgl_puts ptr sf sf sf ptr (void) mgl_puts +libmgl mgl_putsw ptr sf sf sf ptr (void) mgl_putsw +libmgl mgl_puts_dir sf ptr sf sf sf sf sf sf ptr (void) mgl_puts_dir +libmgl mgl_putsw_dir sf ptr sf sf sf sf sf sf ptr (void) mgl_putsw_dir +libmgl mgl_text ptr sf sf sf ptr (void) mgl_text +libmgl mgl_title sf ptr ptr ptr (void) mgl_title +libmgl mgl_titlew sf ptr ptr ptr (void) mgl_titlew +libmgl mgl_putsw_ext ptr sf ptr ptr sf sf sf ptr (void) mgl_putsw_ext +libmgl mgl_puts_ext ptr sf ptr ptr sf sf sf ptr (void) mgl_puts_ext +libmgl mgl_text_ext ptr sf ptr ptr sf sf sf ptr (void) mgl_text_ext +libmgl mgl_colorbar int ptr ptr (void) mgl_colorbar +libmgl mgl_colorbar_ext sf sf sf sf int ptr ptr (void) mgl_colorbar_ext +libmgl mgl_simple_plot ptr int ptr ptr (void) mgl_simple_plot +libmgl mgl_add_legend ptr ptr ptr (void) mgl_add_legend +libmgl mgl_add_legendw ptr ptr ptr (void) mgl_add_legendw +libmgl mgl_clear_legend ptr (void) mgl_clear_legend +libmgl mgl_legend_xy sf sf ptr sf sf ptr (void) mgl_legend_xy +libmgl mgl_legend sf sf ptr int ptr (void) mgl_legend +libmgl mgl_set_legend_box int ptr (void) mgl_set_legend_box +libmgl mgl_fplot int ptr ptr ptr (void) mgl_fplot +libmgl mgl_fplot_xyz int ptr ptr ptr ptr ptr (void) mgl_fplot_xyz +libmgl mgl_plot_xyz ptr ptr ptr ptr ptr (void) mgl_plot_xyz +libmgl mgl_plot_xy ptr ptr ptr ptr (void) mgl_plot_xy +libmgl mgl_plot ptr ptr ptr (void) mgl_plot +libmgl mgl_plot_2 ptr ptr ptr (void) mgl_plot_2 +libmgl mgl_plot_3 ptr ptr ptr (void) mgl_plot_3 +libmgl mgl_tens_xyz ptr ptr ptr ptr ptr ptr (void) mgl_tens_xyz +libmgl mgl_tens_xy ptr ptr ptr ptr ptr (void) mgl_tens_xy +libmgl mgl_tens ptr ptr ptr ptr (void) mgl_tens +libmgl mgl_area_xyz ptr ptr ptr ptr ptr (void) mgl_area_xyz +libmgl mgl_area_xy ptr ptr ptr ptr (void) mgl_area_xy +libmgl mgl_area_xys ptr ptr ptr ptr (void) mgl_area_xys +libmgl mgl_area ptr ptr ptr (void) mgl_area +libmgl mgl_area_2 ptr ptr ptr (void) mgl_area_2 +libmgl mgl_area_3 ptr ptr ptr (void) mgl_area_3 +libmgl mgl_region_xy int ptr ptr ptr ptr ptr (void) mgl_region_xy +libmgl mgl_region int ptr ptr ptr ptr (void) mgl_region +libmgl mgl_mark ptr sf sf sf ptr (void) mgl_mark +libmgl mgl_stem_xyz ptr ptr ptr ptr ptr (void) mgl_stem_xyz +libmgl mgl_stem_xy ptr ptr ptr ptr (void) mgl_stem_xy +libmgl mgl_stem ptr ptr ptr (void) mgl_stem +libmgl mgl_stem_2 ptr ptr ptr (void) mgl_stem_2 +libmgl mgl_stem_3 ptr ptr ptr (void) mgl_stem_3 +libmgl mgl_step_xyz ptr ptr ptr ptr ptr (void) mgl_step_xyz +libmgl mgl_step_xy ptr ptr ptr ptr (void) mgl_step_xy +libmgl mgl_step ptr ptr ptr (void) mgl_step +libmgl mgl_step_2 ptr ptr ptr (void) mgl_step_2 +libmgl mgl_step_3 ptr ptr ptr (void) mgl_step_3 +libmgl mgl_bars_xyz ptr ptr ptr ptr ptr (void) mgl_bars_xyz +libmgl mgl_bars_xy ptr ptr ptr ptr (void) mgl_bars_xy +libmgl mgl_bars ptr ptr ptr (void) mgl_bars +libmgl mgl_bars_2 ptr ptr ptr (void) mgl_bars_2 +libmgl mgl_bars_3 ptr ptr ptr (void) mgl_bars_3 +libmgl mgl_barh_yx ptr ptr ptr ptr (void) mgl_barh_yx +libmgl mgl_barh ptr ptr ptr (void) mgl_barh +libmgl mgl_torus ptr ptr ptr ptr (void) mgl_torus +libmgl mgl_torus_2 ptr ptr ptr (void) mgl_torus_2 +libmgl mgl_text_xyz sf ptr ptr ptr ptr ptr ptr (void) mgl_text_xyz +libmgl mgl_text_xy sf ptr ptr ptr ptr ptr (void) mgl_text_xy +libmgl mgl_text_y sf ptr ptr ptr ptr (void) mgl_text_y +libmgl mgl_chart ptr ptr ptr (void) mgl_chart +libmgl mgl_error ptr ptr ptr ptr (void) mgl_error +libmgl mgl_error_xy ptr ptr ptr ptr ptr (void) mgl_error_xy +libmgl mgl_error_exy ptr ptr ptr ptr ptr ptr (void) mgl_error_exy +libmgl mgl_mark_xyz ptr ptr ptr ptr ptr ptr (void) mgl_mark_xyz +libmgl mgl_mark_xy ptr ptr ptr ptr ptr (void) mgl_mark_xy +libmgl mgl_mark_y ptr ptr ptr ptr (void) mgl_mark_y +libmgl mgl_tube_xyzr ptr ptr ptr ptr ptr ptr (void) mgl_tube_xyzr +libmgl mgl_tube_xyr ptr ptr ptr ptr ptr (void) mgl_tube_xyr +libmgl mgl_tube_r ptr ptr ptr ptr (void) mgl_tube_r +libmgl mgl_tube_xyz ptr sf ptr ptr ptr ptr (void) mgl_tube_xyz +libmgl mgl_tube_xy ptr sf ptr ptr ptr (void) mgl_tube_xy +libmgl mgl_tube ptr sf ptr ptr (void) mgl_tube +libmgl mgl_textmark_xyzr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmark_xyzr +libmgl mgl_textmark_xyr ptr ptr ptr ptr ptr ptr (void) mgl_textmark_xyr +libmgl mgl_textmark_yr ptr ptr ptr ptr ptr (void) mgl_textmark_yr +libmgl mgl_textmark ptr ptr ptr ptr (void) mgl_textmark +libmgl mgl_textmarkw_xyzr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmarkw_xyzr +libmgl mgl_textmarkw_xyr ptr ptr ptr ptr ptr ptr (void) mgl_textmarkw_xyr +libmgl mgl_textmarkw_yr ptr ptr ptr ptr ptr (void) mgl_textmarkw_yr +libmgl mgl_textmarkw ptr ptr ptr ptr (void) mgl_textmarkw +libmgl mgl_fsurf int ptr ptr ptr (void) mgl_fsurf +libmgl mgl_fsurf_xyz int ptr ptr ptr ptr ptr (void) mgl_fsurf_xyz +libmgl mgl_grid_xy sf ptr ptr ptr ptr ptr (void) mgl_grid_xy +libmgl mgl_grid sf ptr ptr ptr (void) mgl_grid +libmgl mgl_mesh_xy ptr ptr ptr ptr ptr (void) mgl_mesh_xy +libmgl mgl_mesh ptr ptr ptr (void) mgl_mesh +libmgl mgl_fall_xy ptr ptr ptr ptr ptr (void) mgl_fall_xy +libmgl mgl_fall ptr ptr ptr (void) mgl_fall +libmgl mgl_belt_xy ptr ptr ptr ptr ptr (void) mgl_belt_xy +libmgl mgl_belt ptr ptr ptr (void) mgl_belt +libmgl mgl_surf_xy ptr ptr ptr ptr ptr (void) mgl_surf_xy +libmgl mgl_surf ptr ptr ptr (void) mgl_surf +libmgl mgl_dens_xy sf ptr ptr ptr ptr ptr (void) mgl_dens_xy +libmgl mgl_dens sf ptr ptr ptr (void) mgl_dens +libmgl mgl_boxs_xy sf ptr ptr ptr ptr ptr (void) mgl_boxs_xy +libmgl mgl_boxs sf ptr ptr ptr (void) mgl_boxs +libmgl mgl_tile_xy ptr ptr ptr ptr ptr (void) mgl_tile_xy +libmgl mgl_tile ptr ptr ptr (void) mgl_tile +libmgl mgl_tiles_xy ptr ptr ptr ptr ptr ptr (void) mgl_tiles_xy +libmgl mgl_tiles ptr ptr ptr ptr (void) mgl_tiles +libmgl mgl_cont_xy_val sf ptr ptr ptr ptr ptr ptr (void) mgl_cont_xy_val +libmgl mgl_cont_val sf ptr ptr ptr ptr (void) mgl_cont_val +libmgl mgl_cont_xy sf int ptr ptr ptr ptr ptr (void) mgl_cont_xy +libmgl mgl_cont sf int ptr ptr ptr (void) mgl_cont +libmgl mgl_contf_xy_val sf ptr ptr ptr ptr ptr ptr (void) mgl_contf_xy_val +libmgl mgl_contf_val sf ptr ptr ptr ptr (void) mgl_contf_val +libmgl mgl_contf_xy sf int ptr ptr ptr ptr ptr (void) mgl_contf_xy +libmgl mgl_contf sf int ptr ptr ptr (void) mgl_contf +libmgl mgl_axial_xy_val ptr ptr ptr ptr ptr ptr (void) mgl_axial_xy_val +libmgl mgl_axial_val ptr ptr ptr ptr (void) mgl_axial_val +libmgl mgl_axial_xy int ptr ptr ptr ptr ptr (void) mgl_axial_xy +libmgl mgl_axial int ptr ptr ptr (void) mgl_axial +libmgl mgl_surfc_xy ptr ptr ptr ptr ptr ptr (void) mgl_surfc_xy +libmgl mgl_surfc ptr ptr ptr ptr (void) mgl_surfc +libmgl mgl_surfa_xy ptr ptr ptr ptr ptr ptr (void) mgl_surfa_xy +libmgl mgl_surfa ptr ptr ptr ptr (void) mgl_surfa +libmgl mgl_stfa_xy sf ptr int ptr ptr ptr ptr ptr (void) mgl_stfa_xy +libmgl mgl_stfa sf ptr int ptr ptr ptr (void) mgl_stfa +libmgl mgl_vect_xy sf ptr ptr ptr ptr ptr ptr (void) mgl_vect_xy +libmgl mgl_vect_2d sf ptr ptr ptr ptr (void) mgl_vect_2d +libmgl mgl_vectl_xy sf ptr ptr ptr ptr ptr ptr (void) mgl_vectl_xy +libmgl mgl_vectl_2d sf ptr ptr ptr ptr (void) mgl_vectl_2d +libmgl mgl_vectc_xy sf ptr ptr ptr ptr ptr ptr (void) mgl_vectc_xy +libmgl mgl_vectc_2d sf ptr ptr ptr ptr (void) mgl_vectc_2d +libmgl mgl_vect_xyz ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_vect_xyz +libmgl mgl_vect_3d ptr ptr ptr ptr ptr (void) mgl_vect_3d +libmgl mgl_vectl_xyz ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_vectl_xyz +libmgl mgl_vectl_3d ptr ptr ptr ptr ptr (void) mgl_vectl_3d +libmgl mgl_vectc_xyz ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_vectc_xyz +libmgl mgl_vectc_3d ptr ptr ptr ptr ptr (void) mgl_vectc_3d +libmgl mgl_map_xy int int ptr ptr ptr ptr ptr ptr (void) mgl_map_xy +libmgl mgl_map int int ptr ptr ptr ptr (void) mgl_map +libmgl mgl_surf3a_xyz_val ptr ptr ptr ptr ptr ptr sf ptr (void) mgl_surf3a_xyz_val +libmgl mgl_surf3a_val ptr ptr ptr sf ptr (void) mgl_surf3a_val +libmgl mgl_surf3a_xyz int ptr ptr ptr ptr ptr ptr ptr (void) mgl_surf3a_xyz +libmgl mgl_surf3a int ptr ptr ptr ptr (void) mgl_surf3a +libmgl mgl_surf3c_xyz_val ptr ptr ptr ptr ptr ptr sf ptr (void) mgl_surf3c_xyz_val +libmgl mgl_surf3c_val ptr ptr ptr sf ptr (void) mgl_surf3c_val +libmgl mgl_surf3c_xyz (void) mgl_surf3c_xyz +libmgl mgl_surf3c int ptr ptr ptr ptr (void) mgl_surf3c +libmgl mgl_flow_xy sf int int ptr ptr ptr ptr ptr ptr (void) mgl_flow_xy +libmgl mgl_flow_2d sf int int ptr ptr ptr ptr (void) mgl_flow_2d +libmgl mgl_flow_xyz int int ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_flow_xyz +libmgl mgl_flow_3d int int ptr ptr ptr ptr ptr (void) mgl_flow_3d +libmgl mgl_pipe_xy sf int int sf ptr ptr ptr ptr ptr ptr (void) mgl_pipe_xy +libmgl mgl_pipe_2d sf int int sf ptr ptr ptr ptr (void) mgl_pipe_2d +libmgl mgl_pipe_xyz int int sf ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_pipe_xyz +libmgl mgl_pipe_3d int int sf ptr ptr ptr ptr ptr (void) mgl_pipe_3d +libmgl mgl_dew_xy sf ptr ptr ptr ptr ptr ptr (void) mgl_dew_xy +libmgl mgl_dew_2d sf ptr ptr ptr ptr (void) mgl_dew_2d +libmgl mgl_grid3_xyz ptr int ptr ptr ptr ptr ptr ptr (void) mgl_grid3_xyz +libmgl mgl_grid3 ptr int ptr ptr ptr (void) mgl_grid3 +libmgl mgl_grid3_all_xyz ptr ptr ptr ptr ptr ptr (void) mgl_grid3_all_xyz +libmgl mgl_grid3_all ptr ptr ptr (void) mgl_grid3_all +libmgl mgl_dens3_xyz ptr int ptr ptr ptr ptr ptr ptr (void) mgl_dens3_xyz +libmgl mgl_dens3 ptr int ptr ptr ptr (void) mgl_dens3 +libmgl mgl_dens3_all_xyz ptr ptr ptr ptr ptr ptr (void) mgl_dens3_all_xyz +libmgl mgl_dens3_all ptr ptr ptr (void) mgl_dens3_all +libmgl mgl_surf3_xyz_val ptr ptr ptr ptr ptr sf ptr (void) mgl_surf3_xyz_val +libmgl mgl_surf3_val ptr ptr sf ptr (void) mgl_surf3_val +libmgl mgl_surf3_xyz int ptr ptr ptr ptr ptr ptr (void) mgl_surf3_xyz +libmgl mgl_surf3 int ptr ptr ptr (void) mgl_surf3 +libmgl mgl_cont3_xyz_val ptr int ptr ptr ptr ptr ptr ptr ptr (void) mgl_cont3_xyz_val +libmgl mgl_cont3_val ptr int ptr ptr ptr ptr (void) mgl_cont3_val +libmgl mgl_cont3_xyz int ptr int ptr ptr ptr ptr ptr ptr (void) mgl_cont3_xyz +libmgl mgl_cont3 int ptr int ptr ptr ptr (void) mgl_cont3 +libmgl mgl_cont_all_xyz int ptr ptr ptr ptr ptr ptr (void) mgl_cont_all_xyz +libmgl mgl_cont_all int ptr ptr ptr (void) mgl_cont_all +libmgl mgl_cloudp_xyz sf ptr ptr ptr ptr ptr ptr (void) mgl_cloudp_xyz +libmgl mgl_cloudp sf ptr ptr ptr (void) mgl_cloudp +libmgl mgl_cloud_xyz sf ptr ptr ptr ptr ptr ptr (void) mgl_cloud_xyz +libmgl mgl_cloud sf ptr ptr ptr (void) mgl_cloud +libmgl mgl_contf3_xyz_val ptr int ptr ptr ptr ptr ptr ptr ptr (void) mgl_contf3_xyz_val +libmgl mgl_contf3_val ptr int ptr ptr ptr ptr (void) mgl_contf3_val +libmgl mgl_contf3_xyz int ptr int ptr ptr ptr ptr ptr ptr (void) mgl_contf3_xyz +libmgl mgl_contf3 int ptr int ptr ptr ptr (void) mgl_contf3 +libmgl mgl_contf_all_xyz int ptr ptr ptr ptr ptr ptr (void) mgl_contf_all_xyz +libmgl mgl_contf_all int ptr ptr ptr (void) mgl_contf_all +libmgl mgl_beam_val int ptr sf ptr ptr ptr ptr sf ptr (void) mgl_beam_val +libmgl mgl_beam int int ptr sf ptr ptr ptr ptr ptr (void) mgl_beam +libmgl mgl_triplot_xyzc ptr ptr ptr ptr ptr ptr ptr (void) mgl_triplot_xyzc +libmgl mgl_triplot_xyz ptr ptr ptr ptr ptr ptr (void) mgl_triplot_xyz +libmgl mgl_triplot_xy sf ptr ptr ptr ptr ptr (void) mgl_triplot_xy +libmgl mgl_dots ptr ptr ptr ptr ptr (void) mgl_dots +libmgl mgl_dots_tr ptr ptr ptr (void) mgl_dots_tr +libmgl mgl_crust sf ptr ptr ptr ptr ptr (void) mgl_crust +libmgl mgl_crust_tr sf ptr ptr ptr (void) mgl_crust_tr +libmgl mgl_dens_x sf ptr ptr ptr (void) mgl_dens_x +libmgl mgl_dens_y sf ptr ptr ptr (void) mgl_dens_y +libmgl mgl_dens_z sf ptr ptr ptr (void) mgl_dens_z +libmgl mgl_cont_x int sf ptr ptr ptr (void) mgl_cont_x +libmgl mgl_cont_y int sf ptr ptr ptr (void) mgl_cont_y +libmgl mgl_cont_z int sf ptr ptr ptr (void) mgl_cont_z +libmgl mgl_cont_x_val sf ptr ptr ptr ptr (void) mgl_cont_x_val +libmgl mgl_cont_y_val sf ptr ptr ptr ptr (void) mgl_cont_y_val +libmgl mgl_cont_z_val sf ptr ptr ptr ptr (void) mgl_cont_z_val +libmgl mgl_contf_x int sf ptr ptr ptr (void) mgl_contf_x +libmgl mgl_contf_y int sf ptr ptr ptr (void) mgl_contf_y +libmgl mgl_contf_z int sf ptr ptr ptr (void) mgl_contf_z +libmgl mgl_contf_x_val sf ptr ptr ptr ptr (void) mgl_contf_x_val +libmgl mgl_contf_y_val sf ptr ptr ptr ptr (void) mgl_contf_y_val +libmgl mgl_contf_z_val sf ptr ptr ptr ptr (void) mgl_contf_z_val +libmgl mgl_data_rearrange int int int ptr (void) mgl_data_rearrange +libmgl mgl_data_set_float int int int sf ptr (void) mgl_data_set_float +libmgl mgl_data_set_double int int int df ptr (void) mgl_data_set_double +libmgl mgl_data_set_float2 int int sf ptr (void) mgl_data_set_float2 +libmgl mgl_data_set_double2 int int df ptr (void) mgl_data_set_double2 +libmgl mgl_data_set_float3 int int int sf ptr (void) mgl_data_set_float3 +libmgl mgl_data_set_double3 int int int ptr ptr (void) mgl_data_set_double3 +libmgl mgl_data_set ptr ptr (void) mgl_data_set +libmgl mgl_data_set_vector ptr ptr (void) mgl_data_set_vector +libmgl mgl_data_set_matrix ptr ptr (void) mgl_data_set_matrix +libmgl mgl_data_get_value int int int ptr (fp) mgl_data_get_value +libmgl mgl_data_get_nx ptr (int) mgl_data_get_nx +libmgl mgl_data_get_ny ptr (int) mgl_data_get_ny +libmgl mgl_data_get_nz ptr (int) mgl_data_get_nz +libmgl mgl_data_set_value int int int sf ptr (void) mgl_data_set_value +libmgl mgl_data_set_values int int int ptr ptr (void) mgl_data_set_values +libmgl mgl_data_read ptr ptr (int) mgl_data_read +libmgl mgl_data_read_mat int ptr ptr (int) mgl_data_read_mat +libmgl mgl_data_read_dim int int int ptr ptr (int) mgl_data_read_dim +libmgl mgl_data_save int ptr ptr (void) mgl_data_save +libmgl mgl_data_export int sf sf ptr ptr ptr (void) mgl_data_export +libmgl mgl_data_import sf sf ptr ptr ptr (void) mgl_data_import +libmgl mgl_data_create int int int ptr (void) mgl_data_create +libmgl mgl_data_transpose ptr ptr (void) mgl_data_transpose +libmgl mgl_data_norm int int sf sf ptr (void) mgl_data_norm +libmgl mgl_data_norm_slice int int ptr sf sf ptr (void) mgl_data_norm_slice +libmgl mgl_data_subdata int int int ptr (ptr) mgl_data_subdata +libmgl mgl_data_column ptr ptr (ptr) mgl_data_column +libmgl mgl_data_set_id ptr ptr (void) mgl_data_set_id +libmgl mgl_data_fill ptr sf sf ptr (void) mgl_data_fill +libmgl mgl_data_fill_eq ptr ptr ptr ptr ptr (void) mgl_data_fill_eq +libmgl mgl_data_put_val int int int sf ptr (void) mgl_data_put_val +libmgl mgl_data_put_dat int int int ptr ptr (void) mgl_data_put_dat +libmgl mgl_data_modify int ptr ptr (void) mgl_data_modify +libmgl mgl_data_modify_vw ptr ptr ptr ptr (void) mgl_data_modify_vw +libmgl mgl_data_squeeze int int int int ptr (void) mgl_data_squeeze +libmgl mgl_data_max ptr (fp) mgl_data_max +libmgl mgl_data_min ptr (fp) mgl_data_min +libmgl mgl_data_value int int int ptr (fp) mgl_data_value +libmgl mgl_data_combine ptr ptr (ptr) mgl_data_combine +libmgl mgl_data_extend int int ptr (void) mgl_data_extend +libmgl mgl_data_insert int int ptr ptr (void) mgl_data_insert +libmgl mgl_data_delete int int ptr ptr (void) mgl_data_delete +libmgl mgl_data_smooth ptr sf int ptr (void) mgl_data_smooth +libmgl mgl_data_sum ptr ptr (ptr) mgl_data_sum +libmgl mgl_data_max_dir ptr ptr (ptr) mgl_data_max_dir +libmgl mgl_data_min_dir ptr ptr (ptr) mgl_data_min_dir +libmgl mgl_data_cumsum ptr ptr (void) mgl_data_cumsum +libmgl mgl_data_integral ptr ptr (void) mgl_data_integral +libmgl mgl_data_diff ptr ptr (void) mgl_data_diff +libmgl mgl_data_diff_par ptr ptr ptr ptr (void) mgl_data_diff_par +libmgl mgl_data_diff2 ptr ptr (void) mgl_data_diff2 +libmgl mgl_data_swap ptr ptr (void) mgl_data_swap +libmgl mgl_data_mirror ptr ptr (void) mgl_data_mirror +libmgl mgl_data_spline sf sf sf ptr (fp) mgl_data_spline +libmgl mgl_data_spline1 sf sf sf ptr (fp) mgl_data_spline1 +libmgl mgl_data_linear sf sf sf ptr (fp) mgl_data_linear +libmgl mgl_data_linear1 sf sf sf ptr (fp) mgl_data_linear1 +libmgl mgl_data_resize int int int ptr (ptr) mgl_data_resize +libmgl mgl_data_resize_box (ptr) mgl_data_resize_box +libmgl mgl_data_hist int sf sf int ptr (ptr) mgl_data_hist +libmgl mgl_data_hist_w int sf sf int ptr ptr (ptr) mgl_data_hist_w +libmgl mgl_data_momentum ptr ptr ptr (ptr) mgl_data_momentum +libmgl mgl_data_evaluate_i int ptr ptr (ptr) mgl_data_evaluate_i +libmgl mgl_data_evaluate_ij int ptr ptr ptr (ptr) mgl_data_evaluate_ij +libmgl mgl_data_evaluate_ijk int ptr ptr ptr ptr (ptr) mgl_data_evaluate_ijk +libmgl mgl_data_envelop ptr ptr (void) mgl_data_envelop +libmgl mgl_data_sew sf ptr ptr (void) mgl_data_sew +libmgl mgl_data_crop ptr int int ptr (void) mgl_data_crop +libmgl mgl_data_mul_dat ptr ptr (void) mgl_data_mul_dat +libmgl mgl_data_div_dat ptr ptr (void) mgl_data_div_dat +libmgl mgl_data_add_dat ptr ptr (void) mgl_data_add_dat +libmgl mgl_data_sub_dat ptr ptr (void) mgl_data_sub_dat +libmgl mgl_data_mul_num sf ptr (void) mgl_data_mul_num +libmgl mgl_data_div_num sf ptr (void) mgl_data_div_num +libmgl mgl_data_add_num sf ptr (void) mgl_data_add_num +libmgl mgl_data_sub_num sf ptr (void) mgl_data_sub_num +libmgl mgl_fit_1 sf ptr ptr ptr ptr ptr (fp) mgl_fit_1 +libmgl mgl_fit_2 sf ptr ptr ptr ptr ptr (fp) mgl_fit_2 +libmgl mgl_fit_3 sf ptr ptr ptr ptr ptr (fp) mgl_fit_3 +libmgl mgl_fit_xy sf ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xy +libmgl mgl_fit_xyz sf ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyz +libmgl mgl_fit_xyza sf ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyza +libmgl mgl_fit_ys sf ptr ptr ptr ptr ptr ptr (fp) mgl_fit_ys +libmgl mgl_fit_xys sf ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xys +libmgl mgl_fit_xyzs sf ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyzs +libmgl mgl_fit_xyzas sf ptr ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyzas +libmgl mgl_fit_1_d ptr ptr ptr ptr ptr ptr (fp) mgl_fit_1_d +libmgl mgl_fit_2_d ptr ptr ptr ptr ptr ptr (fp) mgl_fit_2_d +libmgl mgl_fit_3_d ptr ptr ptr ptr ptr ptr (fp) mgl_fit_3_d +libmgl mgl_fit_xy_d ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xy_d +libmgl mgl_fit_xyz_d ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyz_d +libmgl mgl_fit_xyza_d ptr ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyza_d +libmgl mgl_fit_ys_d ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_ys_d +libmgl mgl_fit_xys_d ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xys_d +libmgl mgl_fit_xyzs_d ptr ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyzs_d +libmgl mgl_fit_xyzas_d ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr (fp) mgl_fit_xyzas_d +libmgl mgl_puts_fit sf ptr ptr sf sf sf ptr (void) mgl_puts_fit +libmgl mgl_sphere ptr sf sf sf sf ptr (void) mgl_sphere +libmgl mgl_drop sf sf ptr sf sf sf sf sf sf sf ptr (void) mgl_drop +libmgl mgl_cone int ptr sf sf sf sf sf sf sf sf ptr (void) mgl_cone +libmgl mgl_pde_solve sf sf ptr ptr ptr ptr (ptr) mgl_pde_solve +libmgl mgl_qo2d_solve ptr ptr sf sf ptr ptr ptr ptr (ptr) mgl_qo2d_solve +libmgl mgl_af2d_solve ptr ptr sf sf ptr ptr ptr ptr (ptr) mgl_af2d_solve +libmgl mgl_ray_trace sf sf sf sf sf sf sf sf ptr (ptr) mgl_ray_trace +libmgl mgl_jacobian_2d ptr ptr (ptr) mgl_jacobian_2d +libmgl mgl_jacobian_3d ptr ptr ptr (ptr) mgl_jacobian_3d +libmgl mgl_transform_a ptr ptr ptr (ptr) mgl_transform_a +libmgl mgl_transform ptr ptr ptr (ptr) mgl_transform +libmgl mgl_data_stfa ptr int ptr ptr (ptr) mgl_data_stfa + +legacy on + +previous +Module; diff --git a/include/mgl2/mgl.fs b/include/mgl2/mgl.fs new file mode 100644 index 0000000..32eb460 --- /dev/null +++ b/include/mgl2/mgl.fs @@ -0,0 +1,608 @@ +\ Mathgl library wrapper +\ Copyright (C) 2008-2013, Sergey Plis, Alexey Balakin +\ +\ This program is free software; you can redistribute it and/or modify +\ it under the terms of the GNU General Public License as published by +\ the Free Software Foundation; either version 2 of the License, or +\ (at your option) any later version. +\ +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +Module mathgl +library libmgl libmgl.so +library libmgl-glut libmgl-glut.so +library libmgl-fltk libmgl-fltk.so +library libmgl-qt libmgl-qt.so +library libmgl-wx libmgl-wx.so +legacy off + +libmgl mgl_create_graph_gl (ptr) mgl_create_graph_gl +libmgl-glut mgl_create_graph_glut ptr ptr ptr (ptr) mgl_create_graph_glut +libmgl-fltk mgl_create_graph_fltk ptr ptr ptr (ptr) mgl_create_graph_fltk +libmgl-fltk mgl_fltk_run (void) mgl_fltk_run +libmgl-qt mgl_create_graph_qt ptr ptr ptr (ptr) mgl_create_graph_qt +libmgl-qt mgl_qt_run (void) mgl_qt_run + +libmgl mgl_get_warn ptr (int) mgl_get_warn +libmgl mgl_set_warn ptr int ptr (void) mgl_set_warn +libmgl gl_get_mess ptr (ptr) gl_get_mess +libmgl mgl_set_plotid ptr ptr (void) mgl_set_plotid +libmgl gl_get_plotid ptr (ptr) gl_get_plotid +libmgl mgl_get_quality ptr (int) mgl_get_quality +libmgl mgl_set_quality int ptr (void) mgl_set_quality +libmgl mgl_set_draw_reg int int int ptr (void) mgl_set_draw_reg +libmgl mgl_is_frames ptr (int) mgl_is_frames +libmgl mgl_get_flag int ptr (int) mgl_get_flag +libmgl mgl_set_flag int int ptr (void) mgl_set_flag +libmgl mgl_use_graph int ptr (int) mgl_use_graph +libmgl mgl_start_group ptr ptr (void) mgl_start_group +libmgl mgl_end_group ptr (void) mgl_end_group +libmgl mgl_highlight int ptr (void) mgl_highlight +libmgl mgl_set_palette ptr ptr (void) mgl_set_palette +libmgl mgl_set_color double double double char (void) mgl_set_color +libmgl mgl_set_def_sch ptr ptr (void) mgl_set_def_sch +libmgl mgl_set_mask ptr char (void) mgl_set_mask +libmgl mgl_set_mask_angle int ptr (void) mgl_set_mask_angle +libmgl mgl_set_alpha_default double ptr (void) mgl_set_alpha_default +libmgl mgl_set_bar_width double ptr (void) mgl_set_bar_width +libmgl mgl_set_meshnum int ptr (void) mgl_set_meshnum +libmgl mgl_set_facenum int ptr (void) mgl_set_facenum +libmgl mgl_clear_unused ptr (void) mgl_clear_unused +libmgl mgl_set_ambbr double ptr (void) mgl_set_ambbr +libmgl mgl_set_difbr double ptr (void) mgl_set_difbr +libmgl mgl_set_light_dif int ptr (void) mgl_set_light_dif +libmgl mgl_set_cut int ptr (void) mgl_set_cut +libmgl mgl_set_cut_box double double double double double double ptr (void) mgl_set_cut_box +libmgl mgl_set_cutoff ptr ptr (void) mgl_set_cutoff +libmgl mgl_set_ranges double double double double double double ptr (void) mgl_set_ranges +libmgl mgl_set_range_val double double char ptr (void) mgl_set_range_val +libmgl mgl_set_range_dat int ptr char ptr (void) mgl_set_range_dat +libmgl mgl_set_auto_ranges double double double double double double double double ptr (void) mgl_set_auto_ranges +libmgl mgl_zoom_axis double double double double double double double double ptr (void) mgl_zoom_axis +libmgl mgl_set_origin double double double ptr (void) mgl_set_origin +libmgl mgl_set_func ptr ptr ptr ptr ptr (void) mgl_set_func +libmgl mgl_set_coor int ptr (void) mgl_set_coor +libmgl mgl_set_ternary int ptr (void) mgl_set_ternary +libmgl mgl_set_tick_rotate int ptr (void) mgl_set_tick_rotate +libmgl mgl_set_tick_skip int ptr (void) mgl_set_tick_skip +libmgl mgl_def_font ptr ptr (void) mgl_def_font +libmgl mgl_set_mark_size double ptr (void) mgl_set_mark_size +libmgl mgl_set_arrow_size double ptr (void) mgl_set_arrow_size +libmgl mgl_set_font_size double ptr (void) mgl_set_font_size +libmgl mgl_set_font_def ptr ptr (void) mgl_set_font_def +libmgl mgl_set_rotated_text int ptr (void) mgl_set_rotated_text +libmgl mgl_load_font ptr ptr ptr (void) mgl_load_font +libmgl mgl_copy_font ptr ptr (void) mgl_copy_font +libmgl mgl_restore_font ptr (void) mgl_restore_font +libmgl mgl_srnd int (void) mgl_srnd +libmgl mgl_rnd (double) mgl_rnd +libmgl mgl_ipow int double (double) mgl_ipow +libmgl mgl_get_time ptr ptr (double) mgl_get_time +libmgl mgl_create_data (ptr) mgl_create_data +libmgl mgl_create_data_size int int int (ptr) mgl_create_data_size +libmgl mgl_create_data_file ptr (ptr) mgl_create_data_file +libmgl mgl_delete_data ptr (void) mgl_delete_data +libmgl gl_data_info ptr (ptr) gl_data_info +libmgl mgl_data_rearrange int int int ptr (void) mgl_data_rearrange +libmgl mgl_data_link int int int ptr ptr (void) mgl_data_link +libmgl mgl_data_set_float int int int ptr ptr (void) mgl_data_set_float +libmgl mgl_data_set_double int int int ptr ptr (void) mgl_data_set_double +libmgl mgl_data_set ptr ptr (void) mgl_data_set +libmgl mgl_data_set_vector ptr ptr (void) mgl_data_set_vector +libmgl mgl_data_set_matrix ptr ptr (void) mgl_data_set_matrix +libmgl mgl_data_set_value int int int sf ptr (void) mgl_data_set_value +libmgl mgl_data_get_value int int int ptr (sf) mgl_data_get_value +libmgl mgl_data_set_values int int int ptr ptr (void) mgl_data_set_values +libmgl mgl_data_read_hdf ptr ptr ptr (int) mgl_data_read_hdf +libmgl mgl_data_save_hdf int ptr ptr ptr (void) mgl_data_save_hdf +libmgl mgl_datas_hdf int ptr ptr (int) mgl_datas_hdf +libmgl mgl_data_read ptr ptr (int) mgl_data_read +libmgl mgl_data_read_mat int ptr ptr (int) mgl_data_read_mat +libmgl mgl_data_read_dim int int int ptr ptr (int) mgl_data_read_dim +libmgl mgl_data_read_range int double double double ptr ptr (int) mgl_data_read_range +libmgl mgl_data_read_all int ptr ptr (int) mgl_data_read_all +libmgl mgl_data_save int ptr ptr (void) mgl_data_save +libmgl mgl_data_export int sf sf ptr ptr ptr (void) mgl_data_export +libmgl mgl_data_import sf sf ptr ptr ptr (void) mgl_data_import +libmgl mgl_data_create int int int ptr (void) mgl_data_create +libmgl mgl_data_transpose ptr ptr (void) mgl_data_transpose +libmgl mgl_data_norm int int sf sf ptr (void) mgl_data_norm +libmgl mgl_data_norm_slice int int char sf sf ptr (void) mgl_data_norm_slice +libmgl mgl_data_subdata int int int ptr (ptr) mgl_data_subdata +libmgl mgl_data_subdata_ext ptr ptr ptr ptr (ptr) mgl_data_subdata_ext +libmgl mgl_data_column ptr ptr (ptr) mgl_data_column +libmgl mgl_data_set_id ptr ptr (void) mgl_data_set_id +libmgl mgl_data_fill char sf sf ptr (void) mgl_data_fill +libmgl mgl_data_fill_eq ptr ptr ptr ptr ptr ptr (void) mgl_data_fill_eq +libmgl mgl_data_refill_x int sf sf ptr ptr ptr (void) mgl_data_refill_x +libmgl mgl_data_refill_xy int sf sf sf sf ptr ptr ptr ptr (void) mgl_data_refill_xy +libmgl mgl_data_refill_xyz sf sf sf sf sf sf ptr ptr ptr ptr ptr (void) mgl_data_refill_xyz +libmgl mgl_data_refill_gr ptr int ptr ptr ptr ptr ptr ptr (void) mgl_data_refill_gr +libmgl mgl_data_grid ptr ptr ptr ptr ptr ptr (void) mgl_data_grid +libmgl mgl_data_grid_xy sf sf sf sf ptr ptr ptr ptr (void) mgl_data_grid_xy +libmgl mgl_data_put_val int int int sf ptr (void) mgl_data_put_val +libmgl mgl_data_put_dat int int int ptr ptr (void) mgl_data_put_dat +libmgl mgl_data_modify int ptr ptr (void) mgl_data_modify +libmgl mgl_data_modify_vw ptr ptr ptr ptr (void) mgl_data_modify_vw +libmgl mgl_data_squeeze int int int int ptr (void) mgl_data_squeeze +libmgl mgl_data_max ptr (sf) mgl_data_max +libmgl mgl_data_min ptr (sf) mgl_data_min +libmgl gl_data_value int int int ptr (ptr) gl_data_value +libmgl gl_data_data ptr (ptr) gl_data_data +libmgl mgl_data_get_nx ptr (int) mgl_data_get_nx +libmgl mgl_data_get_ny ptr (int) mgl_data_get_ny +libmgl mgl_data_get_nz ptr (int) mgl_data_get_nz +libmgl mgl_data_first ptr ptr ptr ptr ptr (sf) mgl_data_first +libmgl mgl_data_last ptr ptr ptr ptr ptr (sf) mgl_data_last +libmgl mgl_data_find int int int char ptr ptr (int) mgl_data_find +libmgl mgl_data_find_any ptr ptr (int) mgl_data_find_any +libmgl mgl_data_max_int ptr ptr ptr ptr (sf) mgl_data_max_int +libmgl mgl_data_max_real ptr ptr ptr ptr (sf) mgl_data_max_real +libmgl mgl_data_min_int ptr ptr ptr ptr (sf) mgl_data_min_int +libmgl mgl_data_min_real ptr ptr ptr ptr (sf) mgl_data_min_real +libmgl mgl_data_momentum_val ptr ptr ptr ptr char ptr (sf) mgl_data_momentum_val +libmgl mgl_data_combine ptr ptr (ptr) mgl_data_combine +libmgl mgl_data_extend int int ptr (void) mgl_data_extend +libmgl mgl_data_insert int int char ptr (void) mgl_data_insert +libmgl mgl_data_delete int int char ptr (void) mgl_data_delete +libmgl mgl_data_join ptr ptr (void) mgl_data_join +libmgl mgl_data_smooth sf ptr ptr (void) mgl_data_smooth +libmgl mgl_data_sum ptr ptr (ptr) mgl_data_sum +libmgl mgl_data_max_dir ptr ptr (ptr) mgl_data_max_dir +libmgl mgl_data_min_dir ptr ptr (ptr) mgl_data_min_dir +libmgl mgl_data_cumsum ptr ptr (void) mgl_data_cumsum +libmgl mgl_data_integral ptr ptr (void) mgl_data_integral +libmgl mgl_data_diff ptr ptr (void) mgl_data_diff +libmgl mgl_data_diff_par ptr ptr ptr ptr (void) mgl_data_diff_par +libmgl mgl_data_diff2 ptr ptr (void) mgl_data_diff2 +libmgl mgl_data_swap ptr ptr (void) mgl_data_swap +libmgl mgl_data_roll int char ptr (void) mgl_data_roll +libmgl mgl_data_mirror ptr ptr (void) mgl_data_mirror +libmgl mgl_data_sort int int ptr (void) mgl_data_sort +libmgl mgl_data_hankel ptr ptr (void) mgl_data_hankel +libmgl mgl_data_sinfft ptr ptr (void) mgl_data_sinfft +libmgl mgl_data_cosfft ptr ptr (void) mgl_data_cosfft +libmgl mgl_data_fill_sample ptr ptr (void) mgl_data_fill_sample +libmgl mgl_data_correl ptr ptr ptr (ptr) mgl_data_correl +libmgl mgl_clear_fft (void) mgl_clear_fft +libmgl mgl_data_spline sf sf sf ptr (sf) mgl_data_spline +libmgl mgl_data_linear sf sf sf ptr (sf) mgl_data_linear +libmgl mgl_data_spline_ext ptr ptr ptr sf sf sf ptr (sf) mgl_data_spline_ext +libmgl mgl_data_linear_ext ptr ptr ptr sf sf sf ptr (sf) mgl_data_linear_ext +libmgl mgl_data_solve_1d int int sf ptr (sf) mgl_data_solve_1d +libmgl mgl_data_solve int ptr char sf ptr (ptr) mgl_data_solve +libmgl mgl_data_trace ptr (ptr) mgl_data_trace +libmgl mgl_data_resize int int int ptr (ptr) mgl_data_resize +libmgl mgl_data_resize_box sf sf sf sf sf sf int int int ptr (ptr) mgl_data_resize_box +libmgl mgl_data_hist int sf sf int ptr (ptr) mgl_data_hist +libmgl mgl_data_hist_w int sf sf int ptr ptr (ptr) mgl_data_hist_w +libmgl mgl_data_momentum ptr char ptr (ptr) mgl_data_momentum +libmgl mgl_data_evaluate int ptr ptr ptr ptr (ptr) mgl_data_evaluate +libmgl mgl_data_envelop char ptr (void) mgl_data_envelop +libmgl mgl_data_sew sf ptr ptr (void) mgl_data_sew +libmgl mgl_data_crop char int int ptr (void) mgl_data_crop +libmgl mgl_data_clean int ptr (void) mgl_data_clean +libmgl mgl_data_mul_dat ptr ptr (void) mgl_data_mul_dat +libmgl mgl_data_div_dat ptr ptr (void) mgl_data_div_dat +libmgl mgl_data_add_dat ptr ptr (void) mgl_data_add_dat +libmgl mgl_data_sub_dat ptr ptr (void) mgl_data_sub_dat +libmgl mgl_data_mul_num sf ptr (void) mgl_data_mul_num +libmgl mgl_data_div_num sf ptr (void) mgl_data_div_num +libmgl mgl_data_add_num sf ptr (void) mgl_data_add_num +libmgl mgl_data_sub_num sf ptr (void) mgl_data_sub_num +libmgl mgl_transform_a ptr ptr ptr (ptr) mgl_transform_a +libmgl mgl_transform ptr ptr ptr (ptr) mgl_transform +libmgl mgl_data_fourier ptr ptr ptr (void) mgl_data_fourier +libmgl mgl_data_stfa char int ptr ptr (ptr) mgl_data_stfa +libmgl mgl_triangulation_3d ptr ptr ptr (ptr) mgl_triangulation_3d +libmgl mgl_triangulation_2d ptr ptr (ptr) mgl_triangulation_2d +libmgl mgl_find_root_txt char sf ptr (sf) mgl_find_root_txt +libmgl mgl_data_roots char ptr ptr (ptr) mgl_data_roots +libmgl mgl_datac_save int ptr ptr (void) mgl_datac_save +libmgl mgl_datac_save_hdf int ptr ptr ptr (void) mgl_datac_save_hdf +libmgl mgl_datac_real ptr (ptr) mgl_datac_real +libmgl mgl_datac_imag ptr (ptr) mgl_datac_imag +libmgl mgl_datac_abs ptr (ptr) mgl_datac_abs +libmgl mgl_datac_arg ptr (ptr) mgl_datac_arg +libmgl mgl_text_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_text_xyz +libmgl mgl_textw_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_textw_xyz +libmgl mgl_text_xy ptr ptr ptr ptr ptr ptr (void) mgl_text_xy +libmgl mgl_textw_xy ptr ptr ptr ptr ptr ptr (void) mgl_textw_xy +libmgl mgl_text_y ptr ptr ptr ptr ptr (void) mgl_text_y +libmgl mgl_textw_y ptr ptr ptr ptr ptr (void) mgl_textw_y +libmgl mgl_cont_gen ptr ptr ptr ptr ptr double ptr (void) mgl_cont_gen +libmgl mgl_contf_gen ptr ptr ptr ptr ptr double double ptr (void) mgl_contf_gen +libmgl mgl_cont_xy_val ptr ptr ptr ptr ptr ptr ptr (void) mgl_cont_xy_val +libmgl mgl_cont_val ptr ptr ptr ptr ptr (void) mgl_cont_val +libmgl mgl_cont_xy ptr ptr ptr ptr ptr ptr (void) mgl_cont_xy +libmgl mgl_cont ptr ptr ptr ptr (void) mgl_cont +libmgl mgl_contf_xy_val ptr ptr ptr ptr ptr ptr ptr (void) mgl_contf_xy_val +libmgl mgl_contf_val ptr ptr ptr ptr ptr (void) mgl_contf_val +libmgl mgl_contf_xy ptr ptr ptr ptr ptr ptr (void) mgl_contf_xy +libmgl mgl_contf ptr ptr ptr ptr (void) mgl_contf +libmgl mgl_contd_xy_val ptr ptr ptr ptr ptr ptr ptr (void) mgl_contd_xy_val +libmgl mgl_contd_val ptr ptr ptr ptr ptr (void) mgl_contd_val +libmgl mgl_contd_xy ptr ptr ptr ptr ptr ptr (void) mgl_contd_xy +libmgl mgl_contd ptr ptr ptr ptr (void) mgl_contd +libmgl mgl_contv_xy_val ptr ptr ptr ptr ptr ptr ptr (void) mgl_contv_xy_val +libmgl mgl_contv_val ptr ptr ptr ptr ptr (void) mgl_contv_val +libmgl mgl_contv_xy ptr ptr ptr ptr ptr ptr (void) mgl_contv_xy +libmgl mgl_contv ptr ptr ptr ptr (void) mgl_contv +libmgl mgl_axial_xy_val ptr ptr ptr ptr ptr ptr ptr (void) mgl_axial_xy_val +libmgl mgl_axial_val ptr ptr ptr ptr ptr (void) mgl_axial_val +libmgl mgl_axial_xy ptr ptr ptr ptr ptr ptr (void) mgl_axial_xy +libmgl mgl_axial ptr ptr ptr ptr (void) mgl_axial +libmgl mgl_torus ptr ptr ptr ptr ptr (void) mgl_torus +libmgl mgl_grid3_xyz ptr double ptr ptr ptr ptr ptr ptr (void) mgl_grid3_xyz +libmgl mgl_grid3 ptr double ptr ptr ptr (void) mgl_grid3 +libmgl mgl_dens3_xyz ptr double ptr ptr ptr ptr ptr ptr (void) mgl_dens3_xyz +libmgl mgl_dens3 ptr double ptr ptr ptr (void) mgl_dens3 +libmgl mgl_cont3_xyz_val ptr double ptr ptr ptr ptr ptr ptr ptr (void) mgl_cont3_xyz_val +libmgl mgl_cont3_val ptr double ptr ptr ptr ptr (void) mgl_cont3_val +libmgl mgl_cont3_xyz ptr double ptr ptr ptr ptr ptr ptr (void) mgl_cont3_xyz +libmgl mgl_cont3 ptr double ptr ptr ptr (void) mgl_cont3 +libmgl mgl_contf3_xyz_val ptr double ptr ptr ptr ptr ptr ptr ptr (void) mgl_contf3_xyz_val +libmgl mgl_contf3_val ptr double ptr ptr ptr ptr (void) mgl_contf3_val +libmgl mgl_contf3_xyz ptr double ptr ptr ptr ptr ptr ptr (void) mgl_contf3_xyz +libmgl mgl_contf3 ptr double ptr ptr ptr (void) mgl_contf3 +libmgl mgl_fit_1 ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_1 +libmgl mgl_fit_2 ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_2 +libmgl mgl_fit_3 ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_3 +libmgl mgl_fit_xy ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xy +libmgl mgl_fit_xyz ptr ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xyz +libmgl mgl_fit_xyza ptr ptr ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xyza +libmgl mgl_fit_ys ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_ys +libmgl mgl_fit_xys ptr ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xys +libmgl mgl_fit_xyzs ptr ptr ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xyzs +libmgl mgl_fit_xyzas ptr ptr ptr ptr ptr ptr ptr ptr ptr ptr (ptr) mgl_fit_xyzas +libmgl gl_get_fit ptr (ptr) gl_get_fit +libmgl mgl_hist_x ptr ptr ptr ptr (ptr) mgl_hist_x +libmgl mgl_hist_xy ptr ptr ptr ptr ptr (ptr) mgl_hist_xy +libmgl mgl_hist_xyz ptr ptr ptr ptr ptr ptr (ptr) mgl_hist_xyz +libmgl mgl_puts_fit double ptr ptr double double double ptr (void) mgl_puts_fit +libmgl mgl_fplot ptr ptr ptr ptr (void) mgl_fplot +libmgl mgl_fplot_xyz ptr ptr ptr ptr ptr ptr (void) mgl_fplot_xyz +libmgl mgl_radar ptr ptr ptr ptr (void) mgl_radar +libmgl mgl_plot_xyz ptr ptr ptr ptr ptr ptr (void) mgl_plot_xyz +libmgl mgl_plot_xy ptr ptr ptr ptr ptr (void) mgl_plot_xy +libmgl mgl_plot ptr ptr ptr ptr (void) mgl_plot +libmgl mgl_tens_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_tens_xyz +libmgl mgl_tens_xy ptr ptr ptr ptr ptr ptr (void) mgl_tens_xy +libmgl mgl_tens ptr ptr ptr ptr ptr (void) mgl_tens +libmgl mgl_tape_xyz ptr ptr ptr ptr ptr ptr (void) mgl_tape_xyz +libmgl mgl_tape_xy ptr ptr ptr ptr ptr (void) mgl_tape_xy +libmgl mgl_tape ptr ptr ptr ptr (void) mgl_tape +libmgl mgl_boxplot_xy ptr ptr ptr ptr ptr (void) mgl_boxplot_xy +libmgl mgl_boxplot ptr ptr ptr ptr (void) mgl_boxplot +libmgl mgl_area_xyz ptr ptr ptr ptr ptr ptr (void) mgl_area_xyz +libmgl mgl_area_xy ptr ptr ptr ptr ptr (void) mgl_area_xy +libmgl mgl_area ptr ptr ptr ptr (void) mgl_area +libmgl mgl_region_xy ptr ptr ptr ptr ptr ptr (void) mgl_region_xy +libmgl mgl_region ptr ptr ptr ptr ptr (void) mgl_region +libmgl mgl_stem_xyz ptr ptr ptr ptr ptr ptr (void) mgl_stem_xyz +libmgl mgl_stem_xy ptr ptr ptr ptr ptr (void) mgl_stem_xy +libmgl mgl_stem ptr ptr ptr ptr (void) mgl_stem +libmgl mgl_step_xyz ptr ptr ptr ptr ptr ptr (void) mgl_step_xyz +libmgl mgl_step_xy ptr ptr ptr ptr ptr (void) mgl_step_xy +libmgl mgl_step ptr ptr ptr ptr (void) mgl_step +libmgl mgl_bars_xyz ptr ptr ptr ptr ptr ptr (void) mgl_bars_xyz +libmgl mgl_bars_xy ptr ptr ptr ptr ptr (void) mgl_bars_xy +libmgl mgl_bars ptr ptr ptr ptr (void) mgl_bars +libmgl mgl_barh_yx ptr ptr ptr ptr ptr (void) mgl_barh_yx +libmgl mgl_barh ptr ptr ptr ptr (void) mgl_barh +libmgl mgl_ohlc_x ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_ohlc_x +libmgl mgl_ohlc ptr ptr ptr ptr ptr ptr ptr (void) mgl_ohlc +libmgl mgl_chart ptr ptr ptr ptr (void) mgl_chart +libmgl mgl_error_exy ptr ptr ptr ptr ptr ptr ptr (void) mgl_error_exy +libmgl mgl_error_xy ptr ptr ptr ptr ptr ptr (void) mgl_error_xy +libmgl mgl_error ptr ptr ptr ptr ptr (void) mgl_error +libmgl mgl_mark_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_mark_xyz +libmgl mgl_mark_xy ptr ptr ptr ptr ptr ptr (void) mgl_mark_xy +libmgl mgl_mark_y ptr ptr ptr ptr ptr (void) mgl_mark_y +libmgl mgl_tube_xyzr ptr ptr ptr ptr ptr ptr ptr (void) mgl_tube_xyzr +libmgl mgl_tube_xyr ptr ptr ptr ptr ptr ptr (void) mgl_tube_xyr +libmgl mgl_tube_r ptr ptr ptr ptr ptr (void) mgl_tube_r +libmgl mgl_tube_xyz ptr ptr double ptr ptr ptr ptr (void) mgl_tube_xyz +libmgl mgl_tube_xy ptr ptr double ptr ptr ptr (void) mgl_tube_xy +libmgl mgl_tube ptr ptr double ptr ptr (void) mgl_tube +libmgl mgl_candle_xyv ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_candle_xyv +libmgl mgl_candle_yv ptr ptr ptr ptr ptr ptr ptr (void) mgl_candle_yv +libmgl mgl_candle ptr ptr ptr ptr ptr ptr (void) mgl_candle +libmgl mgl_fsurf ptr ptr ptr ptr (void) mgl_fsurf +libmgl mgl_fsurf_xyz ptr ptr ptr ptr ptr ptr (void) mgl_fsurf_xyz +libmgl mgl_grid_xy ptr ptr ptr ptr ptr ptr (void) mgl_grid_xy +libmgl mgl_grid ptr ptr ptr ptr (void) mgl_grid +libmgl mgl_mesh_xy ptr ptr ptr ptr ptr ptr (void) mgl_mesh_xy +libmgl mgl_mesh ptr ptr ptr ptr (void) mgl_mesh +libmgl mgl_fall_xy ptr ptr ptr ptr ptr ptr (void) mgl_fall_xy +libmgl mgl_fall ptr ptr ptr ptr (void) mgl_fall +libmgl mgl_belt_xy ptr ptr ptr ptr ptr ptr (void) mgl_belt_xy +libmgl mgl_belt ptr ptr ptr ptr (void) mgl_belt +libmgl mgl_surf_xy ptr ptr ptr ptr ptr ptr (void) mgl_surf_xy +libmgl mgl_surf ptr ptr ptr ptr (void) mgl_surf +libmgl mgl_dens_xy ptr ptr ptr ptr ptr ptr (void) mgl_dens_xy +libmgl mgl_dens ptr ptr ptr ptr (void) mgl_dens +libmgl mgl_boxs_xy ptr ptr ptr ptr ptr ptr (void) mgl_boxs_xy +libmgl mgl_boxs ptr ptr ptr ptr (void) mgl_boxs +libmgl mgl_tile_xy ptr ptr ptr ptr ptr ptr (void) mgl_tile_xy +libmgl mgl_tile ptr ptr ptr ptr (void) mgl_tile +libmgl mgl_tiles_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_tiles_xy +libmgl mgl_tiles ptr ptr ptr ptr ptr (void) mgl_tiles +libmgl mgl_surfc_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_surfc_xy +libmgl mgl_surfc ptr ptr ptr ptr ptr (void) mgl_surfc +libmgl mgl_surfa_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_surfa_xy +libmgl mgl_surfa ptr ptr ptr ptr ptr (void) mgl_surfa +libmgl mgl_stfa_xy ptr ptr int ptr ptr ptr ptr ptr (void) mgl_stfa_xy +libmgl mgl_stfa ptr ptr int ptr ptr ptr (void) mgl_stfa +libmgl mgl_map_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_map_xy +libmgl mgl_map ptr ptr ptr ptr ptr (void) mgl_map +libmgl mgl_surf3_xyz_val ptr ptr ptr ptr ptr ptr double ptr (void) mgl_surf3_xyz_val +libmgl mgl_surf3_val ptr ptr ptr double ptr (void) mgl_surf3_val +libmgl mgl_surf3_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_surf3_xyz +libmgl mgl_surf3 ptr ptr ptr ptr (void) mgl_surf3 +libmgl mgl_surf3a_xyz_val ptr ptr ptr ptr ptr ptr ptr double ptr (void) mgl_surf3a_xyz_val +libmgl mgl_surf3a_val ptr ptr ptr ptr double ptr (void) mgl_surf3a_val +libmgl mgl_surf3a_xyz ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_surf3a_xyz +libmgl mgl_surf3a ptr ptr ptr ptr ptr (void) mgl_surf3a +libmgl mgl_surf3c_xyz_val ptr ptr ptr ptr ptr ptr ptr double ptr (void) mgl_surf3c_xyz_val +libmgl mgl_surf3c_val ptr ptr ptr ptr double ptr (void) mgl_surf3c_val +libmgl mgl_surf3c_xyz ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_surf3c_xyz +libmgl mgl_surf3c ptr ptr ptr ptr ptr (void) mgl_surf3c +libmgl mgl_cloud_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_cloud_xyz +libmgl mgl_cloud ptr ptr ptr ptr (void) mgl_cloud +libmgl mgl_beam_val int ptr double ptr ptr ptr ptr double ptr (void) mgl_beam_val +libmgl mgl_beam int int ptr double ptr ptr ptr ptr ptr (void) mgl_beam +libmgl mgl_traj_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_traj_xy +libmgl mgl_traj_xyz ptr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_traj_xyz +libmgl mgl_vect_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_vect_xy +libmgl mgl_vect_2d ptr ptr ptr ptr ptr (void) mgl_vect_2d +libmgl mgl_vect_xyz ptr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_vect_xyz +libmgl mgl_vect_3d ptr ptr ptr ptr ptr ptr (void) mgl_vect_3d +libmgl mgl_flow_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_flow_xy +libmgl mgl_flow_2d ptr ptr ptr ptr ptr (void) mgl_flow_2d +libmgl mgl_flow_xyz ptr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_flow_xyz +libmgl mgl_flow_3d ptr ptr ptr ptr ptr ptr (void) mgl_flow_3d +libmgl mgl_flowp_xy ptr ptr ptr ptr ptr ptr double double double ptr (void) mgl_flowp_xy +libmgl mgl_flowp_2d ptr ptr ptr ptr double double double ptr (void) mgl_flowp_2d +libmgl mgl_flowp_xyz ptr ptr ptr ptr ptr ptr ptr ptr double double double ptr (void) mgl_flowp_xyz +libmgl mgl_flowp_3d ptr ptr ptr ptr ptr double double double ptr (void) mgl_flowp_3d +libmgl mgl_pipe_xy ptr double ptr ptr ptr ptr ptr ptr (void) mgl_pipe_xy +libmgl mgl_pipe_2d ptr double ptr ptr ptr ptr (void) mgl_pipe_2d +libmgl mgl_pipe_xyz ptr double ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_pipe_xyz +libmgl mgl_pipe_3d ptr double ptr ptr ptr ptr ptr (void) mgl_pipe_3d +libmgl mgl_grad_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_grad_xyz +libmgl mgl_grad_xy ptr ptr ptr ptr ptr ptr (void) mgl_grad_xy +libmgl mgl_grad ptr ptr ptr ptr (void) mgl_grad +libmgl mgl_vect3_xyz ptr double ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_vect3_xyz +libmgl mgl_vect3 ptr double ptr ptr ptr ptr ptr (void) mgl_vect3 +libmgl mgl_mark ptr double double double ptr (void) mgl_mark +libmgl mgl_ball double double double ptr (void) mgl_ball +libmgl mgl_line int ptr double double double double double double ptr (void) mgl_line +libmgl mgl_curve int ptr double double double double double double double double double double double double ptr (void) mgl_curve +libmgl mgl_error_box ptr double double double double double double ptr (void) mgl_error_box +libmgl mgl_face ptr double double double double double double double double double double double double ptr (void) mgl_face +libmgl mgl_facex double double ptr double double double double double ptr (void) mgl_facex +libmgl mgl_facey double double ptr double double double double double ptr (void) mgl_facey +libmgl mgl_facez double double ptr double double double double double ptr (void) mgl_facez +libmgl mgl_sphere ptr double double double double ptr (void) mgl_sphere +libmgl mgl_drop double double ptr double double double double double double double ptr (void) mgl_drop +libmgl mgl_cone ptr double double double double double double double double ptr (void) mgl_cone +libmgl mgl_ellipse ptr double double double double double double double ptr (void) mgl_ellipse +libmgl mgl_rhomb ptr double double double double double double double ptr (void) mgl_rhomb +libmgl mgl_cones_xyz ptr ptr ptr ptr ptr ptr (void) mgl_cones_xyz +libmgl mgl_cones_xz ptr ptr ptr ptr ptr (void) mgl_cones_xz +libmgl mgl_cones ptr ptr ptr ptr (void) mgl_cones +libmgl mgl_dew_xy ptr ptr ptr ptr ptr ptr ptr (void) mgl_dew_xy +libmgl mgl_dew_2d ptr ptr ptr ptr ptr (void) mgl_dew_2d +libmgl mgl_puts_dir double ptr ptr double double double double double double ptr (void) mgl_puts_dir +libmgl mgl_putsw_dir double ptr ptr double double double double double double ptr (void) mgl_putsw_dir +libmgl mgl_textmark_xyzr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmark_xyzr +libmgl mgl_textmarkw_xyzr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmarkw_xyzr +libmgl mgl_textmark_xyr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmark_xyr +libmgl mgl_textmarkw_xyr ptr ptr ptr ptr ptr ptr ptr (void) mgl_textmarkw_xyr +libmgl mgl_textmark_yr ptr ptr ptr ptr ptr ptr (void) mgl_textmark_yr +libmgl mgl_textmarkw_yr ptr ptr ptr ptr ptr ptr (void) mgl_textmarkw_yr +libmgl mgl_textmark ptr ptr ptr ptr ptr (void) mgl_textmark +libmgl mgl_textmarkw ptr ptr ptr ptr ptr (void) mgl_textmarkw +libmgl mgl_label_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_label_xyz +libmgl mgl_labelw_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_labelw_xyz +libmgl mgl_label_xy ptr ptr ptr ptr ptr ptr (void) mgl_label_xy +libmgl mgl_labelw_xy ptr ptr ptr ptr ptr ptr (void) mgl_labelw_xy +libmgl mgl_label_y ptr ptr ptr ptr ptr (void) mgl_label_y +libmgl mgl_labelw_y ptr ptr ptr ptr ptr (void) mgl_labelw_y +libmgl mgl_table ptr ptr ptr ptr double double ptr (void) mgl_table +libmgl mgl_tablew ptr ptr ptr ptr double double ptr (void) mgl_tablew +libmgl mgl_triplot_xyzc ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_triplot_xyzc +libmgl mgl_triplot_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_triplot_xyz +libmgl mgl_triplot_xy ptr ptr ptr ptr ptr ptr (void) mgl_triplot_xy +libmgl mgl_quadplot_xyzc ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_quadplot_xyzc +libmgl mgl_quadplot_xyz ptr ptr ptr ptr ptr ptr ptr (void) mgl_quadplot_xyz +libmgl mgl_quadplot_xy ptr ptr ptr ptr ptr ptr (void) mgl_quadplot_xy +libmgl mgl_tricont_xyzcv ptr ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_tricont_xyzcv +libmgl mgl_tricont_xycv ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_tricont_xycv +libmgl mgl_tricont_xyzc ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_tricont_xyzc +libmgl mgl_tricont_xyc ptr ptr ptr ptr ptr ptr ptr (void) mgl_tricont_xyc +libmgl mgl_dots ptr ptr ptr ptr ptr ptr (void) mgl_dots +libmgl mgl_dots_a ptr ptr ptr ptr ptr ptr ptr (void) mgl_dots_a +libmgl mgl_dots_ca ptr ptr ptr ptr ptr ptr ptr ptr (void) mgl_dots_ca +libmgl mgl_crust ptr ptr ptr ptr ptr ptr (void) mgl_crust +libmgl mgl_dens_x ptr double ptr ptr ptr (void) mgl_dens_x +libmgl mgl_dens_y ptr double ptr ptr ptr (void) mgl_dens_y +libmgl mgl_dens_z ptr double ptr ptr ptr (void) mgl_dens_z +libmgl mgl_cont_x ptr double ptr ptr ptr (void) mgl_cont_x +libmgl mgl_cont_y ptr double ptr ptr ptr (void) mgl_cont_y +libmgl mgl_cont_z ptr double ptr ptr ptr (void) mgl_cont_z +libmgl mgl_cont_x_val ptr double ptr ptr ptr ptr (void) mgl_cont_x_val +libmgl mgl_cont_y_val ptr double ptr ptr ptr ptr (void) mgl_cont_y_val +libmgl mgl_cont_z_val ptr double ptr ptr ptr ptr (void) mgl_cont_z_val +libmgl mgl_contf_x ptr double ptr ptr ptr (void) mgl_contf_x +libmgl mgl_contf_y ptr double ptr ptr ptr (void) mgl_contf_y +libmgl mgl_contf_z ptr double ptr ptr ptr (void) mgl_contf_z +libmgl mgl_contf_x_val ptr double ptr ptr ptr ptr (void) mgl_contf_x_val +libmgl mgl_contf_y_val ptr double ptr ptr ptr ptr (void) mgl_contf_y_val +libmgl mgl_contf_z_val ptr double ptr ptr ptr ptr (void) mgl_contf_z_val +libmgl mgl_create_graph int int (ptr) mgl_create_graph +libmgl mgl_delete_graph ptr (void) mgl_delete_graph +libmgl mgl_set_size int int ptr (void) mgl_set_size +libmgl mgl_set_def_param ptr (void) mgl_set_def_param +libmgl mgl_combine_gr ptr ptr (void) mgl_combine_gr +libmgl mgl_finish ptr (void) mgl_finish +libmgl mgl_set_tick_len double double ptr (void) mgl_set_tick_len +libmgl mgl_set_axis_stl ptr ptr ptr ptr (void) mgl_set_axis_stl +libmgl mgl_adjust_ticks ptr ptr (void) mgl_adjust_ticks +libmgl mgl_set_ticks double int double char ptr (void) mgl_set_ticks +libmgl mgl_set_ticks_str int ptr char ptr (void) mgl_set_ticks_str +libmgl mgl_set_ticks_wcs int ptr char ptr (void) mgl_set_ticks_wcs +libmgl mgl_set_ticks_val int ptr ptr char ptr (void) mgl_set_ticks_val +libmgl mgl_set_ticks_valw int ptr ptr char ptr (void) mgl_set_ticks_valw +libmgl mgl_tune_ticks double int ptr (void) mgl_tune_ticks +libmgl mgl_set_tick_templ ptr char ptr (void) mgl_set_tick_templ +libmgl mgl_set_tick_templw ptr char ptr (void) mgl_set_tick_templw +libmgl mgl_set_ticks_time ptr double char ptr (void) mgl_set_ticks_time +libmgl mgl_set_tick_shift double double double double ptr (void) mgl_set_tick_shift +libmgl mgl_box ptr (void) mgl_box +libmgl mgl_box_str int ptr ptr (void) mgl_box_str +libmgl mgl_axis ptr ptr ptr ptr (void) mgl_axis +libmgl mgl_axis_grid ptr ptr ptr ptr (void) mgl_axis_grid +libmgl mgl_label ptr double ptr char ptr (void) mgl_label +libmgl mgl_labelw ptr double ptr char ptr (void) mgl_labelw +libmgl mgl_colorbar ptr ptr (void) mgl_colorbar +libmgl mgl_colorbar_ext double double double double ptr ptr (void) mgl_colorbar_ext +libmgl mgl_colorbar_val ptr ptr ptr (void) mgl_colorbar_val +libmgl mgl_colorbar_val_ext double double double double ptr ptr ptr (void) mgl_colorbar_val_ext +libmgl mgl_add_legend ptr ptr ptr (void) mgl_add_legend +libmgl mgl_add_legendw ptr ptr ptr (void) mgl_add_legendw +libmgl mgl_clear_legend ptr (void) mgl_clear_legend +libmgl mgl_legend_pos ptr ptr double double ptr (void) mgl_legend_pos +libmgl mgl_legend ptr ptr int ptr (void) mgl_legend +libmgl mgl_set_legend_marks int ptr (void) mgl_set_legend_marks +libmgl mgl_show_image int ptr ptr (void) mgl_show_image +libmgl mgl_write_frame ptr ptr ptr (void) mgl_write_frame +libmgl mgl_write_tga ptr ptr ptr (void) mgl_write_tga +libmgl mgl_write_bmp ptr ptr ptr (void) mgl_write_bmp +libmgl mgl_write_jpg ptr ptr ptr (void) mgl_write_jpg +libmgl mgl_write_png ptr ptr ptr (void) mgl_write_png +libmgl mgl_write_png_solid ptr ptr ptr (void) mgl_write_png_solid +libmgl mgl_write_bps ptr ptr ptr (void) mgl_write_bps +libmgl mgl_write_eps ptr ptr ptr (void) mgl_write_eps +libmgl mgl_write_svg ptr ptr ptr (void) mgl_write_svg +libmgl mgl_write_tex ptr ptr ptr (void) mgl_write_tex +libmgl mgl_write_obj int ptr ptr ptr (void) mgl_write_obj +libmgl mgl_write_obj_old int ptr ptr ptr (void) mgl_write_obj_old +libmgl mgl_write_stl ptr ptr ptr (void) mgl_write_stl +libmgl mgl_write_off int ptr ptr ptr (void) mgl_write_off +libmgl mgl_write_xyz ptr ptr ptr (void) mgl_write_xyz +libmgl mgl_write_prc int ptr ptr ptr (void) mgl_write_prc +libmgl mgl_write_gif ptr ptr ptr (void) mgl_write_gif +libmgl mgl_start_gif int ptr ptr (void) mgl_start_gif +libmgl mgl_close_gif ptr (void) mgl_close_gif +libmgl mgl_export_mgld ptr ptr ptr (void) mgl_export_mgld +libmgl mgl_import_mgld int ptr ptr (void) mgl_import_mgld +libmgl mgl_write_json ptr ptr ptr (void) mgl_write_json +libmgl mgl_write_json_z ptr ptr ptr (void) mgl_write_json_z +libmgl gl_get_json ptr (ptr) gl_get_json +libmgl gl_get_rgb ptr (ptr) gl_get_rgb +libmgl gl_get_rgba ptr (ptr) gl_get_rgba +libmgl mgl_set_obj_id int ptr (void) mgl_set_obj_id +libmgl mgl_get_obj_id int int ptr (int) mgl_get_obj_id +libmgl mgl_get_spl_id int int ptr (int) mgl_get_spl_id +libmgl mgl_get_width ptr (int) mgl_get_width +libmgl mgl_get_height ptr (int) mgl_get_height +libmgl mgl_calc_xyz ptr ptr ptr int int ptr (void) mgl_calc_xyz +libmgl mgl_calc_scr ptr ptr double double double ptr (void) mgl_calc_scr +libmgl mgl_is_active int int int ptr (int) mgl_is_active +libmgl mgl_new_frame ptr (int) mgl_new_frame +libmgl mgl_end_frame ptr (void) mgl_end_frame +libmgl mgl_get_num_frame ptr (int) mgl_get_num_frame +libmgl mgl_reset_frames ptr (void) mgl_reset_frames +libmgl mgl_get_frame int ptr (void) mgl_get_frame +libmgl mgl_set_frame int ptr (void) mgl_set_frame +libmgl mgl_show_frame int ptr (void) mgl_show_frame +libmgl mgl_del_frame int ptr (void) mgl_del_frame +libmgl mgl_set_transp_type int ptr (void) mgl_set_transp_type +libmgl mgl_set_alpha int ptr (void) mgl_set_alpha +libmgl mgl_set_fog double double ptr (void) mgl_set_fog +libmgl mgl_set_light int ptr (void) mgl_set_light +libmgl mgl_set_light_n int int ptr (void) mgl_set_light_n +libmgl mgl_add_light double double double int ptr (void) mgl_add_light +libmgl mgl_add_light_ext double double char double double double int ptr (void) mgl_add_light_ext +libmgl mgl_add_light_loc double double char double double double double double double int ptr (void) mgl_add_light_loc +libmgl mgl_mat_pop ptr (void) mgl_mat_pop +libmgl mgl_mat_push ptr (void) mgl_mat_push +libmgl mgl_clf ptr (void) mgl_clf +libmgl mgl_clf_rgb double double double ptr (void) mgl_clf_rgb +libmgl mgl_clf_chr char ptr (void) mgl_clf_chr +libmgl mgl_subplot ptr int int int ptr (void) mgl_subplot +libmgl mgl_subplot_d double double ptr int int int ptr (void) mgl_subplot_d +libmgl mgl_multiplot ptr int int int int int ptr (void) mgl_multiplot +libmgl mgl_inplot double double double double ptr (void) mgl_inplot +libmgl mgl_relplot double double double double ptr (void) mgl_relplot +libmgl mgl_columnplot double int int ptr (void) mgl_columnplot +libmgl mgl_gridplot double int int int ptr (void) mgl_gridplot +libmgl mgl_stickplot double double int int ptr (void) mgl_stickplot +libmgl mgl_title double ptr ptr ptr (void) mgl_title +libmgl mgl_titlew double ptr ptr ptr (void) mgl_titlew +libmgl mgl_set_plotfactor double ptr (void) mgl_set_plotfactor +libmgl mgl_aspect double double double ptr (void) mgl_aspect +libmgl mgl_rotate double double double ptr (void) mgl_rotate +libmgl mgl_rotate_vector double double double double ptr (void) mgl_rotate_vector +libmgl mgl_perspective double ptr (void) mgl_perspective +libmgl mgl_view double double double ptr (void) mgl_view +libmgl mgl_zoom double double double double ptr (void) mgl_zoom +libmgl mgl_wnd_set_delay double ptr (void) mgl_wnd_set_delay +libmgl mgl_wnd_get_delay ptr (double) mgl_wnd_get_delay +libmgl mgl_setup_window int int ptr (void) mgl_setup_window +libmgl mgl_wnd_toggle_alpha ptr (void) mgl_wnd_toggle_alpha +libmgl mgl_wnd_toggle_light ptr (void) mgl_wnd_toggle_light +libmgl mgl_wnd_toggle_zoom ptr (void) mgl_wnd_toggle_zoom +libmgl mgl_wnd_toggle_rotate ptr (void) mgl_wnd_toggle_rotate +libmgl mgl_wnd_toggle_no ptr (void) mgl_wnd_toggle_no +libmgl mgl_wnd_update ptr (void) mgl_wnd_update +libmgl mgl_wnd_reload ptr (void) mgl_wnd_reload +libmgl mgl_wnd_adjust ptr (void) mgl_wnd_adjust +libmgl mgl_wnd_next_frame ptr (void) mgl_wnd_next_frame +libmgl mgl_wnd_prev_frame ptr (void) mgl_wnd_prev_frame +libmgl mgl_wnd_animation ptr (void) mgl_wnd_animation +libmgl mgl_get_last_mouse_pos ptr ptr ptr ptr (void) mgl_get_last_mouse_pos +libmgl mgl_create_parser (ptr) mgl_create_parser +libmgl mgl_use_parser int ptr (int) mgl_use_parser +libmgl mgl_delete_parser ptr (void) mgl_delete_parser +libmgl mgl_parser_add_param ptr int ptr (void) mgl_parser_add_param +libmgl mgl_parser_add_paramw ptr int ptr (void) mgl_parser_add_paramw +libmgl mgl_parser_add_var ptr ptr (ptr) mgl_parser_add_var +libmgl mgl_parser_add_varw ptr ptr (ptr) mgl_parser_add_varw +libmgl mgl_parser_find_var ptr ptr (ptr) mgl_parser_find_var +libmgl mgl_parser_find_varw ptr ptr (ptr) mgl_parser_find_varw +libmgl mgl_parser_del_var ptr ptr (void) mgl_parser_del_var +libmgl mgl_parser_del_varw ptr ptr (void) mgl_parser_del_varw +libmgl mgl_parser_del_all ptr (void) mgl_parser_del_all +libmgl mgl_parse_line int ptr ptr ptr (int) mgl_parse_line +libmgl mgl_parse_linew int ptr ptr ptr (int) mgl_parse_linew +libmgl mgl_parse_text ptr ptr ptr (void) mgl_parse_text +libmgl mgl_parse_textw ptr ptr ptr (void) mgl_parse_textw +libmgl mgl_parser_restore_once ptr (void) mgl_parser_restore_once +libmgl mgl_parser_allow_setsize int ptr (void) mgl_parser_allow_setsize +libmgl mgl_parser_allow_file_io int ptr (void) mgl_parser_allow_file_io +libmgl mgl_parser_stop ptr (void) mgl_parser_stop +libmgl mgl_parser_cmd_type ptr ptr (int) mgl_parser_cmd_type +libmgl gl_parser_cmd_desc ptr ptr (ptr) gl_parser_cmd_desc +libmgl gl_parser_cmd_frmt ptr ptr (ptr) gl_parser_cmd_frmt +libmgl gl_parser_cmd_name int ptr (ptr) gl_parser_cmd_name +libmgl mgl_parser_cmd_num ptr (int) mgl_parser_cmd_num +libmgl mgl_parser_calc ptr ptr (ptr) mgl_parser_calc +libmgl mgl_parser_calcw ptr ptr (ptr) mgl_parser_calcw +libmgl mgl_create_expr ptr (ptr) mgl_create_expr +libmgl mgl_delete_expr ptr (void) mgl_delete_expr +libmgl mgl_expr_eval double double double ptr (double) mgl_expr_eval +libmgl mgl_expr_eval_v ptr ptr (double) mgl_expr_eval_v +libmgl mgl_expr_diff double double double char ptr (double) mgl_expr_diff +libmgl mgl_expr_diff_v ptr char ptr (double) mgl_expr_diff_v +libmgl mgl_gauss_rnd (double) mgl_gauss_rnd +libmgl mgl_fft_freq int ptr (void) mgl_fft_freq +libmgl mgl_strcls ptr (void) mgl_strcls +libmgl mgl_strpos ptr ptr (int) mgl_strpos +libmgl mgl_chrpos char ptr (int) mgl_chrpos +libmgl mgl_istrue char (int) mgl_istrue diff --git a/include/mgl2/mgl.h b/include/mgl2/mgl.h new file mode 100644 index 0000000..8266c96 --- /dev/null +++ b/include/mgl2/mgl.h @@ -0,0 +1,1293 @@ +/*************************************************************************** + * mgl.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_H_ +#define _MGL_H_ + +#include "mgl2/mgl_cf.h" +#ifdef __cplusplus +#include "mgl2/data.h" +#include "mgl2/datac.h" +//----------------------------------------------------------------------------- +/// Wrapper class for all graphics +class MGL_EXPORT mglGraph +{ +protected: + HMGL gr; +public: + inline mglGraph(int kind=0, int width=600, int height=400) + { + if(kind==-1) gr=NULL; +#if MGL_HAVE_OPENGL + else if(kind==1) gr=mgl_create_graph_gl(); +#else + else if(kind==1) + { gr=mgl_create_graph(width, height); + mglGlobalMess += "OpenGL support was disabled. Please, enable it and rebuild MathGL.\n"; } +#endif + else gr=mgl_create_graph(width, height); + } + inline mglGraph(const mglGraph &graph) + { gr = graph.gr; mgl_use_graph(gr,1); } + inline mglGraph(HMGL graph) + { gr = graph; mgl_use_graph(gr,1); } + virtual ~mglGraph() + { if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); } + /// Get pointer to internal mglCanvas object + inline HMGL Self() { return gr; } + /// Set default parameters for plotting + inline void DefaultPlotParam() { mgl_set_def_param(gr); } + /// Set name of plot for saving filename + inline void SetPlotId(const char *id) { mgl_set_plotid(gr,id); } + /// Get name of plot for saving filename + inline const char *GetPlotId() { return mgl_get_plotid(gr); } + + /// Set the transparency on/off. + inline void Alpha(bool enable) { mgl_set_alpha(gr, enable); } + /// Set default value of alpha-channel + inline void SetAlphaDef(double alpha) { mgl_set_alpha_default(gr, alpha); } + /// Set the transparency type (0 - usual, 1 - glass, 2 - lamp) + inline void SetTranspType(int type) { mgl_set_transp_type(gr, type); } + + /// Set the using of light on/off. + inline void Light(bool enable) { mgl_set_light(gr, enable); } + /// Switch on/off the specified light source. + inline void Light(int n,bool enable) { mgl_set_light_n(gr, n, enable); } + /// Use diffusive light (only for local light sources) -- OBSOLETE + inline void SetDifLight(bool dif) { mgl_set_light_dif(gr, dif); } + /// Add a light source. + inline void AddLight(int n, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_ext(gr, n, p.x, p.y, p.z, col, bright, ap); } + inline void AddLight(int n, mglPoint r, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_loc(gr, n, r.x, r.y, r.z, p.x, p.y, p.z, col, bright, ap); } + /// Set ambient light brightness + inline void SetAmbient(double i) { mgl_set_ambbr(gr, i); } + /// Set diffusive light brightness + inline void SetDiffuse(double i) { mgl_set_difbr(gr, i); } + /// Set the fog distance or switch it off (if d=0). + inline void Fog(double d, double dz=0.25) { mgl_set_fog(gr, d, dz); } + + /// Set relative width of rectangles in Bars, Barh, BoxPlot + inline void SetBarWidth(double width) { mgl_set_bar_width(gr, width); } + /// Set default size of marks (locally you can use "size" option) + inline void SetMarkSize(double size) { mgl_set_mark_size(gr, size); } + /// Set default size of arrows (locally you can use "size" option) + inline void SetArrowSize(double size) { mgl_set_arrow_size(gr, size); } + /// Set number of mesh lines (use 0 to draw all of them) + inline void SetMeshNum(int num) { mgl_set_meshnum(gr, num); } + /// Set number of visible faces (use 0 to draw all of them) + inline void SetFaceNum(int num) { mgl_set_facenum(gr, num); } + + /// Set cutting for points outside of bounding box + inline void SetCut(bool cut) { mgl_set_cut(gr, cut); } + /// Set additional cutting box + inline void SetCutBox(mglPoint p1, mglPoint p2) + { mgl_set_cut_box(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z); } + /// Set the cutting off condition (formula) + inline void CutOff(const char *EqC) { mgl_set_cutoff(gr, EqC); } + + /// Set default font size + inline void SetFontSize(double size) { mgl_set_font_size(gr, size); } + /// Set default font style and color + inline void SetFontDef(const char *fnt) { mgl_set_font_def(gr, fnt); } + /// Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72) + virtual void SetFontSizePT(double pt, int dpi=72){ SetFontSize(pt*27.f/dpi); } + /// Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt) + inline void SetFontSizeCM(double cm, int dpi=72) { SetFontSizePT(cm*28.45f,dpi); } + /// Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt) + inline void SetFontSizeIN(double in, int dpi=72) { SetFontSizePT(in*72.27f,dpi); } + /// Load font from file + inline void LoadFont(const char *name, const char *path=NULL) + { mgl_load_font(gr, name, path); } + /// Copy font from another mglGraph instance + inline void CopyFont(const mglGraph *GR) { mgl_copy_font(gr, GR->gr);} + /// Restore font (load default font for new HMGL objects) + inline void RestoreFont() { mgl_restore_font(gr); } + /// Set to use or not text rotation + inline void SetRotatedText(bool rotated) { mgl_set_rotated_text(gr, rotated); } + + /// Set default palette + inline void SetPalette(const char *colors) { mgl_set_palette(gr, colors); } + /// Set default color scheme + inline void SetDefScheme(const char *sch) { mgl_set_def_sch(gr, sch); } + + /// Sets RGB values for color with given id + static inline void SetColor(char id, double r, double g, double b) { mgl_set_color(id, r, g, b); } + /// Set mask for face coloring as array of type 'unsigned char[8]' + static inline void SetMask(char id, const char *mask) { mgl_set_mask(id, mask); } + /// Set mask for face coloring as uint64_t number + static inline void SetMask(char id, uint64_t mask) { mgl_set_mask_val(id, mask); } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { mgl_set_mask_angle(gr, angle); } + + /// Get last warning code + inline int GetWarn() { return mgl_get_warn(gr);} + /// Set warning code ant fill message + inline void SetWarn(int code, const char *info) { mgl_set_warn(gr,code,info); } + /// Set buffer for warning messages + inline const char *Message() { return mgl_get_mess(gr); } + + /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image! + inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1)) + { mgl_zoom_axis(gr, p1.x,p1.y,p1.z,p1.c, p2.x,p2.y,p2.z,p2.c); } + /// Add [v1, v2] to the current range in direction dir + inline void AddRange(char dir, double v1, double v2) + { mgl_add_range_val(gr, dir, v1, v2); } + /// Set range in direction dir as [v1, v2] + inline void SetRange(char dir, double v1, double v2) + { mgl_set_range_val(gr, dir, v1, v2); } + /// Set range in direction dir as minimal and maximal values of data a + inline void SetRange(char dir, const mglDataA &dat, bool add=false) + { mgl_set_range_dat(gr, dir, &dat, add); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglDataA &xx, const mglDataA &yy, const mglDataA &zz, const mglDataA &cc) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&cc,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglDataA &xx, const mglDataA &yy, const mglDataA &zz) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&zz,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglDataA &xx, const mglDataA &yy) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); } + /// Set values of axis ranges + inline void SetRanges(double x1, double x2, double y1, double y2, double z1=0, double z2=0) + { mgl_set_ranges(gr, x1, x2, y1, y2, z1, z2); } + /// Set values of axis ranges + inline void SetRanges(mglPoint p1, mglPoint p2) + { mgl_set_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z); } + /// Set ranges for automatic variables + inline void SetAutoRanges(double x1, double x2, double y1=0, double y2=0, double z1=0, double z2=0, double c1=0, double c2=0) + { mgl_set_auto_ranges(gr, x1, x2, y1, y2, z1, z2, c1, c2); } + /// Set ranges for automatic variables + inline void SetAutoRanges(mglPoint p1, mglPoint p2) + { mgl_set_auto_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z, p1.c, p2.c); } + /// Set axis origin + inline void SetOrigin(mglPoint p) + { mgl_set_origin(gr, p.x, p.y, p.z); } + inline void SetOrigin(double x0, double y0, double z0=NaN) + { mgl_set_origin(gr, x0, y0, z0); } + + /// Set the transformation formulas for coordinate + inline void SetFunc(const char *EqX, const char *EqY, const char *EqZ=NULL, const char *EqA=NULL) + { mgl_set_func(gr, EqX, EqY, EqZ, EqA); } + /// Set one of predefined transformation rule + inline void SetCoor(int how) { mgl_set_coor(gr, how); } + /// Set to draw Ternary axis (triangle like axis, grid and so on) + inline void Ternary(int val) { mgl_set_ternary(gr, val); } + + /// Set to use or not tick labels rotation + inline void SetTickRotate(bool val) { mgl_set_tick_rotate(gr,val); } + /// Set to use or not tick labels skipping + inline void SetTickSkip(bool val) { mgl_set_tick_skip(gr,val); } + /// Set tick length + inline void SetTickLen(double len, double stt=1) + { mgl_set_tick_len(gr, len, stt); } + /// Set axis and ticks style + inline void SetAxisStl(const char *stl="k", const char *tck=0, const char *sub=0) + { mgl_set_axis_stl(gr, stl, tck, sub); } + + /// Set time templates for ticks + inline void SetTicksTime(char dir, double d=0, const char *t="") + { mgl_set_ticks_time(gr,dir,d,t); } + /// Set ticks text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const char *lbl, bool add=false) + { mgl_set_ticks_str(gr,dir,lbl,add); } + inline void SetTicksVal(char dir, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_wcs(gr,dir,lbl,add); } + /// Set ticks position and text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const mglDataA &v, const char *lbl, bool add=false) + { mgl_set_ticks_val(gr,dir,&v,lbl,add); } + inline void SetTicksVal(char dir, const mglDataA &v, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_valw(gr,dir,&v,lbl,add); } + /// Set the ticks parameters + inline void SetTicks(char dir, double d=0, int ns=0, double org=NaN) + { mgl_set_ticks(gr, dir, d, ns, org); } + /// Auto adjust ticks + inline void Adjust(const char *dir="xyzc") + { mgl_adjust_ticks(gr, dir); } + /// Set templates for ticks + inline void SetTickTempl(char dir, const char *t) + { mgl_set_tick_templ(gr,dir,t); } + inline void SetTickTempl(char dir, const wchar_t *t) + { mgl_set_tick_templw(gr,dir,t); } + /// Tune ticks + inline void SetTuneTicks(int tune, double fact_pos=1.15) + { mgl_tune_ticks(gr, tune, fact_pos); } + /// Set additional shift of tick labels + inline void SetTickShift(mglPoint p) + { mgl_set_tick_shift(gr,p.x,p.y,p.z,p.c); } + /// Set to use UTC time instead of local time + inline void SetTimeUTC(bool enable) + { mgl_set_flag(gr,enable, MGL_USE_GMTIME); } + /// Set to draw tick labels at axis origin + inline void SetOriginTick(bool enable=true) + { mgl_set_flag(gr,!enable, MGL_NO_ORIGIN); } + + /// Put further plotting in some region of whole frame. + inline void SubPlot(int nx,int ny,int m,const char *style="<>_^", double dx=0, double dy=0) + { mgl_subplot_d(gr, nx, ny, m, style, dx, dy); } + /// Like SubPlot() but "join" several cells + inline void MultiPlot(int nx,int ny,int m, int dx, int dy, const char *style="<>_^") + { mgl_multiplot(gr, nx, ny, m, dx, dy, style); } + /// Put further plotting in a region of whole frame. + inline void InPlot(double x1,double x2,double y1,double y2, bool rel=true) + { if(rel) mgl_relplot(gr, x1, x2, y1, y2); + else mgl_inplot(gr, x1, x2, y1, y2); } + /// Put further plotting in column cell of previous subplot + inline void ColumnPlot(int num, int ind, double d=0) + { mgl_columnplot(gr,num,ind,d); } + /// Put further plotting in matrix cell of previous subplot + inline void GridPlot(int nx, int ny, int ind, double d=0) + { mgl_gridplot(gr,nx,ny,ind,d); } + /// Put further plotting in cell of stick rotated on angles tet, phi + inline void StickPlot(int num, int i, double tet, double phi) + { mgl_stickplot(gr,num,i,tet,phi); } + + /// Set factor of plot size + inline void SetPlotFactor(double val) + { mgl_set_plotfactor(gr,val); } + /// Push transformation matrix into stack + inline void Push() { mgl_mat_push(gr); } + /// Pop transformation matrix from stack + inline void Pop() { mgl_mat_pop(gr); } + + /// Add title for current subplot/inplot + inline void Title(const char *title,const char *stl="",double size=-2) + { mgl_title(gr,title,stl,size); } + inline void Title(const wchar_t *title,const char *stl="",double size=-2) + { mgl_titlew(gr,title,stl,size); } + /// Set aspect ratio for further plotting. + inline void Aspect(double Ax,double Ay,double Az=1) + { mgl_aspect(gr, Ax, Ay, Az); } + /// Rotate a further plotting. + inline void Rotate(double TetX,double TetZ=0,double TetY=0) + { mgl_rotate(gr, TetX, TetZ, TetY); } + /// Rotate a further plotting around vector {x,y,z}. + inline void RotateN(double Tet,double x,double y,double z) + { mgl_rotate_vector(gr, Tet, x, y, z); } + /// Set perspective (in range [0,1)) for plot. Set to zero for switching off. + inline void Perspective(double val) + { mgl_perspective(gr, val); } + /// Set angle of view independently from Rotate(). + inline void View(double TetX,double TetZ=0,double TetY=0) + { mgl_view(gr, TetX, TetZ, TetY); } + /// Zoom in/out a part of picture (use Zoom(0, 0, 1, 1) for restore default) + inline void Zoom(double x1, double y1, double x2, double y2) + { mgl_zoom(gr, x1, y1, x2, y2); } + + /// Set size of frame in pixels. Normally this function is called internally. + inline void SetSize(int width, int height) { mgl_set_size(gr, width, height); } + /// Set plot quality + inline void SetQuality(int qual=MGL_DRAW_NORM) { mgl_set_quality(gr, qual); } + /// Get plot quality + inline int GetQuality() { return mgl_get_quality(gr); } + /// Set drawing region for Quality&4 + inline void SetDrawReg(long nx=1, long ny=1, long m=0) { mgl_set_draw_reg(gr,nx,ny,m); } + /// Start group of objects + inline void StartGroup(const char *name) { mgl_start_group(gr, name); } + /// End group of objects + inline void EndGroup() { mgl_end_group(gr); } + /// Highlight objects with given id + inline void Highlight(int id) { mgl_highlight(gr, id); } + + /// Show current image + inline void ShowImage(const char *viewer, bool keep=0) + { mgl_show_image(gr, viewer, keep); } + /// Write the frame in file (depending extension, write current frame if fname is empty) + inline void WriteFrame(const char *fname=0,const char *descr="") + { mgl_write_frame(gr, fname, descr); } + /// Write the frame in file using JPEG format + inline void WriteJPEG(const char *fname,const char *descr="") + { mgl_write_jpg(gr, fname, descr); } + /// Write the frame in file using PNG format with transparency + inline void WritePNG(const char *fname,const char *descr="", bool alpha=true) + { if(alpha) mgl_write_png(gr, fname, descr); + else mgl_write_png_solid(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteBMP(const char *fname,const char *descr="") + { mgl_write_bmp(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteTGA(const char *fname,const char *descr="") + { mgl_write_tga(gr, fname, descr); } + /// Write the frame in file using PostScript format + inline void WriteEPS(const char *fname,const char *descr="") + { mgl_write_eps(gr, fname, descr); } + /// Write the frame in file using LaTeX format + inline void WriteTEX(const char *fname,const char *descr="") + { mgl_write_tex(gr, fname, descr); } + /// Write the frame in file using PostScript format as bitmap + inline void WriteBPS(const char *fname,const char *descr="") + { mgl_write_bps(gr, fname, descr); } + /// Write the frame in file using SVG format + inline void WriteSVG(const char *fname,const char *descr="") + { mgl_write_svg(gr, fname, descr); } + /// Write the frame in file using GIF format (only for current frame!) + inline void WriteGIF(const char *fname,const char *descr="") + { mgl_write_gif(gr, fname, descr); } + + /// Write the frame in file using OBJ format + inline void WriteOBJ(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj(gr, fname, descr, use_png); } + /// Write the frame in file using OBJ format - Balakin way + inline void WriteOBJold(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj_old(gr, fname, descr, use_png); } + /// Write the frame in file using XYZ format + inline void WriteXYZ(const char *fname,const char *descr="") + { mgl_write_xyz(gr, fname, descr); } + /// Write the frame in file using STL format (faces only) + inline void WriteSTL(const char *fname,const char *descr="") + { mgl_write_stl(gr, fname, descr); } + /// Write the frame in file using OFF format + inline void WriteOFF(const char *fname,const char *descr="", bool colored=false) + { mgl_write_off(gr, fname, descr,colored); } +// /// Write the frame in file using X3D format +// inline void WriteX3D(const char *fname,const char *descr="") +// { mgl_write_x3d(gr, fname, descr); } + /// Write the frame in file using PRC format + inline void WritePRC(const char *fname,const char *descr="",bool make_pdf=true) + { mgl_write_prc(gr, fname, descr, make_pdf); } + /// Export in JSON format suitable for later drawing by JavaScript + inline void WriteJSON(const char *fname,const char *descr="",bool force_z=false) + { if(force_z) mgl_write_json_z(gr, fname, descr); + else mgl_write_json(gr, fname, descr); } + /// Return string of JSON data suitable for later drawing by JavaScript + inline const char *GetJSON() { return mgl_get_json(gr); } + + /// Force preparing the image. It can be useful for OpenGL mode mostly. + inline void Finish() { mgl_finish(gr); } + /// Create new frame. + inline void NewFrame() { mgl_new_frame(gr); } + /// Finish frame drawing + inline void EndFrame() { mgl_end_frame(gr); } + /// Get the number of created frames + inline int GetNumFrame() { return mgl_get_num_frame(gr); } + /// Reset frames counter (start it from zero) + inline void ResetFrames() { mgl_reset_frames(gr); } + /// Delete primitives for i-th frame (work if MGL_VECT_FRAME is set on) + inline void DelFrame(int i) { mgl_del_frame(gr, i); } + /// Get drawing data for i-th frame (work if MGL_VECT_FRAME is set on) + inline void GetFrame(int i) { mgl_get_frame(gr, i); } + /// Set drawing data for i-th frame (work if MGL_VECT_FRAME is set on). Work as EndFrame() but don't add frame to GIF image. + inline void SetFrame(int i) { mgl_set_frame(gr, i); } + /// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) + inline void ShowFrame(int i){ mgl_show_frame(gr, i); } + + /// Start write frames to cinema using GIF format + inline void StartGIF(const char *fname, int ms=100) + { mgl_start_gif(gr, fname,ms); } + /// Stop writing cinema using GIF format + inline void CloseGIF() { mgl_close_gif(gr); } + /// Export points and primitives in file using MGLD format + inline void ExportMGLD(const char *fname, const char *descr=0) + { mgl_export_mgld(gr, fname, descr); } + /// Import points and primitives from file using MGLD format + inline void ImportMGLD(const char *fname, bool add=false) + { mgl_import_mgld(gr, fname, add); } + + /// Copy RGB values into array which is allocated by user + inline void GetRGB(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=3*w*h) memcpy(imgdata, mgl_get_rgb(gr),3*w*h); + } + inline const unsigned char *GetRGB() { return mgl_get_rgb(gr); } + /// Copy RGBA values into array which is allocated by user + inline void GetRGBA(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=4*w*h) memcpy(imgdata, mgl_get_rgba(gr),4*w*h); + } + inline const unsigned char *GetRGBA() { return mgl_get_rgba(gr); } + /// Copy BGRN values into array which is allocated by user + inline void GetBGRN(unsigned char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr), i; + const unsigned char *buf=mgl_get_rgb(gr); + if(imglen>=4*w*h) for(i=0;igr); } + + /// Clear up the frame + inline void Clf(double r, double g, double b) { mgl_clf_rgb(gr, r, g, b); } + inline void Clf(char col) { mgl_clf_chr(gr, col); } + inline void Clf() { mgl_clf(gr); } + /// Clear unused points and primitives. Useful only in combination with SetFaceNum(). + inline void ClearUnused() { mgl_clear_unused(gr); } + /// Draws the point (ball) at position {x,y,z} with color c + inline void Ball(mglPoint p, char c='r') + { char s[3]={'.',c,0}; mgl_mark(gr, p.x, p.y, p.z, s); } + /// Draws the mark at position p + inline void Mark(mglPoint p, const char *mark) + { mgl_mark(gr, p.x, p.y, p.z, mark); } + /// Draws the line between points by specified pen + inline void Line(mglPoint p1, mglPoint p2, const char *pen="B",int n=2) + { mgl_line(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, pen, n); } + /// Draws the spline curve between points by specified pen + inline void Curve(mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *pen="B", int n=100) + { mgl_curve(gr, p1.x, p1.y, p1.z, d1.x, d1.y, d1.z, p2.x, p2.y, p2.z, d2.x, d2.y, d2.z, pen, n); } + /// Draws the 3d error box e for point p + inline void Error(mglPoint p, mglPoint e, const char *pen="k") + { mgl_error_box(gr, p.x, p.y, p.z, e.x, e.y, e.z, pen); } + + /// Draws the face between points with color stl (include interpolation up to 4 colors). + inline void Face(mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="r") + { mgl_face(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z, p4.x, p4.y, p4.z, stl); } + /// Draws the face in y-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceX(mglPoint p, double wy, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facex(gr, p.x, p.y, p.z, wy, wz, stl, dx, dy); } + /// Draws the face in x-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceY(mglPoint p, double wx, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facey(gr, p.x, p.y, p.z, wx, wz, stl, dx, dy); } + /// Draws the face in x-y plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceZ(mglPoint p, double wx, double wy, const char *stl="w", double dx=0, double dy=0) + { mgl_facez(gr, p.x, p.y, p.z, wx, wy, stl, dx, dy); } + /// Draws the drop at point p in direction d with color col and radius r + inline void Drop(mglPoint p, mglPoint d, double r, const char *col="r", double shift=1, double ap=1) + { mgl_drop(gr, p.x, p.y, p.z, d.x, d.y, d.z, r, col, shift, ap); } + /// Draws the sphere at point p with color col and radius r + inline void Sphere(mglPoint p, double r, const char *col="r") + { mgl_sphere(gr, p.x, p.y, p.z, r, col); } + /// Draws the cone between points p1,p2 with radius r1,r2 and with style stl + inline void Cone(mglPoint p1, mglPoint p2, double r1, double r2=-1, const char *stl="r@") + { mgl_cone(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z,r1,r2,stl); } + /// Draws the ellipse between points p1,p2 with color stl and width r + inline void Ellipse(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_ellipse(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + /// Draws the circle at point p with color stl and radius r + inline void Circle(mglPoint p, double r, const char *stl="r") + { mgl_ellipse(gr, p.x, p.y, p.z, p.x, p.y, p.z, r,stl); } + /// Draws the rhomb between points p1,p2 with color stl and width r + inline void Rhomb(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_rhomb(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + + /// Print text in position p with specified font + inline void Putsw(mglPoint p,const wchar_t *text,const char *font=":C",double size=-1) + { mgl_putsw(gr, p.x, p.y, p.z, text, font, size); } + inline void Puts(mglPoint p,const char *text,const char *font=":C",double size=-1) + { mgl_puts(gr, p.x, p.y, p.z, text, font, size); } + inline void Putsw(double x, double y,const wchar_t *text,const char *font=":AC",double size=-1) + { mgl_putsw(gr, x, y, 0, text, font, size); } + inline void Puts(double x, double y,const char *text,const char *font=":AC",double size=-1) + { mgl_puts(gr, x, y, 0, text, font, size); } + /// Print text in position p along direction d with specified font + inline void Putsw(mglPoint p, mglPoint d, const wchar_t *text, const char *font=":L", double size=-1) + { mgl_putsw_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + inline void Puts(mglPoint p, mglPoint d, const char *text, const char *font=":L", double size=-1) + { mgl_puts_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + + /// Print text along the curve + inline void Text(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *text, const char *font="", const char *opt="") + { mgl_text_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglDataA &x, const mglDataA &y, const char *text, const char *font="", const char *opt="") + { mgl_text_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglDataA &y, const char *text, const char *font="", const char *opt="") + { mgl_text_y(gr, &y, text, font, opt); } + inline void Text(const mglDataA &x, const mglDataA &y, const mglDataA &z, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglDataA &x, const mglDataA &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglDataA &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_y(gr, &y, text, font, opt); } + + /// Draws bounding box outside the plotting volume with color c. + inline void Box(const char *col="", bool ticks=true) + { mgl_box_str(gr, col, ticks); } + /// Draw axises with ticks in direction(s) dir. + inline void Axis(const char *dir="xyzt", const char *stl="", const char *opt="") + { mgl_axis(gr, dir,stl,opt); } + /// Draw grid lines perpendicular to direction(s) dir. + inline void Grid(const char *dir="xyzt",const char *pen="B", const char *opt="") + { mgl_axis_grid(gr, dir, pen, opt); } + /// Print the label text for axis dir. + inline void Label(char dir, const char *text, double pos=+1, const char *opt="") + { mgl_label(gr, dir, text, pos, opt); } + inline void Label(char dir, const wchar_t *text, double pos=+1, const char *opt="") + { mgl_labelw(gr, dir, text, pos, opt); } + + /// Draw colorbar at edge of axis + inline void Colorbar(const char *sch="") + { mgl_colorbar(gr, sch); } + inline void Colorbar(const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_ext(gr, sch, x,y,w,h); } + /// Draw colorbar with manual colors at edge of axis + inline void Colorbar(const mglDataA &val, const char *sch="") + { mgl_colorbar_val(gr, &val, sch); } + inline void Colorbar(const mglDataA &val, const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_val_ext(gr, &val, sch, x,y,w,h); } + + /// Add string to legend + inline void AddLegend(const char *text,const char *style) + { mgl_add_legend(gr, text, style); } + inline void AddLegend(const wchar_t *text,const char *style) + { mgl_add_legendw(gr, text, style); } + /// Clear saved legend string + inline void ClearLegend() + { mgl_clear_legend(gr); } + /// Draw legend of accumulated strings at position {x,y} + inline void Legend(double x, double y, const char *font="#", const char *opt="") + { mgl_legend_pos(gr, x, y, font, opt); } + /// Draw legend of accumulated strings + inline void Legend(int where=3, const char *font="#", const char *opt="") + { mgl_legend(gr, where, font, opt); } + /// Set number of marks in legend sample + inline void SetLegendMarks(int num) { mgl_set_legend_marks(gr, num); } + + /// Draw usual curve {x,y,z} + inline void Plot(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_plot_xyz(gr, &x, &y, &z, pen, opt); } + inline void Plot(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_plot_xy(gr, &x, &y, pen,opt); } + inline void Plot(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_plot(gr, &y, pen,opt); } + /// Draw tape(s) which rotates as (bi-)normales of curve {x,y,z} + inline void Tape(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_tape_xyz(gr, &x, &y, &z, pen, opt); } + inline void Tape(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_tape_xy(gr, &x, &y, pen,opt); } + inline void Tape(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_tape(gr, &y, pen,opt); } + /// Draw radar chart (plot in curved coordinates) + inline void Radar(const mglDataA &a, const char *pen="", const char *opt="") + { mgl_radar(gr, &a, pen, opt); } + /// Draw stairs for points in arrays {x,y,z} + inline void Step(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_step_xyz(gr, &x, &y, &z, pen, opt); } + inline void Step(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_step_xy(gr, &x, &y, pen, opt); } + inline void Step(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_step(gr, &y, pen, opt); } + /// Draw curve {x,y,z} which is colored by c (like tension plot) + inline void Tens(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const char *pen="", const char *opt="") + { mgl_tens_xyz(gr, &x, &y, &z, &c, pen, opt); } + inline void Tens(const mglDataA &x, const mglDataA &y, const mglDataA &c, const char *pen="", const char *opt="") + { mgl_tens_xy(gr, &x, &y, &c, pen, opt); } + inline void Tens(const mglDataA &y, const mglDataA &c, const char *pen="", const char *opt="") + { mgl_tens(gr, &y, &c, pen, opt); } + /// Fill area between curve {x,y,z} and axis plane + inline void Area(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_area_xyz(gr, &x, &y, &z, pen, opt); } + inline void Area(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_area_xy(gr, &x, &y, pen, opt); } + inline void Area(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_area(gr, &y, pen, opt); } + /// Fill area between curves y1 and y2 specified parametrically + inline void Region(const mglDataA &y1, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_region(gr, &y1, &y2, pen, opt); } + inline void Region(const mglDataA &x, const mglDataA &y1, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_region_xy(gr, &x, &y1, &y2, pen, opt); } + /// Fill area (draw ribbon) between curves {x1,y1,z1} and {x2,y2,z2} + inline void Region(const mglDataA &x1, const mglDataA &y1, const mglDataA &z1, const mglDataA &x2, const mglDataA &y2, const mglDataA &z2, const char *pen="", const char *opt="") + { mgl_region_3d(gr, &x1, &y1, &z1, &x2, &y2, &z2, pen, opt); } + inline void Region(const mglDataA &x1, const mglDataA &y1, const mglDataA &x2, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_region_3d(gr, &x1, &y1, NULL, &x2, &y2, NULL, pen, opt); } + /// Draw vertical lines from points {x,y,z} to axis plane + inline void Stem(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_stem_xyz(gr, &x, &y, &z, pen, opt); } + inline void Stem(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_stem_xy(gr, &x, &y, pen, opt); } + inline void Stem(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_stem(gr, &y, pen, opt); } + + /// Draw vertical bars from points {x,y,z} to axis plane + inline void Bars(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_bars_xyz(gr, &x, &y, &z, pen, opt); } + inline void Bars(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_bars_xy(gr, &x, &y, pen, opt); } + inline void Bars(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_bars(gr, &y, pen, opt); } + /// Draw horizontal bars from points {x,y} to axis plane + inline void Barh(const mglDataA &y, const mglDataA &v, const char *pen="", const char *opt="") + { mgl_barh_yx(gr, &y, &v, pen, opt); } + inline void Barh(const mglDataA &v, const char *pen="", const char *opt="") + { mgl_barh(gr, &v, pen, opt); } + /// Draw chart for data a + inline void Chart(const mglDataA &a, const char *colors="", const char *opt="") + { mgl_chart(gr, &a, colors,opt); } + + /// Draw Open-High-Low-Close (OHLC) diagram + inline void OHLC(const mglDataA &x, const mglDataA &open, const mglDataA &high, const mglDataA &low, const mglDataA &close, const char *pen="", const char *opt="") + { mgl_ohlc_x(gr, &x, &open,&high,&low,&close,pen,opt); } + inline void OHLC(const mglDataA &open, const mglDataA &high, const mglDataA &low, const mglDataA &close, const char *pen="", const char *opt="") + { mgl_ohlc(gr, &open,&high,&low,&close,pen,opt); } + + /// Draw box-plot (special 5-value plot used in statistic) + inline void BoxPlot(const mglDataA &x, const mglDataA &y, const char *pen="", const char *opt="") + { mgl_boxplot_xy(gr, &x, &y, pen,opt); } + inline void BoxPlot(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_boxplot(gr, &y, pen,opt); } + /// Draw candle plot + inline void Candle(const mglDataA &x, const mglDataA &v1, const mglDataA &v2, const mglDataA &y1, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_candle_xyv(gr, &x, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglDataA &v1, const mglDataA &v2, const mglDataA &y1, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglDataA &v1, const mglDataA &v2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, NULL, NULL, pen, opt); } + inline void Candle(const mglDataA &y, const mglDataA &y1, const mglDataA &y2, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, &y1, &y2, pen, opt); } + inline void Candle(const mglDataA &y, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, NULL, NULL, pen, opt); } + /// Draw cones from points {x,y,z} to axis plane + inline void Cones(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *pen="@", const char *opt="") + { mgl_cones_xyz(gr, &x, &y, &z, pen, opt); } + inline void Cones(const mglDataA &x, const mglDataA &z, const char *pen="@", const char *opt="") + { mgl_cones_xz(gr, &x, &z, pen, opt); } + inline void Cones(const mglDataA &z, const char *pen="@", const char *opt="") + { mgl_cones(gr, &z, pen, opt); } + + /// Draw error boxes {ex,ey} at points {x,y} + inline void Error(const mglDataA &y, const mglDataA &ey, const char *pen="", const char *opt="") + { mgl_error(gr, &y, &ey, pen, opt); } + inline void Error(const mglDataA &x, const mglDataA &y, const mglDataA &ey, const char *pen="", const char *opt="") + { mgl_error_xy(gr, &x, &y, &ey, pen, opt); } + inline void Error(const mglDataA &x, const mglDataA &y, const mglDataA &ex, const mglDataA &ey, const char *pen="", const char *opt="") + { mgl_error_exy(gr, &x, &y, &ex, &ey, pen, opt); } + /// Draw marks with size r at points {x,y,z} + inline void Mark(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const char *pen, const char *opt="") + { mgl_mark_xyz(gr, &x, &y, &z, &r, pen, opt); } + inline void Mark(const mglDataA &x, const mglDataA &y, const mglDataA &r, const char *pen, const char *opt="") + { mgl_mark_xy(gr, &x, &y, &r, pen, opt); } + inline void Mark(const mglDataA &y, const mglDataA &r, const char *pen, const char *opt="") + { mgl_mark_y(gr, &y, &r, pen, opt); } + /// Draw textual marks with size r at points {x,y,z} + inline void TextMark(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &x, const mglDataA &y, const mglDataA &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &y, const mglDataA &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &y, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark(gr, &y, text, fnt, opt); } + inline void TextMark(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &x, const mglDataA &y, const mglDataA &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &y, const mglDataA &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglDataA &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw(gr, &y, text, fnt, opt); } + + /// Draw labels for points coordinate(s) at points {x,y,z} + inline void Label(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglDataA &x, const mglDataA &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglDataA &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_y(gr, &y, text, fnt, opt); } + inline void Label(const mglDataA &x, const mglDataA &y, const mglDataA &z, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglDataA &x, const mglDataA &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglDataA &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_y(gr, &y, text, fnt, opt); } + + /// Draw table for values val along given direction with row labels text + inline void Table(const mglDataA &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, 0, 0, &val, text, fnt, opt); } + inline void Table(const mglDataA &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, 0, 0, &val, text, fnt, opt); } + /// Draw table for values val along given direction with row labels text at given position + inline void Table(double x, double y, const mglDataA &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, x, y, &val, text, fnt, opt); } + inline void Table(double x, double y, const mglDataA &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, x, y, &val, text, fnt, opt); } + + /// Draw tube with radius r around curve {x,y,z} + inline void Tube(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const char *pen="", const char *opt="") + { mgl_tube_xyzr(gr, &x, &y, &z, &r, pen, opt); } + inline void Tube(const mglDataA &x, const mglDataA &y, const mglDataA &z, double r, const char *pen="", const char *opt="") + { mgl_tube_xyz(gr, &x, &y, &z, r, pen, opt); } + inline void Tube(const mglDataA &x, const mglDataA &y, const mglDataA &r, const char *pen="", const char *opt="") + { mgl_tube_xyr(gr, &x, &y, &r, pen, opt); } + inline void Tube(const mglDataA &x, const mglDataA &y, double r, const char *pen="", const char *opt="") + { mgl_tube_xy(gr, &x, &y, r, pen, opt); } + inline void Tube(const mglDataA &y, const mglDataA &r, const char *pen="", const char *opt="") + { mgl_tube_r(gr, &y, &r, pen, opt); } + inline void Tube(const mglDataA &y, double r, const char *pen="", const char *opt="") + { mgl_tube(gr, &y, r, pen, opt); } + /// Draw surface of curve {r,z} rotatation around axis + inline void Torus(const mglDataA &r, const mglDataA &z, const char *pen="", const char *opt="") + { mgl_torus(gr, &r, &z, pen,opt); } + + /// Draw mesh lines for 2d data specified parametrically + inline void Mesh(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_mesh_xy(gr, &x, &y, &z, stl, opt); } + inline void Mesh(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_mesh(gr, &z, stl, opt); } + /// Draw mesh lines for 2d data specified parametrically + inline void Fall(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_fall_xy(gr, &x, &y, &z, stl, opt); } + inline void Fall(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_fall(gr, &z, stl, opt); } + /// Draw belts for 2d data specified parametrically + inline void Belt(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_belt_xy(gr, &x, &y, &z, stl, opt); } + inline void Belt(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_belt(gr, &z, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to z + inline void Surf(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_surf_xy(gr, &x, &y, &z, stl, opt); } + inline void Surf(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_surf(gr, &z, stl, opt); } + /// Draw grid lines for density plot of 2d data specified parametrically + inline void Grid(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_grid_xy(gr, &x, &y, &z, stl, opt); } + inline void Grid(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_grid(gr, &z, stl, opt); } + /// Draw vertical tiles for 2d data specified parametrically + inline void Tile(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_tile_xy(gr, &x, &y, &z, stl, opt); } + inline void Tile(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_tile(gr, &z, stl, opt); } + /// Draw density plot for 2d data specified parametrically + inline void Dens(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_dens_xy(gr, &x, &y, &z, stl, opt); } + inline void Dens(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_dens(gr, &z, stl, opt); } + /// Draw vertical boxes for 2d data specified parametrically + inline void Boxs(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *stl="", const char *opt="") + { mgl_boxs_xy(gr, &x, &y, &z, stl, opt); } + inline void Boxs(const mglDataA &z, const char *stl="", const char *opt="") + { mgl_boxs(gr, &z, stl, opt); } + + /// Draw contour lines for 2d data specified parametrically + inline void Cont(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_cont_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void Cont(const mglDataA &v, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_cont_val(gr, &v, &z, sch, opt); } + inline void Cont(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_cont_xy(gr, &x, &y, &z, sch, opt); } + inline void Cont(const mglDataA &z, const char *sch="", const char *opt="") + { mgl_cont(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically + inline void ContF(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contf_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContF(const mglDataA &v, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contf_val(gr, &v, &z, sch, opt); } + inline void ContF(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contf_xy(gr, &x, &y, &z, sch, opt); } + inline void ContF(const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contf(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically with manual colors + inline void ContD(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contd_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContD(const mglDataA &v, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contd_val(gr, &v, &z, sch, opt); } + inline void ContD(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contd_xy(gr, &x, &y, &z, sch, opt); } + inline void ContD(const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contd(gr, &z, sch, opt); } + /// Draw contour tubes for 2d data specified parametrically + inline void ContV(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contv_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContV(const mglDataA &v, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contv_val(gr, &v, &z, sch, opt); } + inline void ContV(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contv_xy(gr, &x, &y, &z, sch, opt); } + inline void ContV(const mglDataA &z, const char *sch="", const char *opt="") + { mgl_contv(gr, &z, sch, opt); } + + /// Draw axial-symmetric isosurfaces for 2d data specified parametrically + inline void Axial(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_axial_xy_val(gr, &v, &x, &y, &z, sch,opt); } + inline void Axial(const mglDataA &v, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_axial_val(gr, &v, &z, sch, opt); } + inline void Axial(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_axial_xy(gr, &x, &y, &z, sch, opt); } + inline void Axial(const mglDataA &z, const char *sch="", const char *opt="") + { mgl_axial(gr, &z, sch, opt); } + + /// Draw grid lines for density plot at slice for 3d data specified parametrically + inline void Grid3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Grid3(const mglDataA &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3(gr, &a, stl, sVal, opt); } + /// Draw density plot at slice for 3d data specified parametrically + inline void Dens3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Dens3(const mglDataA &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3(gr, &a, stl, sVal, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically + inline void Surf3(double Val, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz_val(gr, Val, &x, &y, &z, &a, stl, opt); } + inline void Surf3(double Val, const mglDataA &a, const char *stl="", const char *opt="") + { mgl_surf3_val(gr, Val, &a, stl, opt); } + inline void Surf3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Surf3(const mglDataA &a, const char *stl="", const char *opt="") + { mgl_surf3(gr, &a, stl, opt); } + + /// Draw a semi-transparent cloud for 3d data + inline void Cloud(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *stl="", const char *opt="") + { mgl_cloud_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Cloud(const mglDataA &a, const char *stl="", const char *opt="") + { mgl_cloud(gr, &a, stl, opt); } + + /// Draw contour lines at slice for 3d data specified parametrically + inline void Cont3(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglDataA &v, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_val(gr, &v, &a, sch, sVal, opt); } + inline void Cont3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3(gr, &a, sch, sVal, opt); } + + /// Draw solid contours at slice for 3d data specified parametrically + inline void ContF3(const mglDataA &v, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglDataA &v, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_val(gr, &v, &a, sch, sVal, opt); } + inline void ContF3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglDataA &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3(gr, &a, sch, sVal, opt); } + + /// Draw several isosurfaces for 3d beam in curvilinear coordinates + inline void Beam(const mglDataA &tr, const mglDataA &g1, const mglDataA &g2, const mglDataA &a, double r, const char *stl=0, int flag=0, int num=3) + { mgl_beam(gr, &tr,&g1,&g2,&a,r,stl,flag,num); } + inline void Beam(double val, const mglDataA &tr, const mglDataA &g1, const mglDataA &g2, const mglDataA &a, double r, const char *stl=NULL, int flag=0) + { mgl_beam_val(gr,val,&tr,&g1,&g2,&a,r,stl,flag); } + + /// Draw vertical tiles with variable size r for 2d data specified parametrically + inline void TileS(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &r, const char *stl="", const char *opt="") + { mgl_tiles_xy(gr, &x, &y, &z, &r, stl, opt); } + inline void TileS(const mglDataA &z, const mglDataA &r, const char *stl="", const char *opt="") + { mgl_tiles(gr, &z, &r, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to c + inline void SurfC(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_surfc_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfC(const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_surfc(gr, &z, &c, sch,opt); } + /// Draw surface for 2d data specified parametrically with alpha proportional to c + inline void SurfA(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_surfa_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfA(const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_surfa(gr, &z, &c, sch,opt); } + + /// Color map of matrix a to matrix b, both matrix can parametrically depend on coordinates + inline void Map(const mglDataA &x, const mglDataA &y, const mglDataA &a, const mglDataA &b, const char *sch="", const char *opt="") + { mgl_map_xy(gr, &x, &y, &a, &b, sch, opt); } + inline void Map(const mglDataA &a, const mglDataA &b, const char *sch="", const char *opt="") + { mgl_map(gr, &a, &b, sch, opt); } + /// Draw density plot for spectra-gramm specified parametrically + inline void STFA(const mglDataA &x, const mglDataA &y, const mglDataA &re, const mglDataA &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa_xy(gr, &x, &y, &re, &im, dn, sch, opt); } + inline void STFA(const mglDataA &re, const mglDataA &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa(gr, &re, &im, dn, sch, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with alpha proportional to b + inline void Surf3A(double Val, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(double Val, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3a_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3A(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3a(gr, &a, &b, stl, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with color proportional to b + inline void Surf3C(double Val, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl,opt); } + inline void Surf3C(double Val, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3c_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3C(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3C(const mglDataA &a, const mglDataA &b, const char *stl="", const char *opt="") + { mgl_surf3c(gr, &a, &b, stl, opt); } + + /// Plot dew drops for vector field {ax,ay} parametrically depended on coordinate {x,y} + inline void Dew(const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_dew_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Dew(const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_dew_2d(gr, &ax, &ay, sch, opt); } + /// Plot vectors at position {x,y,z} along {ax,ay,az} with length/color proportional to |a| + inline void Traj(const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_traj_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Traj(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_traj_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + + /// Plot vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with length/color proportional to |a| + inline void Vect(const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_vect_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Vect(const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_vect_2d(gr, &ax, &ay, sch, opt); } + inline void Vect(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_vect_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Vect(const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_vect_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Draw vector plot at slice for 3d data specified parametrically + inline void Vect3(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3_xyz(gr, &x, &y, &z, &ax,&ay,&az, stl, sVal, opt); } + inline void Vect3(const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3(gr, &ax,&ay,&az, stl, sVal, opt); } + + /// Plot flows for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void Flow(const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_flow_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Flow(const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_flow_2d(gr, &ax, &ay, sch, opt); } + inline void Flow(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_flow_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Flow(const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_flow_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Plot flow from point p for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void FlowP(mglPoint p, const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_flowp_xy(gr, p.x, p.y, p.z, &x, &y, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglDataA &ax, const mglDataA &ay, const char *sch="", const char *opt="") + { mgl_flowp_2d(gr, p.x, p.y, p.z, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_flowp_xyz(gr, p.x, p.y, p.z, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void FlowP(mglPoint p, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", const char *opt="") + { mgl_flowp_3d(gr, p.x, p.y, p.z, &ax, &ay, &az, sch, opt); } + + /// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y,z} + inline void Grad(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &phi, const char *sch="", const char *opt="") + { mgl_grad_xyz(gr,&x,&y,&z,&phi,sch,opt); } + inline void Grad(const mglDataA &x, const mglDataA &y, const mglDataA &phi, const char *sch="", const char *opt="") + { mgl_grad_xy(gr,&x,&y,&phi,sch,opt); } + inline void Grad(const mglDataA &phi, const char *sch="", const char *opt="") + { mgl_grad(gr,&phi,sch,opt); } + + /// Plot flow pipes for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color and radius proportional to |a| + inline void Pipe(const mglDataA &x, const mglDataA &y, const mglDataA &ax, const mglDataA &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xy(gr, &x, &y, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglDataA &ax, const mglDataA &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_2d(gr, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, r0, opt); } + inline void Pipe(const mglDataA &ax, const mglDataA &ay, const mglDataA &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_3d(gr, &ax, &ay, &az, sch, r0, opt); } + + /// Draw density plot for data at x = sVal + inline void DensX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_x(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at y = sVal + inline void DensY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_y(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at z = sVal + inline void DensZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_z(gr, &a, stl, sVal, opt); } + /// Draw contour lines for data at x = sVal + inline void ContX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x(gr, &a, stl, sVal, opt); } + inline void ContX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at y = sVal + inline void ContY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y(gr, &a, stl, sVal, opt); } + inline void ContY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at z = sVal + inline void ContZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z(gr, &a, stl, sVal, opt); } + inline void ContZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at x = sVal + inline void ContFX(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x(gr, &a, stl, sVal, opt); } + inline void ContFX(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at y = sVal + inline void ContFY(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y(gr, &a, stl, sVal, opt); } + inline void ContFY(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at z = sVal + inline void ContFZ(const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z(gr, &a, stl, sVal, opt); } + inline void ContFZ(const mglDataA &v, const mglDataA &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z_val(gr, &v, &a, stl, sVal, opt); } + + /// Draw curve for formula with x in x-axis range + inline void FPlot(const char *fy, const char *stl="", const char *opt="") + { mgl_fplot(gr, fy, stl, opt); } + /// Draw curve for formulas parametrically depended on t in range [0,1] + inline void FPlot(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fplot_xyz(gr, fx, fy, fz, stl, opt); } + /// Draw surface by formula with x,y in axis range + inline void FSurf(const char *fz, const char *stl="", const char *opt="") + { mgl_fsurf(gr, fz, stl, opt); } + /// Draw surface by formulas parametrically depended on u,v in range [0,1] + inline void FSurf(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fsurf_xyz(gr, fx, fy, fz, stl, opt); } + + /// Draw triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_triplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void TriPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_triplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const char *sch="", const char *opt="") + { mgl_triplot_xy(gr, &nums, &x, &y, sch, opt); } + /// Draw quad mesh for points in arrays {x,y,z} with specified color c. + inline void QuadPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const char *sch="", const char *opt="") + { mgl_quadplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void QuadPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_quadplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void QuadPlot(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const char *sch="", const char *opt="") + { mgl_quadplot_xy(gr, &nums, &x, &y, sch, opt); } + + /// Draw contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriCont(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_tricont_xyc(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriContV(const mglDataA &v, const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_tricont_xycv(gr, &v, &nums, &x, &y, &z, sch, opt); } + inline void TriCont(const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzc(gr, &nums, &x, &y, &z, &a, sch, opt); } + inline void TriContV(const mglDataA &v, const mglDataA &nums, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzcv(gr, &v, &nums, &x, &y, &z, &a, sch, opt); } + + /// Draw dots in points {x,y,z}. + inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_dots(gr, &x, &y, &z, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified alpha a. + inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *sch="", const char *opt="") + { mgl_dots_a(gr, &x, &y, &z, &a, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. + inline void Dots(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &c, const mglDataA &a, const char *sch="", const char *opt="") + { mgl_dots_ca(gr, &x, &y, &z, &c, &a, sch, opt); } + /// Draw surface reconstructed for points in arrays {x,y,z}. + inline void Crust(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *sch="", const char *opt="") + { mgl_crust(gr, &x, &y, &z, sch, opt); } + + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglDataA &y, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq,vars,0, opt)); } + inline mglData Fit(const mglDataA &y, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq, vars, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit2(const mglDataA &z, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, vars,0, opt)); } + inline mglData Fit2(const mglDataA &z, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, vars, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit3(const mglDataA &a, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, vars,0, opt)); } + inline mglData Fit3(const mglDataA &a, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, vars, &ini, opt)); } + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglDataA &x, const mglDataA &y, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, vars,0, opt)); } + inline mglData Fit(const mglDataA &x, const mglDataA &y, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, vars, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, vars,0, opt)); } + inline mglData Fit(const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, vars, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq, vars,0, opt)); } + inline mglData Fit(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq,vars, &ini, opt)); } + /// Fit data with dispersion s along x-direction for each data row. Return array with values for found formula. + inline mglData FitS(const mglDataA &y, const mglDataA &s, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, vars,0, opt)); } + inline mglData FitS(const mglDataA &y, const mglDataA &s, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, vars, &ini, opt)); } + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &s, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, vars,0, opt)); } + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &s, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, vars, &ini, opt)); } + /// Fit data with dispersion s along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &s, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, vars,0, opt)); } + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &s, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, vars, &ini, opt)); } + /// Fit data with dispersion s along all directions. Return array with values for found formula. + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &s, const char *eq, const char *vars, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, vars,0, opt)); } + inline mglData FitS(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const mglDataA &s, const char *eq, const char *vars, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, vars, &ini, opt)); } + /// Print fitted last formula (with coefficients) + inline void PutsFit(mglPoint p, const char *prefix=0, const char *font="", double size=-1) + { mgl_puts_fit(gr, p.x, p.y, p.z, prefix, font, size); } + /// Get last fitted formula + inline const char *GetFit() + { return mgl_get_fit(gr); } + + /// Solve PDE with x,y,z in range [Min, Max] + inline mglData PDE(const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, double dz=0.1, double k0=100, const char *opt="") + { return mglData(true,mgl_pde_solve(gr,ham,&ini_re,&ini_im,dz,k0, opt)); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglData &u, const char *eq, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglDataA &v, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglDataA &v, const mglDataA &w, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, &w, opt); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglDataC &u, const char *eq, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglDataA &v, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglDataA &v, const mglDataA &w, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, &w, opt); } + + /// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglDataA &xdat, const mglDataA &ydat, const mglDataA &zdat, const mglDataA &vdat, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,&zdat,&vdat,-1,opt); } + + /// Set the data by triangulated surface values assuming x,y,z in range [Min, Max] + inline void DataGrid(mglData &d, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *opt="") + { mgl_data_grid(gr,&d,&x,&y,&z,opt); } + + /// Make histogram (distribution) of data. This function do not plot data. + inline mglData Hist(const mglDataA &x, const mglDataA &a, const char *opt="") + { return mglData(true, mgl_hist_x(gr, &x, &a, opt)); } + inline mglData Hist(const mglDataA &x, const mglDataA &y, const mglDataA &a, const char *opt="") + { return mglData(true, mgl_hist_xy(gr, &x, &y, &a, opt)); } + inline mglData Hist(const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *opt="") + { return mglData(true, mgl_hist_xyz(gr, &x, &y, &z, &a, opt)); } + + inline void Compression(bool){} // NOTE: Add later -- IDTF + /// Set the preference for vertex color on/off (for formats that support it, now only PRC does). + inline void VertexColor(bool enable) { mgl_set_flag(gr,enable, MGL_PREFERVC); } + /// Render only front side of surfaces for dubugging purposes (for formats that support it, now only PRC does). + inline void DoubleSided(bool enable) { mgl_set_flag(gr,!enable, MGL_ONESIDED); } +// inline void TextureColor(bool){} // NOTE: Add later -- IDTF +}; +//----------------------------------------------------------------------------- +/// Wrapper class for MGL parsing +class MGL_EXPORT mglParse +{ + HMPR pr; +public: + mglParse(HMPR p) { pr = p; mgl_use_parser(pr,1); } + mglParse(mglParse &p) { pr = p.pr; mgl_use_parser(pr,1); } + mglParse(bool setsize=false) + { pr=mgl_create_parser(); mgl_parser_allow_setsize(pr, setsize); } + ~mglParse() { if(mgl_use_parser(pr,-1)<1) mgl_delete_parser(pr); } + /// Get pointer to internal mglParser object + inline HMPR Self() { return pr; } + /// Parse and draw single line of the MGL script + inline int Parse(mglGraph *gr, const char *str, int pos) + { return mgl_parse_line(gr->Self(), pr, str, pos); } + inline int Parse(mglGraph *gr, const wchar_t *str, int pos) + { return mgl_parse_linew(gr->Self(), pr, str, pos); } + /// Execute MGL script text with '\n' separated lines + inline void Execute(mglGraph *gr, const char *str) + { mgl_parse_text(gr->Self(), pr, str); } + inline void Execute(mglGraph *gr, const wchar_t *str) + { mgl_parse_textw(gr->Self(), pr, str); } + /// Execute and draw script from the file + inline void Execute(mglGraph *gr, FILE *fp, bool print=false) + { mgl_parse_file(gr->Self(), pr, fp, print); } + + /// Return type of command: 0 - not found, 1 - data plot, 2 - other plot, + /// 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program + /// 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot + /// 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform + inline int CmdType(const char *name) + { return mgl_parser_cmd_type(pr, name); } + /// Return string of command format (command name and its argument[s]) + inline const char *CmdFormat(const char *name) + { return mgl_parser_cmd_frmt(pr, name); } + /// Return description of MGL command + inline const char *CmdDesc(const char *name) + { return mgl_parser_cmd_desc(pr, name); } + /// Get name of command with nmber n + inline const char *GetCmdName(long n) + { return mgl_parser_cmd_name(pr,n); } + /// Get number of defined commands + inline long GetCmdNum() + { return mgl_parser_cmd_num(pr); } + + /// Set value for parameter $N + inline void AddParam(int id, const char *str) + { mgl_parser_add_param(pr, id, str); } + inline void AddParam(int id, const wchar_t *str) + { mgl_parser_add_paramw(pr, id, str); } + /// Restore once flag + inline void RestoreOnce() { mgl_parser_restore_once(pr); } + /// Allow changing size of the picture + inline void AllowSetSize(bool allow) { mgl_parser_allow_setsize(pr, allow); } + /// Allow reading/saving files + inline void AllowFileIO(bool allow) { mgl_parser_allow_file_io(pr, allow); } + /// Set flag to stop script parsing + inline void Stop() { mgl_parser_stop(pr); } + + /// Return result of formula evaluation + inline mglData Calc(const char *formula) + { return mglData(true,mgl_parser_calc(pr,formula)); } + inline mglData Calc(const wchar_t *formula) + { return mglData(true,mgl_parser_calcw(pr,formula)); } + + /// Find variable with given name or add a new one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *AddVar(const char *name) + { return dynamic_cast(mgl_parser_add_var(pr, name)); } + inline mglVar *AddVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_add_varw(pr, name)); } + /// Find variable with given name or return NULL if no one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *FindVar(const char *name) + { return dynamic_cast(mgl_parser_find_var(pr, name)); } + inline mglVar *FindVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_find_varw(pr, name)); } + /// Delete variable with name + inline void DeleteVar(const char *name) { mgl_parser_del_var(pr, name); } + inline void DeleteVar(const wchar_t *name) { mgl_parser_del_varw(pr, name); } + /// Delete all data variables + void DeleteAll() { mgl_parser_del_all(pr); } +}; +//----------------------------------------------------------------------------- +#endif +#endif \ No newline at end of file diff --git a/include/mgl2/mgl_cf.h b/include/mgl2/mgl_cf.h new file mode 100644 index 0000000..bc1096e --- /dev/null +++ b/include/mgl2/mgl_cf.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * MGL_EXPORT mgl_cf.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_CF_H_ +#define _MGL_CF_H_ +//----------------------------------------------------------------------------- +#ifdef __cplusplus +#include +#include +#endif +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#if MGL_HAVE_OPENGL +#ifdef __cplusplus +extern "C" { +#endif +//----------------------------------------------------------------------------- +HMGL MGL_EXPORT mgl_create_graph_gl(); +uintptr_t MGL_EXPORT mgl_create_graph_gl_(); +//----------------------------------------------------------------------------- +#ifdef __cplusplus +} +#endif +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/mgl_pas.pas b/include/mgl2/mgl_pas.pas new file mode 100644 index 0000000..2e6537a --- /dev/null +++ b/include/mgl2/mgl_pas.pas @@ -0,0 +1,1512 @@ +//************************************************************************** +// mgl_pas.pas is part of Math Graphic Library * +// Copyright (C) 2008-2013 Mikhail Barg, Alexey Balakin * +// * +// This program is free software; you can redistribute it and/or modify * +// it under the terms of the GNU Library General Public License as * +// published by the Free Software Foundation; either version 2 of the * +// License, or (at your option) any later version. * +// * +// This program is distributed in the hope that it will be useful, * +// but WITHOUT ANY WARRANTY; without even the implied warranty of * +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +// GNU General Public License for more details. * +// * +// You should have received a copy of the GNU Library General Public * +// License along with this program; if not, write to the * +// Free Software Foundation, Inc., * +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +//************************************************************************** + +unit mgl_pas; + +{$IFDEF FPC} +{$MODE DELPHI } +{$PACKENUM 4} (* use 4-byte enums *) +{$PACKRECORDS C} (* C/C++-compatible record packing *) +{$ELSE} +{$MINENUMSIZE 4} (* use 4-byte enums *) +{$ENDIF} + +{$IFDEF DARWIN} +{$linklib libmgl} +{$ENDIF} + +interface + +uses +{$IFDEF MSWINDOWS} +Windows, Graphics, +{$ENDIF} +Math; + +const MGL_VER2 = 2.2; +//* This define enables double precision in MathGL */ +MGL_USE_DOUBLE = 1; + +const +{$IFDEF MSWINDOWS} +//win - .dll +libmgl = 'libmgl.dll'; +libmglglut = 'libmgl-glut.dll'; +libmglfltk = 'libmgl-fltk.dll'; +libmglqt = 'libmgl-qt.dll'; +{$ELSE} +{$IFDEF LINUX} +//linux - .so +libmgl = 'libmgl.so'; +libmglglut = 'libmgl-glut.so'; +libmglfltk = 'libmgl-fltk.so'; +libmglqt = 'libmgl-qt.so'; +{$ELSE} +{$IFDEF DARWIN} +//darwin - .dylib +libmgl = 'libmgl.dylib'; +libmglglut = 'libmgl-glut.dylib'; +libmglfltk = 'libmgl-fltk.dylib'; +libmglqt = 'libmgl-qt.dylib'; +{$ELSE} +// other platforms? + +{$ENDIF} +{$ENDIF} +{$ENDIF} + +{$IF (MGL_USE_DOUBLE = 0)} +type mreal = double; +{$ELSE} +type mreal = real; +{$IFEND} +{$IFDEF FPC} +{$ELSE} +type QWord = Int64; +{$ENDIF} + +Pmreal = ^mreal; + +type TNGLDraw = record +end; +type TMGLGraph = record +end; +type TMGLData = record +end; +type TMGLParse = record +end; +type TMGLFormula = record +end; +type TMGLFormulaC = record +end; +type TMGLDataC = record +end; +type HMDR = ^TNGLDraw; +type HMGL = ^TMGLGraph; +type HMDT = ^TMGLData; +type HMPR = ^TMGLParse; +type PPChar = ^PChar; +type HMEX = ^TMGLFormula; +type HAEX = ^TMGLFormulaC; +type HADT = ^TMGLDataC; + +type Preal = ^single; +type Pdouble = ^double; +type Pint = ^integer; +type dual = record +re, im: mreal; +end; +type Pdual = ^dual; +type TGSLVector = record +end; +type TGSLMatrix = record +end; +type PGSLVector = ^TGSLVector; +type PGSLMatrix = ^TGSLMatrix; + +type TMglDrawFunction = function (gr: HMGL; p: pointer): integer; cdecl; +function mgl_create_graph_gl(): HMGL; cdecl; external libmgl; +function mgl_create_graph_glut(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglglut; +function mgl_create_graph_fltk(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglfltk; +procedure mgl_fltk_run(); cdecl; external libmglfltk; +function mgl_create_graph_qt(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglqt; +procedure mgl_qt_run(); cdecl; external libmglqt; + +{== ../include/mgl2/base_cf.h ==} +//----------------------------------------------------------------------------- +/// Get last warning code +function mgl_get_warn(gr: HMGL): integer; cdecl; external libmgl; +/// Set warning code ant fill message +procedure mgl_set_warn(gr: HMGL;code: integer;const text: PChar); cdecl; external libmgl; +/// Set buffer for warning messages +function mgl_get_mess(gr: HMGL): PChar; cdecl; external libmgl; +/// Set name of plot for saving filename +procedure mgl_set_plotid(gr: HMGL;const id: PChar); cdecl; external libmgl; +/// Get name of plot for saving filename +function mgl_get_plotid(gr: HMGL): PChar; cdecl; external libmgl; +/// Get plot quality +function mgl_get_quality(gr: HMGL): integer; cdecl; external libmgl; +/// Set plot quality +procedure mgl_set_quality(gr: HMGL;qual: integer); cdecl; external libmgl; +/// Set drawing region for Quality&4 +procedure mgl_set_draw_reg(gr: HMGL;nx: integer;ny: integer;m: integer); cdecl; external libmgl; +/// Is frames +function mgl_is_frames(gr: HMGL): integer; cdecl; external libmgl; +/// Get bit-value flag of HMGL state (for advanced users only) +function mgl_get_flag(gr: HMGL;flag: LongWord): integer; cdecl; external libmgl; +/// Set bit-value flag of HMGL state (for advanced users only) +procedure mgl_set_flag(gr: HMGL;val: integer;flag: LongWord); cdecl; external libmgl; +/// Change counter of HMGL uses (for advanced users only). Non-zero counter prevent automatic object removing. +function mgl_use_graph(gr: HMGL;inc: integer): integer; cdecl; external libmgl; +/// Start group of objects +procedure mgl_start_group(gr: HMGL;const name: PChar); cdecl; external libmgl; +/// End group of objects +procedure mgl_end_group(gr: HMGL); cdecl; external libmgl; +/// Highlight objects with given id +procedure mgl_highlight(gr: HMGL;id: integer); cdecl; external libmgl; +/// Set default palette +procedure mgl_set_palette(gr: HMGL;const colors: PChar); cdecl; external libmgl; +/// Sets RGB values for color with given id +procedure mgl_set_color(id: char;r: double;g: double;b: double); cdecl; external libmgl; +/// Set default color scheme +procedure mgl_set_def_sch(gr: HMGL;const sch: PChar); cdecl; external libmgl; +/// Set mask for face coloring as array of type 'unsigned char[8]' +procedure mgl_set_mask(id: char;const mask: PChar); cdecl; external libmgl; +/// Set mask for face coloring as unsigned long number +procedure mgl_set_mask_val(id: char;mask: QWord); cdecl; external libmgl; +/// Set default mask rotation angle +procedure mgl_set_mask_angle(gr: HMGL;angle: integer); cdecl; external libmgl; +/// Set default value of alpha-channel +procedure mgl_set_alpha_default(gr: HMGL;alpha: double); cdecl; external libmgl; +/// Set relative width of rectangles in Bars, Barh, BoxPlot +procedure mgl_set_bar_width(gr: HMGL;width: double); cdecl; external libmgl; +/// Set number of mesh lines (use 0 to draw all of them) +procedure mgl_set_meshnum(gr: HMGL;num: integer); cdecl; external libmgl; +/// Set number of visible faces (use 0 to draw all of them) +procedure mgl_set_facenum(gr: HMGL;num: integer); cdecl; external libmgl; +/// Clear unused points and primitives. Useful only in combination with mgl_set_facenum(). +procedure mgl_clear_unused(gr: HMGL); cdecl; external libmgl; +/// Set ambient light brightness +procedure mgl_set_ambbr(gr: HMGL;i: double); cdecl; external libmgl; +/// Set diffusive light brightness +procedure mgl_set_difbr(gr: HMGL;i: double); cdecl; external libmgl; +/// Use diffusive light (only for local light sources) -- OBSOLETE +procedure mgl_set_light_dif(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Set cutting for points outside of bounding box +procedure mgl_set_cut(gr: HMGL;cut: integer); cdecl; external libmgl; +/// Set additional cutting box +procedure mgl_set_cut_box(gr: HMGL;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double); cdecl; external libmgl; +/// Set the cutting off condition (formula) +procedure mgl_set_cutoff(gr: HMGL;const EqC: PChar); cdecl; external libmgl; +/// Set values of axis range +procedure mgl_set_ranges(gr: HMGL;x1: double;x2: double;y1: double;y2: double;z1: double;z2: double); cdecl; external libmgl; +/// Set range in direction dir as [v1, v2] +procedure mgl_set_range_val(gr: HMGL;dir: char;v1: double;v2: double); cdecl; external libmgl; +/// Set range in direction dir as minimal and maximal values of data a +procedure mgl_set_range_dat(gr: HMGL;dir: char;const a: HMDT;add: integer); cdecl; external libmgl; +/// Set ranges for automatic variables +procedure mgl_set_auto_ranges(gr: HMGL;x1: double;x2: double;y1: double;y2: double;z1: double;z2: double;c1: double;c2: double); cdecl; external libmgl; +/// Set axis range scaling -- simplified way to shift/zoom axis range -- need to redraw whole image! +procedure mgl_zoom_axis(gr: HMGL;x1: double;y1: double;z1: double;c1: double;x2: double;y2: double;z2: double;c2: double); cdecl; external libmgl; +/// Set axis origin +procedure mgl_set_origin(gr: HMGL;x0: double;y0: double;z0: double); cdecl; external libmgl; +/// Set the transformation formulas for coordinate +procedure mgl_set_func(gr: HMGL;const EqX: PChar;const EqY: PChar;const EqZ: PChar;const EqA: PChar); cdecl; external libmgl; +/// Set one of predefined transformation rule +procedure mgl_set_coor(gr: HMGL;how: integer); cdecl; external libmgl; +/// Set to draw Ternary axis (triangle like axis, grid and so on) +procedure mgl_set_ternary(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Set to use or not tick labels rotation +procedure mgl_set_tick_rotate(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Set to use or not tick labels skipping +procedure mgl_set_tick_skip(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Set default font for all new HMGL objects +procedure mgl_def_font(const name: PChar;const path: PChar); cdecl; external libmgl; +/// Set default size of marks (locally you can use "size" option) +procedure mgl_set_mark_size(gr: HMGL;size: double); cdecl; external libmgl; +/// Set default size of arrows (locally you can use "size" option) +procedure mgl_set_arrow_size(gr: HMGL;size: double); cdecl; external libmgl; +/// Set default font size +procedure mgl_set_font_size(gr: HMGL;size: double); cdecl; external libmgl; +/// Set default font style and color +procedure mgl_set_font_def(gr: HMGL;const fnt: PChar); cdecl; external libmgl; +/// Set to use or not text rotation +procedure mgl_set_rotated_text(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Load font from file +procedure mgl_load_font(gr: HMGL;const name: PChar;const path: PChar); cdecl; external libmgl; +/// Copy font from another mglGraph instance +procedure mgl_copy_font(gr: HMGL;gr_from: HMGL); cdecl; external libmgl; +/// Restore font (load default font for new HMGL objects) +procedure mgl_restore_font(gr: HMGL); cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/data_cf.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// Set seed for random numbers +procedure mgl_srnd(seed: integer); cdecl; external libmgl; +/// Get random number +function mgl_rnd(): double; cdecl; external libmgl; +/// Get integer power of x +function mgl_ipow(x: double;n: integer): double; cdecl; external libmgl; +/// Get number of seconds since 1970 for given string +function mgl_get_time(const time: PChar;const fmt: PChar): double; cdecl; external libmgl; +/// Create HMDT object +function mgl_create_data(): HMDT; cdecl; external libmgl; +/// Create HMDT object with specified sizes +function mgl_create_data_size(nx: integer;ny: integer;nz: integer): HMDT; cdecl; external libmgl; +/// Create HMDT object with data from file +function mgl_create_data_file(const fname: PChar): HMDT; cdecl; external libmgl; +/// Delete HMDT object +procedure mgl_delete_data(dat: HMDT); cdecl; external libmgl; +/// Get information about the data (sizes and momentum) to string +function mgl_data_info(const dat: HMDT): PChar; cdecl; external libmgl; +/// Rearange data dimensions +procedure mgl_data_rearrange(dat: HMDT;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Link external data array (don't delete it at exit) +procedure mgl_data_link(dat: HMDT;A: Pmreal;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (float *) array +procedure mgl_data_set_float(dat: HMDT;const A: Preal;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (double *) array +procedure mgl_data_set_double(dat: HMDT;const A: Pdouble;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (float **) array +/// Allocate memory and copy the data from the (double **) array +/// Allocate memory and copy the data from the (float ***) array +/// Allocate memory and copy the data from the (double ***) array +/// Import data from abstract type +procedure mgl_data_set(dat: HMDT;const a: HMDT); cdecl; external libmgl; +/// Allocate memory and copy the data from the gsl_vector +procedure mgl_data_set_vector(dat: HMDT;v: PGSLVector); cdecl; external libmgl; +/// Allocate memory and copy the data from the gsl_matrix +procedure mgl_data_set_matrix(dat: HMDT;m: PGSLMatrix); cdecl; external libmgl; +/// Set value of data element [i,j,k] +procedure mgl_data_set_value(dat: HMDT;v: mreal;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Get value of data element [i,j,k] +function mgl_data_get_value(const dat: HMDT;i: integer;j: integer;k: integer): mreal; cdecl; external libmgl; +/// Allocate memory and scanf the data from the string +procedure mgl_data_set_values(dat: HMDT;const val: PChar;nx: integer;ny: integer;nz: integer); cdecl; external libmgl; +/// Read data array from HDF file (parse HDF4 and HDF5 files) +function mgl_data_read_hdf(d: HMDT;const fname: PChar;const data: PChar): integer; cdecl; external libmgl; +/// Save data to HDF file +procedure mgl_data_save_hdf(const d: HMDT;const fname: PChar;const data: PChar;rewrite: integer); cdecl; external libmgl; +/// Put HDF data names into buf as '\t' separated. +function mgl_datas_hdf(const fname: PChar;buf: PChar;size: integer): integer; cdecl; external libmgl; +/// Read data from tab-separated text file with auto determining size +function mgl_data_read(dat: HMDT;const fname: PChar): integer; cdecl; external libmgl; +/// Read data from text file with size specified at beginning of the file +function mgl_data_read_mat(dat: HMDT;const fname: PChar;dim: integer): integer; cdecl; external libmgl; +/// Read data from text file with specifeid size +function mgl_data_read_dim(dat: HMDT;const fname: PChar;mx: integer;my: integer;mz: integer): integer; cdecl; external libmgl; +/// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to +function mgl_data_read_range(d: HMDT;const templ: PChar;n1: double;n2: double;step: double;as_slice: integer): integer; cdecl; external libmgl; +/// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") +function mgl_data_read_all(dat: HMDT;const templ: PChar;as_slice: integer): integer; cdecl; external libmgl; +/// Save whole data array (for ns=-1) or only ns-th slice to text file +procedure mgl_data_save(const dat: HMDT;const fname: PChar;ns: integer); cdecl; external libmgl; +/// Export data array (for ns=-1) or only ns-th slice to PNG file according color scheme +procedure mgl_data_export(const dat: HMDT;const fname: PChar;const scheme: PChar;v1: mreal;v2: mreal;ns: integer); cdecl; external libmgl; +/// Import data array from PNG file according color scheme +procedure mgl_data_import(dat: HMDT;const fname: PChar;const scheme: PChar;v1: mreal;v2: mreal); cdecl; external libmgl; +/// Create or recreate the array with specified size and fill it by zero +procedure mgl_data_create(dat: HMDT;nx: integer;ny: integer;nz: integer); cdecl; external libmgl; +/// Transpose dimensions of the data (generalization of Transpose) +procedure mgl_data_transpose(dat: HMDT;const dim: PChar); cdecl; external libmgl; +/// Normalize the data to range [v1,v2] +procedure mgl_data_norm(dat: HMDT;v1: mreal;v2: mreal;sym: integer;dim: integer); cdecl; external libmgl; +/// Normalize the data to range [v1,v2] slice by slice +procedure mgl_data_norm_slice(dat: HMDT;v1: mreal;v2: mreal;dir: char;keep_en: integer;sym: integer); cdecl; external libmgl; +/// Get sub-array of the data with given fixed indexes +function mgl_data_subdata(const dat: HMDT;xx: integer;yy: integer;zz: integer): HMDT; cdecl; external libmgl; +/// Get sub-array of the data with given fixed indexes (like indirect access) +function mgl_data_subdata_ext(const dat: HMDT;const xx: HMDT;const yy: HMDT;const zz: HMDT): HMDT; cdecl; external libmgl; +/// Get column (or slice) of the data filled by formulas of named columns +function mgl_data_column(const dat: HMDT;const eq: PChar): HMDT; cdecl; external libmgl; +/// Set names for columns (slices) +procedure mgl_data_set_id(d: HMDT;const id: PChar); cdecl; external libmgl; +/// Equidistantly fill the data to range [x1,x2] in direction dir +procedure mgl_data_fill(dat: HMDT;x1: mreal;x2: mreal;dir: char); cdecl; external libmgl; +/// Modify the data by specified formula assuming x,y,z in range [r1,r2] +procedure mgl_data_fill_eq(gr: HMGL;dat: HMDT;const eq: PChar;const vdat: HMDT;const wdat: HMDT;const opt: PChar); cdecl; external libmgl; +/// Fill dat by interpolated values of vdat parametrically depended on xdat for x in range [x1,x2] +procedure mgl_data_refill_x(dat: HMDT;const xdat: HMDT;const vdat: HMDT;x1: mreal;x2: mreal;sl: integer); cdecl; external libmgl; +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat for x,y in range [x1,x2]*[y1,y2] +procedure mgl_data_refill_xy(dat: HMDT;const xdat: HMDT;const ydat: HMDT;const vdat: HMDT;x1: mreal;x2: mreal;y1: mreal;y2: mreal;sl: integer); cdecl; external libmgl; +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [x1,x2]*[y1,y2]*[z1,z2] +procedure mgl_data_refill_xyz(dat: HMDT;const xdat: HMDT;const ydat: HMDT;const zdat: HMDT;const vdat: HMDT;x1: mreal;x2: mreal;y1: mreal;y2: mreal;z1: mreal;z2: mreal); cdecl; external libmgl; +/// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range +procedure mgl_data_refill_gr(gr: HMGL;dat: HMDT;const xdat: HMDT;const ydat: HMDT;const zdat: HMDT;const vdat: HMDT;sl: integer;const opt: PChar); cdecl; external libmgl; +/// Set the data by triangulated surface values assuming x,y,z in range [r1,r2] +procedure mgl_data_grid(gr: HMGL;d: HMDT;const xdat: HMDT;const ydat: HMDT;const zdat: HMDT;const opt: PChar); cdecl; external libmgl; +/// Set the data by triangulated surface values assuming x,y,z in range [x1,x2]*[y1,y2] +procedure mgl_data_grid_xy(d: HMDT;const xdat: HMDT;const ydat: HMDT;const zdat: HMDT;x1: mreal;x2: mreal;y1: mreal;y2: mreal); cdecl; external libmgl; +/// Put value to data element(s) +procedure mgl_data_put_val(dat: HMDT;val: mreal;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Put array to data element(s) +procedure mgl_data_put_dat(dat: HMDT;const val: HMDT;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Modify the data by specified formula +procedure mgl_data_modify(dat: HMDT;const eq: PChar;dim: integer); cdecl; external libmgl; +/// Modify the data by specified formula +procedure mgl_data_modify_vw(dat: HMDT;const eq: PChar;const vdat: HMDT;const wdat: HMDT); cdecl; external libmgl; +/// Reduce size of the data +procedure mgl_data_squeeze(dat: HMDT;rx: integer;ry: integer;rz: integer;smooth: integer); cdecl; external libmgl; +/// Get maximal value of the data +function mgl_data_max(const dat: HMDT): mreal; cdecl; external libmgl; +/// Get minimal value of the data +function mgl_data_min(const dat: HMDT): mreal; cdecl; external libmgl; +/// Returns pointer to data element [i,j,k] +function mgl_data_value(dat: HMDT;i: integer;j: integer;k: integer): Pmreal; cdecl; external libmgl; +/// Returns pointer to internal data array +function mgl_data_data(dat: HMDT): Pmreal; cdecl; external libmgl; +/// Gets the x-size of the data. +function mgl_data_get_nx(const d: HMDT): integer; cdecl; external libmgl; +/// Gets the y-size of the data. +function mgl_data_get_ny(const d: HMDT): integer; cdecl; external libmgl; +/// Gets the z-size of the data. +function mgl_data_get_nz(const d: HMDT): integer; cdecl; external libmgl; +/// Find position (after specified in i,j,k) of first nonzero value of formula +function mgl_data_first(const dat: HMDT;const cond: PChar;i: Pint;j: Pint;k: Pint): mreal; cdecl; external libmgl; +/// Find position (before specified in i,j,k) of last nonzero value of formula +function mgl_data_last(const dat: HMDT;const cond: PChar;i: Pint;j: Pint;k: Pint): mreal; cdecl; external libmgl; +/// Find position of first in direction 'dir' nonzero value of formula +function mgl_data_find(const dat: HMDT;const cond: PChar;dir: char;i: integer;j: integer;k: integer): integer; cdecl; external libmgl; +/// Find if any nonzero value of formula +function mgl_data_find_any(const dat: HMDT;const cond: PChar): integer; cdecl; external libmgl; +/// Get maximal value of the data and its position +function mgl_data_max_int(const dat: HMDT;i: Pint;j: Pint;k: Pint): mreal; cdecl; external libmgl; +/// Get maximal value of the data and its approximated position +function mgl_data_max_real(const dat: HMDT;x: Pmreal;y: Pmreal;z: Pmreal): mreal; cdecl; external libmgl; +/// Get minimal value of the data and its position +function mgl_data_min_int(const dat: HMDT;i: Pint;j: Pint;k: Pint): mreal; cdecl; external libmgl; +/// Get minimal value of the data and its approximated position +function mgl_data_min_real(const dat: HMDT;x: Pmreal;y: Pmreal;z: Pmreal): mreal; cdecl; external libmgl; +/// Get "energy and find 4 momenta of data: median, width, skewness, kurtosis +function mgl_data_momentum_val(const d: HMDT;dir: char;m: Pmreal;w: Pmreal;s: Pmreal;k: Pmreal): mreal; cdecl; external libmgl; +/// Get the data which is direct multiplication (like, d[i,j] = this[i]*a[j] and so on) +function mgl_data_combine(const dat1: HMDT;const dat2: HMDT): HMDT; cdecl; external libmgl; +/// Extend data dimensions +procedure mgl_data_extend(dat: HMDT;n1: integer;n2: integer); cdecl; external libmgl; +/// Insert data rows/columns/slices +procedure mgl_data_insert(dat: HMDT;dir: char;at: integer;num: integer); cdecl; external libmgl; +/// Delete data rows/columns/slices +procedure mgl_data_delete(dat: HMDT;dir: char;at: integer;num: integer); cdecl; external libmgl; +/// Joind another data array +procedure mgl_data_join(dat: HMDT;const d: HMDT); cdecl; external libmgl; +/// Smooth the data on specified direction or directions +procedure mgl_data_smooth(d: HMDT;const dirs: PChar;delta: mreal); cdecl; external libmgl; +/// Get array which is result of summation in given direction or directions +function mgl_data_sum(const dat: HMDT;const dir: PChar): HMDT; cdecl; external libmgl; +/// Get array which is result of maximal values in given direction or directions +function mgl_data_max_dir(const dat: HMDT;const dir: PChar): HMDT; cdecl; external libmgl; +/// Get array which is result of minimal values in given direction or directions +function mgl_data_min_dir(const dat: HMDT;const dir: PChar): HMDT; cdecl; external libmgl; +/// Cumulative summation the data in given direction or directions +procedure mgl_data_cumsum(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Integrate (cumulative summation) the data in given direction or directions +procedure mgl_data_integral(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Differentiate the data in given direction or directions +procedure mgl_data_diff(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Differentiate the parametrically specified data along direction v1 with v2,v3=const (v3 can be NULL) +procedure mgl_data_diff_par(dat: HMDT;const v1: HMDT;const v2: HMDT;const v3: HMDT); cdecl; external libmgl; +/// Double-differentiate (like Laplace operator) the data in given direction +procedure mgl_data_diff2(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Swap left and right part of the data in given direction (useful for Fourier spectrum) +procedure mgl_data_swap(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Roll data along direction dir by num slices +procedure mgl_data_roll(dat: HMDT;dir: char;num: integer); cdecl; external libmgl; +/// Mirror the data in given direction (useful for Fourier spectrum) +procedure mgl_data_mirror(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Sort rows (or slices) by values of specified column +procedure mgl_data_sort(dat: HMDT;idx: integer;idy: integer); cdecl; external libmgl; +/// Apply Hankel transform +procedure mgl_data_hankel(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Apply Sin-Fourier transform +procedure mgl_data_sinfft(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Apply Cos-Fourier transform +procedure mgl_data_cosfft(dat: HMDT;const dir: PChar); cdecl; external libmgl; +/// Fill data by 'x'/'k' samples for Hankel ('h') or Fourier ('f') transform +procedure mgl_data_fill_sample(dat: HMDT;const how: PChar); cdecl; external libmgl; +/// Find correlation between 2 data arrays +function mgl_data_correl(const dat1: HMDT;const dat2: HMDT;const dir: PChar): HMDT; cdecl; external libmgl; +/// Allocate and prepare data for Fourier transform by nthr threads +/// Free data for Fourier transform +/// Make Fourier transform of data x of size n and step s between points +/// Clear internal data for speeding up FFT and Hankel transforms +procedure mgl_clear_fft(); cdecl; external libmgl; +/// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_data_spline(const dat: HMDT;x: mreal;y: mreal;z: mreal): mreal; cdecl; external libmgl; +/// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_data_linear(const dat: HMDT;x: mreal;y: mreal;z: mreal): mreal; cdecl; external libmgl; +/// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_data_spline_ext(const dat: HMDT;x: mreal;y: mreal;z: mreal;dx: Pmreal;dy: Pmreal;dz: Pmreal): mreal; cdecl; external libmgl; +/// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_data_linear_ext(const dat: HMDT;x: mreal;y: mreal;z: mreal;dx: Pmreal;dy: Pmreal;dz: Pmreal): mreal; cdecl; external libmgl; +/// Return an approximated x-value (root) when dat(x) = val +function mgl_data_solve_1d(const dat: HMDT;val: mreal;spl: integer;i0: integer): mreal; cdecl; external libmgl; +/// Return an approximated value (root) when dat(x) = val +function mgl_data_solve(const dat: HMDT;val: mreal;dir: char;const i0: HMDT;norm: integer): HMDT; cdecl; external libmgl; +/// Get trace of the data array +function mgl_data_trace(const d: HMDT): HMDT; cdecl; external libmgl; +/// Resize the data to new sizes +function mgl_data_resize(const dat: HMDT;mx: integer;my: integer;mz: integer): HMDT; cdecl; external libmgl; +/// Resize the data to new sizes of box [x1,x2]*[y1,y2]*[z1,z2] +function mgl_data_resize_box(const dat: HMDT;mx: integer;my: integer;mz: integer;x1: mreal;x2: mreal;y1: mreal;y2: mreal;z1: mreal;z2: mreal): HMDT; cdecl; external libmgl; +/// Create n-th points distribution of this data values in range [v1, v2] +function mgl_data_hist(const dat: HMDT;n: integer;v1: mreal;v2: mreal;nsub: integer): HMDT; cdecl; external libmgl; +/// Create n-th points distribution of this data values in range [v1, v2] with weight w +function mgl_data_hist_w(const dat: HMDT;const weight: HMDT;n: integer;v1: mreal;v2: mreal;nsub: integer): HMDT; cdecl; external libmgl; +/// Get momentum (1D-array) of data along direction 'dir'. String looks like "x1" for median in x-direction, "x2" for width in x-dir and so on. +function mgl_data_momentum(const dat: HMDT;dir: char;const how: PChar): HMDT; cdecl; external libmgl; +/// Get array which values is result of interpolation this for coordinates from other arrays +function mgl_data_evaluate(const dat: HMDT;const idat: HMDT;const jdat: HMDT;const kdat: HMDT;norm: integer): HMDT; cdecl; external libmgl; +/// Set as the data envelop +procedure mgl_data_envelop(dat: HMDT;dir: char); cdecl; external libmgl; +/// Remove phase jump +procedure mgl_data_sew(dat: HMDT;const dirs: PChar;da: mreal); cdecl; external libmgl; +/// Crop the data +procedure mgl_data_crop(dat: HMDT;n1: integer;n2: integer;dir: char); cdecl; external libmgl; +/// Remove rows with duplicate values in column id +procedure mgl_data_clean(dat: HMDT;id: integer); cdecl; external libmgl; +/// Multiply the data by other one for each element +procedure mgl_data_mul_dat(dat: HMDT;const d: HMDT); cdecl; external libmgl; +/// Divide the data by other one for each element +procedure mgl_data_div_dat(dat: HMDT;const d: HMDT); cdecl; external libmgl; +/// Add the other data +procedure mgl_data_add_dat(dat: HMDT;const d: HMDT); cdecl; external libmgl; +/// Subtract the other data +procedure mgl_data_sub_dat(dat: HMDT;const d: HMDT); cdecl; external libmgl; +/// Multiply each element by the number +procedure mgl_data_mul_num(dat: HMDT;d: mreal); cdecl; external libmgl; +/// Divide each element by the number +procedure mgl_data_div_num(dat: HMDT;d: mreal); cdecl; external libmgl; +/// Add the number +procedure mgl_data_add_num(dat: HMDT;d: mreal); cdecl; external libmgl; +/// Subtract the number +procedure mgl_data_sub_num(dat: HMDT;d: mreal); cdecl; external libmgl; +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for amplitude and phase +function mgl_transform_a(const am: HMDT;const ph: HMDT;const tr: PChar): HMDT; cdecl; external libmgl; +/// Integral data transformation (like Fourier 'f' or 'i', Hankel 'h' or None 'n') for real and imaginary parts +function mgl_transform(const re: HMDT;const im: HMDT;const tr: PChar): HMDT; cdecl; external libmgl; +/// Apply Fourier transform for the data and save result into it +procedure mgl_data_fourier(re: HMDT;im: HMDT;const dir: PChar); cdecl; external libmgl; +/// Short time Fourier analysis for real and imaginary parts. Output is amplitude of partial Fourier (result will have size {dn, floor(nx/dn), ny} for dir='x' +function mgl_data_stfa(const re: HMDT;const im: HMDT;dn: integer;dir: char): HMDT; cdecl; external libmgl; +/// Do something like Delone triangulation for 3d points +function mgl_triangulation_3d(const x: HMDT;const y: HMDT;const z: HMDT): HMDT; cdecl; external libmgl; +/// Do Delone triangulation for 2d points +function mgl_triangulation_2d(const x: HMDT;const y: HMDT): HMDT; cdecl; external libmgl; +/// Find root for nonlinear equation +/// Find root for nonlinear equation defined by textual formula +function mgl_find_root_txt(const func: PChar;ini: mreal;var_id: char): mreal; cdecl; external libmgl; +/// Find roots for nonlinear equation defined by textual formula +function mgl_data_roots(const func: PChar;const ini: HMDT;var_id: char): HMDT; cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/datac_cf.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// Create HMDT object +function mgl_create_datac(): HADT; cdecl; external libmgl; +/// Create HMDT object with specified sizes +function mgl_create_datac_size(nx: integer;ny: integer;nz: integer): HADT; cdecl; external libmgl; +/// Create HMDT object with data from file +function mgl_create_datac_file(const fname: PChar): HADT; cdecl; external libmgl; +/// Delete HMDT object +procedure mgl_delete_datac(dat: HADT); cdecl; external libmgl; +/// Rearange data dimensions +procedure mgl_datac_rearrange(dat: HADT;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Link external data array (don't delete it at exit) +procedure mgl_datac_link(dat: HADT;A: Pdual;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (float *) array +procedure mgl_datac_set_float(dat: HADT;const A: Preal;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (double *) array +procedure mgl_datac_set_double(dat: HADT;const A: Pdouble;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Allocate memory and copy the data from the (dual *) array +procedure mgl_datac_set_complex(dat: HADT;const A: Pdual;mx: integer;my: integer;mz: integer); cdecl; external libmgl; +/// Import data from abstract type +procedure mgl_datac_set(dat: HADT;const a: HMDT); cdecl; external libmgl; +/// Allocate memory and copy the data from the gsl_vector +procedure mgl_datac_set_vector(dat: HADT;v: PGSLVector); cdecl; external libmgl; +/// Allocate memory and copy the data from the gsl_matrix +procedure mgl_datac_set_matrix(dat: HADT;m: PGSLMatrix); cdecl; external libmgl; +/// Set value of data element [i,j,k] +procedure mgl_datac_set_value(dat: HADT;v: dual;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Get value of data element [i,j,k] +function mgl_datac_get_value(const dat: HMDT;i: integer;j: integer;k: integer): dual; cdecl; external libmgl; +/// Allocate memory and scanf the data from the string +procedure mgl_datac_set_values(dat: HADT;const val: PChar;nx: integer;ny: integer;nz: integer); cdecl; external libmgl; +/// Returns pointer to internal data array +function mgl_datac_data(dat: HADT): PDual; cdecl; external libmgl; +/// Returns pointer to data element [i,j,k] +function mgl_datac_value(dat: HADT;i: integer;j: integer;k: integer): PDual; cdecl; external libmgl; +/// Set the data from HCDT objects for real and imaginary parts +procedure mgl_datac_set_ri(dat: HADT;const re: HMDT;const im: HMDT); cdecl; external libmgl; +/// Set the data from HCDT objects as amplitude and phase of complex data +procedure mgl_datac_set_ap(dat: HADT;const abs: HMDT;const phi: HMDT); cdecl; external libmgl; +/// Read data from tab-separated text file with auto determining size +function mgl_datac_read(dat: HADT;const fname: PChar): integer; cdecl; external libmgl; +/// Read data from text file with size specified at beginning of the file +function mgl_datac_read_mat(dat: HADT;const fname: PChar;dim: integer): integer; cdecl; external libmgl; +/// Read data from text file with specifeid size +function mgl_datac_read_dim(dat: HADT;const fname: PChar;mx: integer;my: integer;mz: integer): integer; cdecl; external libmgl; +/// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to +function mgl_datac_read_range(d: HADT;const templ: PChar;from: double;to_: double;step: double;as_slice: integer): integer; cdecl; external libmgl; +/// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") +function mgl_datac_read_all(dat: HADT;const templ: PChar;as_slice: integer): integer; cdecl; external libmgl; +/// Save whole data array (for ns=-1) or only ns-th slice to text file +procedure mgl_datac_save(const dat: HMDT;const fname: PChar;ns: integer); cdecl; external libmgl; +/// Read data array from HDF file (parse HDF4 and HDF5 files) +function mgl_datac_read_hdf(d: HADT;const fname: PChar;const data: PChar): integer; cdecl; external libmgl; +/// Save data to HDF file +procedure mgl_datac_save_hdf(const d: HMDT;const fname: PChar;const data: PChar;rewrite: integer); cdecl; external libmgl; +/// Create or recreate the array with specified size and fill it by zero +procedure mgl_datac_create(dat: HADT;nx: integer;ny: integer;nz: integer); cdecl; external libmgl; +/// Transpose dimensions of the data (generalization of Transpose) +procedure mgl_datac_transpose(dat: HADT;const dim: PChar); cdecl; external libmgl; +/// Set names for columns (slices) +procedure mgl_datac_set_id(d: HADT;const id: PChar); cdecl; external libmgl; +/// Equidistantly fill the data to range [x1,x2] in direction dir +procedure mgl_datac_fill(dat: HADT;x1: dual;x2: dual;dir: char); cdecl; external libmgl; +/// Modify the data by specified formula assuming x,y,z in range [r1,r2] +procedure mgl_datac_fill_eq(gr: HMGL;dat: HADT;const eq: PChar;const vdat: HMDT;const wdat: HMDT;const opt: PChar); cdecl; external libmgl; +/// Modify the data by specified formula +procedure mgl_datac_modify(dat: HADT;const eq: PChar;dim: integer); cdecl; external libmgl; +/// Modify the data by specified formula +procedure mgl_datac_modify_vw(dat: HADT;const eq: PChar;const vdat: HMDT;const wdat: HMDT); cdecl; external libmgl; +/// Put value to data element(s) +procedure mgl_datac_put_val(dat: HADT;val: dual;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Put array to data element(s) +procedure mgl_datac_put_dat(dat: HADT;const val: HMDT;i: integer;j: integer;k: integer); cdecl; external libmgl; +/// Reduce size of the data +procedure mgl_datac_squeeze(dat: HADT;rx: integer;ry: integer;rz: integer;smooth: integer); cdecl; external libmgl; +/// Extend data dimensions +procedure mgl_datac_extend(dat: HADT;n1: integer;n2: integer); cdecl; external libmgl; +/// Insert data rows/columns/slices +procedure mgl_datac_insert(dat: HADT;dir: char;at: integer;num: integer); cdecl; external libmgl; +/// Delete data rows/columns/slices +procedure mgl_datac_delete(dat: HADT;dir: char;at: integer;num: integer); cdecl; external libmgl; +/// Joind another data array +procedure mgl_datac_join(dat: HADT;const d: HMDT); cdecl; external libmgl; +/// Smooth the data on specified direction or directions +procedure mgl_datac_smooth(d: HADT;const dirs: PChar;delta: mreal); cdecl; external libmgl; +/// Cumulative summation the data in given direction or directions +procedure mgl_datac_cumsum(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Integrate (cumulative summation) the data in given direction or directions +procedure mgl_datac_integral(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Differentiate the data in given direction or directions +procedure mgl_datac_diff(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Double-differentiate (like Laplace operator) the data in given direction +procedure mgl_datac_diff2(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Swap left and right part of the data in given direction (useful for Fourier spectrum) +procedure mgl_datac_swap(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Roll data along direction dir by num slices +procedure mgl_datac_roll(dat: HADT;dir: char;num: integer); cdecl; external libmgl; +/// Mirror the data in given direction (useful for Fourier spectrum) +procedure mgl_datac_mirror(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Crop the data +procedure mgl_datac_crop(dat: HADT;n1: integer;n2: integer;dir: char); cdecl; external libmgl; +/// Apply Hankel transform +procedure mgl_datac_hankel(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Apply Fourier transform +procedure mgl_datac_fft(dat: HADT;const dir: PChar); cdecl; external libmgl; +/// Find correlation between 2 data arrays +function mgl_datac_correl(const dat1: HMDT;const dat2: HMDT;const dir: PChar): HADT; cdecl; external libmgl; +function mgl_datac_real(const dat: HMDT): HMDT; cdecl; external libmgl; +function mgl_datac_imag(const dat: HMDT): HMDT; cdecl; external libmgl; +function mgl_datac_abs(const dat: HMDT): HMDT; cdecl; external libmgl; +function mgl_datac_arg(const dat: HMDT): HMDT; cdecl; external libmgl; +/// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_datac_linear(const d: HMDT;x: mreal;y: mreal;z: mreal): dual; cdecl; external libmgl; +/// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_datac_linear_ext(const d: HMDT;x: mreal;y: mreal;z: mreal;dx: Pdual;dy: Pdual;dz: Pdual): dual; cdecl; external libmgl; +/// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_datac_spline(const dat: HMDT;x: mreal;y: mreal;z: mreal): dual; cdecl; external libmgl; +/// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] +function mgl_datac_spline_ext(const dat: HMDT;x: mreal;y: mreal;z: mreal;dx: Pdual;dy: Pdual;dz: Pdual): dual; cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/cont.h ==} +//----------------------------------------------------------------------------- +/// Print text along the curve in parametric form {x,y,z} +procedure mgl_text_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const text: PChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textw_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const text: PWideChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +/// Print text along the curve in parametric form {x,y} +procedure mgl_text_xy(gr: HMGL;const x: HMDT;const y: HMDT;const text: PChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textw_xy(gr: HMGL;const x: HMDT;const y: HMDT;const text: PWideChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +/// Print text along the curve +procedure mgl_text_y(gr: HMGL;const y: HMDT;const text: PChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textw_y(gr: HMGL;const y: HMDT;const text: PWideChar;const font: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_cont_gen(gr: HMGL;val: double;const a: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const stl: PChar); cdecl; external libmgl; +procedure mgl_contf_gen(gr: HMGL;v1: double;v2: double;const a: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const stl: PChar); cdecl; external libmgl; +//void MGL_EXPORT mgl_contv_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl) +//void MGL_EXPORT mgl_axial_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *stl) +/// Draw manual contour lines for 2d data specified parametrically +procedure mgl_cont_xy_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for 2d data +procedure mgl_cont_val(gr: HMGL;const v: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for 2d data specified parametrically +procedure mgl_cont_xy(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for 2d data +procedure mgl_cont(gr: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for 2d data specified parametrically +procedure mgl_contf_xy_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for 2d data +procedure mgl_contf_val(gr: HMGL;const v: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for 2d data specified parametrically +procedure mgl_contf_xy(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for 2d data +procedure mgl_contf(gr: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for 2d data specified parametrically with manual colors +procedure mgl_contd_xy_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for 2d data with manual colors +procedure mgl_contd_val(gr: HMGL;const v: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for 2d data specified parametrically with manual colors +procedure mgl_contd_xy(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for 2d data with manual colors +procedure mgl_contd(gr: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour tubes for 2d data specified parametrically +procedure mgl_contv_xy_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour tubes for 2d data +procedure mgl_contv_val(gr: HMGL;const v: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour tubes for 2d data specified parametrically +procedure mgl_contv_xy(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour tubes for 2d data +procedure mgl_contv(gr: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual axial-symmetric isosurfaces for 2d data specified parametrically +procedure mgl_axial_xy_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual axial-symmetric isosurfaces for 2d data +procedure mgl_axial_val(gr: HMGL;const v: HMDT;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw axial-symmetric isosurfaces for 2d data specified parametrically +procedure mgl_axial_xy(gr: HMGL;const x: HMDT;const y: HMDT;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw axial-symmetric isosurfaces for 2d data +procedure mgl_axial(gr: HMGL;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface of curve {r,z} rotatation around axis +procedure mgl_torus(gr: HMGL;const r: HMDT;const z: HMDT;const col: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw grid lines for density plot at slice for 3d data specified parametrically +procedure mgl_grid3_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw grid lines for density plot at slice for 3d data +procedure mgl_grid3(gr: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw density plot at slice for 3d data specified parametrically +procedure mgl_dens3_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw density plot at slice for 3d data +procedure mgl_dens3(gr: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines at slice for 3d data specified parametrically +procedure mgl_cont3_xyz_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines at slice for 3d data +procedure mgl_cont3_val(gr: HMGL;const v: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines at slice for 3d data specified parametrically +procedure mgl_cont3_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines at slice for 3d data +procedure mgl_cont3(gr: HMGL;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours at slice for 3d data specified parametrically +procedure mgl_contf3_xyz_val(gr: HMGL;const v: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours at slice for 3d data +procedure mgl_contf3_val(gr: HMGL;const v: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours at slice for 3d data specified parametrically +procedure mgl_contf3_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours at slice for 3d data +procedure mgl_contf3(gr: HMGL;const a: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +{== ../include/mgl2/fit.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +function mgl_fit_1(gr: HMGL;const y: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_2(gr: HMGL;const z: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_3(gr: HMGL;const a: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xy(gr: HMGL;const x: HMDT;const y: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xyza(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_ys(gr: HMGL;const y: HMDT;const s: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xys(gr: HMGL;const x: HMDT;const y: HMDT;const s: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xyzs(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const s: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_fit_xyzas(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const s: HMDT;const eq: PChar;const vars: PChar;ini: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_get_fit(gr: HMGL): PChar; cdecl; external libmgl; +function mgl_hist_x(gr: HMGL;const x: HMDT;const a: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_hist_xy(gr: HMGL;const x: HMDT;const y: HMDT;const a: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +function mgl_hist_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const opt: PChar): HMDT; cdecl; external libmgl; +procedure mgl_puts_fit(gr: HMGL;x: double;y: double;z: double;const prefix: PChar;const font: PChar;size: double); cdecl; external libmgl; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +{== ../include/mgl2/plot.h ==} +//----------------------------------------------------------------------------- +/// Draw curve for formula with x in x-axis range +procedure mgl_fplot(gr: HMGL;const eqY: PChar;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw curve for formulas parametrically depended on t in range [0,1] +procedure mgl_fplot_xyz(gr: HMGL;const eqX: PChar;const eqY: PChar;const eqZ: PChar;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw radar chart (plot in curved coordinates) +procedure mgl_radar(graph: HMGL;const a: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw usual curve {x,y,z} +procedure mgl_plot_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw usual curve {x,y} +procedure mgl_plot_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw usual curve {x,y} with x in x-axis range +procedure mgl_plot(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw curve {x,y,z} which is colored by c (like tension plot) +procedure mgl_tens_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw curve {x,y} which is colored by c (like tension plot) +procedure mgl_tens_xy(graph: HMGL;const x: HMDT;const y: HMDT;const c: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw curve {x,y} with x in x-axis range which is colored by c (like tension plot) +procedure mgl_tens(graph: HMGL;const y: HMDT;const c: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y,z} +procedure mgl_tape_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y} +procedure mgl_tape_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y} with x in x-axis range +procedure mgl_tape(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw box-plot (special 5-value plot used in statistic) for data specified parametrically +procedure mgl_boxplot_xy(graph: HMGL;const x: HMDT;const a: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw box-plot (special 5-value plot used in statistic) +procedure mgl_boxplot(graph: HMGL;const a: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Fill area between curve {x,y,z} and axis plane +procedure mgl_area_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Fill area between curve {x,y} and axis plane +procedure mgl_area_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Fill area between curve {x,y} with x in x-axis range and axis plane +procedure mgl_area(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Fill area between curves {x,y1} and {x,y2} +procedure mgl_region_xy(graph: HMGL;const x: HMDT;const y1: HMDT;const y2: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Fill area between curves {x,y1} and {x,y2} with x in x-axis range +procedure mgl_region(graph: HMGL;const y1: HMDT;const y2: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical lines from points {x,y,z} to axis plane +procedure mgl_stem_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical lines from points {x,y} to axis plane +procedure mgl_stem_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical lines from points {x,y} with x in x-axis range to axis plane +procedure mgl_stem(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw stairs for points in arrays {x,y,z} +procedure mgl_step_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw stairs for points in arrays {x,y} +procedure mgl_step_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw stairs for points in arrays {x,y} with x in x-axis range +procedure mgl_step(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical bars from points {x,y,z} to axis plane +procedure mgl_bars_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical bars from points {x,y} to axis plane +procedure mgl_bars_xy(graph: HMGL;const x: HMDT;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical bars from points {x,y} with x in x-axis range to axis plane +procedure mgl_bars(graph: HMGL;const y: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw horizontal bars from points {v,y} to axis plane +procedure mgl_barh_yx(graph: HMGL;const y: HMDT;const v: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw horizontal bars from points {v,y} with y in y-axis range to axis plane +procedure mgl_barh(graph: HMGL;const v: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw Open-High-Low-Close (OHLC) diagram +procedure mgl_ohlc_x(graph: HMGL;const x: HMDT;const open: HMDT;const high: HMDT;const low: HMDT;const close: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw Open-High-Low-Close (OHLC) diagram with x in x-axis range +procedure mgl_ohlc(graph: HMGL;const open: HMDT;const high: HMDT;const low: HMDT;const close: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw chart for data a +procedure mgl_chart(graph: HMGL;const a: HMDT;const col: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw error boxes {ex,ey} at points {x,y} +procedure mgl_error_exy(graph: HMGL;const x: HMDT;const y: HMDT;const ex: HMDT;const ey: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw error boxes {ey} at points {x,y} +procedure mgl_error_xy(graph: HMGL;const x: HMDT;const y: HMDT;const ey: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw error boxes {ey} at points {x,y} with x in x-axis range +procedure mgl_error(graph: HMGL;const y: HMDT;const ey: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw marks with size r at points {x,y,z} +procedure mgl_mark_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw marks with size r at points {x,y} +procedure mgl_mark_xy(graph: HMGL;const x: HMDT;const y: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw marks with size r at points {x,y} with x in x-axis range +procedure mgl_mark_y(graph: HMGL;const y: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with variable radius r around curve {x,y,z} +procedure mgl_tube_xyzr(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with variable radius r around curve {x,y} +procedure mgl_tube_xyr(graph: HMGL;const x: HMDT;const y: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with variable radius r around curve {x,y} with x in x-axis range +procedure mgl_tube_r(graph: HMGL;const y: HMDT;const r: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with constant radius r around curve {x,y,z} +procedure mgl_tube_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;r: double;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with constant radius r around curve {x,y} +procedure mgl_tube_xy(graph: HMGL;const x: HMDT;const y: HMDT;r: double;const penl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw tube with constant radius r around curve {x,y} with x in x-axis range +procedure mgl_tube(graph: HMGL;const y: HMDT;r: double;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw candle plot for data specified parametrically +procedure mgl_candle_xyv(gr: HMGL;const x: HMDT;const v1: HMDT;const v2: HMDT;const y1: HMDT;const y2: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw candle plot +procedure mgl_candle_yv(gr: HMGL;const v1: HMDT;const v2: HMDT;const y1: HMDT;const y2: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw candle plot with v1=v[i], v2=v[i+1] +procedure mgl_candle(gr: HMGL;const v: HMDT;const y1: HMDT;const y2: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/surf.h ==} +//----------------------------------------------------------------------------- +/// Draw surface by formula with x,y in axis range +procedure mgl_fsurf(graph: HMGL;const fz: PChar;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface by formulas parametrically depended on u,v in range [0,1] +procedure mgl_fsurf_xyz(graph: HMGL;const fx: PChar;const fy: PChar;const fz: PChar;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw grid lines for density plot of 2d data specified parametrically +procedure mgl_grid_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw grid lines for density plot of 2d data +procedure mgl_grid(graph: HMGL;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw mesh lines for 2d data specified parametrically +procedure mgl_mesh_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw mesh lines for 2d data +procedure mgl_mesh(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw mesh lines for 2d data specified parametrically +procedure mgl_fall_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw mesh lines for 2d data +procedure mgl_fall(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw belts for 2d data specified parametrically +procedure mgl_belt_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw belts for 2d data +procedure mgl_belt(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data specified parametrically with color proportional to z +procedure mgl_surf_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data with color proportional to z +procedure mgl_surf(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for 2d data specified parametrically +procedure mgl_dens_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for 2d data +procedure mgl_dens(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical boxes for 2d data specified parametrically +procedure mgl_boxs_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical boxes for 2d data +procedure mgl_boxs(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical tiles for 2d data specified parametrically +procedure mgl_tile_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical tiles for 2d data +procedure mgl_tile(graph: HMGL;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical tiles with variable size r for 2d data specified parametrically +procedure mgl_tiles_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const r: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vertical tiles with variable size r for 2d data +procedure mgl_tiles(graph: HMGL;const z: HMDT;const r: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data specified parametrically with color proportional to c +procedure mgl_surfc_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data with color proportional to c +procedure mgl_surfc(graph: HMGL;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data specified parametrically with alpha proportional to c +procedure mgl_surfa_xy(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface for 2d data with alpha proportional to c +procedure mgl_surfa(graph: HMGL;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for spectra-gramm specified parametrically +procedure mgl_stfa_xy(graph: HMGL;const x: HMDT;const y: HMDT;const re: HMDT;const im: HMDT;dn: integer;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for spectra-gramm +procedure mgl_stfa(graph: HMGL;const re: HMDT;const im: HMDT;dn: integer;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Color map of matrix a to matrix b, both matrix can parametrically depend on coordinates +procedure mgl_map_xy(graph: HMGL;const x: HMDT;const y: HMDT;const a: HMDT;const b: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Color map of matrix a to matrix b +procedure mgl_map(graph: HMGL;const a: HMDT;const b: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/volume.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// Draw isosurface for 3d data specified parametrically +procedure mgl_surf3_xyz_val(graph: HMGL;Val: double;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d data +procedure mgl_surf3_val(graph: HMGL;Val: double;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data specified parametrically +procedure mgl_surf3_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data +procedure mgl_surf3(graph: HMGL;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d data specified parametrically with alpha proportional to b +procedure mgl_surf3a_xyz_val(graph: HMGL;Val: double;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d data with alpha proportional to b +procedure mgl_surf3a_val(graph: HMGL;Val: double;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data specified parametrically with alpha proportional to b +procedure mgl_surf3a_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data with alpha proportional to b +procedure mgl_surf3a(graph: HMGL;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d data specified parametrically with color proportional to b +procedure mgl_surf3c_xyz_val(graph: HMGL;Val: double;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d data with color proportional to b +procedure mgl_surf3c_val(graph: HMGL;Val: double;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data specified parametrically with color proportional to b +procedure mgl_surf3c_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurfaces for 3d data with color proportional to b +procedure mgl_surf3c(graph: HMGL;const a: HMDT;const b: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw a semi-transparent cloud for 3d data specified parametrically +procedure mgl_cloud_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw a semi-transparent cloud for 3d data +procedure mgl_cloud(graph: HMGL;const a: HMDT;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw isosurface for 3d beam in curvilinear coordinates +procedure mgl_beam_val(graph: HMGL;Val: double;const tr: HMDT;const g1: HMDT;const g2: HMDT;const a: HMDT;r: double;const stl: PChar;norm: integer); cdecl; external libmgl; +/// Draw several isosurfaces for 3d beam in curvilinear coordinates +procedure mgl_beam(graph: HMGL;const tr: HMDT;const g1: HMDT;const g2: HMDT;const a: HMDT;r: double;const stl: PChar;norm: integer;num: integer); cdecl; external libmgl; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +{== ../include/mgl2/vect.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// Plot vectors at position {x,y} along {ax,ay} with length/color proportional to |a| +procedure mgl_traj_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot vectors at position {x,y,z} along {ax,ay,az} with length/color proportional to |a| +procedure mgl_traj_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot vector field {ax,ay} parametrically depended on coordinate {x,y} with length/color proportional to |a| +procedure mgl_vect_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot vector field {ax,ay} with length/color proportional to |a| +procedure mgl_vect_2d(gr: HMGL;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with length/color proportional to |a| +procedure mgl_vect_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot vector field {ax,ay,az} with length/color proportional to |a| +procedure mgl_vect_3d(gr: HMGL;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for vector field {ax,ay} parametrically depended on coordinate {x,y} with color proportional to |a| +procedure mgl_flow_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for vector field {ax,ay} with color proportional to |a| +procedure mgl_flow_2d(gr: HMGL;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| +procedure mgl_flow_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for vector field {ax,ay,az} with color proportional to |a| +procedure mgl_flow_3d(gr: HMGL;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flow from point p for vector field {ax,ay} parametrically depended on coordinate {x,y} with color proportional to |a| +procedure mgl_flowp_xy(gr: HMGL;x0: double;y0: double;z0: double;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flow from point p for vector field {ax,ay} with color proportional to |a| +procedure mgl_flowp_2d(gr: HMGL;x0: double;y0: double;z0: double;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flow from point p for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| +procedure mgl_flowp_xyz(gr: HMGL;x0: double;y0: double;z0: double;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flow from point p for vector field {ax,ay,az} with color proportional to |a| +procedure mgl_flowp_3d(gr: HMGL;x0: double;y0: double;z0: double;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flow pipes for vector field {ax,ay} parametrically depended on coordinate {x,y} with color and radius proportional to |a| +procedure mgl_pipe_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;r0: double;const opt: PChar); cdecl; external libmgl; +/// Plot flow pipes for vector field {ax,ay} with color and radius proportional to |a| +procedure mgl_pipe_2d(gr: HMGL;const ax: HMDT;const ay: HMDT;const sch: PChar;r0: double;const opt: PChar); cdecl; external libmgl; +/// Plot flow pipes for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color and radius proportional to |a| +procedure mgl_pipe_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;r0: double;const opt: PChar); cdecl; external libmgl; +/// Plot flow pipes for vector field {ax,ay,az} with color and radius proportional to |a| +procedure mgl_pipe_3d(gr: HMGL;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;r0: double;const opt: PChar); cdecl; external libmgl; +/// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y,z} +procedure mgl_grad_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ph: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y} +procedure mgl_grad_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ph: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot flows for gradient of scalar field phi +procedure mgl_grad(gr: HMGL;const ph: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw vector plot at slice for 3d data specified parametrically +procedure mgl_vect3_xyz(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw vector plot at slice for 3d data +procedure mgl_vect3(gr: HMGL;const ax: HMDT;const ay: HMDT;const az: HMDT;const sch: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +{== ../include/mgl2/prim.h ==} +//----------------------------------------------------------------------------- +/// Draws the mark at position {x,y,z} +procedure mgl_mark(gr: HMGL;x: double;y: double;z: double;const mark: PChar); cdecl; external libmgl; +/// Draws red point (ball) at position {x,y,z} +procedure mgl_ball(gr: HMGL;x: double;y: double;z: double); cdecl; external libmgl; +/// Draws the line between 2 points by specified pen +procedure mgl_line(gr: HMGL;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double;const pen: PChar;n: integer); cdecl; external libmgl; +/// Draws the spline curve between 2 points by specified pen +procedure mgl_curve(gr: HMGL;x1: double;y1: double;z1: double;dx1: double;dy1: double;dz1: double;x2: double;y2: double;z2: double;dx2: double;dy2: double;dz2: double;const pen: PChar;n: integer); cdecl; external libmgl; +/// Draws the 3d error box {ex,ey,ez} for point {x,y,z} +procedure mgl_error_box(gr: HMGL;x: double;y: double;z: double;ex: double;ey: double;ez: double;const pen: PChar); cdecl; external libmgl; +/// Draws the face between points with color stl (include interpolation up to 4 colors). +procedure mgl_face(gr: HMGL;x0: double;y0: double;z0: double;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double;x3: double;y3: double;z3: double;const stl: PChar); cdecl; external libmgl; +/// Draws the face in y-z plane at point p with color stl (include interpolation up to 4 colors). +procedure mgl_facex(gr: HMGL;x0: double;y0: double;z0: double;wy: double;wz: double;const stl: PChar;dx: double;dy: double); cdecl; external libmgl; +/// Draws the face in x-z plane at point p with color stl (include interpolation up to 4 colors). +procedure mgl_facey(gr: HMGL;x0: double;y0: double;z0: double;wx: double;wz: double;const stl: PChar;dx: double;dy: double); cdecl; external libmgl; +/// Draws the face in x-y plane at point p with color stl (include interpolation up to 4 colors). +procedure mgl_facez(gr: HMGL;x0: double;y0: double;z0: double;wx: double;wy: double;const stl: PChar;dx: double;dy: double); cdecl; external libmgl; +/// Draws the sphere at point {x,y,z} with color stl and radius r +procedure mgl_sphere(gr: HMGL;x: double;y: double;z: double;r: double;const stl: PChar); cdecl; external libmgl; +/// Draws the drop at point {x,y,z} in direction {dx,dy,dz} with color stl and radius r +procedure mgl_drop(gr: HMGL;x: double;y: double;z: double;dx: double;dy: double;dz: double;r: double;const stl: PChar;shift: double;ap: double); cdecl; external libmgl; +/// Draws the cone between points p1,p2 with radius r1,r2 and with style stl +procedure mgl_cone(gr: HMGL;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double;r1: double;r2: double;const stl: PChar); cdecl; external libmgl; +/// Draws the ellipse between points p1,p2 with color stl and width r +procedure mgl_ellipse(gr: HMGL;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double;r: double;const stl: PChar); cdecl; external libmgl; +/// Draws the rhomb between points p1,p2 with color stl and width r +procedure mgl_rhomb(gr: HMGL;x1: double;y1: double;z1: double;x2: double;y2: double;z2: double;r: double;const stl: PChar); cdecl; external libmgl; +/// Draw cones from points {x,y,z} to axis plane +procedure mgl_cones_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw cones from points {x,z} to axis plane +procedure mgl_cones_xz(graph: HMGL;const x: HMDT;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw cones from points {x,z} with x in x-axis range to axis plane +procedure mgl_cones(graph: HMGL;const z: HMDT;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot dew drops for vector field {ax,ay} parametrically depended on coordinate {x,y} +procedure mgl_dew_xy(gr: HMGL;const x: HMDT;const y: HMDT;const ax: HMDT;const ay: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Plot dew drops for vector field {ax,ay} +procedure mgl_dew_2d(gr: HMGL;const ax: HMDT;const ay: HMDT;const sch: PChar;const optl: PChar); cdecl; external libmgl; +/// Print text in position {x,y,z} with specified font +procedure mgl_puts_dir(graph: HMGL;x: double;y: double;z: double;dx: double;dy: double;dz: double;const text: PChar;const font: PChar;size: double); cdecl; external libmgl; +procedure mgl_putsw_dir(graph: HMGL;x: double;y: double;z: double;dx: double;dy: double;dz: double;const text: PWideChar;const font: PChar;size: double); cdecl; external libmgl; +/// Draw textual marks with size r at points {x,y,z} +procedure mgl_textmark_xyzr(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const r: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textmarkw_xyzr(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const r: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw textual marks with size r at points {x,y} +procedure mgl_textmark_xyr(graph: HMGL;const x: HMDT;const y: HMDT;const r: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textmarkw_xyr(graph: HMGL;const x: HMDT;const y: HMDT;const r: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw textual marks with size r at points {x,y} with x in x-axis range +procedure mgl_textmark_yr(graph: HMGL;const y: HMDT;const r: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textmarkw_yr(graph: HMGL;const y: HMDT;const r: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw textual marks with size r=1 at points {x,y} with x in x-axis range +procedure mgl_textmark(graph: HMGL;const y: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_textmarkw(graph: HMGL;const y: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw labels for points coordinate(s) at points {x,y,z} +procedure mgl_label_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_labelw_xyz(graph: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw labels for points coordinate(s) at points {x,y} +procedure mgl_label_xy(graph: HMGL;const x: HMDT;const y: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_labelw_xy(graph: HMGL;const x: HMDT;const y: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw labels for points coordinate(s) at points {x,y} with x in x-axis range +procedure mgl_label_y(graph: HMGL;const y: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_labelw_y(graph: HMGL;const y: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw table for values val along given direction with row labels text at position {x,y} +procedure mgl_table(gr: HMGL;x: double;y: double;const val: HMDT;const text: PChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +procedure mgl_tablew(gr: HMGL;x: double;y: double;const val: HMDT;const text: PWideChar;const fnt: PChar;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/other.h ==} +//----------------------------------------------------------------------------- +/// Draw triangle mesh for points in arrays {x,y,z} with specified color c. +procedure mgl_triplot_xyzc(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw triangle mesh for points in arrays {x,y,z} with color proportional to z. +procedure mgl_triplot_xyz(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw triangle mesh for points in arrays {x,y} +procedure mgl_triplot_xy(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw quad mesh for points in arrays {x,y,z} with specified color c. +procedure mgl_quadplot_xyzc(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw quad mesh for points in arrays {x,y,z} with color proportional to z. +procedure mgl_quadplot_xyz(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw quad mesh for points in arrays {x,y}. +procedure mgl_quadplot_xy(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. +procedure mgl_tricont_xyzcv(gr: HMGL;const v: HMDT;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for triangle mesh for points in arrays {x,y,z}. +procedure mgl_tricont_xycv(gr: HMGL;const v: HMDT;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. +procedure mgl_tricont_xyzc(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for triangle mesh for points in arrays {x,y,z}. +procedure mgl_tricont_xyc(gr: HMGL;const nums: HMDT;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw dots in points {x,y,z}. +procedure mgl_dots(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw semitransparent dots in points {x,y,z} with specified alpha a. +procedure mgl_dots_a(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. +procedure mgl_dots_ca(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const c: HMDT;const a: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw surface reconstructed for points in arrays {x,y,z}. +procedure mgl_crust(gr: HMGL;const x: HMDT;const y: HMDT;const z: HMDT;const sch: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for data at x = sVal +procedure mgl_dens_x(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for data at y = sVal +procedure mgl_dens_y(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw density plot for data at z = sVal +procedure mgl_dens_z(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for data at x = sVal +procedure mgl_cont_x(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for data at y = sVal +procedure mgl_cont_y(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw contour lines for data at z = sVal +procedure mgl_cont_z(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for data at x = sVal +procedure mgl_cont_x_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for data at y = sVal +procedure mgl_cont_y_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual contour lines for data at z = sVal +procedure mgl_cont_z_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for data at x = sVal +procedure mgl_contf_x(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for data at y = sVal +procedure mgl_contf_y(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw solid contours for data at z = sVal +procedure mgl_contf_z(graph: HMGL;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for data at x = sVal +procedure mgl_contf_x_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for data at y = sVal +procedure mgl_contf_y_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +/// Draw manual solid contours for data at z = sVal +procedure mgl_contf_z_val(graph: HMGL;const v: HMDT;const a: HMDT;const stl: PChar;sVal: double;const opt: PChar); cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/canvas_cf.h ==} +//----------------------------------------------------------------------------- +/// Create HMGL object with specified sizes +function mgl_create_graph(width: integer;height: integer): HMGL; cdecl; external libmgl; +/// Delete HMGL object +procedure mgl_delete_graph(gr: HMGL); cdecl; external libmgl; +/// Set size of frame in pixels. Normally this function is called internally. +procedure mgl_set_size(gr: HMGL;width: integer;height: integer); cdecl; external libmgl; +/// Set default parameters for plotting +procedure mgl_set_def_param(gr: HMGL); cdecl; external libmgl; +/// Combine plots from 2 canvases. Result will be saved into gr +procedure mgl_combine_gr(gr: HMGL;gr2: HMGL); cdecl; external libmgl; +/// Force preparing the image. It can be useful for OpenGL mode mostly. +procedure mgl_finish(gr: HMGL); cdecl; external libmgl; +/// Set tick length +procedure mgl_set_tick_len(gr: HMGL;len: double;stt: double); cdecl; external libmgl; +/// Set axis and ticks style +procedure mgl_set_axis_stl(gr: HMGL;const stl: PChar;const tck: PChar;const sub: PChar); cdecl; external libmgl; +/// Auto adjust ticks +procedure mgl_adjust_ticks(gr: HMGL;const dir: PChar); cdecl; external libmgl; +/// Set the ticks parameters +procedure mgl_set_ticks(gr: HMGL;dir: char;d: double;ns: integer;org: double); cdecl; external libmgl; +/// Set ticks text (\n separated). Use "" to disable this feature. +procedure mgl_set_ticks_str(gr: HMGL;dir: char;const lbl: PChar;add: integer); cdecl; external libmgl; +procedure mgl_set_ticks_wcs(gr: HMGL;dir: char;const lbl: PWideChar;add: integer); cdecl; external libmgl; +/// Set ticks position and text (\n separated). Use "" to disable this feature. +procedure mgl_set_ticks_val(gr: HMGL;dir: char;const val: HMDT;const lbl: PChar;add: integer); cdecl; external libmgl; +procedure mgl_set_ticks_valw(gr: HMGL;dir: char;const val: HMDT;const lbl: PWideChar;add: integer); cdecl; external libmgl; +/// Tune ticks +procedure mgl_tune_ticks(gr: HMGL;tune: integer;fact_pos: double); cdecl; external libmgl; +/// Set templates for ticks +procedure mgl_set_tick_templ(gr: HMGL;dir: char;const templ: PChar); cdecl; external libmgl; +procedure mgl_set_tick_templw(gr: HMGL;dir: char;const templ: PWideChar); cdecl; external libmgl; +/// Set time templates for ticks +procedure mgl_set_ticks_time(gr: HMGL;dir: char;d: double;const t: PChar); cdecl; external libmgl; +/// Set additional shift of tick labels +procedure mgl_set_tick_shift(gr: HMGL;sx: double;sy: double;sz: double;sc: double); cdecl; external libmgl; +/// Draws bounding box outside the plotting volume +procedure mgl_box(gr: HMGL); cdecl; external libmgl; +/// Draws bounding box outside the plotting volume with color c +procedure mgl_box_str(gr: HMGL;const col: PChar;ticks: integer); cdecl; external libmgl; +/// Draw axises with ticks in direction(s) dir. +procedure mgl_axis(gr: HMGL;const dir: PChar;const stl: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw grid lines perpendicular to direction(s) dir. +procedure mgl_axis_grid(gr: HMGL;const dir: PChar;const pen: PChar;const opt: PChar); cdecl; external libmgl; +/// Print the label text for axis dir. +procedure mgl_label(gr: HMGL;dir: char;const text: PChar;pos: double;const opt: PChar); cdecl; external libmgl; +procedure mgl_labelw(gr: HMGL;dir: char;const text: PWideChar;pos: double;const opt: PChar); cdecl; external libmgl; +/// Draw colorbar at edge of axis +procedure mgl_colorbar(gr: HMGL;const sch: PChar); cdecl; external libmgl; +/// Draw colorbar at manual position +procedure mgl_colorbar_ext(gr: HMGL;const sch: PChar;x: double;y: double;w: double;h: double); cdecl; external libmgl; +/// Draw colorbar with manual colors at edge of axis +procedure mgl_colorbar_val(gr: HMGL;const dat: HMDT;const sch: PChar); cdecl; external libmgl; +/// Draw colorbar with manual colors at manual position +procedure mgl_colorbar_val_ext(gr: HMGL;const dat: HMDT;const sch: PChar;x: double;y: double;w: double;h: double); cdecl; external libmgl; +/// Add string to legend +procedure mgl_add_legend(gr: HMGL;const text: PChar;const style: PChar); cdecl; external libmgl; +procedure mgl_add_legendw(gr: HMGL;const text: PWideChar;const style: PChar); cdecl; external libmgl; +/// Clear saved legend string +procedure mgl_clear_legend(gr: HMGL); cdecl; external libmgl; +/// Draw legend of accumulated strings at position {x,y} +procedure mgl_legend_pos(gr: HMGL;x: double;y: double;const font: PChar;const opt: PChar); cdecl; external libmgl; +/// Draw legend of accumulated strings +procedure mgl_legend(gr: HMGL;where: integer;const font: PChar;const opt: PChar); cdecl; external libmgl; +/// Set number of marks in legend sample +procedure mgl_set_legend_marks(gr: HMGL;num: integer); cdecl; external libmgl; +/// Show current image +procedure mgl_show_image(gr: HMGL;const viewer: PChar;keep: integer); cdecl; external libmgl; +/// Write the frame in file (depending extension, write current frame if fname is empty) +procedure mgl_write_frame(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using BMP format +procedure mgl_write_tga(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using BMP format +procedure mgl_write_bmp(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using JPEG format +procedure mgl_write_jpg(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using PNG format with transparency +procedure mgl_write_png(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using PNG format without transparency +procedure mgl_write_png_solid(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using PostScript format as bitmap +procedure mgl_write_bps(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using PostScript format +procedure mgl_write_eps(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using SVG format +procedure mgl_write_svg(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using LaTeX format +procedure mgl_write_tex(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using OBJ format +procedure mgl_write_obj(gr: HMGL;const fname: PChar;const descr: PChar;use_png: integer); cdecl; external libmgl; +/// Write the frame in file using OBJ format (old version) +procedure mgl_write_obj_old(gr: HMGL;const fname: PChar;const descr: PChar;use_png: integer); cdecl; external libmgl; +/// Write the frame in file using STL format (faces only) +procedure mgl_write_stl(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using OFF format +procedure mgl_write_off(gr: HMGL;const fname: PChar;const descr: PChar;colored: integer); cdecl; external libmgl; +/// Write the frame in file using XYZ format +procedure mgl_write_xyz(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Write the frame in file using PRC format +procedure mgl_write_prc(gr: HMGL;const fname: PChar;const descr: PChar;make_pdf: integer); cdecl; external libmgl; +/// Write the frame in file using GIF format (only for current frame!) +procedure mgl_write_gif(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Start write frames to cinema using GIF format +procedure mgl_start_gif(gr: HMGL;const fname: PChar;ms: integer); cdecl; external libmgl; +/// Stop writing cinema using GIF format +procedure mgl_close_gif(gr: HMGL); cdecl; external libmgl; +/// Export points and primitives in file using MGLD format +procedure mgl_export_mgld(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +/// Import points and primitives from file using MGLD format +procedure mgl_import_mgld(gr: HMGL;const fname: PChar;add: integer); cdecl; external libmgl; +/// Export in JSON format suitable for later drawing by JavaScript +procedure mgl_write_json(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +procedure mgl_write_json_z(gr: HMGL;const fname: PChar;const descr: PChar); cdecl; external libmgl; +function mgl_get_json(gr: HMGL): PChar; cdecl; external libmgl; +/// Get RGB values of current bitmap +function mgl_get_rgb(gr: HMGL): PByte; cdecl; external libmgl; +/// Get RGBA values of current bitmap +function mgl_get_rgba(gr: HMGL): PByte; cdecl; external libmgl; +/// Set object/subplot id +procedure mgl_set_obj_id(gr: HMGL;id: integer); cdecl; external libmgl; +/// Get object id +function mgl_get_obj_id(gr: HMGL;x: integer;y: integer): integer; cdecl; external libmgl; +/// Get subplot id +function mgl_get_spl_id(gr: HMGL;x: integer;y: integer): integer; cdecl; external libmgl; +/// Get width of the image +function mgl_get_width(gr: HMGL): integer; cdecl; external libmgl; +/// Get height of the image +function mgl_get_height(gr: HMGL): integer; cdecl; external libmgl; +/// Calculate 3D coordinate {x,y,z} for screen point {xs,ys} +procedure mgl_calc_xyz(gr: HMGL;xs: integer;ys: integer;x: Pmreal;y: Pmreal;z: Pmreal); cdecl; external libmgl; +/// Calculate screen point {xs,ys} for 3D coordinate {x,y,z} +procedure mgl_calc_scr(gr: HMGL;x: double;y: double;z: double;xs: Pint;ys: Pint); cdecl; external libmgl; +/// Check if {xs,ys} is close to active point with accuracy d, and return its position or -1 +function mgl_is_active(gr: HMGL;xs: integer;ys: integer;d: integer): integer; cdecl; external libmgl; +/// Create new frame. +function mgl_new_frame(gr: HMGL): integer; cdecl; external libmgl; +/// Finish frame drawing +procedure mgl_end_frame(gr: HMGL); cdecl; external libmgl; +/// Get the number of created frames +function mgl_get_num_frame(gr: HMGL): integer; cdecl; external libmgl; +/// Reset frames counter (start it from zero) +procedure mgl_reset_frames(gr: HMGL); cdecl; external libmgl; +/// Get drawing data for i-th frame (work if MGL_VECT_FRAME is set on) +procedure mgl_get_frame(gr: HMGL;i: integer); cdecl; external libmgl; +/// Set drawing data for i-th frame (work if MGL_VECT_FRAME is set on) +procedure mgl_set_frame(gr: HMGL;i: integer); cdecl; external libmgl; +/// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) +procedure mgl_show_frame(gr: HMGL;i: integer); cdecl; external libmgl; +/// Delete primitives for i-th frame (work if MGL_VECT_FRAME is set on) +procedure mgl_del_frame(gr: HMGL;i: integer); cdecl; external libmgl; +/// Set the transparency type (0 - usual, 1 - glass, 2 - lamp) +procedure mgl_set_transp_type(gr: HMGL;kind: integer); cdecl; external libmgl; +/// Set the transparency on/off. +procedure mgl_set_alpha(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Set the fog distance or switch it off (if d=0). +procedure mgl_set_fog(gr: HMGL;d: double;dz: double); cdecl; external libmgl; +/// Set the using of light on/off. +procedure mgl_set_light(gr: HMGL;enable: integer); cdecl; external libmgl; +/// Switch on/off the specified light source. +procedure mgl_set_light_n(gr: HMGL;n: integer;enable: integer); cdecl; external libmgl; +/// Add white light source at infinity. +procedure mgl_add_light(gr: HMGL;n: integer;x: double;y: double;z: double); cdecl; external libmgl; +/// Add light source at infinity (more settings). +procedure mgl_add_light_ext(gr: HMGL;n: integer;x: double;y: double;z: double;c: char;br: double;ap: double); cdecl; external libmgl; +/// Add local light source. +procedure mgl_add_light_loc(gr: HMGL;n: integer;x: double;y: double;z: double;dx: double;dy: double;dz: double;c: char;br: double;ap: double); cdecl; external libmgl; +/// Pop transformation matrix from stack +procedure mgl_mat_pop(gr: HMGL); cdecl; external libmgl; +/// Push transformation matrix into stack +procedure mgl_mat_push(gr: HMGL); cdecl; external libmgl; +/// Clear up the frame +procedure mgl_clf(gr: HMGL); cdecl; external libmgl; +/// Clear up the frame and fill background by specified color +procedure mgl_clf_rgb(gr: HMGL;r: double;g: double;b: double); cdecl; external libmgl; +/// Clear up the frame and fill background by specified color +procedure mgl_clf_chr(gr: HMGL;col: char); cdecl; external libmgl; +/// Put further plotting in some region of whole frame. +procedure mgl_subplot(gr: HMGL;nx: integer;ny: integer;m: integer;const style: PChar); cdecl; external libmgl; +/// Put further plotting in some region of whole frame and shift it by distance {dx,dy}. +procedure mgl_subplot_d(gr: HMGL;nx: integer;ny: integer;m: integer;const style: PChar;dx: double;dy: double); cdecl; external libmgl; +/// Like MGL_EXPORT mgl_subplot() but "join" several cells +procedure mgl_multiplot(gr: HMGL;nx: integer;ny: integer;m: integer;dx: integer;dy: integer;const style: PChar); cdecl; external libmgl; +/// Put further plotting in a region of whole frame. +procedure mgl_inplot(gr: HMGL;x1: double;x2: double;y1: double;y2: double); cdecl; external libmgl; +/// Put further plotting in a region of current subplot/inplot. +procedure mgl_relplot(gr: HMGL;x1: double;x2: double;y1: double;y2: double); cdecl; external libmgl; +/// Put further plotting in column cell of previous subplot/inplot. +procedure mgl_columnplot(gr: HMGL;num: integer;ind: integer;d: double); cdecl; external libmgl; +/// Put further plotting in matrix cell of previous subplot/inplot. +procedure mgl_gridplot(gr: HMGL;nx: integer;ny: integer;m: integer;d: double); cdecl; external libmgl; +/// Put further plotting in cell of stick rotated on angles tet, phi. +procedure mgl_stickplot(gr: HMGL;num: integer;ind: integer;tet: double;phi: double); cdecl; external libmgl; +/// Add title for current subplot/inplot. +procedure mgl_title(gr: HMGL;const title: PChar;const stl: PChar;size: double); cdecl; external libmgl; +procedure mgl_titlew(gr: HMGL;const title: PWideChar;const stl: PChar;size: double); cdecl; external libmgl; +/// Set factor of plot size +procedure mgl_set_plotfactor(gr: HMGL;val: double); cdecl; external libmgl; +/// Set aspect ratio for further plotting. +procedure mgl_aspect(gr: HMGL;Ax: double;Ay: double;Az: double); cdecl; external libmgl; +/// Rotate a further plotting. +procedure mgl_rotate(gr: HMGL;TetX: double;TetZ: double;TetY: double); cdecl; external libmgl; +/// Rotate a further plotting around vector {x,y,z}. +procedure mgl_rotate_vector(gr: HMGL;Tet: double;x: double;y: double;z: double); cdecl; external libmgl; +/// Set perspective (in range [0,1)) for plot. Set to zero for switching off. +procedure mgl_perspective(gr: HMGL;val: double); cdecl; external libmgl; +/// Set angle of view independently from Rotate(). +procedure mgl_view(gr: HMGL;TetX: double;TetZ: double;TetY: double); cdecl; external libmgl; +/// Zoom in/out a part of picture (use mgl_zoom(0, 0, 1, 1) for restore default) +procedure mgl_zoom(gr: HMGL;x1: double;y1: double;x2: double;y2: double); cdecl; external libmgl; +//----------------------------------------------------------------------------- +/// Callback function for mouse click +/// Set delay for animation in seconds +procedure mgl_wnd_set_delay(gr: HMGL;dt: double); cdecl; external libmgl; +/// Get delay for animation in seconds +function mgl_wnd_get_delay(gr: HMGL): double; cdecl; external libmgl; +/// Set window properties +procedure mgl_setup_window(gr: HMGL;clf_upd: integer;showpos: integer); cdecl; external libmgl; +/// Switch on/off transparency (do not overwrite user settings) +procedure mgl_wnd_toggle_alpha(gr: HMGL); cdecl; external libmgl; +/// Switch on/off lighting (do not overwrite user settings) +procedure mgl_wnd_toggle_light(gr: HMGL); cdecl; external libmgl; +/// Switch on/off zooming by mouse +procedure mgl_wnd_toggle_zoom(gr: HMGL); cdecl; external libmgl; +/// Switch on/off rotation by mouse +procedure mgl_wnd_toggle_rotate(gr: HMGL); cdecl; external libmgl; +/// Switch off all zooming and rotation +procedure mgl_wnd_toggle_no(gr: HMGL); cdecl; external libmgl; +/// Update picture by calling user drawing function +procedure mgl_wnd_update(gr: HMGL); cdecl; external libmgl; +/// Reload user data and update picture +procedure mgl_wnd_reload(gr: HMGL); cdecl; external libmgl; +/// Adjust size of bitmap to window size +procedure mgl_wnd_adjust(gr: HMGL); cdecl; external libmgl; +/// Show next frame (if one) +procedure mgl_wnd_next_frame(gr: HMGL); cdecl; external libmgl; +/// Show previous frame (if one) +procedure mgl_wnd_prev_frame(gr: HMGL); cdecl; external libmgl; +/// Run slideshow (animation) of frames +procedure mgl_wnd_animation(gr: HMGL); cdecl; external libmgl; +/// Get last mouse position +procedure mgl_get_last_mouse_pos(gr: HMGL;x: Pmreal;y: Pmreal;z: Pmreal); cdecl; external libmgl; +//----------------------------------------------------------------------------- +/// Create HMPR object for parsing MGL scripts +function mgl_create_parser(): HMPR; cdecl; external libmgl; +/// Change counter of HMPR uses (for advanced users only). Non-zero counter prevent automatic object removing. +function mgl_use_parser(p: HMPR;inc: integer): integer; cdecl; external libmgl; +/// Delete HMPR object +procedure mgl_delete_parser(p: HMPR); cdecl; external libmgl; +/// Set value for parameter $N +procedure mgl_parser_add_param(p: HMPR;id: integer;const str: PChar); cdecl; external libmgl; +procedure mgl_parser_add_paramw(p: HMPR;id: integer;const str: PWideChar); cdecl; external libmgl; +/// Find variable with given name or add a new one +/// NOTE !!! You must not delete obtained data arrays !!! +function mgl_parser_add_var(p: HMPR;const name: PChar): HMDT; cdecl; external libmgl; +function mgl_parser_add_varw(p: HMPR;const name: PWideChar): HMDT; cdecl; external libmgl; +/// Find variable with given name or return NULL if no one +/// NOTE !!! You must not delete obtained data arrays !!! +function mgl_parser_find_var(p: HMPR;const name: PChar): HMDT; cdecl; external libmgl; +function mgl_parser_find_varw(p: HMPR;const name: PWideChar): HMDT; cdecl; external libmgl; +/// Delete variable with name +procedure mgl_parser_del_var(p: HMPR;const name: PChar); cdecl; external libmgl; +procedure mgl_parser_del_varw(p: HMPR;const name: PWideChar); cdecl; external libmgl; +/// Delete all data variables +procedure mgl_parser_del_all(p: HMPR); cdecl; external libmgl; +/// Parse and draw single line of the MGL script +function mgl_parse_line(gr: HMGL;p: HMPR;const str: PChar;pos: integer): integer; cdecl; external libmgl; +function mgl_parse_linew(gr: HMGL;p: HMPR;const str: PWideChar;pos: integer): integer; cdecl; external libmgl; +/// Execute and draw script from the file +/// Execute MGL script text with '\n' separated lines +procedure mgl_parse_text(gr: HMGL;p: HMPR;const str: PChar); cdecl; external libmgl; +procedure mgl_parse_textw(gr: HMGL;p: HMPR;const str: PWideChar); cdecl; external libmgl; +/// Restore once flag +procedure mgl_parser_restore_once(p: HMPR); cdecl; external libmgl; +/// Allow changing size of the picture +procedure mgl_parser_allow_setsize(p: HMPR;a: integer); cdecl; external libmgl; +/// Allow reading/saving files +procedure mgl_parser_allow_file_io(p: HMPR;a: integer); cdecl; external libmgl; +/// Set flag to stop script parsing +procedure mgl_parser_stop(p: HMPR); cdecl; external libmgl; +/// Return type of command: 0 - not found, 1 - data plot, 2 - other plot, +/// 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program +/// 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot +/// 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform +function mgl_parser_cmd_type(pr: HMPR;const name: PChar): integer; cdecl; external libmgl; +/// Return description of MGL command +function mgl_parser_cmd_desc(pr: HMPR;const name: PChar): PChar; cdecl; external libmgl; +/// Return string of command format (command name and its argument[s]) +function mgl_parser_cmd_frmt(pr: HMPR;const name: PChar): PChar; cdecl; external libmgl; +/// Get name of command with nmber n +function mgl_parser_cmd_name(pr: HMPR;id: integer): PChar; cdecl; external libmgl; +/// Get number of defined commands +function mgl_parser_cmd_num(pr: HMPR): integer; cdecl; external libmgl; +/// Return result of formula evaluation +function mgl_parser_calc(pr: HMPR;const formula: PChar): HMDT; cdecl; external libmgl; +function mgl_parser_calcw(pr: HMPR;const formula: PWideChar): HMDT; cdecl; external libmgl; +//----------------------------------------------------------------------------- +/// Create HMEX object for expression evaluating +function mgl_create_expr(const expr: PChar): HMEX; cdecl; external libmgl; +function mgl_create_cexpr(const expr: PChar): HAEX; cdecl; external libmgl; +/// Delete HMEX object +procedure mgl_delete_expr(ex: HMEX); cdecl; external libmgl; +procedure mgl_delete_cexpr(ex: HAEX); cdecl; external libmgl; +/// Return value of expression for given x,y,z variables +function mgl_expr_eval(ex: HMEX;x: double;y: double;z: double): double; cdecl; external libmgl; +function mgl_cexpr_eval(ex: HAEX;x: dual;y: dual;z: dual): dual; cdecl; external libmgl; +/// Return value of expression for given variables +function mgl_expr_eval_v(ex: HMEX;vars: Pmreal): double; cdecl; external libmgl; +function mgl_cexpr_eval_v(ex: HAEX;vars: Pdual): dual; cdecl; external libmgl; +/// Return value of expression differentiation over variable dir for given x,y,z variables +function mgl_expr_diff(ex: HMEX;dir: char;x: double;y: double;z: double): double; cdecl; external libmgl; +/// Return value of expression differentiation over variable dir for given variables +function mgl_expr_diff_v(ex: HMEX;dir: char;vars: Pmreal): double; cdecl; external libmgl; +//----------------------------------------------------------------------------- +{== ../include/mgl2/addon.h ==} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +/// Get integer power of x +function mgl_ipowc(x: dual;n: integer): dual; cdecl; external libmgl; +/// Get exp(i*a) +function mgl_expi(a: dual): dual; cdecl; external libmgl; +overload; +/// Get exp(i*a) +function mgl_expi(a: double): dual; cdecl; external libmgl; +overload; +/// Explicit scheme for 1 step of axial diffraction +function mgl_difr_axial(a: Pdual;n: integer;q: dual;Border: integer;b: Pdual;d: Pdual;kk: integer;di: double): integer; cdecl; external libmgl; +/// Explicit scheme for 1 step of plane diffraction +function mgl_difr_grid(a: Pdual;n: integer;q: dual;Border: integer;b: Pdual;d: Pdual;kk: integer): integer; cdecl; external libmgl; +//----------------------------------------------------------------------------- +/// Get random number with Gaussian distribution +function mgl_gauss_rnd(): double; cdecl; external libmgl; +/// Fill frequencies for FFT +procedure mgl_fft_freq(freq: Pdouble;nn: integer); cdecl; external libmgl; +/// Remove double spaces from the string +procedure mgl_strcls(str: PChar); cdecl; external libmgl; +/// Get position of substring or return -1 if not found +function mgl_strpos(const str: PChar;fnd: PChar): integer; cdecl; external libmgl; +/// Get position of symbol or return -1 if not found +function mgl_chrpos(const str: PChar;fnd: char): integer; cdecl; external libmgl; +/// Get uncommented string from file (NOTE: it is not thread safe!!!) +/// Get parameters from uncommented strings of file (NOTE: it is not thread safe!!!) +/// Check if symbol denote true +function mgl_istrue(ch: char): integer; cdecl; external libmgl; +/// Print test message +/// Print info message +/// Locate next data block (block started by -----) + + +{$IFDEF MSWINDOWS} +//*****************************************************************************/ +// Delphi - specific +//*****************************************************************************/ +procedure mgl_begin(); +procedure mgl_end(); + +procedure mgl_draw_on_canvas(gr: HMGL; width, height: integer; canvas: TCanvas; switchXY: boolean = false); + +implementation + +var _FPUCW: word; + +procedure mgl_begin(); + begin + _FPUCW := Get8087CW(); // backup current FPU CW + Set8087CW(_FPUCW or $3F); // masking all FPU exceptions + end; + +procedure mgl_end(); + begin + Set8087CW(_FPUCW); // restore old FPU CW + end; + +procedure mgl_draw_on_canvas(gr: HMGL; width, height: integer; canvas: TCanvas; switchXY: boolean = false); + var i, j: integer; + bytes: PByte; + col: TColor; + begin + bytes := mgl_get_rgb(gr); + + if (not switchXY) then + for j := 0 to height - 1 do + for i := 0 to width - 1 do + begin + col := 0; + col := col or (bytes^); + inc(bytes); + col := col or (bytes^) shl 8; + inc(bytes); + col := col or (bytes^) shl 16; + inc(bytes); + canvas.Pixels[i, j] := col; + end + else + for j := height - 1 downto 0 do + for i := 0 to width - 1 do + begin + col := 0; + col := col or (bytes^); + inc(bytes); + col := col or (bytes^) shl 8; + inc(bytes); + col := col or (bytes^) shl 16; + inc(bytes); + canvas.Pixels[j, i] := col; + end; + end; + +{$ENDIF} +end. + diff --git a/include/mgl2/mglplot.fs b/include/mgl2/mglplot.fs new file mode 100644 index 0000000..76de339 --- /dev/null +++ b/include/mgl2/mglplot.fs @@ -0,0 +1,562 @@ +\ Mathgl library wrapper Thu Feb 21 12:33:02 MST 2008 +\ Copyright (C) 2008, Sergey Plis +\ +\ This program is free software; you can redistribute it and/or modify +\ it under the terms of the GNU General Public License as published by +\ the Free Software Foundation; either version 2 of the License, or +\ (at your option) any later version. +\ +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\needs gsl include gsl.fs +\needs mathgl include mathgl.fs +\needs vectors include vectors.fs +\needs $! include string.fs + +Module mglplot + +also minos also vectors also gsl also mathgl also float + +\ ------------------------------------------------------------------------ +\ structures +\ ------------------------------------------------------------------------ +struct{ + cell transp? + cell transp_type + cell alpha? + cell light + cell box + cell grid + double ambient + cell axis? + cell axis_str + cell rotation[ + cell aspect[ + cell colorbar + double linewidth + double fontsize + cell labelx$ + cell labely$ + cell labelz$ + cell textrotate +} mgl-params + +struct{ + cell next \ next plot in the list of current figure + cell prev + cell xrange \ + cell yrange \ + cell zrange \ + cell hmdtlist \ vector of all data objects used in the plot + cell params \ vector of parameters to the plotting function + cell ops \ vector of xt's of operations to place params + \ list on the stack so the plotting function can + \ be executed + cell plotfunc \ the plotting function +} a_plot + +struct{ + cell next \ next figure in the figure structure + cell # + cell active? \ True/False + cell figure \ plot object +} a_figure + +: dispose-hmdtlist ( v( -- ) + dup )size 0 do + dup i )@ + mgl_delete_data + loop drop ; + +: dispose-a-plot ( *a_plot -- ) + dup a_plot hmdtlist @ dispose-hmdtlist + dup a_plot params @ )free + dup a_plot ops @ )free + dup a_plot xrange @ ]free + dup a_plot yrange @ ]free + dup a_plot zrange @ ]free + free throw ; + +: dispose-all-plots ( *a_plot -- ) + dup begin while + dup a_plot next @ + swap dispose-a-plot + dup + repeat drop ; + +\ simple aux words +| : ]@s ( x[ -- f: x[0] .. x[n] ) + dup ]size 0 do dup i ]@ loop drop ; +| : ]!s ( x[ f: x[0] .. x[n] -- ) + dup ]size 0 do dup i ]! loop drop ; +| create axis-param 0 c, 0 c, 0 c, 0 c, 0 c, +| create mglstrbuff $FF allot +: default-rotation ( -- r[ ) 3 :] dup 0e 0e 0e ]!s ; +: clear-axis-param + axis-param dup 'x swap c! 1+ dup 'y swap c! 1+ 'z swap c! ; + +: NAN ( -- f: NAN) $7FC00000 sp@ sf@ drop ; +\ ------------------------------------------------------------------------ +\ GUI +\ ------------------------------------------------------------------------ + +component class mathplot + private: + method fill-pixmap + method mgl_settings_reset + cell var mhold + public: + early open + early dialog + early open-app + + method generate-plot + method addplot + method clear-pixmap + method #plots + method clf + method mgl-rotation! + method mgl-colorbar + + method mgl-hold + method mgl-holdoff + method mgl-holdon + method hold@ + method hold! + method mgl-grid + method fontsize + + method mgl-xlabel + method mgl-ylabel + method mgl-zlabel + + canvas ptr mCanvas + ( [varstart] ) + \ memory-pixmap ptr pxmap \ the pixmap on the canvas + cell var pxmap + cell var graph \ the graph to display + cell var plotlist \ list of plots to display + cell var parameters \ parameter structure + ( [varend] ) + how: + : params DF[ 0 ]DF s" figure" ; + : hold@ mhold @ ; + : hold! mhold ! ; + : mgl-hold mhold @ not mhold ! ; + : mgl-holdoff mhold off ; + : mgl-holdon mhold on ; + + : open self DF[ 0 ]DF s" bigforth Plot" open-component ; + : dialog new DF[ 0 ]DF s" bigforth Plot" open-dialog ; + : open-app new DF[ 0 ]DF s" bigforth Plot" open-application ; + : clear-pixmap pxmap @ if pxmap @ >o dispose o> 0 pxmap ! then ; + : #plots ( -- ) + 0 + plotlist @ begin dup while + swap 1+ swap + a_plot next @ + repeat + drop ; + + : assign + &600 &400 mgl_create_graph_zb graph ! + sizeof mgl-params allocate throw parameters ! + parameters @ sizeof mgl-params erase + mgl_settings_reset + + \ 0 0 + parameters @ mgl-params labelx$ dup @ if $off else drop then + \ 0 0 + parameters @ mgl-params labely$ dup @ if $off else drop then + \ 0 0 + parameters @ mgl-params labelz$ dup @ if $off else drop then + + 0 pxmap ! + 0 plotlist ! + mhold off ; + + : fontsize ( f: size -- ) parameters @ mgl-params fontsize sf! ; + + : mgl-set-params ( -- ) + graph @ + dup parameters @ mgl-params rotation[ @ ]@s mgl_rotate + dup parameters @ mgl-params ambient sf@ mgl_set_ambbr + dup parameters @ mgl-params fontsize sf@ mgl_set_font_size + dup parameters @ mgl-params linewidth sf@ mgl_set_base_line_width + dup parameters @ mgl-params aspect[ @ ]@s mgl_aspect + dup parameters @ mgl-params transp? @ mgl_set_transp + dup parameters @ mgl-params transp_type @ mgl_set_transp_type + dup parameters @ mgl-params alpha? @ mgl_set_alpha + dup parameters @ mgl-params light @ mgl_set_light + dup parameters @ mgl-params textrotate @ mgl_set_rotated_text + dup parameters @ mgl-params box @ mgl_box + parameters @ mgl-params grid @ if + dup 0" xyz" 0 mgl_axis_grid + then + drop ; + : mgl-post-params ( -- ) + graph @ 1 mgl_set_rotated_text + parameters @ mgl-params labelx$ @ if + parameters @ mgl-params labelx$ $@ mglstrbuff 0place + parameters @ mgl-params fontsize sf@ 0e0 + graph @ 'x mglstrbuff 0 mgl_label_ext + then + parameters @ mgl-params labely$ @ if + parameters @ mgl-params labely$ $@ mglstrbuff 0place + parameters @ mgl-params fontsize sf@ 0e0 + graph @ 'y mglstrbuff 0 mgl_label_ext + then + parameters @ mgl-params labelz$ @ drop 0 if + parameters @ mgl-params labelz$ $@ mglstrbuff 0place + parameters @ mgl-params fontsize sf@ 0e0 + graph @ 'z mglstrbuff 0 mgl_label_ext + then + parameters @ mgl-params colorbar @ drop 0 if + dup 0 0 mgl_colorbar + then ; + : mgl_settings_reset + 1 parameters @ mgl-params transp? ! + 1 parameters @ mgl-params transp_type ! + 0 parameters @ mgl-params alpha? ! + 0 parameters @ mgl-params box ! + 0 parameters @ mgl-params colorbar ! + 0 parameters @ mgl-params light ! + 1 parameters @ mgl-params axis? ! + axis-param parameters @ mgl-params axis_str ! + clear-axis-param + parameters @ mgl-params labelx$ dup @ if $off else drop then + parameters @ mgl-params labely$ dup @ if $off else drop then + parameters @ mgl-params labelz$ dup @ if $off else drop then + \ parameters @ mgl-params textrotate off + !0.9 parameters @ mgl-params ambient sf! + !2.5 parameters @ mgl-params fontsize sf! + !1.2 parameters @ mgl-params linewidth sf! + parameters @ mgl-params rotation[ @ dup if ]free else drop then + default-rotation parameters @ mgl-params rotation[ ! + parameters @ mgl-params aspect[ @ dup if ]free else drop then + 3 :] parameters @ mgl-params aspect[ ! + ; + + : mgl_settings_free + parameters @ mgl-params labelx$ dup @ if $off else drop then + parameters @ mgl-params labely$ dup @ if $off else drop then + parameters @ mgl-params labelz$ dup @ if $off else drop then + parameters @ mgl-params rotation[ @ dup if ]free else drop then + parameters @ mgl-params aspect[ @ dup if ]free else drop then + ; + + : addplot ( *a_plot -- ) + mhold @ if + >r plotlist @ r@ a_plot next ! r> + plotlist @ if + dup plotlist @ a_plot prev ! + then + else + plotlist @ dispose-all-plots + then + plotlist ! + generate-plot + mcanvas draw ; + : display_a_plot ( *a_plot -- ) + >r graph @ + r@ a_plot ops @ + r@ a_plot params @ + dup )size 0 do + i -rot + 2>r + 2r@ rot dup >r *) swap r> )@ F execute + 2r> + loop 2drop + r> a_plot plotfunc @ + F execute ; + : xmin ( -- f: xmin ) + 1e20 plotlist @ begin dup while + dup a_plot xrange @ ]min fmin + a_plot next @ + repeat + drop ; + : xmax ( -- f: xmax ) + -1e20 plotlist @ begin dup while + dup a_plot xrange @ ]max fmax + a_plot next @ + repeat + drop ; + : ymin ( -- f: ymin ) + 1e20 plotlist @ begin dup while + dup a_plot yrange @ ]min fmin + a_plot next @ + repeat + drop ; + : ymax ( -- f: ymax ) + -1e20 plotlist @ begin dup while + dup a_plot yrange @ ]max fmax + a_plot next @ + repeat + drop ; + + : zmin ( -- f: zmin ) + 1e20 plotlist @ begin dup while + dup a_plot zrange @ ]min fmin + a_plot next @ + repeat + drop ; + : zmax ( -- f: ymax ) + -1e20 plotlist @ begin dup while + dup a_plot zrange @ ]max fmax + a_plot next @ + repeat + drop ; + + : display_plots ( -- ) + 0 plotlist @ begin dup while + nip dup a_plot next @ + repeat + drop + begin dup while + dup display_a_plot + a_plot prev @ + repeat drop ; + + : create-figure ( -- ) + graph @ mgl_identity + graph @ mgl_clf + graph @ mCanvas with w @ h @ endwith mgl_set_size + +\ parameters @ mgl-params rotation[ @ ]null? if +\ graph @ +\ [ 1e 3e fsqrt f/ 1e fswap f- 2e f/ 0.7e f* ] fliteral +\ fdup +\ fdup fdup 1e fswap f- fswap 1e fswap f- +\ mgl_set_zoom +\ else + graph @ 0e 0e 0e 0e mgl_set_zoom +\ parameters @ mgl-params fontsize sf@ +\ 1.2e f* parameters @ mgl-params fontsize sf! +\ then + graph @ xmin ymin zmin xmax ymax zmax mgl_set_axis_3d +\ graph @ xmin ymin zmin mgl_set_origin + graph @ NAN NAN NAN mgl_set_origin + mgl-set-params + mgl-post-params + display_plots + ; + : fill-pixmap + clear-pixmap + graph @ mgl_get_rgb + mCanvas with w @ h @ endwith * 4 * dup allocate throw + dup >r + swap 4 / 3 * move r@ + mCanvas with w @ h @ endwith memory-pixmap new pxmap ! + r> free throw ; + : generate-plot ( -- ) + create-figure + fill-pixmap ; + + : freeplots plotlist @ dispose-all-plots 0 plotlist ! ; + + : clf freeplots clear-pixmap draw ; + + : mgl-rotation! ( f: x y z ) + fswap frot parameters @ mgl-params rotation[ @ ]!s + generate-plot + mcanvas draw ; + : mgl-rotation@ ( -- f: x y z ) + parameters @ mgl-params rotation[ @ ]@s ; + : mgl-colorbar ( -- ) + parameters @ mgl-params colorbar @ + not + parameters @ mgl-params colorbar ! + generate-plot mcanvas draw ; + : mgl-grid parameters @ mgl-params grid dup @ not swap ! + generate-plot mcanvas draw ; + : mgl-xlabel ( addr u -- ) + parameters @ mgl-params labelx$ dup @ + if dup $off $! else $! then + generate-plot mcanvas draw ; + : mgl-ylabel ( addr u -- ) + parameters @ mgl-params labely$ dup @ + if dup $off $! else $! then + generate-plot mcanvas draw ; + : mgl-zlabel ( addr u -- ) + parameters @ mgl-params labelz$ dup @ + if dup $off $! else $! then + generate-plot mcanvas draw ; + + : dispose + clear-pixmap + plotlist @ dispose-all-plots + graph @ mgl_delete_graph + mgl_settings_free + parameters @ sizeof mgl-params erase + parameters @ free throw + super dispose ; + : widget + CV[ + outer with pxmap @ endwith 0<> if + outer with pxmap @ endwith icon + then + ]CV + ^^ CK[ 2drop 2drop ]CK + $258 $1 *hfil $190 $1 *vfil canvas new ^^bind mCanvas + $10 $1 *hfill *hglue new + ^^ S[ s" not done" mCanvas text ]S X" Save " button new + ^^ S[ close ]S X" Close " button new + &3 habox new vfixbox panel + &2 vabox new ; +class; + +sizeof a_figure allocate throw constant current-figure + +current-figure sizeof a_figure erase + +actor class clear-pointer + how: + : dispose + current-figure a_figure active? off + current-figure sizeof a_figure erase + super dispose ; +class; + +: init-plot + current-figure a_figure active? @ not if + screen self mathplot new + current-figure a_figure figure ! + current-figure a_figure active? on + clear-pointer new + current-figure a_figure figure @ + mathplot with >callback open endwith + then ; + +: s>range[] ( fmin fmax -- :] ) 2 :] dup 1 ]! dup 0 ]! ; + +: []plot ( x[ str0 xt -- *a_plot ) + >r >r dup >r + mgl_create_data dup rot mgl_data_set_vector + sizeof a_plot allocate throw + dup r@ dup ]min ]max s>range[] swap a_plot yrange ! + dup r> ]size 0e s>f s>range[] swap a_plot xrange ! + dup 0e 0e s>range[] swap a_plot zrange ! + dup 0 swap a_plot next ! + dup 0 swap a_plot prev ! + over 1 ivector* over a_plot hmdtlist ! + over r> 2 ivector* over a_plot params ! + ['] @ ['] @ 2 ivector* over a_plot ops ! + nip r> over a_plot plotfunc ! ; +: addplot ( *a_plot -- ) + init-plot + current-figure a_figure figure @ + mathplot with addplot endwith ; +: ]plot ( *gsl_vector 0"" -- ) ['] mgl_plot []plot addplot ; +: ]stem ( *gsl_vector 0"" -- ) ['] mgl_stem []plot addplot ; +: ]bars ( *gsl_vector 0"" -- ) ['] mgl_bars []plot addplot ; +: ]step ( *gsl_vector 0"" -- ) ['] mgl_step []plot addplot ; +: ]area ( *gsl_vector 0"" -- ) ['] mgl_area []plot addplot ; + +: [[]]plot ( x[[ str0 xt -- *a_plot ) + >r >r dup >r + mgl_create_data dup rot mgl_data_set_matrix + sizeof a_plot allocate throw + dup r@ dup ]]min ]]max s>range[] swap a_plot zrange ! + dup r@ ]]size1 0e s>f s>range[] swap a_plot xrange ! + dup r> ]]size2 0e s>f s>range[] swap a_plot yrange ! + dup 0 swap a_plot next ! + dup 0 swap a_plot prev ! + over 1 ivector* over a_plot hmdtlist ! + over r> 2 ivector* over a_plot params ! + ['] @ ['] @ 2 ivector* over a_plot ops ! + nip r> over a_plot plotfunc ! ; +: ]]surf ( *gsl_matrix 0"" -- ) ['] mgl_surf [[]]plot addplot ; +: ]]tile ( *gsl_matrix 0"" -- ) ['] mgl_tile [[]]plot addplot ; +: ]]belt ( *gsl_matrix 0"" -- ) ['] mgl_belt [[]]plot addplot ; +: ]]fall ( *gsl_matrix 0"" -- ) ['] mgl_fall [[]]plot addplot ; +: ]]mesh ( *gsl_matrix 0"" -- ) ['] mgl_mesh [[]]plot addplot ; +: ]]msurf ( *gsl_matrix 0"" -- ) + init-plot + 2dup ]]surf + current-figure a_figure figure @ + mathplot with hold@ mgl-holdon endwith + >r + ]]mesh + r> + current-figure a_figure figure @ + mathplot with hold! endwith ; + +: [[]]plotf ( f:v x[[ str0 xt -- *a_plot ) + >r >r dup >r + mgl_create_data dup rot mgl_data_set_matrix + sizeof a_plot allocate throw + dup r@ dup ]]min ]]max s>range[] swap a_plot zrange ! + dup r@ ]]size1 0e s>f s>range[] swap a_plot xrange ! + dup r> ]]size2 0e s>f s>range[] swap a_plot yrange ! + dup 0 swap a_plot next ! + dup 0 swap a_plot prev ! + over 1 ivector* over a_plot hmdtlist ! + over r> f>fs 3 ivector* over a_plot params ! + ['] @ ['] @ ['] sf@ 3 ivector* over a_plot ops ! + nip r> over a_plot plotfunc ! ; +: ]]boxs ( f:v *gsl_matrix 0"" -- ) ['] mgl_boxs [[]]plotf addplot ; + +: clf current-figure a_figure active? @ if + current-figure a_figure figure @ >o mathplot clf o> + then ; + +: fontsize! ( f:size -- ) current-figure a_figure active? @ if + current-figure a_figure figure @ >o mathplot fontsize o> + then ; + +: rotation ( F: x y z -- ) + current-figure a_figure active? @ if + current-figure a_figure figure @ >o mathplot mgl-rotation! o> + else + fdrop fdrop fdrop + then ; +: colorbar current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-colorbar o> + then ; + + +: mglhold current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-hold o> + then ; + +: mglholdon current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-holdon o> + then ; +: mglholdoff current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-holdoff o> + then ; + +: mglgrid current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-grid o> + then ; + +: xlabel ( addr u -- ) current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-xlabel o> + then ; +: ylabel ( addr u -- ) current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-ylabel o> + then ; +: zlabel ( addr u -- ) current-figure a_figure active? @ if + current-figure a_figure figure @ + >o mathplot mgl-zlabel o> + then ; + + +clear +previous previous previous previous previous +Module; + +\\\ +also mglplot also minos also gsl +100 fvector x[ x[ ]randomize +x[ 0 ]plot diff --git a/include/mgl2/mpi.h b/include/mgl2/mpi.h new file mode 100644 index 0000000..11819ca --- /dev/null +++ b/include/mgl2/mpi.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * mgl.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_MPI_H_ +#define _MGL_MPI_H_ + +#include "mgl2/mgl_cf.h" + +#ifdef __cplusplus +extern "C" { +#endif +/// Send graphical information to node id using MPI +void MGL_EXPORT mgl_mpi_send(HMGL gr, int id); +void MGL_EXPORT mgl_mpi_send_(uintptr_t *gr, int *id); +/// Receive graphical information from node id using MPI +void MGL_EXPORT mgl_mpi_recv(HMGL gr, int id); +void MGL_EXPORT mgl_mpi_recv_(uintptr_t *gr, int *id); +#ifdef __cplusplus +} + +#include "mgl2/mgl.h" +//----------------------------------------------------------------------------- +/// Wrapper class for all graphics +class MGL_EXPORT mglGraphMPI:public mglGraph +{ +public: + inline mglGraphMPI(int kind=0, int width=600, int height=400):mglGraph(kind,width,height){} + inline mglGraphMPI(const mglGraph &graph):mglGraph(graph){} + inline mglGraphMPI(HMGL graph):mglGraph(graph){} + virtual ~mglGraphMPI(){} + + /// Send graphical information to node id using MPI + inline void MPI_Send(int id) { mgl_mpi_send(gr,id); } + /// Receive graphical information from node id using MPI + inline void MPI_Recv(int id) { mgl_mpi_recv(gr,id); } + +}; +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/opengl.h b/include/mgl2/opengl.h new file mode 100644 index 0000000..37a276e --- /dev/null +++ b/include/mgl2/opengl.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * opengl.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef MGL_CANVAS_GL_H +#define MGL_CANVAS_GL_H +//----------------------------------------------------------------------------- +#include "mgl2/canvas.h" +//----------------------------------------------------------------------------- +class MGL_EXPORT mglCanvasGL : public mglCanvas +{ +public: + mglCanvasGL(); + ~mglCanvasGL(); + + void SetQuality(int =0) { Quality=2; } + void Finish(); + void SetSize(int ,int ) {} + void View(mreal tetX,mreal tetY,mreal tetZ); + void Zoom(mreal x1, mreal y1, mreal x2, mreal y2); +/* int NewFrame(); + void EndFrame(); + void DelFrame(long ){}*/ + + bool Alpha(bool enable); + void Fog(mreal d, mreal dz=0.25); + bool Light(bool enable); + void Light(int n, bool enable); + void AddLight(int n,mglPoint r,mglPoint d, char c='w', mreal bright=0.5, mreal ap=0); + void Clf(mglColor Back=NC); + +protected: + // provide fastest variant for usual points (not glyphs or marks) + void line_draw(long n1, long n2); + void trig_draw(long n1, long n2, long n3); + void quad_draw(long n1, long n2, long n3, long n4); + // variant for glyphs or marks + void line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *d); + void trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d); + void quad_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d); + void pnt_draw(const mglPnt &p, const mglDrawReg *d); + void mark_draw(const mglPnt &q, char type, mreal size, mglDrawReg *d); + + unsigned char **GetRGBLines(long &w, long &h, unsigned char *&f, bool solid=true); + void LightScale(const mglMatrix *M); + void set_pen(unsigned style,mreal width); + + void gl_clf(mglColor Back=WC); +}; +//----------------------------------------------------------------------------- +#endif + diff --git a/include/mgl2/other.h b/include/mgl2/other.h new file mode 100644 index 0000000..7b7a8d5 --- /dev/null +++ b/include/mgl2/other.h @@ -0,0 +1,129 @@ +/*************************************************************************** + * other.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_OTHER_H_ +#define _MGL_OTHER_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Draw triangle mesh for points in arrays {x,y,z} with specified color c. +void MGL_EXPORT mgl_triplot_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_triplot_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw triangle mesh for points in arrays {x,y,z} with color proportional to z. +void MGL_EXPORT mgl_triplot_xyz(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_triplot_xyz_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw triangle mesh for points in arrays {x,y} +void MGL_EXPORT mgl_triplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt); +void MGL_EXPORT mgl_triplot_xy_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, const char *sch, const char *opt,int,int); + +/// Draw quad mesh for points in arrays {x,y,z} with specified color c. +void MGL_EXPORT mgl_quadplot_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_quadplot_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw quad mesh for points in arrays {x,y,z} with color proportional to z. +void MGL_EXPORT mgl_quadplot_xyz(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_quadplot_xyz_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw quad mesh for points in arrays {x,y}. +void MGL_EXPORT mgl_quadplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt); +void MGL_EXPORT mgl_quadplot_xy_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, const char *sch, const char *opt,int,int); + +/// Draw manual contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. +void MGL_EXPORT mgl_tricont_xyzcv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_tricont_xyzcv_(uintptr_t *gr, uintptr_t *v, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw manual contour lines for triangle mesh for points in arrays {x,y,z}. +void MGL_EXPORT mgl_tricont_xycv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_tricont_xycv_(uintptr_t *gr, uintptr_t *v, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. +void MGL_EXPORT mgl_tricont_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_tricont_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int, int); +/// Draw contour lines for triangle mesh for points in arrays {x,y,z}. +void MGL_EXPORT mgl_tricont_xyc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_tricont_xyc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int, int); + +/// Draw dots in points {x,y,z}. +void MGL_EXPORT mgl_dots(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_dots_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw semitransparent dots in points {x,y,z} with specified alpha a. +void MGL_EXPORT mgl_dots_a(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_dots_a_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. +void MGL_EXPORT mgl_dots_ca(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, HCDT a, const char *sch, const char *opt); +void MGL_EXPORT mgl_dots_ca_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, uintptr_t *a, const char *sch, const char *opt,int,int); + +/// Draw surface reconstructed for points in arrays {x,y,z}. +void MGL_EXPORT mgl_crust(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_crust_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw density plot for data at x = sVal +void MGL_EXPORT mgl_dens_x(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_dens_x_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw density plot for data at y = sVal +void MGL_EXPORT mgl_dens_y(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_dens_y_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw density plot for data at z = sVal +void MGL_EXPORT mgl_dens_z(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_dens_z_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); + +/// Draw contour lines for data at x = sVal +void MGL_EXPORT mgl_cont_x(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_x_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw contour lines for data at y = sVal +void MGL_EXPORT mgl_cont_y(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_y_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw contour lines for data at z = sVal +void MGL_EXPORT mgl_cont_z(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_z_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); + +/// Draw manual contour lines for data at x = sVal +void MGL_EXPORT mgl_cont_x_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_x_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw manual contour lines for data at y = sVal +void MGL_EXPORT mgl_cont_y_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_y_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw manual contour lines for data at z = sVal +void MGL_EXPORT mgl_cont_z_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_cont_z_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); + +/// Draw solid contours for data at x = sVal +void MGL_EXPORT mgl_contf_x(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_x_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw solid contours for data at y = sVal +void MGL_EXPORT mgl_contf_y(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_y_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw solid contours for data at z = sVal +void MGL_EXPORT mgl_contf_z(HMGL graph, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_z_(uintptr_t *graph, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); + +/// Draw manual solid contours for data at x = sVal +void MGL_EXPORT mgl_contf_x_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_x_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw manual solid contours for data at y = sVal +void MGL_EXPORT mgl_contf_y_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_y_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); +/// Draw manual solid contours for data at z = sVal +void MGL_EXPORT mgl_contf_z_val(HMGL graph, HCDT v, HCDT a, const char *stl, double sVal, const char *opt); +void MGL_EXPORT mgl_contf_z_val_(uintptr_t *graph, uintptr_t *v, uintptr_t *a, const char *stl, mreal *sVal, const char *opt,int,int); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/parser.h b/include/mgl2/parser.h new file mode 100644 index 0000000..6110b98 --- /dev/null +++ b/include/mgl2/parser.h @@ -0,0 +1,198 @@ +/*************************************************************************** + * parser.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_PARSER_H_ +#define _MGL_PARSER_H_ + +#ifdef __cplusplus +#include "mgl2/mgl.h" +#include +//----------------------------------------------------------------------------- +/// Structure for the command argument. +struct mglArg +{ + int type; ///< Type of argument {0-data,1-string,2-number} + mglData *d; ///< Pointer to data (used if type==0) + std::wstring w; ///< String with parameters + std::string s; ///< String with parameters + mreal v; ///< Numerical value (used if type==2) + mglArg() { type=-1; d=0; v=0; } +}; +//----------------------------------------------------------------------------- +/// Structure for MGL command +struct mglCommand +{ + const char *name; ///< Name of command + const char *desc; ///< Short command description (can be NULL) + const char *form; ///< Format of command arguments (can be NULL) + /// Function for executing (plotting) + int (*exec)(mglGraph *gr, long n, mglArg *a, const char *k, const char *opt); + /// Type of command: 0 - data plot, 1 - other plot, + /// 2 - setup, 3 - data handle, 4 - data create, 5 - subplot, 6 - program + /// 7 - 1d plot, 8 - 2d plot, 9 - 3d plot, 10 - dd plot, 11 - vector plot + /// 12 - axis, 13 - primitives, 14 - axis setup, 15 - text/legend, 16 - data transform + int type; +}; +extern mglCommand mgls_base_cmd[]; +//----------------------------------------------------------------------------- +/// Structure for the number handling (see mglParse class). +struct mglNum +{ + mreal d; ///< Number itself + std::wstring s; ///< Number name + mglNum *next; ///< Pointer to next instance in list + mglNum *prev; ///< Pointer to prev instance in list + mglNum() { d=0; next=prev=0; } + ~mglNum(); + /// Move variable after var and copy func from var (if func is 0) + void MoveAfter(mglNum *var); +}; +//----------------------------------------------------------------------------- +/// Structure for function name and position. +struct mglFunc +{ + long pos; + int narg; + std::wstring func; +// wchar_t func[64]; + mglFunc(long p, const wchar_t *f); + mglFunc(const mglFunc &f); + mglFunc() { pos=narg=-1; } +}; +//----------------------------------------------------------------------------- +/// Structure for stack of functions and its arguments. +struct mglFnStack +{ + mglFnStack() {pos=0;} + long pos; + std::wstring par[10]; +}; +//----------------------------------------------------------------------------- +/// Function for asking question in console mode +void MGL_EXPORT mgl_ask_gets(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +/// Structure for the command argument (see mglGraph::Exec()). +class mglParser +{ +friend void mgl_export(wchar_t *out, const wchar_t *in, int type); +public: + mglVar *DataList; ///< List with data and its names + mglNum *NumList; ///< List with numbers and its names + bool AllowSetSize; ///< Allow using setsize command + bool AllowFileIO; ///< Allow reading/saving files + bool Stop; ///< Stop command was. Flag prevent further execution + mglCommand *Cmd; ///< Table of MGL commands (can be changed by user). It MUST be sorted by 'name'!!! + long InUse; ///< Smart pointer (number of users) + + mglParser(bool setsize=false); + ~mglParser(); + /// Find the command by the keyword name + mglCommand *FindCommand(const char *name); + mglCommand *FindCommand(const wchar_t *name); + /// Parse and execute the string of MGL script + inline int Parse(HMGL gr, const char *str, long pos=0) + { mglGraph GR(gr); return Parse(&GR,str,pos); } + int Parse(mglGraph *gr, const char *str, long pos=0); + /// Parse and execute the unicode string of MGL script + inline int Parse(HMGL gr, const wchar_t *str, long pos=0) + { mglGraph GR(gr); return Parse(&GR,str,pos); } + int Parse(mglGraph *gr, std::wstring str, long pos=0); + /// Execute MGL script file fname + inline void Execute(HMGL gr, FILE *fp, bool print=false) + { mglGraph GR(gr); Execute(&GR,fp,print); } + void Execute(mglGraph *gr, FILE *fp, bool print=false); + /// Execute MGL script from array of lines + inline void Execute(HMGL gr, int num, const wchar_t **text) + { mglGraph GR(gr); Execute(&GR,num,text); } + void Execute(mglGraph *gr, int num, const wchar_t **text); + /// Execute MGL script text with '\n' separated lines + inline void Execute(HMGL gr, const wchar_t *text) + { mglGraph GR(gr); Execute(&GR,text); } + void Execute(mglGraph *gr, const wchar_t *text); + /// Execute MGL script text with '\n' separated lines + inline void Execute(HMGL gr, const char *text) + { mglGraph GR(gr); Execute(&GR,text); } + void Execute(mglGraph *gr, const char *text); + /// Scan for functions (use NULL for reset) + void ScanFunc(const wchar_t *line); + /// Check if name is function and return its address (or 0 if no) + long IsFunc(const std::wstring &name, int *narg=0); + /// Find variable or return 0 if absent + mglVar *FindVar(const char *name); + mglVar *FindVar(const wchar_t *name); + /// Find variable or create it if absent + mglVar *AddVar(const char *name); + mglVar *AddVar(const wchar_t *name); + /// Find number or return 0 if absent + mglNum *FindNum(const char *name); + mglNum *FindNum(const wchar_t *name); + /// Find number or create it if absent + mglNum *AddNum(const char *name); + mglNum *AddNum(const wchar_t *name); + /// Add string for parameter $1, ..., $9 + void AddParam(int n, const char *str); + void AddParam(int n, const wchar_t *str); + /// Add new MGL command(s) (last command MUST HAVE name[0]=0 !!!) + void AddCommand(mglCommand *cmd, int num=0); + /// Restore Once flag + inline void RestoreOnce() { Once = true; } + /// Delete variable + void DeleteVar(mglVar *v); + /// Delete variable by its name + void DeleteVar(const char *name); + void DeleteVar(const wchar_t *name); + /// Delete all data variables + void DeleteAll(); +private: +// long parlen; ///< Length of parameter strings + std::wstring par[40]; ///< Parameter for substituting instead of $1, ..., $9 + bool Once; ///< Flag for command which should be executed only once + bool Skip; ///< Flag that commands should be skiped (inside 'once' block) + int if_stack[40]; ///< Stack for if-else-endif commands + int if_pos; ///< position in if_stack + std::vector func; ///< function names and position + std::vector fn_stack; ///< function calls stack +// int fn_pos; ///< position in function stack + int if_for[40]; ///< position in if_stack for for-cycle start + mglData *fval; ///< Values for for-cycle. Note that nx - number of elements, ny - next element, nz - address (or string number) of first cycle command + int for_stack[40]; ///< The order of for-variables + int for_addr; ///< Flag for saving address in variable (for_addr-1) + bool for_br; ///< Break is switched on (skip all comands until 'next') + + /// Parse command + int Exec(mglGraph *gr, const wchar_t *com, long n, mglArg *a, const std::wstring &var, const wchar_t *opt); + /// Fill arguments a from strings + void FillArg(mglGraph *gr, int n, std::wstring *arg, mglArg *a); + /// PreExecute stage -- parse some commands and create variables + int PreExec(mglGraph *gr, long n, std::wstring *arg, mglArg *a); + /// Execute program-flow control commands + int FlowExec(mglGraph *gr, const std::wstring &com, long n, mglArg *a); + /// Parse and execute the unicode string of MGL script + int ParseDat(mglGraph *gr, std::wstring str, mglData &res); + /// Define '$' parameters or start for loop + int ParseDef(std::wstring &str); + /// Parse $N arguments + void PutArg(std::wstring &str, bool def); + /// In skip mode + bool inline ifskip() { return (if_pos>0 && !(if_stack[if_pos-1]&1)); } + bool inline skip() { return (Skip || ifskip() || for_br); } +}; +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/pde.h b/include/mgl2/pde.h new file mode 100644 index 0000000..47c50be --- /dev/null +++ b/include/mgl2/pde.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * data_cf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_PDE_H_ +#define _MGL_PDE_H_ +//----------------------------------------------------------------------------- +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Saves result of PDE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini +HADT MGL_EXPORT mgl_pde_solve_c(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0,const char *opt); +uintptr_t MGL_EXPORT mgl_pde_solve_c_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0,const char *opt,int,int); +/// Saves result of PDE solving (|u|^2) for "Hamiltonian" ham with initial conditions ini +HMDT MGL_EXPORT mgl_pde_solve(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0,const char *opt); +uintptr_t MGL_EXPORT mgl_pde_solve_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0,const char *opt,int,int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HADT MGL_EXPORT mgl_qo2d_solve_c(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +HADT MGL_EXPORT mgl_qo2d_func_c(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +uintptr_t MGL_EXPORT mgl_qo2d_solve_c_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HMDT MGL_EXPORT mgl_qo2d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +HMDT MGL_EXPORT mgl_qo2d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy); +uintptr_t MGL_EXPORT mgl_qo2d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HADT MGL_EXPORT mgl_qo3d_solve_c(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +HADT MGL_EXPORT mgl_qo3d_func_c(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +uintptr_t MGL_EXPORT mgl_qo3d_solve_c_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, uintptr_t* zz, int); +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +HMDT MGL_EXPORT mgl_qo3d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +HMDT MGL_EXPORT mgl_qo3d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz); +uintptr_t MGL_EXPORT mgl_qo3d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, uintptr_t* zz, int); +/// Saves result of ODE solving of n equations with right part func and initial conditions x0 over time interval [0,tmax] with time step dt +HMDT MGL_EXPORT mgl_ode_solve(void (*func)(const mreal *x, mreal *dx, void *par), int n, mreal *x0, mreal dt, mreal tmax, void *par); +/// Finds ray with starting point r0, p0 (and prepares ray data for mgl_qo2d_solve) +HMDT MGL_EXPORT mgl_ray_trace(const char *ham, mreal x0, mreal y0, mreal z0, mreal px, mreal py, mreal pz, mreal dt, mreal tmax); +uintptr_t MGL_EXPORT mgl_ray_trace_(const char *ham, mreal *x0, mreal *y0, mreal *z0, mreal *px, mreal *py, mreal *pz, mreal *dt, mreal *tmax,int); +/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du +HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y); +uintptr_t MGL_EXPORT mgl_jacobian_2d_(uintptr_t* x, uintptr_t* y); +/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} +HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z); +uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/plot.h b/include/mgl2/plot.h new file mode 100644 index 0000000..2494ae2 --- /dev/null +++ b/include/mgl2/plot.h @@ -0,0 +1,197 @@ +/*************************************************************************** + * plot.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_1D_H_ +#define _MGL_1D_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Draw curve for formula with x in x-axis range +void MGL_EXPORT mgl_fplot(HMGL gr, const char *eqY, const char *pen, const char *opt); +void MGL_EXPORT mgl_fplot_(uintptr_t *gr, const char *fy, const char *stl, const char *opt, int ly, int ls, int lo); +/// Draw curve for formulas parametrically depended on t in range [0,1] +void MGL_EXPORT mgl_fplot_xyz(HMGL gr, const char *eqX, const char *eqY, const char *eqZ, const char *pen, const char *opt); +void MGL_EXPORT mgl_fplot_xyz_(uintptr_t *gr, const char *fx, const char *fy, const char *fz, const char *stl, const char *opt, int lx, int ly, int lz, int ls, int lo); + +/// Draw radar chart (plot in curved coordinates) +void MGL_EXPORT mgl_radar(HMGL graph, HCDT a, const char *pen, const char *opt); +void MGL_EXPORT mgl_radar_(uintptr_t *gr, uintptr_t *a, const char *pen, const char *opt, int l,int lo); + +/// Draw usual curve {x,y,z} +void MGL_EXPORT mgl_plot_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_plot_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw usual curve {x,y} +void MGL_EXPORT mgl_plot_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_plot_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw usual curve {x,y} with x in x-axis range +void MGL_EXPORT mgl_plot(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_plot_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Draw curve {x,y,z} which is colored by c (like tension plot) +void MGL_EXPORT mgl_tens_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT c, const char *pen, const char *opt); +void MGL_EXPORT mgl_tens_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *pen, const char *opt,int,int); +/// Draw curve {x,y} which is colored by c (like tension plot) +void MGL_EXPORT mgl_tens_xy(HMGL graph, HCDT x, HCDT y, HCDT c, const char *pen, const char *opt); +void MGL_EXPORT mgl_tens_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *c, const char *pen, const char *opt,int,int); +/// Draw curve {x,y} with x in x-axis range which is colored by c (like tension plot) +void MGL_EXPORT mgl_tens(HMGL graph, HCDT y, HCDT c, const char *pen, const char *opt); +void MGL_EXPORT mgl_tens_(uintptr_t *graph, uintptr_t *y, uintptr_t *c, const char *pen, const char *opt,int,int); + +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y,z} +void MGL_EXPORT mgl_tape_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_tape_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y} +void MGL_EXPORT mgl_tape_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_tape_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw tape(s) which rotates as (bi-)normales of curve {x,y} with x in x-axis range +void MGL_EXPORT mgl_tape(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_tape_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Draw box-plot (special 5-value plot used in statistic) for data specified parametrically +void MGL_EXPORT mgl_boxplot_xy(HMGL graph, HCDT x, HCDT a, const char *pen, const char *opt); +void MGL_EXPORT mgl_boxplot_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw box-plot (special 5-value plot used in statistic) +void MGL_EXPORT mgl_boxplot(HMGL graph, HCDT a, const char *pen, const char *opt); +void MGL_EXPORT mgl_boxplot_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Fill area between curve {x,y,z} and axis plane +void MGL_EXPORT mgl_area_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_area_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Fill area between curve {x,y} and axis plane +void MGL_EXPORT mgl_area_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_area_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Fill area between curve {x,y} with x in x-axis range and axis plane +void MGL_EXPORT mgl_area(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_area_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Fill area (draw ribbon) between curves {x1,y1,z1} and {x2,y2,z2} +void MGL_EXPORT mgl_region_3d(HMGL graph, HCDT x1, HCDT y1, HCDT z1, HCDT x2, HCDT y2, HCDT z2, const char *pen, const char *opt); +void MGL_EXPORT mgl_region_3d_(uintptr_t *graph, uintptr_t *x1, uintptr_t *y1, uintptr_t *z1, uintptr_t *x2, uintptr_t *y2, uintptr_t *z2, const char *pen, const char *opt,int,int); +/// Fill area between curves {x,y1} and {x,y2} +void MGL_EXPORT mgl_region_xy(HMGL graph, HCDT x, HCDT y1, HCDT y2, const char *pen, const char *opt); +void MGL_EXPORT mgl_region_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int, int); +/// Fill area between curves {x,y1} and {x,y2} with x in x-axis range +void MGL_EXPORT mgl_region(HMGL graph, HCDT y1, HCDT y2, const char *pen, const char *opt); +void MGL_EXPORT mgl_region_(uintptr_t *graph, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int, int); + +/// Draw vertical lines from points {x,y,z} to axis plane +void MGL_EXPORT mgl_stem_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_stem_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw vertical lines from points {x,y} to axis plane +void MGL_EXPORT mgl_stem_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_stem_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw vertical lines from points {x,y} with x in x-axis range to axis plane +void MGL_EXPORT mgl_stem(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_stem_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Draw stairs for points in arrays {x,y,z} +void MGL_EXPORT mgl_step_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_step_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw stairs for points in arrays {x,y} +void MGL_EXPORT mgl_step_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_step_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw stairs for points in arrays {x,y} with x in x-axis range +void MGL_EXPORT mgl_step(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_step_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Draw vertical bars from points {x,y,z} to axis plane +void MGL_EXPORT mgl_bars_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_bars_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw vertical bars from points {x,y} to axis plane +void MGL_EXPORT mgl_bars_xy(HMGL graph, HCDT x, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_bars_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int,int); +/// Draw vertical bars from points {x,y} with x in x-axis range to axis plane +void MGL_EXPORT mgl_bars(HMGL graph, HCDT y, const char *pen, const char *opt); +void MGL_EXPORT mgl_bars_(uintptr_t *graph, uintptr_t *y, const char *pen, const char *opt,int,int); + +/// Draw horizontal bars from points {v,y} to axis plane +void MGL_EXPORT mgl_barh_yx(HMGL graph, HCDT y, HCDT v, const char *pen, const char *opt); +void MGL_EXPORT mgl_barh_yx_(uintptr_t *graph, uintptr_t *y, uintptr_t *v, const char *pen, const char *opt,int,int); +/// Draw horizontal bars from points {v,y} with y in y-axis range to axis plane +void MGL_EXPORT mgl_barh(HMGL graph, HCDT v, const char *pen, const char *opt); +void MGL_EXPORT mgl_barh_(uintptr_t *graph, uintptr_t *v, const char *pen, const char *opt,int,int); + +/// Draw Open-High-Low-Close (OHLC) diagram +void MGL_EXPORT mgl_ohlc_x(HMGL graph, HCDT x, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt); +void MGL_EXPORT mgl_ohlc_x_(uintptr_t *graph, uintptr_t *x, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int,int); +/// Draw Open-High-Low-Close (OHLC) diagram with x in x-axis range +void MGL_EXPORT mgl_ohlc(HMGL graph, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt); +void MGL_EXPORT mgl_ohlc_(uintptr_t *graph, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int,int); + +/// Draw chart for data a +void MGL_EXPORT mgl_chart(HMGL graph, HCDT a, const char *col, const char *opt); +void MGL_EXPORT mgl_chart_(uintptr_t *graph, uintptr_t *a, const char *col, const char *opt,int,int); + +/// Draw error boxes {ex,ey} at points {x,y} +void MGL_EXPORT mgl_error_exy(HMGL graph, HCDT x, HCDT y, HCDT ex, HCDT ey, const char *pen, const char *opt); +void MGL_EXPORT mgl_error_exy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *ex, uintptr_t *ey, const char *pen, const char *opt,int,int); +/// Draw error boxes {ey} at points {x,y} +void MGL_EXPORT mgl_error_xy(HMGL graph, HCDT x, HCDT y, HCDT ey, const char *pen, const char *opt); +void MGL_EXPORT mgl_error_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *ey, const char *pen, const char *opt,int,int); +/// Draw error boxes {ey} at points {x,y} with x in x-axis range +void MGL_EXPORT mgl_error(HMGL graph, HCDT y, HCDT ey, const char *pen, const char *opt); +void MGL_EXPORT mgl_error_(uintptr_t *graph, uintptr_t *y, uintptr_t *ey, const char *pen, const char *opt,int,int); + +/// Draw marks with size r at points {x,y,z} +void MGL_EXPORT mgl_mark_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_mark_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *pen, const char *opt,int,int); +/// Draw marks with size r at points {x,y} +void MGL_EXPORT mgl_mark_xy(HMGL graph, HCDT x, HCDT y, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_mark_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int,int); +/// Draw marks with size r at points {x,y} with x in x-axis range +void MGL_EXPORT mgl_mark_y(HMGL graph, HCDT y, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_mark_y_(uintptr_t *graph, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int,int); + +/// Draw tube with variable radius r around curve {x,y,z} +void MGL_EXPORT mgl_tube_xyzr(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_tube_xyzr_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *pen, const char *opt,int,int); +/// Draw tube with variable radius r around curve {x,y} +void MGL_EXPORT mgl_tube_xyr(HMGL graph, HCDT x, HCDT y, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_tube_xyr_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int,int); +/// Draw tube with variable radius r around curve {x,y} with x in x-axis range +void MGL_EXPORT mgl_tube_r(HMGL graph, HCDT y, HCDT r, const char *pen, const char *opt); +void MGL_EXPORT mgl_tube_r_(uintptr_t *graph, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int,int); +/// Draw tube with constant radius r around curve {x,y,z} +void MGL_EXPORT mgl_tube_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, double r, const char *pen, const char *opt); +void MGL_EXPORT mgl_tube_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, mreal *r, const char *pen, const char *opt,int,int); +/// Draw tube with constant radius r around curve {x,y} +void MGL_EXPORT mgl_tube_xy(HMGL graph, HCDT x, HCDT y, double r, const char *penl, const char *opt); +void MGL_EXPORT mgl_tube_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, mreal *r, const char *pen, const char *opt,int,int); +/// Draw tube with constant radius r around curve {x,y} with x in x-axis range +void MGL_EXPORT mgl_tube(HMGL graph, HCDT y, double r, const char *pen, const char *opt); +void MGL_EXPORT mgl_tube_(uintptr_t *graph, uintptr_t *y, mreal *r, const char *pen, const char *opt,int,int); + +/// Draw candle plot for data specified parametrically +void MGL_EXPORT mgl_candle_xyv(HMGL gr, HCDT x, HCDT v1, HCDT v2, HCDT y1, HCDT y2, const char *pen, const char *opt); +void MGL_EXPORT mgl_candle_xyv_(uintptr_t *gr, uintptr_t *x, uintptr_t *v1, uintptr_t *v2, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int,int); +/// Draw candle plot +void MGL_EXPORT mgl_candle_yv(HMGL gr, HCDT v1, HCDT v2, HCDT y1, HCDT y2, const char *pen, const char *opt); +void MGL_EXPORT mgl_candle_yv_(uintptr_t *gr, uintptr_t *v1, uintptr_t *v2, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int,int); +/// Draw candle plot with v1=v[i], v2=v[i+1] +void MGL_EXPORT mgl_candle(HMGL gr, HCDT v, HCDT y1, HCDT y2, const char *pen, const char *opt); +void MGL_EXPORT mgl_candle_(uintptr_t *gr, uintptr_t *y, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int,int); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/prim.h b/include/mgl2/prim.h new file mode 100644 index 0000000..404f1ce --- /dev/null +++ b/include/mgl2/prim.h @@ -0,0 +1,143 @@ +/*************************************************************************** + * prim.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_PRIM_H_ +#define _MGL_PRIM_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Draws the mark at position {x,y,z} +void MGL_EXPORT mgl_mark(HMGL gr, double x,double y,double z,const char *mark); +void MGL_EXPORT mgl_mark_(uintptr_t *gr, mreal *x, mreal *y, mreal *z,const char *mark,int); +/// Draws red point (ball) at position {x,y,z} +void MGL_EXPORT mgl_ball(HMGL gr, double x,double y,double z); +void MGL_EXPORT mgl_ball_(uintptr_t *gr, mreal *x, mreal *y, mreal *z); + +/// Draws the line between 2 points by specified pen +void MGL_EXPORT mgl_line(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, const char *pen,int n); +void MGL_EXPORT mgl_line_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, const char *pen,int *n,int); +/// Draws the spline curve between 2 points by specified pen +void MGL_EXPORT mgl_curve(HMGL gr, double x1, double y1, double z1, double dx1, double dy1, double dz1, double x2, double y2, double z2, double dx2, double dy2, double dz2, const char *pen,int n); +void MGL_EXPORT mgl_curve_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *dx1, mreal *dy1, mreal *dz1, mreal *x2, mreal *y2, mreal *z2, mreal *dx2, mreal *dy2, mreal *dz2, const char *pen,int *n, int l); + +/// Draws the 3d error box {ex,ey,ez} for point {x,y,z} +void MGL_EXPORT mgl_error_box(HMGL gr, double x, double y, double z, double ex, double ey, double ez, const char *pen); +void MGL_EXPORT mgl_error_box_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, mreal *ex, mreal *ey, mreal *ez, const char *pen, int); + +/// Draws the face between points with color stl (include interpolation up to 4 colors). +void MGL_EXPORT mgl_face(HMGL gr, double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, const char *stl); +void MGL_EXPORT mgl_face_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *x3, mreal *y3, mreal *z3, const char *stl, int); +/// Draws the face in y-z plane at point p with color stl (include interpolation up to 4 colors). +void MGL_EXPORT mgl_facex(HMGL gr, double x0, double y0, double z0, double wy, double wz, const char *stl, double dx, double dy); +void MGL_EXPORT mgl_facex_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wy, mreal *wz, const char *stl, mreal *dx, mreal *dy, int l); +/// Draws the face in x-z plane at point p with color stl (include interpolation up to 4 colors). +void MGL_EXPORT mgl_facey(HMGL gr, double x0, double y0, double z0, double wx, double wz, const char *stl, double dx, double dy); +void MGL_EXPORT mgl_facey_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wx, mreal *wz, const char *stl, mreal *dx, mreal *dy, int l); +/// Draws the face in x-y plane at point p with color stl (include interpolation up to 4 colors). +void MGL_EXPORT mgl_facez(HMGL gr, double x0, double y0, double z0, double wx, double wy, const char *stl, double dx, double dy); +void MGL_EXPORT mgl_facez_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wx, mreal *wy, const char *stl, mreal *dx, mreal *dy, int l); + +/// Draws the sphere at point {x,y,z} with color stl and radius r +void MGL_EXPORT mgl_sphere(HMGL gr, double x, double y, double z, double r, const char *stl); +void MGL_EXPORT mgl_sphere_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, mreal *r, const char *stl, int); +/// Draws the drop at point {x,y,z} in direction {dx,dy,dz} with color stl and radius r +void MGL_EXPORT mgl_drop(HMGL gr, double x, double y, double z, double dx, double dy, double dz, double r, const char *stl, double shift, double ap); +void MGL_EXPORT mgl_drop_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl, mreal *shift, mreal *ap, int); +/// Draws the cone between points p1,p2 with radius r1,r2 and with style stl +void MGL_EXPORT mgl_cone(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r1, double r2, const char *stl); +void MGL_EXPORT mgl_cone_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r1, mreal *r2, const char *stl, int); +/// Draws the ellipse between points p1,p2 with color stl and width r +void MGL_EXPORT mgl_ellipse(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r, const char *stl); +void MGL_EXPORT mgl_ellipse_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl, int); +/// Draws the rhomb between points p1,p2 with color stl and width r +void MGL_EXPORT mgl_rhomb(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r, const char *stl); +void MGL_EXPORT mgl_rhomb_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl, int); + +/// Draw cones from points {x,y,z} to axis plane +void MGL_EXPORT mgl_cones_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_cones_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw cones from points {x,z} to axis plane +void MGL_EXPORT mgl_cones_xz(HMGL graph, HCDT x, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_cones_xz_(uintptr_t *graph, uintptr_t *x, uintptr_t *z, const char *pen, const char *opt,int,int); +/// Draw cones from points {x,z} with x in x-axis range to axis plane +void MGL_EXPORT mgl_cones(HMGL graph, HCDT z, const char *pen, const char *opt); +void MGL_EXPORT mgl_cones_(uintptr_t *graph, uintptr_t *z, const char *pen, const char *opt,int,int); + +/// Plot dew drops for vector field {ax,ay} parametrically depended on coordinate {x,y} +void MGL_EXPORT mgl_dew_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_dew_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot dew drops for vector field {ax,ay} +void MGL_EXPORT mgl_dew_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *optl); +void MGL_EXPORT mgl_dew_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int l); + +/// Print text in position {x,y,z} with specified font +/* NOTE: Function don't have options because it can be part of group.*/ +void MGL_EXPORT mgl_puts(HMGL graph, double x, double y, double z,const char *text, const char *font, double size); +void MGL_EXPORT mgl_puts_(uintptr_t *graph, mreal *x, mreal *y, mreal *z,const char *text, const char *font, mreal *size, int, int); +void MGL_EXPORT mgl_putsw(HMGL graph, double x, double y, double z,const wchar_t *text, const char *font, double size); + +/// Print text in position {x,y,z} along direction {dx,dy,dz} with specified font +/* NOTE: Function don't have options because it can be part of group.*/ +void MGL_EXPORT mgl_puts_dir(HMGL graph, double x, double y, double z, double dx, double dy, double dz, const char *text, const char *font, double size); +void MGL_EXPORT mgl_puts_dir_(uintptr_t *graph, mreal *x, mreal *y, mreal *z, mreal *dx, mreal *dy, mreal *dz, const char *text, const char *font, mreal *size, int, int); +void MGL_EXPORT mgl_putsw_dir(HMGL graph, double x, double y, double z, double dx, double dy, double dz, const wchar_t *text, const char *font, double size); + +/// Draw textual marks with size r at points {x,y,z} +void MGL_EXPORT mgl_textmark_xyzr(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT r, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_textmark_xyzr_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_textmarkw_xyzr(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT r, const wchar_t *text, const char *fnt, const char *opt); +/// Draw textual marks with size r at points {x,y} +void MGL_EXPORT mgl_textmark_xyr(HMGL graph, HCDT x, HCDT y, HCDT r, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_textmark_xyr_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_textmarkw_xyr(HMGL graph, HCDT x, HCDT y, HCDT r, const wchar_t *text, const char *fnt, const char *opt); +/// Draw textual marks with size r at points {x,y} with x in x-axis range +void MGL_EXPORT mgl_textmark_yr(HMGL graph, HCDT y, HCDT r, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_textmark_yr_(uintptr_t *graph, uintptr_t *y, uintptr_t *r, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_textmarkw_yr(HMGL graph, HCDT y, HCDT r, const wchar_t *text, const char *fnt, const char *opt); +/// Draw textual marks with size r=1 at points {x,y} with x in x-axis range +void MGL_EXPORT mgl_textmark(HMGL graph, HCDT y, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_textmarkw(HMGL graph, HCDT y, const wchar_t *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_textmark_(uintptr_t *graph, uintptr_t *y, const char *text, const char *fnt, const char *opt,int,int,int); + +/// Draw labels for points coordinate(s) at points {x,y,z} +void MGL_EXPORT mgl_label_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_label_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_labelw_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, const wchar_t *text, const char *fnt, const char *opt); +/// Draw labels for points coordinate(s) at points {x,y} +void MGL_EXPORT mgl_label_xy(HMGL graph, HCDT x, HCDT y, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_label_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_labelw_xy(HMGL graph, HCDT x, HCDT y, const wchar_t *text, const char *fnt, const char *opt); +/// Draw labels for points coordinate(s) at points {x,y} with x in x-axis range +void MGL_EXPORT mgl_label_y(HMGL graph, HCDT y, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_labelw_y(HMGL graph, HCDT y, const wchar_t *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_label_y_(uintptr_t *graph, uintptr_t *y, const char *text, const char *fnt, const char *opt,int,int,int); + +/// Draw table for values val along given direction with row labels text at position {x,y} +void MGL_EXPORT mgl_table(HMGL gr, double x, double y, HCDT val, const char *text, const char *fnt, const char *opt); +void MGL_EXPORT mgl_table_(uintptr_t *gr, mreal *x, mreal *y, uintptr_t *val, const char *text, const char *fnt, const char *opt,int,int,int); +void MGL_EXPORT mgl_tablew(HMGL gr, double x, double y, HCDT val, const wchar_t *text, const char *fnt, const char *opt); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/qmathgl.h b/include/mgl2/qmathgl.h new file mode 100644 index 0000000..a9fd085 --- /dev/null +++ b/include/mgl2/qmathgl.h @@ -0,0 +1,219 @@ +/*************************************************************************** + * window.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_QMATHGL_H_ +#define _MGL_QMATHGL_H_ +//----------------------------------------------------------------------------- +#include +#include +#include +#include +//----------------------------------------------------------------------------- +class QTextEdit; +class QMenu; +class QMainWindow; +class QScrollArea; +class QSpinBox; +class QTimer; +class mglCanvas; +//----------------------------------------------------------------------------- +/// Class is Qt widget which display MathGL graphics +class MGL_EXPORT QMathGL : public QWidget +{ + Q_OBJECT +public: + friend void *mgl_qt_thr(void *); + QString appName; ///< Application name for message boxes + bool autoResize; ///< Allow auto resizing (default is false) + bool enableMouse; ///< Enable mouse handlers + bool enableWheel; ///< Enable mouse wheel handlers + QString primitives; ///< Manual primitives, defined by user + + QMathGL(QWidget *parent = 0, Qt::WindowFlags f = 0); + virtual ~QMathGL(); + double getRatio(); + void setPopup(QMenu *p) { popup = p; } ///< Set popup menu pointer + void setSize(int w, int h); ///< Set window/picture sizes + void setGraph(HMGL GR); ///< Set grapher object + inline void setGraph(mglGraph *GR) + { setGraph(GR->Self()); } + inline HMGL getGraph() { return (HMGL)gr; } + /// Set drawing functions and its parameter + void setDraw(int (*func)(mglBase *gr, void *par), void *par); + void setDraw(mglDraw *dr); + inline void setDraw(int (*func)(mglGraph *gr)) + { setDraw(func?mgl_draw_graph:0,(void*)func); } + inline void zoomRegion(mreal xx1,mreal xx2,mreal yy1, mreal yy2) + { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } + + int getPer() {return int(per);} ///< Get perspective value + int getPhi() {return int(phi);} ///< Get Phi-angle value + int getTet() {return int(tet);} ///< Get Theta-angle value + bool getAlpha() {return alpha;} ///< Get transparency state + bool getLight() {return light;} ///< Get lightning state + bool getZoom() {return zoom;} ///< Get mouse zooming state + bool getRotate(){return rotate;} ///< Get mouse rotation state + bool getViewYZ(){return viewYZ;} ///< Get mouse rotation axis + bool isActive(int xs,int ys); ///< Check if active point is pressed + +public slots: + void refresh(); + void update(); ///< Update picture + void copy(); ///< copy graphics to clipboard + void copyClickCoor(); ///< copy click coordinates to clipboard + void print(); ///< Print plot + void stop(); ///< Stop execution + void setPer(int p); ///< Set perspective value + void setPhi(int p); ///< Set Phi-angle value + void setTet(int t); ///< Set Theta-angle value + void setAlpha(bool a); ///< Switch on/off transparency + void setLight(bool l); ///< Switch on/off lightning + void setGrid(bool r); ///< Switch on/off grid drawing + void imgSize(int w, int h); ///< Set image size + void setViewYZ(bool v); ///< Switch on/off rotation around Y and Z axis + + void setCustZoom(bool a); ///< Switch on/off using custom zoom + void setCustDraw(bool a); ///< Switch on/off using custom draw + void setZoom(bool z); ///< Switch on/off mouse zooming + void setRotate(bool r); ///< Switch on/off mouse rotation + void zoomIn(); ///< Zoom in graphics + void zoomOut(); ///< Zoom out graphics + void restore(); ///< Restore zoom and rotation to default values + // void reload(); ///< Reload data and execute script + + void shiftLeft(); ///< Shift graphics to left direction + void shiftRight(); ///< Shift graphics to right direction + void shiftUp(); ///< Shift graphics to up direction + void shiftDown(); ///< Shift graphics to down direction + + void exportPNG(QString fname=""); ///< export to PNG file + void exportPNGs(QString fname=""); ///< export to PNG file (no transparency) + void exportGIF(QString fname=""); ///< export to GIF file + void exportJPG(QString fname=""); ///< export to JPEG file + void exportBPS(QString fname=""); ///< export to bitmap EPS file + void exportEPS(QString fname=""); ///< export to vector EPS file + void exportSVG(QString fname=""); ///< export to SVG file + void exportTEX(QString fname=""); ///< export to SVG file + void exportTGA(QString fname=""); ///< export to TGA file + + void exportXYZ(QString fname=""); ///< export to XYZ file + void exportOBJ(QString fname=""); ///< export to OBJ file + void exportSTL(QString fname=""); ///< export to STL file + void exportOFF(QString fname=""); ///< export to OFF file +// void exportX3D(QString fname=""); ///< export to XYZ file + void exportPRC(QString fname=""); ///< export to PRC file + void exportMGLD(QString fname=""); ///< export to MGLD file + void setMGLFont(QString path); ///< restore/load font for graphics + + void addMark(); ///< add marker into primitives + void addLine(); ///< add line into primitives + void addRect(); ///< add rectangle into primitives + void addCurve(); ///< add curve into primitives + void addRhomb(); ///< add rhombus into primitives + void addEllipse(); ///< add ellipse into primitives + void addText(QString txt=""); ///< add text into primitives + void setStyle(int id, QString stl);///< set style for primitive with id + + void adjust(); ///< Adjust plot size to fill entire window + void nextSlide(); ///< Show next slide + void prevSlide(); ///< Show previous slide + void animation(bool st=true); ///< Start animation + void about(); ///< Show about information + void aboutQt(); ///< Show information about Qt version + +signals: + void gridChanged(int); ///< Grid drawing changed (by mouse or by toolbar) + void phiChanged(int); ///< Phi angle changed (by mouse or by toolbar) + void tetChanged(int); ///< Tet angle changed (by mouse or by toolbar) + void perChanged(int); ///< Perspective changed (by mouse or by toolbar) + void alphaChanged(bool); ///< Transparency changed (by toolbar) + void lightChanged(bool); ///< Lighting changed (by toolbar) + void zoomChanged(bool); ///< Zooming changed (by toolbar) + void rotateChanged(bool); ///< Rotation changed (by toolbar) + void usePrimChanged(bool); ///< Use primitive changed (i.e. have or not drawing function) + void viewYZChanged(bool); ///< Rotation axis changed (by toolbar) + void mouseClick(mreal,mreal,mreal); ///< Position of mouse click + void frameChanged(int); ///< Need another frame to show + void showWarn(QString); ///< Show warnings + void posChanged(QString message); ///< user click to show mouse position + void objChanged(int objId); ///< User double-click to select object/line + void refreshData(); + void doubleClick(int id); ///< Double mouse click by object with id + void askStyle(int id); ///< Update style + /// user can define its own zooming function + void customZoom(double x1, double y1, double x2, double y2, double tet, double phi, double per); + /// user can define its own drawing/setting function which will be called before main drawing + void customDraw(double x1, double y1, double x2, double y2, bool draw); + +protected: + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *); + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *); + void mouseDoubleClickEvent(QMouseEvent *); + + mglCanvas *gr; ///< Built-in mglCanvasQT-er instance (used by default) + void *draw_par; ///< Parameters for drawing function mglCanvasWnd::DrawFunc. + /// Drawing function for window procedure. It should return the number of frames. + int (*draw_func)(mglBase *gr, void *par); + mglDraw *draw; ///< Class for drawing -- need to call directly due to inheritance mechanism + QString mousePos; ///< Last mouse position + QPixmap pic; ///< Pixmap for drawing (changed by update) + double tet, phi; ///< Rotation angles + double per; ///< Value of perspective ( must be in [0,1) ) + bool alpha; ///< Transparency state + bool light; ///< Lightning state + bool custZoom; ///< Use custom zoom instead of built in + bool custDraw; ///< Use custom draw before main drawing + bool zoom; ///< Mouse zoom state + bool grid; ///< Grid drawing state + bool rotate; ///< Mouse rotation state + bool viewYZ; ///< Set mouse rotation around Y and Z axis (instead of X and Z) + mreal x1,x2,y1,y2; ///< Zoom in region + mreal ax1,ax2,ay1,ay2; ///< Axis range zoom + bool showMessage; ///< Flag for showing messages (enabled by each execute()) + QMenu *popup; ///< Pointer to pop-up menu + QTimer *timer; ///< Timer for animation +private: + int x0, y0, xe, ye; ///< Temporary variables for mouse + uchar *grBuf; + void draw_thr(); +}; +//----------------------------------------------------------------------------- +/// Class for drawing the MGL script +class MGL_EXPORT mglDrawScript : public mglDraw +{ +public: + HMPR par; ///< Parser to be used + QString text; ///< Script to be drawn + long line; ///< Line which will be highlited + mglDrawScript(HMPR p):mglDraw() { par=p; line=-1; } + virtual ~mglDrawScript() {} + int Draw(mglGraph *gr) + { gr->Highlight(line+1); mgl_parse_textw(gr->Self(),par,text.toStdWString().c_str()); return 0; } +}; +//----------------------------------------------------------------------------- +/// Convert bitmap from mglCanvasWnd to QPixmap +void mglConvertFromGraph(QPixmap &pic, mglCanvas *gr, uchar **buf); +/// Make menu, toolbars and return popup menu for MainWindow +QMenu *mglMakeMenu(QMainWindow* Wnd, QMathGL* QMGL, QSpinBox*& tet, QSpinBox*& phi); +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/qt.h b/include/mgl2/qt.h new file mode 100644 index 0000000..bee9b2f --- /dev/null +++ b/include/mgl2/qt.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * window.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_QT_H_ +#define _MGL_QT_H_ +#include +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +/// Creates Qt window for plotting +HMGL MGL_EXPORT mgl_create_graph_qt(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)); +uintptr_t MGL_EXPORT mgl_create_graph_qt_(const char *title, int); +/// Run main Qt loop for event handling. +int MGL_EXPORT mgl_qt_run(); +int MGL_EXPORT mgl_qt_run_(); +#ifdef __cplusplus +} +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +/// Wrapper class for windows displaying graphics +class MGL_EXPORT mglQT : public mglWnd +{ +public: + mglQT(const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_qt(0,title,0,0); } + mglQT(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, void (*load)(void *p)=0) : mglWnd() + { gr = mgl_create_graph_qt(draw,title,par,load); } + mglQT(int (*draw)(mglGraph *gr), const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_qt(draw?mgl_draw_graph:0,title,(void*)draw,0); } + mglQT(mglDraw *draw, const char *title="MathGL") : mglWnd() + { gr = mgl_create_graph_qt(draw?mgl_draw_class:0,title,draw,mgl_reload_class); + mgl_set_click_func(gr, mgl_click_class); } + int Run() { return mgl_qt_run(); } ///< Run main loop for event handling +}; +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ask_qt(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +#endif +#endif diff --git a/include/mgl2/surf.h b/include/mgl2/surf.h new file mode 100644 index 0000000..b1fe54e --- /dev/null +++ b/include/mgl2/surf.h @@ -0,0 +1,130 @@ +/*************************************************************************** + * surf.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_SURF_H_ +#define _MGL_SURF_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif + +/// Draw surface by formula with x,y in axis range +void MGL_EXPORT mgl_fsurf(HMGL graph, const char *fz, const char *stl, const char *opt); +void MGL_EXPORT mgl_fsurf_(uintptr_t *graph, const char *fz, const char *stl, const char *opt,int,int,int); +/// Draw surface by formulas parametrically depended on u,v in range [0,1] +void MGL_EXPORT mgl_fsurf_xyz(HMGL graph, const char *fx, const char *fy, const char *fz, const char *stl, const char *opt); +void MGL_EXPORT mgl_fsurf_xyz_(uintptr_t *graph, const char *fx, const char *fy, const char *fz, const char *stl, const char *opt, int, int, int, int, int); + +/// Draw grid lines for density plot of 2d data specified parametrically +void MGL_EXPORT mgl_grid_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *stl, const char *opt); +void MGL_EXPORT mgl_grid_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *stl, const char *opt,int,int); +/// Draw grid lines for density plot of 2d data +void MGL_EXPORT mgl_grid(HMGL graph, HCDT a,const char *stl, const char *opt); +void MGL_EXPORT mgl_grid_(uintptr_t *graph, uintptr_t *a,const char *stl, const char *opt,int,int); + +/// Draw mesh lines for 2d data specified parametrically +void MGL_EXPORT mgl_mesh_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_mesh_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw mesh lines for 2d data +void MGL_EXPORT mgl_mesh(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_mesh_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw mesh lines for 2d data specified parametrically +void MGL_EXPORT mgl_fall_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_fall_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw mesh lines for 2d data +void MGL_EXPORT mgl_fall(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_fall_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw belts for 2d data specified parametrically +void MGL_EXPORT mgl_belt_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_belt_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw belts for 2d data +void MGL_EXPORT mgl_belt(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_belt_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw surface for 2d data specified parametrically with color proportional to z +void MGL_EXPORT mgl_surf_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_surf_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw surface for 2d data with color proportional to z +void MGL_EXPORT mgl_surf(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_surf_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw density plot for 2d data specified parametrically +void MGL_EXPORT mgl_dens_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_dens_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw density plot for 2d data +void MGL_EXPORT mgl_dens(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_dens_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw vertical boxes for 2d data specified parametrically +void MGL_EXPORT mgl_boxs_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_boxs_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int,int); +/// Draw vertical boxes for 2d data +void MGL_EXPORT mgl_boxs(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_boxs_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw vertical tiles for 2d data specified parametrically +void MGL_EXPORT mgl_tile_xy(HMGL graph, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_tile_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int,int); +/// Draw vertical tiles for 2d data +void MGL_EXPORT mgl_tile(HMGL graph, HCDT z, const char *sch, const char *opt); +void MGL_EXPORT mgl_tile_(uintptr_t *graph, uintptr_t *z, const char *sch, const char *opt,int,int); + +/// Draw vertical tiles with variable size r for 2d data specified parametrically +void MGL_EXPORT mgl_tiles_xy(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT r, const char *sch, const char *opt); +void MGL_EXPORT mgl_tiles_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw vertical tiles with variable size r for 2d data +void MGL_EXPORT mgl_tiles(HMGL graph, HCDT z, HCDT r, const char *sch, const char *opt); +void MGL_EXPORT mgl_tiles_(uintptr_t *graph, uintptr_t *z, uintptr_t *r, const char *sch, const char *opt,int,int); + +/// Draw surface for 2d data specified parametrically with color proportional to c +void MGL_EXPORT mgl_surfc_xy(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_surfc_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw surface for 2d data with color proportional to c +void MGL_EXPORT mgl_surfc(HMGL graph, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_surfc_(uintptr_t *graph, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); + +/// Draw surface for 2d data specified parametrically with alpha proportional to c +void MGL_EXPORT mgl_surfa_xy(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_surfa_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); +/// Draw surface for 2d data with alpha proportional to c +void MGL_EXPORT mgl_surfa(HMGL graph, HCDT z, HCDT c, const char *sch, const char *opt); +void MGL_EXPORT mgl_surfa_(uintptr_t *graph, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int,int); + +/// Draw density plot for spectra-gramm specified parametrically +void MGL_EXPORT mgl_stfa_xy(HMGL graph, HCDT x, HCDT y, HCDT re, HCDT im, int dn, const char *sch, const char *opt); +void MGL_EXPORT mgl_stfa_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *re, uintptr_t *im, int *dn, const char *sch, const char *opt,int, int); +/// Draw density plot for spectra-gramm +void MGL_EXPORT mgl_stfa(HMGL graph, HCDT re, HCDT im, int dn, const char *sch, const char *opt); +void MGL_EXPORT mgl_stfa_(uintptr_t *graph, uintptr_t *re, uintptr_t *im, int *dn, const char *sch, const char *opt,int, int); + +/// Color map of matrix a to matrix b, both matrix can parametrically depend on coordinates +void MGL_EXPORT mgl_map_xy(HMGL graph, HCDT x, HCDT y, HCDT a, HCDT b, const char *sch, const char *opt); +void MGL_EXPORT mgl_map_xy_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int,int); +/// Color map of matrix a to matrix b +void MGL_EXPORT mgl_map(HMGL graph, HCDT a, HCDT b, const char *sch, const char *opt); +void MGL_EXPORT mgl_map_(uintptr_t *graph, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int,int); + +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/thread.h b/include/mgl2/thread.h new file mode 100644 index 0000000..f8c3db5 --- /dev/null +++ b/include/mgl2/thread.h @@ -0,0 +1,86 @@ +/*************************************************************************** + * thread.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_THREAD_H_ +#define _MGL_THREAD_H_ +#include "mgl2/define.h" +//----------------------------------------------------------------------------- +#if MGL_HAVE_PTHREAD +#include +#endif +//----------------------------------------------------------------------------- +struct mglThreadD +{ + mreal *a; // float* array with parameters or results + const mreal *b,*c,*d,*e; // float* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration + const char *s; +}; +struct mglThreadC +{ + dual *a; // dual* array with parameters or results + const dual *b,*c,*d,*e; // dual* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration + const char *s; +}; +struct mglThreadV +{ + mreal *a; // float* array with parameters or results + dual *aa; // dual* array with parameters or results + const void *b,*c; // float* arrays with parameters + const mreal *d; // float* arrays with parameters + const long *p; // long* array with parameters + const void *v; // pointer to data/grapher + int id; // thread id + long n; // total number of iteration +}; +struct mglThreadT +{ + void *a; // dual* or mreal* array with input or results + double *b; // dual* array with input or results + const long *p; // long* array with parameters + const void *v; // pointer to table/parameter + void **w; // pointer to workspace + int id; // thread id + long n; // total number of iteration + const void *re,*im; +}; +/// Start several thread for the task +void MGL_EXPORT mglStartThread(void *(*func)(void *), void (*post)(mglThreadD *,mreal *), long n, + mreal *a=0, const mreal *b=0, const mreal *c=0, const long *p=0, + const void *v=0, const mreal *d=0, const mreal *e=0, const char *s=0); +void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, mreal *a, const void *b=0, + const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); +void MGL_EXPORT mglStartThreadV(void *(*func)(void *), long n, dual *a, const void *b=0, + const void *c=0, const long *p=0, const void *v=0, const mreal *d=0); +void MGL_EXPORT mglStartThreadC(void *(*func)(void *), void (*post)(mglThreadC *,dual *), long n, + dual *a=0, const dual *b=0, const dual *c=0, const long *p=0, + const void *v=0, const dual *d=0, const dual *e=0, const char *s=0); +void MGL_EXPORT mglStartThreadT(void *(*func)(void *), long n, void *a, double *b, const void *v=0, + void **w=0, const long *p=0, const void *re=0, const void *im=0); +MGL_EXPORT extern int mglNumThr; ///< Number of thread for plotting and data handling +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/include/mgl2/type.h b/include/mgl2/type.h new file mode 100644 index 0000000..6fa165c --- /dev/null +++ b/include/mgl2/type.h @@ -0,0 +1,153 @@ +/*************************************************************************** + * type.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_TYPE_H_ +#define _MGL_TYPE_H_ + +#include "mgl2/define.h" +//----------------------------------------------------------------------------- +const mreal Pi = M_PI; +const mreal NaN = NAN; +const mreal mgl_min_a = 1./256; +//----------------------------------------------------------------------------- +#define MGL_SET_XYZ(p,xx,yy,zz) {p.x=(xx);p.y=(yy);p.z=(zz);} +#define MGL_SET_XY(p,xx,yy) {p.x=(xx);p.y=(yy);p.z=0;} +#define MGL_SET_RGBA(p,rr,gg,bb,aa) {p.r=(rr);p.g=(gg);p.b=(bb);p.a=(aa);} +#define MGL_SET_RGB(p,rr,gg,bb) {p.r=(rr);p.g=(gg);p.b=(bb);} +//----------------------------------------------------------------------------- +/// Class for point in 3D space +struct MGL_EXPORT mglPoint +{ + mreal x,y,z,c; + mglPoint(mreal X=0,mreal Y=0,mreal Z=0,mreal C=0){x=X;y=Y;z=Z;c=C;} + inline bool IsNAN() { return (x!=x || y!=y || z!=z || c!=c); } + inline mreal val(int i) { return (i<2 ? (i==0 ? x:y) : (i==2 ? z:c)); } + inline mreal norm() { return sqrt(x*x+y*y+z*z); } + inline void Normalize() { mreal v=norm(); x/=v; y/=v; z/=v; } + + inline void operator+=(const mglPoint &a) { x+=a.x; y+=a.y; z+=a.z; c+=a.c; } + inline void operator-=(const mglPoint &a) { x-=a.x; y-=a.y; z-=a.z; c-=a.c; } + inline void operator+=(mreal a) { x+=a; y+=a; z+=a; } + inline void operator-=(mreal a) { x-=a; y-=a; z-=a; } + inline void operator*=(mreal a) { x*=a; y*=a; z*=a; } + inline void operator/=(mreal a) { x/=a; y/=a; z/=a; } +}; +#ifndef SWIG +inline mglPoint operator+(const mglPoint &a, const mglPoint &b) +{ return mglPoint(a.x+b.x, a.y+b.y, a.z+b.z, a.c+b.c); } +inline mglPoint operator-(const mglPoint &a, const mglPoint &b) +{ return mglPoint(a.x-b.x, a.y-b.y, a.z-b.z, a.c-b.c); } +inline mglPoint operator-(const mglPoint &a) +{ return mglPoint(-a.x, -a.y, -a.z, -a.c); } +inline mglPoint operator*(mreal b, const mglPoint &a) +{ return mglPoint(a.x*b, a.y*b, a.z*b); } +inline mglPoint operator*(const mglPoint &a, mreal b) +{ return mglPoint(a.x*b, a.y*b, a.z*b); } +inline mglPoint operator/(const mglPoint &a, mreal b) +{ return mglPoint(a.x/b, a.y/b, a.z/b); } +inline mreal operator*(const mglPoint &a, const mglPoint &b) +{ return a.x*b.x+a.y*b.y+a.z*b.z; } +inline mglPoint operator/(const mglPoint &a, const mglPoint &b) +{ return mglPoint(a.x*b.x, a.y*b.y, a.z*b.z); } +inline mglPoint operator&(const mglPoint &a, const mglPoint &b) +{ return a - b*((a*b)/(b*b)); } +inline mglPoint operator|(const mglPoint &a, const mglPoint &b) +{ return b*((a*b)/(b*b)); } +inline mglPoint operator^(const mglPoint &a, const mglPoint &b) +{ return mglPoint(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x); } +inline mglPoint operator!(const mglPoint &a) +{ mreal f=mgl_hypot(a.x,a.y); return f==0?mglPoint(0.,1.,0.):mglPoint(-a.y/f, a.x/f, 0); } +inline bool operator==(const mglPoint &a, const mglPoint &b) +{ return !memcmp(&a, &b, sizeof(mglPoint)); } +inline bool operator!=(const mglPoint &a, const mglPoint &b) +{ return memcmp(&a, &b, sizeof(mglPoint)); } +inline bool operator<(const mglPoint &a, const mglPoint &b) +{ return a.x<=b.x && a.y<=b.y && a.z<=b.z; } +inline bool operator>(const mglPoint &a, const mglPoint &b) +{ return a.x>=b.x && a.y>=b.y && a.z>=b.z; } +inline mreal mgl_norm(const mglPoint &p) +{ return sqrt(p.x*p.x+p.y*p.y+p.z*p.z); } +#endif +//----------------------------------------------------------------------------- +/// Class for RGBA color +struct MGL_EXPORT mglColor +{ + float r; ///< Red component of color + float g; ///< Green component of color + float b; ///< Blue component of color + float a; ///< Alpha component of color + + /// Constructor for RGB components manualy + mglColor(float R,float G,float B, float A=1){ r=R; g=G; b=B; a=A; } + /// Constructor set default color + mglColor() { r=g=b=0; a=1; } + /// Constructor set color from character id + mglColor(char c, float bright=1) { Set(c,bright); } + /// Set color as Red, Green, Blue values + void Set(float R,float G,float B,float A=1) { r=R; g=G; b=B; a=A; } + /// Set color as Red, Green, Blue values + void Set(mglColor c, float bright=1) + { + if(bright<0) bright=0; if(bright>2.f) bright=2.f; + r = bright<=1 ? c.r*bright : 1 - (1-c.r)*(2-bright); + g = bright<=1 ? c.g*bright : 1 - (1-c.g)*(2-bright); + b = bright<=1 ? c.b*bright : 1 - (1-c.b)*(2-bright); a = 1; + } + /// Check if color is valid + inline bool Valid() + { return (r>=0 && r<=1 && g>=0 && g<=1 && b>=0 && b<=1 && a>=0 && a<=1); } + /// Get maximal spectral component + inline float Norm() + { return r>g ? r : (g>b ? g : b); } + inline float NormS() + { return r*r+g*g+b*b; } + /// Set color from symbolic id + inline void Set(char p, float bright=1) + { + float rgb[3]; mgl_chrrgb(p,rgb); + Set(mglColor(rgb[0],rgb[1],rgb[2]),bright); + } + /// Copy color from other one + inline bool operator==(const mglColor &c) const + { return !memcmp(this, &c, sizeof(mglColor)); } + inline bool operator!=(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor)); } + inline bool operator<(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor))<0; } + // transparency still the same + inline void operator*=(float v) { r*=v; g*=v; b*=v; a*=v; } + inline void operator+=(const mglColor &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; } + inline void operator-=(const mglColor &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; } +}; +#ifndef SWIG +inline mglColor operator+(const mglColor &a, const mglColor &b) +{ return mglColor(a.r+b.r, a.g+b.g, a.b+b.b, a.a+b.a); } +inline mglColor operator-(const mglColor &a, const mglColor &b) +{ return mglColor(a.r-b.r, a.g-b.g, a.b-b.b, a.a-b.a); } +inline mglColor operator*(const mglColor &a, float b) +{ return mglColor(a.r*b, a.g*b, a.b*b, a.a*b); } +inline mglColor operator*(float b, const mglColor &a) +{ return mglColor(a.r*b, a.g*b, a.b*b, a.a*b); } +inline mglColor operator/(const mglColor &a, float b) +{ return mglColor(a.r/b, a.g/b, a.b/b, a.a/b); } +inline mglColor operator!(const mglColor &a) +{ return mglColor(1-a.r, 1-a.g, 1-a.b, a.a); } +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/vect.h b/include/mgl2/vect.h new file mode 100644 index 0000000..ce1f33f --- /dev/null +++ b/include/mgl2/vect.h @@ -0,0 +1,108 @@ +/*************************************************************************** + * vect.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_VECT_H_ +#define _MGL_VECT_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +//----------------------------------------------------------------------------- +/// Plot vectors at position {x,y} along {ax,ay} with length/color proportional to |a| +void MGL_EXPORT mgl_traj_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_traj_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot vectors at position {x,y,z} along {ax,ay,az} with length/color proportional to |a| +void MGL_EXPORT mgl_traj_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_traj_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); + +/// Plot vector field {ax,ay} parametrically depended on coordinate {x,y} with length/color proportional to |a| +void MGL_EXPORT mgl_vect_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_vect_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot vector field {ax,ay} with length/color proportional to |a| +void MGL_EXPORT mgl_vect_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_vect_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with length/color proportional to |a| +void MGL_EXPORT mgl_vect_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_vect_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); +/// Plot vector field {ax,ay,az} with length/color proportional to |a| +void MGL_EXPORT mgl_vect_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_vect_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); + +/// Plot flows for vector field {ax,ay} parametrically depended on coordinate {x,y} with color proportional to |a| +void MGL_EXPORT mgl_flow_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_flow_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot flows for vector field {ax,ay} with color proportional to |a| +void MGL_EXPORT mgl_flow_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_flow_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int,int); +/// Plot flows for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| +void MGL_EXPORT mgl_flow_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_flow_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); +/// Plot flows for vector field {ax,ay,az} with color proportional to |a| +void MGL_EXPORT mgl_flow_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_flow_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); + +/// Plot flow from point p for vector field {ax,ay} parametrically depended on coordinate {x,y} with color proportional to |a| +void MGL_EXPORT mgl_flowp_xy(HMGL gr, double x0, double y0, double z0, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_flowp_xy_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int, int); +/// Plot flow from point p for vector field {ax,ay} with color proportional to |a| +void MGL_EXPORT mgl_flowp_2d(HMGL gr, double x0, double y0, double z0, HCDT ax, HCDT ay, const char *sch, const char *opt); +void MGL_EXPORT mgl_flowp_2d_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int, int); +/// Plot flow from point p for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| +void MGL_EXPORT mgl_flowp_xyz(HMGL gr, double x0, double y0, double z0, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_flowp_xyz_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int, int); +/// Plot flow from point p for vector field {ax,ay,az} with color proportional to |a| +void MGL_EXPORT mgl_flowp_3d(HMGL gr, double x0, double y0, double z0, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt); +void MGL_EXPORT mgl_flowp_3d_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int,int); + +/// Plot flow pipes for vector field {ax,ay} parametrically depended on coordinate {x,y} with color and radius proportional to |a| +void MGL_EXPORT mgl_pipe_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, double r0, const char *opt); +void MGL_EXPORT mgl_pipe_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, mreal *r0, const char *opt,int,int); +/// Plot flow pipes for vector field {ax,ay} with color and radius proportional to |a| +void MGL_EXPORT mgl_pipe_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, double r0, const char *opt); +void MGL_EXPORT mgl_pipe_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, mreal *r0, const char *opt,int,int); +/// Plot flow pipes for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color and radius proportional to |a| +void MGL_EXPORT mgl_pipe_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, double r0, const char *opt); +void MGL_EXPORT mgl_pipe_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *r0, const char *opt,int,int); +/// Plot flow pipes for vector field {ax,ay,az} with color and radius proportional to |a| +void MGL_EXPORT mgl_pipe_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, double r0, const char *opt); +void MGL_EXPORT mgl_pipe_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *r0, const char *opt,int,int); + +/// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y,z} +void MGL_EXPORT mgl_grad_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ph, const char *sch, const char *opt); +void MGL_EXPORT mgl_grad_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ph, const char *sch, const char *opt,int, int); +/// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y} +void MGL_EXPORT mgl_grad_xy(HMGL gr, HCDT x, HCDT y, HCDT ph, const char *sch, const char *opt); +void MGL_EXPORT mgl_grad_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ph, const char *sch, const char *opt,int,int); +/// Plot flows for gradient of scalar field phi +void MGL_EXPORT mgl_grad(HMGL gr, HCDT ph, const char *sch, const char *opt); +void MGL_EXPORT mgl_grad_(uintptr_t *gr, uintptr_t *ph, const char *sch, const char *opt,int,int); + +/// Draw vector plot at slice for 3d data specified parametrically +void MGL_EXPORT mgl_vect3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_vect3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *sVal, const char *opt,int,int); +/// Draw vector plot at slice for 3d data +void MGL_EXPORT mgl_vect3(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt); +void MGL_EXPORT mgl_vect3_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *sVal, const char *opt,int,int); +//----------------------------------------------------------------------------- +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/vectors.fs b/include/mgl2/vectors.fs new file mode 100644 index 0000000..b3eb672 --- /dev/null +++ b/include/mgl2/vectors.fs @@ -0,0 +1,161 @@ +\ Integer vectors library Thu Feb 21 12:46:01 MST 2008 +\ Copyright (C) 2008, Sergey Plis +\ +\ This program is free software; you can redistribute it and/or modify +\ it under the terms of the GNU General Public License as published by +\ the Free Software Foundation; either version 2 of the License, or +\ (at your option) any later version. +\ +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\needs float import float + +\ vector variables better have names ending with "(" for readability +Module vectors +also float + +\ fetches +| create fetch_operations ' c@ , ' w@ , ' @ , 0 , ' 2@ , ' f@ , + +\ stores +| create store_operations ' c! , ' w! , ' ! , 0 , ' 2! , ' f! , +| : type-idx ( cell_size -- idx ) 4 >> ; macro +| : f-op ( cell-size -- cfa ) type-idx cells fetch_operations + @ ; +| : s-op ( cell-size -- cfa ) type-idx cells store_operations + @ ; + +: ^)! ( *vector -- addr ) [ 3 cells ] literal - @ ; +: ^)@ ( *vector -- addr ) [ 4 cells ] literal - @ ; + +\ number of elements +: )size ( *vector -- size ) [ 1 cells ] literal - @ ; + +\ set number of elements - useful for temporal size adjustments in +\ datastructures such as heaps +: )size! ( sz *vector -- ) [ 1 cells ] literal - ! ; + +\ size of an element in bytes +: )type ( *vector -- size ) [ 2 cells ] literal - @ ; + +: )free ( *vector -- ) [ 4 cells ] literal - free throw ; + +\ header | fetch_cfa | store_cfa | el_size | #els | +\ cell-size in bits +\ unnamed vector +: _vector ( n cell-size -- addr ) + 2dup * [ 4 cells ] literal + allocate throw + dup >r over f-op swap ! + r@ cell+ over s-op swap ! + r@ [ 2 cells ] literal + ! \ cell size store + r@ [ 3 cells ] literal + ! \ #els store + r> [ 4 cells ] literal + ; + +\ named vector +: vector ( n cell-size -- ) + create + 2dup * [ 4 cells ] literal + allocate throw dup , + dup >r over f-op swap ! + r@ cell+ over s-op swap ! + r@ [ 2 cells ] literal + ! \ cell size store + r@ [ 3 cells ] literal + ! \ #els store + r> dup + \ erasing the content + [ 2 cells ] literal + @ over [ 3 cells ] literal + @ * + swap [ 4 cells ] literal + swap erase + does> @ [ 4 cells ] literal + ; + +\ vector of pointers +: vector* ( # -- *vector ) cell 8 * _vector ; + +| : ?idx-in-range ( *vector idx -- 1/0 ) dup rot )size < swap 0>= and ; +| : check-range ( *vector idx -- *vector idx | fail ) + 2dup ?idx-in-range not abort" Index is out of range! " ; + +\ addr of ith element of the vector +: *) ( *vector i -- addr ) over )type 3 >> * + ; +: )@ ( *vector index -- ) + [IFDEF] отладка + check-range + [THEN] + over dup ^)@ >r )type 3 >> * + r> execute ; +: )! ( value *vector index -- ) + [IFDEF] отладка + check-range + [THEN] + over dup ^)! >r )type 3 >> * + r> execute ; +\ : test! cell * + ! ; +| create print-funcs ' . , ' . , ' . , 0 , ' d. , ' f. , +: )print ( *v -- cfa ) )type type-idx cells print-funcs + @ execute ; +: )map ( *v xt -- ) swap dup )size 0 do 2dup i )@ swap execute loop 2drop ; +: map ( *v -- ) ( word-to-map ) ' swap dup )size 0 do 2dup i )@ swap execute loop 2drop ; +: )initperm ( v( -- ) + dup )size 0 do + dup + i swap over )! + loop drop ; +: ). ( *vector -- ) dup )size 0 do dup i )@ over )print loop drop ; +\ does arbitrary vector contain this element ? +: )in? ( *v value -- 1/0 ) + swap dup )size 0 do + 2dup i )@ = if 2drop True unloop exit then + loop 2drop False ; +: )find ( *v value -- i True/False ) + swap dup )size 0 do + 2dup i )@ = if 2drop i True unloop exit then + loop 2drop False ; +: vector->stack ( *v -- n1 n2 .. n# # ) + dup )size 0 do dup i )@ swap loop )size ; +\ initialized cell vector +\ preserve order +: ivector* ( n1 n2 .. n# # -- *vector ) + dup vector* swap 1- 0 swap do + swap over i )! + -1 +loop ; +\ reversed order +: irvector* ( n1 n2 .. n# # -- *vector ) + dup vector* swap 0 do + swap over i )! + loop ; +\ does not take care of duplicate elements +| : overlap ( v1( v2( -- n1 .. n2 # / 0 ) depth 2- >r + dup )size 0 do + 2dup i )@ )in? if + dup i )@ -rot + then + loop 2drop depth r> - ; +| : notoverlap ( v1( v2( -- n1 .. n2 # ) + depth 2- >r + dup )size 0 do + 2dup i )@ )in? not if + dup i )@ -rot + then + loop 2drop depth r> - ; +: )union ( *v1( *v2( -- *v3( ) + over >r + notoverlap + r> swap >r vector->stack r> + + dup 0= abort" empty union!" + ivector* ; +: )intersection ( *v1( *v2( -- *v3(/0 ) + overlap dup 0<> if ivector* then ; +\ elementwise comparison of two vectors +: )= ( *v1( *v2( -- 1/0 ) dup )size >r over )size r> + <> if 2drop 0 exit then + dup )size 0 do + 2dup i )@ swap i )@ <> if + 2drop unloop 0 exit + then + loop 2drop -1 ; +: subset? ( *v( *s( -- 1/0 ) + 2dup )intersection dup 0= if -rot 2drop exit then + dup >r )= swap drop r> )free ; +: )clone ( *v -- *cv ) + vector->stack ivector* ; +: )erase ( *v -- ) dup )size over )type 3 >> * erase ; +: _last ( *v -- *v idx-of-last-element ) dup )size 1- ; + +clear +previous +Module; \ No newline at end of file diff --git a/include/mgl2/volume.h b/include/mgl2/volume.h new file mode 100644 index 0000000..9ec34ae --- /dev/null +++ b/include/mgl2/volume.h @@ -0,0 +1,85 @@ +/*************************************************************************** + * volume.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_VOL_H_ +#define _MGL_VOL_H_ +#include "mgl2/abstract.h" +//----------------------------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +//----------------------------------------------------------------------------- +/// Draw isosurface for 3d data specified parametrically +void MGL_EXPORT mgl_surf3_xyz_val(HMGL graph, double Val, HCDT x, HCDT y, HCDT z, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3_xyz_val_(uintptr_t *graph, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *stl, const char *opt,int,int); +/// Draw isosurface for 3d data +void MGL_EXPORT mgl_surf3_val(HMGL graph, double Val, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3_val_(uintptr_t *graph, mreal *Val, uintptr_t *a, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data specified parametrically +void MGL_EXPORT mgl_surf3_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data +void MGL_EXPORT mgl_surf3(HMGL graph, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3_(uintptr_t *graph, uintptr_t *a, const char *stl, const char *opt,int,int); + +/// Draw isosurface for 3d data specified parametrically with alpha proportional to b +void MGL_EXPORT mgl_surf3a_xyz_val(HMGL graph, double Val, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3a_xyz_val_(uintptr_t *graph, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurface for 3d data with alpha proportional to b +void MGL_EXPORT mgl_surf3a_val(HMGL graph, double Val, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3a_val_(uintptr_t *graph, mreal *Val, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data specified parametrically with alpha proportional to b +void MGL_EXPORT mgl_surf3a_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3a_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data with alpha proportional to b +void MGL_EXPORT mgl_surf3a(HMGL graph, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3a_(uintptr_t *graph, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); + +/// Draw isosurface for 3d data specified parametrically with color proportional to b +void MGL_EXPORT mgl_surf3c_xyz_val(HMGL graph, double Val, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3c_xyz_val_(uintptr_t *graph, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurface for 3d data with color proportional to b +void MGL_EXPORT mgl_surf3c_val(HMGL graph, double Val, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3c_val_(uintptr_t *graph, mreal *Val, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data specified parametrically with color proportional to b +void MGL_EXPORT mgl_surf3c_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3c_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); +/// Draw isosurfaces for 3d data with color proportional to b +void MGL_EXPORT mgl_surf3c(HMGL graph, HCDT a, HCDT b, const char *stl, const char *opt); +void MGL_EXPORT mgl_surf3c_(uintptr_t *graph, uintptr_t *a, uintptr_t *b, const char *stl, const char *opt,int,int); + +/// Draw a semi-transparent cloud for 3d data specified parametrically +void MGL_EXPORT mgl_cloud_xyz(HMGL graph, HCDT x, HCDT y, HCDT z, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_cloud_xyz_(uintptr_t *graph, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *stl, const char *opt,int,int); +/// Draw a semi-transparent cloud for 3d data +void MGL_EXPORT mgl_cloud(HMGL graph, HCDT a, const char *stl, const char *opt); +void MGL_EXPORT mgl_cloud_(uintptr_t *graph, uintptr_t *a, const char *stl, const char *opt,int,int); + +/// Draw isosurface for 3d beam in curvilinear coordinates +void MGL_EXPORT mgl_beam_val(HMGL graph, double Val, HCDT tr, HCDT g1, HCDT g2, HCDT a, double r, const char *stl, int norm); +void MGL_EXPORT mgl_beam_val_(uintptr_t *gr, mreal *val, uintptr_t *tr, uintptr_t *g1, uintptr_t *g2, uintptr_t *a, mreal *r, const char *sch, int *norm,int l); +/// Draw several isosurfaces for 3d beam in curvilinear coordinates +void MGL_EXPORT mgl_beam(HMGL graph, HCDT tr, HCDT g1, HCDT g2, HCDT a, double r, const char *stl, int norm, int num); +void MGL_EXPORT mgl_beam_(uintptr_t *gr, uintptr_t *tr, uintptr_t *g1, uintptr_t *g2, uintptr_t *a, mreal *r, const char *sch, int *norm, int *num,int l); +//----------------------------------------------------------------------------- +#ifdef __cplusplus +} +#endif +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/window.h b/include/mgl2/window.h new file mode 100644 index 0000000..b4a84ea --- /dev/null +++ b/include/mgl2/window.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * window.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_WINDOW_H_ +#define _MGL_WINDOW_H_ + +#include "mgl2/qt.h" +#include "mgl2/fltk.h" +#include "mgl2/wx.h" +//----------------------------------------------------------------------------- +/// Wrapper class for all windows displaying graphics +class MGL_EXPORT mglWindow : public mglWnd +{ + int wnd; ///< Type of window +public: + mglWindow(const char *title="MathGL") : mglWnd() + { wnd=1; gr = mgl_create_graph_fltk(0,title,0,0); } + mglWindow(int (*draw)(HMGL gr, void *p), const char *title="MathGL", void *par=NULL, int kind=0, void (*load)(void *p)=0) : mglWnd() + { + wnd=kind; + if(wnd==1) gr = mgl_create_graph_qt(draw,title,par,load); + else gr = mgl_create_graph_fltk(draw,title,par,load); + } + mglWindow(int (*draw)(mglGraph *gr), const char *title="MathGL", int kind=0) : mglWnd() + { + wnd=kind; + if(wnd==1) gr = mgl_create_graph_qt(draw?mgl_draw_graph:0,title,(void*)draw,0); + else gr = mgl_create_graph_fltk(draw?mgl_draw_graph:0,title,(void*)draw,0); + } + mglWindow(mglDraw *draw, const char *title="MathGL", int kind=0) : mglWnd() + { + wnd=kind; + if(wnd==1) gr = mgl_create_graph_qt(draw?mgl_draw_class:0,title,draw,mgl_reload_class); + else gr = mgl_create_graph_fltk(draw?mgl_draw_class:0,title,draw,mgl_reload_class); + mgl_set_click_func(gr, mgl_click_class); + } + /// Run main loop for event handling + int Run() { return wnd==0? mgl_fltk_run():mgl_qt_run(); } + /// Run main loop for event handling in separate thread (for FLTK only) + inline int RunThr() { return wnd==0 ? mgl_fltk_thr():0; } +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/wnd.h b/include/mgl2/wnd.h new file mode 100644 index 0000000..e09af52 --- /dev/null +++ b/include/mgl2/wnd.h @@ -0,0 +1,96 @@ +/*************************************************************************** + * wnd.h is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _MGL_WND_H_ +#define _MGL_WND_H_ + +#include "mgl2/mgl.h" +//----------------------------------------------------------------------------- +/// Class for drawing in windows (like, mglCanvasFL, mglCanvasQT and so on) +/// Make inherited class and redefine Draw() function if you don't want to use function pointers. +class MGL_EXPORT mglDraw +{ +public: + virtual int Draw(mglGraph *)=0; ///< Function for drawing + virtual void Reload() {} ///< Function for reloading data + virtual void Click() {} ///< Callback function on mouse click + virtual ~mglDraw() {} +#if MGL_HAVE_PTHREAD + pthread_t thr; + bool running; + mglDraw() { running=false; } + virtual void Calc() {} ///< Function for calculations + inline void Run() ///< Run calculations in other thread + { mgl_draw_thr(this); } +#else + mglDraw(){} +#endif +}; +//----------------------------------------------------------------------------- +extern "C" { +int MGL_EXPORT mgl_draw_graph(HMGL gr, void *p); +// NOTE: MGL_EXPORT mgl_draw_class() and MGL_EXPORT mgl_draw_load() use mglWindow* only. Don't use it with inherited classes +int MGL_EXPORT mgl_draw_class(HMGL gr, void *p); +void MGL_EXPORT mgl_click_class(void *p); +void MGL_EXPORT mgl_reload_class(void *p); +} +//----------------------------------------------------------------------------- +/// Abstract class for windows displaying graphics +class MGL_EXPORT mglWnd : public mglGraph +{ +public: + mglWnd() : mglGraph(-1) {} + virtual int Run()=0; ///< Run main loop for event handling + + inline void ToggleAlpha() ///< Switch on/off transparency (do not overwrite user settings) + { mgl_wnd_toggle_alpha(gr); } + inline void ToggleLight() ///< Switch on/off lighting (do not overwrite user settings) + { mgl_wnd_toggle_light(gr); } + inline void ToggleZoom() ///< Switch on/off zooming by mouse + { mgl_wnd_toggle_zoom(gr); } + inline void ToggleRotate() ///< Switch on/off rotation by mouse + { mgl_wnd_toggle_rotate(gr); } + inline void ToggleNo() ///< Switch off all zooming and rotation + { mgl_wnd_toggle_no(gr); } + inline void Update() ///< Update picture by calling user drawing function + { mgl_wnd_update(gr); } + inline void ReLoad() ///< Reload user data and update picture + { mgl_wnd_reload(gr); } + inline void Adjust() ///< Adjust size of bitmap to window size + { mgl_wnd_adjust(gr); } + inline void NextFrame() ///< Show next frame (if one) + { mgl_wnd_next_frame(gr); } + inline void PrevFrame() ///< Show previous frame (if one) + { mgl_wnd_prev_frame(gr); } + inline void Animation() ///< Run slideshow (animation) of frames + { mgl_wnd_animation(gr); } + void SetClickFunc(void (*func)(void *p)) ///< Callback function for mouse click + { mgl_set_click_func(gr,func); } + + inline void SetDelay(double dt) ///< Set delay for animation in seconds + { mgl_wnd_set_delay(gr, dt); } + inline double GetDelay() ///< Get delay for animation in seconds + { return mgl_wnd_get_delay(gr); } + inline void Setup(bool clf_upd=true, bool showpos=false) + { mgl_setup_window(gr, clf_upd, showpos); } + inline mglPoint LastMousePos() ///< Last mouse position + { mreal x,y,z; mgl_get_last_mouse_pos(gr,&x,&y,&z); return mglPoint(x,y,z); } +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/mgl2/wx.h b/include/mgl2/wx.h new file mode 100644 index 0000000..911fda4 --- /dev/null +++ b/include/mgl2/wx.h @@ -0,0 +1,138 @@ +/*************************************************************************** + * wx.h.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef MGL_WX_H +#define MGL_WX_H +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include +class mglCanvas; +//----------------------------------------------------------------------------- +/// Convert MathGL image to wxBitmap +wxBitmap MGL_EXPORT ConvertFromGraph(HMGL gr); +//----------------------------------------------------------------------------- +/// Class is Wx widget which display MathGL graphics +class MGL_EXPORT wxMathGL : public wxWindow +{ +public: + wxString appName; ///< Application name for message boxes + bool AutoResize; ///< Allow auto resizing (default is false) + + wxMathGL(wxWindow *parent, wxWindowID id=-1, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=0, const wxString& name=wxPanelNameStr); + virtual ~wxMathGL(); + double GetRatio(); + void SetPopup(wxMenu *p) { popup = p; }; ///< Set popup menu pointer + void SetSize(int w, int h); ///< Set window/picture sizes + void SetGraph(HMGL gr); ///< Set grapher object + inline void SetGraph(mglGraph *GR) + { SetGraph(GR->Self()); } + inline HMGL GetGraph() { return (HMGL)gr; } + + /// Set drawing functions and its parameter + inline void SetDraw(int (*func)(mglBase *gr, void *par), void *par=0) + { draw_func = func; draw_par = par; } + inline void SetDraw(mglDraw *dr) + { draw_cl = dr; } + inline void SetDraw(int (*draw)(mglGraph *gr)) + { SetDraw(draw?mgl_draw_graph:0,(void*)draw); } + inline void ZoomRegion(mreal xx1,mreal xx2,mreal yy1, mreal yy2) + { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } + + int GetPer() {return per;}; ///< Get perspective value + int GetPhi() {return phi;}; ///< Get Phi-angle value + int GetTet() {return tet;}; ///< Get Theta-angle value + bool GetAlpha() {return alpha;}; ///< Get transparency state + bool GetLight() {return light;}; ///< Get lightning state + bool GetZoom() {return zoom;}; ///< Get mouse zooming state + bool GetRotate() {return rotate;}; ///< Get mouse rotation state + + void Repaint(); + void Update(); ///< Update picture + void Copy(); ///< copy graphics to clipboard + void Print(); ///< Print plot +// void Stop(); ///< Stop execution + void SetPer(int p); ///< Set perspective value + void SetPhi(int p); ///< Set Phi-angle value + void SetTet(int t); ///< Set Theta-angle value + void SetAlpha(bool a); ///< Switch on/off transparency + void SetLight(bool l); ///< Switch on/off lightning + void SetZoom(bool z); ///< Switch on/off mouse zooming + void SetRotate(bool r); ///< Switch on/off mouse rotation + void ZoomIn(); ///< Zoom in graphics + void ZoomOut(); ///< Zoom out graphics + void Restore(); ///< Restore zoom and rotation to default values +// void Reload(); ///< Reload data and execute script + void ShiftLeft(); ///< Shift graphics to left direction + void ShiftRight(); ///< Shift graphics to right direction + void ShiftUp(); ///< Shift graphics to up direction + void ShiftDown(); ///< Shift graphics to down direction + void ExportPNG(wxString fname=L""); ///< export to PNG file + void ExportPNGs(wxString fname=L""); ///< export to PNG file (no transparency) + void ExportJPG(wxString fname=L""); ///< export to JPEG file + void ExportBPS(wxString fname=L""); ///< export to bitmap EPS file + void ExportEPS(wxString fname=L""); ///< export to vector EPS file + void ExportSVG(wxString fname=L""); ///< export to SVG file + + void Adjust(); ///< Adjust plot size to fill entire window + void NextSlide(); ///< Show next slide + void PrevSlide(); ///< Show previous slide + void Animation(bool st=true); ///< Start animation + + void About(); ///< Show about information + +protected: + void OnPaint(wxPaintEvent& event); + void OnSize(wxSizeEvent& event); + void OnNextSlide(wxTimerEvent& evt); ///< Show next slide + void OnMouseLeftDown(wxMouseEvent &ev); + void OnMouseDown(wxMouseEvent &ev); + void OnMouseLeftUp(wxMouseEvent &ev); + void OnMouseRightUp(wxMouseEvent &ev); + void OnMouseMove(wxMouseEvent &ev); +// void MousePressEvent(QMouseEvent *); +// void MouseReleaseEvent(QMouseEvent *); +// void MouseMoveEvent(QMouseEvent *); + + mglCanvas *gr; ///< pointer to grapher + void *draw_par; ///< Parameters for drawing function mglCanvasWnd::DrawFunc. + /// Drawing function for window procedure. It should return the number of frames. + int (*draw_func)(mglBase *gr, void *par); + mglDraw *draw_cl; + + wxString MousePos; ///< Last mouse position + wxBitmap pic; ///< Pixmap for drawing (changed by update) + double tet, phi; ///< Rotation angles + double per; ///< Value of perspective ( must be in [0,1) ) + bool alpha; ///< Transparency state + bool light; ///< Lightning state + bool zoom; ///< Mouse zoom state + bool rotate; ///< Mouse rotation state + mreal x1,x2,y1,y2; ///< Zoom in region + bool showMessage; ///< Flag for showing messages (enabled by each execute()) + wxMenu *popup; ///< Pointer to pop-up menu + wxTimer *timer; ///< Timer for animation + DECLARE_EVENT_TABLE() +private: + int x0, y0, xe, ye; ///< Temporary variables for mouse +}; +//----------------------------------------------------------------------------- +#endif diff --git a/include/xpm/accessories-calculator.png b/include/xpm/accessories-calculator.png new file mode 100644 index 0000000..9248971 Binary files /dev/null and b/include/xpm/accessories-calculator.png differ diff --git a/include/xpm/accessories-calculator.xpm b/include/xpm/accessories-calculator.xpm new file mode 100644 index 0000000..7a35ccb --- /dev/null +++ b/include/xpm/accessories-calculator.xpm @@ -0,0 +1,112 @@ +/* XPM */ +static const char * accessories_calculator_xpm[] = { +"16 16 93 2", +" c None", +". c #555753", +"+ c #B8BBB3", +"@ c #858971", +"# c #787C66", +"$ c #83876F", +"% c #7A7E68", +"& c #7D816A", +"* c #777B5E", +"= c #555843", +"- c #585B45", +"; c #474938", +"> c #393B2D", +", c #717559", +"' c #989C8A", +") c #969A88", +"! c #979B89", +"~ c #44494A", +"{ c #3A4041", +"] c #3F4446", +"^ c #383D3F", +"/ c #303638", +"( c #303537", +"_ c #2F3537", +": c #313739", +"< c #9C9FA1", +"[ c #5B5C5C", +"} c #595A5C", +"| c #737678", +"1 c #5B5C5E", +"2 c #595A5B", +"3 c #66696B", +"4 c #595A5A", +"5 c #585858", +"6 c #616365", +"7 c #626567", +"8 c #515354", +"9 c #535555", +"0 c #535455", +"a c #5E605C", +"b c #6B6D6B", +"c c #808080", +"d c #7F7F7F", +"e c #535353", +"f c #7E7E7E", +"g c #818181", +"h c #555555", +"i c #575757", +"j c #565758", +"k c #848484", +"l c #898989", +"m c #696A69", +"n c #545454", +"o c #555556", +"p c #787878", +"q c #545657", +"r c #878787", +"s c #888888", +"t c #87898A", +"u c #505051", +"v c #505152", +"w c #646667", +"x c #535354", +"y c #515151", +"z c #616364", +"A c #515252", +"B c #606365", +"C c #5B5B5B", +"D c #5A5A5A", +"E c #7D7D7D", +"F c #828282", +"G c #545455", +"H c #585859", +"I c #696A68", +"J c #858585", +"K c #565656", +"L c #838383", +"M c #8A8A8A", +"N c #8D8D8D", +"O c #858788", +"P c #646666", +"Q c #525353", +"R c #616262", +"S c #555757", +"T c #5E5F5F", +"U c #9B9B9B", +"V c #858686", +"W c #888989", +"X c #868686", +"Y c #878888", +"Z c #6C6D6B", +"` c #757674", +" . c #787977", +". . . . . . . . . . . . . . . . ", +". + + + + + + + + + + + + + + . ", +". + @ @ @ @ @ @ @ # $ % & @ + . ", +". + * * * * * * * = - ; > , + . ", +". + ' ' ' ' ' ' ' ) ! ) ! ' + . ", +". ~ + + + + + + + + + + + + { . ", +". ] ^ / / ( _ _ _ _ _ _ _ _ : . ", +". < [ } | 1 2 3 4 5 6 7 8 9 0 . ", +"a b c d e f g h d g i j k l k . ", +". m d f n f f o p d i q r s r . ", +". t u v w x y z A y 6 B 5 C D . ", +". m c d 9 E g n F k G H r s s . ", +". I k E y c J K L J K 5 M N M . ", +". O n G P Q K R S K T 5 M U M . ", +". O V V W V X Y X X Y Z ` .` . ", +". . . . . . . . . . . . . . . . "}; diff --git a/include/xpm/alpha.png b/include/xpm/alpha.png new file mode 100644 index 0000000..fdb8836 Binary files /dev/null and b/include/xpm/alpha.png differ diff --git a/include/xpm/alpha.xpm b/include/xpm/alpha.xpm new file mode 100644 index 0000000..1c41468 --- /dev/null +++ b/include/xpm/alpha.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static const char * alpha_xpm[] = { +"16 16 7 1", +" c None", +"! c #000000", +"# c #0000FF", +"$ c #000080", +"% c #008080", +"& c #FFFFFF", +"' c #00FFFF", +" ", +" ", +" #$$$$$$ ", +" !$!!$!!!!# ", +" #%%&$%''!'%'$ ", +"#%##!#$'%#%%##! ", +" !%%!$&%%'!!%%$ ", +" #''%#%!$##''% ", +" %''##%&&%''# ", +" %'%#%&&%'# ", +" #'%#%&$'% ", +" $'#%&%% ", +" %%%#%# ", +" #!%$% ", +" #!$ ", +" !# "}; diff --git a/include/xpm/alpha_on.xpm b/include/xpm/alpha_on.xpm new file mode 100644 index 0000000..58e50f7 --- /dev/null +++ b/include/xpm/alpha_on.xpm @@ -0,0 +1,26 @@ +/* XPM */ +static const char * alpha_on_xpm[] = { +"16 16 7 1", +" c None", +"! c #000000", +"# c #FF0000", +"$ c #800000", +"% c #808000", +"& c #FFFFFF", +"' c #FFFF00", +" ", +" ", +" #$$$$$$ ", +" !$!!$!!!!# ", +" #%%&$%''!'%'$ ", +"#%##!#$'%#%%##! ", +" !%%!$&%%'!!%%$ ", +" #''%#%!$##''% ", +" %''##%&&%''# ", +" %'%#%&&%'# ", +" #'%#%&$'% ", +" $'#%&%% ", +" %%%#%# ", +" #!%$% ", +" #!$ ", +" !# "}; diff --git a/include/xpm/arrow_a.xpm b/include/xpm/arrow_a.xpm new file mode 100644 index 0000000..457c0aa --- /dev/null +++ b/include/xpm/arrow_a.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_a_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ... ", +" .... ", +" ..... ", +" ...... ", +" ...............", +" ...... ", +" ..... ", +" .... ", +" ... ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_d.xpm b/include/xpm/arrow_d.xpm new file mode 100644 index 0000000..834f703 --- /dev/null +++ b/include/xpm/arrow_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . ", +" ... ", +" ..... ", +" ....... ", +" ...............", +" ....... ", +" ..... ", +" ... ", +" . ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_i.xpm b/include/xpm/arrow_i.xpm new file mode 100644 index 0000000..a8c617e --- /dev/null +++ b/include/xpm/arrow_i.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_i_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ...............", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_k.xpm b/include/xpm/arrow_k.xpm new file mode 100644 index 0000000..840d325 --- /dev/null +++ b/include/xpm/arrow_k.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_k_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" .. ... ", +" .. .... ", +" .. ..... ", +" ........ ", +" ...............", +" ........ ", +" .. ..... ", +" .. .... ", +" .. ... ", +" .. ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_n.xpm b/include/xpm/arrow_n.xpm new file mode 100644 index 0000000..305238b --- /dev/null +++ b/include/xpm/arrow_n.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_n_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ..............", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_o.xpm b/include/xpm/arrow_o.xpm new file mode 100644 index 0000000..6f4b583 --- /dev/null +++ b/include/xpm/arrow_o.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_o_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" .... ", +" ...... ", +" ........ ", +" ........ ", +" ..............", +" ........ ", +" ........ ", +" ....... ", +" .... ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_s.xpm b/include/xpm/arrow_s.xpm new file mode 100644 index 0000000..ddeeb7f --- /dev/null +++ b/include/xpm/arrow_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ........ ", +" ........ ", +" ........ ", +" ........ ", +" ..............", +" ........ ", +" ........ ", +" ........ ", +" ........ ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_t.xpm b/include/xpm/arrow_t.xpm new file mode 100644 index 0000000..71ff9dc --- /dev/null +++ b/include/xpm/arrow_t.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_t_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" ...............", +" ........ ", +" ...... ", +" .... ", +" .. ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/arrow_v.xpm b/include/xpm/arrow_v.xpm new file mode 100644 index 0000000..038a3e5 --- /dev/null +++ b/include/xpm/arrow_v.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_v_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ... ", +" .... ", +" ..... ", +" ...... ", +" ...........", +" ...... ", +" ..... ", +" .... ", +" ... ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/axis_sh.xpm b/include/xpm/axis_sh.xpm new file mode 100644 index 0000000..eab287c --- /dev/null +++ b/include/xpm/axis_sh.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * axis_sh_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" ", +" . ", +". . + ", +" . +++ ", +" . + ", +". . + + + ", +" . +++++++++ ", +" . + + + ", +". . + ", +" . +++ ", +" . + ", +". . ", +" . ", +" ............. ", +". ", +" . . . . . "}; diff --git a/include/xpm/box.xpm b/include/xpm/box.xpm new file mode 100644 index 0000000..e2d9d12 --- /dev/null +++ b/include/xpm/box.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * box_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #666666", +" ", +" ......... ", +" .+ .. ", +" . + . . ", +" . + . . ", +" . + . . ", +" ......... . ", +" . + . . ", +" . + . . ", +" . +++.++++. ", +" . + . . ", +" . + . . ", +" . + . . ", +" .+ .. ", +" ......... ", +" "}; diff --git a/include/xpm/cons.xpm b/include/xpm/cons.xpm new file mode 100644 index 0000000..b22b0f4 --- /dev/null +++ b/include/xpm/cons.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * cons_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #0000FF", +"@ c #FF0000", +" ", +" .............. ", +" . . ", +" . . . . . . .. ", +" . . ", +" . . . . . . .. ", +" .............. ", +" ", +" +++++++++++++ ", +" +++++++++ ", +" +++++ ", +" + ", +" @@@@@@@@@@@@@@ ", +" @ @ @ @ @ @ @@ ", +" @@@@@@@@@@@@@@ ", +" "}; diff --git a/include/xpm/copy.xpm b/include/xpm/copy.xpm new file mode 100644 index 0000000..bfaecb1 --- /dev/null +++ b/include/xpm/copy.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * copy_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #FFFFFF", +"@ c #808080", +" ", +" ", +" ........ ", +" .++++++.@ ", +" .+@@@@+.@ ", +" .++........ ", +" .+@.++++++.@ ", +" .++.+....+.@ ", +" .+@.++++++.@ ", +" .++.+....+.@ ", +" ....++++++.@ ", +" @.+....+.@ ", +" .++++++.@ ", +" ........@ ", +" @@@@@@@@ ", +" "}; diff --git a/include/xpm/crop.xpm b/include/xpm/crop.xpm new file mode 100644 index 0000000..e18a730 --- /dev/null +++ b/include/xpm/crop.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * crop_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . ", +" ", +" . ", +" ", +" . . ...... ", +" . . ", +" . . ", +" . . ", +" . . ", +" ...... . . ", +" ", +" . ", +" ", +" . ", +" "}; diff --git a/include/xpm/curve.xpm b/include/xpm/curve.xpm new file mode 100644 index 0000000..88e37e3 --- /dev/null +++ b/include/xpm/curve.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * curve_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .", +" .", +" . ", +" . ", +" . ", +" . ", +" .. ", +" .. ", +" .. ", +" .. ", +" . ", +" . ", +" . ", +" . ", +". ", +". "}; diff --git a/include/xpm/dash_d.xpm b/include/xpm/dash_d.xpm new file mode 100644 index 0000000..6892ce6 --- /dev/null +++ b/include/xpm/dash_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +". . . . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_e.xpm b/include/xpm/dash_e.xpm new file mode 100644 index 0000000..13eaf63 --- /dev/null +++ b/include/xpm/dash_e.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_e_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +". . . . . . . . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_i.xpm b/include/xpm/dash_i.xpm new file mode 100644 index 0000000..2ad1f1c --- /dev/null +++ b/include/xpm/dash_i.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_i_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".. . .. . .. . .", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_j.xpm b/include/xpm/dash_j.xpm new file mode 100644 index 0000000..70a9cc4 --- /dev/null +++ b/include/xpm/dash_j.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_j_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... . .... .", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_l.xpm b/include/xpm/dash_l.xpm new file mode 100644 index 0000000..4346c08 --- /dev/null +++ b/include/xpm/dash_l.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_l_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... .... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_m.xpm b/include/xpm/dash_m.xpm new file mode 100644 index 0000000..7cd2b39 --- /dev/null +++ b/include/xpm/dash_m.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_m_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".. .. .. .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dash_s.xpm b/include/xpm/dash_s.xpm new file mode 100644 index 0000000..4edb6c5 --- /dev/null +++ b/include/xpm/dash_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +"................", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/dialog-information.png b/include/xpm/dialog-information.png new file mode 100644 index 0000000..8851b99 Binary files /dev/null and b/include/xpm/dialog-information.png differ diff --git a/include/xpm/diff.xpm b/include/xpm/diff.xpm new file mode 100644 index 0000000..b90448a --- /dev/null +++ b/include/xpm/diff.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * diff_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" . . . ", +" . . ", +" .... . ", +" . . . .. ", +" . . . . . ", +" .. . . ", +" . .... ", +" . . . ", +" . . . . .", +" . .. . ", +" . .", +" ", +" "}; diff --git a/include/xpm/diff2.xpm b/include/xpm/diff2.xpm new file mode 100644 index 0000000..7a2d7eb --- /dev/null +++ b/include/xpm/diff2.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * diff2_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ", +" ", +" . ", +" .. ", +" .+.. ", +" +. ..+ ", +" . .. ", +" .+ +.. ", +" +. ..+ ", +" . .. ", +" .+ +.. ", +" ............ ", +" ", +" "}; diff --git a/include/xpm/document-export.png b/include/xpm/document-export.png new file mode 100644 index 0000000..eb82440 Binary files /dev/null and b/include/xpm/document-export.png differ diff --git a/include/xpm/document-export.xpm b/include/xpm/document-export.xpm new file mode 100644 index 0000000..489a4f4 --- /dev/null +++ b/include/xpm/document-export.xpm @@ -0,0 +1,166 @@ +/* XPM */ +static const char * document_export_xpm[] = { +"16 16 147 2", +" c None", +". c #38678B", +"+ c #3D698A", +"@ c #4A7180", +"# c #58787A", +"$ c #B1CEE6", +"% c #D0DFEF", +"& c #C5DBEC", +"* c #9BC2DF", +"= c #688BA0", +"- c #436E88", +"; c #6B7F88", +"> c #667173", +", c #627075", +"' c #4A6D85", +") c #41749A", +"! c #44789F", +"~ c #9EBFD9", +"{ c #C1D9EB", +"] c #5186AF", +"^ c #4E6A7D", +"/ c #6E99B6", +"( c #ABCBE2", +"_ c #92B7D3", +": c #547D9B", +"< c #D5DFE5", +"[ c #7798B0", +"} c #79A7CA", +"| c #8FB3CE", +"1 c #3D6B8E", +"2 c #ACBCC3", +"3 c #5892BD", +"4 c #EF9800", +"5 c #ECA307", +"6 c #BDD552", +"7 c #98BFDC", +"8 c #719FBF", +"9 c #739FC0", +"0 c #96BBD8", +"a c #95A9AF", +"b c #02ABF0", +"c c #0074F6", +"d c #F97200", +"e c #FE3C00", +"f c #FF3500", +"g c #CAC6AC", +"h c #ABC8DF", +"i c #92A6AC", +"j c #BFE6E5", +"k c #1CFFDF", +"l c #32FFCA", +"m c #F99A00", +"n c #FF7400", +"o c #FDA917", +"p c #E4E822", +"q c #9DE4A5", +"r c #37698D", +"s c #ACCBE3", +"t c #3B6B8F", +"u c #8BA4AF", +"v c #9EDEE9", +"w c #8CFDCB", +"x c #BBFF41", +"y c #ECEA10", +"z c #F2C505", +"A c #B2FA4B", +"B c #53F8BE", +"C c #3BC4F1", +"D c #328AFE", +"E c #AABCD1", +"F c #3F6C8E", +"G c #9AAEB4", +"H c #BBF8EA", +"I c #A0FE7E", +"J c #EEEEEE", +"K c #FAC004", +"L c #FDB701", +"M c #DDE01B", +"N c #49FEB4", +"O c #00AEFF", +"P c #0039FF", +"Q c #0024B3", +"R c #0029CA", +"S c #0057FF", +"T c #03BDFB", +"U c #28FFD3", +"V c #85FE79", +"W c #E3FF18", +"X c #DDFE1F", +"Y c #C7FF34", +"Z c #8BFF72", +"` c #F0CA07", +" . c #AFFA4D", +".. c #59FEA3", +"+. c #2FE6CE", +"@. c #21CBDE", +"#. c #17CDE7", +"$. c #13DBEB", +"%. c #13FFE9", +"&. c #16FFE5", +"*. c #43FABA", +"=. c #3DF5C0", +"-. c #2BECD2", +";. c #08D3F4", +">. c #009FFF", +",. c #F89A00", +"'. c #FE5F00", +"). c #FB4D00", +"!. c #FC5500", +"~. c #FE7E00", +"{. c #F8C805", +"]. c #BDFB3F", +"^. c #51FFAC", +"/. c #0BDAF2", +"(. c #0082FF", +"_. c #0045FC", +":. c #0037EC", +"<. c #003DFE", +"[. c #0041FF", +"}. c #F86B00", +"|. c #E60000", +"1. c #B60000", +"2. c #B30000", +"3. c #BB0000", +"4. c #EE1200", +"5. c #FF9A00", +"6. c #AAFF53", +"7. c #0BEBF1", +"8. c #006DFF", +"9. c #0035F2", +"0. c #0037E9", +"a. c #006CFF", +"b. c #0ED7F0", +"c. c #F88F01", +"d. c #F94100", +"e. c #E92400", +"f. c #E21D00", +"g. c #EA2400", +"h. c #FA4200", +"i. c #FF9100", +"j. c #F2D10B", +"k. c #B7F746", +"l. c #80F87D", +"m. c #6EF18E", +"n. c #75F389", +"o. c #94FB69", +"p. c #D2EA2B", +" . . . + @ # ", +" $ % & * = - ", +"; > , ' ) ! ~ { ] ^ ", +" / . ( _ : < ", +" [ . } | 1 2 ", +" . . . . } 3 . . . . ", +" 4 5 6 . 7 8 8 8 9 0 . a b c ", +" d e f g . 7 9 9 h . i j k l ", +" m n o p q r s 7 t u v w x y ", +" z A B C D E F . G H I J K L ", +" M N O P Q R S T U V W X Y Z ", +" ` ...+.@.#.$.%.&.*.=.-.;.>. ", +" ,.'.).!.~.{.].^./.(._.:.<.[. ", +" }.|.1.2.3.4.5.6.7.8.9.0.a.b. ", +" c.d.e.f.g.h.i.j.k.l.m.n.o.p. ", +" "}; diff --git a/include/xpm/document-import.png b/include/xpm/document-import.png new file mode 100644 index 0000000..0b4e816 Binary files /dev/null and b/include/xpm/document-import.png differ diff --git a/include/xpm/document-import.xpm b/include/xpm/document-import.xpm new file mode 100644 index 0000000..39c5113 --- /dev/null +++ b/include/xpm/document-import.xpm @@ -0,0 +1,189 @@ +/* XPM */ +static const char * document_import_xpm[] = { +"16 16 170 2", +" c None", +". c #FB6801", +"+ c #FF3F00", +"@ c #FF6200", +"# c #EDDE11", +"$ c #58FFA6", +"% c #07C2F8", +"& c #0070FF", +"* c #0064FF", +"= c #0195FF", +"- c #0AD3F4", +"; c #2CFFD1", +"> c #5CFEA1", +", c #7A7A7A", +"' c #797979", +") c #FAA302", +"! c #F1B50D", +"~ c #BFE240", +"{ c #61F29D", +"] c #10BFEE", +"^ c #0066FF", +"/ c #0043FF", +"( c #0170FF", +"_ c #0EC8F0", +": c #59FCA5", +"< c #C6FB38", +"[ c #F5CE09", +"} c #787878", +"| c #C9C9C9", +"1 c #C7C7C7", +"2 c #DFE11A", +"3 c #56FAA8", +"4 c #08A6F7", +"5 c #004EE6", +"6 c #0032C9", +"7 c #0041FF", +"8 c #0297FD", +"9 c #27F0D6", +"0 c #91FF6C", +"a c #E1FF1B", +"b c #EDEC10", +"c c #E5E019", +"d c #737373", +"e c #C5C5C5", +"f c #B0B0B0", +"g c #DDE31D", +"h c #0FB6F0", +"i c #047CF5", +"j c #0374F4", +"k c #049DFB", +"l c #0FE8EF", +"m c #43FFBB", +"n c #7EFF81", +"o c #8CFF72", +"p c #65FA99", +"q c #2CE1D3", +"r c #6E6E6E", +"s c #C1C1C0", +"t c #ACACAC", +"u c #F9A502", +"v c #F5A10A", +"w c #E0A31C", +"x c #CCB833", +"y c #B3DD4C", +"z c #83FC7B", +"A c #2DFFD0", +"B c #0DDEF1", +"C c #059FF9", +"D c #0279F8", +"E c #0062FD", +"F c #004DFF", +"G c #6A6A6A", +"H c #BDBDBD", +"I c #A9A9A9", +"J c #FA6201", +"K c #E00600", +"L c #C00000", +"M c #C40100", +"N c #ED1C00", +"O c #FAA205", +"P c #85FF79", +"Q c #08C2F6", +"R c #004CFC", +"S c #0030BE", +"T c #0051EC", +"U c #0AA6F5", +"V c #656565", +"W c #B7B7B7", +"X c #A6A6A6", +"Y c #FB7E01", +"Z c #F32E00", +"` c #DE1A00", +" . c #DE1900", +".. c #F42F00", +"+. c #FF8400", +"@. c #E6DE18", +"#. c #91F96D", +"$. c #60EA9E", +"%. c #5AE5A4", +"&. c #73F18B", +"*. c #B7F047", +"=. c #5F5F5F", +"-. c #B3B3B3", +";. c #406CA5", +">. c #3868A5", +",. c #3768A5", +"'. c #3666A5", +"). c #3566A5", +"!. c #3566A4", +"~. c #3465A4", +"{. c #3767A6", +"]. c #5B5B5B", +"^. c #AEAEAE", +"/. c #C0D5EA", +"(. c #C1D5EA", +"_. c #C1D6EA", +":. c #BBD2E8", +"<. c #3465A5", +"[. c #565656", +"}. c #C3D6EA", +"|. c #92B5DB", +"1. c #95B8DC", +"2. c #B9D0E7", +"3. c #3466A4", +"4. c #515151", +"5. c #A5A5A4", +"6. c #3666A4", +"7. c #C5D7EB", +"8. c #98B9DD", +"9. c #95B7DC", +"0. c #B8CEE7", +"a. c #4C4C4C", +"b. c #A1A1A1", +"c. c #3767A5", +"d. c #BFD2E9", +"e. c #9BBADD", +"f. c #9ABADD", +"g. c #96B7DC", +"h. c #8FB2DA", +"i. c #8BB0D8", +"j. c #B1C9E4", +"k. c #484848", +"l. c #9B9B9B", +"m. c #A5C1E1", +"n. c #8EB2D9", +"o. c #8AAFD8", +"p. c #85ACD7", +"q. c #83AAD6", +"r. c #81A9D5", +"s. c #7EA7D4", +"t. c #79A3D3", +"u. c #77A2D2", +"v. c #7BA5D3", +"w. c #95B6DB", +"x. c #3567A6", +"y. c #494949", +"z. c #999999", +"A. c #3968A5", +"B. c #94B5DB", +"C. c #82AAD5", +"D. c #7DA6D4", +"E. c #7FA8D4", +"F. c #85ABD5", +"G. c #7E8896", +"H. c #5588BF", +"I. c #5689C0", +"J. c #4B7EB7", +"K. c #3667A6", +"L. c #454A51", +"M. c #3565A4", +" . + @ # $ % & * = - ; > ", +", ' ' ) ! ~ { ] ^ / ( _ : < [ ", +"} | 1 2 3 4 5 6 7 8 9 0 a b c ", +"d e f g 3 h i j k l m n o p q ", +"r s t u v w x y z A B C D E F ", +"G H I J K L M N O P Q R S T U ", +"V W X Y Z ` ...+.@.#.$.%.&.*. ", +"=.-.;.>.>.,.'.'.).!.!.!.~.~.~.{.", +"].^.)././././././.(._._._._.:.<.", +"[.I !.}.|.|.|.|.|.|.|.|.|.1.2.3.", +"4.5.6.7.8.8.8.8.8.8.8.8.8.9.0.).", +"a.b.c.d.e.f.f.f.f.f.f.g.h.i.j.).", +"k.l.>.m.n.o.p.q.r.s.t.u.u.v.w.x.", +"y.z.A.B.C.D.D.D.D.D.D.D.D.E.F.'.", +"k.G.A.H.I.I.I.I.I.I.I.I.I.I.J.K.", +"L.~.~.~.~.~.~.~.~.~.~.~.~.~.M. "}; diff --git a/include/xpm/document-new.png b/include/xpm/document-new.png new file mode 100644 index 0000000..4c3efdd Binary files /dev/null and b/include/xpm/document-new.png differ diff --git a/include/xpm/document-new.xpm b/include/xpm/document-new.xpm new file mode 100644 index 0000000..6336507 --- /dev/null +++ b/include/xpm/document-new.xpm @@ -0,0 +1,78 @@ +/* XPM */ +static const char * document_new_xpm[] = { +"16 16 59 1", +" c None", +". c #9E9E9E", +"+ c #818181", +"@ c #8C8C7C", +"# c #9F9F72", +"$ c #AFAE6A", +"% c #EDE436", +"& c #FFFFFF", +"* c #F2EE9B", +"= c #F7F069", +"- c #FAF24D", +"; c #F7EF46", +"> c #F4EB28", +", c #ECECEC", +"' c #EAEAEA", +") c #EBEBEB", +"! c #F0EDB4", +"~ c #F7F06A", +"{ c #FCF43A", +"] c #FDF668", +"^ c #FDF66A", +"/ c #FBF23C", +"( c #F9EF1E", +"_ c #F2EE9C", +": c #FAF24E", +"< c #FDF667", +"[ c #FEFAB5", +"} c #FEFAB8", +"| c #FDF56B", +"1 c #FAEF22", +"2 c #F3EF9B", +"3 c #FEFABB", +"4 c #FEFBBF", +"5 c #FDF66E", +"6 c #FAF022", +"7 c #EDEDED", +"8 c #F1EEB1", +"9 c #F8F167", +"0 c #FDF440", +"a c #FDF771", +"b c #FDF772", +"c c #FCF343", +"d c #F6EC24", +"e c #EFEEE0", +"f c #F4EF96", +"g c #F8F163", +"h c #FBF346", +"i c #FBF345", +"j c #F7EF5D", +"k c #EEEEEE", +"l c #EEEEE2", +"m c #F3F0B1", +"n c #F5F092", +"o c #F5F09A", +"p c #969677", +"q c #EFEFEF", +"r c #F0F0F0", +"s c #F1F1F1", +"t c #F2F2F2", +".++++++++@#$% ", +"+&&&&&&&&*=-;> ", +"+&,'')))!~{]^/( ", +"+&'')),,_:<[}|1 ", +"+&')),,,2:^3456 ", +"+&)),,,7890abcd ", +"+&)),,77efghij ", +"+&),,77kklmnop ", +"+&,,77kkqqqr&+ ", +"+&,,77kkqqrr&+ ", +"+&,7kkqqrsss&+ ", +"+&77kkqrrsst&+ ", +"+&77kqqrrstt&+ ", +"+&&&&&&&&&&&&+ ", +".++++++++++++. ", +" "}; diff --git a/include/xpm/document-open.png b/include/xpm/document-open.png new file mode 100644 index 0000000..ab94046 Binary files /dev/null and b/include/xpm/document-open.png differ diff --git a/include/xpm/document-open.xpm b/include/xpm/document-open.xpm new file mode 100644 index 0000000..10b148b --- /dev/null +++ b/include/xpm/document-open.xpm @@ -0,0 +1,156 @@ +/* XPM */ +static const char * document_open_xpm[] = { +"16 16 137 2", +" c None", +". c #565854", +"+ c #575955", +"@ c #595B57", +"# c #5A5C58", +"$ c #5F615D", +"% c #7A7A7A", +"& c #797979", +"* c #F7F7F7", +"= c #F9F9F9", +"- c #FAFAFA", +"; c #FBFBFB", +"> c #FCFCFC", +", c #A2A3A2", +"' c #5B5C58", +") c #787878", +"! c #C9C9C9", +"~ c #C7C7C7", +"{ c #C4C4C4", +"] c #555753", +"^ c #DADADA", +"/ c #D3D3D3", +"( c #D2D2D2", +"_ c #CFCFCF", +": c #CDCDCD", +"< c #FEFEFE", +"[ c #939392", +"} c #5B5E5A", +"| c #737373", +"1 c #C5C5C5", +"2 c #B0B0B0", +"3 c #ACACAC", +"4 c #DCDCDC", +"5 c #9C9D9C", +"6 c #D5D5D4", +"7 c #FDFDFD", +"8 c #969796", +"9 c #5B5D59", +"0 c #6E6E6E", +"a c #C1C1C0", +"b c #AAAAAA", +"c c #E2E2E2", +"d c #DFDFDF", +"e c #DEDEDE", +"f c #DDDDDD", +"g c #E0E0E0", +"h c #E9E9E9", +"i c #E5E5E5", +"j c #D0D0D0", +"k c #5D5F5B", +"l c #6A6A6A", +"m c #BDBDBD", +"n c #A9A9A9", +"o c #A5A5A5", +"p c #E6E6E6", +"q c #9FA09E", +"r c #9C9D9B", +"s c #E3E3E3", +"t c #D0D1D0", +"u c #656565", +"v c #B7B7B7", +"w c #A6A6A6", +"x c #A1A1A1", +"y c #EBEBEB", +"z c #EAEAEA", +"A c #E8E8E8", +"B c #E7E7E7", +"C c #D9D9D9", +"D c #5B5C59", +"E c #5F5F5F", +"F c #B3B3B3", +"G c #406CA5", +"H c #3868A5", +"I c #3768A5", +"J c #3666A5", +"K c #3566A5", +"L c #3566A4", +"M c #3465A4", +"N c #3767A6", +"O c #5B5B5B", +"P c #AEAEAE", +"Q c #C0D5EA", +"R c #C1D5EA", +"S c #C1D6EA", +"T c #BBD2E8", +"U c #3465A5", +"V c #565656", +"W c #C3D6EA", +"X c #92B5DB", +"Y c #95B8DC", +"Z c #B9D0E7", +"` c #3466A4", +" . c #515151", +".. c #A5A5A4", +"+. c #3666A4", +"@. c #C5D7EB", +"#. c #98B9DD", +"$. c #95B7DC", +"%. c #B8CEE7", +"&. c #4C4C4C", +"*. c #3767A5", +"=. c #BFD2E9", +"-. c #9BBADD", +";. c #9ABADD", +">. c #96B7DC", +",. c #8FB2DA", +"'. c #8BB0D8", +"). c #B1C9E4", +"!. c #484848", +"~. c #9B9B9B", +"{. c #A5C1E1", +"]. c #8EB2D9", +"^. c #8AAFD8", +"/. c #85ACD7", +"(. c #83AAD6", +"_. c #81A9D5", +":. c #7EA7D4", +"<. c #79A3D3", +"[. c #77A2D2", +"}. c #7BA5D3", +"|. c #95B6DB", +"1. c #3567A6", +"2. c #494949", +"3. c #999999", +"4. c #3968A5", +"5. c #94B5DB", +"6. c #82AAD5", +"7. c #7DA6D4", +"8. c #7FA8D4", +"9. c #85ABD5", +"0. c #7E8896", +"a. c #5588BF", +"b. c #5689C0", +"c. c #4B7EB7", +"d. c #3667A6", +"e. c #454A51", +"f. c #3565A4", +" . + . + + @ # $ ", +"% & & & . * = - ; ; > , ' ", +") ! ~ { ] ^ / / ( _ : < [ } ", +"| 1 2 3 ] 4 5 5 5 5 6 < 7 8 9 ", +"0 a 3 b . c d e e f g h i j k ", +"l m n o . p q r r r f s s t 9 ", +"u v w x + y z z h h A A B C D ", +"E F G H H I J J K L L L M M M N ", +"O P K Q Q Q Q Q Q R S S S S T U ", +"V n L W X X X X X X X X X Y Z ` ", +" ...+.@.#.#.#.#.#.#.#.#.#.$.%.K ", +"&.x *.=.-.;.;.;.;.;.;.>.,.'.).K ", +"!.~.H {.].^./.(._.:.<.[.[.}.|.1.", +"2.3.4.5.6.7.7.7.7.7.7.7.7.8.9.J ", +"!.0.4.a.b.b.b.b.b.b.b.b.b.b.c.d.", +"e.M M M M M M M M M M M M M f. "}; diff --git a/include/xpm/document-print.png b/include/xpm/document-print.png new file mode 100644 index 0000000..35c37bd Binary files /dev/null and b/include/xpm/document-print.png differ diff --git a/include/xpm/document-print.xpm b/include/xpm/document-print.xpm new file mode 100644 index 0000000..21170e9 --- /dev/null +++ b/include/xpm/document-print.xpm @@ -0,0 +1,86 @@ +/* XPM */ +static const char * document_print_xpm[] = { +"16 16 67 1", +" c None", +". c #AAABA9", +"+ c #F9F9F9", +"@ c #888A85", +"# c #F8F8F8", +"$ c #C4C4C4", +"% c #F1F1F1", +"& c #F3F3F3", +"* c #F7F7F7", +"= c #C6C6C6", +"- c #C7C7C7", +"; c #E0E0E0", +"> c #E2E2E2", +", c #E3E3E3", +"' c #E5E5E5", +") c #E6E6E6", +"! c #E7E7E7", +"~ c #F6F6F6", +"{ c #F5F5F5", +"] c #F5F5F6", +"^ c #7D7E7C", +"/ c #858684", +"( c #ABABAB", +"_ c #A9A9A9", +": c #AAAAAA", +"< c #FCFCFC", +"[ c #F4F4F4", +"} c #E8E8E8", +"| c #FDFDFD", +"1 c #D4D4D4", +"2 c #EDEDED", +"3 c #AEAEAE", +"4 c #DFDFDF", +"5 c #E1E1E1", +"6 c #DCDCDC", +"7 c #9F9F9F", +"8 c #CDCCCB", +"9 c #F0F0F0", +"0 c #CCCBCB", +"a c #DDDDDD", +"b c #DEDEDE", +"c c #D9D9D9", +"d c #8C8B8A", +"e c #C5C5C5", +"f c #F2F2F2", +"g c #BEBEBE", +"h c #868584", +"i c #7A7978", +"j c #767574", +"k c #787675", +"l c #767472", +"m c #72716F", +"n c #747372", +"o c #B2B2B2", +"p c #BBBBBB", +"q c #B9B9B9", +"r c #B8B8B8", +"s c #B8B8B7", +"t c #B6B6B6", +"u c #B3B3B3", +"v c #B5B5B5", +"w c #B7B7B7", +"x c #ECECEC", +"y c #D7D7D7", +"z c #D8D8D8", +"A c #D5D5D5", +"B c #D6D6D6", +" ", +" ........... ", +" .++++@+++#. ", +" .+$$@@@$$#. ", +" .+%@@@@@&*. ", +" .*$$=@=--#. ", +" .*;>,@')!*. ", +" .~{{{{]]~*. ", +" ^^/(_(((((_:/^^", +" ^<+[[[[[[[[[)}^", +" ^|123&4,5>;678^", +" ^90aabbb6aacde^", +" ^fghiijklmnkoe^", +" ^fpqqrrstuvwr-^", +" ^xyzzyyyyyAyB1^", +" ^^^^^^^^^^^^^^^"}; diff --git a/include/xpm/document-properties.png b/include/xpm/document-properties.png new file mode 100644 index 0000000..ab0e8ea Binary files /dev/null and b/include/xpm/document-properties.png differ diff --git a/include/xpm/document-properties.xpm b/include/xpm/document-properties.xpm new file mode 100644 index 0000000..e12cda1 --- /dev/null +++ b/include/xpm/document-properties.xpm @@ -0,0 +1,60 @@ +/* XPM */ +static const char * document_properties_xpm[] = { +"16 16 41 1", +" c None", +". c #999999", +"+ c #818181", +"@ c #FFFFFF", +"# c #ECECEC", +"$ c #EAEAEA", +"% c #EBEBEB", +"& c #EDEDED", +"* c #F0F0F0", +"= c #C4C4C4", +"- c #C5C5C5", +"; c #C6C6C6", +"> c #C7C7C7", +", c #696969", +"' c #D2D2D2", +") c #EEEEEE", +"! c #B0B0B0", +"~ c #585858", +"{ c #696966", +"] c #6A6A6A", +"^ c #D2D2CC", +"/ c #D6D6D6", +"( c #595959", +"_ c #626262", +": c #6C6C6C", +"< c #DCDCDC", +"[ c #EFEFEF", +"} c #D4D4D4", +"| c #777777", +"1 c #858585", +"2 c #909090", +"3 c #9D9D9D", +"4 c #C8C8C8", +"5 c #B5B5B5", +"6 c #929292", +"7 c #9E9E9E", +"8 c #ABABAB", +"9 c #E0E0E0", +"0 c #ADADAD", +"a c #BABABA", +"b c #959595", +" .++++++++++++ ", +" +@@@@@@@@@@@@+ ", +" +@#$$%%%##&*@+ ", +" +@$=--;;;;>*@+ ", +" +@$%%,,,'&)*@+ ", +" +@%-;!~~~;>*@+ ", +" +@%,'#',{#)*@+ ", +" +@%~~!~]]^)*@+ ", +" +@#,,,]]]]/*@+ ", +" +@#!~~~~(_:<@+ ", +" +@#&))[}|123@+ ", +" +@&;>>445678@+ ", +" +@&&)[[**90a@+ ", +" +@@@@@@@@@@@@+ ", +" b++++++++++++b ", +" "}; diff --git a/include/xpm/document-save.png b/include/xpm/document-save.png new file mode 100644 index 0000000..22ff495 Binary files /dev/null and b/include/xpm/document-save.png differ diff --git a/include/xpm/document-save.xpm b/include/xpm/document-save.xpm new file mode 100644 index 0000000..e651d91 --- /dev/null +++ b/include/xpm/document-save.xpm @@ -0,0 +1,126 @@ +/* XPM */ +static const char * document_save_xpm[] = { +"16 16 107 2", +" c None", +". c #38678B", +"+ c #3D698A", +"@ c #4A7180", +"# c #58787A", +"$ c #B1CEE6", +"% c #D0DFEF", +"& c #C5DBEC", +"* c #9BC2DF", +"= c #688BA0", +"- c #436E88", +"; c #6B7F88", +"> c #667173", +", c #627075", +"' c #4A6D85", +") c #41749A", +"! c #44789F", +"~ c #9EBFD9", +"{ c #C1D9EB", +"] c #5186AF", +"^ c #4E6A7D", +"/ c #6E706B", +"( c #6B716E", +"_ c #E2E6DD", +": c #FFFFFF", +"< c #DDE1D6", +"[ c #C9D6DD", +"} c #6E99B6", +"| c #ABCBE2", +"1 c #92B7D3", +"2 c #547D9B", +"3 c #D5DFE5", +"4 c #F4F4F4", +"5 c #72756B", +"6 c #FDFDFD", +"7 c #EEEEEE", +"8 c #EDEDED", +"9 c #DFE2DE", +"0 c #7798B0", +"a c #79A7CA", +"b c #8FB3CE", +"c c #3D6B8E", +"d c #ACBCC3", +"e c #EDEDEE", +"f c #EDEEEE", +"g c #EDEEED", +"h c #F3F4F3", +"i c #FCFBFC", +"j c #EBECEC", +"k c #5892BD", +"l c #ECECEC", +"m c #F3F3F3", +"n c #FAFAFA", +"o c #E9E9EA", +"p c #CACFC4", +"q c #98BFDC", +"r c #719FBF", +"s c #739FC0", +"t c #96BBD8", +"u c #95A9AF", +"v c #EAE9EA", +"w c #F2F2F2", +"x c #F9F9F9", +"y c #E4E4E4", +"z c #C5CBBF", +"A c #ABC8DF", +"B c #92A6AC", +"C c #F1F1F1", +"D c #ACCBE3", +"E c #3B6B8F", +"F c #F7F7F7", +"G c #E3E3E3", +"H c #CED4C8", +"I c #3F6C8E", +"J c #9AAEB4", +"K c #FCFCFC", +"L c #F0F0F0", +"M c #FEFEFE", +"N c #EBEBEB", +"O c #CECECE", +"P c #C9C9C9", +"Q c #C5C5C5", +"R c #D6D6D6", +"S c #9F9F9F", +"T c #AFAFAF", +"U c #BCBCBC", +"V c #C4C4C4", +"W c #C8C8C8", +"X c #D0D0D0", +"Y c #A9A9A9", +"Z c #D2D2D2", +"` c #B9B9B9", +" . c #CACACA", +".. c #CDCDCD", +"+. c #C3C3C3", +"@. c #AAAAA9", +"#. c #B4B4B4", +"$. c #C2C2C2", +"%. c #CBCBCB", +"&. c #A8A7A8", +"*. c #D1D1D1", +"=. c #A8A7A7", +"-. c #B7B6B6", +";. c #DDDDDD", +">. c #DCDCDC", +",. c #D5D5D5", +"'. c #CFCFCF", +" . . . + @ # ", +" $ % & * = - ", +"; > , ' ) ! ~ { ] ^ / / / / / / ", +"( _ : < [ } . | 1 2 3 : : : 4 / ", +"5 6 7 8 9 0 . a b c d e f g h / ", +"/ i j . . . . a k . . . . l m / ", +"/ n o p . q r r r s t . u v w / ", +"/ x n y z . q s s A . B y 4 C / ", +"/ x 7 n y z . D q E B y n 7 C / ", +"/ F G 7 n n H I . J n K 7 G L / ", +"/ M : : : : : : : 4 4 N N G L / ", +"/ O P P P P Q P P Q Q Q Q Q R / ", +"/ O Q S T U V W X Y Z Y Z ` ./ ", +"/ ..+.@.#.$.V W %.&.*.=.*.-. ./ ", +"/ ;.>.>.>.,.,.'.'.'.'.'.'.'. ./ ", +"/ / / / / / / / / / / / / / / / "}; diff --git a/include/xpm/down_1.xpm b/include/xpm/down_1.xpm new file mode 100644 index 0000000..e8d3b52 --- /dev/null +++ b/include/xpm/down_1.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * down_1_xpm[] = { +"16 16 3 1", +". c None", +"+ c #7F0000", +"@ c #FF0000", +"................", +"................", +".....+++++++....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +"..++++@@@@@++++.", +"...+@@@@@@@@@+..", +"....+@@@@@@@+...", +".....+@@@@@+....", +"......+@@@+.....", +".......+@+......", +"........+.......", +"................"}; diff --git a/include/xpm/edit-copy.png b/include/xpm/edit-copy.png new file mode 100644 index 0000000..8dd48c4 Binary files /dev/null and b/include/xpm/edit-copy.png differ diff --git a/include/xpm/edit-copy.xpm b/include/xpm/edit-copy.xpm new file mode 100644 index 0000000..6c9d2b2 --- /dev/null +++ b/include/xpm/edit-copy.xpm @@ -0,0 +1,60 @@ +/* XPM */ +static const char * edit_copy_xpm[] = { +"16 16 41 1", +" c None", +". c #888A85", +"+ c #FFFFFF", +"@ c #F0F0EF", +"# c #EFEFEE", +"$ c #C8C8C7", +"% c #9A9B97", +"& c #8D8F8A", +"* c #8A8C87", +"= c #898B86", +"- c #C7C7C6", +"; c #C6C6C5", +"> c #EEEEED", +", c #EDEDEC", +"' c #FEFEFE", +") c #ECECEC", +"! c #C4C4C3", +"~ c #FAFAFA", +"{ c #F3F3F3", +"] c #F9F9F9", +"^ c #EBEBEB", +"/ c #EAEAEA", +"( c #EEEEEE", +"_ c #F7F7F6", +": c #C3C4C3", +"< c #F3F3F2", +"[ c #F4F4F3", +"} c #F2F2F2", +"| c #8C8E89", +"1 c #FEFEFD", +"2 c #989A95", +"3 c #F8F8F7", +"4 c #E3E4E2", +"5 c #FAFAF9", +"6 c #E3E3E2", +"7 c #F4F4F4", +"8 c #F6F6F5", +"9 c #FCFCFB", +"0 c #FBFBFB", +"a c #D4D4D4", +"b c #989A96", +" .......... ", +" ++++++++++. ", +" +@#####@@+. ", +" +@$%..........&", +" +@@*++++++++++.", +" +@$=+@@@@@@@@+.", +" +@#*+@------@+.", +" +#;=+@@@@@@@@+.", +" +>,*+@-----@@+.", +" ')!=+@@@@@@@~{.", +" ]^/*+@-----(_:.", +" <[}*+@@@@@||||.", +" ====1@@@@~2~34.", +" =5@@@~~2~6..", +" =7_890ab4.. ", +" |=........ "}; diff --git a/include/xpm/edit-cut.png b/include/xpm/edit-cut.png new file mode 100644 index 0000000..dc9eb9a Binary files /dev/null and b/include/xpm/edit-cut.png differ diff --git a/include/xpm/edit-cut.xpm b/include/xpm/edit-cut.xpm new file mode 100644 index 0000000..367226c --- /dev/null +++ b/include/xpm/edit-cut.xpm @@ -0,0 +1,107 @@ +/* XPM */ +static const char * edit_cut_xpm[] = { +"16 16 88 1", +" c None", +". c #8B8D88", +"+ c #939590", +"@ c #8F918C", +"# c #8E908B", +"$ c #F7F7F7", +"% c #90918D", +"& c #D2D3D0", +"* c #D2D4D0", +"= c #EFF0EF", +"- c #92948F", +"; c #AAACA7", +"> c #C6C8C3", +", c #8D8F8A", +"' c #B3B5B0", +") c #F7F7F6", +"! c #CCCEC9", +"~ c #AEAFAB", +"{ c #DBDCD9", +"] c #91938E", +"^ c #8C8E89", +"/ c #B6B8B3", +"( c #CDCECB", +"_ c #B5B6B2", +": c #9FA09C", +"< c #B5B6B3", +"[ c #B8BAB5", +"} c #E1E1DF", +"| c #F5F6F5", +"1 c #9A9C97", +"2 c #A8A9A5", +"3 c #BABBB7", +"4 c #E7E8E6", +"5 c #8A8C87", +"6 c #898984", +"7 c #C5C6C3", +"8 c #B3B2AF", +"9 c #9C2F2C", +"0 c #AE1818", +"a c #AB1616", +"b c #A60606", +"c c #A34A45", +"d c #A60202", +"e c #C71A19", +"f c #AD1717", +"g c #A90707", +"h c #D22020", +"i c #CE1E1E", +"j c #B70F0E", +"k c #A40502", +"l c #A80403", +"m c #C91A1A", +"n c #D12020", +"o c #CB1F1F", +"p c #A90A0A", +"q c #A80606", +"r c #D01F1F", +"s c #A80303", +"t c #C01514", +"u c #A60101", +"v c #CD1D1C", +"w c #C01513", +"x c #CD1D1D", +"y c #A70606", +"z c #AB1414", +"A c #D52323", +"B c #CE1D1D", +"C c #CA1B1A", +"D c #AB0D0D", +"E c #CF1D1D", +"F c #B50B0B", +"G c #D32121", +"H c #AA0C0C", +"I c #AA0909", +"J c #D62323", +"K c #B80D0D", +"L c #D11F1F", +"M c #AB1111", +"N c #AB1313", +"O c #DB2727", +"P c #A80707", +"Q c #AA0808", +"R c #D42222", +"S c #AA0E0E", +"T c #AB1010", +"U c #AA0D0D", +"V c #AA0B0B", +"W c #A90B0B", +" .+ .@ ", +" #$. %&@ ", +" .*=- ;>, ", +" ,'). #!~. ", +" .{=]^/(. ", +" ,_$.:<[. ", +" .}|12. ", +" ,34;#5 ", +" 6789 ", +" 0abcdef0 ", +" ghijklmnop ", +" qrstu vwsxy ", +" zA Bp sC nz ", +" DE FGH IJK LM ", +" NOrBP QREBN ", +" STa UVW "}; diff --git a/include/xpm/edit-delete.png b/include/xpm/edit-delete.png new file mode 100644 index 0000000..184f762 Binary files /dev/null and b/include/xpm/edit-delete.png differ diff --git a/include/xpm/edit-delete.xpm b/include/xpm/edit-delete.xpm new file mode 100644 index 0000000..1b2b8d4 --- /dev/null +++ b/include/xpm/edit-delete.xpm @@ -0,0 +1,155 @@ +/* XPM */ +static const char * edit_delete_xpm[] = { +"16 16 136 2", +" c None", +". c #2E3436", +"+ c #64696A", +"@ c #909894", +"# c #E9EAE3", +"$ c #EEEFEC", +"% c #EFF0EE", +"& c #D2D5D3", +"* c #BFC1C1", +"= c #979A9B", +"- c #424749", +"; c #D9DBD6", +"> c #C7CAC4", +", c #6E7672", +"' c #424745", +") c #242727", +"! c #313432", +"~ c #7A837E", +"{ c #B3B8B3", +"] c #CBCECB", +"^ c #CBCFCB", +"/ c #D6D9D3", +"( c #D2D5CD", +"_ c #DADCD6", +": c #AEB3AD", +"< c #5C6362", +"[ c #353939", +"} c #373A38", +"| c #585E5B", +"1 c #8D948F", +"2 c #AAAFA7", +"3 c #D2D6D2", +"4 c #B5BAB5", +"5 c #E5E5E1", +"6 c #F0F0ED", +"7 c #ECEDE9", +"8 c #E3E5E0", +"9 c #DDDED9", +"0 c #CBCEC7", +"a c #B6BBB3", +"b c #A2A8A0", +"c c #B3B8B0", +"d c #BABFB7", +"e c #ABB0A8", +"f c #CBCECD", +"g c #E0E2E2", +"h c #E6E6DD", +"i c #F4F4EF", +"j c #F4F3F1", +"k c #F4F4F1", +"l c #F3F4F0", +"m c #F0F0EB", +"n c #E5E6E0", +"o c #D6D9D2", +"p c #919894", +"q c #8B8F8D", +"r c #898D8D", +"s c #9A9C9C", +"t c #C2C5C4", +"u c #BCC0BF", +"v c #D9DBD2", +"w c #DFE0D8", +"x c #D9DBD4", +"y c #CCD0CF", +"z c #848C89", +"A c #969C99", +"B c #86898A", +"C c #53585A", +"D c #5A5F60", +"E c #8B8F8F", +"F c #ADAFB0", +"G c #E4E5E5", +"H c #E3E5E5", +"I c #E3E5E4", +"J c #A1A4A4", +"K c #686D6E", +"L c #3C4041", +"M c #4C5052", +"N c #6B7171", +"O c #323838", +"P c #2E3434", +"Q c #2B3132", +"R c #2B3133", +"S c #292E30", +"T c #282D2F", +"U c #272C2E", +"V c #393D3C", +"W c #939594", +"X c #AFB5B3", +"Y c #B0B6B4", +"Z c #69706E", +"` c #979F9B", +" . c #6A716D", +".. c #393E3B", +"+. c #5F6764", +"@. c #333734", +"#. c #616866", +"$. c #989B99", +"%. c #B7BBBB", +"&. c #D5D8D6", +"*. c #818A88", +"=. c #D1D4D2", +"-. c #7E8785", +";. c #515756", +">. c #899290", +",. c #434844", +"'. c #6E7774", +"). c #A0A3A1", +"!. c #D6D9D7", +"~. c #858D8A", +"{. c #D8DBD8", +"]. c #A2A8A3", +"^. c #555B59", +"/. c #979E9C", +"(. c #454B47", +"_. c #6F7875", +":. c #D4D7D5", +"<. c #838C89", +"[. c #D8DBD7", +"}. c #9B9D9B", +"|. c #AFB1B0", +"1. c #CCCFCF", +"2. c #B9BBBB", +"3. c #DDDFDC", +"4. c #A0A7A4", +"5. c #878B88", +"6. c #929595", +"7. c #727373", +"8. c #575C5E", +"9. c #9B9C9B", +"0. c #D5D8D7", +"a. c #CFD2D0", +"b. c #BFC0BF", +"c. c #BEC1BF", +"d. c #878787", +"e. c #54595A", +" . . . . . . ", +" . + @ # $ % & * = . ", +" - ; > , ' ) ! ~ { ] ^ . ", +" . / ( _ : < [ } | 1 2 3 4 . ", +" . 5 6 7 8 9 0 a b c d e f . ", +" . g h i j k l m n o p q r . ", +" . s t u v w x y z A B C . . ", +" . D E F G H I J K L M . ", +" . N O P Q R S T U V W . ", +" . X Y Z ` ...+.@.#.$.. ", +" . %.&.*.=.-.;.>.,.'.).. ", +" . %.!.~.{.].^./.(._.).. ", +" . %.:.<.[.].^./.(.'.}.. ", +" . |.1.2.3.].^.4.5.6.7.. ", +" . 8.9.0.a.b.c.d.e.. ", +" . . . . . . "}; diff --git a/include/xpm/edit-find.png b/include/xpm/edit-find.png new file mode 100644 index 0000000..d072d3c Binary files /dev/null and b/include/xpm/edit-find.png differ diff --git a/include/xpm/edit-find.xpm b/include/xpm/edit-find.xpm new file mode 100644 index 0000000..8a8fb2e --- /dev/null +++ b/include/xpm/edit-find.xpm @@ -0,0 +1,96 @@ +/* XPM */ +static const char * edit_find_xpm[] = { +"16 16 77 1", +" c None", +". c #9A9B97", +"+ c #888A85", +"@ c #8D8F8A", +"# c #8A8C87", +"$ c #FFFFFF", +"% c #898B86", +"& c #F0F0EF", +"* c #C7C7C6", +"= c #D6D6D5", +"- c #818380", +"; c #828480", +"> c #A8A9A6", +", c #AEBAC8", +"' c #A6BCD2", +") c #A2BAD4", +"! c #A8B9CD", +"~ c #D6D7D5", +"{ c #A8B7C8", +"] c #8AACD2", +"^ c #BFD3E7", +"/ c #C5D7EA", +"( c #9CBAD9", +"_ c #90ADCB", +": c #A3AEBB", +"< c #85A9CF", +"[ c #DCE6F2", +"} c #E8EEF7", +"| c #E4ECF5", +"1 c #CADAEC", +"2 c #8EB2D8", +"3 c #97AFCB", +"4 c #A2B8D0", +"5 c #A5C0DF", +"6 c #D9E4F1", +"7 c #E0EAF3", +"8 c #DDE7F2", +"9 c #C1D4E9", +"0 c #A0BEDF", +"a c #81A6D0", +"b c #FEFEFD", +"c c #A9BFD6", +"d c #A5C1E0", +"e c #D0DEEE", +"f c #DAE5F2", +"g c #CDDCED", +"h c #C8D9EC", +"i c #BCD0E8", +"j c #80A7D1", +"k c #FAFAF9", +"l c #A7B5C3", +"m c #89ABD0", +"n c #B3CAE5", +"o c #C3D7EB", +"p c #C1D4EA", +"q c #CFDDEE", +"r c #A3BDDA", +"s c #93AFCE", +"t c #CFCFCD", +"u c #9FB8D1", +"v c #91B3D6", +"w c #AFC5DF", +"x c #B2CAE3", +"y c #A0BAD6", +"z c #97B4D3", +"A c #757673", +"B c #8C8E89", +"C c #7E807B", +"D c #B3C8DC", +"E c #8BACCF", +"F c #80A8D1", +"G c #99B3D0", +"H c #A3A4A3", +"I c #6C6E6A", +"J c #8D8E8C", +"K c #B8B8B7", +"L c #848482", +".++++++++++@ ", +"#$$$$$$$$$$+ ", +"%$&&&&&&&&$+ ", +"#$&******&$+ ", +"%$&&&&=----; ", +"#$&**>-,')!- ", +"%$&&~-{]^/(_- ", +"#$&*-:<[}|123- ", +"#$&&-4567890a- ", +"%b&&-cdefghij- ", +"%k&&-lmnopqrs- ", +"%$$$t-uvwxyz-A ", +"B%+++C-DEFG-HHI ", +" I----JKHHL", +" JKHL", +" JJL"}; diff --git a/include/xpm/edit-paste.png b/include/xpm/edit-paste.png new file mode 100644 index 0000000..24588a3 Binary files /dev/null and b/include/xpm/edit-paste.png differ diff --git a/include/xpm/edit-paste.xpm b/include/xpm/edit-paste.xpm new file mode 100644 index 0000000..333091c --- /dev/null +++ b/include/xpm/edit-paste.xpm @@ -0,0 +1,96 @@ +/* XPM */ +static const char * edit_paste_xpm[] = { +"16 16 77 1", +" c None", +". c #5F5F5E", +"+ c #5C5C5C", +"@ c #6D4401", +"# c #6C4401", +"$ c #6B4403", +"% c #5C5C5B", +"& c #959589", +"* c #97978A", +"= c #C08424", +"- c #A47E3E", +"; c #706D64", +"> c #5E5E5E", +", c #7F7F7C", +"' c #80807D", +") c #7E7E7B", +"! c #6E6C64", +"~ c #A17C40", +"{ c #B97F23", +"] c #6C4301", +"^ c #6F4602", +"/ c #C68827", +"( c #716F64", +"_ c #F1F1F1", +": c #E0E0E0", +"< c #BBBBBB", +"[ c #F2F2F2", +"} c #6E6D64", +"| c #C58727", +"1 c #6A4200", +"2 c #666864", +"3 c #FFFFFF", +"4 c #F0F0EF", +"5 c #676964", +"6 c #C28628", +"7 c #C58726", +"8 c #B3B5B5", +"9 c #EFEFEE", +"0 c #EFEFED", +"a c #EDEDEB", +"b c #6E4602", +"c c #B2B4B4", +"d c #B1B2B2", +"e c #EAEAE8", +"f c #EDEDEC", +"g c #EBEBEA", +"h c #DBDBD9", +"i c #EEEEED", +"j c #ECECEB", +"k c #EBEBE9", +"l c #E9E9E7", +"m c #DADAD8", +"n c #CCCDCA", +"o c #ECECEA", +"p c #E8E8E6", +"q c #CDCECB", +"r c #B9BAB6", +"s c #B8B9B5", +"t c #6E4502", +"u c #E7E7E5", +"v c #D9D9D6", +"w c #B9B9B6", +"x c #E7E7E4", +"y c #D8D8D5", +"z c #C1C2BE", +"A c #B7B7B4", +"B c #706D63", +"C c #EDEEED", +"D c #FEFEFE", +"E c #FEFEFD", +"F c #BA7F23", +"G c #A77D3B", +"H c #736F64", +"I c #6A6C68", +"J c #A37C3D", +"K c #B37B22", +"L c #6B4301", +" .++++. ", +" @#$%&**&%$## ", +" @=-;>,'')>!~{] ", +" ^/(_:<<<<:[}|1 ", +" ^/234444443561 ", +" ^7234888893561 ", +" ^72344440a3561 ", +" b723488cde3561 ", +" b72349fgeh3561 ", +" b723ijklmn3561 ", +" b723oepqrs3561 ", +" t723luvw333561 ", +" t723xyzA335|61 ", +" t7BCDDD9E5|||1 ", +" ]FGHIIIIIJJJKL ", +" ]##########L "}; diff --git a/include/xpm/edit-redo.png b/include/xpm/edit-redo.png new file mode 100644 index 0000000..c3b0df0 Binary files /dev/null and b/include/xpm/edit-redo.png differ diff --git a/include/xpm/edit-redo.xpm b/include/xpm/edit-redo.xpm new file mode 100644 index 0000000..c83b376 --- /dev/null +++ b/include/xpm/edit-redo.xpm @@ -0,0 +1,66 @@ +/* XPM */ +static const char * edit_redo_xpm[] = { +"16 16 47 1", +" c None", +". c #4E9A06", +"+ c #AEF36C", +"@ c #8F9B0C", +"# c #A9DE49", +"$ c #AEF16A", +"% c #AEF26B", +"& c #B3F573", +"* c #A6EF61", +"= c #73D216", +"- c #ACD945", +"; c #AFEF67", +"> c #A1E950", +", c #A0DB24", +"' c #A9D846", +") c #B1EF65", +"! c #A4DE24", +"~ c #97DD2A", +"{ c #AFD71A", +"] c #75D318", +"^ c #9DC230", +"/ c #B1ED60", +"( c #A5DF26", +"_ c #C8D009", +": c #77D014", +"< c #8AE234", +"[ c #559F0C", +"} c #B1E963", +"| c #BAE031", +"1 c #CBD417", +"2 c #9BD622", +"3 c #A1DA23", +"4 c #D9DE23", +"5 c #529D0A", +"6 c #B2EC64", +"7 c #CDD624", +"8 c #93A10B", +"9 c #CCD41E", +"0 c #BEE246", +"a c #99A605", +"b c #B3D937", +"c c #B8DD3A", +"d c #AFC723", +"e c #919D05", +"f c #5AA80F", +"g c #C0D62C", +"h c #9A9902", +" . ", +" .. ", +" .+. ", +" ....++. ", +" .@#$%&*=+. ", +" .-;>,,,,==+. ", +" .')!~,,{===]+.", +" .^/({{_:====<. ", +" [}|1233334=<. ", +" 5678.....9<. ", +" .0a. .<. ", +" .b. .. ", +" .c. . ", +" .de ", +" fgh ", +" "}; diff --git a/include/xpm/edit-select-all.png b/include/xpm/edit-select-all.png new file mode 100644 index 0000000..f4b0b19 Binary files /dev/null and b/include/xpm/edit-select-all.png differ diff --git a/include/xpm/edit-select-all.xpm b/include/xpm/edit-select-all.xpm new file mode 100644 index 0000000..08ee62a --- /dev/null +++ b/include/xpm/edit-select-all.xpm @@ -0,0 +1,56 @@ +/* XPM */ +static const char * edit_select_all_xpm[] = { +"16 16 37 1", +" c None", +". c #8B8D89", +"+ c #888A85", +"@ c #8C8E89", +"# c #FDFDFD", +"$ c #FEFEFE", +"% c #FCFCFC", +"& c #FBFBFB", +"* c #FAFAFA", +"= c #F9F9F9", +"- c #8B8D88", +"; c #A8BED6", +"> c #A9BFD7", +", c #AAC0D8", +"' c #ABC1D9", +") c #F8F8F8", +"! c #8197AF", +"~ c #ACC2DA", +"{ c #ADC3DB", +"] c #AEC4DC", +"^ c #EBEBEB", +"/ c #AFC5DD", +"( c #ECECEC", +"_ c #B0C6DE", +": c #EEEEEE", +"< c #B1C7DF", +"[ c #F0F0F0", +"} c #B2C8E0", +"| c #F2F2F2", +"1 c #F7F7F7", +"2 c #000000", +"3 c #B3C9E1", +"4 c #F4F4F4", +"5 c #F5F5F5", +"6 c #F6F6F6", +"7 c #8298B0", +"8 c #8D8F8A", +" .++++++++++++@ ", +" +#$$##%%&&**=- ", +" +#;>>,,''''')- ", +" +$>!!!!~!!!~)- ", +" +#,!!!!{{{{{)- ", +" +#,!!!!{]]]^)- ", +" +%'!!!!]!!/()- ", +" +%~~{]//___:)- ", +" +%~{]//__<<[)- ", +" +&~!!!!!!!}|1- ", +" +&{]/__2}2341- ", +" +*{]/_<}25661- ", +" +={7777}21)11- ", +" +={]/_<}21=)1- ", +" +))))))2)2)))- ", +" @++++++++++++8 "}; diff --git a/include/xpm/edit-undo.png b/include/xpm/edit-undo.png new file mode 100644 index 0000000..8b0fef9 Binary files /dev/null and b/include/xpm/edit-undo.png differ diff --git a/include/xpm/edit-undo.xpm b/include/xpm/edit-undo.xpm new file mode 100644 index 0000000..3bce212 --- /dev/null +++ b/include/xpm/edit-undo.xpm @@ -0,0 +1,80 @@ +/* XPM */ +static const char * edit_undo_xpm[] = { +"16 16 61 1", +" c None", +". c #C4A000", +"+ c #FBF3AD", +"@ c #FBE425", +"# c #BEA113", +"$ c #BB9F15", +"% c #BBA11B", +"& c #F6E131", +"* c #FAE320", +"= c #FAEC73", +"- c #FAEB6F", +"; c #F7E86E", +"> c #F7E86C", +", c #BCA114", +"' c #C1A314", +") c #F6E02F", +"! c #F7E232", +"~ c #F1DB29", +"{ c #F5E02F", +"] c #E3CD16", +"^ c #ECD936", +"/ c #F6E769", +"( c #E3CE41", +"_ c #C1A313", +": c #F8E232", +"< c #E8D21D", +"[ c #E1CD40", +"} c #BDA116", +"| c #FBED79", +"1 c #F4DF2C", +"2 c #D6C004", +"3 c #DFC80B", +"4 c #F3E56A", +"5 c #C5AB1B", +"6 c #BCA015", +"7 c #FBED76", +"8 c #DAC304", +"9 c #F9EA69", +"0 c #F7DD05", +"a c #DFC80A", +"b c #D8C207", +"c c #EBDC6F", +"d c #BFA31B", +"e c #C4A901", +"f c #EEE16E", +"g c #DFC90F", +"h c #F2E469", +"i c #C0A41A", +"j c #F5E66D", +"k c #EFE276", +"l c #C1A319", +"m c #C8AC02", +"n c #F2E788", +"o c #C2A211", +"p c #CBAA0E", +"q c #E9DA5D", +"r c #C0A623", +"s c #DBC443", +"t c #D8C543", +"u c #EADB66", +"v c #C2A611", +" . ", +" .. ", +" .+. ", +" .+@..#$% ", +" .+&*=-;>,' ", +" .+)!~{~]^/(_ ", +".+):!!{~<<<^[} ", +" .|:1222<<<3456 ", +" .78799990abcd ", +" .77....efghi ", +" .7. .jkl ", +" .. mno ", +" . pqr ", +" str ", +" uv ", +" "}; diff --git a/include/xpm/fileprint.xpm b/include/xpm/fileprint.xpm new file mode 100644 index 0000000..6ada912 --- /dev/null +++ b/include/xpm/fileprint.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char *fileprint[] = { +" 16 14 6 1", +". c #000000", +"# c #848284", +"a c #c6c3c6", +"b c #ffff00", +"c c #ffffff", +"d c None", +"ddddd.........dd", +"dddd.cccccccc.dd", +"dddd.c.....c.ddd", +"ddd.cccccccc.ddd", +"ddd.c.....c....d", +"dd.cccccccc.a.a.", +"d..........a.a..", +".aaaaaaaaaa.a.a.", +".............aa.", +".aaaaaa###aa.a.d", +".aaaaaabbbaa...d", +".............a.d", +"d.aaaaaaaaa.a.dd", +"dd...........ddd" +}; diff --git a/include/xpm/film-b.png b/include/xpm/film-b.png new file mode 100644 index 0000000..edccf1b Binary files /dev/null and b/include/xpm/film-b.png differ diff --git a/include/xpm/film-b.xpm b/include/xpm/film-b.xpm new file mode 100644 index 0000000..3f50d46 --- /dev/null +++ b/include/xpm/film-b.xpm @@ -0,0 +1,34 @@ +/* XPM */ +static const char * film_b_xpm[] = { +"16 16 15 1", +" c None", +". c #7474D1", +"+ c #7171D0", +"@ c #7070CF", +"# c #6F6FCF", +"$ c #6A6ACD", +"% c #6868CD", +"& c #7373D0", +"* c #7979D2", +"= c #7C7CD3", +"- c #7676D1", +"; c #7E7ED3", +"> c #8282D5", +", c #8585D6", +"' c #8181D4", +" ", +" ", +" .+@#$$%$%%% ", +" . &+##$#$ % ", +" **..++#+##$ ", +" = *-..+.+ # ", +" ;==**....&+ ", +" > ;==**** . ", +" ,>>'==*=*** ", +" > ;==**** . ", +" ;==**....&+ ", +" = *-..+.+ # ", +" **..++#+##$ ", +" . &+##$#$ % ", +" .+@#$$%$%%% ", +" "}; diff --git a/include/xpm/film-r.xpm b/include/xpm/film-r.xpm new file mode 100644 index 0000000..b84f594 --- /dev/null +++ b/include/xpm/film-r.xpm @@ -0,0 +1,32 @@ +/* XPM */ +static const char * film_r_xpm[] = { +"16 16 13 1", +" c None", +". c #B53C3C", +"+ c #B23B3B", +"@ c #AF3A3A", +"# c #AE3939", +"$ c #A63737", +"% c #A53737", +"& c #BD3F3F", +"* c #C04141", +"= c #BA3E3E", +"- c #C14444", +"; c #C24949", +"> c #C44F4F", +" ", +" ", +" .+@#$$%$%%% ", +" . .+##$#$ % ", +" &&..++#+##$ ", +" * &=..+.+ # ", +" -**&&.....+ ", +" ; -**&&&& . ", +" >;;;**&*&&& ", +" ; -**&&&& . ", +" -**&&.....+ ", +" * &=..+.+ # ", +" &&..++#+##$ ", +" . .+##$#$ % ", +" .+@#$$%$%%% ", +" "}; diff --git a/include/xpm/first.xpm b/include/xpm/first.xpm new file mode 100644 index 0000000..0265075 --- /dev/null +++ b/include/xpm/first.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * first_xpm[] = { +"16 16 2 1", +" c None", +". c #0000FF", +" ", +" ", +" ", +" .. . ", +" .. ... ", +" .. ..... ", +" .. ....... ", +" .. ......... ", +" ............ ", +" ............ ", +" .. ......... ", +" .. ....... ", +" .. ..... ", +" .. ... ", +" .. . ", +" "}; diff --git a/include/xpm/folder.png b/include/xpm/folder.png new file mode 100644 index 0000000..65bd0bb Binary files /dev/null and b/include/xpm/folder.png differ diff --git a/include/xpm/folder.xpm b/include/xpm/folder.xpm new file mode 100644 index 0000000..6473918 --- /dev/null +++ b/include/xpm/folder.xpm @@ -0,0 +1,130 @@ +/* XPM */ +static const char * folder_xpm[] = { +"16 16 111 2", +" c None", +". c #7A7A7A", +"+ c #797979", +"@ c #787878", +"# c #C9C9C9", +"$ c #C7C7C7", +"% c #C5C5C5", +"& c #C4C4C4", +"* c #B4B4B4", +"= c #747474", +"- c #737373", +"; c #B0B0B0", +"> c #ADADAD", +", c #ABABAB", +"' c #AAAAAA", +") c #ACACAC", +"! c #8D8D8D", +"~ c #8C8C8C", +"{ c #808080", +"] c #6C6C6C", +"^ c #6E6E6E", +"/ c #C1C1C0", +"( c #A7A7A7", +"_ c #A5A5A5", +": c #A4A4A4", +"< c #B6B6B6", +"[ c #B9B9B9", +"} c #BBBBBB", +"| c #A2A2A2", +"1 c #6A6A6A", +"2 c #BDBDBD", +"3 c #416DA6", +"4 c #3666A5", +"5 c #3566A4", +"6 c #3465A4", +"7 c #3768A6", +"8 c #656565", +"9 c #B7B7B7", +"0 c #3566A5", +"a c #BED3EA", +"b c #BFD4EA", +"c c #BED4EA", +"d c #BED3E9", +"e c #B8CFE8", +"f c #3465A5", +"g c #5F5F5F", +"h c #B3B3B3", +"i c #C1D5EA", +"j c #91B4DB", +"k c #91B5DB", +"l c #92B5DB", +"m c #96B8DC", +"n c #B7CFE7", +"o c #3466A4", +"p c #5B5B5B", +"q c #AEAEAE", +"r c #3667A5", +"s c #C4D7EB", +"t c #94B7DC", +"u c #91B4DA", +"v c #B6CDE6", +"w c #565656", +"x c #A9A9A9", +"y c #3666A4", +"z c #C6D8EC", +"A c #99BADD", +"B c #95B7DC", +"C c #8EB2DA", +"D c #8BB0D9", +"E c #B8CFE7", +"F c #515151", +"G c #A5A5A4", +"H c #3767A5", +"I c #BED2E9", +"J c #9BBADD", +"K c #99B9DD", +"L c #95B6DC", +"M c #90B3DA", +"N c #8EB2D9", +"O c #89AED8", +"P c #87ADD7", +"Q c #8BB0D8", +"R c #B1C9E5", +"S c #4C4C4C", +"T c #A1A1A1", +"U c #3868A5", +"V c #A9C4E2", +"W c #81A8D5", +"X c #7AA4D3", +"Y c #7EA7D4", +"Z c #9CBADD", +"` c #484848", +" . c #9B9B9B", +".. c #3867A4", +"+. c #85ABD5", +"@. c #6E9CCE", +"#. c #6D9CCE", +"$. c #709ECF", +"%. c #84ABD5", +"&. c #494949", +"*. c #999999", +"=. c #3968A5", +"-. c #7EA6D3", +";. c #78A3D2", +">. c #79A4D3", +",. c #7AA5D1", +"'. c #788697", +"). c #3A69A5", +"!. c #5083BA", +"~. c #4578B2", +"{. c #464D53", +" ", +". + + + + + + ", +"@ # $ % & & * = ", +"- % ; > , ' ) ! ! ~ ~ ~ { ] ", +"^ / ) ' ( _ : : ) < [ } | 1 ", +"1 2 3 4 4 4 4 4 5 5 5 5 6 6 6 7 ", +"8 9 0 a b b c c c d d d d d e f ", +"g h 5 i j j k k l l l l l m n o ", +"p q r s t t t t t t t t t u v 0 ", +"w x y z A A A A A A A B C D E 0 ", +"F G H I J K L l M N O P P Q R 0 ", +"S T U V W X X X X X X X X Y Z 0 ", +"` ...+.@.#.#.#.#.#.#.#.#.$.%.0 ", +"&.*.=.-.;.;.;.;.;.;.;.;.;.>.,.0 ", +"` '.).!.!.!.!.!.!.!.!.!.!.!.~.4 ", +"{.6 6 6 6 6 6 6 6 6 6 6 6 6 5 "}; diff --git a/include/xpm/format-indent-more.png b/include/xpm/format-indent-more.png new file mode 100644 index 0000000..00309ea Binary files /dev/null and b/include/xpm/format-indent-more.png differ diff --git a/include/xpm/format-indent-more.xpm b/include/xpm/format-indent-more.xpm new file mode 100644 index 0000000..d2193fd --- /dev/null +++ b/include/xpm/format-indent-more.xpm @@ -0,0 +1,53 @@ +/* XPM */ +static const char * format_indent_more_xpm[] = { +"16 16 34 1", +" c None", +". c #4E8FCC", +"+ c #498DC7", +"@ c #FFFFFF", +"# c #4B90CB", +"$ c #FEFEFE", +"% c #FABFBA", +"& c #A22320", +"* c #F9B7B3", +"= c #921B18", +"- c #F9B5B1", +"; c #FCD2D2", +"> c #F49A9A", +", c #E67674", +"' c #D55653", +") c #BE3936", +"! c #F8B3B0", +"~ c #F49A98", +"{ c #D45552", +"] c #F8B2AE", +"^ c #F39D99", +"/ c #E67572", +"( c #F8B0AC", +"_ c #F39B97", +": c #E67772", +"< c #D35653", +"[ c #F8AEAA", +"} c #F39795", +"| c #E57471", +"1 c #D35451", +"2 c #F8AEAC", +"3 c #F8B1AC", +"4 c #FBCAC7", +"5 c #4C8ECC", +" .++++++++++++. ", +" +@@@@@@@@@@@@# ", +" +@@@@@@@@@@@$# ", +" +@@@@@#####@$# ", +" +@@@@@%@@@@@$# ", +" +@@@@@&*@@@@@# ", +" +@@@@@&=-@@@@# ", +" +;>,')&==!@@@# ", +" +;~,{)&===]@$# ", +" +;^/{)&====($# ", +" +;_:<)&===[@$# ", +" +;}|1)&==2@@@# ", +" +@@@@@&=3@@@@# ", +" +@@@@@&3@@@@@# ", +" +@@@@@4$$@@@@# ", +" .############5 "}; diff --git a/include/xpm/func.xpm b/include/xpm/func.xpm new file mode 100644 index 0000000..e62cfe7 --- /dev/null +++ b/include/xpm/func.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * func_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . . . ", +" . . . ", +" . . . ", +" ... . . . . ", +" . . . . . ", +" . . .. . ", +" . . .. . ", +" . . . . . ", +" . . . . . ", +" . . ", +" . . ", +" ", +" "}; diff --git a/include/xpm/go-down.png b/include/xpm/go-down.png new file mode 100644 index 0000000..3dd7fcc Binary files /dev/null and b/include/xpm/go-down.png differ diff --git a/include/xpm/go-down.xpm b/include/xpm/go-down.xpm new file mode 100644 index 0000000..e11a2cf --- /dev/null +++ b/include/xpm/go-down.xpm @@ -0,0 +1,112 @@ +/* XPM */ +static const char * go_down_xpm[] = { +"16 16 93 2", +" c None", +". c #3A7404", +"+ c #3A7304", +"@ c #C7DEB0", +"# c #C3DCAB", +"$ c #BFDAA6", +"% c #B1D291", +"& c #A3CA7E", +"* c #C8DFB1", +"= c #8DBE5F", +"- c #86BA55", +"; c #71AE37", +"> c #4E9A06", +", c #C7DFB1", +"' c #78B241", +") c #8CBD5D", +"! c #85B954", +"~ c #7CB447", +"{ c #3B7504", +"] c #3B7604", +"^ c #C5DDAD", +"/ c #89BC59", +"( c #82B850", +"_ c #6FAD34", +": c #568927", +"< c #C2DBAA", +"[ c #C6DEAF", +"} c #C2DCAA", +"| c #88BD56", +"1 c #82BA4D", +"2 c #63AA1F", +"3 c #53A208", +"4 c #A5CE7F", +"5 c #A4CD7E", +"6 c #A4CC7E", +"7 c #9FC778", +"8 c #4B8218", +"9 c #3B7404", +"0 c #7AA54F", +"a c #B8D69B", +"b c #8DBE5D", +"c c #8AC058", +"d c #87C051", +"e c #7EBC42", +"f c #5AAB0C", +"g c #59AB0B", +"h c #59AA0A", +"i c #58A90C", +"j c #97C768", +"k c #659A34", +"l c #99BF75", +"m c #A9D183", +"n c #89C252", +"o c #87C34D", +"p c #69B61E", +"q c #5FB40D", +"r c #5EB30D", +"s c #89C54E", +"t c #84B755", +"u c #40780D", +"v c #B1D390", +"w c #98CC65", +"x c #7DC23B", +"y c #62B90F", +"z c #65BC0F", +"A c #65BD10", +"B c #7BC532", +"C c #9FCE71", +"D c #3F780A", +"E c #578C26", +"F c #B7DB94", +"G c #79C331", +"H c #67C011", +"I c #6AC512", +"J c #73C91F", +"K c #A8DB78", +"L c #52891E", +"M c #7AAA4C", +"N c #A0D66D", +"O c #69C412", +"P c #6ECB14", +"Q c #A5E06C", +"R c #72A83F", +"S c #3C7604", +"T c #8DBF5D", +"U c #8DD14C", +"V c #90D54E", +"W c #92C55F", +"X c #427A0E", +"Y c #A2D174", +"Z c #A3D375", +"` c #427B0E", +" . c #568B24", +" . + + + + + + . ", +" + @ # $ % & & + ", +" + * = - ; > & + ", +" + , = - ' > & + ", +" + @ ) ! ~ > & + ", +"{ + + + ] ^ / ( _ > & ] + + + { ", +" : < [ ^ } | 1 2 3 4 5 6 7 8 ", +" 9 0 a b c d e f g h i j k 9 ", +" . l m n o p q q r s t { ", +" u v w x y z A B C D ", +" E F G H I J K L ", +" { M N O P Q R S ", +" ] T U V W S ", +" X Y Z ` ", +" . . ", +" S S "}; diff --git a/include/xpm/go-first.png b/include/xpm/go-first.png new file mode 100644 index 0000000..9c15c09 Binary files /dev/null and b/include/xpm/go-first.png differ diff --git a/include/xpm/go-first.xpm b/include/xpm/go-first.xpm new file mode 100644 index 0000000..3687e51 --- /dev/null +++ b/include/xpm/go-first.xpm @@ -0,0 +1,119 @@ +/* XPM */ +static const char * go_first_xpm[] = { +"16 16 100 2", +" c None", +". c #3A7304", +"+ c #3B7504", +"@ c #3B7404", +"# c #588B28", +"$ c #3A7404", +"% c #81AA58", +"& c #C4DCAC", +"* c #457C12", +"= c #A6C787", +"- c #BEDAA5", +"; c #C6DEAF", +"> c #629135", +", c #BBD6A1", +"' c #B0D290", +") c #91C064", +"! c #C3DDAB", +"~ c #3B7604", +"{ c #3B7506", +"] c #86AE5F", +"^ c #BDD9A3", +"/ c #9DC775", +"( c #8CBD5D", +"_ c #8BBE5B", +": c #C2DDA8", +"< c #C0DDA5", +"[ c #BEDBA2", +"} c #BBD99E", +"| c #B8D79A", +"1 c #B4D496", +"2 c #487E17", +"3 c #A0C380", +"4 c #B1D292", +"5 c #8BBC5D", +"6 c #86BA55", +"7 c #87BD54", +"8 c #87BF52", +"9 c #87C04F", +"0 c #85C04C", +"a c #81BE46", +"b c #7CBA3F", +"c c #76B539", +"d c #B4D594", +"e c #AECE8F", +"f c #9CC673", +"g c #7DB448", +"h c #7DB549", +"i c #80B74B", +"j c #83BC4B", +"k c #81BF46", +"l c #79BC37", +"m c #71BA2A", +"n c #69B51E", +"o c #65B31B", +"p c #65B01D", +"q c #B0D58E", +"r c #A1C77E", +"s c #68A92B", +"t c #62A523", +"u c #5FA81A", +"v c #5DAB11", +"w c #5CB00C", +"x c #60B50D", +"y c #62B80E", +"z c #61B80E", +"A c #5FB50D", +"B c #5CAF0C", +"C c #A8D280", +"D c #41790E", +"E c #85B25A", +"F c #8FBF62", +"G c #59A213", +"H c #55A509", +"I c #5AAD0B", +"J c #64BB0F", +"K c #66BF10", +"L c #63BB0F", +"M c #5FB40D", +"N c #A9D480", +"O c #6A9C3B", +"P c #9CC772", +"Q c #70B42D", +"R c #62B90E", +"S c #B0DE83", +"T c #B2E184", +"U c #ADDA82", +"V c #AAD681", +"W c #50851D", +"X c #99C66E", +"Y c #8AC74E", +"Z c #64BB11", +"` c #B1E084", +" . c #3F7B05", +".. c #3F780A", +"+. c #87B955", +"@. c #9FD56C", +"#. c #6AA136", +"$. c #ACDB7E", +"%. c #4E8619", +"&. c #3C7604", +". . + ", +". . @ # . ", +". . $ % & . ", +". . * = - ; . ", +". . @ > , ' ) ! ~ . . . . $ ", +". . { ] ^ / ( _ : < [ } | 1 . ", +". . 2 3 4 5 6 7 8 9 0 a b c d . ", +". . e f g h i j k l m n o p q . ", +". . r ( s t u v w x y z A B C . ", +". . D E F G H I A J K K L M N . ", +". . $ O P Q w R S T T S U V . ", +". . @ W X Y Z ` .. . . . $ ", +". . ..+.@.` . ", +". . + #.$.. ", +". . ~ %.. ", +". . &. "}; diff --git a/include/xpm/go-last.png b/include/xpm/go-last.png new file mode 100644 index 0000000..6e904ef Binary files /dev/null and b/include/xpm/go-last.png differ diff --git a/include/xpm/go-last.xpm b/include/xpm/go-last.xpm new file mode 100644 index 0000000..2103750 --- /dev/null +++ b/include/xpm/go-last.xpm @@ -0,0 +1,119 @@ +/* XPM */ +static const char * go_last_xpm[] = { +"16 16 100 2", +" c None", +". c #3B7504", +"+ c #3A7304", +"@ c #568927", +"# c #3A7404", +"$ c #C0DBA7", +"% c #7EA955", +"& c #C3DCAB", +"* c #BCD8A0", +"= c #A4C684", +"- c #447B11", +"; c #3B7604", +"> c #C1DBA9", +", c #8EBE5F", +"' c #AFD28D", +") c #BAD6A0", +"! c #629135", +"~ c #3B7404", +"{ c #B2D393", +"] c #B4D496", +"^ c #B7D69A", +"/ c #BAD79E", +"( c #BDD9A1", +"_ c #C0DCA4", +": c #8AC058", +"< c #8EC25C", +"[ c #9FCB76", +"} c #BFDBA4", +"| c #86AF60", +"1 c #3B7506", +"2 c #B0D190", +"3 c #6CAB30", +"4 c #71AE37", +"5 c #76B23D", +"6 c #7DB845", +"7 c #83BE4B", +"8 c #87C150", +"9 c #8BC353", +"0 c #8CC356", +"a c #91C560", +"b c #B4D694", +"c c #A2C581", +"d c #497E17", +"e c #ACCF8A", +"f c #59A016", +"g c #589F14", +"h c #5EA718", +"i c #6AB226", +"j c #76BB35", +"k c #83C245", +"l c #88C64B", +"m c #88C54D", +"n c #87C34D", +"o c #84BF4C", +"p c #B0D092", +"q c #A3CA7E", +"r c #4E9A06", +"s c #509E07", +"t c #56A609", +"u c #5AAD0B", +"v c #5EB30D", +"w c #61B70E", +"x c #66BB16", +"y c #6CBC1F", +"z c #71BC2A", +"A c #73B930", +"B c #92C560", +"C c #A3C97F", +"D c #52A108", +"E c #58A90A", +"F c #5DB10C", +"G c #62B80E", +"H c #66BE10", +"I c #67C011", +"J c #6ABB1B", +"K c #99CE66", +"L c #89B85B", +"M c #42790E", +"N c #A6CF7F", +"O c #A9D480", +"P c #ACD881", +"Q c #AFDC83", +"R c #6AC412", +"S c #6CC813", +"T c #80CC35", +"U c #A6D777", +"V c #6EA33D", +"W c #3D7904", +"X c #AFDD83", +"Y c #6DC815", +"Z c #97DC55", +"` c #A3D673", +" . c #52891E", +".. c #A5DC6E", +"+. c #8DC459", +"@. c #3F790A", +"#. c #AAD97D", +"$. c #6CA436", +"%. c #3C7604", +"&. c #4D8519", +" . + + ", +" + @ # + + ", +" + $ % # + + ", +" + & * = - + + ", +"# + + + + ; > , ' ) ! ~ + + ", +"+ { ] ^ / ( _ : < [ } | 1 + + ", +"+ 2 3 4 5 6 7 8 9 0 a b c d + + ", +"+ e f g h i j k l m n o [ p + + ", +"+ q r s t u v w x y z A B C + + ", +"+ q r D E F G H I H J K L M + + ", +"+ q q N O P Q R S T U V . + + ", +"# + + + + W X Y Z ` .; + + ", +" + X ..+.@. + + ", +" + #.$.%. + + ", +" + &.%. + + ", +" ; + + "}; diff --git a/include/xpm/go-next-b.png b/include/xpm/go-next-b.png new file mode 100644 index 0000000..1f48daf Binary files /dev/null and b/include/xpm/go-next-b.png differ diff --git a/include/xpm/go-next.png b/include/xpm/go-next.png new file mode 100644 index 0000000..6ef8de7 Binary files /dev/null and b/include/xpm/go-next.png differ diff --git a/include/xpm/go-next.xpm b/include/xpm/go-next.xpm new file mode 100644 index 0000000..49e0f2f --- /dev/null +++ b/include/xpm/go-next.xpm @@ -0,0 +1,119 @@ +/* XPM */ +static const char * go_next_xpm[] = { +"16 16 100 2", +" c None", +". c #3B7504", +"+ c #3A7304", +"@ c #598C2A", +"# c #3A7404", +"$ c #CBE1B7", +"% c #82AB5A", +"& c #CEE3BB", +"* c #C3DCAB", +"= c #A4C684", +"- c #437A10", +"; c #3B7604", +"> c #CBE0B6", +", c #99C46F", +"' c #B1D291", +") c #B7D49C", +"! c #5F8F31", +"~ c #3B7404", +"{ c #C0DBA7", +"] c #C2DCAA", +"^ c #C5DDAD", +"/ c #C6DEAF", +"( c #C7DEB0", +"_ c #91C164", +": c #8FC161", +"< c #9DC873", +"[ c #BBD99F", +"} c #81AB5A", +"| c #3A7405", +"1 c #BDD9A3", +"2 c #85B954", +"3 c #88BB58", +"4 c #8BBC5B", +"5 c #8BBD5C", +"6 c #8CBE5C", +"7 c #8DC15C", +"8 c #8DC25A", +"9 c #8AC255", +"0 c #8CC358", +"a c #AFD48C", +"b c #9CC37A", +"c c #467C14", +"d c #B9D79C", +"e c #74AF3B", +"f c #6EAC33", +"g c #68A92B", +"h c #6BAC2F", +"i c #78B63D", +"j c #82BE49", +"k c #89C350", +"l c #88C44D", +"m c #84C249", +"n c #80BE44", +"o c #9BCA6D", +"p c #AACE89", +"q c #5E8F30", +"r c #A3CA7E", +"s c #4E9A06", +"t c #52A007", +"u c #57A709", +"v c #5BAE0B", +"w c #5FB20E", +"x c #66B817", +"y c #6CBA1F", +"z c #6FBA26", +"A c #8DC655", +"B c #9EC976", +"C c #568926", +"D c #4F9C06", +"E c #54A408", +"F c #5AAC0B", +"G c #5EB30D", +"H c #62B90E", +"I c #64BC0F", +"J c #6CBF1C", +"K c #9CD267", +"L c #8BBB5D", +"M c #427A0E", +"N c #A4CC7E", +"O c #A7D17F", +"P c #AAD581", +"Q c #61B70E", +"R c #66BF10", +"S c #7FCB34", +"T c #A8DA78", +"U c #71A63E", +"V c #3C7804", +"W c #ABD681", +"X c #64BA11", +"Y c #92D352", +"Z c #A5D773", +"` c #538B1E", +" . c #3C7604", +".. c #ABD781", +"+. c #A0D56C", +"@. c #8BC158", +"#. c #40790A", +"$. c #A6D37B", +"%. c #6AA136", +"&. c #4D8418", +" . ", +" + @ # ", +" + $ % # ", +" + & * = - ", +"# + + + + ; > , ' ) ! ~ ", +"+ { ] ^ / ( ( _ : < [ } | ", +"+ 1 2 3 4 5 6 7 8 9 0 a b c ", +"+ d e f g h i j k l m n o p q . ", +"+ r s s s t u v w x y z A B C . ", +"+ r s s D E F G H I J K L M ", +"+ r r r N O P Q R S T U ; ", +"# + + + + V W X Y Z ` . ", +" + ..+.@.#. ", +" + $.%. . ", +" + &.; ", +" . "}; diff --git a/include/xpm/go-previous-b.png b/include/xpm/go-previous-b.png new file mode 100644 index 0000000..7c8443a Binary files /dev/null and b/include/xpm/go-previous-b.png differ diff --git a/include/xpm/go-previous.png b/include/xpm/go-previous.png new file mode 100644 index 0000000..659cd90 Binary files /dev/null and b/include/xpm/go-previous.png differ diff --git a/include/xpm/go-previous.xpm b/include/xpm/go-previous.xpm new file mode 100644 index 0000000..65984e8 --- /dev/null +++ b/include/xpm/go-previous.xpm @@ -0,0 +1,117 @@ +/* XPM */ +static const char * go_previous_xpm[] = { +"16 16 98 2", +" c None", +". c #3B7504", +"+ c #3B7404", +"@ c #598B29", +"# c #3A7304", +"$ c #3A7404", +"% c #7FA956", +"& c #C8DFB1", +"* c #437A10", +"= c #A0C37E", +"- c #BDD9A3", +"; c #CAE0B5", +"> c #5D8D2E", +", c #B3D296", +"' c #AACF88", +") c #91C064", +"! c #C7DFB1", +"~ c #3B7604", +"{ c #3A7405", +"] c #7DA855", +"^ c #B5D497", +"/ c #94C26A", +"( c #87BA57", +"_ c #8BBD5C", +": c #C4DDAC", +"< c #C5DEAE", +"[ c #C6DEAE", +"} c #C2DCAA", +"| c #457C13", +"1 c #97BD72", +"2 c #A7CD84", +"3 c #80B64D", +"4 c #7DB549", +"5 c #82B74F", +"6 c #85B954", +"7 c #88BB58", +"8 c #89BC59", +"9 c #8ABC5A", +"0 c #BFDAA6", +"a c #5A8C2C", +"b c #A5C982", +"c c #90BF63", +"d c #70AD35", +"e c #75B23C", +"f c #7BB642", +"g c #7FB947", +"h c #7AB742", +"i c #71B035", +"j c #65A827", +"k c #5EA31D", +"l c #60A420", +"m c #68A92B", +"n c #B8D69B", +"o c #578927", +"p c #9DC477", +"q c #87BB54", +"r c #66AC22", +"s c #66AF20", +"t c #62AF17", +"u c #5CAD0E", +"v c #59AC0B", +"w c #58A90A", +"x c #55A409", +"y c #519E07", +"z c #4E9A06", +"A c #A3CA7E", +"B c #41790E", +"C c #87B65B", +"D c #96CA65", +"E c #65B519", +"F c #60B50D", +"G c #61B70E", +"H c #61B60E", +"I c #5EB30D", +"J c #5AAD0B", +"K c #56A609", +"L c #6EA23D", +"M c #A5D576", +"N c #7CC833", +"O c #69C211", +"P c #67C111", +"Q c #AEDB82", +"R c #ACD881", +"S c #A9D480", +"T c #A6CF7F", +"U c #52891E", +"V c #A3D572", +"W c #97DA54", +"X c #6EC915", +"Y c #B0DE83", +"Z c #3D7904", +"` c #3F790A", +" . c #8DC459", +".. c #A5DC6E", +"+. c #3C7604", +"@. c #6BA236", +"#. c #A9D77D", +"$. c #4D8419", +" . ", +" + @ # ", +" $ % & # ", +" * = - ; # ", +" + > , ' ) ! ~ # # # # $ ", +" { ] ^ / ( _ : < [ < : } # ", +" | 1 2 3 4 5 6 7 8 9 8 7 0 # ", +". a b c d e f g h i j k l m n # ", +". o p q r s t u v w x y z z A # ", +" B C D E F G H I J K y z A # ", +" . L M N O P Q R S T A A # ", +" ~ U V W X Y Z # # # # $ ", +" ` ...Y # ", +" +.@.#.# ", +" ~ $.# ", +" . "}; diff --git a/include/xpm/go-up.png b/include/xpm/go-up.png new file mode 100644 index 0000000..fa9a7d7 Binary files /dev/null and b/include/xpm/go-up.png differ diff --git a/include/xpm/go-up.xpm b/include/xpm/go-up.xpm new file mode 100644 index 0000000..d3ae19f --- /dev/null +++ b/include/xpm/go-up.xpm @@ -0,0 +1,124 @@ +/* XPM */ +static const char * go_up_xpm[] = { +"16 16 105 2", +" c None", +". c #3B7504", +"+ c #578928", +"@ c #568926", +"# c #41790F", +"$ c #A7CA87", +"% c #A2C77E", +"& c #41790E", +"* c #3A7404", +"= c #96BD72", +"- c #9AC572", +"; c #95C26A", +"> c #86B35B", +", c #3B7404", +"' c #78A54E", +") c #B0D291", +"! c #7DB448", +"~ c #76B13F", +"{ c #6A9C3B", +"] c #578A28", +"^ c #BBD7A0", +"/ c #8CBD5F", +"( c #80B64D", +"_ c #7AB344", +": c #5CA21A", +"< c #9AC471", +"[ c #4F841D", +"} c #40780D", +"| c #B7D49C", +"1 c #A0C97A", +"2 c #8BBE5A", +"3 c #86BC51", +"4 c #74B438", +"5 c #53A308", +"6 c #6CAF2C", +"7 c #97C36E", +"8 c #3E770A", +"9 c #A1C480", +"0 c #B5D597", +"a c #96C569", +"b c #91C560", +"c c #8BC356", +"d c #66B01D", +"e c #59AC0B", +"f c #59AB0B", +"g c #85C14D", +"h c #84B455", +"i c #7FA956", +"j c #C7DFB0", +"k c #A0CB77", +"l c #9ACA6C", +"m c #96CA63", +"n c #81C143", +"o c #5EB30D", +"p c #5FB50D", +"q c #5FB40D", +"r c #5FB20F", +"s c #9BCE6A", +"t c #679C35", +"u c #588B28", +"v c #CAE0B5", +"w c #D0E5BC", +"x c #CEE5B8", +"y c #CBE5B3", +"z c #97CD63", +"A c #68BA19", +"B c #64BC0F", +"C c #65BE10", +"D c #AFDC83", +"E c #AEDB82", +"F c #ACD982", +"G c #A6D37B", +"H c #4C8418", +"I c #3A7304", +"J c #3C7804", +"K c #CBE6B2", +"L c #89C94B", +"M c #65BD10", +"N c #69C311", +"O c #6BC712", +"P c #B2E184", +"Q c #3E7A05", +"R c #CAE5B0", +"S c #78C331", +"T c #67C011", +"U c #6CC813", +"V c #71CF15", +"W c #B4E585", +"X c #C8E4AD", +"Y c #6DBD1F", +"Z c #66BF10", +"` c #6AC512", +" . c #6DC913", +".. c #B3E384", +"+. c #C5E2A9", +"@. c #65B616", +"#. c #63BA0F", +"$. c #66BE10", +"%. c #67C111", +"&. c #B0DE83", +"*. c #C1DFA5", +"=. c #AAD581", +"-. c #ABD781", +";. c #ADDA82", +">. c #ADD982", +" . . ", +" + @ ", +" # $ % & ", +" * = - ; > * ", +" , ' ) ! ~ ; { * ", +" ] ^ / ( _ : < [ ", +" } | 1 2 3 4 5 6 7 8 ", +" * 9 0 a b c d e f g h . ", +" , i j k l m n o p q r s t . ", +" u v w x y z A B C D E F G H ", +". I I I J K L M N O P Q I I I . ", +" I R S T U V W I ", +" I X Y Z ` ...I ", +" I +.@.#.$.%.&.I ", +" I *.=.-.F ;.>.I ", +" * I I I I I I , "}; diff --git a/include/xpm/help-contents.png b/include/xpm/help-contents.png new file mode 100644 index 0000000..b3ae2c3 Binary files /dev/null and b/include/xpm/help-contents.png differ diff --git a/include/xpm/help-contents.xpm b/include/xpm/help-contents.xpm new file mode 100644 index 0000000..a307af2 --- /dev/null +++ b/include/xpm/help-contents.xpm @@ -0,0 +1,123 @@ +/* XPM */ +static const char * help_contents_xpm[] = { +"16 16 104 2", +" c None", +". c #8D8F8A", +"+ c #898B86", +"@ c #888A85", +"# c #8F918C", +"$ c #FFFFFF", +"% c #8A8C87", +"& c #DEE1DB", +"* c #C0C3BC", +"= c #BABDB6", +"- c #C2C4BE", +"; c #EAECE8", +"> c #DFE2DC", +", c #E3E5E0", +"' c #E6E9E4", +") c #EDEEEB", +"! c #EFF0ED", +"~ c #F0F1EF", +"{ c #F0F1EE", +"] c #EEF0ED", +"^ c #ECEDEA", +"/ c #E0E3DD", +"( c #E4E6E1", +"_ c #C5ABA8", +": c #A37A77", +"< c #A47E7B", +"[ c #CAB1AE", +"} c #EDEFEC", +"| c #E1E3DE", +"1 c #B17977", +"2 c #A32827", +"3 c #D69392", +"4 c #EEEEEC", +"5 c #EEEEED", +"6 c #D79C9B", +"7 c #A52927", +"8 c #B57D7B", +"9 c #C6ABA8", +"0 c #F08686", +"a c #EB5757", +"b c #BAA6A2", +"c c #EB5C5C", +"d c #F09F9F", +"e c #A62A29", +"f c #D0B4B2", +"g c #A2837F", +"h c #D78F8E", +"i c #EC5757", +"j c #AB1010", +"k c #B99390", +"l c #ED5F5F", +"m c #DBA4A2", +"n c #A6827E", +"o c #F0F0EE", +"p c #BAA9A6", +"q c #B68885", +"r c #F4F5F3", +"s c #F8F8F7", +"t c #BD9896", +"u c #BBA6A3", +"v c #F2F2F1", +"w c #BAA8A5", +"x c #B79693", +"y c #F8F9F8", +"z c #BA8D8B", +"A c #BCAEAB", +"B c #F5F5F4", +"C c #A47F7B", +"D c #E09392", +"E c #EC8C8C", +"F c #A21B1B", +"G c #B89490", +"H c #BA9694", +"I c #A11C1B", +"J c #EDA7A7", +"K c #E39E9D", +"L c #A68481", +"M c #C6ACA8", +"N c #B21C1C", +"O c #F69090", +"P c #EE9897", +"Q c #BFAEAB", +"R c #C0AFAC", +"S c #EFB2B1", +"T c #F9B1B1", +"U c #B32020", +"V c #D0B5B3", +"W c #E2E5E0", +"X c #B27774", +"Y c #B32221", +"Z c #E6AAA9", +"` c #F8F8F8", +" . c #FAFAF9", +".. c #EAB8B7", +"+. c #B52626", +"@. c #B77B79", +"#. c #F2F3F0", +"$. c #E2E4DF", +"%. c #E6E8E4", +"&. c #C5ADA9", +"*. c #A47C79", +"=. c #A57B78", +"-. c #CDB3B1", +";. c #F1F2F0", +" . + @ @ @ @ @ @ @ @ @ @ + # ", +" + $ $ $ $ $ $ $ $ $ $ $ $ % ", +" @ $ & * = = = = = = - ; $ @ ", +" @ $ > , ' ; ) ! ~ { ] ^ $ @ ", +" @ $ / ( _ : . . < [ ~ } $ @ ", +" @ $ | 1 2 3 4 5 6 7 8 ! $ @ ", +" @ $ 9 2 0 a b b c d e f $ @ ", +" @ $ g h i j k k j l m n $ @ ", +" @ $ . o p q r s t u v . $ @ ", +" @ $ . v w x r y z A B . $ @ ", +" @ $ C D E F G H I J K L $ @ ", +" @ $ M N O P Q R S T U V $ @ ", +" @ $ W X Y Z ` ...+.@.#.$ @ ", +" @ $ $.%.&.*.. . =.-.r ;.$ @ ", +" + $ $ $ $ $ $ $ $ $ $ $ $ % ", +" . + @ @ @ @ @ @ @ @ @ @ + # "}; diff --git a/include/xpm/help-faq.png b/include/xpm/help-faq.png new file mode 100644 index 0000000..f6bc721 Binary files /dev/null and b/include/xpm/help-faq.png differ diff --git a/include/xpm/help-faq.xpm b/include/xpm/help-faq.xpm new file mode 100644 index 0000000..1b8b9fe --- /dev/null +++ b/include/xpm/help-faq.xpm @@ -0,0 +1,92 @@ +/* XPM */ +static const char * help_faq_xpm[] = { +"16 16 73 1", +" c None", +". c #B6B8B4", +"+ c #93938F", +"@ c #888A85", +"# c #8D908A", +"$ c #BDBEBB", +"% c #FCFCFC", +"& c #FFFFFF", +"* c #BBBCBB", +"= c #8D8F89", +"- c #91928E", +"; c #93968F", +"> c #B4B5B1", +", c #EEEEEB", +"' c #A0BDDA", +") c #A3BFDB", +"! c #91B3D5", +"~ c #DBE2EB", +"{ c #FCFCFB", +"] c #BCBDBA", +"^ c #B8B9B7", +"/ c #F1F1F1", +"( c #F2F2F1", +"_ c #ADC6DE", +": c #BFD1E2", +"< c #FEFEFE", +"[ c #8F918C", +"} c #8D8E8A", +"| c #F2F2F0", +"1 c #EFEFED", +"2 c #A1BDDA", +"3 c #91B3D6", +"4 c #E1E7EC", +"5 c #92948F", +"6 c #F5F5F4", +"7 c #BDD0E5", +"8 c #ACC6DF", +"9 c #F4F5F4", +"0 c #8F908C", +"a c #F1F1F0", +"b c #AEC6DE", +"c c #BFD1E3", +"d c #F8F8F6", +"e c #8AAFD5", +"f c #FBFBFB", +"g c #F8F8F7", +"h c #8AAFD6", +"i c #7AA5D3", +"j c #8A8C88", +"k c #FBFBFA", +"l c #90938E", +"m c #8E8F8B", +"n c #FDFDFD", +"o c #7AA5D2", +"p c #8B8D88", +"q c #949591", +"r c #F6F6F5", +"s c #969994", +"t c #C0C1BE", +"u c #FEFEFD", +"v c #90928E", +"w c #90938C", +"x c #EEEEEC", +"y c #8D8F8A", +"z c #939590", +"A c #979994", +"B c #90908C", +"C c #DFDFDE", +"D c #90928D", +"E c #EDEDEC", +"F c #8F908B", +"G c #DFE0DE", +"H c #8E908B", +" ", +" .+@@@@# ", +" .$%&&&&%* ", +" =-@@@@;>,')!~{#", +" ]%&&&&%]^/(_:<[", +"}%|12)34{56789<[", +"0<||a|bc<0dedd&[", +"[<666789<[ffff&[", +"[&ggghgg&[ c #F9F9F8", +", c #4D4E4B", +"' c #5B5E5A", +") c #6E6F6C", +"! c #EEEFEE", +"~ c #FCFDFC", +"{ c #FBFBFB", +"] c #595A57", +"^ c #595A56", +"/ c #646662", +"( c #EBEBEA", +"_ c #575855", +": c #6A6B67", +"< c #767874", +"[ c #EBECEA", +"} c #FAFAFA", +"| c #F2F4F1", +"1 c #F1F1F0", +"2 c #666763", +"3 c #E6E7E6", +"4 c #FAFAF9", +"5 c #626460", +"6 c #73756F", +"7 c #80817C", +"8 c #D4D6D3", +"9 c #F1F2F0", +"0 c #E7E9E4", +"a c #DFE2DD", +"b c #FCFCFB", +"c c #737470", +"d c #CFD1CE", +"e c #F2F3F0", +"f c #E8EAE6", +"g c #E0E2DD", +"h c #6D6E6A", +"i c #82837F", +"j c #ABAEA8", +"k c #F0F1EF", +"l c #F9FAF9", +"m c #FEFEFE", +"n c #797B75", +"o c #7F817C", +"p c #969791", +"q c #EEEFED", +"r c #767973", +"s c #838581", +"t c #91928C", +"u c #C9CBC6", +"v c #838580", +"w c #8D9089", +"x c #AFB0AC", +"y c #81837D", +"z c #90938C", +"A c #9C9E97", +"B c #9A9D97", +"C c #ADAFAA", +"D c #82837E", +" ", +" ", +" ", +" . . ", +" +@@ #@$ ", +" %&*= -;>, ", +" ')!~{]^/(~{_ ", +" :<[}|1{234|1{5 ", +" 67890abcdefgbh ", +" ijklmnopq4mr ", +" stulv wxly ", +" zAB CAo ", +" D D ", +" ", +" ", +" "}; diff --git a/include/xpm/media-seek-forward.png b/include/xpm/media-seek-forward.png new file mode 100644 index 0000000..4d7e2cd Binary files /dev/null and b/include/xpm/media-seek-forward.png differ diff --git a/include/xpm/media-seek-forward.xpm b/include/xpm/media-seek-forward.xpm new file mode 100644 index 0000000..e386c53 --- /dev/null +++ b/include/xpm/media-seek-forward.xpm @@ -0,0 +1,88 @@ +/* XPM */ +static const char * media_seek_forward_xpm[] = { +"16 16 69 1", +" c None", +". c #414140", +"+ c #4A4B48", +"@ c #494A47", +"# c #3D3D3B", +"$ c #3D3F3B", +"% c #4D4E4B", +"& c #F9F9F8", +"* c #696C68", +"= c #4C4C4A", +"- c #4E504C", +"; c #FCFCFC", +"> c #747571", +", c #4E4F4C", +"' c #575855", +") c #FBFBFB", +"! c #FCFDFC", +"~ c #EBEBEA", +"{ c #646662", +"] c #595A56", +"^ c #595A57", +"/ c #EEEFEE", +"( c #6E6F6C", +"_ c #5B5E5A", +": c #626460", +"< c #F1F1F0", +"[ c #F2F4F1", +"} c #FAFAF9", +"| c #E6E7E6", +"1 c #666763", +"2 c #FAFAFA", +"3 c #EBECEA", +"4 c #767874", +"5 c #6A6B67", +"6 c #6D6E6A", +"7 c #FCFCFB", +"8 c #E0E2DD", +"9 c #E8EAE6", +"0 c #F2F3F0", +"a c #CFD1CE", +"b c #737470", +"c c #DFE2DD", +"d c #E7E9E4", +"e c #F1F2F0", +"f c #D4D6D3", +"g c #80817C", +"h c #73756F", +"i c #767973", +"j c #FEFEFE", +"k c #EEEFED", +"l c #969791", +"m c #7F817C", +"n c #797B75", +"o c #F9FAF9", +"p c #F0F1EF", +"q c #ABAEA8", +"r c #82837F", +"s c #81837D", +"t c #AFB0AC", +"u c #8D9089", +"v c #838580", +"w c #C9CBC6", +"x c #91928C", +"y c #838581", +"z c #9C9E97", +"A c #ADAFAA", +"B c #9A9D97", +"C c #90938C", +"D c #82837E", +" ", +" ", +" ", +" . . ", +" +@# @@$ ", +" %&*= -;>, ", +" ')!~{]^)!/(_ ", +" :)<[}|1)<[2345 ", +" 67890ab7cdefgh ", +" ij}klmnjopqr ", +" sotu vowxy ", +" mzA BzC ", +" D D ", +" ", +" ", +" "}; diff --git a/include/xpm/next.xpm b/include/xpm/next.xpm new file mode 100644 index 0000000..606c733 --- /dev/null +++ b/include/xpm/next.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * next_xpm[] = { +"16 16 2 1", +" c #E7E7E7", +". c #0000FF", +" ", +" ", +" ", +" . ", +" ... ", +" ..... ", +" ....... ", +" ......... ", +" ........... ", +" ........... ", +" ......... ", +" ....... ", +" ..... ", +" ... ", +" . ", +" "}; diff --git a/include/xpm/next_sl.xpm b/include/xpm/next_sl.xpm new file mode 100644 index 0000000..da4f178 --- /dev/null +++ b/include/xpm/next_sl.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * next_sl_xpm[] = { +"16 16 5 1", +" c None", +". c #00007F", +"+ c #007FFF", +"@ c #0000FF", +"# c #003F80", +" ", +" .. ", +" .+. ", +" .++. ", +" .++@+. ", +" ....++@+@+. ", +" .@+@+@+@+@+. ", +" .@@@@@@@@+@+. ", +" .@@@@@@@@@@@@. ", +" .@@@@@@@@#@#. ", +" .@#@#@#@#@#. ", +" ....@#@#@#. ", +" .@#@#. ", +" .##. ", +" .#. ", +" .. "}; diff --git a/include/xpm/none.xpm b/include/xpm/none.xpm new file mode 100644 index 0000000..e81575f --- /dev/null +++ b/include/xpm/none.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * none_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +"................", +".. ..", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". .. .", +". .. .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +".. ..", +"................"}; diff --git a/include/xpm/norm_1.xpm b/include/xpm/norm_1.xpm new file mode 100644 index 0000000..a433a58 --- /dev/null +++ b/include/xpm/norm_1.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * norm_1_xpm[] = { +"16 16 3 1", +". c None", +"+ c #7F0000", +"@ c #FF0000", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +".++++++++++++++.", +".+@@@@@@@@@@@@+.", +".+@@@@@@@@@@@@+.", +".++++++++++++++.", +"................", +"................", +"................", +"................", +"................"}; diff --git a/include/xpm/object-rotate-right-on.xpm b/include/xpm/object-rotate-right-on.xpm new file mode 100644 index 0000000..978ad9e --- /dev/null +++ b/include/xpm/object-rotate-right-on.xpm @@ -0,0 +1,67 @@ +/* XPM */ +static char * object_rotate_right_on_xpm[] = { +"16 16 48 1", +" c None", +". c #7439AE", +"+ c #6D36A3", +"@ c #6C36A2", +"# c #6F37A6", +"$ c #7339AC", +"% c #6E37A5", +"& c #F7F3FB", +"* c #F9F5FC", +"= c #F8F4FB", +"- c #EFE7F7", +"; c #D4BEE9", +"> c #8E55C6", +", c #7238AB", +"' c #DECDEE", +") c #DFCFEF", +"! c #E1D2F0", +"~ c #EADFF4", +"{ c #F5F0FA", +"] c #D3BCE9", +"^ c #DAC7EC", +"/ c #DCCAED", +"( c #E2D3F0", +"_ c #EEE5F6", +": c #D8C4EB", +"< c #ECE2F5", +"[ c #D5C0EA", +"} c #773BB2", +"| c #B28BD8", +"1 c #F3ECF9", +"2 c #F1EAF8", +"3 c #945EC9", +"4 c #7138A9", +"5 c #BE9DDE", +"6 c #D1BAE8", +"7 c #7E3FBD", +"8 c #CEB5E6", +"9 c #CDB4E6", +"0 c #CBB1E4", +"a c #C9AEE3", +"b c #C8ACE3", +"c c #FBF8FD", +"d c #C5A8E2", +"e c #C3A4E1", +"f c #C2A3E0", +"g c #E0D0EF", +"h c #C0A0DF", +"i c #F2EBF8", +" .+@@#$$ ", +" %&**=-;>, ", +" @='')!~{]. ", +" @=^^^^^/-($ ", +" %{&&{_'::<[. ", +" ,+@@}|1^;[23 ", +" 45~66![. ", +" 7188;<, ", +" @19081# ", +" @@,1aba1$@@", +" @c1)ddd'1c@", +" @c!efe(c@ ", +" @cghgc@ ", +" @cic@ ", +" @*@ ", +" @ "}; diff --git a/include/xpm/object-rotate-right.png b/include/xpm/object-rotate-right.png new file mode 100644 index 0000000..49e5727 Binary files /dev/null and b/include/xpm/object-rotate-right.png differ diff --git a/include/xpm/object-rotate-right.xpm b/include/xpm/object-rotate-right.xpm new file mode 100644 index 0000000..c9b4357 --- /dev/null +++ b/include/xpm/object-rotate-right.xpm @@ -0,0 +1,103 @@ +/* XPM */ +static const char * object_rotate_right_xpm[] = { +"16 16 84 1", +" c None", +". c #D2650C", +"+ c #CE5D02", +"@ c #CE5C00", +"# c #CF5F03", +"$ c #D1640B", +"% c #D1640C", +"& c #CF5D03", +"* c #FEF7EF", +"= c #FFF9F1", +"- c #FEF8F0", +"; c #FCEFDF", +"> c #F4D1AE", +", c #DB8138", +"' c #D1630A", +") c #FFF8EF", +"! c #FDDCAA", +"~ c #FDDDAB", +"{ c #FDE0B4", +"] c #FEE9CA", +"^ c #FEF6E8", +"/ c #F3CFAA", +"( c #D1650C", +"_ c #FFF8ED", +": c #FDD8A2", +"< c #FDDAA7", +"[ c #FEEED6", +"} c #F9E1C5", +"| c #D2640B", +"1 c #CF5D02", +"2 c #FEF6EA", +"3 c #FFF7EC", +"4 c #FFF5E7", +"5 c #FEEDD4", +"6 c #FDD599", +"7 c #FEEBCE", +"8 c #F6D1A8", +"9 c #D2660D", +"0 c #D2630A", +"a c #D1680F", +"b c #E8AA72", +"c c #FEF2E0", +"d c #FDD191", +"e c #FDD294", +"f c #FEF1DC", +"g c #DD8A40", +"h c #D06107", +"i c #EDB883", +"j c #FEE9CB", +"k c #FDCE89", +"l c #FEDFB3", +"m c #F6D1A9", +"n c #D2650B", +"o c #D5701B", +"p c #FFF3E3", +"q c #FDCA81", +"r c #FDEBD5", +"s c #D16206", +"t c #CE5C01", +"u c #FEF3E2", +"v c #FCC97D", +"w c #FCC778", +"x c #FCCA7F", +"y c #FEF3E3", +"z c #CF5E01", +"A c #D0620A", +"B c #FCC574", +"C c #FCC370", +"D c #FCC473", +"E c #FEF3E4", +"F c #D0640C", +"G c #FEFCF8", +"H c #FDDDAD", +"I c #FCC068", +"J c #FFFCF9", +"K c #FEDFB2", +"L c #FCBE61", +"M c #FCBD5F", +"N c #FEE0B3", +"O c #FEDDAD", +"P c #FCBA5A", +"Q c #FEDEAF", +"R c #FEF1DE", +"S c #FEFAF6", +" .+@@#$% ", +" &*==-;>,' ", +" @)!!~{]^/( ", +" @_:::::<[}| ", +" 123345!66789 ", +" 0+@@abc:defg ", +" hijkklmn ", +" opqqdrs ", +" tuvwxyz ", +" @@AcBCDEF@@", +" @GyHIII!yG@", +" @JKLMLNJ@ ", +" @JOPQJ@ ", +" @JRJ@ ", +" @S@ ", +" @ "}; diff --git a/include/xpm/ok.xpm b/include/xpm/ok.xpm new file mode 100644 index 0000000..0a1c7dc --- /dev/null +++ b/include/xpm/ok.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * ok_xpm[] = { +"16 16 3 1", +" c None", +"! c #000090", +"# c #0000FF", +" ", +" # ", +" ## ", +" ##! ", +" ##! ", +" ##! ", +" ##! ", +" ##! ", +" ##! ", +" ### ###! ", +" ### ##! ", +" #####! ", +" ###! ", +" ##! ", +" #! ", +" ! "}; diff --git a/include/xpm/oper.xpm b/include/xpm/oper.xpm new file mode 100644 index 0000000..ca6a51d --- /dev/null +++ b/include/xpm/oper.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . ", +" . ", +" ..... ..... ", +" . ", +" . ", +" ", +" ", +" ", +" . . ", +" . . . . ", +" . ... ", +" . ... ", +" . . . . ", +" . . ", +" "}; diff --git a/include/xpm/oper_a.xpm b/include/xpm/oper_a.xpm new file mode 100644 index 0000000..afa1a80 --- /dev/null +++ b/include/xpm/oper_a.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_a_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" . ", +" . ", +" . ...... ", +" ....... ", +" . ...... ", +" . ", +" . ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/oper_d.xpm b/include/xpm/oper_d.xpm new file mode 100644 index 0000000..2b89d5e --- /dev/null +++ b/include/xpm/oper_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . ", +" . ", +" . ", +" . ...... ", +" . ", +" . ...... ", +" . ", +" . ", +" . ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/oper_dir.xpm b/include/xpm/oper_dir.xpm new file mode 100644 index 0000000..f6f7b8a --- /dev/null +++ b/include/xpm/oper_dir.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_dir_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" . ", +" . . ", +" . . ", +" . .... . ", +" . . . . ", +" . .... . ", +" . ", +" ..... ", +" . . ", +" .. . ", +" . . . ", +" . . ", +" .... . . ", +". .. . ..... ", +". . . ", +" .. . . "}; diff --git a/include/xpm/oper_m.xpm b/include/xpm/oper_m.xpm new file mode 100644 index 0000000..f2f8db1 --- /dev/null +++ b/include/xpm/oper_m.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * oper_m_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ", +" ", +" . . ", +" +. .+ ", +" +.+ ...... ", +" ...... ", +" +.+ ...... ", +" +. .+ ", +" . . ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/oper_of.xpm b/include/xpm/oper_of.xpm new file mode 100644 index 0000000..c22a9ba --- /dev/null +++ b/include/xpm/oper_of.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * oper_of_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" . ++ ", +" . . ++ ", +" . . ++++++", +" . .... .++++++", +" . . . . ++ ", +" . .... . ++ ", +" . ", +" ..... ", +" . . ", +" .. . ", +" . . . ", +" . . ", +" .... . . ", +". .. . ..... ", +". . . ", +" .. . . "}; diff --git a/include/xpm/oper_s.xpm b/include/xpm/oper_s.xpm new file mode 100644 index 0000000..6bda134 --- /dev/null +++ b/include/xpm/oper_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ...... ", +" ....... ", +" ...... ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/option.xpm b/include/xpm/option.xpm new file mode 100644 index 0000000..d7dd6d6 --- /dev/null +++ b/include/xpm/option.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * option_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F0000", +" ", +" ", +" ", +" .. ", +" .++. ", +" .++. ", +" .. ", +" ", +" ", +" .. ", +" .++. ", +" .++. ", +" .+. ++ ++ ++ ", +" . ++ ++ ++ ", +" . ", +" "}; diff --git a/include/xpm/plot.xpm b/include/xpm/plot.xpm new file mode 100644 index 0000000..e6e79c1 --- /dev/null +++ b/include/xpm/plot.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * plot_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #0000FF", +"@ c #FF0000", +" ", +" . ", +" .. + ", +" . ++ ", +" . + ", +" .. + ", +" . + ", +" . + ", +" .. @@@+ ", +" . @ +@ @ ", +" .@@ + @ @ ", +" .. + @@@ ", +" . ++ ", +" .++ . . . ", +" .............. ", +" "}; diff --git a/include/xpm/preferences-system.png b/include/xpm/preferences-system.png new file mode 100644 index 0000000..9460dfc Binary files /dev/null and b/include/xpm/preferences-system.png differ diff --git a/include/xpm/preferences-system.xpm b/include/xpm/preferences-system.xpm new file mode 100644 index 0000000..1dc058b --- /dev/null +++ b/include/xpm/preferences-system.xpm @@ -0,0 +1,63 @@ +/* XPM */ +static const char * preferences_system_xpm[] = { +"16 16 44 1", +" c None", +". c #888A85", +"+ c #ECEBE9", +"@ c #EFEFEE", +"# c #F0F0EE", +"$ c #F0F0F0", +"% c #FAFAFA", +"& c #8A8C87", +"* c #F6F6F5", +"= c #ABACA9", +"- c #F7F7F7", +"; c #E5E3E2", +"> c #ADADAA", +", c #EEEEEC", +"' c #F3F3F3", +") c #F0F0EF", +"! c #EEEEED", +"~ c #ECECEA", +"{ c #BAB9B6", +"] c #D2D1D0", +"^ c #A4A4A3", +"/ c #B8B7B5", +"( c #B9B8B7", +"_ c #204A87", +": c #7D8385", +"< c #CAC9C8", +"[ c #BFBEBD", +"} c #ADBBCC", +"| c #7C93B3", +"1 c #D4D3D3", +"2 c #BDC8D4", +"3 c #788DA4", +"4 c #92A5BE", +"5 c #E4E3E2", +"6 c #C6C4C2", +"7 c #748AA2", +"8 c #7A95B4", +"9 c #D4D3D2", +"0 c #C4C3C2", +"a c #7D91A7", +"b c #7A95B5", +"c c #728BAE", +"d c #A0A19E", +"e c #869CB8", +" ", +" . . ", +" .+. .@. ", +" .#. .$. ", +" . .%. .& ", +".*=.-;>, . ", +" .')!~{. . ", +" ....]^.. ", +" /.(. ", +" ___:><[. ", +" _}}|_..1[. ", +" _2334_ .56.. ", +"_}378|_ .90. ", +"_}abc_ .d. ", +"_4ee_ ... ", +" ___ "}; diff --git a/include/xpm/prev_sl.xpm b/include/xpm/prev_sl.xpm new file mode 100644 index 0000000..3f20e59 --- /dev/null +++ b/include/xpm/prev_sl.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * prev_sl_xpm[] = { +"16 16 5 1", +" c None", +". c #00007F", +"+ c #007FFF", +"@ c #0000FF", +"# c #003F80", +" ", +" .. ", +" .+. ", +" .++. ", +" .+@++. ", +" .+@+@++.... ", +" .+@+@+@+@+@. ", +" .+@+@@@@@@@@. ", +" .@@@@@@@@@@@@. ", +" .#@#@@@@@@@@. ", +" .#@#@#@#@#@. ", +" .#@#@#@.... ", +" .#@#@. ", +" .##. ", +" .#. ", +" .. "}; diff --git a/include/xpm/preview.xpm b/include/xpm/preview.xpm new file mode 100644 index 0000000..0446109 --- /dev/null +++ b/include/xpm/preview.xpm @@ -0,0 +1,193 @@ +/* XPM */ +static const char *preview_xpm[] = { +"16 16 174 2", +" c None", +". c #EA6E0E", +"+ c #F67F06", +"@ c #E3BB18", +"# c #A4E757", +"$ c #56E6A3", +"% c #25DAD6", +"& c #11E5EB", +"* c #2AF5D0", +"= c #72F588", +"- c #B0EC4B", +"; c #C7DC34", +"> c #C3E336", +", c #98F563", +"' c #3FF6BC", +") c #07D5F5", +"! c #0E9EEA", +"~ c #F44C0A", +"{ c #FC0E00", +"] c #FB1900", +"^ c #FF5B00", +"/ c #F7C407", +"( c #B5FD49", +"_ c #4BFFB3", +": c #0BF6F3", +"< c #05D9F9", +"[ c #0CD2F2", +"} c #14DEEB", +"| c #1BF0E3", +"1 c #20FEDE", +"2 c #27FFD7", +"3 c #2BFDD3", +"4 c #3BEEC3", +"5 c #F14F0A", +"6 c #FC1400", +"7 c #FB1700", +"8 c #FF5000", +"9 c #FBBA03", +"0 c #B8FD46", +"a c #39FCC5", +"b c #01CAFE", +"c c #0088FF", +"d c #0075FF", +"e c #008FFF", +"f c #01CCFE", +"g c #22FCDC", +"h c #73FF8B", +"i c #BAFC44", +"j c #D3E228", +"k c #F47B0A", +"l c #FF8C00", +"m c #F4BA0A", +"n c #CBE733", +"o c #7DFC81", +"p c #2BEDD3", +"q c #03C1FB", +"r c #0090FF", +"s c #0082FF", +"t c #009DFF", +"u c #08D4F7", +"v c #3AFAC4", +"w c #98FF66", +"x c #E7EF18", +"y c #FEBC01", +"z c #F4920A", +"A c #F4AD0B", +"B c #D4F62A", +"C c #63FD9B", +"D c #16D9E9", +"E c #0296FD", +"F c #0063FF", +"G c #0059FF", +"H c #0076FF", +"I c #00B6FF", +"J c #1AF2E4", +"K c #6EFF90", +"L c #C8FD36", +"M c #F9E306", +"N c #FFB900", +"O c #FFA800", +"P c #F4AF0B", +"Q c #EFBD0D", +"R c #A0FF5E", +"S c #1BF3E3", +"T c #009CFF", +"U c #0056FF", +"V c #0041FF", +"W c #005DFF", +"X c #00A0FF", +"Y c #0EEEF0", +"Z c #5FFF9F", +"` c #B7FF47", +" . c #F1FA0D", +".. c #F9E606", +"+. c #F0E70E", +"@. c #D4F42A", +"#. c #9CF05F", +"$. c #F4AA0A", +"%. c #DFF01F", +"&. c #8DFD71", +"*. c #4CF4B2", +"=. c #2DDFD1", +"-. c #21D5DE", +";. c #1CDFE2", +">. c #20F4DE", +",. c #3BFFC3", +"'. c #79FF85", +"). c #80FF7E", +"!. c #72FE8C", +"~. c #51FAAD", +"{. c #28EFD6", +"]. c #14CDEA", +"^. c #F4760A", +"/. c #FF6B00", +"(. c #FD6D00", +"_. c #F87A05", +":. c #F1910C", +"<. c #E9B615", +"[. c #D8DF26", +"}. c #B2FC4C", +"|. c #70FF8E", +"1. c #2DFED1", +"2. c #0BE3F3", +"3. c #04B9FB", +"4. c #0099FE", +"5. c #0085FF", +"6. c #007EFF", +"7. c #0A84F4", +"8. c #F1480A", +"9. c #EA0500", +"0. c #C50000", +"a. c #B30000", +"b. c #BB0100", +"c. c #DA0600", +"d. c #FA3500", +"e. c #FCB403", +"f. c #ACFD52", +"g. c #24F8DA", +"h. c #00A5FF", +"i. c #0036FF", +"j. c #0046FF", +"k. c #007FFF", +"l. c #11C0EA", +"m. c #F4440A", +"n. c #E10100", +"o. c #B20000", +"p. c #990000", +"q. c #9B0000", +"r. c #B90000", +"s. c #EB0500", +"t. c #FF6700", +"u. c #E9E716", +"v. c #75FF89", +"w. c #1EE7E0", +"x. c #09B9F6", +"y. c #06ACF8", +"z. c #11C6ED", +"A. c #38F0C6", +"B. c #8FF26F", +"C. c #E9630E", +"D. c #F43606", +"E. c #E92406", +"F. c #E02006", +"G. c #DE2006", +"H. c #F43706", +"I. c #F56806", +"J. c #F5A106", +"K. c #EBCC11", +"L. c #CED92D", +"M. c #B9DB41", +"N. c #B9DD43", +"O. c #C8D933", +"P. c #E3CE18", +"Q. c #E8AB10", +" ", +" ", +" ", +". + @ # $ % & * = - ; > , ' ) ! ", +"~ { ] ^ / ( _ : < [ } | 1 2 3 4 ", +"5 6 7 8 9 0 a b c d e f g h i j ", +"k l m n o p q r s t u v w x y z ", +"A B C D E F G H I J K L M N O P ", +"Q R S T U V W X Y Z ` ...+.@.#.", +"$.%.&.*.=.-.;.>.,.Z '.).!.~.{.].", +"^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.", +"8.9.0.a.b.c.d.e.f.g.h.U i.j.k.l.", +"m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.", +"C.D.E.F.G.E.H.I.J.K.L.M.N.O.P.Q.", +" ", +" "}; diff --git a/include/xpm/process-stop.png b/include/xpm/process-stop.png new file mode 100644 index 0000000..ab6808f Binary files /dev/null and b/include/xpm/process-stop.png differ diff --git a/include/xpm/process-stop.xpm b/include/xpm/process-stop.xpm new file mode 100644 index 0000000..a5a48e9 --- /dev/null +++ b/include/xpm/process-stop.xpm @@ -0,0 +1,152 @@ +/* XPM */ +static const char * process_stop_xpm[] = { +"16 16 133 2", +" c None", +". c #890000", +"+ c #860000", +"@ c #AF2222", +"# c #F68888", +"$ c #F78B8B", +"% c #F68A8A", +"& c #F68787", +"* c #F58383", +"= c #B82323", +"- c #B12222", +"; c #F38383", +"> c #DC4242", +", c #D52F2F", +"' c #DB3C3C", +") c #F17575", +"! c #B41F1F", +"~ c #B22424", +"{ c #D53737", +"] c #DA3B3B", +"^ c #F06F6F", +"/ c #B11B1B", +"( c #B32626", +"_ c #DB4141", +": c #D75757", +"< c #DACDCD", +"[ c #D75F5F", +"} c #D85C5C", +"| c #E6D9D9", +"1 c #DB5F5F", +"2 c #D93B3B", +"3 c #EF6A6A", +"4 c #B01818", +"5 c #880202", +"6 c #F68989", +"7 c #DB4040", +"8 c #D89292", +"9 c #DBDBDB", +"0 c #DAD6D6", +"a c #D76060", +"b c #D85A5A", +"c c #E6E0E0", +"d c #EDEDED", +"e c #E5A5A5", +"f c #D22F2F", +"g c #D63B3B", +"h c #EE6868", +"i c #890303", +"j c #D53030", +"k c #D89999", +"l c #DFDFDF", +"m c #E2DEDE", +"n c #E6DFDF", +"o c #ECECEC", +"p c #E6ABAB", +"q c #D23131", +"r c #D02F2F", +"s c #CE2F2F", +"t c #ED6565", +"u c #890202", +"v c #DEACAC", +"w c #E8E8E8", +"x c #E8BCBC", +"y c #D13131", +"z c #CF2F2F", +"A c #CC2F2F", +"B c #EC6161", +"C c #D85B5B", +"D c #F1F1F1", +"E c #F3EDED", +"F c #DA6464", +"G c #C92929", +"H c #E94545", +"I c #F58585", +"J c #D75B5B", +"K c #E5DFDF", +"L c #E4AAAA", +"M c #E6A5A5", +"N c #F9F9F9", +"O c #FCF7F7", +"P c #DA6767", +"Q c #C51A1A", +"R c #BD0202", +"S c #E83737", +"T c #F26969", +"U c #D52323", +"V c #D21F1F", +"W c #DE9292", +"X c #CE2828", +"Y c #E9A5A5", +"Z c #FEFEFE", +"` c #E39696", +" . c #BD0000", +".. c #BD0303", +"+. c #E63434", +"@. c #B82424", +"#. c #EF5A5A", +"$. c #D31111", +"%. c #CB0101", +"&. c #D65858", +"*. c #C70303", +"=. c #C50000", +"-. c #C30000", +";. c #C10101", +">. c #D65F5F", +",. c #BE0404", +"'. c #DF2B2B", +"). c #C71D1D", +"!. c #870000", +"~. c #B72121", +"{. c #ED5252", +"]. c #D01010", +"^. c #C70000", +"/. c #C10000", +"(. c #BF0000", +"_. c #BE0505", +":. c #DF2C2C", +"<. c #C41B1B", +"[. c #880000", +"}. c #B41D1D", +"|. c #EB4C4C", +"1. c #CC0F0F", +"2. c #BF0505", +"3. c #DF2D2D", +"4. c #BF1919", +"5. c #B11A1A", +"6. c #EC4A4A", +"7. c #ED4747", +"8. c #EB4343", +"9. c #EA3F3F", +"0. c #E83B3B", +"a. c #E73737", +"b. c #BC1818", +" . + + + + + + . ", +" . @ # $ $ % & * = . ", +" . - ; > , , , , ' ) ! . ", +" . ~ ; > { , , , , { ] ^ / . ", +". ( ; _ : < [ , , } | 1 2 3 4 . ", +"5 6 7 , 8 9 0 a b c d e f g h 5 ", +"i # , , j k l m n o p q r s t u ", +"i # , , , j v w o x y z s A B u ", +"i # , , , C n o D E F s A G H u ", +"i I , , J K o L M N O P Q R S u ", +"5 T U V W o L r X Y Z ` ...+.u ", +". @.#.$.%.&.*.=.-.;.>.R ,.'.).!.", +" . ~.{.].^.=.-./.(. ._.:.<.[. ", +" . }.|.1.-./.(. .2.3.4.[. ", +" . 5.6.7.8.9.0.a.b.[. ", +" . + + + + + + [. "}; diff --git a/include/xpm/right_1.xpm b/include/xpm/right_1.xpm new file mode 100644 index 0000000..a7b3a67 --- /dev/null +++ b/include/xpm/right_1.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * right_1_xpm[] = { +"16 16 3 1", +". c None", +"+ c #7F0000", +"@ c #FF0000", +"................", +"................", +"........+.......", +"........++......", +"........+@+.....", +"..+++++++@@+....", +"..+@@@@@@@@@+...", +"..+@@@@@@@@@@+..", +"..+@@@@@@@@@@@+.", +"..+@@@@@@@@@@+..", +"..+@@@@@@@@@+...", +"..+++++++@@+....", +"........+@+.....", +"........++......", +"........+.......", +"................"}; diff --git a/include/xpm/rotate.xpm b/include/xpm/rotate.xpm new file mode 100644 index 0000000..e6b0220 --- /dev/null +++ b/include/xpm/rotate.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char *rotate_xpm[]={ +"16 16 3 1", +". c None", +"# c #000080", +"a c #8080ff", +"......#########.", +"......#aaaaaa#..", +".......#aaaa##..", +"..###..#aaaaa#..", +".#aa#..#aaa#aa#.", +".#aa#...#a##aa#.", +"#aa#....#a#.#aa#", +"#aa#.....#..#aa#", +"#aa#........#aa#", +"#aa#........#aa#", +".#a#........#a#.", +".#aa#......#aa#.", +"..#aa##..##aa#..", +"...#aaa##aaa#...", +"....##aaaa##....", +"......####......"}; diff --git a/include/xpm/rotate_on.xpm b/include/xpm/rotate_on.xpm new file mode 100644 index 0000000..45cfe6d --- /dev/null +++ b/include/xpm/rotate_on.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char *rotate_on_xpm[]={ +"16 16 3 1", +". c None", +"# c #800000", +"a c #ff0000", +"......#########.", +"......#aaaaaa#..", +".......#aaaa##..", +"..###..#aaaaa#..", +".#aa#..#aaa#aa#.", +".#aa#...#a##aa#.", +"#aa#....#a#.#aa#", +"#aa#.....#..#aa#", +"#aa#........#aa#", +"#aa#........#aa#", +".#a#........#a#.", +".#aa#......#aa#.", +"..#aa##..##aa#..", +"...#aaa##aaa#...", +"....##aaaa##....", +"......####......"}; diff --git a/include/xpm/show_on.xpm b/include/xpm/show_on.xpm new file mode 100644 index 0000000..bce9067 --- /dev/null +++ b/include/xpm/show_on.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * show_on_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF3F00", +" ", +" ", +" ............ ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" ............ "}; diff --git a/include/xpm/show_sl.xpm b/include/xpm/show_sl.xpm new file mode 100644 index 0000000..21e4e90 --- /dev/null +++ b/include/xpm/show_sl.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * show_sl_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #007FFF", +" ", +" ", +" ............ ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" . .++++++. . ", +" ...++++++... ", +" . .++++++. . ", +" ............ "}; diff --git a/include/xpm/size.xpm b/include/xpm/size.xpm new file mode 100644 index 0000000..3a1d846 --- /dev/null +++ b/include/xpm/size.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * size_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .............. ", +" . . . ", +" . ... . ", +" . . . ", +" . . . ", +" . . . . . ", +" .............. ", +" . . . . . ", +" . . . ", +" . . . ", +" . . . ", +" . ... . ", +" . . . ", +" .............. "}; diff --git a/include/xpm/smth.xpm b/include/xpm/smth.xpm new file mode 100644 index 0000000..a2b9d46 --- /dev/null +++ b/include/xpm/smth.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * smth_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" ", +" ", +" ", +" ", +" . ", +" . ", +" . . . ", +" . . .. ", +" +++. . . ", +" +. ++ +++. ", +" . .++ ++ ", +" . . . .+ ", +" . . . . ", +" . ", +" . ", +" "}; diff --git a/include/xpm/squize.xpm b/include/xpm/squize.xpm new file mode 100644 index 0000000..fa68e6a --- /dev/null +++ b/include/xpm/squize.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * squize_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ...... ", +" . . ", +" . . ", +" . . . . ", +" +. . . .+ ", +"...... ......", +" +. . . .+ ", +" . . . . ", +" . . ", +" . . ", +" . . ", +" ...... ", +" ", +" "}; diff --git a/include/xpm/style.xpm b/include/xpm/style.xpm new file mode 100644 index 0000000..9125d5f --- /dev/null +++ b/include/xpm/style.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * style_xpm[] = { +"16 16 3 1", +" c None", +". c #FF0000", +"q c #7F0000", +" ", +" ", +" ", +" qqq qqq ", +" q.q q.q ", +" q.q q.q ", +" q.q q.q ", +" q q ", +" q q ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/include/xpm/sum.xpm b/include/xpm/sum.xpm new file mode 100644 index 0000000..fc017ac --- /dev/null +++ b/include/xpm/sum.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * sum_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .......... ", +" . . ", +" . . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" . ", +" . ", +" . . ", +" . . ", +" .......... ", +" "}; diff --git a/include/xpm/swap.xpm b/include/xpm/swap.xpm new file mode 100644 index 0000000..6ad367c --- /dev/null +++ b/include/xpm/swap.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * swap_xpm[] = { +"16 16 4 1", +" c None", +". c #0000FF", +"+ c #000000", +"@ c #FF0000", +" ", +" . .. ", +" . . ", +" . . ", +" . . ", +" ...... ", +" + + ", +" + + ", +" + + ", +" + + + + ", +" ++ @@@ ++ ", +" +++ @ @ +++ ", +" @ @ ", +" @ @ ", +" @@@ @@@ ", +" "}; diff --git a/include/xpm/system-file-manager.png b/include/xpm/system-file-manager.png new file mode 100644 index 0000000..60cade4 Binary files /dev/null and b/include/xpm/system-file-manager.png differ diff --git a/include/xpm/table.xpm b/include/xpm/table.xpm new file mode 100644 index 0000000..43b33a4 --- /dev/null +++ b/include/xpm/table.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * table_xpm[] = { +"16 16 4 1", +" c None", +"# c #000000", +"o c #777777", +". c #FFFFFF", +" ", +" ###############", +" #ooo#oooo#oooo#", +" #ooo#oooo#oooo#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" ", +" "}; + diff --git a/include/xpm/text-x-generic.png b/include/xpm/text-x-generic.png new file mode 100644 index 0000000..2d7f2d6 Binary files /dev/null and b/include/xpm/text-x-generic.png differ diff --git a/include/xpm/text.xpm b/include/xpm/text.xpm new file mode 100644 index 0000000..56317c0 --- /dev/null +++ b/include/xpm/text.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * text_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ............ ", +" ............ ", +" . .. . ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" .... ", +" "}; diff --git a/include/xpm/tran.xpm b/include/xpm/tran.xpm new file mode 100644 index 0000000..29fa1ee --- /dev/null +++ b/include/xpm/tran.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * tran_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #FF0000", +"@ c #0000FF", +" ", +" ", +" ......++++++++ ", +" . . + ", +" . . ..+ + + ++ ", +" . . + ", +" . . ..+ + + ++ ", +" .++++.++++++++ ", +" . . .. ", +" . . @ ", +" . . .. @@@ ", +" . . @ ", +" . . .. @ ", +" . . @@ ", +" . . .. @@@ ", +" ...... "}; diff --git a/include/xpm/udav.png b/include/xpm/udav.png new file mode 100644 index 0000000..76ba7d9 Binary files /dev/null and b/include/xpm/udav.png differ diff --git a/include/xpm/udav.xpm b/include/xpm/udav.xpm new file mode 100644 index 0000000..714a7b3 --- /dev/null +++ b/include/xpm/udav.xpm @@ -0,0 +1,416 @@ +/* XPM */ +static const char *udav_xpm[]={ +"64 64 349 2", +"Qt c None", +"#n c #000080", +"#h c #010180", +"#y c #010181", +"#s c #020281", +"#c c #020282", +"dg c #030382", +".8 c #030383", +"#r c #040483", +"#m c #040484", +"#g c #050584", +"#M c #050585", +"#q c #060685", +"a. c #060686", +"#p c #070786", +"ck c #070787", +"aj c #080887", +"bm c #080888", +"aK c #090988", +"a4 c #090989", +"aJ c #0a0a89", +"## c #0a0a8a", +"#G c #0b0b8a", +"cx c #0b0b8b", +"b7 c #0c0c8b", +"#z c #0c0c8c", +"b6 c #0d0d8c", +"b8 c #0d0d8d", +"#l c #0e0e8d", +"cj c #0e0e8e", +"b5 c #0f0f8e", +"#S c #0f0f8f", +"ci c #10108f", +"bE c #101090", +"b4 c #111190", +"c2 c #111191", +"#W c #121291", +"b9 c #121292", +"#b c #131392", +"b3 c #131393", +"ak c #141493", +"aD c #141494", +"bG c #151594", +"aq c #151595", +"bF c #161695", +"#i c #161696", +"aE c #171796", +"ae c #171797", +".5 c #181897", +"cq c #181898", +"#L c #191998", +"bU c #191999", +"b2 c #1a1a99", +"aL c #1a1a9a", +"ds c #1b1b9a", +"#A c #1b1b9b", +"#k c #1c1c9b", +"#f c #1c1c9c", +"cG c #1d1d9c", +"bM c #1d1d9d", +"bN c #1e1e9d", +"ch c #1e1e9e", +"bL c #1f1f9e", +"b1 c #1f1f9f", +"#j c #20209f", +"bO c #2020a0", +"cS c #2121a0", +"bY c #2121a1", +"db c #2222a1", +"bK c #2222a2", +"bn c #2323a2", +"a# c #2323a3", +"bH c #2424a4", +"bJ c #2525a4", +"a3 c #2525a5", +"#o c #2626a5", +"df c #2626a6", +"#. c #2727a6", +"bP c #2727a7", +"ai c #2828a7", +"cF c #2828a8", +"cf c #2929a9", +"b0 c #2a2aa9", +"#x c #2a2aaa", +".7 c #2b2baa", +"bI c #2b2bab", +"cy c #2c2cab", +"a5 c #2c2cac", +"aI c #2d2dac", +"#d c #2d2dad", +"cp c #2e2ead", +"bo c #2e2eae", +"ap c #2f2fae", +"#1 c #3030b0", +"cg c #3131b1", +"bZ c #3232b1", +"de c #3333b2", +"dw c #3333b3", +"bQ c #3434b4", +"bp c #3535b5", +"c3 c #3636b5", +"#R c #3636b6", +"cC c #3737b7", +"aC c #3838b7", +"#t c #3838b8", +"#T c #3939b8", +"#F c #3939b9", +"bq c #3a3ab9", +"#6 c #3a3aba", +"aM c #3c3cbb", +"#B c #3d3dbc", +"cr c #3d3dbd", +"#N c #3e3ebd", +"dA c #3e3ebe", +"ar c #3f3fbe", +"bA c #3f3fbf", +"bR c #4040c0", +"bS c #4141c0", +"dh c #4141c1", +"ce c #4242c1", +"da c #4343c3", +"br c #4444c3", +"#X c #4545c4", +"a6 c #4545c5", +"cM c #4646c5", +"bw c #4646c6", +"#e c #4747c6", +"bs c #4747c7", +"bv c #4848c7", +"aB c #4848c8", +"bt c #4949c8", +"bu c #4949c9", +"bx c #4a4ac9", +"as c #4a4aca", +"cs c #4b4bca", +"ct c #4b4bcb", +"#u c #4c4ccb", +"bl c #4c4ccc", +"dz c #5050cf", +"c6 c #5151d0", +"a7 c #5151d1", +"by c #5252d1", +"#H c #5353d2", +"dx c #5454d3", +"d# c #5454d4", +"at c #5555d5", +"aA c #5656d5", +"cw c #5656d6", +"dy c #5757d6", +"bz c #5858d8", +"#a c #5959d9", +"cE c #5a5ad9", +"cL c #5b5bdb", +"a8 c #5c5cdb", +"aN c #5c5cdc", +".6 c #5d5ddd", +"c5 c #5e5edd", +"bk c #5e5ede", +"dt c #5f5fde", +"cT c #6060df", +"al c #6262e1", +"au c #6262e2", +"az c #6464e4", +"af c #6565e4", +"cD c #6565e5", +"#2 c #6666e6", +"d. c #6767e7", +"co c #6868e7", +".9 c #6868e8", +"av c #6969e8", +"cN c #6a6aea", +"a2 c #6b6bea", +"c. c #6b6beb", +"dk c #6c6ceb", +"aO c #6c6cec", +"ay c #6d6dec", +"ad c #6e6eee", +"ax c #6f6fef", +"bD c #7070f0", +"#w c #7171f0", +"aw c #7171f1", +"cu c #7272f1", +"c7 c #7272f2", +"a9 c #7373f2", +"aF c #7373f3", +"dn c #7474f4", +"b. c #7878f7", +"#C c #7979f8", +".4 c #7979f9", +"aP c #7a7af9", +"aa c #7b7bfa", +"b# c #7c7cfb", +"cd c #7e7efd", +"bX c #7f7ffe", +".3 c #800000", +".1 c #800101", +"ba c #8080ff", +".2 c #810101", +".X c #810202", +"dp c #8181ff", +".W c #820202", +".Y c #820303", +"#5 c #8282ff", +".Z c #830303", +"aH c #8383ff", +".R c #840505", +"#v c #8484ff", +".S c #850606", +"bb c #8585ff", +".T c #860707", +"#K c #8686ff", +".U c #870808", +".V c #880808", +"aQ c #8888ff", +".Q c #890a0a", +"dr c #8989ff", +".K c #8a0a0a", +"cz c #8a8aff", +".j c #8b0b0b", +"cK c #8b8bff", +"bc c #8c8cff", +"cU c #8d8dff", +".B c #8e0e0e", +".P c #8e0f0f", +"ao c #8e8eff", +".L c #8f0f0f", +"cH c #9090ff", +"bd c #9292ff", +".C c #931414", +"aR c #9393ff", +".O c #941414", +"#D c #9494ff", +"#O c #9595ff", +"cV c #9696ff", +".M c #981818", +"#E c #9898ff", +".c c #991a1a", +"cO c #9999ff", +".N c #9a1b1b", +".s c #9b1b1b", +".J c #9d1e1e", +"be c #9d9dff", +"aS c #9e9eff", +"dd c #9f9fff", +"c8 c #a1a1ff", +".D c #a32424", +"#7 c #a3a3ff", +"#I c #a5a5ff", +".r c #a72828", +"aT c #a7a7ff", +"do c #a8a8ff", +"cn c #a9a9ff", +".# c #ab2c2c", +"c9 c #ababff", +".A c #ac2c2c", +"cW c #adadff", +"#Y c #aeaeff", +".I c #af2f2f", +"du c #b0b0ff", +"#0 c #b1b1ff", +"c4 c #b2b2ff", +"bf c #b3b3ff", +".E c #b43535", +"cA c #b4b4ff", +"#Q c #b5b5ff", +"dv c #b6b6ff", +"cl c #b7b7ff", +"cX c #b8b8ff", +"aU c #b9b9ff", +"cc c #babaff", +".i c #bc3c3c", +"bW c #bcbcff", +"dm c #bdbdff", +".H c #be3f3f", +"aZ c #bebeff", +"bB c #bfbfff", +"aV c #c0c0ff", +".b c #c14141", +".t c #c14242", +"bg c #c1c1ff", +"#V c #c2c2ff", +".F c #c34343", +"#9 c #c3c3ff", +"cY c #c4c4ff", +"#J c #c5c5ff", +"cP c #c6c6ff", +"aW c #c7c7ff", +"aY c #c8c8ff", +".a c #c94949", +"bC c #c9c9ff", +".k c #ca4a4a", +"c1 c #cacaff", +".G c #cb4b4b", +"aX c #cbcbff", +"di c #ccccff", +"dj c #cdcdff", +"bh c #ceceff", +"a1 c #d0d0ff", +"c# c #d1d1ff", +"c0 c #d2d2ff", +"cR c #d3d3ff", +".z c #d45555", +"cZ c #d4d4ff", +"bT c #d6d6ff", +"dl c #d8d8ff", +"#3 c #dadaff", +"am c #dbdbff", +"bi c #dcdcff", +"ag c #ddddff", +"#P c #dfdfff", +"cI c #e1e1ff", +"bV c #e4e4ff", +".q c #e66666", +"dc c #e6e6ff", +"aG c #e7e7ff", +".d c #e86969", +"cb c #e8e8ff", +"cJ c #eaeaff", +"ab c #ececff", +".u c #ed6d6d", +"bj c #ededff", +"cB c #efefff", +"#U c #f0f0ff", +"cQ c #f1f1ff", +"cv c #f2f2ff", +"dq c #f4f4ff", +"cm c #f5f5ff", +"ca c #f6f6ff", +"a0 c #f7f7ff", +"an c #f9f9ff", +"ah c #fafaff", +"#Z c #fbfbff", +"ac c #fcfcff", +"#8 c #fdfdff", +"#4 c #fefeff", +".y c #ff7f7f", +".h c #ff8686", +".v c #ff9292", +".l c #ff9595", +".x c #ff9d9d", +".w c #ffa5a5", +".p c #ffb0b0", +".e c #ffb3b3", +".g c #ffbfbf", +".f c #ffcece", +".m c #ffd9d9", +".o c #ffe8e8", +".n c #fff8f8", +".0 c #ffff00", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.#.a.b.cQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.c.d.e.f.g.h.iQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.j.k.l.m.n.o.p.q.rQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.s.t.u.v.w.x.y.z.A.BQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.C.D.E.F.G.a.H.I.J.BQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.K.L.C.M.N.N.M.O.P.QQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.R.S.T.U.V.V.V.U.T.SQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.W.X.W.W.W.W.Y.Y.Z.RQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.1.1.1.1.1.1.2.W.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.3.3.3.3.3.2.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.4.5.2.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.6.7.8.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.9#..8.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0###a#b#c.0.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0#d#e#f#g#h.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0#i#j#k#l#m#h#n#o.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0#p#q#r#s#n#n#m#t#u#v#w#x.0.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0#y#h#n#m#r#q#z#A#B#C#D#E#F.0.0.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0#r#s#h#h#h#y#r#G#j#H#I#J#K#L.0.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0#n#n#n#y#M#b#N#O#P#Q#R.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0#h#n#h#r#S#T#E#U#V#N.0.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0#h#h#r#W#X#Y#Z#0#1.0.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0#y#q#k#2#3#4#5.5.0.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0#c#z#6#7#8#9#X#q.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0a.a#aaabacadae.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0#m.5afagah#Kai.0.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0.0.0.0.0.0.0.0.0#gaj.0.0.0.0.0.0.0.0.0akalamanaoapaj.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt.0.0a.aqa#aparasatauavadawaxayazaAaBaCa#aDaEaFaGanaHaIaJ.0.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtaKaL#xaM#uaNaOaPaQaRaSaT#0aUaVaWaXaXaYaZ#Y#E#.aSa0a1a2a3a4.0.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQt###fa5#Ta6a7a8afaOa9b.b#babbbcbdbeaTbfbgbhbiaGbjbk#3#Z#IblaLajbm.0.0.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtaDbnbobpbqarbrbsbtbuaBbvbw#e#ebx#ubybzaladaaao#7bAbB#8bCbDapbEa.aObqbF.0.0QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtbGbH#dbobI#x.7a5a5#xaibJbK#jbLbMbNbNbObnbP#dbQbRbSaZ#4bTbbarbUa4#ZbVbWbXbr#LQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQt#SbYapbZb0b1b2b2aLbUaEb3b4b5b6b7#G#####Gb7b8#Sb9c.bT#4c#bbbrbL#z#q#Pca#8cbcccdcebFQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQt#icf#taMcgchcicj#Scjb7a4ck#q#g#m#r.8.8.8.8#rblclca#ZaUaF#NbMb8a.#MaQ#0amcmah#Pcncocpa4QtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQt#Gcq.7crcsctcra3b6aJbma.#m.8#c#s#y#y#y#hbJcu#Vcvcvcaaocw#1.5cx#q#rcybSalczcA#PcacBaYaQa6aEQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQt###ka#cCctaNcDazcEbt#tcFch.5cGb0bRazcHbBcIbjbVcJcKcLaCbLbEbm#m.8##bE#AaIcMcNcOcPcbcQcR#EatcSQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtajcj#L#dcCcscTcu#5cUcVbe#IcWcXcYbhcZc0c1cRcUaycsbZbNc2aJ#M.8#ca..8#q##b9bLc3aAbXc4biab#3#7c5#o#pQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQt#qaKb8bGchbSaBc6cE#2c7bX#KbccVc8c9#Qd.d#da#1db#i#laK#M.8#s#sa.#h#y#c#r#pb8cqb0btaF#7a1dccZdda8#o#MQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQt#g#g#paJb8b9.5chbJbI#1c3cC#t#Rde#ddf#jcqb9b6aK#q#r#c#s#y#y.0#h#n#n#h#ydg#M##ak#odhc.dddi#PdjcVd#dbQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQt.8.8#m#M#paK###zcj#SbEbEbE#S#lb7aJaj#q#m.8#c#s#y#h#h#s.0.0.0Qt#m#h#h#y#c#maKb9bndhdkbeaXdldm#vbw#LQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQt#c#c#cdgdg.8#r#m#m#m#m#m#r.8dg#c#s#y#h#h#h#n#h#y.0.0QtQtQtQtQtQtQt#y#y#s#maK#ba3brdndodia1aU#Obyb4QtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQt#s#y#y#y#y#y#y#y#y#y#h#h#h#h#n#n#n#n#n#n#yQtQtQtQtQtQtQtQtQtQtQtQtQt#y#c#maJaDbIa7dpaZdqaha1drbAb3QtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtdg#y#h#h#n#n#n#n#n#n#n#n#n#n#n#n#hdgQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#s#c#Mcxdsc3dtaodudvaScudhdsQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtdg#y#h#h#h#n#n#n#h#y#cQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtdg#pbEb1dwbwdxdydzdA#xaEQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#maJb5bGdsbLbOchaLakb8ckQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#q#qckaKaJ####a4bm#p#pQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#m#c#cdgdgdg.8.8.8#rQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#y#h#h#h#h#h#y#s#rQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#h#n#n#n#n#h#cQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt#h#h#yQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt", +"QtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQtQt"}; diff --git a/include/xpm/up_1.xpm b/include/xpm/up_1.xpm new file mode 100644 index 0000000..472b450 --- /dev/null +++ b/include/xpm/up_1.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * up_1_xpm[] = { +"16 16 3 1", +". c None", +"+ c #7F0000", +"@ c #FF0000", +"................", +"................", +"........+.......", +".......+@+......", +"......+@@@+.....", +".....+@@@@@+....", +"....+@@@@@@@+...", +"...+@@@@@@@@@+..", +"..++++@@@@@++++.", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+@@@@@+....", +".....+++++++....", +"................"}; diff --git a/include/xpm/update.xpm b/include/xpm/update.xpm new file mode 100644 index 0000000..5ee1dd6 --- /dev/null +++ b/include/xpm/update.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char *update_xpm[] = { +"16 16 2 1", +" c None", +". c #00007F", +" ", +" ", +" .... ", +" . . ", +" . ..... ", +" . ... ", +" . ", +" ", +" ", +" . ", +" ... . ", +" ..... . ", +" . . ", +" .... ", +" ", +" "}; diff --git a/include/xpm/view-refresh.png b/include/xpm/view-refresh.png new file mode 100644 index 0000000..3fd71d6 Binary files /dev/null and b/include/xpm/view-refresh.png differ diff --git a/include/xpm/view-refresh.xpm b/include/xpm/view-refresh.xpm new file mode 100644 index 0000000..32d59ea --- /dev/null +++ b/include/xpm/view-refresh.xpm @@ -0,0 +1,113 @@ +/* XPM */ +static const char * view_refresh_xpm[] = { +"16 16 94 2", +" c None", +". c #3A69A7", +"+ c #3A6AA7", +"@ c #3667A5", +"# c #3969A7", +"$ c #3868A6", +"% c #6890C0", +"& c #8FB0D3", +"* c #A8C2DF", +"= c #A8C1DE", +"- c #93B1D4", +"; c #5F87B9", +"> c #3767A5", +", c #3465A4", +"' c #3969A6", +") c #8CADD3", +"! c #9DBDDC", +"~ c #A1BEDD", +"{ c #B4CBE5", +"] c #BFD3E9", +"^ c #CCDDEE", +"/ c #D5E2F0", +"( c #BFD2E7", +"_ c #4B77AF", +": c #4371AB", +"< c #3566A4", +"[ c #6990C0", +"} c #7298C5", +"| c #3C6BA8", +"1 c #5D85B7", +"2 c #A1BBD9", +"3 c #D8E4F1", +"4 c #DBE6F2", +"5 c #DDE8F3", +"6 c #88A7CE", +"7 c #C8D8EA", +"8 c #4170AB", +"9 c #3C6CA9", +"0 c #3869A6", +"a c #6188B9", +"b c #CDDBEB", +"c c #E2EBF5", +"d c #E6EEF6", +"e c #3565A4", +"f c #6891C7", +"g c #C7D7E9", +"h c #C6D8EB", +"i c #E3ECF5", +"j c #3A6AA6", +"k c #8FACD0", +"l c #E7EEF6", +"m c #4774AD", +"n c #4C77AF", +"o c #4C78AF", +"p c #E5EDF5", +"q c #E5EDF6", +"r c #E4ECF5", +"s c #9CB7D7", +"t c #3768A6", +"u c #C4D7EB", +"v c #C9D9EA", +"w c #3566A5", +"x c #6C95C9", +"y c #537FB7", +"z c #E4EDF5", +"A c #C1D2E6", +"B c #4D79B0", +"C c #3C6BA9", +"D c #4F7CB6", +"E c #3768A5", +"F c #95B2D4", +"G c #E0E9F4", +"H c #CCDCED", +"I c #8FADD2", +"J c #4C78B0", +"K c #3D6DA9", +"L c #5B84B7", +"M c #4E7AB1", +"N c #B4CAE3", +"O c #C9DAEC", +"P c #BCD1E7", +"Q c #B0C9E3", +"R c #A0BEDE", +"S c #88ABD2", +"T c #82A5CE", +"U c #8EAED3", +"V c #3767A6", +"W c #5580B5", +"X c #84A6CE", +"Y c #97B6D8", +"Z c #99B9DB", +"` c #8AACD3", +" . c #6D94C2", +".. c #3B6BA7", +" . + @ # + ", +" $ % & * = - ; > , ", +" ' ) ! ~ { ] ^ / ( _ @ : < ", +" # [ } | < + 1 2 3 4 5 6 7 + ", +" $ 8 9 + 0 a b c d d + ", +" e + f > < g h i j ", +" , $ k l 4 d j ", +" , , m n n o , ", +" , , , , , , , ", +" , p q r s t , ", +" < d u v , w x y , ", +" > d i z A B 0 C D + E ", +" $ 3 F G 5 H I J w ' ' K J + ", +" > L @ M N O P Q R S T U $ ", +" , @ V W X Y Z ` .$ ", +" , + 0 < + .. "}; diff --git a/include/xpm/weather-clear.png b/include/xpm/weather-clear.png new file mode 100644 index 0000000..7dc15ea Binary files /dev/null and b/include/xpm/weather-clear.png differ diff --git a/include/xpm/weather-clear.xpm b/include/xpm/weather-clear.xpm new file mode 100644 index 0000000..2b21ab2 --- /dev/null +++ b/include/xpm/weather-clear.xpm @@ -0,0 +1,95 @@ +/* XPM */ +static const char * weather_clear_xpm[] = { +"16 16 76 1", +" c None", +". c #FCB03E", +"+ c #FCB13E", +"@ c #FCAF3E", +"# c #FCB23F", +"$ c #FDCD83", +"% c #FCCC82", +"& c #FCC470", +"* c #FCB953", +"= c #FCB23E", +"- c #FCC66D", +"; c #FDE6BF", +"> c #FEF9E7", +", c #FEFCF0", +"' c #FEF9DF", +") c #FDEAAD", +"! c #FBBA57", +"~ c #FCB33F", +"{ c #FDE6C1", +"] c #FEFEFB", +"^ c #FEFCEF", +"/ c #FEF8CE", +"( c #FDF4B0", +"_ c #FCF4AD", +": c #FDF0A2", +"< c #FAB545", +"[ c #FEF8E7", +"} c #FEFDF0", +"| c #FEF9CF", +"1 c #FDF4AC", +"2 c #FDF089", +"3 c #FCEF87", +"4 c #FCD964", +"5 c #FCB33E", +"6 c #FCCD84", +"7 c #FEFCF1", +"8 c #FEF8D0", +"9 c #FEF9D0", +"0 c #FDF6BE", +"a c #FDF3A1", +"b c #FCEF81", +"c c #FCEC68", +"d c #FCE768", +"e c #FBB13E", +"f c #FCC570", +"g c #FEFAE3", +"h c #FDF5B1", +"i c #FDF4AE", +"j c #FDF3A2", +"k c #FDF08C", +"l c #FCED71", +"m c #FCE959", +"n c #FCE459", +"o c #FBB13F", +"p c #FCBC57", +"q c #FDECB4", +"r c #FCF4AB", +"s c #FDF08B", +"t c #FCEF82", +"u c #FCEA5A", +"v c #FCEA57", +"w c #FBD349", +"x c #FBBD5B", +"y c #FDF1AA", +"z c #FCEF84", +"A c #FCEB65", +"B c #FCE956", +"C c #FCE34E", +"D c #FAB43F", +"E c #FCB43F", +"F c #FBB94A", +"G c #FBDB6C", +"H c #FCE86E", +"I c #FCE55D", +"J c #FCD549", +"K c #FBB43F", +" ", +" .+ ", +" ++ ", +" @# $%&* =@ ", +" =-;>,')!~# ", +" {]^/(_:< ", +" $[}}|12345 ", +" ++67890abcde+. ", +" .+fghijklmno++ ", +" pqrstluvw# ", +" xyzABvCD ", +" #EFGHIJK5= ", +" @= #oe5 #@ ", +" ++ ", +" +. ", +" "}; diff --git a/include/xpm/window.xpm b/include/xpm/window.xpm new file mode 100644 index 0000000..28ac182 --- /dev/null +++ b/include/xpm/window.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static const char * window_xpm[] = { +"16 16 10 1", +" c None", +". c #000000", +"+ c #333377", +"@ c #FFFFFF", +"# c #777777", +"$ c #00007F", +"% c #4444FF", +"& c #FF0000", +"* c #007F00", +"= c #7F0000", +" ", +" ", +".............. ", +".++++++++++++. ", +".@@@@@#@@@@@@. ", +".@$.............", +".@@.%%%%%%%%%%%.", +".@$.@@@@@#@@@@@.", +".@@.@$$@@#@@@@@.", +".@$.@@@@@#@@@@@.", +".@@.@$&*@#@@@@@.", +"....@@@@@#@@@@@.", +" .@$&=@#@@@@@.", +" .@@@@@#@@@@@.", +" .............", +" "}; diff --git a/include/xpm/wire.xpm b/include/xpm/wire.xpm new file mode 100644 index 0000000..b67d50b --- /dev/null +++ b/include/xpm/wire.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * wire_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . . ", +" . . ", +" . . ", +" ............ ", +" . . ", +" . . ", +" . . ", +" . . ", +" ............ ", +" . . ", +" . . ", +" . . ", +" "}; diff --git a/include/xpm/x-office-presentation.png b/include/xpm/x-office-presentation.png new file mode 100644 index 0000000..f7ea302 Binary files /dev/null and b/include/xpm/x-office-presentation.png differ diff --git a/include/xpm/x-office-spreadsheet.png b/include/xpm/x-office-spreadsheet.png new file mode 100644 index 0000000..a6b1268 Binary files /dev/null and b/include/xpm/x-office-spreadsheet.png differ diff --git a/include/xpm/x-office-spreadsheet.xpm b/include/xpm/x-office-spreadsheet.xpm new file mode 100644 index 0000000..8707737 --- /dev/null +++ b/include/xpm/x-office-spreadsheet.xpm @@ -0,0 +1,143 @@ +/* XPM */ +static const char * x_office_spreadsheet_xpm[] = { +"16 16 124 2", +" c None", +". c #999999", +"+ c #818181", +"@ c #FFFFFF", +"# c #B7B7B7", +"$ c #B7B7B8", +"% c #9E9E9F", +"& c #B8B8B8", +"* c #9F9F9F", +"= c #B8B8B9", +"- c #9E9E9E", +"; c #9F9F9E", +"> c #B7B8B7", +", c #C3C3C3", +"' c #EEEEEE", +") c #C2C2C2", +"! c #EEEFEE", +"~ c #EFEEEF", +"{ c #B1B1B1", +"] c #B9B8B9", +"^ c #E0E0E0", +"/ c #E0E1E0", +"( c #E1E0E0", +"_ c #E1E1E1", +": c #B9B8B8", +"< c #C4C4C4", +"[ c #C3C4C4", +"} c #EEEEEF", +"| c #EFEFEF", +"1 c #F0EFEF", +"2 c #B9B9B8", +"3 c #B9B9B9", +"4 c #C9A6A5", +"5 c #AE3A36", +"6 c #A50F0C", +"7 c #A40201", +"8 c #A40D0A", +"9 c #B03B37", +"0 c #8D6969", +"a c #9E403D", +"b c #A70A07", +"c c #C66453", +"d c #CB715C", +"e c #C9735D", +"f c #C5715B", +"g c #BF6C59", +"h c #C06E61", +"i c #AC201D", +"j c #A73634", +"k c #B2B2B2", +"l c #A65C5B", +"m c #AF2017", +"n c #CB725D", +"o c #C7654D", +"p c #BB5338", +"q c #B65136", +"r c #B04E35", +"s c #B35D47", +"t c #AE5B45", +"u c #A95743", +"v c #AA2F28", +"w c #9F2523", +"x c #A51412", +"y c #CA6F5A", +"z c #BF5439", +"A c #BA5237", +"B c #B44F36", +"C c #AF4D34", +"D c #886556", +"E c #765F5A", +"F c #715B56", +"G c #6B5853", +"H c #77605B", +"I c #9D0D0C", +"J c #C76951", +"K c #B85137", +"L c #B24E36", +"M c #AD4C34", +"N c #AE653A", +"O c #95995D", +"P c #1D84A0", +"Q c #177F99", +"R c #3D91A5", +"S c #3B8EA0", +"T c #A20101", +"U c #9F1212", +"V c #CA7E6D", +"W c #B85F48", +"X c #AB4C33", +"Y c #A64932", +"Z c #B18B44", +"` c #B8BC50", +" . c #358086", +".. c #509CAD", +"+. c #278397", +"@. c #496E77", +"#. c #970909", +"$. c #BC7878", +"%. c #9C1D1A", +"&. c #BD7E6D", +"*. c #BE7F70", +"=. c #BD8374", +"-. c #CDC787", +";. c #CBD089", +">. c #B4B48A", +",. c #5C93A0", +"'. c #44656D", +"). c #7B1618", +"!. c #A12F2F", +"~. c #959595", +"{. c #934040", +"]. c #9E0605", +"^. c #99463D", +"/. c #9E624D", +"(. c #A6A14C", +"_. c #9F9B4A", +":. c #948845", +"<. c #4B3C43", +"[. c #9A0505", +"}. c #A32B2B", +"|. c #991C1C", +"1. c #A00C0C", +"2. c #A30201", +"3. c #A42525", +". + + + + + + + + + + + + ", +"+ @ @ @ @ @ @ @ @ @ @ @ @ + ", +"+ @ # # $ % & & * = = * @ + ", +"+ @ - ; * * * * * * * * @ + ", +"+ @ > , , * ' ' ) ! ~ ) @ + ", +"+ @ { & ] * ^ / ) ( _ ) @ + ", +"+ @ : < [ * } ~ ) | 1 ) @ + ", +"+ @ { 2 3 * 4 5 6 7 7 8 9 0 ", +"+ @ 3 < < a b c d e f g h i j ", +"+ @ k 3 l m n o p q r s t u v w ", +"+ @ 3 < x y z A B C D E F G H I ", +"+ @ k 3 7 J K L M N O P Q R S T ", +"+ @ 3 < U V W X Y Z ` ...+.@.#.", +"+ @ @ @ $.%.&.*.=.-.;.>.,.'.).!.", +"~.+ + + + {.].^./.(._.:.<.[.}. ", +" |.1.2.T 1.3. "}; diff --git a/include/xpm/zoom-fit-best-r.xpm b/include/xpm/zoom-fit-best-r.xpm new file mode 100644 index 0000000..a77f7e1 --- /dev/null +++ b/include/xpm/zoom-fit-best-r.xpm @@ -0,0 +1,88 @@ +/* XPM */ +static const char * zoom_fit_best_r_xpm[] = { +"16 16 69 1", +" c None", +". c #C34C4C", +"+ c #C34E4E", +"@ c #D98C8C", +"# c #E9BCBC", +"$ c #F2D8D8", +"% c #C95C5C", +"& c #EAC1C1", +"* c #ECC7C7", +"= c #DC9595", +"- c #EBC3C3", +"; c #CF7070", +"> c #B33C3C", +", c #BD3F3F", +"' c #D27878", +") c #D07373", +"! c #BA3E3E", +"~ c #FEFDFD", +"{ c #D37E7E", +"] c #BE3F3F", +"^ c #B13B3B", +"/ c #C44F4F", +"( c #DA9090", +"_ c #D27979", +": c #B83D3D", +"< c #D58282", +"[ c #D07171", +"} c #E1A6A6", +"| c #DFA0A0", +"1 c #CD6868", +"2 c #CB6464", +"3 c #D37C7C", +"4 c #C75757", +"5 c #C95E5E", +"6 c #C85B5B", +"7 c #AC3939", +"8 c #DD9A9A", +"9 c #C75858", +"0 c #AE3939", +"a c #DE9D9D", +"b c #DB9393", +"c c #EECDCD", +"d c #CB6262", +"e c #B23B3B", +"f c #EFCFCF", +"g c #EDC8C8", +"h c #D47F7F", +"i c #B73D3D", +"j c #CD6A6A", +"k c #CE6C6C", +"l c #CA6060", +"m c #EECCCC", +"n c #F1D4D4", +"o c #E6B5B5", +"p c #E9BEBE", +"q c #F0D3D3", +"r c #CE6D6D", +"s c #903030", +"t c #DF9F9F", +"u c #F3DEDE", +"v c #C34B4B", +"w c #DC9797", +"x c #DE9C9C", +"y c #C65555", +"z c #822B2B", +"A c #DA9191", +"B c #852C2C", +"C c #7F2A2A", +"D c #812B2B", +" .+..+. ", +" .@#$$#@. ", +" %&*=@@=-&% ", +" .&;>,')!>;&. ", +".@->~~{]~~^-@. ", +"/#(,~]_):~>(#+ ", +".$<[,[}|12%_$. ", +".$3452=@67+3$. ", +"/&87~7990~7a&/ ", +".bc^~~>d~~efb. ", +" /ghi:jk::hg. ", +" lmn#oopqclrs ", +" /tcuuc|/vwxs ", +" /y//4/ z>vAB", +" C^;B", +" CD "}; diff --git a/include/xpm/zoom-fit-best.png b/include/xpm/zoom-fit-best.png new file mode 100644 index 0000000..eb28409 Binary files /dev/null and b/include/xpm/zoom-fit-best.png differ diff --git a/include/xpm/zoom-fit-best.xpm b/include/xpm/zoom-fit-best.xpm new file mode 100644 index 0000000..c093447 --- /dev/null +++ b/include/xpm/zoom-fit-best.xpm @@ -0,0 +1,133 @@ +/* XPM */ +static const char * zoom_fit_best_xpm[] = { +"16 16 114 2", +" c None", +". c #878B87", +"+ c #868C8A", +"@ c #888B89", +"# c #ACB6BF", +"$ c #CDD6DD", +"% c #E4E7E9", +"& c #929594", +"* c #CFD8E0", +"= c #D3DDE5", +"- c #A4BFDC", +"; c #99B9DA", +"> c #9AB9DA", +", c #A4BFDD", +"' c #CFDAE5", +") c #87A6CA", +"! c #547FB5", +"~ c #5B84B8", +"{ c #8AAAD0", +"] c #88A9CF", +"^ c #5983B7", +"/ c #537EB5", +"( c #527EB5", +"_ c #FFFFFF", +": c #90AED2", +"< c #5C85B8", +"[ c #507DB4", +"} c #868C8B", +"| c #9DBBDA", +"1 c #5E86B8", +"2 c #8CABD1", +"3 c #87A8CF", +"4 c #5982B7", +"5 c #9EBBDA", +"6 c #878B88", +"7 c #8EB2D6", +"8 c #85A7CE", +"9 c #5A84B7", +"0 c #86A7CE", +"a c #AFC8E4", +"b c #AAC5E2", +"c c #7DA1CC", +"d c #799FCA", +"e c #7199C8", +"f c #86ACD4", +"g c #89AED4", +"h c #6C96C6", +"i c #739AC8", +"j c #799ECA", +"k c #A0BEDF", +"l c #9AB9DC", +"m c #7198C7", +"n c #4D7AB2", +"o c #638FC2", +"p c #878C8B", +"q c #CFD8DE", +"r c #A7C1DD", +"s c #4D7BB3", +"t c #4E7BB3", +"u c #6E97C6", +"v c #4F7CB3", +"w c #A9C3DE", +"x c #D0D8DE", +"y c #888B87", +"z c #B1BAC1", +"A c #D9E1E8", +"B c #517DB4", +"C c #779DC9", +"D c #527EB4", +"E c #DAE2E8", +"F c #B2BBC1", +"G c #8A8C8A", +"H c #D7DDE2", +"I c #96B0CF", +"J c #5680B5", +"K c #5681B6", +"L c #7FA2CC", +"M c #80A3CC", +"N c #5781B6", +"O c #D8DEE3", +"P c #949895", +"Q c #DADFE3", +"R c #E1E6EA", +"S c #C7D7E8", +"T c #BDD2E6", +"U c #BED2E6", +"V c #C8D8E8", +"W c #DFE5EA", +"X c #DBE0E4", +"Y c #959896", +"Z c #9DA09B", +"` c #60625F", +" . c #8A8D8A", +".. c #BCC1C4", +"+. c #DCE0E2", +"@. c #E9EBEB", +"#. c #BDC2C5", +"$. c #898C88", +"%. c #878A84", +"&. c #B9BCB6", +"*. c #BDBFBC", +"=. c #61635F", +"-. c #8A8C88", +";. c #8D918D", +">. c #8B8D89", +",. c #8E918D", +"'. c #575955", +"). c #7A7B78", +"!. c #B7B8B6", +"~. c #595B57", +"{. c #555753", +"]. c #767873", +"^. c #A0A29F", +"/. c #565854", +" . + . . + . ", +" @ # $ % % $ # @ ", +" & * = - ; > , ' * & ", +" @ * ) ! ~ { ] ^ / ) * @ ", +". # ' ( _ _ : < _ _ [ ' # . ", +"} $ | ~ _ 1 2 3 4 _ ! 5 $ + ", +"6 % 7 8 9 0 a b c d e f % . ", +"6 % g h i j k l m n o g % . ", +"p q r s _ t u u v _ t w x p ", +"y z A B _ _ / C _ _ D E F y ", +" G H I J K L M N K I O . ", +" P Q R S T U V W X Y Z ` ", +" ...+.@.@.+.#.$.%.&.*.=. ", +" -.;.>.>.,.-. '.).%.!.~.", +" {.].^.~.", +" {./. "}; diff --git a/include/xpm/zoom-in.png b/include/xpm/zoom-in.png new file mode 100644 index 0000000..31ac736 Binary files /dev/null and b/include/xpm/zoom-in.png differ diff --git a/include/xpm/zoom-in.xpm b/include/xpm/zoom-in.xpm new file mode 100644 index 0000000..22e285b --- /dev/null +++ b/include/xpm/zoom-in.xpm @@ -0,0 +1,124 @@ +/* XPM */ +static const char * zoom_in_xpm[] = { +"16 16 105 2", +" c None", +". c #878B87", +"+ c #868C8A", +"@ c #888B89", +"# c #ACB6BF", +"$ c #CDD6DD", +"% c #E4E7E9", +"& c #929594", +"* c #CFD8E0", +"= c #D3DDE5", +"- c #A4BFDC", +"; c #99B9DA", +"> c #9AB9DA", +", c #A4BFDD", +"' c #CFDAE5", +") c #B4C9DF", +"! c #9DBDDD", +"~ c #B5CDE6", +"{ c #5C84B8", +"] c #5B84B8", +"^ c #B0CAE4", +"/ c #9ABADD", +"( c #98B9DC", +"_ c #BCD1E8", +": c #5F87B9", +"< c #FFFFFF", +"[ c #5A84B7", +"} c #ABC6E2", +"| c #91B4DA", +"1 c #868C8B", +"2 c #9DBBDA", +"3 c #B6CDE6", +"4 c #5D85B8", +"5 c #5E86B8", +"6 c #5982B7", +"7 c #5781B6", +"8 c #9FBDDE", +"9 c #9EBBDA", +"0 c #878B88", +"a c #8EB2D6", +"b c #5983B7", +"c c #507DB4", +"d c #86ACD4", +"e c #89AED4", +"f c #4E7BB3", +"g c #4A78B2", +"h c #878C8B", +"i c #CFD8DE", +"j c #A7C1DD", +"k c #86ADD6", +"l c #4F7CB3", +"m c #89AED6", +"n c #A9C3DE", +"o c #D0D8DE", +"p c #888B87", +"q c #B1BAC1", +"r c #D9E1E8", +"s c #94B6DA", +"t c #96B7DB", +"u c #527EB5", +"v c #537EB5", +"w c #97B8DB", +"x c #DAE2E8", +"y c #B2BBC1", +"z c #8A8C8A", +"A c #D7DDE2", +"B c #CAD8E6", +"C c #A4C0DF", +"D c #A6C2E0", +"E c #A7C3E1", +"F c #D8DEE3", +"G c #949895", +"H c #DADFE3", +"I c #E1E6EA", +"J c #C7D7E8", +"K c #BDD2E6", +"L c #BED2E6", +"M c #C8D8E8", +"N c #DFE5EA", +"O c #DBE0E4", +"P c #959896", +"Q c #9DA09B", +"R c #60625F", +"S c #8A8D8A", +"T c #BCC1C4", +"U c #DCE0E2", +"V c #E9EBEB", +"W c #BDC2C5", +"X c #898C88", +"Y c #878A84", +"Z c #B9BCB6", +"` c #BDBFBC", +" . c #61635F", +".. c #8A8C88", +"+. c #8D918D", +"@. c #8B8D89", +"#. c #8E918D", +"$. c #575955", +"%. c #7A7B78", +"&. c #B7B8B6", +"*. c #595B57", +"=. c #555753", +"-. c #767873", +";. c #A0A29F", +">. c #565854", +" . + . . + . ", +" @ # $ % % $ # @ ", +" & * = - ; > , ' * & ", +" @ * ) ! ~ { ] ^ / ) * @ ", +". # ' ( _ : < < [ } | ' # . ", +"1 $ 2 3 4 5 < < 6 7 8 9 $ + ", +"0 % a b < < < < < < c d % . ", +"0 % e f < < < < < < g e % . ", +"h i j k f f < < l f m n o h ", +"p q r s t u < < v ( w x y p ", +" z A B C D 7 7 E D B F . ", +" G H I J K L M N O P Q R ", +" S T U V V U W X Y Z ` . ", +" ..+.@.@.#... $.%.Y &.*.", +" =.-.;.*.", +" =.>. "}; diff --git a/include/xpm/zoom-original.png b/include/xpm/zoom-original.png new file mode 100644 index 0000000..8e35414 Binary files /dev/null and b/include/xpm/zoom-original.png differ diff --git a/include/xpm/zoom-original.xpm b/include/xpm/zoom-original.xpm new file mode 100644 index 0000000..6cc6b3c --- /dev/null +++ b/include/xpm/zoom-original.xpm @@ -0,0 +1,130 @@ +/* XPM */ +static const char * zoom_original_xpm[] = { +"16 16 111 2", +" c None", +". c #878B87", +"+ c #868C8A", +"@ c #888B89", +"# c #ACB6BF", +"$ c #CDD6DD", +"% c #E4E7E9", +"& c #929594", +"* c #CFD8E0", +"= c #D3DDE5", +"- c #A4BFDC", +"; c #99B9DA", +"> c #9AB9DA", +", c #A4BFDD", +"' c #CFDAE5", +") c #B4C9DF", +"! c #9DBDDD", +"~ c #B5CDE6", +"{ c #5C84B8", +"] c #5B84B8", +"^ c #B0CAE4", +"/ c #9ABADD", +"( c #98B9DC", +"_ c #BCD1E8", +": c #5F87B9", +"< c #FFFFFF", +"[ c #5A84B7", +"} c #ABC6E2", +"| c #91B4DA", +"1 c #868C8B", +"2 c #9DBBDA", +"3 c #B6CDE6", +"4 c #5D85B8", +"5 c #5982B7", +"6 c #A7C3E1", +"7 c #9FBDDE", +"8 c #9EBBDA", +"9 c #878B88", +"0 c #8EB2D6", +"a c #5A83B7", +"b c #5681B6", +"c c #9EBDDE", +"d c #86ACD4", +"e c #89AED4", +"f c #8AAFD7", +"g c #94B6DB", +"h c #547FB5", +"i c #507DB4", +"j c #85ACD5", +"k c #7BA5D2", +"l c #878C8B", +"m c #CFD8DE", +"n c #A7C1DD", +"o c #86ADD6", +"p c #89AED6", +"q c #4E7BB3", +"r c #4F7CB3", +"s c #8BB0D7", +"t c #A9C3DE", +"u c #D0D8DE", +"v c #888B87", +"w c #B1BAC1", +"x c #D9E1E8", +"y c #94B6DA", +"z c #96B7DB", +"A c #527EB5", +"B c #537EB5", +"C c #97B8DB", +"D c #DAE2E8", +"E c #B2BBC1", +"F c #8A8C8A", +"G c #D7DDE2", +"H c #CAD8E6", +"I c #A4C0DF", +"J c #A6C2E0", +"K c #5781B6", +"L c #D8DEE3", +"M c #949895", +"N c #DADFE3", +"O c #E1E6EA", +"P c #C7D7E8", +"Q c #BDD2E6", +"R c #BED2E6", +"S c #C8D8E8", +"T c #DFE5EA", +"U c #DBE0E4", +"V c #959896", +"W c #9DA09B", +"X c #60625F", +"Y c #8A8D8A", +"Z c #BCC1C4", +"` c #DCE0E2", +" . c #E9EBEB", +".. c #BDC2C5", +"+. c #898C88", +"@. c #878A84", +"#. c #B9BCB6", +"$. c #BDBFBC", +"%. c #61635F", +"&. c #8A8C88", +"*. c #8D918D", +"=. c #8B8D89", +"-. c #8E918D", +";. c #575955", +">. c #7A7B78", +",. c #B7B8B6", +"'. c #595B57", +"). c #555753", +"!. c #767873", +"~. c #A0A29F", +"{. c #565854", +" . + . . + . ", +" @ # $ % % $ # @ ", +" & * = - ; > , ' * & ", +" @ * ) ! ~ { ] ^ / ) * @ ", +". # ' ( _ : < < [ } | ' # . ", +"1 $ 2 3 4 < < < 5 6 7 8 $ + ", +"9 % 0 ^ [ a < < b c | d % . ", +"9 % e f g h < < i j k e % . ", +"l m n o p q < < r s p t u l ", +"v w x y z A < < B ( C D E v ", +" F G H I J K K 6 J H L . ", +" M N O P Q R S T U V W X ", +" Y Z ` . .` ..+.@.#.$.%. ", +" &.*.=.=.-.&. ;.>.@.,.'.", +" ).!.~.'.", +" ).{. "}; diff --git a/include/xpm/zoom-out.png b/include/xpm/zoom-out.png new file mode 100644 index 0000000..df5be3c Binary files /dev/null and b/include/xpm/zoom-out.png differ diff --git a/include/xpm/zoom-out.xpm b/include/xpm/zoom-out.xpm new file mode 100644 index 0000000..7bd9c37 --- /dev/null +++ b/include/xpm/zoom-out.xpm @@ -0,0 +1,127 @@ +/* XPM */ +static const char * zoom_out_xpm[] = { +"16 16 108 2", +" c None", +". c #878B87", +"+ c #868C8A", +"@ c #888B89", +"# c #ACB6BF", +"$ c #CDD6DD", +"% c #E4E7E9", +"& c #929594", +"* c #CFD8E0", +"= c #D3DDE5", +"- c #A4BFDC", +"; c #99B9DA", +"> c #9AB9DA", +", c #A4BFDD", +"' c #CFDAE5", +") c #B4C9DF", +"! c #9DBDDD", +"~ c #B5CDE6", +"{ c #B7CEE7", +"] c #B0CAE4", +"^ c #9ABADD", +"/ c #98B9DC", +"( c #BCD1E8", +"_ c #C2D6EA", +": c #C1D4EA", +"< c #BAD0E7", +"[ c #B2CBE5", +"} c #ABC6E2", +"| c #91B4DA", +"1 c #868C8B", +"2 c #9DBBDA", +"3 c #B6CDE6", +"4 c #5D85B8", +"5 c #5E86B8", +"6 c #5C85B8", +"7 c #5B84B8", +"8 c #5982B7", +"9 c #5781B6", +"0 c #9FBDDE", +"a c #9EBBDA", +"b c #878B88", +"c c #8EB2D6", +"d c #5983B7", +"e c #FFFFFF", +"f c #507DB4", +"g c #86ACD4", +"h c #89AED4", +"i c #4E7BB3", +"j c #4A78B2", +"k c #878C8B", +"l c #CFD8DE", +"m c #A7C1DD", +"n c #86ADD6", +"o c #4F7CB3", +"p c #89AED6", +"q c #A9C3DE", +"r c #D0D8DE", +"s c #888B87", +"t c #B1BAC1", +"u c #D9E1E8", +"v c #94B6DA", +"w c #96B7DB", +"x c #9ABADC", +"y c #97B8DB", +"z c #DAE2E8", +"A c #B2BBC1", +"B c #8A8C8A", +"C c #D7DDE2", +"D c #CAD8E6", +"E c #A4C0DF", +"F c #A6C2E0", +"G c #A7C3E1", +"H c #A8C4E1", +"I c #D8DEE3", +"J c #949895", +"K c #DADFE3", +"L c #E1E6EA", +"M c #C7D7E8", +"N c #BDD2E6", +"O c #BED2E6", +"P c #C8D8E8", +"Q c #DFE5EA", +"R c #DBE0E4", +"S c #959896", +"T c #9DA09B", +"U c #60625F", +"V c #8A8D8A", +"W c #BCC1C4", +"X c #DCE0E2", +"Y c #E9EBEB", +"Z c #BDC2C5", +"` c #898C88", +" . c #878A84", +".. c #B9BCB6", +"+. c #BDBFBC", +"@. c #61635F", +"#. c #8A8C88", +"$. c #8D918D", +"%. c #8B8D89", +"&. c #8E918D", +"*. c #575955", +"=. c #7A7B78", +"-. c #B7B8B6", +";. c #595B57", +">. c #555753", +",. c #767873", +"'. c #A0A29F", +"). c #565854", +" . + . . + . ", +" @ # $ % % $ # @ ", +" & * = - ; > , ' * & ", +" @ * ) ! ~ { ~ ] ^ ) * @ ", +". # ' / ( _ : < [ } | ' # . ", +"1 $ 2 3 4 5 6 7 8 9 0 a $ + ", +"b % c d e e e e e e f g % . ", +"b % h i e e e e e e j h % . ", +"k l m n i i o o o i p q r k ", +"s t u v w / x x x / y z A s ", +" B C D E F G H G F D I . ", +" J K L M N O P Q R S T U ", +" V W X Y Y X Z ` ...+.@. ", +" #.$.%.%.&.#. *.=. .-.;.", +" >.,.'.;.", +" >.). "}; diff --git a/include/xpm/zoom_1.xpm b/include/xpm/zoom_1.xpm new file mode 100644 index 0000000..c6015ea --- /dev/null +++ b/include/xpm/zoom_1.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * zoom_1_xpm[] = { +"16 16 3 1", +". c None", +"+ c #7F0000", +"@ c #FF0000", +"................", +"................", +"......++++......", +"......+@@+......", +"......+@@+......", +"......+@@+......", +"......+@@+......", +".++++++@@++++++.", +".+@@@@@@@@@@@@+.", +".+@@@@@@@@@@@@+.", +".++++++@@++++++.", +"......+@@+......", +"......+@@+......", +"......+@@+......", +"......+@@+......", +"......++++......"}; diff --git a/include/xpm/zoom_in.xpm b/include/xpm/zoom_in.xpm new file mode 100644 index 0000000..ee3ce6f --- /dev/null +++ b/include/xpm/zoom_in.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static const char *zoom_in_xpm[]={ +"16 16 6 1", +"# c None", +". c #000000", +"a c #000080", +"c c #804000", +"b c #d3e4e8", +"d c #ffff00", +".##...##...##...", +".####aa#########", +".##aabbaa#######", +"##abbbbbba#####.", +"##abbbbbba#####.", +".abbbbbbbba####.", +".abbbbbbbba#####", +".#abbbbbba######", +"##abbbbbba#####.", +"###aabbaaccc###.", +".####aa##cddc##.", +".########cdddc##", +".#########cdddc#", +"###########cddc.", +"############cc#.", +"...##...##...##."}; diff --git a/include/xpm/zoom_on.xpm b/include/xpm/zoom_on.xpm new file mode 100644 index 0000000..bb19096 --- /dev/null +++ b/include/xpm/zoom_on.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static const char *zoom_on_xpm[]={ +"16 16 6 1", +" c None", +". c #000000", +"a c #800000", +"c c #804000", +"b c #ff3f3f", +"d c #007f7f", +". ... ... ...", +". aa ", +". aabbaa ", +" abbbbbba .", +" abbbbbba .", +".abbbbbbbba .", +".abbbbbbbba ", +". abbbbbba ", +" abbbbbba .", +" aabbaaccc .", +". aa cddc .", +". cdddc ", +". cdddc ", +" cddc.", +" cc .", +"... ... ... ."}; diff --git a/include/xpm/zoom_out.xpm b/include/xpm/zoom_out.xpm new file mode 100644 index 0000000..f5c3805 --- /dev/null +++ b/include/xpm/zoom_out.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static const char *zoom_out_xpm[]={ +"16 16 6 1", +". c None", +"c c #000000", +"# c #000080", +"b c #804000", +"a c #d3e4e8", +"d c #ffff00", +"................", +"....##..........", +"..##aa##........", +".#aaaaaa#.......", +".#aaaaaa#.......", +"#aaaaaaaa#......", +"#aaaaaaaa#......", +".#aaaaaa#.......", +".#aaaaaa#.......", +"..##aa##bb......", +"....##..bbbb....", +"..c....c.bddb...", +".cc.c.cc.bdddb..", +"..c....c..bdddb.", +"..c.c..c...bddb.", +"..c....c....bb.."}; diff --git a/json/Backend.cpp b/json/Backend.cpp new file mode 100644 index 0000000..32fa3f0 --- /dev/null +++ b/json/Backend.cpp @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include "Backend.hpp" +#include +//----------------------------------------------------------------------------- +Backend::Backend(QObject *parent) : QObject(parent) { } +//----------------------------------------------------------------------------- +QString Backend::show(const QString& text) const +{ + qDebug() << __FUNCTION__; + const char *tmp = tmpnam(0); + mglGraph gr; + gr.SetFaceNum(200); + mglParse pr; + pr.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + setlocale(LC_NUMERIC, "C"); + pr.Execute(&gr,text.toStdWString().c_str()); + gr.WriteJSON(tmp); + setlocale(LC_NUMERIC, ""); + + QFile f(tmp); + f.open(QIODevice::ReadOnly); + QTextStream ts(&f); + ts.setAutoDetectUnicode(true); + const QString json = ts.readAll(); + f.remove(); + return json; +} +//----------------------------------------------------------------------------- +QString Backend::coor(const QString& xy, const QString& text) const +{ + qDebug() << __FUNCTION__; + mglGraph gr; + mglParse pr; + pr.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + setlocale(LC_NUMERIC, "C"); + pr.Execute(&gr,text.toStdWString().c_str()); + gr.Finish(); + + int x = (int)xy.section(" ",0,0).toDouble(); + int y = (int)xy.section(" ",1,1).toDouble(); + mglPoint p = gr.CalcXYZ(x,y); + QString res; + res.sprintf("x = %g, y = %g, z = %g for point (%d, %d)\n", p.x, p.y, p.z, x,y); + qDebug() << res+"\nask"+xy; + return res+"\nask"+xy; +} +//----------------------------------------------------------------------------- +QString Backend::geometry(const QString& mgl) const +{ + qDebug() << __FUNCTION__; + const char *tmp = tmpnam(0); + mglGraph gr; +#if 0 + gr.SetFaceNum(200); +#endif + mglParse pr; + pr.AllowSetSize(true); + setlocale(LC_CTYPE, ""); + setlocale(LC_NUMERIC, "C"); + pr.Execute(&gr,mgl.toStdWString().c_str()); + gr.WriteJSON(tmp); + setlocale(LC_NUMERIC, ""); + + QFile f(tmp); + f.open(QIODevice::ReadOnly); + QTextStream ts(&f); + ts.setAutoDetectUnicode(true); + const QString json = ts.readAll(); + f.remove(); + return json; +} +//----------------------------------------------------------------------------- diff --git a/json/Backend.hpp b/json/Backend.hpp new file mode 100644 index 0000000..3c7ecbe --- /dev/null +++ b/json/Backend.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + +class Backend : public QObject +{ + Q_OBJECT + +public: + explicit Backend(QObject *parent = 0); + +public: +// Q_INVOKABLE QString join(const QStringList list) const; + Q_INVOKABLE QString show(const QString& text) const; + Q_INVOKABLE QString coor(const QString& xy, const QString& text) const; + Q_INVOKABLE QString geometry(const QString& mgl) const; +}; + diff --git a/json/CMakeLists.txt b/json/CMakeLists.txt new file mode 100644 index 0000000..e45d923 --- /dev/null +++ b/json/CMakeLists.txt @@ -0,0 +1,25 @@ +if(enable-json-sample) + +set(json_src Backend.cpp MainWindow.cpp) +set(json_moc_hdr Backend.hpp MainWindow.hpp) + +include_directories(${MathGL_BINARY_DIR}/json) +if(enable-qt5) + include(../cmake-qt5.txt) + qt5_wrap_ui(json_ui_src MainWindow.ui) + qt5_wrap_cpp(json_moc_src ${json_moc_hdr} ) +else(enable-qt5) + include(../cmake-qt4.txt) + qt4_wrap_ui(json_ui_src MainWindow.ui) + qt4_wrap_cpp(json_moc_src ${json_moc_hdr} ) +endif(enable-qt5) +add_executable(MglForJsTestBench ${json_src} ${json_moc_src} ${json_ui_src}) +if(enable-qt5) + add_definitions( -DMGL_USE_QT5) + target_link_libraries(MglForJsTestBench mgl-qt5) + qt5_use_modules(MglForJsTestBench Core Widgets Gui Network WebKit WebKitWidgets PrintSupport) +else(enable-qt5) + target_link_libraries(MglForJsTestBench mgl-qt ${QT_LIBRARIES}) +endif(enable-qt5) + +endif(enable-json-sample) diff --git a/json/MainWindow.cpp b/json/MainWindow.cpp new file mode 100644 index 0000000..748251d --- /dev/null +++ b/json/MainWindow.cpp @@ -0,0 +1,55 @@ +#include "MainWindow.hpp" +#include "ui_MainWindow.h" +#include "mgl2/config.h" + +#include +#include +#include +//----------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} +//----------------------------------------------------------------------------- +MainWindow::MainWindow(QWidget* const parent) : QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + // configure webkit + QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptEnabled, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); + QWebSettings::globalSettings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); + + // create non-cached QNetworkAccessManager and assign to webview + QNetworkAccessManager* manager = new QNetworkAccessManager(this); + QNetworkDiskCache* diskCache = new QNetworkDiskCache(); +#ifdef MGL_USE_QT5 + const QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); +#else + const QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); +#endif + diskCache->setCacheDirectory(location); + diskCache->setMaximumCacheSize(0); + manager->setCache(diskCache); + ui->webView->page()->setNetworkAccessManager(manager); + + // inject backend object each time javascript object is cleared + connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(injectBackendObject())); + // set url to load + ui->webView->load(QUrl(QString("file:///%1/../../json/%2").arg(qApp->applicationDirPath()).arg("index.html"))); +} +//----------------------------------------------------------------------------- +void MainWindow::injectBackendObject() +{ + ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("globalBackend", &_backend); +} +//----------------------------------------------------------------------------- +MainWindow::~MainWindow() { delete ui; } +//----------------------------------------------------------------------------- diff --git a/json/MainWindow.hpp b/json/MainWindow.hpp new file mode 100644 index 0000000..6aa46f0 --- /dev/null +++ b/json/MainWindow.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "Backend.hpp" +#include +//#include + +namespace Ui { class MainWindow; } + +class MainWindow : public QMainWindow { + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void injectBackendObject(); + +private: + Ui::MainWindow *ui; + Backend _backend; +}; + diff --git a/json/MainWindow.ui b/json/MainWindow.ui new file mode 100644 index 0000000..e808739 --- /dev/null +++ b/json/MainWindow.ui @@ -0,0 +1,44 @@ + + + MainWindow + + + + 0 + 0 + 850 + 650 + + + + MainWindow + + + + + + + + + + about:blank + + + + + + + + + + + + + QWebView + QWidget +
QtWebKit/QWebView
+
+
+ + +
diff --git a/json/RotationExample.py b/json/RotationExample.py new file mode 100644 index 0000000..85e2a44 --- /dev/null +++ b/json/RotationExample.py @@ -0,0 +1,25 @@ +""" +.. versionadded:: 1.1.0 + This demo depends on new features added to contourf3d. +""" + +from mpl_toolkits.mplot3d import axes3d +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.gca(projection='3d') +X, Y, Z = axes3d.get_test_data(0.05) +ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) +cset = ax.contourf(X, Y, Z, zdir='z', offset=-100) +cset = ax.contourf(X, Y, Z, zdir='x', offset=-40) +cset = ax.contourf(X, Y, Z, zdir='y', offset=40) + +ax.set_xlabel('X') +ax.set_xlim(-40, 40) +ax.set_ylabel('Y') +ax.set_ylim(-40, 40) +ax.set_zlabel('Z') +ax.set_zlim(-100, 100) + +plt.show() + diff --git a/json/index.html b/json/index.html new file mode 100644 index 0000000..2bcda48 --- /dev/null +++ b/json/index.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + +
+ + + + + +
+ + +
+ + diff --git a/json/main.js b/json/main.js new file mode 100644 index 0000000..d13345c --- /dev/null +++ b/json/main.js @@ -0,0 +1,35 @@ +var graph; + +/** + * Entry function. + */ +var main = function() { + // get canvas to work over from the DOM + var canvas = document.getElementById("canvas"); + + // get backend injected by from C++ side just to illustrate where it came from + // in normal web application it shall be implemented using some transport protocol + var backend = new mathgl.WebkitBackend(); + + // instantiate mathgl graph instance connecting it with canvas and backend + graph = new mathgl.Graph(canvas, backend); + graph.setBackgroundFillStyle("#F0F0F0"); + // initialize it by some sample MGL script + graph.init(makeSampleScript()); +} + + +//var script = "rotate 40 60:fsurf 'sin(2*pi*x*y)'\nbox:axis:fplot 'sin(2*pi*t)' 'cos(2*pi*t)' '2*t-1' 'm2o'"; +//var script = "box:axis:fplot 'sin(pi*x)'"; +//var script = "rotate 10 20: box:axis:fsurf 'sin(pi*x*y)'"; + +var makeSampleScript = function() { + var mgl = "origintick off\n"; + mgl += "title 'qqq' '@k':ranges -2 2 -2 2 -2 2:colorbar '>'\n" // NOTE: Ranges MUST BE specified for correctly work of zoomaxis feature + mgl += "facenum 50:"; + mgl += "origin 0 0 0:axis :xlabel 'x':ylabel 'y':zlabel 'z':" + mgl += "box:fplot 'sin(x^2)'\n"; // This is just for testing zoomaxis features + mgl += "fplot 'sin(2*pi*t)' '2*t-1' 'cos(2*pi*t)' 'm2o':fsurf 'sin(pi*x*y)':"; + mgl += "text 0 0 'aaa'"; + return mgl; +} diff --git a/json/mathgl.Backend.js b/json/mathgl.Backend.js new file mode 100644 index 0000000..6c1ec74 --- /dev/null +++ b/json/mathgl.Backend.js @@ -0,0 +1,13 @@ +/** + * Backend interface. The only responsibility its successors is to return geometry object by given MGL script. + */ + +/** constructor */ +mathgl.Backend = function() {} + +/** + * Request for geometry data for given MGL script. + * @param mgl {String} MGL script containing all the information neede to build geometry + * @return {Object} geometry data gathered from server-side + */ +mathgl.Backend.prototype.geometry = function(mgl) { throw new Error("abstract method invoked"); } diff --git a/json/mathgl.Graph.js b/json/mathgl.Graph.js new file mode 100644 index 0000000..fcc2153 --- /dev/null +++ b/json/mathgl.Graph.js @@ -0,0 +1,653 @@ +/** + * Graph - main MathGL class. + */ + +/** + * Constructor - create graph attached to specified canvas and working over provided backend. + * @param backend {mathgl.Backend} implementation of backend interface + * @param canvas {Canvas} canvas to plot graph on + */ +mathgl.Graph = function(canvas, backend) { + this.__backend = backend; + this.__canvas = canvas; + this.__view = null; + this.__geometry = null; + // indicate whether rendering handlers are in the event queue + this.__isDraftRenderingInScheduled = false; + this.__isPreciseRenderingScheduled = false; + // draft rendering finished timestamp + this.__draftFinishedTimestamp = new Date(); + this.__backgroundFillStyle = '#EEEEFF'; + this.__preciseRenderingDelay = 700; + + this.__maxDraftPoints = 30000; + this.__asp_scl=0; // inertia of aspect scaling + this.__fov = 0; // perspective + this.__x1 = 0; this.__y1 = 0; this.__z1 = 0; + this.__x2 = 1; this.__y2 = 1; this.__z2 = 1; +} + + +/** + * Initialize current view by given MGL script. + * @param mgl {String} MGL script + */ +mathgl.Graph.prototype.init = function(mgl) { + // request backend for geometry object + this.__geometry = this.__backend.geometry(mgl); + this.__geometry.mgl = mgl; + // construct view according the view type recieved from backend (within geometry object) and initialize it + + this.__view = new mathgl.View(); + // connect method which starts rendering to view object + this.__view.setRenderLauncher(mathgl.bind(this.__renderStart, this)); + // connect pick point handler + this.__view.setPickPointHandler(mathgl.bind(this.__pickPointHandler, this)); + // attach canvas to view + this.__view.attachCanvas(this.__canvas); +} + + +/** + * Load graph state from JSON string. + * @param json {String} string in JSON format with previously saved state + */ +mathgl.Graph.prototype.load = function(json) { + throw new Error("TODO"); +} + + +/** + * Save current graph state to JSON string. + * @return {String} state serialized to JSON string + */ +mathgl.Graph.prototype.save = function() { + throw new Error("TODO"); +} + + +/** + * background fill style setter + * @param fillStyle something that will be accepted by canvas' 2d context as fill style, e.g. color, gradient, pattern. + */ +mathgl.Graph.prototype.setBackgroundFillStyle = function(fillStyle) { + this.__backgroundFillStyle = fillStyle; +} + + +/** @return background fill style */ +mathgl.Graph.prototype.backgroundFillStyle = function() { + return this.__backgroundFillStyle; +} + + +/** called when user picks the point on the graph, point shall be somehow displayed/highlighted */ +mathgl.Graph.prototype.__pickPointHandler = function(x, y) { + var obj = this.__geometry; + var xy = x*obj.width/this.__canvas.width + " " + y*obj.height/this.__canvas.height; + // introduce zoom and view coomand for server side + var zoom = "zoom "+(0.5-obj.pf/2)+" "+(0.5-obj.pf/2)+" "+(0.5+obj.pf/2)+" "+(0.5+obj.pf/2)+"\n"; + var view1 = "view 0 "+this.__view.__pitch*180/Math.PI+" 0"+"\n"; + var view2 = "view 0 0 "+(-this.__view.__yaw)*180/Math.PI+"\n"; + var persp = "perspective "+(-this.__fov)+"\n"; + // now ask server side for proper coordinates + var res = this.__backend.coor(xy, zoom+view1+view2+persp+obj.mgl); +} + + +/** called when user shift axis range */ +mathgl.Graph.prototype.shiftAxis = function(x, y, z) { + var dx = x*(this.__x2-this.__x1), dy = y*(this.__y2-this.__y1), dz = z*(this.__z2-this.__z1) + this.__x1 += dx; this.__x2 += dx; + this.__y1 += dy; this.__y2 += dy; + this.__z1 += dz; this.__z2 += dz; + // introduce zoomaxis coomand for server side + var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__z1+" "+this.__x2+" "+this.__y2+" "+this.__z2+"\n"; + var mgl = this.__geometry.mgl; + // now ask server side for proper coordinates + this.__geometry = this.__backend.geometry(zoom+mgl); + this.__geometry.mgl = mgl; + this.__renderStart(); +} + + +/** called when user shift axis range */ +mathgl.Graph.prototype.zoomAxis = function(factor) { + var d, c; + d=(this.__x2-this.__x1)*factor/2; c=(this.__x2+this.__x1)/2; + this.__x1 = c-d; this.__x2 = c+d; + d=(this.__y2-this.__y1)*factor/2; c=(this.__y2+this.__y1)/2; + this.__y1 = c-d; this.__y2 = c+d; + d=(this.__z2-this.__z1)*factor/2; c=(this.__z2+this.__z1)/2; + this.__z1 = c-d; this.__z2 = c+d; + // introduce zoomaxis coomand for server side + var zoom = "zoomaxis "+this.__x1+" "+this.__y1+" "+this.__z1+" "+this.__x2+" "+this.__y2+" "+this.__z2+"\n"; + var mgl = this.__geometry.mgl; + // now ask server side for proper coordinates + this.__geometry = this.__backend.geometry(zoom+this.__geometry.mgl); + this.__geometry.mgl = mgl; + this.__renderStart(); +} + + +/** initiate the chains of rendering the geometry to the canvas */ +mathgl.Graph.prototype.__renderStart = function() { + // do nothing if processing is already started + if (!this.__isDraftRenderingInScheduled) { + // enqueue draft rendering step + this.__isDraftRenderingInScheduled = true; + setTimeout(mathgl.bind(this.__renderDraft, this), 0); + } +} + + +/** draft rendering */ +mathgl.Graph.prototype.__renderDraft = function() { + this.__drawMesh(false); + this.__isDraftRenderingInScheduled = false; + + // enqueue precise rendering step + if (!this.__isPreciseRenderingScheduled) { + this.__isPreciseRenderingScheduled = true; + setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay); + } + this.__draftFinishedTimestamp = new Date(); +} + + +/** precise rendering */ +mathgl.Graph.prototype.__renderPrecise = function() { + // do nothing if draft rendering is scheduled + if (this.__isDraftRenderingInScheduled) { + this.__isPreciseRenderingScheduled = false; + return; + } + + // check that enough time has passed since last occurance of draft rendering finished + // rechedule pricese rendering if it is not + var current = new Date(); + if (current - this.__draftFinishedTimestamp < this.__preciseRenderingDelay) { + setTimeout(mathgl.bind(this.__renderPrecise, this), this.__preciseRenderingDelay - (current - this.__draftFinishedTimestamp)); + return; + } + this.__drawMesh(true); + this.__isPreciseRenderingScheduled = false; +} + + +/** fill canvas background */ +mathgl.Graph.prototype.__drawBackground = function() { + var c = this.__canvas.getContext("2d"); + var h = this.__canvas.height; + var w = this.__canvas.width; + c.fillStyle = this.__backgroundFillStyle; + c.fillRect(0, 0 , w, h); +} + + +/** auxiliary function to draw mesh */ +mathgl.Graph.prototype.__drawMesh = function(isPrecise) { + var c = this.__canvas.getContext("2d"); + var m = this.__view.viewMatrix().inverse(); +// var vvv = $M([[1,0,0,1]]); + var obj = this.__geometry; + var h = this.__canvas.height; + var fy = h / obj.height; + var w = this.__canvas.width; + var fx = w / obj.width; +// var df=dxMath.PI/2) t += Math.PI; + } + else t=0; + var c=Math.cos(t), s=Math.sin(t), d=prim[6]/200; + + var b=[d*c, d*s, d*s, -d*c, pp[n1][0],pp[n1][1]]; + var x=obj.coor[n2][0]*scl/100, y=obj.coor[n2][1]*scl/100, f=prim[8]*scl/1e5; + if(n3&8) + { + if(!(n3&4)) this.__mgl_line_glyph(ctx, x,y, f,1,b); + else this.__mgl_line_glyph(ctx, x,y, f,0,b); + } + else + { + if(!(n3&4)) this.__mgl_fill_glyph(ctx, x,y, f,obj.glfs[n4],b); + else this.__mgl_wire_glyph(ctx, x,y, f,obj.glfs[n4],b); + } + break; + } +} + +mathgl.Graph.prototype.__mgl_pf = function(obj, z) { +// return 1/obj.pf; + return (1-this.__fov)/obj.pf/(1-this.__fov*z/obj.depth); // TODO: check calc coordinates!!! +// return 1/(1+obj.pf*(1-z/obj.depth)); +} + + +/** change coordinates according current transformations, usually called internally by draw() */ +mathgl.Graph.prototype.__mgl_prepare = function(obj, skip) { + // fill transformation matrix + if(!skip) + { + var dx = 1/Math.abs(obj.z[1]-obj.z[0]); + var dy = 1/Math.abs(obj.z[3]-obj.z[2]); + var cx=Math.cos(obj.tet*deg), sx=Math.sin(obj.tet*deg); // tetx + var cy=Math.cos(obj.phi*deg), sy=Math.sin(obj.phi*deg); // tety + var cz=Math.cos(obj.bet*deg), sz=Math.sin(obj.bet*deg); // tetz + obj.b = [dx*cx*cy, -dx*cy*sx, dx*sy, + dy*(cx*sy*sz+cz*sx), dy*(cx*cz-sx*sy*sz), -dy*cy*sz, + sx*sz-cx*cz*sy, cx*sz+cz*sx*sy, cy*cz, + obj.width/2*(1+dx-obj.z[1]-obj.z[0])/dx, + obj.height/2*(1+dy-obj.z[3]-obj.z[2])/dy, obj.depth/2, dx,dy,1]; + } + // now transform points for found transformation matrix + var b = obj.b, i; + for(i=0;i' + ctx.moveTo(x-s/2,y-s); ctx.lineTo(x-s/2,y+s); + ctx.lineTo(x+s,y); ctx.closePath(); + ctx.stroke(); break; +// case 46: // '.' + default: + ctx.rect(x,y,1,1); ctx.fill(); break; + } +} + + +/** for internal use only */ +mathgl.Graph.prototype.__mgl_fill_glyph = function(ctx, x,y, f,g,b) { + var xx,yy,j; + var np=0; ctx.beginPath(); + for(j=0;j 63) this.__pitch -= 20*Math.PI; + if(this.__pitch < -63) this.__pitch += 20*Math.PI; + if(this.__yaw > 63) this.__yaw -= 20*Math.PI; + if(this.__yaw <-63) this.__yaw += 20*Math.PI; +// this.__pitch = Math.min(this.__pitch, Math.PI / 2); +// this.__pitch = Math.max(this.__pitch, -Math.PI / 2); +// this.__yaw = Math.min(this.__yaw, Math.PI); +// this.__yaw = Math.max(this.__yaw, -Math.PI); + + if(this.__onCameraChanged) + this.__onCameraChanged(this.getViewpoint()); + this.__renderLauncherFunc(); + } +} + + +mathgl.View.prototype.__onMouseDown = function(e) { + this.__mouseX = e.offsetX; + this.__mouseY = e.offsetY; + this.__isMouseDown = true; +} + + +mathgl.View.prototype.__onMouseUp = function() { + this.__isMouseDown = false; +} + + +mathgl.View.prototype.__onMouseOut = function() { + this.__isMouseDown = false; +} + + +mathgl.View.prototype.__onDblClick = function(e) { + this.__pickPointHandlerFunc(e.offsetX, e.offsetY); +} + + +mathgl.View.prototype.__onMouseWheel = function(e) { + this.__isMouseDown = false; + this.__distance -= 0.1 * e.wheelDelta / 120; + this.__distance = Math.min(this.__distance, 10.0); + this.__distance = Math.max(this.__distance, 0.2); + if(this.__onCameraChanged) + this.__onCameraChanged(this.getViewpoint()); + this.__renderLauncherFunc(); +} + +mathgl.View.prototype.getViewpoint = function() { + return { + distance : this.__distance, + pitch : this.__pitch, + yaw : this.__yaw, + }; +} + +mathgl.View.prototype.setViewpoint = function(distance, pitch, yaw) { + this.__distance = distance; + this.__pitch = pitch; + this.__yaw = yaw; + this.__renderLauncherFunc(); +} + +mathgl.View.prototype.destroy = function() { + this.__renderLauncherFunc = null; + this.__pickPointHandlerFunc = null; + this.detachCanvas(); +} + +mathgl.View.prototype.setCameraEventHandler = function(handler) { + this.__onCameraChanged = handler; +} + + + diff --git a/json/mathgl.WebkitBackend.js b/json/mathgl.WebkitBackend.js new file mode 100644 index 0000000..fbc91a8 --- /dev/null +++ b/json/mathgl.WebkitBackend.js @@ -0,0 +1,25 @@ +/** + * Webkit backend. Backend base on the object injected by QWebView. + */ + +/** constructor */ +mathgl.WebkitBackend = function() {} + +/** inherit from mathgl.Backend interface */ +mathgl.WebkitBackend.prototype = new mathgl.Backend(); + + +/** return geometry */ +mathgl.WebkitBackend.prototype.geometry = function(mgl) { + var geometryData = globalBackend.geometry(mgl); + + /* + var zlib = require('zlib'); + zlib.unzip(geometryData, function(err, buffer) { + if (!err) { geometryData = buffer; }); + */ + + var obj = JSON.parse(geometryData); + obj.pp = new Array(); + return obj; +} diff --git a/json/mathgl.js b/json/mathgl.js new file mode 100644 index 0000000..02fe4a4 --- /dev/null +++ b/json/mathgl.js @@ -0,0 +1,29 @@ +/** main mathgl namespace */ +var mathgl = { + version: '0.1.0' +} + + +/** + * Auxiliary functions. + */ + +/** trivial bind implementation */ +mathgl.bind = function(func, context) { + return function() { + func.apply(context, arguments); + }; +} + + +/** clone */ +mathgl.clone = function(obj) { + if (obj === null || typeof(obj) != 'object') { + return obj; + } + var temp = new obj.constructor(); + for (var key in obj) { + temp[key] = mathgl.clone(obj[key]); + } + return temp; +} diff --git a/json/sylvester.src.js b/json/sylvester.src.js new file mode 100644 index 0000000..97a6491 --- /dev/null +++ b/json/sylvester.src.js @@ -0,0 +1,1254 @@ +// === Sylvester === +// Vector and Matrix mathematics modules for JavaScript +// Copyright (c) 2007 James Coglan +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +var Sylvester = { + version: '0.1.3', + precision: 1e-6 +}; + +function Vector() {} +Vector.prototype = { + + // Returns element i of the vector + e: function(i) { + return (i < 1 || i > this.elements.length) ? null : this.elements[i-1]; + }, + + // Returns the number of elements the vector has + dimensions: function() { + return this.elements.length; + }, + + // Returns the modulus ('length') of the vector + modulus: function() { + return Math.sqrt(this.dot(this)); + }, + + // Returns true iff the vector is equal to the argument + eql: function(vector) { + var n = this.elements.length; + var V = vector.elements || vector; + if (n != V.length) { return false; } + do { + if (Math.abs(this.elements[n-1] - V[n-1]) > Sylvester.precision) { return false; } + } while (--n); + return true; + }, + + // Returns a copy of the vector + dup: function() { + return Vector.create(this.elements); + }, + + // Maps the vector to another vector according to the given function + map: function(fn) { + var elements = []; + this.each(function(x, i) { + elements.push(fn(x, i)); + }); + return Vector.create(elements); + }, + + // Calls the iterator for each element of the vector in turn + each: function(fn) { + var n = this.elements.length, k = n, i; + do { i = k - n; + fn(this.elements[i], i+1); + } while (--n); + }, + + // Returns a new vector created by normalizing the receiver + toUnitVector: function() { + var r = this.modulus(); + if (r === 0) { return this.dup(); } + return this.map(function(x) { return x/r; }); + }, + + // Returns the angle between the vector and the argument (also a vector) + angleFrom: function(vector) { + var V = vector.elements || vector; + var n = this.elements.length, k = n, i; + if (n != V.length) { return null; } + var dot = 0, mod1 = 0, mod2 = 0; + // Work things out in parallel to save time + this.each(function(x, i) { + dot += x * V[i-1]; + mod1 += x * x; + mod2 += V[i-1] * V[i-1]; + }); + mod1 = Math.sqrt(mod1); mod2 = Math.sqrt(mod2); + if (mod1*mod2 === 0) { return null; } + var theta = dot / (mod1*mod2); + if (theta < -1) { theta = -1; } + if (theta > 1) { theta = 1; } + return Math.acos(theta); + }, + + // Returns true iff the vector is parallel to the argument + isParallelTo: function(vector) { + var angle = this.angleFrom(vector); + return (angle === null) ? null : (angle <= Sylvester.precision); + }, + + // Returns true iff the vector is antiparallel to the argument + isAntiparallelTo: function(vector) { + var angle = this.angleFrom(vector); + return (angle === null) ? null : (Math.abs(angle - Math.PI) <= Sylvester.precision); + }, + + // Returns true iff the vector is perpendicular to the argument + isPerpendicularTo: function(vector) { + var dot = this.dot(vector); + return (dot === null) ? null : (Math.abs(dot) <= Sylvester.precision); + }, + + // Returns the result of adding the argument to the vector + add: function(vector) { + var V = vector.elements || vector; + if (this.elements.length != V.length) { return null; } + return this.map(function(x, i) { return x + V[i-1]; }); + }, + + // Returns the result of subtracting the argument from the vector + subtract: function(vector) { + var V = vector.elements || vector; + if (this.elements.length != V.length) { return null; } + return this.map(function(x, i) { return x - V[i-1]; }); + }, + + // Returns the result of multiplying the elements of the vector by the argument + multiply: function(k) { + return this.map(function(x) { return x*k; }); + }, + + x: function(k) { return this.multiply(k); }, + + // Returns the scalar product of the vector with the argument + // Both vectors must have equal dimensionality + dot: function(vector) { + var V = vector.elements || vector; + var i, product = 0, n = this.elements.length; + if (n != V.length) { return null; } + do { product += this.elements[n-1] * V[n-1]; } while (--n); + return product; + }, + + // Returns the vector product of the vector with the argument + // Both vectors must have dimensionality 3 + cross: function(vector) { + var B = vector.elements || vector; + if (this.elements.length != 3 || B.length != 3) { return null; } + var A = this.elements; + return Vector.create([ + (A[1] * B[2]) - (A[2] * B[1]), + (A[2] * B[0]) - (A[0] * B[2]), + (A[0] * B[1]) - (A[1] * B[0]) + ]); + }, + + // Returns the (absolute) largest element of the vector + max: function() { + var m = 0, n = this.elements.length, k = n, i; + do { i = k - n; + if (Math.abs(this.elements[i]) > Math.abs(m)) { m = this.elements[i]; } + } while (--n); + return m; + }, + + // Returns the index of the first match found + indexOf: function(x) { + var index = null, n = this.elements.length, k = n, i; + do { i = k - n; + if (index === null && this.elements[i] == x) { + index = i + 1; + } + } while (--n); + return index; + }, + + // Returns a diagonal matrix with the vector's elements as its diagonal elements + toDiagonalMatrix: function() { + return Matrix.Diagonal(this.elements); + }, + + // Returns the result of rounding the elements of the vector + round: function() { + return this.map(function(x) { return Math.round(x); }); + }, + + // Returns a copy of the vector with elements set to the given value if they + // differ from it by less than Sylvester.precision + snapTo: function(x) { + return this.map(function(y) { + return (Math.abs(y - x) <= Sylvester.precision) ? x : y; + }); + }, + + // Returns the vector's distance from the argument, when considered as a point in space + distanceFrom: function(obj) { + if (obj.anchor) { return obj.distanceFrom(this); } + var V = obj.elements || obj; + if (V.length != this.elements.length) { return null; } + var sum = 0, part; + this.each(function(x, i) { + part = x - V[i-1]; + sum += part * part; + }); + return Math.sqrt(sum); + }, + + // Returns true if the vector is point on the given line + liesOn: function(line) { + return line.contains(this); + }, + + // Return true iff the vector is a point in the given plane + liesIn: function(plane) { + return plane.contains(this); + }, + + // Rotates the vector about the given object. The object should be a + // point if the vector is 2D, and a line if it is 3D. Be careful with line directions! + rotate: function(t, obj) { + var V, R, x, y, z; + switch (this.elements.length) { + case 2: + V = obj.elements || obj; + if (V.length != 2) { return null; } + R = Matrix.Rotation(t).elements; + x = this.elements[0] - V[0]; + y = this.elements[1] - V[1]; + return Vector.create([ + V[0] + R[0][0] * x + R[0][1] * y, + V[1] + R[1][0] * x + R[1][1] * y + ]); + break; + case 3: + if (!obj.direction) { return null; } + var C = obj.pointClosestTo(this).elements; + R = Matrix.Rotation(t, obj.direction).elements; + x = this.elements[0] - C[0]; + y = this.elements[1] - C[1]; + z = this.elements[2] - C[2]; + return Vector.create([ + C[0] + R[0][0] * x + R[0][1] * y + R[0][2] * z, + C[1] + R[1][0] * x + R[1][1] * y + R[1][2] * z, + C[2] + R[2][0] * x + R[2][1] * y + R[2][2] * z + ]); + break; + default: + return null; + } + }, + + // Returns the result of reflecting the point in the given point, line or plane + reflectionIn: function(obj) { + if (obj.anchor) { + // obj is a plane or line + var P = this.elements.slice(); + var C = obj.pointClosestTo(P).elements; + return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))]); + } else { + // obj is a point + var Q = obj.elements || obj; + if (this.elements.length != Q.length) { return null; } + return this.map(function(x, i) { return Q[i-1] + (Q[i-1] - x); }); + } + }, + + // Utility to make sure vectors are 3D. If they are 2D, a zero z-component is added + to3D: function() { + var V = this.dup(); + switch (V.elements.length) { + case 3: break; + case 2: V.elements.push(0); break; + default: return null; + } + return V; + }, + + // Returns a string representation of the vector + inspect: function() { + return '[' + this.elements.join(', ') + ']'; + }, + + // Set vector's elements from an array + setElements: function(els) { + this.elements = (els.elements || els).slice(); + return this; + } +}; + +// Constructor function +Vector.create = function(elements) { + var V = new Vector(); + return V.setElements(elements); +}; + +// i, j, k unit vectors +Vector.i = Vector.create([1,0,0]); +Vector.j = Vector.create([0,1,0]); +Vector.k = Vector.create([0,0,1]); + +// Random vector of size n +Vector.Random = function(n) { + var elements = []; + do { elements.push(Math.random()); + } while (--n); + return Vector.create(elements); +}; + +// Vector filled with zeros +Vector.Zero = function(n) { + var elements = []; + do { elements.push(0); + } while (--n); + return Vector.create(elements); +}; + + + +function Matrix() {} +Matrix.prototype = { + + // Returns element (i,j) of the matrix + e: function(i,j) { + if (i < 1 || i > this.elements.length || j < 1 || j > this.elements[0].length) { return null; } + return this.elements[i-1][j-1]; + }, + + // Returns row k of the matrix as a vector + row: function(i) { + if (i > this.elements.length) { return null; } + return Vector.create(this.elements[i-1]); + }, + + // Returns column k of the matrix as a vector + col: function(j) { + if (j > this.elements[0].length) { return null; } + var col = [], n = this.elements.length, k = n, i; + do { i = k - n; + col.push(this.elements[i][j-1]); + } while (--n); + return Vector.create(col); + }, + + // Returns the number of rows/columns the matrix has + dimensions: function() { + return {rows: this.elements.length, cols: this.elements[0].length}; + }, + + // Returns the number of rows in the matrix + rows: function() { + return this.elements.length; + }, + + // Returns the number of columns in the matrix + cols: function() { + return this.elements[0].length; + }, + + // Returns true iff the matrix is equal to the argument. You can supply + // a vector as the argument, in which case the receiver must be a + // one-column matrix equal to the vector. + eql: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + if (this.elements.length != M.length || + this.elements[0].length != M[0].length) { return false; } + var ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j; + do { i = ki - ni; + nj = kj; + do { j = kj - nj; + if (Math.abs(this.elements[i][j] - M[i][j]) > Sylvester.precision) { return false; } + } while (--nj); + } while (--ni); + return true; + }, + + // Returns a copy of the matrix + dup: function() { + return Matrix.create(this.elements); + }, + + // Maps the matrix to another matrix (of the same dimensions) according to the given function + map: function(fn) { + var els = [], ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j; + do { i = ki - ni; + nj = kj; + els[i] = []; + do { j = kj - nj; + els[i][j] = fn(this.elements[i][j], i + 1, j + 1); + } while (--nj); + } while (--ni); + return Matrix.create(els); + }, + + // Returns true iff the argument has the same dimensions as the matrix + isSameSizeAs: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + return (this.elements.length == M.length && + this.elements[0].length == M[0].length); + }, + + // Returns the result of adding the argument to the matrix + add: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + if (!this.isSameSizeAs(M)) { return null; } + return this.map(function(x, i, j) { return x + M[i-1][j-1]; }); + }, + + // Returns the result of subtracting the argument from the matrix + subtract: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + if (!this.isSameSizeAs(M)) { return null; } + return this.map(function(x, i, j) { return x - M[i-1][j-1]; }); + }, + + // Returns true iff the matrix can multiply the argument from the left + canMultiplyFromLeft: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + // this.columns should equal matrix.rows + return (this.elements[0].length == M.length); + }, + + // Returns the result of multiplying the matrix from the right by the argument. + // If the argument is a scalar then just multiply all the elements. If the argument is + // a vector, a vector is returned, which saves you having to remember calling + // col(1) on the result. + multiply: function(matrix) { + if (!matrix.elements) { + return this.map(function(x) { return x * matrix; }); + } + var returnVector = matrix.modulus ? true : false; + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + if (!this.canMultiplyFromLeft(M)) { return null; } + var ni = this.elements.length, ki = ni, i, nj, kj = M[0].length, j; + var cols = this.elements[0].length, elements = [], sum, nc, c; + do { i = ki - ni; + elements[i] = []; + nj = kj; + do { j = kj - nj; + sum = 0; + nc = cols; + do { c = cols - nc; + sum += this.elements[i][c] * M[c][j]; + } while (--nc); + elements[i][j] = sum; + } while (--nj); + } while (--ni); + var M = Matrix.create(elements); + return returnVector ? M.col(1) : M; + }, + + x: function(matrix) { return this.multiply(matrix); }, + + // Returns a submatrix taken from the matrix + // Argument order is: start row, start col, nrows, ncols + // Element selection wraps if the required index is outside the matrix's bounds, so you could + // use this to perform row/column cycling or copy-augmenting. + minor: function(a, b, c, d) { + var elements = [], ni = c, i, nj, j; + var rows = this.elements.length, cols = this.elements[0].length; + do { i = c - ni; + elements[i] = []; + nj = d; + do { j = d - nj; + elements[i][j] = this.elements[(a+i-1)%rows][(b+j-1)%cols]; + } while (--nj); + } while (--ni); + return Matrix.create(elements); + }, + + // Returns the transpose of the matrix + transpose: function() { + var rows = this.elements.length, cols = this.elements[0].length; + var elements = [], ni = cols, i, nj, j; + do { i = cols - ni; + elements[i] = []; + nj = rows; + do { j = rows - nj; + elements[i][j] = this.elements[j][i]; + } while (--nj); + } while (--ni); + return Matrix.create(elements); + }, + + // Returns true iff the matrix is square + isSquare: function() { + return (this.elements.length == this.elements[0].length); + }, + + // Returns the (absolute) largest element of the matrix + max: function() { + var m = 0, ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j; + do { i = ki - ni; + nj = kj; + do { j = kj - nj; + if (Math.abs(this.elements[i][j]) > Math.abs(m)) { m = this.elements[i][j]; } + } while (--nj); + } while (--ni); + return m; + }, + + // Returns the indeces of the first match found by reading row-by-row from left to right + indexOf: function(x) { + var index = null, ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j; + do { i = ki - ni; + nj = kj; + do { j = kj - nj; + if (this.elements[i][j] == x) { return {i: i+1, j: j+1}; } + } while (--nj); + } while (--ni); + return null; + }, + + // If the matrix is square, returns the diagonal elements as a vector. + // Otherwise, returns null. + diagonal: function() { + if (!this.isSquare) { return null; } + var els = [], n = this.elements.length, k = n, i; + do { i = k - n; + els.push(this.elements[i][i]); + } while (--n); + return Vector.create(els); + }, + + // Make the matrix upper (right) triangular by Gaussian elimination. + // This method only adds multiples of rows to other rows. No rows are + // scaled up or switched, and the determinant is preserved. + toRightTriangular: function() { + var M = this.dup(), els; + var n = this.elements.length, k = n, i, np, kp = this.elements[0].length, p; + do { i = k - n; + if (M.elements[i][i] == 0) { + for (j = i + 1; j < k; j++) { + if (M.elements[j][i] != 0) { + els = []; np = kp; + do { p = kp - np; + els.push(M.elements[i][p] + M.elements[j][p]); + } while (--np); + M.elements[i] = els; + break; + } + } + } + if (M.elements[i][i] != 0) { + for (j = i + 1; j < k; j++) { + var multiplier = M.elements[j][i] / M.elements[i][i]; + els = []; np = kp; + do { p = kp - np; + // Elements with column numbers up to an including the number + // of the row that we're subtracting can safely be set straight to + // zero, since that's the point of this routine and it avoids having + // to loop over and correct rounding errors later + els.push(p <= i ? 0 : M.elements[j][p] - M.elements[i][p] * multiplier); + } while (--np); + M.elements[j] = els; + } + } + } while (--n); + return M; + }, + + toUpperTriangular: function() { return this.toRightTriangular(); }, + + // Returns the determinant for square matrices + determinant: function() { + if (!this.isSquare()) { return null; } + var M = this.toRightTriangular(); + var det = M.elements[0][0], n = M.elements.length - 1, k = n, i; + do { i = k - n + 1; + det = det * M.elements[i][i]; + } while (--n); + return det; + }, + + det: function() { return this.determinant(); }, + + // Returns true iff the matrix is singular + isSingular: function() { + return (this.isSquare() && this.determinant() === 0); + }, + + // Returns the trace for square matrices + trace: function() { + if (!this.isSquare()) { return null; } + var tr = this.elements[0][0], n = this.elements.length - 1, k = n, i; + do { i = k - n + 1; + tr += this.elements[i][i]; + } while (--n); + return tr; + }, + + tr: function() { return this.trace(); }, + + // Returns the rank of the matrix + rank: function() { + var M = this.toRightTriangular(), rank = 0; + var ni = this.elements.length, ki = ni, i, nj, kj = this.elements[0].length, j; + do { i = ki - ni; + nj = kj; + do { j = kj - nj; + if (Math.abs(M.elements[i][j]) > Sylvester.precision) { rank++; break; } + } while (--nj); + } while (--ni); + return rank; + }, + + rk: function() { return this.rank(); }, + + // Returns the result of attaching the given argument to the right-hand side of the matrix + augment: function(matrix) { + var M = matrix.elements || matrix; + if (typeof(M[0][0]) == 'undefined') { M = Matrix.create(M).elements; } + var T = this.dup(), cols = T.elements[0].length; + var ni = T.elements.length, ki = ni, i, nj, kj = M[0].length, j; + if (ni != M.length) { return null; } + do { i = ki - ni; + nj = kj; + do { j = kj - nj; + T.elements[i][cols + j] = M[i][j]; + } while (--nj); + } while (--ni); + return T; + }, + + // Returns the inverse (if one exists) using Gauss-Jordan + inverse: function() { + if (!this.isSquare() || this.isSingular()) { return null; } + var ni = this.elements.length, ki = ni, i, j; + var M = this.augment(Matrix.I(ni)).toRightTriangular(); + var np, kp = M.elements[0].length, p, els, divisor; + var inverse_elements = [], new_element; + // Matrix is non-singular so there will be no zeros on the diagonal + // Cycle through rows from last to first + do { i = ni - 1; + // First, normalise diagonal elements to 1 + els = []; np = kp; + inverse_elements[i] = []; + divisor = M.elements[i][i]; + do { p = kp - np; + new_element = M.elements[i][p] / divisor; + els.push(new_element); + // Shuffle of the current row of the right hand side into the results + // array as it will not be modified by later runs through this loop + if (p >= ki) { inverse_elements[i].push(new_element); } + } while (--np); + M.elements[i] = els; + // Then, subtract this row from those above it to + // give the identity matrix on the left hand side + for (j = 0; j < i; j++) { + els = []; np = kp; + do { p = kp - np; + els.push(M.elements[j][p] - M.elements[i][p] * M.elements[j][i]); + } while (--np); + M.elements[j] = els; + } + } while (--ni); + return Matrix.create(inverse_elements); + }, + + inv: function() { return this.inverse(); }, + + // Returns the result of rounding all the elements + round: function() { + return this.map(function(x) { return Math.round(x); }); + }, + + // Returns a copy of the matrix with elements set to the given value if they + // differ from it by less than Sylvester.precision + snapTo: function(x) { + return this.map(function(p) { + return (Math.abs(p - x) <= Sylvester.precision) ? x : p; + }); + }, + + // Returns a string representation of the matrix + inspect: function() { + var matrix_rows = []; + var n = this.elements.length, k = n, i; + do { i = k - n; + matrix_rows.push(Vector.create(this.elements[i]).inspect()); + } while (--n); + return matrix_rows.join('\n'); + }, + + // Set the matrix's elements from an array. If the argument passed + // is a vector, the resulting matrix will be a single column. + setElements: function(els) { + var i, elements = els.elements || els; + if (typeof(elements[0][0]) != 'undefined') { + var ni = elements.length, ki = ni, nj, kj, j; + this.elements = []; + do { i = ki - ni; + nj = elements[i].length; kj = nj; + this.elements[i] = []; + do { j = kj - nj; + this.elements[i][j] = elements[i][j]; + } while (--nj); + } while(--ni); + return this; + } + var n = elements.length, k = n; + this.elements = []; + do { i = k - n; + this.elements.push([elements[i]]); + } while (--n); + return this; + } +}; + +// Constructor function +Matrix.create = function(elements) { + var M = new Matrix(); + return M.setElements(elements); +}; + +// Identity matrix of size n +Matrix.I = function(n) { + var els = [], k = n, i, nj, j; + do { i = k - n; + els[i] = []; nj = k; + do { j = k - nj; + els[i][j] = (i == j) ? 1 : 0; + } while (--nj); + } while (--n); + return Matrix.create(els); +}; + +// Diagonal matrix - all off-diagonal elements are zero +Matrix.Diagonal = function(elements) { + var n = elements.length, k = n, i; + var M = Matrix.I(n); + do { i = k - n; + M.elements[i][i] = elements[i]; + } while (--n); + return M; +}; + +// Rotation matrix about some axis. If no axis is +// supplied, assume we're after a 2D transform +Matrix.Rotation = function(theta, a) { + if (!a) { + return Matrix.create([ + [Math.cos(theta), -Math.sin(theta)], + [Math.sin(theta), Math.cos(theta)] + ]); + } + var axis = a.dup(); + if (axis.elements.length != 3) { return null; } + var mod = axis.modulus(); + var x = axis.elements[0]/mod, y = axis.elements[1]/mod, z = axis.elements[2]/mod; + var s = Math.sin(theta), c = Math.cos(theta), t = 1 - c; + // Formula derived here: http://www.gamedev.net/reference/articles/article1199.asp + // That proof rotates the co-ordinate system so theta + // becomes -theta and sin becomes -sin here. + return Matrix.create([ + [ t*x*x + c, t*x*y - s*z, t*x*z + s*y ], + [ t*x*y + s*z, t*y*y + c, t*y*z - s*x ], + [ t*x*z - s*y, t*y*z + s*x, t*z*z + c ] + ]); +}; + +// Special case rotations +Matrix.RotationX = function(t) { + var c = Math.cos(t), s = Math.sin(t); + return Matrix.create([ + [ 1, 0, 0 ], + [ 0, c, -s ], + [ 0, s, c ] + ]); +}; +Matrix.RotationY = function(t) { + var c = Math.cos(t), s = Math.sin(t); + return Matrix.create([ + [ c, 0, s ], + [ 0, 1, 0 ], + [ -s, 0, c ] + ]); +}; +Matrix.RotationZ = function(t) { + var c = Math.cos(t), s = Math.sin(t); + return Matrix.create([ + [ c, -s, 0 ], + [ s, c, 0 ], + [ 0, 0, 1 ] + ]); +}; + +// Random matrix of n rows, m columns +Matrix.Random = function(n, m) { + return Matrix.Zero(n, m).map( + function() { return Math.random(); } + ); +}; + +// Matrix filled with zeros +Matrix.Zero = function(n, m) { + var els = [], ni = n, i, nj, j; + do { i = n - ni; + els[i] = []; + nj = m; + do { j = m - nj; + els[i][j] = 0; + } while (--nj); + } while (--ni); + return Matrix.create(els); +}; + + + +function Line() {} +Line.prototype = { + + // Returns true if the argument occupies the same space as the line + eql: function(line) { + return (this.isParallelTo(line) && this.contains(line.anchor)); + }, + + // Returns a copy of the line + dup: function() { + return Line.create(this.anchor, this.direction); + }, + + // Returns the result of translating the line by the given vector/array + translate: function(vector) { + var V = vector.elements || vector; + return Line.create([ + this.anchor.elements[0] + V[0], + this.anchor.elements[1] + V[1], + this.anchor.elements[2] + (V[2] || 0) + ], this.direction); + }, + + // Returns true if the line is parallel to the argument. Here, 'parallel to' + // means that the argument's direction is either parallel or antiparallel to + // the line's own direction. A line is parallel to a plane if the two do not + // have a unique intersection. + isParallelTo: function(obj) { + if (obj.normal) { return obj.isParallelTo(this); } + var theta = this.direction.angleFrom(obj.direction); + return (Math.abs(theta) <= Sylvester.precision || Math.abs(theta - Math.PI) <= Sylvester.precision); + }, + + // Returns the line's perpendicular distance from the argument, + // which can be a point, a line or a plane + distanceFrom: function(obj) { + if (obj.normal) { return obj.distanceFrom(this); } + if (obj.direction) { + // obj is a line + if (this.isParallelTo(obj)) { return this.distanceFrom(obj.anchor); } + var N = this.direction.cross(obj.direction).toUnitVector().elements; + var A = this.anchor.elements, B = obj.anchor.elements; + return Math.abs((A[0] - B[0]) * N[0] + (A[1] - B[1]) * N[1] + (A[2] - B[2]) * N[2]); + } else { + // obj is a point + var P = obj.elements || obj; + var A = this.anchor.elements, D = this.direction.elements; + var PA1 = P[0] - A[0], PA2 = P[1] - A[1], PA3 = (P[2] || 0) - A[2]; + var modPA = Math.sqrt(PA1*PA1 + PA2*PA2 + PA3*PA3); + if (modPA === 0) return 0; + // Assumes direction vector is normalized + var cosTheta = (PA1 * D[0] + PA2 * D[1] + PA3 * D[2]) / modPA; + var sin2 = 1 - cosTheta*cosTheta; + return Math.abs(modPA * Math.sqrt(sin2 < 0 ? 0 : sin2)); + } + }, + + // Returns true iff the argument is a point on the line + contains: function(point) { + var dist = this.distanceFrom(point); + return (dist !== null && dist <= Sylvester.precision); + }, + + // Returns true iff the line lies in the given plane + liesIn: function(plane) { + return plane.contains(this); + }, + + // Returns true iff the line has a unique point of intersection with the argument + intersects: function(obj) { + if (obj.normal) { return obj.intersects(this); } + return (!this.isParallelTo(obj) && this.distanceFrom(obj) <= Sylvester.precision); + }, + + // Returns the unique intersection point with the argument, if one exists + intersectionWith: function(obj) { + if (obj.normal) { return obj.intersectionWith(this); } + if (!this.intersects(obj)) { return null; } + var P = this.anchor.elements, X = this.direction.elements, + Q = obj.anchor.elements, Y = obj.direction.elements; + var X1 = X[0], X2 = X[1], X3 = X[2], Y1 = Y[0], Y2 = Y[1], Y3 = Y[2]; + var PsubQ1 = P[0] - Q[0], PsubQ2 = P[1] - Q[1], PsubQ3 = P[2] - Q[2]; + var XdotQsubP = - X1*PsubQ1 - X2*PsubQ2 - X3*PsubQ3; + var YdotPsubQ = Y1*PsubQ1 + Y2*PsubQ2 + Y3*PsubQ3; + var XdotX = X1*X1 + X2*X2 + X3*X3; + var YdotY = Y1*Y1 + Y2*Y2 + Y3*Y3; + var XdotY = X1*Y1 + X2*Y2 + X3*Y3; + var k = (XdotQsubP * YdotY / XdotX + XdotY * YdotPsubQ) / (YdotY - XdotY * XdotY); + return Vector.create([P[0] + k*X1, P[1] + k*X2, P[2] + k*X3]); + }, + + // Returns the point on the line that is closest to the given point or line + pointClosestTo: function(obj) { + if (obj.direction) { + // obj is a line + if (this.intersects(obj)) { return this.intersectionWith(obj); } + if (this.isParallelTo(obj)) { return null; } + var D = this.direction.elements, E = obj.direction.elements; + var D1 = D[0], D2 = D[1], D3 = D[2], E1 = E[0], E2 = E[1], E3 = E[2]; + // Create plane containing obj and the shared normal and intersect this with it + // Thank you: http://www.cgafaq.info/wiki/Line-line_distance + var x = (D3 * E1 - D1 * E3), y = (D1 * E2 - D2 * E1), z = (D2 * E3 - D3 * E2); + var N = Vector.create([x * E3 - y * E2, y * E1 - z * E3, z * E2 - x * E1]); + var P = Plane.create(obj.anchor, N); + return P.intersectionWith(this); + } else { + // obj is a point + var P = obj.elements || obj; + if (this.contains(P)) { return Vector.create(P); } + var A = this.anchor.elements, D = this.direction.elements; + var D1 = D[0], D2 = D[1], D3 = D[2], A1 = A[0], A2 = A[1], A3 = A[2]; + var x = D1 * (P[1]-A2) - D2 * (P[0]-A1), y = D2 * ((P[2] || 0) - A3) - D3 * (P[1]-A2), + z = D3 * (P[0]-A1) - D1 * ((P[2] || 0) - A3); + var V = Vector.create([D2 * x - D3 * z, D3 * y - D1 * x, D1 * z - D2 * y]); + var k = this.distanceFrom(P) / V.modulus(); + return Vector.create([ + P[0] + V.elements[0] * k, + P[1] + V.elements[1] * k, + (P[2] || 0) + V.elements[2] * k + ]); + } + }, + + // Returns a copy of the line rotated by t radians about the given line. Works by + // finding the argument's closest point to this line's anchor point (call this C) and + // rotating the anchor about C. Also rotates the line's direction about the argument's. + // Be careful with this - the rotation axis' direction affects the outcome! + rotate: function(t, line) { + // If we're working in 2D + if (typeof(line.direction) == 'undefined') { line = Line.create(line.to3D(), Vector.k); } + var R = Matrix.Rotation(t, line.direction).elements; + var C = line.pointClosestTo(this.anchor).elements; + var A = this.anchor.elements, D = this.direction.elements; + var C1 = C[0], C2 = C[1], C3 = C[2], A1 = A[0], A2 = A[1], A3 = A[2]; + var x = A1 - C1, y = A2 - C2, z = A3 - C3; + return Line.create([ + C1 + R[0][0] * x + R[0][1] * y + R[0][2] * z, + C2 + R[1][0] * x + R[1][1] * y + R[1][2] * z, + C3 + R[2][0] * x + R[2][1] * y + R[2][2] * z + ], [ + R[0][0] * D[0] + R[0][1] * D[1] + R[0][2] * D[2], + R[1][0] * D[0] + R[1][1] * D[1] + R[1][2] * D[2], + R[2][0] * D[0] + R[2][1] * D[1] + R[2][2] * D[2] + ]); + }, + + // Returns the line's reflection in the given point or line + reflectionIn: function(obj) { + if (obj.normal) { + // obj is a plane + var A = this.anchor.elements, D = this.direction.elements; + var A1 = A[0], A2 = A[1], A3 = A[2], D1 = D[0], D2 = D[1], D3 = D[2]; + var newA = this.anchor.reflectionIn(obj).elements; + // Add the line's direction vector to its anchor, then mirror that in the plane + var AD1 = A1 + D1, AD2 = A2 + D2, AD3 = A3 + D3; + var Q = obj.pointClosestTo([AD1, AD2, AD3]).elements; + var newD = [Q[0] + (Q[0] - AD1) - newA[0], Q[1] + (Q[1] - AD2) - newA[1], Q[2] + (Q[2] - AD3) - newA[2]]; + return Line.create(newA, newD); + } else if (obj.direction) { + // obj is a line - reflection obtained by rotating PI radians about obj + return this.rotate(Math.PI, obj); + } else { + // obj is a point - just reflect the line's anchor in it + var P = obj.elements || obj; + return Line.create(this.anchor.reflectionIn([P[0], P[1], (P[2] || 0)]), this.direction); + } + }, + + // Set the line's anchor point and direction. + setVectors: function(anchor, direction) { + // Need to do this so that line's properties are not + // references to the arguments passed in + anchor = Vector.create(anchor); + direction = Vector.create(direction); + if (anchor.elements.length == 2) {anchor.elements.push(0); } + if (direction.elements.length == 2) { direction.elements.push(0); } + if (anchor.elements.length > 3 || direction.elements.length > 3) { return null; } + var mod = direction.modulus(); + if (mod === 0) { return null; } + this.anchor = anchor; + this.direction = Vector.create([ + direction.elements[0] / mod, + direction.elements[1] / mod, + direction.elements[2] / mod + ]); + return this; + } +}; + + +// Constructor function +Line.create = function(anchor, direction) { + var L = new Line(); + return L.setVectors(anchor, direction); +}; + +// Axes +Line.X = Line.create(Vector.Zero(3), Vector.i); +Line.Y = Line.create(Vector.Zero(3), Vector.j); +Line.Z = Line.create(Vector.Zero(3), Vector.k); + + + +function Plane() {} +Plane.prototype = { + + // Returns true iff the plane occupies the same space as the argument + eql: function(plane) { + return (this.contains(plane.anchor) && this.isParallelTo(plane)); + }, + + // Returns a copy of the plane + dup: function() { + return Plane.create(this.anchor, this.normal); + }, + + // Returns the result of translating the plane by the given vector + translate: function(vector) { + var V = vector.elements || vector; + return Plane.create([ + this.anchor.elements[0] + V[0], + this.anchor.elements[1] + V[1], + this.anchor.elements[2] + (V[2] || 0) + ], this.normal); + }, + + // Returns true iff the plane is parallel to the argument. Will return true + // if the planes are equal, or if you give a line and it lies in the plane. + isParallelTo: function(obj) { + var theta; + if (obj.normal) { + // obj is a plane + theta = this.normal.angleFrom(obj.normal); + return (Math.abs(theta) <= Sylvester.precision || Math.abs(Math.PI - theta) <= Sylvester.precision); + } else if (obj.direction) { + // obj is a line + return this.normal.isPerpendicularTo(obj.direction); + } + return null; + }, + + // Returns true iff the receiver is perpendicular to the argument + isPerpendicularTo: function(plane) { + var theta = this.normal.angleFrom(plane.normal); + return (Math.abs(Math.PI/2 - theta) <= Sylvester.precision); + }, + + // Returns the plane's distance from the given object (point, line or plane) + distanceFrom: function(obj) { + if (this.intersects(obj) || this.contains(obj)) { return 0; } + if (obj.anchor) { + // obj is a plane or line + var A = this.anchor.elements, B = obj.anchor.elements, N = this.normal.elements; + return Math.abs((A[0] - B[0]) * N[0] + (A[1] - B[1]) * N[1] + (A[2] - B[2]) * N[2]); + } else { + // obj is a point + var P = obj.elements || obj; + var A = this.anchor.elements, N = this.normal.elements; + return Math.abs((A[0] - P[0]) * N[0] + (A[1] - P[1]) * N[1] + (A[2] - (P[2] || 0)) * N[2]); + } + }, + + // Returns true iff the plane contains the given point or line + contains: function(obj) { + if (obj.normal) { return null; } + if (obj.direction) { + return (this.contains(obj.anchor) && this.contains(obj.anchor.add(obj.direction))); + } else { + var P = obj.elements || obj; + var A = this.anchor.elements, N = this.normal.elements; + var diff = Math.abs(N[0]*(A[0] - P[0]) + N[1]*(A[1] - P[1]) + N[2]*(A[2] - (P[2] || 0))); + return (diff <= Sylvester.precision); + } + }, + + // Returns true iff the plane has a unique point/line of intersection with the argument + intersects: function(obj) { + if (typeof(obj.direction) == 'undefined' && typeof(obj.normal) == 'undefined') { return null; } + return !this.isParallelTo(obj); + }, + + // Returns the unique intersection with the argument, if one exists. The result + // will be a vector if a line is supplied, and a line if a plane is supplied. + intersectionWith: function(obj) { + if (!this.intersects(obj)) { return null; } + if (obj.direction) { + // obj is a line + var A = obj.anchor.elements, D = obj.direction.elements, + P = this.anchor.elements, N = this.normal.elements; + var multiplier = (N[0]*(P[0]-A[0]) + N[1]*(P[1]-A[1]) + N[2]*(P[2]-A[2])) / (N[0]*D[0] + N[1]*D[1] + N[2]*D[2]); + return Vector.create([A[0] + D[0]*multiplier, A[1] + D[1]*multiplier, A[2] + D[2]*multiplier]); + } else if (obj.normal) { + // obj is a plane + var direction = this.normal.cross(obj.normal).toUnitVector(); + // To find an anchor point, we find one co-ordinate that has a value + // of zero somewhere on the intersection, and remember which one we picked + var N = this.normal.elements, A = this.anchor.elements, + O = obj.normal.elements, B = obj.anchor.elements; + var solver = Matrix.Zero(2,2), i = 0; + while (solver.isSingular()) { + i++; + solver = Matrix.create([ + [ N[i%3], N[(i+1)%3] ], + [ O[i%3], O[(i+1)%3] ] + ]); + } + // Then we solve the simultaneous equations in the remaining dimensions + var inverse = solver.inverse().elements; + var x = N[0]*A[0] + N[1]*A[1] + N[2]*A[2]; + var y = O[0]*B[0] + O[1]*B[1] + O[2]*B[2]; + var intersection = [ + inverse[0][0] * x + inverse[0][1] * y, + inverse[1][0] * x + inverse[1][1] * y + ]; + var anchor = []; + for (var j = 1; j <= 3; j++) { + // This formula picks the right element from intersection by + // cycling depending on which element we set to zero above + anchor.push((i == j) ? 0 : intersection[(j + (5 - i)%3)%3]); + } + return Line.create(anchor, direction); + } + }, + + // Returns the point in the plane closest to the given point + pointClosestTo: function(point) { + var P = point.elements || point; + var A = this.anchor.elements, N = this.normal.elements; + var dot = (A[0] - P[0]) * N[0] + (A[1] - P[1]) * N[1] + (A[2] - (P[2] || 0)) * N[2]; + return Vector.create([P[0] + N[0] * dot, P[1] + N[1] * dot, (P[2] || 0) + N[2] * dot]); + }, + + // Returns a copy of the plane, rotated by t radians about the given line + // See notes on Line#rotate. + rotate: function(t, line) { + var R = Matrix.Rotation(t, line.direction).elements; + var C = line.pointClosestTo(this.anchor).elements; + var A = this.anchor.elements, N = this.normal.elements; + var C1 = C[0], C2 = C[1], C3 = C[2], A1 = A[0], A2 = A[1], A3 = A[2]; + var x = A1 - C1, y = A2 - C2, z = A3 - C3; + return Plane.create([ + C1 + R[0][0] * x + R[0][1] * y + R[0][2] * z, + C2 + R[1][0] * x + R[1][1] * y + R[1][2] * z, + C3 + R[2][0] * x + R[2][1] * y + R[2][2] * z + ], [ + R[0][0] * N[0] + R[0][1] * N[1] + R[0][2] * N[2], + R[1][0] * N[0] + R[1][1] * N[1] + R[1][2] * N[2], + R[2][0] * N[0] + R[2][1] * N[1] + R[2][2] * N[2] + ]); + }, + + // Returns the reflection of the plane in the given point, line or plane. + reflectionIn: function(obj) { + if (obj.normal) { + // obj is a plane + var A = this.anchor.elements, N = this.normal.elements; + var A1 = A[0], A2 = A[1], A3 = A[2], N1 = N[0], N2 = N[1], N3 = N[2]; + var newA = this.anchor.reflectionIn(obj).elements; + // Add the plane's normal to its anchor, then mirror that in the other plane + var AN1 = A1 + N1, AN2 = A2 + N2, AN3 = A3 + N3; + var Q = obj.pointClosestTo([AN1, AN2, AN3]).elements; + var newN = [Q[0] + (Q[0] - AN1) - newA[0], Q[1] + (Q[1] - AN2) - newA[1], Q[2] + (Q[2] - AN3) - newA[2]]; + return Plane.create(newA, newN); + } else if (obj.direction) { + // obj is a line + return this.rotate(Math.PI, obj); + } else { + // obj is a point + var P = obj.elements || obj; + return Plane.create(this.anchor.reflectionIn([P[0], P[1], (P[2] || 0)]), this.normal); + } + }, + + // Sets the anchor point and normal to the plane. If three arguments are specified, + // the normal is calculated by assuming the three points should lie in the same plane. + // If only two are sepcified, the second is taken to be the normal. Normal vector is + // normalised before storage. + setVectors: function(anchor, v1, v2) { + anchor = Vector.create(anchor); + anchor = anchor.to3D(); if (anchor === null) { return null; } + v1 = Vector.create(v1); + v1 = v1.to3D(); if (v1 === null) { return null; } + if (typeof(v2) == 'undefined') { + v2 = null; + } else { + v2 = Vector.create(v2); + v2 = v2.to3D(); if (v2 === null) { return null; } + } + var A1 = anchor.elements[0], A2 = anchor.elements[1], A3 = anchor.elements[2]; + var v11 = v1.elements[0], v12 = v1.elements[1], v13 = v1.elements[2]; + var normal, mod; + if (v2 !== null) { + var v21 = v2.elements[0], v22 = v2.elements[1], v23 = v2.elements[2]; + normal = Vector.create([ + (v12 - A2) * (v23 - A3) - (v13 - A3) * (v22 - A2), + (v13 - A3) * (v21 - A1) - (v11 - A1) * (v23 - A3), + (v11 - A1) * (v22 - A2) - (v12 - A2) * (v21 - A1) + ]); + mod = normal.modulus(); + if (mod === 0) { return null; } + normal = Vector.create([normal.elements[0] / mod, normal.elements[1] / mod, normal.elements[2] / mod]); + } else { + mod = Math.sqrt(v11*v11 + v12*v12 + v13*v13); + if (mod === 0) { return null; } + normal = Vector.create([v1.elements[0] / mod, v1.elements[1] / mod, v1.elements[2] / mod]); + } + this.anchor = anchor; + this.normal = normal; + return this; + } +}; + +// Constructor function +Plane.create = function(anchor, v1, v2) { + var P = new Plane(); + return P.setVectors(anchor, v1, v2); +}; + +// X-Y-Z planes +Plane.XY = Plane.create(Vector.Zero(3), Vector.k); +Plane.YZ = Plane.create(Vector.Zero(3), Vector.i); +Plane.ZX = Plane.create(Vector.Zero(3), Vector.j); +Plane.YX = Plane.XY; Plane.ZY = Plane.YZ; Plane.XZ = Plane.ZX; + +// Utility functions +var $V = Vector.create; +var $M = Matrix.create; +var $L = Line.create; +var $P = Plane.create; diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt new file mode 100644 index 0000000..6cecfe0 --- /dev/null +++ b/lang/CMakeLists.txt @@ -0,0 +1,86 @@ +set(src_imp_dep +../include/mgl2/type.h +../include/mgl2/data.h +../include/mgl2/mgl.h +) + +set(mgl_clean_files "") + +SET_SOURCE_FILES_PROPERTIES(mathgl.i numpy.i PROPERTIES CPLUSPLUS ON) + +if(MGL_HAVE_PYTHON) + include_directories(${PYTHON_INCLUDE_DIR}) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')" + OUTPUT_VARIABLE MGL_PYTHON_SITE_PACKAGES + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(SWIG_MODULE_mathgl_EXTRA_DEPS numpy.i ${src_imp_dep}) + SWIG_ADD_MODULE(mathgl python mathgl.i) + SWIG_LINK_LIBRARIES(mathgl mgl ${PYTHON_LIBRARIES}) + set_target_properties(_mathgl PROPERTIES BUILD_WITH_INSTALL_RPATH ON) + add_custom_command(OUTPUT mathgl.pyc + COMMAND ${PYTHON_EXECUTABLE} + ARGS -c \"from py_compile import compile\; compile('mathgl.py') \" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang + DEPENDS _mathgl + ) + add_custom_target(mgl_python_module ALL DEPENDS _mathgl mathgl.pyc) + + install(FILES ${MathGL_BINARY_DIR}/lang/mathgl.py ${MathGL_BINARY_DIR}/lang/mathgl.pyc DESTINATION ${MGL_PYTHON_SITE_PACKAGES}) + install (TARGETS _mathgl LIBRARY DESTINATION ${MGL_PYTHON_SITE_PACKAGES}) + set(mgl_clean_files ${mgl_clean_files} mathgl.py) +endif(MGL_HAVE_PYTHON) + +if(MGL_HAVE_LUA) + include_directories(${LUA_INCLUDE_DIR}) + set(SWIG_MODULE_mgl-lua_EXTRA_DEPS numpy.i ${src_imp_dep}) + SWIG_ADD_MODULE(mgl-lua lua mathgl.i) + SWIG_LINK_LIBRARIES(mgl-lua mgl ${LUA_LIBRARIES}) + set_target_properties(mgl-lua PROPERTIES PREFIX "" BUILD_WITH_INSTALL_RPATH ON) + + install (TARGETS mgl-lua LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR}) +endif(MGL_HAVE_LUA) + +if(MGL_HAVE_OCTAVE) + execute_process(COMMAND ${oct_prog} -p CANONICAL_HOST_TYPE + OUTPUT_VARIABLE oct_host + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${oct_prog} -p API_VERSION + OUTPUT_VARIABLE oct_api + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${oct_prog} -p OCTINCLUDEDIR + OUTPUT_VARIABLE oct_inc + OUTPUT_STRIP_TRAILING_WHITESPACE) +message(STATUS "${oct_prog} ${oct_host} ${oct_api}") + set(oct_arch ${oct_host}-${oct_api}) + set(pkg_name mathgl) + set(mgl_pkg_dir ${MathGL_BINARY_DIR}/lang/${pkg_name}/inst/${oct_arch}) + + include_directories(${oct_inc} ${oct_inc}/..) + SET(SWIG_MODULE_mgl-oct_EXTRA_DEPS numpy.i ${src_imp_dep}) + SWIG_ADD_MODULE(mgl-oct octave mathgl.i) + SWIG_LINK_LIBRARIES(mgl-oct mgl) + set_target_properties(mgl-oct PROPERTIES OUTPUT_NAME mathgl PREFIX "" SUFFIX ".oct" BUILD_WITH_INSTALL_RPATH ON) + get_target_property(mgl-oct_filename mgl-oct LOCATION) + add_custom_command(OUTPUT mathgl.tar.gz + COMMAND ${CMAKE_COMMAND} -E make_directory ${mgl_pkg_dir} + COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/COPYING ${MathGL_BINARY_DIR}/lang/${pkg_name} + COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/lang/DESCRIPTION ${MathGL_BINARY_DIR}/lang/${pkg_name} + COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/lang/INDEX ${MathGL_BINARY_DIR}/lang/${pkg_name} + COMMAND ${CMAKE_COMMAND} -E copy ${MathGL_SOURCE_DIR}/lang/PKG_ADD_template ${MathGL_BINARY_DIR}/lang/${pkg_name} + COMMAND ${CMAKE_COMMAND} -E copy ${mgl-oct_filename} ${mgl_pkg_dir} + COMMAND ${oct_tar} cpzf mathgl.tar.gz ${pkg_name} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang + DEPENDS mgl-oct + ) + add_custom_target(mgl_octave_module ALL DEPENDS mathgl.tar.gz) + + install(FILES ${CMAKE_BINARY_DIR}/lang/mathgl.tar.gz DESTINATION ${MGL_DATA_PATH}) + if(enable-octave-install) + install(CODE "execute_process( + COMMAND ${oct_exec} -q --eval \"pkg install mathgl.tar.gz\" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/lang )") + endif(enable-octave-install) + set(mgl_clean_files ${mgl_clean_files} mathgl) +endif(MGL_HAVE_OCTAVE) +set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${mgl_clean_files}") diff --git a/lang/DESCRIPTION b/lang/DESCRIPTION new file mode 100644 index 0000000..b7398da --- /dev/null +++ b/lang/DESCRIPTION @@ -0,0 +1,13 @@ +Name: mathgl +Version: 2.0 +Date: 2011-08-23 +Author: Alexey Balakin +Maintainer: Dmitry Kulagin +Title: MathGL +Description: Data plotting library +Depends: octave (>= 2.9.12) +Autoload: yes +SystemRequirements: ... +License: GPL +Keywords: ... +Url: http://octave.sf.net http://mathgl.sf.net diff --git a/lang/INDEX b/lang/INDEX new file mode 100644 index 0000000..e69de29 diff --git a/lang/PKG_ADD_template b/lang/PKG_ADD_template new file mode 100644 index 0000000..761b400 --- /dev/null +++ b/lang/PKG_ADD_template @@ -0,0 +1,2 @@ +mathgl; + diff --git a/lang/data.i b/lang/data.i new file mode 100644 index 0000000..77dd22d --- /dev/null +++ b/lang/data.i @@ -0,0 +1,455 @@ +/*************************************************************************** + * data.i is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#include +class mglData +{ +public: + + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + mreal *a; ///< data array + std::string id; ///< column (or slice) names + bool link; ///< use external data (i.e. don't free it) + + /// Initiate by other mglData variable + inline mglData(const mglData &d) { a=0; mgl_data_set(this,&d); } // NOTE: must be constructor for mglData& to exclude copy one + inline mglData(const mglData *d) { a=0; mgl_data_set(this, d); } + inline mglData(bool, mglData *d) // NOTE: Variable d will be deleted!!! + { if(d) + { nx=d->nx; ny=d->ny; nz=d->nz; a=d->a; d->a=0; + id=d->id; link=d->link; delete d; } + else { a=0; Create(1); } } + /// Initiate by flat array + inline mglData(int size, const float *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const float *d) { a=0; Set(d,cols,rows); } + inline mglData(int size, const double *d) { a=0; Set(d,size); } + inline mglData(int rows, int cols, const double *d) { a=0; Set(d,cols,rows); } + inline mglData(const double *d, int size) { a=0; Set(d,size); } + inline mglData(const double *d, int rows, int cols) { a=0; Set(d,cols,rows); } + /// Read data from file + inline mglData(const char *fname) { a=0; Read(fname); } + /// Allocate the memory for data array and initialize it zero + inline mglData(long xx=1,long yy=1,long zz=1) { a=0; Create(xx,yy,zz); } + /// Delete the array + virtual ~mglData() { if(!link && a) delete []a; } + inline mreal GetVal(long i, long j=0, long k=0) + { return mgl_data_get_value(this,i,j,k);} + inline void SetVal(mreal f, long i, long j=0, long k=0) + { mgl_data_set_value(this,f,i,j,k); } + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + + /// Link external data array (don't delete it at exit) + inline void Link(mreal *A, long NX, long NY=1, long NZ=1) + { mgl_data_link(this,A,NX,NY,NZ); } + inline void Link(mglData &d) { Link(d.a,d.nx,d.ny,d.nz); } + /// Allocate memory and copy the data from the gsl_vector + inline void Set(gsl_vector *m) { mgl_data_set_vector(this,m); } + /// Allocate memory and copy the data from the gsl_matrix + inline void Set(gsl_matrix *m) { mgl_data_set_matrix(this,m); } + + /// Allocate memory and copy the data from the (float *) array + inline void Set(const float *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_float(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (double *) array + inline void Set(const double *A,long NX,long NY=1,long NZ=1) + { mgl_data_set_double(this,A,NX,NY,NZ); } + /// Allocate memory and copy the data from the (float **) array + inline void Set(float const * const *A,long N1,long N2) + { mgl_data_set_float2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (double **) array + inline void Set(double const * const *A,long N1,long N2) + { mgl_data_set_double2(this,A,N1,N2); } + /// Allocate memory and copy the data from the (float ***) array + inline void Set(float const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_float3(this,A,N1,N2,N3); } + /// Allocate memory and copy the data from the (double ***) array + inline void Set(double const * const * const *A,long N1,long N2,long N3) + { mgl_data_set_double3(this,A,N1,N2,N3); } + /// Allocate memory and scanf the data from the string + inline void Set(const char *str,long NX,long NY=1,long NZ=1) + { mgl_data_set_values(this,str,NX,NY,NZ); } + /// Import data from abstract type + inline void Set(const mglData &dat) { mgl_data_set(this, &dat); } + + /// Create or recreate the array with specified size and fill it by zero + inline void Create(long mx,long my=1,long mz=1) + { mgl_data_create(this,mx,my,mz); } + /// Rearange data dimensions + inline void Rearrange(long mx, long my=0, long mz=0) + { mgl_data_rearrange(this,mx,my,mz); } + /// Transpose dimensions of the data (generalization of Transpose) + inline void Transpose(const char *dim="yx") + { mgl_data_transpose(this,dim); } + /// Extend data dimensions + inline void Extend(long n1, long n2=0) + { mgl_data_extend(this,n1,n2); } + /// Reduce size of the data + inline void Squeeze(long rx,long ry=1,long rz=1,bool smooth=false) + { mgl_data_squeeze(this,rx,ry,rz,smooth); } + /// Crop the data + inline void Crop(long n1, long n2,char dir='x') + { mgl_data_crop(this,n1,n2,dir); } + /// Insert data rows/columns/slices + inline void Insert(char dir, long at=0, long num=1) + { mgl_data_insert(this,dir,at,num); } + /// Delete data rows/columns/slices + inline void Delete(char dir, long at=0, long num=1) + { mgl_data_delete(this,dir,at,num); } + /// Remove rows with duplicate values in column id + inline void Clean(long id) + { mgl_data_clean(this,id); } + /// Join with another data array + inline void Join(const mglData &d) + { mgl_data_join(this,&d); } + + /// Modify the data by specified formula + inline void Modify(const char *eq,long dim=0) + { mgl_data_modify(this, eq, dim); } + /// Modify the data by specified formula + inline void Modify(const char *eq,const mglData &vdat, const mglData &wdat) + { mgl_data_modify_vw(this,eq,&vdat,&wdat); } + /// Modify the data by specified formula + inline void Modify(const char *eq,const mglData &vdat) + { mgl_data_modify_vw(this,eq,&vdat,0); } + /// Modify the data by specified formula assuming x,y,z in range [r1,r2] + inline void Fill(mglBase *gr, const char *eq, const char *opt="") + { mgl_data_fill_eq(gr,this,eq,0,0,opt); } + inline void Fill(mglBase *gr, const char *eq, const mglData &vdat, const char *opt="") + { mgl_data_fill_eq(gr,this,eq,&vdat,0,opt); } + inline void Fill(mglBase *gr, const char *eq, const mglData &vdat, const mglData &wdat,const char *opt="") + { mgl_data_fill_eq(gr,this,eq,&vdat,&wdat,opt); } + /// Equidistantly fill the data to range [x1,x2] in direction dir + inline void Fill(mreal x1,mreal x2=NaN,char dir='x') + { return mgl_data_fill(this,x1,x2,dir); } + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in range [p1,p2] + inline void Refill(const mglData &xdat, const mglData &vdat, mreal x1, mreal x2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,x1,x2,sl); } + inline void Refill(const mglData &xdat, const mglData &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_x(this,&xdat,&vdat,p1.x,p2.x,sl); } + inline void Refill(const mglData &xdat, const mglData &ydat, const mglData &vdat, mglPoint p1, mglPoint p2,long sl=-1) + { mgl_data_refill_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y,sl); } + inline void Refill(const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, mglPoint p1, mglPoint p2) + { mgl_data_refill_xyz(this,&xdat,&ydat,&zdat,&vdat,p1.x,p2.x,p1.y,p2.y,p1.z,p2.z); } + /// Fill the data by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range of gr + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &ydat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglBase *gr, const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, const char *opt="") + { mgl_data_refill_gr(gr,this,&xdat,&ydat,&zdat,&vdat,-1,opt); } +/// Set the data by triangulated surface values assuming x,y,z in axis range of gr + inline void Grid(mglBase *gr, const mglData &x, const mglData &y, const mglData &z, const char *opt="") + { mgl_data_grid(gr,this,&x,&y,&z,opt); } + /// Set the data by triangulated surface values assuming x,y,z in range [p1, p2] + inline void Grid(const mglData &xdat, const mglData &ydat, const mglData &vdat, mglPoint p1, mglPoint p2) + { mgl_data_grid_xy(this,&xdat,&ydat,&vdat,p1.x,p2.x,p1.y,p2.y); } + /// Put value to data element(s) + inline void Put(mreal val, long i=-1, long j=-1, long k=-1) + { mgl_data_put_val(this,val,i,j,k); } + /// Put array to data element(s) + inline void Put(const mglData &dat, long i=-1, long j=-1, long k=-1) + { mgl_data_put_dat(this,&dat,i,j,k); } + /// Set names for columns (slices) + inline void SetColumnId(const char *ids) + { mgl_data_set_id(this,ids); } + /// Make new id + inline void NewId() { id.clear(); } + + /// Read data from tab-separated text file with auto determining size + inline bool Read(const char *fname) + { return mgl_data_read(this,fname); } + /// Read data from text file with specifeid size + inline bool Read(const char *fname,long mx,long my=1,long mz=1) + { return mgl_data_read_dim(this,fname,mx,my,mz); } + /// Save whole data array (for ns=-1) or only ns-th slice to text file + inline void Save(const char *fname,long ns=-1) const + { mgl_data_save(this,fname,ns); } + /// Export data array (for ns=-1) or only ns-th slice to PNG file according color scheme + inline void Export(const char *fname,const char *scheme,mreal v1=0,mreal v2=0,long ns=-1) const + { mgl_data_export(this,fname,scheme,v1,v2,ns); } + /// Import data array from PNG file according color scheme + inline void Import(const char *fname,const char *scheme,mreal v1=0,mreal v2=1) + { mgl_data_import(this,fname,scheme,v1,v2); } + /// Read data from tab-separated text files with auto determining size which filenames are result of sprintf(fname,templ,t) where t=from:step:to + inline bool ReadRange(const char *templ, double from, double to, double step=1, bool as_slice=false) + { return mgl_data_read_range(this,templ,from,to,step,as_slice); } + /// Read data from tab-separated text files with auto determining size which filenames are satisfied to template (like "t_*.dat") + inline bool ReadAll(const char *templ, bool as_slice=false) + { return mgl_data_read_all(this, templ, as_slice); } + /// Read data from text file with size specified at beginning of the file + inline bool ReadMat(const char *fname, long dim=2) + { return mgl_data_read_mat(this,fname,dim); } + /// Read data array from HDF file (parse HDF4 and HDF5 files) + inline int ReadHDF(const char *fname,const char *data) + { return mgl_data_read_hdf(this,fname,data); } + /// Save data to HDF file + inline void SaveHDF(const char *fname,const char *data,bool rewrite=false) const + { mgl_data_save_hdf(this,fname,data,rewrite); } + /// Put HDF data names into buf as '\t' separated. + inline static int DatasHDF(const char *fname, char *buf, long size) + { return mgl_datas_hdf(fname,buf,size); } + + /// Get column (or slice) of the data filled by formulas of named columns + inline mglData Column(const char *eq) const + { return mglData(true,mgl_data_column(this,eq)); } + /// Get momentum (1D-array) of data along direction 'dir'. String looks like "x1" for median in x-direction, "x2" for width in x-dir and so on. + inline mglData Momentum(char dir, const char *how) const + { return mglData(true,mgl_data_momentum(this,dir,how)); } + /// Get sub-array of the data with given fixed indexes + inline mglData SubData(long xx,long yy=-1,long zz=-1) const + { return mglData(true,mgl_data_subdata(this,xx,yy,zz)); } + inline mglData SubData(const mglData &xx, const mglData &yy, const mglData &zz) const + { return mglData(true,mgl_data_subdata_ext(this,&xx,&yy,&zz)); } + /// Get trace of the data array + inline mglData Trace() const + { return mglData(true,mgl_data_trace(this)); } + /// Create n-th points distribution of this data values in range [v1, v2] + inline mglData Hist(long n,mreal v1=0,mreal v2=1, long nsub=0) const + { return mglData(true,mgl_data_hist(this,n,v1,v2,nsub)); } + /// Create n-th points distribution of this data values in range [v1, v2] with weight w + inline mglData Hist(const mglData &w, long n,mreal v1=0,mreal v2=1, long nsub=0) const + { return mglData(true,mgl_data_hist_w(this,&w,n,v1,v2,nsub)); } + /// Get array which is result of summation in given direction or directions + inline mglData Sum(const char *dir) const + { return mglData(true,mgl_data_sum(this,dir)); } + /// Get array which is result of maximal values in given direction or directions + inline mglData Max(const char *dir) const + { return mglData(true,mgl_data_max_dir(this,dir)); } + /// Get array which is result of minimal values in given direction or directions + inline mglData Min(const char *dir) const + { return mglData(true,mgl_data_min_dir(this,dir)); } + /// Get the data which is direct multiplication (like, d[i,j] = this[i]*a[j] and so on) + inline mglData Combine(const mglData &dat) const + { return mglData(true,mgl_data_combine(this,&dat)); } + /// Resize the data to new size of box [x1,x2]*[y1,y2]*[z1,z2] + inline mglData Resize(long mx,long my=0,long mz=0, mreal x1=0,mreal x2=1, mreal y1=0,mreal y2=1, mreal z1=0,mreal z2=1) const + { return mglData(true,mgl_data_resize_box(this,mx,my,mz,x1,x2,y1,y2,z1,z2)); } + /// Get array which values is result of interpolation this for coordinates from other arrays + inline mglData Evaluate(const mglData &idat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,0,0,norm)); } + inline mglData Evaluate(const mglData &idat, const mglData &jdat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,&jdat,0,norm)); } + inline mglData Evaluate(const mglData &idat, const mglData &jdat, const mglData &kdat, bool norm=true) const + { return mglData(true,mgl_data_evaluate(this,&idat,&jdat,&kdat,norm)); } + /// Find roots for set of nonlinear equations defined by textual formula + inline mglData Roots(const char *func, char var='x') const + { return mglData(true,mgl_data_roots(func, this, var)); } + /// Find correlation with another data arrays + inline mglData Correl(const mglData &dat, const char *dir) const + { return mglData(true,mgl_data_correl(this,&dat,dir)); } + /// Find auto correlation function + inline mglData AutoCorrel(const char *dir) const + { return mglData(true,mgl_data_correl(this,this,dir)); } + + /// Cumulative summation the data in given direction or directions + inline void CumSum(const char *dir) { mgl_data_cumsum(this,dir); } + /// Integrate (cumulative summation) the data in given direction or directions + inline void Integral(const char *dir) { mgl_data_integral(this,dir); } + /// Differentiate the data in given direction or directions + inline void Diff(const char *dir) { mgl_data_diff(this,dir); } + /// Differentiate the parametrically specified data along direction v1 with v2=const + inline void Diff(const mglData &v1, const mglData &v2) + { mgl_data_diff_par(this,&v1,&v2,0); } + /// Differentiate the parametrically specified data along direction v1 with v2,v3=const + inline void Diff(const mglData &v1, const mglData &v2, const mglData &v3) + { mgl_data_diff_par(this,&v1,&v2,&v3); } + /// Double-differentiate (like Laplace operator) the data in given direction + inline void Diff2(const char *dir) { mgl_data_diff2(this,dir); } + + /// Swap left and right part of the data in given direction (useful for Fourier spectrum) + inline void Swap(const char *dir) { mgl_data_swap(this,dir); } + /// Roll data along direction dir by num slices + inline void Roll(char dir, long num) { mgl_data_roll(this,dir,num); } + /// Mirror the data in given direction (useful for Fourier spectrum) + inline void Mirror(const char *dir) { mgl_data_mirror(this,dir); } + /// Sort rows (or slices) by values of specified column + inline void Sort(long idx, long idy=-1) { mgl_data_sort(this,idx,idy); } + + /// Set as the data envelop + inline void Envelop(char dir='x') + { mgl_data_envelop(this,dir); } + /// Remove phase jump + inline void Sew(const char *dirs="xyz", mreal da=2*Pi) + { mgl_data_sew(this,dirs,da); } + /// Smooth the data on specified direction or directions + inline void Smooth(const char *dirs="xyz",mreal delta=0) + { mgl_data_smooth(this,dirs,delta); } + /// Normalize the data to range [v1,v2] + inline void Norm(mreal v1=0,mreal v2=1,bool sym=false,long dim=0) + { mgl_data_norm(this,v1,v2,sym,dim); } + /// Normalize the data to range [v1,v2] slice by slice + inline void NormSl(mreal v1=0,mreal v2=1,char dir='z',bool keep_en=true,bool sym=false) + { mgl_data_norm_slice(this,v1,v2,dir,keep_en,sym); } + + /// Apply Hankel transform + inline void Hankel(const char *dir) { mgl_data_hankel(this,dir); } + /// Apply Sin-Fourier transform + inline void SinFFT(const char *dir) { mgl_data_sinfft(this,dir); } + /// Apply Cos-Fourier transform + inline void CosFFT(const char *dir) { mgl_data_cosfft(this,dir); } + /// Fill data by 'x'/'k' samples for Hankel ('h') or Fourier ('f') transform + inline void FillSample(const char *how) + { mgl_data_fill_sample(this,how); } + + /// Interpolate by cubic spline the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Spline(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_spline(this, x,y,z); } + /// Interpolate by cubic spline the data to given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Spline1(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_spline(this, x*(nx-1),y*(ny-1),z*(nz-1)); } + /// Interpolate by linear function the data to given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Linear(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear(this,x,y,z); } + /// Interpolate by line the data to given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Linear1(mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear(this,x*(nx-1),y*(ny-1),z*(nz-1)); } + /// Return an approximated x-value (root) when dat(x) = val + inline mreal Solve(mreal val, bool use_spline=true, long i0=0) const + { return mgl_data_solve_1d(this, val, use_spline, i0); } + /// Return an approximated value (root) when dat(x) = val + inline mglData Solve(mreal val, char dir, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, 0, norm)); } + inline mglData Solve(mreal val, char dir, const mglData &i0, bool norm=true) const + { return mglData(true,mgl_data_solve(this, val, dir, &i0, norm)); } + + /// Interpolate by cubic spline the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Spline(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { return mgl_data_spline_ext(this, x,y,z, &(dif.x),&(dif.y), &(dif.z)); } + /// Interpolate by cubic spline the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Spline1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { mreal res=mgl_data_spline_ext(this, x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + /// Interpolate by linear function the data and return its derivatives at given point x=[0...nx-1], y=[0...ny-1], z=[0...nz-1] + inline mreal Linear(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { return mgl_data_linear_ext(this,x,y,z, &(dif.x),&(dif.y), &(dif.z)); } + /// Interpolate by line the data and return its derivatives at given point x,\a y,\a z which normalized in range [0, 1] + inline mreal Linear1(mglPoint &dif, mreal x,mreal y=0,mreal z=0) const + { mreal res=mgl_data_linear_ext(this,x*(nx-1),y*(ny-1),z*(nz-1), &(dif.x),&(dif.y), &(dif.z)); + dif.x*=nx>1?nx-1:1; dif.y*=ny>1?ny-1:1; dif.z*=nz>1?nz-1:1; return res; } + + /// Get information about the data (sizes and momentum) to string + inline const char *PrintInfo() const { return mgl_data_info(this); } + /// Print information about the data (sizes and momentum) to FILE (for example, stdout) + inline void PrintInfo(FILE *fp) const + { if(fp) { fprintf(fp,"%s",mgl_data_info(this)); fflush(fp); } } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + /// Get maximal value of the data and its position + inline mreal Maximal(long &i,long &j,long &k) const + { return mgl_data_max_int(this,&i,&j,&k); } + /// Get minimal value of the data and its position + inline mreal Minimal(long &i,long &j,long &k) const + { return mgl_data_min_int(this,&i,&j,&k); } + /// Get maximal value of the data and its approximated position + inline mreal Maximal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_max_real(this,&x,&y,&z); } + /// Get minimal value of the data and its approximated position + inline mreal Minimal(mreal &x,mreal &y,mreal &z) const + { return mgl_data_min_real(this,&x,&y,&z); } + /// Get "energy" and find first (median) and second (width) momenta of data + inline mreal Momentum(char dir,mreal &m,mreal &w) const + { return mgl_data_momentum_val(this,dir,&m,&w,0,0); } + /// Get "energy and find 4 momenta of data: median, width, skewness, kurtosis + inline mreal Momentum(char dir,mreal &m,mreal &w,mreal &s,mreal &k) const + { return mgl_data_momentum_val(this,dir,&m,&w,&s,&k); } + /// Find position (after specified in i,j,k) of first nonzero value of formula + inline mreal Find(const char *cond, long &i, long &j, long &k) const + { return mgl_data_first(this,cond,&i,&j,&k); } + /// Find position (before specified in i,j,k) of last nonzero value of formula + inline mreal Last(const char *cond, long &i, long &j, long &k) const + { return mgl_data_last(this,cond,&i,&j,&k); } + /// Find position of first in direction 'dir' nonzero value of formula + inline long Find(const char *cond, char dir, long i=0, long j=0, long k=0) const + { return mgl_data_find(this,cond,dir,i,j,k); } + /// Find if any nonzero value of formula + inline bool FindAny(const char *cond) const + { return mgl_data_find_any(this,cond); } + + /// Copy data from other mglData variable + inline mglData &operator=(const mglData &d) + { if(this!=&d) Set(d.a,d.nx,d.ny,d.nz); return *this; } + inline mreal operator=(mreal val) + { for(long i=0;i=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO2d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0)); } +inline mglData mglQO2d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mglData &xx, mglData &yy, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo2d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy)); } +/// Saves result of PDE solving for "Hamiltonian" ham with initial conditions ini along a curve ray (must have nx>=7 - x,y,z,px,py,pz,tau or nx=5 - x,y,px,py,tau) +inline mglData mglQO3d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, 0, 0, 0)); } +inline mglData mglQO3d(const char *ham, const mglData &ini_re, const mglData &ini_im, const mglData &ray, mglData &xx, mglData &yy, mglData &zz, mreal r=1, mreal k0=100) +{ return mglData(true, mgl_qo3d_solve(ham, &ini_re, &ini_im, &ray, r, k0, &xx, &yy, &zz)); } +/// Finds ray with starting point r0, p0 (and prepares ray data for mglQO2d) +inline mglData mglRay(const char *ham, mglPoint r0, mglPoint p0, mreal dt=0.1, mreal tmax=10) +{ return mglData(true, mgl_ray_trace(ham, r0.x, r0.y, r0.z, p0.x, p0.y, p0.z, dt, tmax)); } +/// Calculate Jacobian determinant for D{x(u,v), y(u,v)} = dx/du*dy/dv-dx/dv*dy/du +inline mglData mglJacobian(const mglData &x, const mglData &y) +{ return mglData(true, mgl_jacobian_2d(&x, &y)); } +/// Calculate Jacobian determinant for D{x(u,v,w), y(u,v,w), z(u,v,w)} +inline mglData mglJacobian(const mglData &x, const mglData &y, const mglData &z) +{ return mglData(true, mgl_jacobian_3d(&x, &y, &z)); } +/// Do something like Delone triangulation +inline mglData mglTriangulation(const mglData &x, const mglData &y, const mglData &z) +{ return mglData(true,mgl_triangulation_3d(&x,&y,&z)); } +inline mglData mglTriangulation(const mglData &x, const mglData &y) +{ return mglData(true,mgl_triangulation_2d(&x,&y)); } +//----------------------------------------------------------------------------- diff --git a/lang/mathgl.i b/lang/mathgl.i new file mode 100644 index 0000000..5bd9517 --- /dev/null +++ b/lang/mathgl.i @@ -0,0 +1,96 @@ +/*************************************************************************** + * mgl.i is part of Math Graphic Library + * Copyright (C) 2007 Alexey Balakin , + * Xavier Delacour , + * Alexander Filov * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +%module mathgl +#ifdef SWIGOCTAVE +%feature("autodoc", 1); +#endif // SWIGOCTAVE + +%ignore operator!; +%ignore operator=; +%ignore *::operator=; +%ignore *::operator+=; +%ignore *::operator-=; +%ignore *::operator*=; +%ignore *::operator/=; +//%ignore mglDataA + +%{ +#define SWIG_FILE_WITH_INIT +#include "mgl2/type.h" +#include "mgl2/data.h" +#include "mgl2/mgl.h" +%} + +#if MGL_USE_DOUBLE +typedef double mreal; +#else +typedef float mreal; +#endif + + +#ifdef SWIGOCTAVE +%rename(__add) operator+; +%rename(__sub) operator-; +%rename(__mul) operator*; +%rename(__div) operator/; +%rename(__eq) operator==; +%rename(__ne) operator!=; +%typemap(in,noblock=1) (double* d, int rows, int cols) (Matrix tmp) { + if (!$input.is_matrix_type()) { error("A must be a matrix"); SWIG_fail; } + tmp=$input.matrix_value(); + $1=tmp.data(); + $2=tmp.rows(); + $3=tmp.columns(); +} +#endif + +#ifdef SWIGPYTHON +%rename(__add__) *::operator+(const mglData&, const mglData&); +%rename(__sub__) *::operator-(const mglData&, const mglData &); +%rename(__mul__) *::operator*(const mglData &, float); +%rename(__div__) *::operator/(const mglData &, float); + +// Get the NumPy typemaps +%include "numpy.i" +%init %{ +import_array(); +%} +%apply (double* IN_ARRAY1, int DIM1) {(const double* d, int size)}; +%apply (int DIM1, double* IN_ARRAY1) {(int size, const double* d)}; +%apply (double* IN_ARRAY2, int DIM1, int DIM2) {(const double* d, int rows, int cols)}; +%apply (int DIM1, int DIM2, double* IN_ARRAY2) {(int rows, int cols, const double* d)}; +%apply (double* IN_ARRAY3, int DIM1, int DIM2, int DIM3) {(const double* d, int rows, int cols, int slc)}; +%apply (int DIM1, int DIM2, int DIM3, double* IN_ARRAY3) {(int rows, int cols, int slc, const double* d)}; +#endif + +%include "type.i" +%include "data.i" +%include "mgl.i" +%extend mglData +{ + mreal __getitem__( int i) { return self->GetVal(i); }; + mreal __paren( int i) { return self->GetVal(i); }; + void __setitem__( int i, mreal y) { self->SetVal(y,i); }; + void __paren_asgn( int i, mreal y) { self->SetVal(y,i); }; +}; diff --git a/lang/mgl.i b/lang/mgl.i new file mode 100644 index 0000000..88703ba --- /dev/null +++ b/lang/mgl.i @@ -0,0 +1,1309 @@ +/*************************************************************************** + * mgl.h is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +/// Wrapper class for all graphics +class mglGraph +{ +protected: + HMGL gr; +public: + inline mglGraph(int kind=0, int width=600, int height=400) + { + if(kind==-1) gr=NULL; +#if MGL_HAVE_OPENGL + else if(kind==1) gr=mgl_create_graph_gl(); +#else + else if(kind==1) + { gr=mgl_create_graph(width, height); + mglGlobalMess += "OpenGL support was disabled. Please, enable it and rebuild MathGL.\n"; } +#endif + else gr=mgl_create_graph(width, height); + } + inline mglGraph(const mglGraph &graph) + { gr = graph.gr; mgl_use_graph(gr,1); } + inline mglGraph(HMGL graph) + { gr = graph; mgl_use_graph(gr,1); } + virtual ~mglGraph() + { if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); } + /// Get pointer to internal mglCanvas object + inline HMGL Self() { return gr; } + /// Set default parameters for plotting + inline void DefaultPlotParam() { mgl_set_def_param(gr); } + /// Set name of plot for saving filename + inline void SetPlotId(const char *id) { mgl_set_plotid(gr,id); } + /// Get name of plot for saving filename + inline const char *GetPlotId() { return mgl_get_plotid(gr); } + + /// Set the transparency on/off. + inline void Alpha(bool enable) { mgl_set_alpha(gr, enable); } + /// Set default value of alpha-channel + inline void SetAlphaDef(double alpha) { mgl_set_alpha_default(gr, alpha); } + /// Set the transparency type (0 - usual, 1 - glass, 2 - lamp) + inline void SetTranspType(int type) { mgl_set_transp_type(gr, type); } + + /// Set the using of light on/off. + inline void Light(bool enable) { mgl_set_light(gr, enable); } + /// Switch on/off the specified light source. + inline void Light(int n,bool enable) { mgl_set_light_n(gr, n, enable); } + /// Use diffusive light (only for local light sources) -- OBSOLETE + inline void SetDifLight(bool dif) { mgl_set_light_dif(gr, dif); } + /// Add a light source. + inline void AddLight(int n, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_ext(gr, n, p.x, p.y, p.z, col, bright, ap); } + inline void AddLight(int n, mglPoint r, mglPoint p, char col='w', double bright=0.5, double ap=0) + { mgl_add_light_loc(gr, n, r.x, r.y, r.z, p.x, p.y, p.z, col, bright, ap); } + /// Set ambient light brightness + inline void SetAmbient(double i) { mgl_set_ambbr(gr, i); } + /// Set diffusive light brightness + inline void SetDiffuse(double i) { mgl_set_difbr(gr, i); } + /// Set the fog distance or switch it off (if d=0). + inline void Fog(double d, double dz=0.25) { mgl_set_fog(gr, d, dz); } + + /// Set relative width of rectangles in Bars, Barh, BoxPlot + inline void SetBarWidth(double width) { mgl_set_bar_width(gr, width); } + /// Set default size of marks (locally you can use "size" option) + inline void SetMarkSize(double size) { mgl_set_mark_size(gr, size); } + /// Set default size of arrows (locally you can use "size" option) + inline void SetArrowSize(double size) { mgl_set_arrow_size(gr, size); } + /// Set number of mesh lines (use 0 to draw all of them) + inline void SetMeshNum(int num) { mgl_set_meshnum(gr, num); } + /// Set number of visible faces (use 0 to draw all of them) + inline void SetFaceNum(int num) { mgl_set_facenum(gr, num); } + + /// Set cutting for points outside of bounding box + inline void SetCut(bool cut) { mgl_set_cut(gr, cut); } + /// Set additional cutting box + inline void SetCutBox(mglPoint p1, mglPoint p2) + { mgl_set_cut_box(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z); } + /// Set the cutting off condition (formula) + inline void CutOff(const char *EqC) { mgl_set_cutoff(gr, EqC); } + + /// Set default font size + inline void SetFontSize(double size) { mgl_set_font_size(gr, size); } + /// Set default font style and color + inline void SetFontDef(const char *fnt) { mgl_set_font_def(gr, fnt); } + /// Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72) + virtual void SetFontSizePT(double pt, int dpi=72){ SetFontSize(pt*27.f/dpi); } + /// Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt) + inline void SetFontSizeCM(double cm, int dpi=72) { SetFontSizePT(cm*28.45f,dpi); } + /// Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt) + inline void SetFontSizeIN(double in, int dpi=72) { SetFontSizePT(in*72.27f,dpi); } + /// Load font from file + inline void LoadFont(const char *name, const char *path=NULL) + { mgl_load_font(gr, name, path); } + /// Copy font from another mglGraph instance + inline void CopyFont(const mglGraph *GR) { mgl_copy_font(gr, GR->gr);} + /// Restore font (load default font for new HMGL objects) + inline void RestoreFont() { mgl_restore_font(gr); } + /// Set to use or not text rotation + inline void SetRotatedText(bool rotated) { mgl_set_rotated_text(gr, rotated); } + + /// Set default palette + inline void SetPalette(const char *colors) { mgl_set_palette(gr, colors); } + /// Set default color scheme + inline void SetDefScheme(const char *sch) { mgl_set_def_sch(gr, sch); } + + /// Sets RGB values for color with given id + static inline void SetColor(char id, double r, double g, double b) { mgl_set_color(id, r, g, b); } + /// Set mask for face coloring as array of type 'unsigned char[8]' + static inline void SetMask(char id, const char *mask) { mgl_set_mask(id, mask); } + /// Set mask for face coloring as uint64_t number + static inline void SetMask(char id, uint64_t mask) { mgl_set_mask_val(id, mask); } + /// Set default mask rotation angle + inline void SetMaskAngle(int angle) { mgl_set_mask_angle(gr, angle); } + + /// Get last warning code + inline int GetWarn() { return mgl_get_warn(gr);} + /// Set warning code ant fill message + inline void SetWarn(int code, const char *info) { mgl_set_warn(gr,code,info); } + /// Set buffer for warning messages + inline const char *Message() { return mgl_get_mess(gr); } + + /// Set axis range scaling -- simplified way to shift/zoom axis range -- need to replot whole image! + inline void ZoomAxis(mglPoint p1=mglPoint(0,0,0,0), mglPoint p2=mglPoint(1,1,1,1)) + { mgl_zoom_axis(gr, p1.x,p1.y,p1.z,p1.c, p2.x,p2.y,p2.z,p2.c); } + /// Set range in direction dir as [v1, v2] + inline void SetRange(char dir, double v1, double v2) + { mgl_set_range_val(gr, dir, v1, v2); } + /// Set range in direction dir as minimal and maximal values of data a + inline void SetRange(char dir, const mglData &dat, bool add=false) + { mgl_set_range_dat(gr, dir, &dat, add); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy, const mglData &zz, const mglData &cc) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&cc,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy, const mglData &zz) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); + mgl_set_range_dat(gr,'z',&zz,0); mgl_set_range_dat(gr,'c',&zz,0); } + /// Set values of axis range as minimal and maximal values of datas + inline void SetRanges(const mglData &xx, const mglData &yy) + { mgl_set_range_dat(gr,'x',&xx,0); mgl_set_range_dat(gr,'y',&yy,0); } + /// Set values of axis ranges + inline void SetRanges(double x1, double x2, double y1, double y2, double z1=0, double z2=0) + { mgl_set_ranges(gr, x1, x2, y1, y2, z1, z2); } + /// Set values of axis ranges + inline void SetRanges(mglPoint p1, mglPoint p2) + { mgl_set_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z); } + /// Set ranges for automatic variables + inline void SetAutoRanges(double x1, double x2, double y1=0, double y2=0, double z1=0, double z2=0, double c1=0, double c2=0) + { mgl_set_auto_ranges(gr, x1, x2, y1, y2, z1, z2, c1, c2); } + /// Set ranges for automatic variables + inline void SetAutoRanges(mglPoint p1, mglPoint p2) + { mgl_set_auto_ranges(gr, p1.x, p2.x, p1.y, p2.y, p1.z, p2.z, p1.c, p2.c); } + /// Set axis origin + inline void SetOrigin(mglPoint p) + { mgl_set_origin(gr, p.x, p.y, p.z); } + inline void SetOrigin(double x0, double y0, double z0=NaN) + { mgl_set_origin(gr, x0, y0, z0); } + + /// Set the transformation formulas for coordinate + inline void SetFunc(const char *EqX, const char *EqY, const char *EqZ=NULL, const char *EqA=NULL) + { mgl_set_func(gr, EqX, EqY, EqZ, EqA); } + /// Set one of predefined transformation rule + inline void SetCoor(int how) { mgl_set_coor(gr, how); } + /// Set to draw Ternary axis (triangle like axis, grid and so on) + inline void Ternary(int val) { mgl_set_ternary(gr, val); } + + /// Set to use or not tick labels rotation + inline void SetTickRotate(bool val) { mgl_set_tick_rotate(gr,val); } + /// Set to use or not tick labels skipping + inline void SetTickSkip(bool val) { mgl_set_tick_skip(gr,val); } + /// Set tick length + inline void SetTickLen(double len, double stt=1) + { mgl_set_tick_len(gr, len, stt); } + /// Set axis and ticks style + inline void SetAxisStl(const char *stl="k", const char *tck=0, const char *sub=0) + { mgl_set_axis_stl(gr, stl, tck, sub); } + + /// Set time templates for ticks + inline void SetTicksTime(char dir, double d=0, const char *t="") + { mgl_set_ticks_time(gr,dir,d,t); } + /// Set ticks text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const char *lbl, bool add=false) + { mgl_set_ticks_str(gr,dir,lbl,add); } + inline void SetTicksVal(char dir, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_wcs(gr,dir,lbl,add); } + /// Set ticks position and text (\n separated). Use "" to disable this feature. + inline void SetTicksVal(char dir, const mglData &v, const char *lbl, bool add=false) + { mgl_set_ticks_val(gr,dir,&v,lbl,add); } + inline void SetTicksVal(char dir, const mglData &v, const wchar_t *lbl, bool add=false) + { mgl_set_ticks_valw(gr,dir,&v,lbl,add); } + /// Set the ticks parameters + inline void SetTicks(char dir, double d=0, int ns=0, double org=NaN) + { mgl_set_ticks(gr, dir, d, ns, org); } + /// Auto adjust ticks + inline void Adjust(const char *dir="xyzc") + { mgl_adjust_ticks(gr, dir); } + /// Set templates for ticks + inline void SetTickTempl(char dir, const char *t) + { mgl_set_tick_templ(gr,dir,t); } + inline void SetTickTempl(char dir, const wchar_t *t) + { mgl_set_tick_templw(gr,dir,t); } + /// Tune ticks + inline void SetTuneTicks(int tune, double fact_pos=1.15) + { mgl_tune_ticks(gr, tune, fact_pos); } + /// Set additional shift of tick labels + inline void SetTickShift(mglPoint p) + { mgl_set_tick_shift(gr,p.x,p.y,p.z,p.c); } + /// Set to use UTC time instead of local time + inline void SetTimeUTC(bool enable) + { mgl_set_flag(gr,enable, MGL_USE_GMTIME); } + /// Set to draw tick labels at axis origin + inline void SetOriginTick(bool enable=true) + { mgl_set_flag(gr,!enable, MGL_NO_ORIGIN); } + + /// Put further plotting in some region of whole frame. + inline void SubPlot(int nx,int ny,int m,const char *style="<>_^", double dx=0, double dy=0) + { mgl_subplot_d(gr, nx, ny, m, style, dx, dy); } + /// Like SubPlot() but "join" several cells + inline void MultiPlot(int nx,int ny,int m, int dx, int dy, const char *style="<>_^") + { mgl_multiplot(gr, nx, ny, m, dx, dy, style); } + /// Put further plotting in a region of whole frame. + inline void InPlot(double x1,double x2,double y1,double y2, bool rel=true) + { if(rel) mgl_relplot(gr, x1, x2, y1, y2); + else mgl_inplot(gr, x1, x2, y1, y2); } + /// Put further plotting in column cell of previous subplot + inline void ColumnPlot(int num, int ind, double d=0) + { mgl_columnplot(gr,num,ind,d); } + /// Put further plotting in matrix cell of previous subplot + inline void GridPlot(int nx, int ny, int ind, double d=0) + { mgl_gridplot(gr,nx,ny,ind,d); } + /// Put further plotting in cell of stick rotated on angles tet, phi + inline void StickPlot(int num, int i, double tet, double phi) + { mgl_stickplot(gr,num,i,tet,phi); } + + /// Set factor of plot size + inline void SetPlotFactor(double val) + { mgl_set_plotfactor(gr,val); } + /// Push transformation matrix into stack + inline void Push() { mgl_mat_push(gr); } + /// Pop transformation matrix from stack + inline void Pop() { mgl_mat_pop(gr); } + + /// Add title for current subplot/inplot + inline void Title(const char *title,const char *stl="",double size=-2) + { mgl_title(gr,title,stl,size); } + inline void Title(const wchar_t *title,const char *stl="",double size=-2) + { mgl_titlew(gr,title,stl,size); } + /// Set aspect ratio for further plotting. + inline void Aspect(double Ax,double Ay,double Az=1) + { mgl_aspect(gr, Ax, Ay, Az); } + /// Rotate a further plotting. + inline void Rotate(double TetX,double TetZ=0,double TetY=0) + { mgl_rotate(gr, TetX, TetZ, TetY); } + /// Rotate a further plotting around vector {x,y,z}. + inline void RotateN(double Tet,double x,double y,double z) + { mgl_rotate_vector(gr, Tet, x, y, z); } + /// Set perspective (in range [0,1)) for plot. Set to zero for switching off. + inline void Perspective(double val) + { mgl_perspective(gr, val); } + /// Set angle of view independently from Rotate(). + inline void View(double TetX,double TetZ=0,double TetY=0) + { mgl_view(gr, TetX, TetZ, TetY); } + /// Zoom in/out a part of picture (use Zoom(0, 0, 1, 1) for restore default) + inline void Zoom(double x1, double y1, double x2, double y2) + { mgl_zoom(gr, x1, y1, x2, y2); } + + /// Set size of frame in pixels. Normally this function is called internally. + inline void SetSize(int width, int height) { mgl_set_size(gr, width, height); } + /// Set plot quality + inline void SetQuality(int qual=MGL_DRAW_NORM) { mgl_set_quality(gr, qual); } + /// Get plot quality + inline int GetQuality() { return mgl_get_quality(gr); } + /// Set drawing region for Quality&4 + inline void SetDrawReg(long nx, long ny, long m){ mgl_set_draw_reg(gr,nx,ny,m); } + /// Start group of objects + inline void StartGroup(const char *name) { mgl_start_group(gr, name); } + /// End group of objects + inline void EndGroup() { mgl_end_group(gr); } + /// Highlight objects with given id + inline void Highlight(int id) { mgl_highlight(gr, id); } + + /// Show current image + inline void ShowImage(const char *viewer, bool keep=0) + { mgl_show_image(gr, viewer, keep); } + /// Write the frame in file (depending extension, write current frame if fname is empty) + inline void WriteFrame(const char *fname=0,const char *descr="") + { mgl_write_frame(gr, fname, descr); } + /// Write the frame in file using JPEG format + inline void WriteJPEG(const char *fname,const char *descr="") + { mgl_write_jpg(gr, fname, descr); } + /// Write the frame in file using PNG format with transparency + inline void WritePNG(const char *fname,const char *descr="", bool alpha=true) + { if(alpha) mgl_write_png(gr, fname, descr); + else mgl_write_png_solid(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteBMP(const char *fname,const char *descr="") + { mgl_write_bmp(gr, fname, descr); } + /// Write the frame in file using BMP format + inline void WriteTGA(const char *fname,const char *descr="") + { mgl_write_tga(gr, fname, descr); } + /// Write the frame in file using PostScript format + inline void WriteEPS(const char *fname,const char *descr="") + { mgl_write_eps(gr, fname, descr); } + /// Write the frame in file using LaTeX format + inline void WriteTEX(const char *fname,const char *descr="") + { mgl_write_tex(gr, fname, descr); } + /// Write the frame in file using PostScript format as bitmap + inline void WriteBPS(const char *fname,const char *descr="") + { mgl_write_bps(gr, fname, descr); } + /// Write the frame in file using SVG format + inline void WriteSVG(const char *fname,const char *descr="") + { mgl_write_svg(gr, fname, descr); } + /// Write the frame in file using GIF format (only for current frame!) + inline void WriteGIF(const char *fname,const char *descr="") + { mgl_write_gif(gr, fname, descr); } + + /// Write the frame in file using OBJ format + inline void WriteOBJ(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj(gr, fname, descr, use_png); } + /// Write the frame in file using OBJ format - Balakin way + inline void WriteOBJold(const char *fname,const char *descr="",bool use_png=true) + { mgl_write_obj_old(gr, fname, descr, use_png); } + /// Write the frame in file using XYZ format + inline void WriteXYZ(const char *fname,const char *descr="") + { mgl_write_xyz(gr, fname, descr); } + /// Write the frame in file using STL format (faces only) + inline void WriteSTL(const char *fname,const char *descr="") + { mgl_write_stl(gr, fname, descr); } + /// Write the frame in file using OFF format + inline void WriteOFF(const char *fname,const char *descr="", bool colored=false) + { mgl_write_off(gr, fname, descr,colored); } +// /// Write the frame in file using X3D format +// inline void WriteX3D(const char *fname,const char *descr="") +// { mgl_write_x3d(gr, fname, descr); } + /// Write the frame in file using PRC format + inline void WritePRC(const char *fname,const char *descr="",bool make_pdf=true) + { mgl_write_prc(gr, fname, descr, make_pdf); } + /// Export in JSON format suitable for later drawing by JavaScript + inline void WriteJSON(const char *fname,const char *descr="",bool force_z=false) + { if(force_z) mgl_write_json_z(gr, fname, descr); + else mgl_write_json(gr, fname, descr); } + /// Return string of JSON data suitable for later drawing by JavaScript + inline const char *GetJSON() { return mgl_get_json(gr); } + + /// Force preparing the image. It can be useful for OpenGL mode mostly. + inline void Finish() { mgl_finish(gr); } + /// Create new frame. + inline void NewFrame() { mgl_new_frame(gr); } + /// Finish frame drawing + inline void EndFrame() { mgl_end_frame(gr); } + /// Get the number of created frames + inline int GetNumFrame() { return mgl_get_num_frame(gr); } + /// Reset frames counter (start it from zero) + inline void ResetFrames() { mgl_reset_frames(gr); } + /// Delete primitives for i-th frame (work if MGL_VECT_FRAME is set on) + inline void DelFrame(int i) { mgl_del_frame(gr, i); } + /// Get drawing data for i-th frame (work if MGL_VECT_FRAME is set on) + inline void GetFrame(int i) { mgl_get_frame(gr, i); } + /// Set drawing data for i-th frame (work if MGL_VECT_FRAME is set on). Work as EndFrame() but don't add frame to GIF image. + inline void SetFrame(int i) { mgl_set_frame(gr, i); } + /// Append drawing data from i-th frame (work if MGL_VECT_FRAME is set on) + inline void ShowFrame(int i){ mgl_show_frame(gr, i); } + + /// Start write frames to cinema using GIF format + inline void StartGIF(const char *fname, int ms=100) + { mgl_start_gif(gr, fname,ms); } + /// Stop writing cinema using GIF format + inline void CloseGIF() { mgl_close_gif(gr); } + /// Export points and primitives in file using MGLD format + inline void ExportMGLD(const char *fname, const char *descr=0) + { mgl_export_mgld(gr, fname, descr); } + /// Import points and primitives from file using MGLD format + inline void ImportMGLD(const char *fname, bool add=false) + { mgl_import_mgld(gr, fname, add); } + + /// Copy RGB values into array which is allocated by user + inline void GetRGB(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=3*w*h) memcpy(imgdata, mgl_get_rgb(gr),3*w*h); + } + inline const unsigned char *GetRGB() { return mgl_get_rgb(gr); } + /// Copy RGBA values into array which is allocated by user + inline void GetRGBA(char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr); + if(imglen>=4*w*h) memcpy(imgdata, mgl_get_rgba(gr),4*w*h); + } + inline const unsigned char *GetRGBA() { return mgl_get_rgba(gr); } + /// Copy BGRN values into array which is allocated by user + inline void GetBGRN(unsigned char *imgdata, int imglen) + { + long w=mgl_get_width(gr), h=mgl_get_height(gr), i; + const unsigned char *buf=mgl_get_rgb(gr); + if(imglen>=4*w*h) for(i=0;igr); } + + /// Clear up the frame + inline void Clf(double r, double g, double b) { mgl_clf_rgb(gr, r, g, b); } + inline void Clf(char col) { mgl_clf_chr(gr, col); } + inline void Clf() { mgl_clf(gr); } + /// Clear unused points and primitives. Useful only in combination with SetFaceNum(). + inline void ClearUnused() { mgl_clear_unused(gr); } + /// Draws the point (ball) at position {x,y,z} with color c + inline void Ball(mglPoint p, char c='r') + { char s[3]={'.',c,0}; mgl_mark(gr, p.x, p.y, p.z, s); } + /// Draws the mark at position p + inline void Mark(mglPoint p, const char *mark) + { mgl_mark(gr, p.x, p.y, p.z, mark); } + /// Draws the line between points by specified pen + inline void Line(mglPoint p1, mglPoint p2, const char *pen="B",int n=2) + { mgl_line(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, pen, n); } + /// Draws the spline curve between points by specified pen + inline void Curve(mglPoint p1, mglPoint d1, mglPoint p2, mglPoint d2, const char *pen="B", int n=100) + { mgl_curve(gr, p1.x, p1.y, p1.z, d1.x, d1.y, d1.z, p2.x, p2.y, p2.z, d2.x, d2.y, d2.z, pen, n); } + /// Draws the 3d error box e for point p + inline void Error(mglPoint p, mglPoint e, const char *pen="k") + { mgl_error_box(gr, p.x, p.y, p.z, e.x, e.y, e.z, pen); } + + /// Draws the face between points with color stl (include interpolation up to 4 colors). + inline void Face(mglPoint p1, mglPoint p2, mglPoint p3, mglPoint p4, const char *stl="r") + { mgl_face(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, p3.x, p3.y, p3.z, p4.x, p4.y, p4.z, stl); } + /// Draws the face in y-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceX(mglPoint p, double wy, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facex(gr, p.x, p.y, p.z, wy, wz, stl, dx, dy); } + /// Draws the face in x-z plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceY(mglPoint p, double wx, double wz, const char *stl="w", double dx=0, double dy=0) + { mgl_facey(gr, p.x, p.y, p.z, wx, wz, stl, dx, dy); } + /// Draws the face in x-y plane at point p with color stl (include interpolation up to 4 colors). + inline void FaceZ(mglPoint p, double wx, double wy, const char *stl="w", double dx=0, double dy=0) + { mgl_facez(gr, p.x, p.y, p.z, wx, wy, stl, dx, dy); } + /// Draws the drop at point p in direction d with color col and radius r + inline void Drop(mglPoint p, mglPoint d, double r, const char *col="r", double shift=1, double ap=1) + { mgl_drop(gr, p.x, p.y, p.z, d.x, d.y, d.z, r, col, shift, ap); } + /// Draws the sphere at point p with color col and radius r + inline void Sphere(mglPoint p, double r, const char *col="r") + { mgl_sphere(gr, p.x, p.y, p.z, r, col); } + /// Draws the cone between points p1,p2 with radius r1,r2 and with style stl + inline void Cone(mglPoint p1, mglPoint p2, double r1, double r2=-1, const char *stl="r@") + { mgl_cone(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z,r1,r2,stl); } + /// Draws the ellipse between points p1,p2 with color stl and width r + inline void Ellipse(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_ellipse(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + /// Draws the circle at point p with color stl and radius r + inline void Circle(mglPoint p, double r, const char *stl="r") + { mgl_ellipse(gr, p.x, p.y, p.z, p.x, p.y, p.z, r,stl); } + /// Draws the rhomb between points p1,p2 with color stl and width r + inline void Rhomb(mglPoint p1, mglPoint p2, double r, const char *stl="r") + { mgl_rhomb(gr, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, r,stl); } + + /// Print text in position p with specified font + inline void Putsw(mglPoint p,const wchar_t *text,const char *font=":C",double size=-1) + { mgl_putsw(gr, p.x, p.y, p.z, text, font, size); } + inline void Puts(mglPoint p,const char *text,const char *font=":C",double size=-1) + { mgl_puts(gr, p.x, p.y, p.z, text, font, size); } + inline void Putsw(double x, double y,const wchar_t *text,const char *font=":AC",double size=-1) + { mgl_putsw(gr, x, y, 0, text, font, size); } + inline void Puts(double x, double y,const char *text,const char *font=":AC",double size=-1) + { mgl_puts(gr, x, y, 0, text, font, size); } + /// Print text in position p along direction d with specified font + inline void Putsw(mglPoint p, mglPoint d, const wchar_t *text, const char *font=":L", double size=-1) + { mgl_putsw_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + inline void Puts(mglPoint p, mglPoint d, const char *text, const char *font=":L", double size=-1) + { mgl_puts_dir(gr, p.x, p.y, p.z, d.x, d.y, d.z, text, font, size); } + + /// Print text along the curve + inline void Text(const mglData &x, const mglData &y, const mglData &z, const char *text, const char *font="", const char *opt="") + { mgl_text_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const char *text, const char *font="", const char *opt="") + { mgl_text_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglData &y, const char *text, const char *font="", const char *opt="") + { mgl_text_y(gr, &y, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xyz(gr, &x, &y, &z, text, font, opt); } + inline void Text(const mglData &x, const mglData &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_xy(gr, &x, &y, text, font, opt); } + inline void Text(const mglData &y, const wchar_t *text, const char *font="", const char *opt="") + { mgl_textw_y(gr, &y, text, font, opt); } + + /// Draws bounding box outside the plotting volume with color c. + inline void Box(const char *col="", bool ticks=true) + { mgl_box_str(gr, col, ticks); } + /// Draw axises with ticks in direction(s) dir. + inline void Axis(const char *dir="xyzt", const char *stl="", const char *opt="") + { mgl_axis(gr, dir,stl,opt); } + /// Draw grid lines perpendicular to direction(s) dir. + inline void Grid(const char *dir="xyzt",const char *pen="B", const char *opt="") + { mgl_axis_grid(gr, dir, pen, opt); } + /// Print the label text for axis dir. + inline void Label(char dir, const char *text, double pos=+1, const char *opt="") + { mgl_label(gr, dir, text, pos, opt); } + inline void Label(char dir, const wchar_t *text, double pos=+1, const char *opt="") + { mgl_labelw(gr, dir, text, pos, opt); } + + /// Draw colorbar at edge of axis + inline void Colorbar(const char *sch="") + { mgl_colorbar(gr, sch); } + inline void Colorbar(const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_ext(gr, sch, x,y,w,h); } + /// Draw colorbar with manual colors at edge of axis + inline void Colorbar(const mglData &val, const char *sch="") + { mgl_colorbar_val(gr, &val, sch); } + inline void Colorbar(const mglData &val, const char *sch,double x,double y,double w=1,double h=1) + { mgl_colorbar_val_ext(gr, &val, sch, x,y,w,h); } + + /// Add string to legend + inline void AddLegend(const char *text,const char *style) + { mgl_add_legend(gr, text, style); } + inline void AddLegend(const wchar_t *text,const char *style) + { mgl_add_legendw(gr, text, style); } + /// Clear saved legend string + inline void ClearLegend() + { mgl_clear_legend(gr); } + /// Draw legend of accumulated strings at position {x,y} + inline void Legend(double x, double y, const char *font="#", const char *opt="") + { mgl_legend_pos(gr, x, y, font, opt); } + /// Draw legend of accumulated strings + inline void Legend(int where=3, const char *font="#", const char *opt="") + { mgl_legend(gr, where, font, opt); } + /// Set number of marks in legend sample + inline void SetLegendMarks(int num) { mgl_set_legend_marks(gr, num); } + + /// Draw usual curve {x,y,z} + inline void Plot(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_plot_xyz(gr, &x, &y, &z, pen, opt); } + inline void Plot(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_plot_xy(gr, &x, &y, pen,opt); } + inline void Plot(const mglData &y, const char *pen="", const char *opt="") + { mgl_plot(gr, &y, pen,opt); } + /// Draw tape(s) which rotates as (bi-)normales of curve {x,y,z} + inline void Tape(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_tape_xyz(gr, &x, &y, &z, pen, opt); } + inline void Tape(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_tape_xy(gr, &x, &y, pen,opt); } + inline void Tape(const mglData &y, const char *pen="", const char *opt="") + { mgl_tape(gr, &y, pen,opt); } + /// Draw radar chart (plot in curved coordinates) + inline void Radar(const mglData &a, const char *pen="", const char *opt="") + { mgl_radar(gr, &a, pen, opt); } + /// Draw stairs for points in arrays {x,y,z} + inline void Step(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_step_xyz(gr, &x, &y, &z, pen, opt); } + inline void Step(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_step_xy(gr, &x, &y, pen, opt); } + inline void Step(const mglData &y, const char *pen="", const char *opt="") + { mgl_step(gr, &y, pen, opt); } + /// Draw curve {x,y,z} which is colored by c (like tension plot) + inline void Tens(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens_xyz(gr, &x, &y, &z, &c, pen, opt); } + inline void Tens(const mglData &x, const mglData &y, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens_xy(gr, &x, &y, &c, pen, opt); } + inline void Tens(const mglData &y, const mglData &c, const char *pen="", const char *opt="") + { mgl_tens(gr, &y, &c, pen, opt); } + /// Fill area between curve {x,y,z} and axis plane + inline void Area(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_area_xyz(gr, &x, &y, &z, pen, opt); } + inline void Area(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_area_xy(gr, &x, &y, pen, opt); } + inline void Area(const mglData &y, const char *pen="", const char *opt="") + { mgl_area(gr, &y, pen, opt); } + /// Fill area between curves y1 and y2 specified parametrically + inline void Region(const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_region(gr, &y1, &y2, pen, opt); } + inline void Region(const mglData &x, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_region_xy(gr, &x, &y1, &y2, pen, opt); } + /// Draw vertical lines from points {x,y,z} to axis plane + inline void Stem(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_stem_xyz(gr, &x, &y, &z, pen, opt); } + inline void Stem(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_stem_xy(gr, &x, &y, pen, opt); } + inline void Stem(const mglData &y, const char *pen="", const char *opt="") + { mgl_stem(gr, &y, pen, opt); } + + /// Draw vertical bars from points {x,y,z} to axis plane + inline void Bars(const mglData &x, const mglData &y, const mglData &z, const char *pen="", const char *opt="") + { mgl_bars_xyz(gr, &x, &y, &z, pen, opt); } + inline void Bars(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_bars_xy(gr, &x, &y, pen, opt); } + inline void Bars(const mglData &y, const char *pen="", const char *opt="") + { mgl_bars(gr, &y, pen, opt); } + /// Draw horizontal bars from points {x,y} to axis plane + inline void Barh(const mglData &y, const mglData &v, const char *pen="", const char *opt="") + { mgl_barh_yx(gr, &y, &v, pen, opt); } + inline void Barh(const mglData &v, const char *pen="", const char *opt="") + { mgl_barh(gr, &v, pen, opt); } + /// Draw chart for data a + inline void Chart(const mglData &a, const char *colors="", const char *opt="") + { mgl_chart(gr, &a, colors,opt); } + /// Draw Open-High-Low-Close (OHLC) diagram + inline void OHLC(const mglData &x, const mglData &open, const mglData &high, const mglData &low, const mglData &close, const char *pen="", const char *opt="") + { mgl_ohlc_x(gr, &x, &open,&high,&low,&close,pen,opt); } + inline void OHLC(const mglData &open, const mglData &high, const mglData &low, const mglData &close, const char *pen="", const char *opt="") + { mgl_ohlc(gr, &open,&high,&low,&close,pen,opt); } + + /// Draw box-plot (special 5-value plot used in statistic) + inline void BoxPlot(const mglData &x, const mglData &y, const char *pen="", const char *opt="") + { mgl_boxplot_xy(gr, &x, &y, pen,opt); } + inline void BoxPlot(const mglData &y, const char *pen="", const char *opt="") + { mgl_boxplot(gr, &y, pen,opt); } + /// Draw candle plot + inline void Candle(const mglData &x, const mglData &v1, const mglData &v2, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle_xyv(gr, &x, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglData &v1, const mglData &v2, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, &y1, &y2, pen, opt); } + inline void Candle(const mglData &v1, const mglData &v2, const char *pen="", const char *opt="") + { mgl_candle_yv(gr, &v1, &v2, NULL, NULL, pen, opt); } + inline void Candle(const mglData &y, const mglData &y1, const mglData &y2, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, &y1, &y2, pen, opt); } + inline void Candle(const mglData &y, const char *pen="", const char *opt="") + { mgl_candle(gr, &y, NULL, NULL, pen, opt); } + /// Draw cones from points {x,y,z} to axis plane + inline void Cones(const mglData &x, const mglData &y, const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones_xyz(gr, &x, &y, &z, pen, opt); } + inline void Cones(const mglData &x, const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones_xz(gr, &x, &z, pen, opt); } + inline void Cones(const mglData &z, const char *pen="@", const char *opt="") + { mgl_cones(gr, &z, pen, opt); } + + /// Draw error boxes {ex,ey} at points {x,y} + inline void Error(const mglData &y, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error(gr, &y, &ey, pen, opt); } + inline void Error(const mglData &x, const mglData &y, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error_xy(gr, &x, &y, &ey, pen, opt); } + inline void Error(const mglData &x, const mglData &y, const mglData &ex, const mglData &ey, const char *pen="", const char *opt="") + { mgl_error_exy(gr, &x, &y, &ex, &ey, pen, opt); } + /// Draw marks with size r at points {x,y,z} + inline void Mark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_xyz(gr, &x, &y, &z, &r, pen, opt); } + inline void Mark(const mglData &x, const mglData &y, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_xy(gr, &x, &y, &r, pen, opt); } + inline void Mark(const mglData &y, const mglData &r, const char *pen, const char *opt="") + { mgl_mark_y(gr, &y, &r, pen, opt); } + /// Draw textual marks with size r at points {x,y,z} + inline void TextMark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const mglData &r, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_textmark(gr, &y, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyzr(gr, &x, &y, &z, &r, text, fnt, opt); } + inline void TextMark(const mglData &x, const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_xyr(gr, &x, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const mglData &r, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw_yr(gr, &y, &r, text, fnt, opt); } + inline void TextMark(const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_textmarkw(gr, &y, text, fnt, opt); } + + /// Draw labels for points coordinate(s) at points {x,y,z} + inline void Label(const mglData &x, const mglData &y, const mglData &z, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglData &y, const char *text, const char *fnt="", const char *opt="") + { mgl_label_y(gr, &y, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const mglData &z, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xyz(gr, &x, &y, &z, text, fnt, opt); } + inline void Label(const mglData &x, const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_xy(gr, &x, &y, text, fnt, opt); } + inline void Label(const mglData &y, const wchar_t *text, const char *fnt="", const char *opt="") + { mgl_labelw_y(gr, &y, text, fnt, opt); } + + /// Draw table for values val along given direction with row labels text + inline void Table(const mglData &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, 0, 0, &val, text, fnt, opt); } + inline void Table(const mglData &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, 0, 0, &val, text, fnt, opt); } + /// Draw table for values val along given direction with row labels text at given position + inline void Table(double x, double y, const mglData &val, const char *text, const char *fnt="#|", const char *opt="") + { mgl_table(gr, x, y, &val, text, fnt, opt); } + inline void Table(double x, double y, const mglData &val, const wchar_t *text, const char *fnt="#|", const char *opt="") + { mgl_tablew(gr, x, y, &val, text, fnt, opt); } + + /// Draw tube with radius r around curve {x,y,z} + inline void Tube(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_xyzr(gr, &x, &y, &z, &r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, const mglData &z, double r, const char *pen="", const char *opt="") + { mgl_tube_xyz(gr, &x, &y, &z, r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_xyr(gr, &x, &y, &r, pen, opt); } + inline void Tube(const mglData &x, const mglData &y, double r, const char *pen="", const char *opt="") + { mgl_tube_xy(gr, &x, &y, r, pen, opt); } + inline void Tube(const mglData &y, const mglData &r, const char *pen="", const char *opt="") + { mgl_tube_r(gr, &y, &r, pen, opt); } + inline void Tube(const mglData &y, double r, const char *pen="", const char *opt="") + { mgl_tube(gr, &y, r, pen, opt); } + /// Draw surface of curve {r,z} rotatation around axis + inline void Torus(const mglData &r, const mglData &z, const char *pen="", const char *opt="") + { mgl_torus(gr, &r, &z, pen,opt); } + + /// Draw mesh lines for 2d data specified parametrically + inline void Mesh(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_mesh_xy(gr, &x, &y, &z, stl, opt); } + inline void Mesh(const mglData &z, const char *stl="", const char *opt="") + { mgl_mesh(gr, &z, stl, opt); } + /// Draw mesh lines for 2d data specified parametrically + inline void Fall(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_fall_xy(gr, &x, &y, &z, stl, opt); } + inline void Fall(const mglData &z, const char *stl="", const char *opt="") + { mgl_fall(gr, &z, stl, opt); } + /// Draw belts for 2d data specified parametrically + inline void Belt(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_belt_xy(gr, &x, &y, &z, stl, opt); } + inline void Belt(const mglData &z, const char *stl="", const char *opt="") + { mgl_belt(gr, &z, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to z + inline void Surf(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_surf_xy(gr, &x, &y, &z, stl, opt); } + inline void Surf(const mglData &z, const char *stl="", const char *opt="") + { mgl_surf(gr, &z, stl, opt); } + /// Draw grid lines for density plot of 2d data specified parametrically + inline void Grid(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_grid_xy(gr, &x, &y, &z, stl, opt); } + inline void Grid(const mglData &z, const char *stl="", const char *opt="") + { mgl_grid(gr, &z, stl, opt); } + /// Draw vertical tiles for 2d data specified parametrically + inline void Tile(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_tile_xy(gr, &x, &y, &z, stl, opt); } + inline void Tile(const mglData &z, const char *stl="", const char *opt="") + { mgl_tile(gr, &z, stl, opt); } + /// Draw density plot for 2d data specified parametrically + inline void Dens(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_dens_xy(gr, &x, &y, &z, stl, opt); } + inline void Dens(const mglData &z, const char *stl="", const char *opt="") + { mgl_dens(gr, &z, stl, opt); } + /// Draw vertical boxes for 2d data specified parametrically + inline void Boxs(const mglData &x, const mglData &y, const mglData &z, const char *stl="", const char *opt="") + { mgl_boxs_xy(gr, &x, &y, &z, stl, opt); } + inline void Boxs(const mglData &z, const char *stl="", const char *opt="") + { mgl_boxs(gr, &z, stl, opt); } + + /// Draw contour lines for 2d data specified parametrically + inline void Cont(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void Cont(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_val(gr, &v, &z, sch, opt); } + inline void Cont(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_cont_xy(gr, &x, &y, &z, sch, opt); } + inline void Cont(const mglData &z, const char *sch="", const char *opt="") + { mgl_cont(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically + inline void ContF(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContF(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_val(gr, &v, &z, sch, opt); } + inline void ContF(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contf_xy(gr, &x, &y, &z, sch, opt); } + inline void ContF(const mglData &z, const char *sch="", const char *opt="") + { mgl_contf(gr, &z, sch, opt); } + /// Draw solid contours for 2d data specified parametrically with manual colors + inline void ContD(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContD(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_val(gr, &v, &z, sch, opt); } + inline void ContD(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contd_xy(gr, &x, &y, &z, sch, opt); } + inline void ContD(const mglData &z, const char *sch="", const char *opt="") + { mgl_contd(gr, &z, sch, opt); } + /// Draw contour tubes for 2d data specified parametrically + inline void ContV(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_xy_val(gr, &v, &x, &y, &z, sch, opt); } + inline void ContV(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_val(gr, &v, &z, sch, opt); } + inline void ContV(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_contv_xy(gr, &x, &y, &z, sch, opt); } + inline void ContV(const mglData &z, const char *sch="", const char *opt="") + { mgl_contv(gr, &z, sch, opt); } + + /// Draw axial-symmetric isosurfaces for 2d data specified parametrically + inline void Axial(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_xy_val(gr, &v, &x, &y, &z, sch,opt); } + inline void Axial(const mglData &v, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_val(gr, &v, &z, sch, opt); } + inline void Axial(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_axial_xy(gr, &x, &y, &z, sch, opt); } + inline void Axial(const mglData &z, const char *sch="", const char *opt="") + { mgl_axial(gr, &z, sch, opt); } + + /// Draw grid lines for density plot at slice for 3d data specified parametrically + inline void Grid3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Grid3(const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_grid3(gr, &a, stl, sVal, opt); } + /// Draw density plot at slice for 3d data specified parametrically + inline void Dens3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3_xyz(gr, &x, &y, &z, &a, stl, sVal, opt); } + inline void Dens3(const mglData &a, const char *stl="", double sVal=-1, const char *opt="") + { mgl_dens3(gr, &a, stl, sVal, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically + inline void Surf3(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz_val(gr, Val, &x, &y, &z, &a, stl, opt); } + inline void Surf3(double Val, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_val(gr, Val, &a, stl, opt); } + inline void Surf3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Surf3(const mglData &a, const char *stl="", const char *opt="") + { mgl_surf3(gr, &a, stl, opt); } + + /// Draw a semi-transparent cloud for 3d data + inline void Cloud(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *stl="", const char *opt="") + { mgl_cloud_xyz(gr, &x, &y, &z, &a, stl, opt); } + inline void Cloud(const mglData &a, const char *stl="", const char *opt="") + { mgl_cloud(gr, &a, stl, opt); } + + /// Draw contour lines at slice for 3d data specified parametrically + inline void Cont3(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglData &v, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_val(gr, &v, &a, sch, sVal, opt); } + inline void Cont3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void Cont3(const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_cont3(gr, &a, sch, sVal, opt); } + + /// Draw solid contours at slice for 3d data specified parametrically + inline void ContF3(const mglData &v, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz_val(gr, &v, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglData &v, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_val(gr, &v, &a, sch, sVal, opt); } + inline void ContF3(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3_xyz(gr, &x, &y, &z, &a, sch, sVal, opt); } + inline void ContF3(const mglData &a, const char *sch="", double sVal=-1, const char *opt="") + { mgl_contf3(gr, &a, sch, sVal, opt); } + + /// Draw several isosurfaces for 3d beam in curvilinear coordinates + inline void Beam(const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, double r, const char *stl=0, int flag=0, int num=3) + { mgl_beam(gr, &tr,&g1,&g2,&a,r,stl,flag,num); } + inline void Beam(double val, const mglData &tr, const mglData &g1, const mglData &g2, const mglData &a, double r, const char *stl=NULL, int flag=0) + { mgl_beam_val(gr,val,&tr,&g1,&g2,&a,r,stl,flag); } + + /// Draw vertical tiles with variable size r for 2d data specified parametrically + inline void TileS(const mglData &x, const mglData &y, const mglData &z, const mglData &r, const char *stl="", const char *opt="") + { mgl_tiles_xy(gr, &x, &y, &z, &r, stl, opt); } + inline void TileS(const mglData &z, const mglData &r, const char *stl="", const char *opt="") + { mgl_tiles(gr, &z, &r, stl, opt); } + /// Draw surface for 2d data specified parametrically with color proportional to c + inline void SurfC(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfc_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfC(const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfc(gr, &z, &c, sch,opt); } + /// Draw surface for 2d data specified parametrically with alpha proportional to c + inline void SurfA(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfa_xy(gr, &x, &y, &z, &c, sch,opt); } + inline void SurfA(const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_surfa(gr, &z, &c, sch,opt); } + + /// Color map of matrix a to matrix b, both matrix can parametrically depend on coordinates + inline void Map(const mglData &x, const mglData &y, const mglData &a, const mglData &b, const char *sch="", const char *opt="") + { mgl_map_xy(gr, &x, &y, &a, &b, sch, opt); } + inline void Map(const mglData &a, const mglData &b, const char *sch="", const char *opt="") + { mgl_map(gr, &a, &b, sch, opt); } + /// Draw density plot for spectra-gramm specified parametrically + inline void STFA(const mglData &x, const mglData &y, const mglData &re, const mglData &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa_xy(gr, &x, &y, &re, &im, dn, sch, opt); } + inline void STFA(const mglData &re, const mglData &im, int dn, const char *sch="", const char *opt="") + { mgl_stfa(gr, &re, &im, dn, sch, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with alpha proportional to b + inline void Surf3A(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(double Val, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3A(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3A(const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3a(gr, &a, &b, stl, opt); } + + /// Draw isosurface(s) for 3d data specified parametrically with color proportional to b + inline void Surf3C(double Val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz_val(gr, Val, &x, &y, &z, &a, &b, stl,opt); } + inline void Surf3C(double Val, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_val(gr, Val, &a, &b, stl, opt); } + inline void Surf3C(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c_xyz(gr, &x, &y, &z, &a, &b, stl, opt); } + inline void Surf3C(const mglData &a, const mglData &b, const char *stl="", const char *opt="") + { mgl_surf3c(gr, &a, &b, stl, opt); } + + /// Plot dew drops for vector field {ax,ay} parametrically depended on coordinate {x,y} + inline void Dew(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_dew_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Dew(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_dew_2d(gr, &ax, &ay, sch, opt); } + /// Plot vectors at position {x,y,z} along {ax,ay,az} with length/color proportional to |a| + inline void Traj(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_traj_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Traj(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_traj_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + + /// Plot vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with length/color proportional to |a| + inline void Vect(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_vect_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Vect(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_vect_2d(gr, &ax, &ay, sch, opt); } + inline void Vect(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_vect_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Vect(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_vect_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Draw vector plot at slice for 3d data specified parametrically + inline void Vect3(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3_xyz(gr, &x, &y, &z, &ax,&ay,&az, stl, sVal, opt); } + inline void Vect3(const mglData &ax, const mglData &ay, const mglData &az, const char *stl="", double sVal=-1, const char *opt="") + { mgl_vect3(gr, &ax,&ay,&az, stl, sVal, opt); } + + /// Plot flows for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void Flow(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flow_xy(gr, &x, &y, &ax, &ay, sch, opt); } + inline void Flow(const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flow_2d(gr, &ax, &ay, sch, opt); } + inline void Flow(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flow_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void Flow(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flow_3d(gr, &ax, &ay, &az, sch, opt); } + + /// Plot flow from point p for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color proportional to |a| + inline void FlowP(mglPoint p, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flowp_xy(gr, p.x, p.y, p.z, &x, &y, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglData &ax, const mglData &ay, const char *sch="", const char *opt="") + { mgl_flowp_2d(gr, p.x, p.y, p.z, &ax, &ay, sch, opt); } + inline void FlowP(mglPoint p, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flowp_xyz(gr, p.x, p.y, p.z, &x, &y, &z, &ax, &ay, &az, sch, opt); } + inline void FlowP(mglPoint p, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", const char *opt="") + { mgl_flowp_3d(gr, p.x, p.y, p.z, &ax, &ay, &az, sch, opt); } + + /// Plot flows for gradient of scalar field phi parametrically depended on coordinate {x,y,z} + inline void Grad(const mglData &x, const mglData &y, const mglData &z, const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad_xyz(gr,&x,&y,&z,&phi,sch,opt); } + inline void Grad(const mglData &x, const mglData &y, const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad_xy(gr,&x,&y,&phi,sch,opt); } + inline void Grad(const mglData &phi, const char *sch="", const char *opt="") + { mgl_grad(gr,&phi,sch,opt); } + + /// Plot flow pipes for vector field {ax,ay,az} parametrically depended on coordinate {x,y,z} with color and radius proportional to |a| + inline void Pipe(const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xy(gr, &x, &y, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglData &ax, const mglData &ay, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_2d(gr, &ax, &ay, sch, r0, opt); } + inline void Pipe(const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_xyz(gr, &x, &y, &z, &ax, &ay, &az, sch, r0, opt); } + inline void Pipe(const mglData &ax, const mglData &ay, const mglData &az, const char *sch="", double r0=0.05, const char *opt="") + { mgl_pipe_3d(gr, &ax, &ay, &az, sch, r0, opt); } + + /// Draw density plot for data at x = sVal + inline void DensX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_x(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at y = sVal + inline void DensY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_y(gr, &a, stl, sVal, opt); } + /// Draw density plot for data at z = sVal + inline void DensZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_dens_z(gr, &a, stl, sVal, opt); } + /// Draw contour lines for data at x = sVal + inline void ContX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x(gr, &a, stl, sVal, opt); } + inline void ContX(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at y = sVal + inline void ContY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y(gr, &a, stl, sVal, opt); } + inline void ContY(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw contour lines for data at z = sVal + inline void ContZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z(gr, &a, stl, sVal, opt); } + inline void ContZ(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_cont_z_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at x = sVal + inline void ContFX(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x(gr, &a, stl, sVal, opt); } + inline void ContFX(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_x_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at y = sVal + inline void ContFY(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y(gr, &a, stl, sVal, opt); } + inline void ContFY(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_y_val(gr, &v, &a, stl, sVal, opt); } + /// Draw solid contours for data at z = sVal + inline void ContFZ(const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z(gr, &a, stl, sVal, opt); } + inline void ContFZ(const mglData &v, const mglData &a, const char *stl="", double sVal=NaN, const char *opt="") + { mgl_contf_z_val(gr, &v, &a, stl, sVal, opt); } + + /// Draw curve for formula with x in x-axis range + inline void FPlot(const char *fy, const char *stl="", const char *opt="") + { mgl_fplot(gr, fy, stl, opt); } + /// Draw curve for formulas parametrically depended on t in range [0,1] + inline void FPlot(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fplot_xyz(gr, fx, fy, fz, stl, opt); } + /// Draw surface by formula with x,y in axis range + inline void FSurf(const char *fz, const char *stl="", const char *opt="") + { mgl_fsurf(gr, fz, stl, opt); } + /// Draw surface by formulas parametrically depended on u,v in range [0,1] + inline void FSurf(const char *fx, const char *fy, const char *fz, const char *stl, const char *opt="") + { mgl_fsurf_xyz(gr, fx, fy, fz, stl, opt); } + + /// Draw triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_triplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_triplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriPlot(const mglData &nums, const mglData &x, const mglData &y, const char *sch="", const char *opt="") + { mgl_triplot_xy(gr, &nums, &x, &y, sch, opt); } + /// Draw quad mesh for points in arrays {x,y,z} with specified color c. + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &c, const char *sch="", const char *opt="") + { mgl_quadplot_xyzc(gr, &nums, &x, &y, &z, &c, sch, opt); } + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_quadplot_xyz(gr, &nums, &x, &y, &z, sch, opt); } + inline void QuadPlot(const mglData &nums, const mglData &x, const mglData &y, const char *sch="", const char *opt="") + { mgl_quadplot_xy(gr, &nums, &x, &y, sch, opt); } + + /// Draw contour lines for triangle mesh for points in arrays {x,y,z} with specified color c. + inline void TriCont(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_tricont_xyc(gr, &nums, &x, &y, &z, sch, opt); } + inline void TriContV(const mglData &v, const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_tricont_xycv(gr, &v, &nums, &x, &y, &z, sch, opt); } + inline void TriCont(const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzc(gr, &nums, &x, &y, &z, &a, sch, opt); } + inline void TriContV(const mglData &v, const mglData &nums, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_tricont_xyzcv(gr, &v, &nums, &x, &y, &z, &a, sch, opt); } + + /// Draw dots in points {x,y,z}. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_dots(gr, &x, &y, &z, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified alpha a. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *sch="", const char *opt="") + { mgl_dots_a(gr, &x, &y, &z, &a, sch, opt); } + /// Draw semitransparent dots in points {x,y,z} with specified color c and alpha a. + inline void Dots(const mglData &x, const mglData &y, const mglData &z, const mglData &c, const mglData &a, const char *sch="", const char *opt="") + { mgl_dots_ca(gr, &x, &y, &z, &c, &a, sch, opt); } + /// Draw surface reconstructed for points in arrays {x,y,z}. + inline void Crust(const mglData &x, const mglData &y, const mglData &z, const char *sch="", const char *opt="") + { mgl_crust(gr, &x, &y, &z, sch, opt); } + + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglData &y, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq,var,0, opt)); } + inline mglData Fit(const mglData &y, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_1(gr, &y, eq, var, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit2(const mglData &z, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, var,0, opt)); } + inline mglData Fit2(const mglData &z, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_2(gr, &z, eq, var, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit3(const mglData &a, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, var,0, opt)); } + inline mglData Fit3(const mglData &a, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_3(gr, &a, eq, var, &ini, opt)); } + /// Fit data along x-direction for each data row. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xy(gr, &x, &y, eq, var, &ini, opt)); } + /// Fit data along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyz(gr, &x, &y, &z, eq, var, &ini, opt)); } + /// Fit data along along all directions. Return array with values for found formula. + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq, var,0, opt)); } + inline mglData Fit(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyza(gr, &x, &y, &z, &a, eq,var, &ini, opt)); } + /// Fit data with dispersion s along x-direction for each data row. Return array with values for found formula. + inline mglData FitS(const mglData &y, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &y, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_ys(gr, &y, &s, eq, var, &ini, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xys(gr, &x, &y, &s, eq, var, &ini, opt)); } + /// Fit data with dispersion s along x-, y-directions for each data slice. Return array with values for found formula. + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzs(gr, &x, &y, &z, &s, eq, var, &ini, opt)); } + /// Fit data with dispersion s along all directions. Return array with values for found formula. + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *eq, const char *var, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, var,0, opt)); } + inline mglData FitS(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &s, const char *eq, const char *var, mglData &ini, const char *opt="") + { return mglData(true,mgl_fit_xyzas(gr, &x, &y, &z, &a, &s, eq, var, &ini, opt)); } + /// Print fitted last formula (with coefficients) + inline void PutsFit(mglPoint p, const char *prefix=0, const char *font="", double size=-1) + { mgl_puts_fit(gr, p.x, p.y, p.z, prefix, font, size); } + /// Get last fitted formula + inline const char *GetFit() + { return mgl_get_fit(gr); } + + /// Solve PDE with x,y,z in range [Min, Max] + inline mglData PDE(const char *ham, const mglData &ini_re, const mglData &ini_im, double dz=0.1, double k0=100, const char *opt="") + { return mglData(true,mgl_pde_solve(gr,ham,&ini_re,&ini_im,dz,k0, opt)); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglData &u, const char *eq, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglData &v, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglData &u, const char *eq, const mglData &v, const mglData &w, const char *opt="") + { mgl_data_fill_eq(gr, &u, eq, &v, &w, opt); } + /// Fill data by formula with x,y,z in range [Min, Max] + inline void Fill(mglDataC &u, const char *eq, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, 0, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglData &v, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, 0, opt); } + inline void Fill(mglDataC &u, const char *eq, const mglData &v, const mglData &w, const char *opt="") + { mgl_datac_fill_eq(gr, &u, eq, &v, &w, opt); } + + /// Fill dat by interpolated values of vdat parametrically depended on xdat,ydat,zdat for x,y,z in axis range + inline void Refill(mglData &dat, const mglData &xdat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,0,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglData &xdat, const mglData &ydat, const mglData &vdat, long sl=-1, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,0,&vdat,sl,opt); } + inline void Refill(mglData &dat, const mglData &xdat, const mglData &ydat, const mglData &zdat, const mglData &vdat, const char *opt="") + { mgl_data_refill_gr(gr,&dat,&xdat,&ydat,&zdat,&vdat,-1,opt); } + + /// Set the data by triangulated surface values assuming x,y,z in range [Min, Max] + inline void DataGrid(mglData &d, const mglData &x, const mglData &y, const mglData &z, const char *opt="") + { mgl_data_grid(gr,&d,&x,&y,&z,opt); } + + /// Make histogram (distribution) of data. This function do not plot data. + inline mglData Hist(const mglData &x, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_x(gr, &x, &a, opt)); } + inline mglData Hist(const mglData &x, const mglData &y, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_xy(gr, &x, &y, &a, opt)); } + inline mglData Hist(const mglData &x, const mglData &y, const mglData &z, const mglData &a, const char *opt="") + { return mglData(true, mgl_hist_xyz(gr, &x, &y, &z, &a, opt)); } + + inline void Compression(bool){} // NOTE: Add later -- IDTF + /// Set the preference for vertex color on/off (for formats that support it, now only PRC does). + inline void VertexColor(bool enable) { mgl_set_flag(gr,enable, MGL_PREFERVC); } + /// Render only front side of surfaces for dubugging purposes (for formats that support it, now only PRC does). + inline void DoubleSided(bool enable) { mgl_set_flag(gr,!enable, MGL_ONESIDED); } +// inline void TextureColor(bool){} // NOTE: Add later -- IDTF +}; +//----------------------------------------------------------------------------- +/// Wrapper class for MGL parsing +class mglParse +{ + HMPR pr; +public: + mglParse(HMPR p) { pr = p; mgl_use_parser(pr,1); } + mglParse(mglParse &p) { pr = p.pr; mgl_use_parser(pr,1); } + mglParse(bool setsize=false) + { pr=mgl_create_parser(); mgl_parser_allow_setsize(pr, setsize); } + ~mglParse() { if(mgl_use_parser(pr,-1)<1) mgl_delete_parser(pr); } + /// Get pointer to internal mglParser object + inline HMPR Self() { return pr; } + /// Parse and draw single line of the MGL script + inline int Parse(mglGraph *gr, const char *str, int pos) + { return mgl_parse_line(gr->Self(), pr, str, pos); } + inline int Parse(mglGraph *gr, const wchar_t *str, int pos) + { return mgl_parse_linew(gr->Self(), pr, str, pos); } + /// Execute MGL script text with '\n' separated lines + inline void Execute(mglGraph *gr, const char *str) + { mgl_parse_text(gr->Self(), pr, str); } + inline void Execute(mglGraph *gr, const wchar_t *str) + { mgl_parse_textw(gr->Self(), pr, str); } + /// Execute and draw script from the file + inline void Execute(mglGraph *gr, FILE *fp, bool print=false) + { mgl_parse_file(gr->Self(), pr, fp, print); } + + /// Return type of command: 0 - not found, 1 - data plot, 2 - other plot, + /// 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program + /// 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot + /// 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform + inline int CmdType(const char *name) + { return mgl_parser_cmd_type(pr, name); } + /// Return string of command format (command name and its argument[s]) + inline const char *CmdFormat(const char *name) + { return mgl_parser_cmd_frmt(pr, name); } + /// Return description of MGL command + inline const char *CmdDesc(const char *name) + { return mgl_parser_cmd_desc(pr, name); } + /// Get name of command with nmber n + inline const char *GetCmdName(long n) + { return mgl_parser_cmd_name(pr,n); } + /// Get number of defined commands + inline long GetCmdNum() + { return mgl_parser_cmd_num(pr); } + + /// Set value for parameter $N + inline void AddParam(int id, const char *str) + { mgl_parser_add_param(pr, id, str); } + inline void AddParam(int id, const wchar_t *str) + { mgl_parser_add_paramw(pr, id, str); } + /// Restore once flag + inline void RestoreOnce() { mgl_parser_restore_once(pr); } + /// Allow changing size of the picture + inline void AllowSetSize(bool allow) { mgl_parser_allow_setsize(pr, allow); } + /// Allow reading/saving files + inline void AllowFileIO(bool allow) { mgl_parser_allow_file_io(pr, allow); } + /// Set flag to stop script parsing + inline void Stop() { mgl_parser_stop(pr); } + + /// Return result of formula evaluation + inline mglData Calc(const char *formula) + { return mglData(true,mgl_parser_calc(pr,formula)); } + inline mglData Calc(const wchar_t *formula) + { return mglData(true,mgl_parser_calcw(pr,formula)); } + + /// Find variable with given name or add a new one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *AddVar(const char *name) + { return dynamic_cast(mgl_parser_add_var(pr, name)); } + inline mglVar *AddVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_add_varw(pr, name)); } + /// Find variable with given name or return NULL if no one + /// NOTE !!! You must not delete obtained data arrays !!! + inline mglVar *FindVar(const char *name) + { return dynamic_cast(mgl_parser_find_var(pr, name)); } + inline mglVar *FindVar(const wchar_t *name) + { return dynamic_cast(mgl_parser_find_varw(pr, name)); } + /// Delete variable with name + inline void DeleteVar(const char *name) { mgl_parser_del_var(pr, name); } + inline void DeleteVar(const wchar_t *name) { mgl_parser_del_varw(pr, name); } + /// Delete all data variables + void DeleteAll() { mgl_parser_del_all(pr); } +}; +//----------------------------------------------------------------------------- +/// Wrapper class expression evaluating +class mglExpr +{ + HMEX ex; +public: + mglExpr(const char *expr) { ex = mgl_create_expr(expr); } + ~mglExpr() { mgl_delete_expr(ex); } + /// Return value of expression for given x,y,z variables + inline double Eval(double x, double y=0, double z=0) + { return mgl_expr_eval(ex,x,y,z); } + /// Return value of expression differentiation over variable dir for given x,y,z variables + inline double Diff(char dir, double x, double y=0, double z=0) + { return mgl_expr_diff(ex,dir, x,y,z); } +}; +//----------------------------------------------------------------------------- +/// Wrapper class expression evaluating +class mglExprC +{ + HAEX ex; +public: + mglExprC(const char *expr) { ex = mgl_create_cexpr(expr); } + ~mglExprC() { mgl_delete_cexpr(ex); } + /// Return value of expression for given x,y,z variables + inline dual Eval(dual x, dual y=0, dual z=0) + { return mgl_cexpr_eval(ex,x,y,z); } + /// Return value of expression for given x,y,z,u,v,w variables + inline dual Eval(dual x, dual y, dual z, dual u, dual v, dual w) + { + dual var[26]; + var['x'-'a']=x; var['y'-'a']=y; var['z'-'a']=z; + var['u'-'a']=u; var['v'-'a']=v; var['w'-'a']=w; + return mgl_cexpr_eval_v(ex,var); } +}; +//----------------------------------------------------------------------------- diff --git a/lang/numpy.i b/lang/numpy.i new file mode 100644 index 0000000..25d1f1a --- /dev/null +++ b/lang/numpy.i @@ -0,0 +1,1634 @@ +/* -*- C -*- (not really, but good for syntax highlighting) */ +#ifdef SWIGPYTHON + +%{ +#ifndef SWIG_FILE_WITH_INIT +# define NO_IMPORT_ARRAY +#endif +#include "stdio.h" +#include +%} + +/**********************************************************************/ + +%fragment("NumPy_Backward_Compatibility", "header") +{ +/* Support older NumPy data type names +*/ +%#if NDARRAY_VERSION < 0x01000000 +%#define NPY_BOOL PyArray_BOOL +%#define NPY_BYTE PyArray_BYTE +%#define NPY_UBYTE PyArray_UBYTE +%#define NPY_SHORT PyArray_SHORT +%#define NPY_USHORT PyArray_USHORT +%#define NPY_INT PyArray_INT +%#define NPY_UINT PyArray_UINT +%#define NPY_LONG PyArray_LONG +%#define NPY_ULONG PyArray_ULONG +%#define NPY_LONGLONG PyArray_LONGLONG +%#define NPY_ULONGLONG PyArray_ULONGLONG +%#define NPY_FLOAT PyArray_FLOAT +%#define NPY_DOUBLE PyArray_DOUBLE +%#define NPY_LONGDOUBLE PyArray_LONGDOUBLE +%#define NPY_CFLOAT PyArray_CFLOAT +%#define NPY_CDOUBLE PyArray_CDOUBLE +%#define NPY_CLONGDOUBLE PyArray_CLONGDOUBLE +%#define NPY_OBJECT PyArray_OBJECT +%#define NPY_STRING PyArray_STRING +%#define NPY_UNICODE PyArray_UNICODE +%#define NPY_VOID PyArray_VOID +%#define NPY_NTYPES PyArray_NTYPES +%#define NPY_NOTYPE PyArray_NOTYPE +%#define NPY_CHAR PyArray_CHAR +%#define NPY_USERDEF PyArray_USERDEF +%#define npy_intp intp + +%#define NPY_MAX_BYTE MAX_BYTE +%#define NPY_MIN_BYTE MIN_BYTE +%#define NPY_MAX_UBYTE MAX_UBYTE +%#define NPY_MAX_SHORT MAX_SHORT +%#define NPY_MIN_SHORT MIN_SHORT +%#define NPY_MAX_USHORT MAX_USHORT +%#define NPY_MAX_INT MAX_INT +%#define NPY_MIN_INT MIN_INT +%#define NPY_MAX_UINT MAX_UINT +%#define NPY_MAX_LONG MAX_LONG +%#define NPY_MIN_LONG MIN_LONG +%#define NPY_MAX_ULONG MAX_ULONG +%#define NPY_MAX_LONGLONG MAX_LONGLONG +%#define NPY_MIN_LONGLONG MIN_LONGLONG +%#define NPY_MAX_ULONGLONG MAX_ULONGLONG +%#define NPY_MAX_INTP MAX_INTP +%#define NPY_MIN_INTP MIN_INTP + +%#define NPY_FARRAY FARRAY +%#define NPY_F_CONTIGUOUS F_CONTIGUOUS +%#endif +} + +/**********************************************************************/ + +/* The following code originally appeared in + * enthought/kiva/agg/src/numeric.i written by Eric Jones. It was + * translated from C++ to C by John Hunter. Bill Spotz has modified + * it to fix some minor bugs, upgrade from Numeric to numpy (all + * versions), add some comments and functionality, and convert from + * direct code insertion to SWIG fragments. + */ + +%fragment("NumPy_Macros", "header") +{ +/* Macros to extract array attributes. + */ +%#define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) +%#define array_type(a) (int)(PyArray_TYPE(a)) +%#define array_numdims(a) (((PyArrayObject *)a)->nd) +%#define array_dimensions(a) (((PyArrayObject *)a)->dimensions) +%#define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) +%#define array_data(a) (((PyArrayObject *)a)->data) +%#define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) +%#define array_is_native(a) (PyArray_ISNOTSWAPPED(a)) +%#define array_is_fortran(a) (PyArray_ISFORTRAN(a)) +} + +/**********************************************************************/ + +%fragment("NumPy_Utilities", "header") +{ + /* Given a PyObject, return a string describing its type. + */ + char* pytype_string(PyObject* py_obj) { + if (py_obj == NULL ) return "C NULL value"; + if (py_obj == Py_None ) return "Python None" ; + if (PyCallable_Check(py_obj)) return "callable" ; + if (PyString_Check( py_obj)) return "string" ; + if (PyInt_Check( py_obj)) return "int" ; + if (PyFloat_Check( py_obj)) return "float" ; + if (PyDict_Check( py_obj)) return "dict" ; + if (PyList_Check( py_obj)) return "list" ; + if (PyTuple_Check( py_obj)) return "tuple" ; + if (PyFile_Check( py_obj)) return "file" ; + if (PyModule_Check( py_obj)) return "module" ; + if (PyInstance_Check(py_obj)) return "instance" ; + + return "unknow type"; + } + + /* Given a NumPy typecode, return a string describing the type. + */ + char* typecode_string(int typecode) { + static char* type_names[25] = {"bool", "byte", "unsigned byte", + "short", "unsigned short", "int", + "unsigned int", "long", "unsigned long", + "long long", "unsigned long long", + "float", "double", "long double", + "complex float", "complex double", + "complex long double", "object", + "string", "unicode", "void", "ntypes", + "notype", "char", "unknown"}; + return typecode < 24 ? type_names[typecode] : type_names[24]; + } + + /* Make sure input has correct numpy type. Allow character and byte + * to match. Also allow int and long to match. This is deprecated. + * You should use PyArray_EquivTypenums() instead. + */ + int type_match(int actual_type, int desired_type) { + return PyArray_EquivTypenums(actual_type, desired_type); + } +} + +/**********************************************************************/ + +%fragment("NumPy_Object_to_Array", "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities") +{ + /* Given a PyObject pointer, cast it to a PyArrayObject pointer if + * legal. If not, set the python error string appropriately and + * return NULL. + */ + PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) + { + PyArrayObject* ary = NULL; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input), typecode))) + { + ary = (PyArrayObject*) input; + } + else if is_array(input) + { + char* desired_type = typecode_string(typecode); + char* actual_type = typecode_string(array_type(input)); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. Array of type '%s' given", + desired_type, actual_type); + ary = NULL; + } + else + { + char * desired_type = typecode_string(typecode); + char * actual_type = pytype_string(input); + PyErr_Format(PyExc_TypeError, + "Array of type '%s' required. A '%s' was given", + desired_type, actual_type); + ary = NULL; + } + return ary; + } + + /* Convert the given PyObject to a NumPy array with the given + * typecode. On success, return a valid PyArrayObject* with the + * correct type. On failure, the python error string will be set and + * the routine returns NULL. + */ + PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, + int* is_new_object) + { + PyArrayObject* ary = NULL; + PyObject* py_obj; + if (is_array(input) && (typecode == NPY_NOTYPE || + PyArray_EquivTypenums(array_type(input),typecode))) + { + ary = (PyArrayObject*) input; + *is_new_object = 0; + } + else + { + py_obj = PyArray_FROMANY(input, typecode, 0, 0, NPY_DEFAULT); + /* If NULL, PyArray_FromObject will have set python error value.*/ + ary = (PyArrayObject*) py_obj; + *is_new_object = 1; + } + return ary; + } + + /* Given a PyArrayObject, check to see if it is contiguous. If so, + * return the input pointer and flag it as not a new object. If it is + * not contiguous, create a new PyArrayObject using the original data, + * flag it as a new object and return the pointer. + */ + PyArrayObject* make_contiguous(PyArrayObject* ary, int* is_new_object, + int min_dims, int max_dims) + { + PyArrayObject* result; + if (array_is_contiguous(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + result = (PyArrayObject*) PyArray_ContiguousFromObject((PyObject*)ary, + array_type(ary), + min_dims, + max_dims); + *is_new_object = 1; + } + return result; + } + + /* Given a PyArrayObject, check to see if it is Fortran-contiguous. + * If so, return the input pointer, but do not flag it as not a new + * object. If it is not Fortran-contiguous, create a new + * PyArrayObject using the original data, flag it as a new object + * and return the pointer. + */ + PyArrayObject* make_fortran(PyArrayObject* ary, int* is_new_object, + int min_dims, int max_dims) + { + PyArrayObject* result; + if (array_is_fortran(ary)) + { + result = ary; + *is_new_object = 0; + } + else + { + Py_INCREF(ary->descr); + result = (PyArrayObject*) PyArray_FromArray(ary, ary->descr, NPY_FORTRAN); + *is_new_object = 1; + } + return result; + } + + /* Convert a given PyObject to a contiguous PyArrayObject of the + * specified type. If the input object is not a contiguous + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, + &is_new1); + if (ary1) + { + ary2 = make_contiguous(ary1, &is_new2, 0, 0); + if ( is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } + + /* Convert a given PyObject to a Fortran-ordered PyArrayObject of the + * specified type. If the input object is not a Fortran-ordered + * PyArrayObject, a new one will be created and the new object flag + * will be set. + */ + PyArrayObject* obj_to_array_fortran_allow_conversion(PyObject* input, + int typecode, + int* is_new_object) + { + int is_new1 = 0; + int is_new2 = 0; + PyArrayObject* ary2; + PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, + &is_new1); + if (ary1) + { + ary2 = make_fortran(ary1, &is_new2, 0, 0); + if (is_new1 && is_new2) + { + Py_DECREF(ary1); + } + ary1 = ary2; + } + *is_new_object = is_new1 || is_new2; + return ary1; + } + +} /* end fragment */ + + +/**********************************************************************/ + +%fragment("NumPy_Array_Requirements", "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros") +{ + /* Test whether a python object is contiguous. If array is + * contiguous, return 1. Otherwise, set the python error string and + * return 0. + */ + int require_contiguous(PyArrayObject* ary) + { + int contiguous = 1; + if (!array_is_contiguous(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must be contiguous. A non-contiguous array was given"); + contiguous = 0; + } + return contiguous; + } + + /* Require that a numpy array is not byte-swapped. If the array is + * not byte-swapped, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_native(PyArrayObject* ary) + { + int native = 1; + if (!array_is_native(ary)) + { + PyErr_SetString(PyExc_TypeError, + "Array must have native byteorder. " + "A byte-swapped array was given"); + native = 0; + } + return native; + } + + /* Require the given PyArrayObject to have a specified number of + * dimensions. If the array has the specified number of dimensions, + * return 1. Otherwise, set the python error string and return 0. + */ + int require_dimensions(PyArrayObject* ary, int exact_dimensions) + { + int success = 1; + if (array_numdims(ary) != exact_dimensions) + { + PyErr_Format(PyExc_TypeError, + "Array must have %d dimensions. Given array has %d dimensions", + exact_dimensions, array_numdims(ary)); + success = 0; + } + return success; + } + + /* Require the given PyArrayObject to have one of a list of specified + * number of dimensions. If the array has one of the specified number + * of dimensions, return 1. Otherwise, set the python error string + * and return 0. + */ + int require_dimensions_n(PyArrayObject* ary, int* exact_dimensions, int n) + { + int success = 0; + int i; + char dims_str[255] = ""; + char s[255]; + for (i = 0; i < n && !success; i++) + { + if (array_numdims(ary) == exact_dimensions[i]) + { + success = 1; + } + } + if (!success) + { + for (i = 0; i < n-1; i++) + { + sprintf(s, "%d, ", exact_dimensions[i]); + strcat(dims_str,s); + } + sprintf(s, " or %d", exact_dimensions[n-1]); + strcat(dims_str,s); + PyErr_Format(PyExc_TypeError, + "Array must have %s dimensions. Given array has %d dimensions", + dims_str, array_numdims(ary)); + } + return success; + } + + /* Require the given PyArrayObject to have a specified shape. If the + * array has the specified shape, return 1. Otherwise, set the python + * error string and return 0. + */ + int require_size(PyArrayObject* ary, npy_intp* size, int n) + { + int i; + int success = 1; + int len; + char desired_dims[255] = "["; + char s[255]; + char actual_dims[255] = "["; + for(i=0; i < n;i++) + { + if (size[i] != -1 && size[i] != array_size(ary,i)) + { + success = 0; + } + } + if (!success) + { + for (i = 0; i < n; i++) + { + if (size[i] == -1) + { + sprintf(s, "*,"); + } + else + { + sprintf(s, "%ld,", (long int)size[i]); + } + strcat(desired_dims,s); + } + len = strlen(desired_dims); + desired_dims[len-1] = ']'; + for (i = 0; i < n; i++) + { + sprintf(s, "%ld,", (long int)array_size(ary,i)); + strcat(actual_dims,s); + } + len = strlen(actual_dims); + actual_dims[len-1] = ']'; + PyErr_Format(PyExc_TypeError, + "Array must have shape of %s. Given array has shape of %s", + desired_dims, actual_dims); + } + return success; + } + + /* Require the given PyArrayObject to to be FORTRAN ordered. If the + * the PyArrayObject is already FORTRAN ordered, do nothing. Else, + * set the FORTRAN ordering flag and recompute the strides. + */ + int require_fortran(PyArrayObject* ary) + { + int success = 1; + int nd = array_numdims(ary); + int i; + if (array_is_fortran(ary)) return success; + /* Set the FORTRAN ordered flag */ + ary->flags = NPY_FARRAY; + /* Recompute the strides */ + ary->strides[0] = ary->strides[nd-1]; + for (i=1; i < nd; ++i) + ary->strides[i] = ary->strides[i-1] * array_size(ary,i-1); + return success; + } +} + +/* Combine all NumPy fragments into one for convenience */ +%fragment("NumPy_Fragments", "header", + fragment="NumPy_Backward_Compatibility", + fragment="NumPy_Macros", + fragment="NumPy_Utilities", + fragment="NumPy_Object_to_Array", + fragment="NumPy_Array_Requirements") { } + +/* End John Hunter translation (with modifications by Bill Spotz) + */ + +/* %numpy_typemaps() macro + * + * This macro defines a family of 41 typemaps that allow C arguments + * of the form + * + * (DATA_TYPE IN_ARRAY1[ANY]) + * (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + * (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + * + * (DATA_TYPE IN_ARRAY2[ANY][ANY]) + * (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + * (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + * + * (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + * (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + * (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + * + * (DATA_TYPE INPLACE_ARRAY1[ANY]) + * (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + * (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + * + * (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + * (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + * (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + * + * (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + * (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + * (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + * (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + * + * (DATA_TYPE ARGOUT_ARRAY1[ANY]) + * (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + * (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + * + * (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + * + * (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + * + * (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + * (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + * + * (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + * (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + * + * (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + * (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + * (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) + * + * where "DATA_TYPE" is any type supported by the NumPy module, and + * "DIM_TYPE" is any int-like type suitable for specifying dimensions. + * The difference between "ARRAY" typemaps and "FARRAY" typemaps is + * that the "FARRAY" typemaps expect FORTRAN ordering of + * multidimensional arrays. In python, the dimensions will not need + * to be specified (except for the "DATA_TYPE* ARGOUT_ARRAY1" + * typemaps). The IN_ARRAYs can be a numpy array or any sequence that + * can be converted to a numpy array of the specified type. The + * INPLACE_ARRAYs must be numpy arrays of the appropriate type. The + * ARGOUT_ARRAYs will be returned as new numpy arrays of the + * appropriate type. + * + * These typemaps can be applied to existing functions using the + * %apply directive. For example: + * + * %apply (double* IN_ARRAY1, int DIM1) {(double* series, int length)}; + * double prod(double* series, int length); + * + * %apply (int DIM1, int DIM2, double* INPLACE_ARRAY2) + * {(int rows, int cols, double* matrix )}; + * void floor(int rows, int cols, double* matrix, double f); + * + * %apply (double IN_ARRAY3[ANY][ANY][ANY]) + * {(double tensor[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double low[2][2][2] )}; + * %apply (double ARGOUT_ARRAY3[ANY][ANY][ANY]) + * {(double upp[2][2][2] )}; + * void luSplit(double tensor[2][2][2], + * double low[2][2][2], + * double upp[2][2][2] ); + * + * or directly with + * + * double prod(double* IN_ARRAY1, int DIM1); + * + * void floor(int DIM1, int DIM2, double* INPLACE_ARRAY2, double f); + * + * void luSplit(double IN_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY], + * double ARGOUT_ARRAY3[ANY][ANY][ANY]); + */ + +%define %numpy_typemaps(DATA_TYPE, DATA_TYPECODE, DIM_TYPE) + +/************************/ +/* Input Array Typemaps */ +/************************/ + +/* Typemap suite for (DATA_TYPE IN_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY1[ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY1[ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY1[ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = { -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[1] = {-1}; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 1) || + !require_size(array, size, 1)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY2[ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[2] = { -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 2) || + !require_size(array, size, 2) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_FARRAY2) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(freearg) + (DATA_TYPE IN_ARRAY3[ANY][ANY][ANY]) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_ARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_fortran_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) | !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} +%typemap(freearg) + (DATA_TYPE* IN_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* IN_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + $1 = is_array($input) || PySequence_Check($input); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) + (PyArrayObject* array=NULL, int is_new_object=0) +{ + npy_intp size[3] = { -1, -1, -1 }; + array = obj_to_array_contiguous_allow_conversion($input, DATA_TYPECODE, + &is_new_object); + if (!array || !require_dimensions(array, 3) || + !require_size(array, size, 3) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} +%typemap(freearg) + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* IN_FARRAY3) +{ + if (is_new_object$argnum && array$argnum) + { Py_DECREF(array$argnum); } +} + +/***************************/ +/* In-Place Array Typemaps */ +/***************************/ + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY1[ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY1[ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[1] = { $1_dim0 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_size(array, size, 1) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1) + (PyArrayObject* array=NULL, int i=1) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = 1; + for (i=0; i < array_numdims(array); ++i) $2 *= array_size(array,i); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1) + (PyArrayObject* array=NULL, int i=0) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,1) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = 1; + for (i=0; i < array_numdims(array); ++i) $1 *= array_size(array,i); + $2 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY2[ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[2] = { $1_dim0, $1_dim1 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_size(array, size, 2) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_FARRAY2) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,2) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE INPLACE_ARRAY3[ANY][ANY][ANY]) + (PyArrayObject* array=NULL) +{ + npy_intp size[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_size(array, size, 3) || + !require_contiguous(array) || !require_native(array)) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_ARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_ARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_ARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/* Typemap suite for (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, + * DIM_TYPE DIM3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DATA_TYPE* INPLACE_FARRAY3, DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) || + !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); + $2 = (DIM_TYPE) array_size(array,0); + $3 = (DIM_TYPE) array_size(array,1); + $4 = (DIM_TYPE) array_size(array,2); +} + +/* Typemap suite for (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, + * DATA_TYPE* INPLACE_FARRAY3) + */ +%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY, + fragment="NumPy_Macros") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) +{ + $1 = is_array($input) && PyArray_EquivTypenums(array_type($input), + DATA_TYPECODE); +} +%typemap(in, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DIM_TYPE DIM2, DIM_TYPE DIM3, DATA_TYPE* INPLACE_FARRAY3) + (PyArrayObject* array=NULL) +{ + array = obj_to_array_no_conversion($input, DATA_TYPECODE); + if (!array || !require_dimensions(array,3) || !require_contiguous(array) + || !require_native(array) || !require_fortran(array)) SWIG_fail; + $1 = (DIM_TYPE) array_size(array,0); + $2 = (DIM_TYPE) array_size(array,1); + $3 = (DIM_TYPE) array_size(array,2); + $4 = (DATA_TYPE*) array_data(array); +} + +/*************************/ +/* Argout Array Typemaps */ +/*************************/ + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY1[ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY1[ANY]) + (PyObject * array = NULL) +{ + npy_intp dims[1] = { $1_dim0 }; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY1[ANY]) +{ + $result = SWIG_Python_AppendOutput($result,array$argnum); +} + +/* Typemap suite for (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) + (PyObject * array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $2 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $2; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DATA_TYPE* ARGOUT_ARRAY1, DIM_TYPE DIM1) +{ + $result = SWIG_Python_AppendOutput($result,array$argnum); +} + +/* Typemap suite for (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + */ +%typemap(in,numinputs=1, + fragment="NumPy_Fragments") + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) + (PyObject * array = NULL) +{ + npy_intp dims[1]; + if (!PyInt_Check($input)) + { + char* typestring = pytype_string($input); + PyErr_Format(PyExc_TypeError, + "Int dimension expected. '%s' given.", + typestring); + SWIG_fail; + } + $1 = (DIM_TYPE) PyInt_AsLong($input); + dims[0] = (npy_intp) $1; + array = PyArray_SimpleNew(1, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $2 = (DATA_TYPE*) array_data(array); +} +%typemap(argout) + (DIM_TYPE DIM1, DATA_TYPE* ARGOUT_ARRAY1) +{ + $result = SWIG_Python_AppendOutput($result,array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) + (PyObject * array = NULL) +{ + npy_intp dims[2] = { $1_dim0, $1_dim1 }; + array = PyArray_SimpleNew(2, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,array$argnum); +} + +/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + */ +%typemap(in,numinputs=0, + fragment="NumPy_Backward_Compatibility,NumPy_Macros") + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) + (PyObject * array = NULL) +{ + npy_intp dims[3] = { $1_dim0, $1_dim1, $1_dim2 }; + array = PyArray_SimpleNew(3, dims, DATA_TYPECODE); + if (!array) SWIG_fail; + $1 = ($1_ltype) array_data(array); +} +%typemap(argout) + (DATA_TYPE ARGOUT_ARRAY3[ANY][ANY][ANY]) +{ + $result = SWIG_Python_AppendOutput($result,array$argnum); +} + +/*****************************/ +/* Argoutview Array Typemaps */ +/*****************************/ + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1 ) + (DATA_TYPE* data_temp , DIM_TYPE dim_temp) +{ + $1 = &data_temp; + $2 = &dim_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY1, DIM_TYPE* DIM1) +{ + npy_intp dims[1] = { *$2 }; + PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$1)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DATA_TYPE** ARGOUTVIEW_ARRAY1) + (DIM_TYPE dim_temp, DATA_TYPE* data_temp ) +{ + $1 = &dim_temp; + $2 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DATA_TYPE** ARGOUTVIEW_ARRAY1) +{ + npy_intp dims[1] = { *$1 }; + PyObject * array = PyArray_SimpleNewFromData(1, dims, DATA_TYPECODE, (void*)(*$2)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_ARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_ARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject * array = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1 , DIM_TYPE* DIM2 ) + (DATA_TYPE* data_temp , DIM_TYPE dim1_temp, DIM_TYPE dim2_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY2, DIM_TYPE* DIM1, DIM_TYPE* DIM2) +{ + npy_intp dims[2] = { *$2, *$3 }; + PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject * array = (PyArrayObject*) obj; + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1 , DIM_TYPE* DIM2 , DATA_TYPE** ARGOUTVIEW_FARRAY2) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DATA_TYPE* data_temp ) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DATA_TYPE** ARGOUTVIEW_FARRAY2) +{ + npy_intp dims[2] = { *$1, *$2 }; + PyObject * obj = PyArray_SimpleNewFromData(2, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject * array = (PyArrayObject*) obj; + if (!array || !require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DATA_TYPE** ARGOUTVIEW_ARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_ARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_ARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject * array = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3)); + if (!array) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,array); +} + +/* Typemap suite for (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, + DIM_TYPE* DIM3) + */ +%typemap(in,numinputs=0) + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) + (DATA_TYPE* data_temp, DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp) +{ + $1 = &data_temp; + $2 = &dim1_temp; + $3 = &dim2_temp; + $4 = &dim3_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DATA_TYPE** ARGOUTVIEW_FARRAY3, DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3) +{ + npy_intp dims[3] = { *$2, *$3, *$4 }; + PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$1)); + PyArrayObject * array = (PyArrayObject*) obj; + if (!array || require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +/* Typemap suite for (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, + DATA_TYPE** ARGOUTVIEW_FARRAY3) + */ +%typemap(in,numinputs=0) + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) + (DIM_TYPE dim1_temp, DIM_TYPE dim2_temp, DIM_TYPE dim3_temp, DATA_TYPE* data_temp) +{ + $1 = &dim1_temp; + $2 = &dim2_temp; + $3 = &dim3_temp; + $4 = &data_temp; +} +%typemap(argout, + fragment="NumPy_Backward_Compatibility,NumPy_Array_Requirements") + (DIM_TYPE* DIM1, DIM_TYPE* DIM2, DIM_TYPE* DIM3, DATA_TYPE** ARGOUTVIEW_FARRAY3) +{ + npy_intp dims[3] = { *$1, *$2, *$3 }; + PyObject * obj = PyArray_SimpleNewFromData(3, dims, DATA_TYPECODE, (void*)(*$3)); + PyArrayObject * array = (PyArrayObject*) obj; + if (!array || require_fortran(array)) SWIG_fail; + $result = SWIG_Python_AppendOutput($result,obj); +} + +%enddef /* %numpy_typemaps() macro */ +/* *************************************************************** */ + +/* Concrete instances of the %numpy_typemaps() macro: Each invocation + * below applies all of the typemaps above to the specified data type. + */ +%numpy_typemaps(signed char , NPY_BYTE , int) +%numpy_typemaps(unsigned char , NPY_UBYTE , int) +%numpy_typemaps(short , NPY_SHORT , int) +%numpy_typemaps(unsigned short , NPY_USHORT , int) +%numpy_typemaps(int , NPY_INT , int) +%numpy_typemaps(unsigned int , NPY_UINT , int) +%numpy_typemaps(long , NPY_LONG , int) +%numpy_typemaps(unsigned long , NPY_ULONG , int) +%numpy_typemaps(long long , NPY_LONGLONG , int) +%numpy_typemaps(unsigned long long, NPY_ULONGLONG, int) +%numpy_typemaps(float , NPY_FLOAT , int) +%numpy_typemaps(double , NPY_DOUBLE , int) + +/* *************************************************************** + * The follow macro expansion does not work, because C++ bool is 4 + * bytes and NPY_BOOL is 1 byte + * + * %numpy_typemaps(bool, NPY_BOOL, int) + */ + +/* *************************************************************** + * On my Mac, I get the following warning for this macro expansion: + * 'swig/python detected a memory leak of type 'long double *', no destructor found.' + * + * %numpy_typemaps(long double, NPY_LONGDOUBLE, int) + */ + +/* *************************************************************** + * Swig complains about a syntax error for the following macro + * expansions: + * + * %numpy_typemaps(complex float, NPY_CFLOAT , int) + * + * %numpy_typemaps(complex double, NPY_CDOUBLE, int) + * + * %numpy_typemaps(complex long double, NPY_CLONGDOUBLE, int) + */ + +#endif /* SWIGPYTHON */ diff --git a/lang/sed_rules b/lang/sed_rules new file mode 100644 index 0000000..8ee5fb6 --- /dev/null +++ b/lang/sed_rules @@ -0,0 +1,13 @@ +1,19d +s/MGL_EXPORT//g +s/mglDataA/mglData/g +/SWIG/,/endif/ { s/.*//g } +s/^.*---.*$//g +s/^#include.*$//g +s/^#define.*$//g +s/^.*public mglData$//g +s/^#ifndef _MGL_DATA_H_.*$//g +s/^#ifndef _MGL_H_.*$//g +s/^#ifdef __cplusplus.*$//g +/^\s*$/d +N;$!P;$!D;$d diff --git a/lang/type.i b/lang/type.i new file mode 100644 index 0000000..133642a --- /dev/null +++ b/lang/type.i @@ -0,0 +1,99 @@ +/*************************************************************************** + * type.i is part of Math Graphic Library + * Copyright (C) 2007-2012 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/config.h" +#if MGL_USE_DOUBLE +typedef double mreal; +#else +typedef float mreal; +#endif +//----------------------------------------------------------------------------- +const mreal Pi = M_PI; +const mreal NaN = NAN; +const mreal mgl_min_a = 1./256; +//----------------------------------------------------------------------------- +/// Class for point in 3D space +struct mglPoint +{ + mreal x,y,z,c; + mglPoint(mreal X=0,mreal Y=0,mreal Z=0,mreal C=0){x=X;y=Y;z=Z;c=C;} + inline bool IsNAN() { return (x!=x || y!=y || z!=z || c!=c); } + inline mreal val(int i) { return (i<2 ? (i==0 ? x:y) : (i==2 ? z:c)); } + inline mreal norm() { return sqrt(x*x+y*y+z*z); } + inline void Normalize() { mreal v=norm(); x/=v; y/=v; z/=v; } + + inline void operator+=(const mglPoint &a) { x+=a.x; y+=a.y; z+=a.z; c+=a.c; } + inline void operator-=(const mglPoint &a) { x-=a.x; y-=a.y; z-=a.z; c-=a.c; } + inline void operator+=(mreal a) { x+=a; y+=a; z+=a; } + inline void operator-=(mreal a) { x-=a; y-=a; z-=a; } + inline void operator*=(mreal a) { x*=a; y*=a; z*=a; } + inline void operator/=(mreal a) { x/=a; y/=a; z/=a; } +}; +//----------------------------------------------------------------------------- +/// Class for RGBA color +struct mglColor +{ + float r; ///< Red component of color + float g; ///< Green component of color + float b; ///< Blue component of color + float a; ///< Alpha component of color + + /// Constructor for RGB components manualy + mglColor(float R,float G,float B, float A=1){ r=R; g=G; b=B; a=A; } + /// Constructor set default color + mglColor() { r=g=b=0; a=1; } + /// Constructor set color from character id + mglColor(char c, float bright=1) { Set(c,bright); } + /// Set color as Red, Green, Blue values + void Set(float R,float G,float B,float A=1) { r=R; g=G; b=B; a=A; } + /// Set color as Red, Green, Blue values + void Set(mglColor c, float bright=1) + { + if(bright<0) bright=0; if(bright>2.f) bright=2.f; + r = bright<=1 ? c.r*bright : 1 - (1-c.r)*(2-bright); + g = bright<=1 ? c.g*bright : 1 - (1-c.g)*(2-bright); + b = bright<=1 ? c.b*bright : 1 - (1-c.b)*(2-bright); a = 1; + } + /// Check if color is valid + inline bool Valid() + { return (r>=0 && r<=1 && g>=0 && g<=1 && b>=0 && b<=1 && a>=0 && a<=1); } + /// Get maximal spectral component + inline float Norm() + { return r>g ? r : (g>b ? g : b); } + inline float NormS() + { return r*r+g*g+b*b; } + /// Set color from symbolic id + inline void Set(char p, float bright=1) + { + float rgb[3]; mgl_chrrgb(p,rgb); + Set(mglColor(rgb[0],rgb[1],rgb[2]),bright); + } + /// Copy color from other one + inline bool operator==(const mglColor &c) const + { return !memcmp(this, &c, sizeof(mglColor)); } + inline bool operator!=(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor)); } + inline bool operator<(const mglColor &c) const + { return memcmp(this, &c, sizeof(mglColor))<0; } + // transparency still the same + inline void operator*=(float v) { r*=v; g*=v; b*=v; a*=v; } + inline void operator+=(const mglColor &c) { r+=c.r; g+=c.g; b+=c.b; a+=c.a; } + inline void operator-=(const mglColor &c) { r-=c.r; g-=c.g; b-=c.b; a-=c.a; } +}; +//----------------------------------------------------------------------------- diff --git a/mathgl-2x.cbp b/mathgl-2x.cbp new file mode 100644 index 0000000..40ea8f6 --- /dev/null +++ b/mathgl-2x.cbp @@ -0,0 +1,129 @@ + + + + + + diff --git a/mgllab/CMakeLists.txt b/mgllab/CMakeLists.txt new file mode 100644 index 0000000..f64ad22 --- /dev/null +++ b/mgllab/CMakeLists.txt @@ -0,0 +1,10 @@ +if(MGL_HAVE_FLTK) + include_directories(${FLTK_INCLUDE_DIR}) + set(mgl_lab_src animate.cpp editor.cpp help.cpp mathgl.cpp setup.cpp write.cpp data.cpp grid.cpp main.cpp option.cpp table.cpp) + add_executable(mgllab ${mgl_lab_src}) + target_link_libraries(mgllab mgl mgl-fltk ${FLTK_LIBRARIES}) + install( + TARGETS mgllab + RUNTIME DESTINATION bin ) +endif(MGL_HAVE_FLTK) + diff --git a/mgllab/animate.cpp b/mgllab/animate.cpp new file mode 100644 index 0000000..c6de245 --- /dev/null +++ b/mgllab/animate.cpp @@ -0,0 +1,314 @@ +/* animate.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +struct ArgumentDlg +{ +public: + Fl_Window* wnd; + int OK; + Fl_Input *a[10]; + + ArgumentDlg() { memset(this,0,sizeof(ArgumentDlg)); create_dlg(); } + ~ArgumentDlg() { delete wnd; } + void FillResult(); +protected: + void create_dlg(); +} argument_dlg; +//----------------------------------------------------------------------------- +void argument_dlg_cb(Fl_Widget *, void *v) +{ argument_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void ArgumentDlg::create_dlg() +{ + wnd = new Fl_Window(325, 275, gettext("Script arguments")); + a[1] = new Fl_Input(10, 25, 150, 25, gettext("Value for $1")); a[1]->align(FL_ALIGN_TOP_LEFT); + a[2] = new Fl_Input(165, 25, 150, 25, gettext("Value for $2")); a[2]->align(FL_ALIGN_TOP_LEFT); + a[3] = new Fl_Input(10, 70, 150, 25, gettext("Value for $3")); a[3]->align(FL_ALIGN_TOP_LEFT); + a[4] = new Fl_Input(165, 70, 150, 25, gettext("Value for $4")); a[4]->align(FL_ALIGN_TOP_LEFT); + a[5] = new Fl_Input(10, 115, 150, 25, gettext("Value for $5")); a[5]->align(FL_ALIGN_TOP_LEFT); + a[6] = new Fl_Input(165, 115, 150, 25, gettext("Value for $6"));a[6]->align(FL_ALIGN_TOP_LEFT); + a[7] = new Fl_Input(10, 160, 150, 25, gettext("Value for $7")); a[7]->align(FL_ALIGN_TOP_LEFT); + a[8] = new Fl_Input(165, 160, 150, 25, gettext("Value for $8"));a[8]->align(FL_ALIGN_TOP_LEFT); + a[9] = new Fl_Input(10, 205, 150, 25, gettext("Value for $9")); a[9]->align(FL_ALIGN_TOP_LEFT); + a[0] = new Fl_Input(165, 205, 150, 25, gettext("Value for $0"));a[0]->align(FL_ALIGN_TOP_LEFT); + + Fl_Button *o; + o = new Fl_Button(75, 240, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(175, 240, 75, 25, gettext("OK")); o->callback(argument_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +void ArgumentDlg::FillResult() +{ + if(a[0]->value()[0]) Parse->AddParam(0,a[0]->value()); + if(a[1]->value()[0]) Parse->AddParam(1,a[1]->value()); + if(a[2]->value()[0]) Parse->AddParam(2,a[2]->value()); + if(a[3]->value()[0]) Parse->AddParam(3,a[3]->value()); + if(a[4]->value()[0]) Parse->AddParam(4,a[4]->value()); + if(a[5]->value()[0]) Parse->AddParam(5,a[5]->value()); + if(a[6]->value()[0]) Parse->AddParam(6,a[6]->value()); + if(a[7]->value()[0]) Parse->AddParam(7,a[7]->value()); + if(a[8]->value()[0]) Parse->AddParam(8,a[8]->value()); + if(a[9]->value()[0]) Parse->AddParam(9,a[9]->value()); +} +//----------------------------------------------------------------------------- +void argument_cb(Fl_Widget *, void *) +{ + ArgumentDlg *s = &argument_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) s->FillResult(); +} +//----------------------------------------------------------------------------- +void argument_set(int n, const char *s) +{ + if(n<0 || n>9) return; + Parse->AddParam(n,s); + argument_dlg.a[n]->value(s); +} +//----------------------------------------------------------------------------- +AnimateDlg animate_dlg; +//----------------------------------------------------------------------------- +void animate_dlg_cb(Fl_Widget *, void *v) +{ + animate_dlg.swap = false; + if(!animate_dlg.rt->value() && !animate_dlg.rv->value()) + fl_message(gettext("You have to select textual string or numeric cycle")); + else if(animate_dlg.rv->value() && animate_dlg.dx->value()==0) + fl_message(gettext("You have to set nonzero step in cycle")); + else + { + double t0=atof(animate_dlg.x0->value()), t1=atof(animate_dlg.x1->value()), dt=atof(animate_dlg.dx->value()); + if((t1-t0)*dt<0) + { + if(fl_ask(gettext("Order of first and last value is wrong. Swap it?"))) + { + char s[32]; snprintf(s,32,"%g",t0); + animate_dlg.x0->value(animate_dlg.x1->value()); + animate_dlg.x1->value(s); + } + else + { fl_message(gettext("Wrong boundaries")); return; } + } + animate_dlg.OK = true; ((Fl_Window *)v)->hide(); + } +} +//----------------------------------------------------------------------------- +void animate_rad_cb(Fl_Widget *, void *v) +{ + animate_dlg.rt->value(0); + animate_dlg.rv->value(0); + ((Fl_Round_Button *)v)->value(1); +} +//----------------------------------------------------------------------------- +void animate_put_cb(Fl_Widget *, void *) +{ + if(animate_dlg.rt->value()) + { + if(animate_dlg.txt->value()==0 || strlen(animate_dlg.txt->value())==0) return; + char *s = new char[1+strlen(animate_dlg.txt->value())], *a=s; + strcpy(s, animate_dlg.txt->value()); + for(int i=0;s[i]!=0;i++) + { + if(s[i]=='\n') + { + s[i] = 0; + textbuf->append("\n##a "); + textbuf->append(a); + a = s+i+1; + } + } + if(*a) + { textbuf->append("\n##a "); textbuf->append(a); } + delete []s; + } + else if(animate_dlg.rv->value()) + { + char *s = new char[128]; + snprintf(s,128,"\n##c %s %s %s",animate_dlg.x0->value(),animate_dlg.x1->value(),animate_dlg.dx->value()); + textbuf->append(s); + delete []s; + } +} +//----------------------------------------------------------------------------- +void AnimateDlg::create_dlg() +{ + wnd = new Fl_Window(335, 350, gettext("Animation")); + new Fl_Box(10, 5, 315, 25, gettext("Redraw picture for $0 equal to:")); + rt = new Fl_Round_Button(10, 30, 200, 25, gettext("strings in lines below")); + rt->callback(animate_rad_cb, rt); + rv = new Fl_Round_Button(220, 30, 105, 25, gettext("values")); + rv->callback(animate_rad_cb, rv); + txt = new Fl_Multiline_Input(10, 60, 200, 250); + x0 = new Fl_Float_Input(220, 80, 105, 25, gettext("from")); x0->align(FL_ALIGN_TOP_LEFT); + x1 = new Fl_Float_Input(220, 130, 105, 25, gettext("to")); x1->align(FL_ALIGN_TOP_LEFT); + dx = new Fl_Float_Input(220, 180, 105, 25, gettext("with step")); dx->align(FL_ALIGN_TOP_LEFT); + + Fl_Button *o; + o = new Fl_Button(230, 215, 80, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(230, 250, 80, 25, gettext("OK")); o->callback(animate_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + save = new Fl_Check_Button(220, 285, 105, 25, gettext("save slides")); + save->tooltip(gettext("Keep slides in memory (faster animation but require more memory)")); + save->down_box(FL_DOWN_BOX); save->hide(); + + o = new Fl_Button(10, 315, 100, 25, gettext("Put to script")); o->callback(animate_put_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + dt = new Fl_Float_Input(220, 315, 105, 25, gettext("Delay (in sec)"));// dx->align(FL_ALIGN_TOP_LEFT); + + wnd->end(); +} +//----------------------------------------------------------------------------- +void AnimateDlg::FillResult(Fl_MGL* e) +{ + e->NArgs = e->ArgCur = 0; + if(e->ArgBuf) delete [](e->ArgBuf); e->ArgBuf = 0; + e->AnimDelay = atof(dt->value()); + if(rt->value()) + { + char *s; + e->ArgBuf = new char[1+strlen(txt->value())]; + strncpy(e->ArgBuf, txt->value(),32); + s = e->Args[0] = e->ArgBuf; e->NArgs = 1; + for(int i=0;s[i]!=0;i++) + if(s[i]=='\n') + { + s[i] = 0; e->Args[e->NArgs] = s+i+1; e->NArgs += 1; + } + if(e->Args[e->NArgs-1][0]==0) e->NArgs -= 1; + } + else if(rv->value() && atof(dx->value())) + { + double t0=atof(x0->value()), t1=atof(x1->value()), dt=atof(dx->value()), t; + if((t1-t0)/dt<1) + { + e->ArgBuf = new char[32]; snprintf(e->ArgBuf,32,"%g",t0); + e->NArgs = 1; e->Args[0] = e->ArgBuf; return; + } + if((t1-t0)/dt>999) + { + fl_message(gettext("Too many slides. Reduce to 1000 slides.")); + dt = (t1-t0)/998; + } + e->ArgBuf = new char[32*int(1+(t1-t0)/dt)]; + for(t=t0;(dt>0&&t<=t1)||(dt<0&&t>=t1);t+=dt) + { + snprintf(e->ArgBuf + 32*e->NArgs,32,"%g\0",t); + e->Args[e->NArgs] = e->ArgBuf + 32*e->NArgs; + e->NArgs += 1; + } + } + else fl_message(gettext("No selection. So nothing to do")); +} +//----------------------------------------------------------------------------- +void animate_cb(Fl_Widget *, void *v) +{ + ScriptWindow* e = (ScriptWindow*)v; + AnimateDlg *s = &animate_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) s->FillResult(e->graph); +} +//----------------------------------------------------------------------------- +void cpy_arg_buf(const char *str, long *size, char **buf) +{ + const char *end; + for(end=str; *end>' '; end++); + if(end>=str+*size) + { *size = end-str+1; *buf = (char *)realloc(*buf,*size); } + memset(*buf,0,*size); + strncpy(*buf,str,end-str); +} +//----------------------------------------------------------------------------- +void fill_animate(const char *text) +{ + long size=128,i; + const char *str = text; + char *buf = (char *)malloc(size), tmp[4]="#$0"; + for(i=0;i<10;i++) // first read script arguments (if one) + { + tmp[2] = '0'+i; + if((str=strstr(text,tmp))) + { + str+=3; + while(*str>0 && *str<=' ' && *str!='\n') str++; + cpy_arg_buf(str,&size,&buf); + argument_dlg.a[i]->value(buf); + Parse->AddParam(i,buf); + } + } + + char *a = (char *)malloc(size); + memset(a,0,size); i = 0; + str = text; + while((str = strstr(str, "##"))) // now read animation parameters + { + if(str[2]=='a') + { + str += 3; + while(*str>0 && *str<=' ' && *str!='\n') str++; + if(*str==0 || *str=='\n') return; // empty comment + cpy_arg_buf(str,&size,&buf); + if(i==0) Parse->AddParam(0,buf); // put first value as $0 + i += strlen(buf)+1; + if(i>=size) + { + size = (1+ (i+2)/128)*128; + a = (char *)realloc(a,size); + } + strcat(a,buf); strcat(a,"\n"); + } + if(str[2]=='c') + { + str += 3; + register long j=0,l=strlen(str); + char *s=new char[l+1],*s1=0,*s2=0,*s3=0; + bool sp=true; strcpy(s,str); + for(j=0;jvalue(s1); + animate_dlg.x1->value(s2); + animate_dlg.dx->value(s3); + animate_dlg.rv->value(1); + } + delete []s; + } + } + if(i) + { animate_dlg.txt->value(a); animate_dlg.rt->value(1); } + free(buf); free(a); +} diff --git a/mgllab/data.cpp b/mgllab/data.cpp new file mode 100644 index 0000000..f84d34d --- /dev/null +++ b/mgllab/data.cpp @@ -0,0 +1,353 @@ +/* data.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +void option_in_cb(Fl_Widget *, void *v); +void style_in_cb(Fl_Widget *, void *v); +//----------------------------------------------------------------------------- +struct VarDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Choice *var; + Fl_Spinner *dim1, *dim2, *dim3; + VarDlg() { memset(this,0,sizeof(VarDlg)); create_dlg(); } + ~VarDlg() { delete wnd; } + void create_dlg(); + char *get_result(); + void init(); +} var_dlg; +//----------------------------------------------------------------------------- +void VarDlg::init() +{ + char ss[1024]; + var->clear(); + mglVar *v=Parse->FindVar(""); + while(v) + { + wcstombs(ss,v->s.c_str(),1024); + var->add(ss,0,0,v); + v = v->next; + } +} +//----------------------------------------------------------------------------- +char *VarDlg::get_result() +{ + static char res[64]; + char a1[16]=":",a2[16]=":",a3[16]=":"; + res[0]=0; + if(var->value()<0) return res; + const Fl_Menu_Item m=var->menu()[var->value()]; + if(m.text[0]) + { + if(dim3->value()>=0) + { + if(dim1->value()>=0) snprintf(a1,16,"%g",dim1->value()); + if(dim2->value()>=0) snprintf(a2,16,"%g",dim2->value()); + snprintf(a3,16,"%g",dim3->value()); + snprintf(res,64,"%s(%s,%s,%s)",m.text,a1,a2,a3); + } + else if(dim2->value()>=0) + { + if(dim1->value()>=0) snprintf(a1,16,"%g",dim1->value()); + snprintf(a2,16,"%g",dim2->value()); + snprintf(res,64,"%s(%s,%s)",m.text,a1,a2); + } + else if(dim1->value()>=0) + { + snprintf(a1,16,"%g",dim1->value()); + snprintf(res,64,"%s(%s)",m.text,a1); + } + else strncpy(res,m.text,64); + } + return res; +} +//----------------------------------------------------------------------------- +void var_chg_cb(Fl_Widget *, void *) +{ + const Fl_Menu_Item m=var_dlg.var->menu()[var_dlg.var->value()]; + if(m.text[0] && m.user_data()) + { + mglVar *a = (mglVar *)m.user_data(); + var_dlg.dim1->range(-1,a->nx-1); + var_dlg.dim2->range(-1,a->ny-1); + var_dlg.dim3->range(-1,a->nz-1); + } +} +//----------------------------------------------------------------------------- +void var_in_cb(Fl_Widget *, void *v) +{ + Fl_Input *e = (Fl_Input*)v; + VarDlg *s = &var_dlg; + s->OK = false; + s->init(); + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) e->value(s->get_result()); +} +//----------------------------------------------------------------------------- +void var_dlg_cb(Fl_Widget *, void *v) +{ var_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void VarDlg::create_dlg() +{ + wnd = new Fl_Double_Window(190, 180, gettext("Variable")); + var = new Fl_Choice(100, 10, 75, 25, gettext("Variable name")); // !!! add variables here !!! + var->callback(var_chg_cb); + dim1 = new Fl_Spinner(100, 40, 75, 25, gettext("First index")); + dim1->range(-1,0); dim1->value(-1); dim1->step(1); + dim1->tooltip(gettext("Value of first dimensions (-1 for all range)")); + dim2 = new Fl_Spinner(100, 70, 75, 25, gettext("Second index")); + dim2->range(-1,0); dim2->value(-1); dim2->step(1); + dim2->tooltip(gettext("Value of second dimensions (-1 for all range)")); + dim3 = new Fl_Spinner(100, 100, 75, 25, gettext("Third index")); + dim3->range(-1,0); dim3->value(-1); dim3->step(1); + dim3->tooltip(gettext("Value of third dimensions (-1 for all range)")); + Fl_Button *o; + o = new Fl_Button(15, 140, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o = new Fl_Return_Button(100, 140, 75, 25, gettext("OK")); o->callback(var_dlg_cb,wnd); + wnd->end(); +} +//----------------------------------------------------------------------------- +const char *cmds[]={ +"plot|area|bars|barh|boxplot|chart|error|mark|region|stem|step|tens|textmark|torus|tube", +"surf|axial|belt|boxs|cont|contd|contf|dens|fall|grid2|mesh|tile|grad", +"surf3|cloud|beam|cont3|conta|contf3|contfa|dens3|densa|grid3|grida", +"map|stfa|surfa|surfc|tile|surf3a|surf3c", +"flow|pipe|traj|vect|vectc|vectl|dew", +"contx|conty|contz|contfx|contfy|contfz|densx|densy|densz|triplot|tricont|quadplot|crust|dots", +"text|title|fgets|legend|addlegend|clearlegend|legendbox", +"new|var|copy|delete|insert|read|readmat|readall|readhdf|save|savehdf|export|import|info|idset", +"fill|fillsample|modify|put|crop|extend|rearrange|squeeze|transpose|cumsum|diff|diff2|sinfft|cosfft|hankel|envelop|integrate|mirror|norm|normsl|sew|smooth|swap|roll|addto|subto|divto|multo", +"combine|evaluate|max|min|hist|jacobian|momentum|resize|sum|trace|transform|transforma|stfad|pde|qo2d|ray", +"axis|box|colorbar|grid|xlabel|ylabel|zlabel|tlabel", +"alpha|alphadef|transparent|transptype|ambient|light|fog|arrowsize|barwidth|linewidth|marksize|plotfactor|zoom|cut|axialdir|mesgnum|font|palette|rotatetext", +"axis|ranges|caxis|crange|xrange|yrange|zrange|origin|ternary|adjust|ctick|xtick|ytick|ztick|ticklen|tickstl", +"subplot|inplot|rotate|aspect|columnplot|perspective", +"call|func|chdir|define|if|elseif|else|endif|for|next|once|stop|write|setsize", +"fit|fits|putsfit", +"fplot|fsurf|ball|cone|curve|drop|facex|facey|facez|line|rect|sphere"}; +const char *first[]={"plot", "surf", "surf3", "map", "flow", "contx", "text", "new", "fill", "combine", "alpha", "axis", "subplot", "call", "fit", "fplot"}; +const char *cmd_types="1D plots|2D plots|3D plots|Dual plots|Vector plots|Other plots|Text and legend|Create data and I-O|Data handling|Data extraction|Axis and colorbar|General setup|Axis setup|Scale and rotate|Program flow|Nonlinear fitting|Primitives"; +//----------------------------------------------------------------------------- +void data_file(char *fn) +{ + static int num=0; + static char name[32], res[256]; + snprintf(name,32,"mgl_%d",num); num++; + mglData *v = Parse->AddVar(name); + v->Read(fn); + if(v->nz>1) + snprintf(res,256,"#read %s '%s'\nrotate 40 60\ncrange %s\nbox\nsurf3 %s\n", name, fn, name, name); + else if(v->ny>1) + snprintf(res,256,"#read %s '%s'\nrotate 40 60\ncrange %s\nzrange %s\nbox\nsurf %s\n", name, fn, name, name, name); + else + snprintf(res,256,"#read %s '%s'\nyrange %s\nbox\nplot %s\n", name, fn, name, name); + textbuf->text(res); +} +//----------------------------------------------------------------------------- +// +// New Command dialog +// +//----------------------------------------------------------------------------- +struct CmdDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Choice *type, *cmd; + Fl_Input *var_x, *var_y, *var_z, *var_u, *var_v, *var_w; + Fl_Box *fmt, *dsc; + Fl_Input *stl, *zval, *par1, *par2, *opt; + Fl_Help_View *help; + + CmdDlg() { memset(this,0,sizeof(CmdDlg)); create_dlg(); } + ~CmdDlg() { delete wnd; } + void create_dlg(); + char *get_result(); +} cmd_dlg; +//----------------------------------------------------------------------------- +void cmd_dlg_cb(Fl_Widget *, void *v) // add variables checking +{ cmd_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void type_cmd_cb(Fl_Widget *, void *) +{ + int val = cmd_dlg.type->value(); + if(val>=0 && val<16) + { + cmd_dlg.cmd->clear(); cmd_dlg.cmd->add(cmds[val]); + cmd_dlg.dsc->copy_label(Parse->CmdDesc(first[val])); + cmd_dlg.fmt->copy_label(Parse->CmdFormat(first[val])); + + static char str[300]; // load help for command +#ifdef WIN32 + snprintf(str,300,"%s\\mgl_en.html#%s",docdir,first[val]); +#else + snprintf(str,300,"%s/mgl_en.html#%s",docdir,first[val]); +#endif + cmd_dlg.help->load(str); + } + cmd_dlg.cmd->value(0); +} +//----------------------------------------------------------------------------- +void desc_cmd_cb(Fl_Widget *, void *) +{ + const char *name = cmd_dlg.cmd->mvalue()->text; + cmd_dlg.dsc->copy_label(Parse->CmdDesc(name)); + cmd_dlg.fmt->copy_label(Parse->CmdFormat(name)); + + static char str[300]; // load help for command +#ifdef WIN32 + snprintf(str,300,"%s\\mgl_en.html#%s",docdir,name); +#else + snprintf(str,300,"%s/mgl_en.html#%s",docdir,name); +#endif + cmd_dlg.help->load(str); +} +//----------------------------------------------------------------------------- +void CmdDlg::create_dlg() +{ + Fl_Button *o; + wnd = new Fl_Double_Window(500, 450, gettext("Command properties")); + type = new Fl_Choice(90, 10, 170, 25, gettext("Type of plot")); + type->tooltip(gettext("Select one of general types of plot")); + cmd = new Fl_Choice(350, 10, 100, 25, gettext("Command")); + cmd->tooltip(gettext("Select kind of plot in this group")); + + fmt = new Fl_Box(0, 40, 500, 25); + fmt->box(UDAV_DOWN_BOX); + fmt->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + fmt->tooltip(gettext("Format of command and its arguments")); + dsc = new Fl_Box(0, 70, 500, 25); + dsc->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + dsc->tooltip(gettext("Short command description")); + + type->callback(type_cmd_cb,cmd); cmd->callback(desc_cmd_cb,0); + type->add(gettext(cmd_types)); type_cmd_cb(0,0); + + var_x = new Fl_Input(15, 115, 50, 25, "X"); var_x->align(FL_ALIGN_TOP); + o = new Fl_Button(65, 115, 25, 25, ".."); o->callback(var_in_cb,var_x); + var_y = new Fl_Input(95, 115, 50, 25, "Y"); var_y->align(FL_ALIGN_TOP); + o = new Fl_Button(145, 115, 25, 25, ".."); o->callback(var_in_cb,var_y); + var_z = new Fl_Input(175, 115, 50, 25, "Z"); var_z->align(FL_ALIGN_TOP); + o = new Fl_Button(225, 115, 25, 25, ".."); o->callback(var_in_cb,var_z); + var_u = new Fl_Input(255, 115, 50, 25, gettext("Vx or A")); var_u->align(FL_ALIGN_TOP); + o = new Fl_Button(305, 115, 25, 25, ".."); o->callback(var_in_cb,var_u); + var_v = new Fl_Input(335, 115, 50, 25, gettext("Vy or C")); var_v->align(FL_ALIGN_TOP); + o = new Fl_Button(385, 115, 25, 25, ".."); o->callback(var_in_cb,var_v); + var_w = new Fl_Input(415, 115, 50, 25, "Vz");var_w->align(FL_ALIGN_TOP); + o = new Fl_Button(465, 115, 25, 25, ".."); o->callback(var_in_cb,var_w); + + stl = new Fl_Input(15, 165, 50, 25, gettext("Style")); + stl->align(FL_ALIGN_TOP); stl->tooltip(gettext("String argument with command style (or scheme or font)")); + o = new Fl_Button(65, 165, 25, 25, ".."); o->callback(style_in_cb, stl); + + zval = new Fl_Input(95, 165, 75, 25, gettext("zVal or sVal")); + zval->align(FL_ALIGN_TOP); + zval->tooltip(gettext("Z-value or value of slice.\nKeep empty for default value")); + par1 = new Fl_Input(175, 165, 75, 25, gettext("Text or dir")); + par1->align(FL_ALIGN_TOP); + par1->tooltip(gettext("Text (in text command) or direction (in cont3, contf3, dens3)")); + par2 = new Fl_Input(255, 165, 75, 25, gettext("Number")); + par2->align(FL_ALIGN_TOP); + par2->tooltip(gettext("Number of contours in cont* commands")); + + opt = new Fl_Input(15, 215, 290, 25, gettext("Options")); + opt->align(FL_ALIGN_TOP_LEFT); + opt->tooltip(gettext("Command options")); + o = new Fl_Button(305, 215, 25, 25, ".."); o->callback(option_in_cb, opt); + + o = new Fl_Button(405, 180, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb, wnd); + o = new Fl_Return_Button(405, 215, 75, 25, gettext("OK")); o->callback(cmd_dlg_cb, wnd); + + help = new Fl_Help_View(0, 250, 500, 200); + wnd->end(); +} +//----------------------------------------------------------------------------- +char *CmdDlg::get_result() +{ + static char res[1024],buf[128]; + res[0]=0; + const char *cn = cmd->mvalue()->text; + + bool sl3 = !strcmp(cn,"cont3") || !strcmp(cn,"contf3") || !strcmp(cn,"dens3"); + strcpy(res,"\n"); strncat(res,cn,1022); + snprintf(buf,128,"%s%s%s%s%s%s%s%s%s%s%s%s", var_x->value()[0]?" ":"", var_x->value(), + var_y->value()[0]?" ":"", var_y->value(), var_z->value()[0]?" ":"", var_z->value(), + var_u->value()[0]?" ":"", var_u->value(), var_v->value()[0]?" ":"", var_v->value(), + var_w->value()[0]?" ":"", var_w->value()); + strcat(res,buf); + + if(!strcmp(cn,"text") && par1->value()[0]) + { strcat(res," '"); strcat(res,par1->value()); strcat(res,"'"); } + if(sl3 && !par1->value()[0]) + { + strcat(res," 'x'"); + fl_message(gettext("You should specify direction.\nDirection 'x' is selected by default")); + if(zval->value()[0]) + { snprintf(buf,128," %d",atoi(zval->value())); strcat(res,buf); } + } + if(sl3 && par1->value()[0]) + { + strcat(res," '"); strcat(res,par1->value()); strcat(res,"'"); + if(zval->value()[0]) + { snprintf(buf,128," %d",atoi(zval->value())); strcat(res,buf); } + } + if(stl->value()[0]) + { strcat(res," '"); strcat(res,stl->value()); strcat(res,"'"); } + if(!sl3 && zval->value()[0]) + { snprintf(buf,128," %d",atoi(zval->value())); strcat(res,buf); } + if(!sl3 && par2->value()[0]) + { snprintf(buf,128," %d",atoi(par2->value())); strcat(res,buf); } + if(opt->value()[0]) strcat(res,opt->value()); +// strcat(res,"\n"); + return res; +} +//----------------------------------------------------------------------------- +void command_cb(Fl_Widget *, void *v) +{ + CmdDlg *s = &cmd_dlg; + ScriptWindow* e = (ScriptWindow*)v; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + { + long i=e->editor->insert_position(), j=textbuf->line_end(i); + e->editor->insert_position(j); + e->editor->insert(s->get_result()); + } +} +//----------------------------------------------------------------------------- +void plot_dat_cb(Fl_Widget *, void *) +{ + CmdDlg *s = &cmd_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + textbuf->insert(textbuf->length(), s->get_result()); +} +//----------------------------------------------------------------------------- diff --git a/mgllab/editor.cpp b/mgllab/editor.cpp new file mode 100644 index 0000000..e522eac --- /dev/null +++ b/mgllab/editor.cpp @@ -0,0 +1,516 @@ +/* editor.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#ifdef __MWERKS__ +# define FL_DLL +#endif +#include "udav.h" +//----------------------------------------------------------------------------- +int changed = 0; +char filename[256] = ""; +Fl_Text_Buffer *textbuf = 0; +void data_file(char *v); +//----------------------------------------------------------------------------- +// Syntax highlighting stuff... +Fl_Text_Buffer *stylebuf = 0; +Fl_Text_Display::Style_Table_Entry styletable[] = { // Style table + { FL_BLACK, FL_COURIER, 14, 0 }, // A - Plain + { FL_DARK_GREEN,FL_COURIER_ITALIC, 14, 0 }, // B - Line comments + { FL_BLUE, FL_COURIER, 14, 0 }, // C - Number + { FL_RED, FL_COURIER, 14, 0 }, // D - Strings + { FL_DARK_BLUE, FL_COURIER_BOLD, 14, 0 }, // E - Usual ommand + { FL_DARK_CYAN, FL_COURIER_BOLD, 14, 0 }, // F - Flow command + { FL_DARK_MAGENTA, FL_COURIER_BOLD,14, 0 }, // G - New-data command + { FL_DARK_RED, FL_COURIER, 14, 0 }, // H - Option + { FL_DARK_GREEN,FL_COURIER_BOLD, 14, 0 }}; // I - Inactive command +//----------------------------------------------------------------------------- +bool is_sfx(const char *s) // suffix +{ + register long i,n=strlen(s); + for(i=0;i='a';i++); + if(i==1 && s[0]=='a') return true; + if(i==2 && strchr("axyz",s[1]) && strchr("nmawsk",s[0])) return true; + if(i==3 && (!strncmp("fst",s,3) || !strncmp("lst",s,3) || !strncmp("max",s,3) || + !strncmp("min",s,3) || !strncmp("sum",s,3))) + return true; + return false; +// char *t = new char[i+1]; memcpy(t,s,i*sizeof(char)); t[i]=0; +} +//----------------------------------------------------------------------------- +bool is_opt(const char *s) // option +{ + const char *o[]={"xrange","yrange","zrange","crange","alpha", + "cut","value","meshnum","size","legend"}; + int l[10] = {6, 6, 6, 6, 5, 3, 5, 7, 4, 6}; + register long i; + for(i=0;i<10;i++) if(!strncmp(o[i],s,l[i]) && s[l[i]]<=' ') return true; + return false; +} +//----------------------------------------------------------------------------- +bool is_num(const char *s) // number +{ + register long i,n=strlen(s); + if(s[0]==':' && (s[1]<=' ' || s[1]==';')) return true; + if(n>=2 && !strncmp("pi",s,2) && (s[2]<=' ' || s[2]==';' || s[2]==':')) return true; + if(n>=2 && !strncmp("on",s,2) && (s[2]<=' ' || s[2]==';' || s[2]==':')) return true; + if(n>=3 && !strncmp("off",s,3) && (s[3]<=' ' || s[3]==';' || s[2]==':')) return true; + if(n>=3 && !strncmp("nan",s,3) && (s[3]<=' ' || s[3]==';' || s[2]==':')) return true; + for(i=0;iCmdType(w); + if(rts==5) res = 'G'; + else if(rts==7) res = 'F'; + else if(rts) res = 'E'; + delete []w; return res; +} +//----------------------------------------------------------------------------- +// Parse text and produce style data. +void style_parse(const char *text, char *style, int /*length*/) +{ + register long i; + long n=strlen(text); + bool nl=true, arg=true; + // Style letters: + // A - Plain + // B - Line comments + // C - Number + // D - Strings + // E - Usual command + // F - Flow command + // G - New data command + // H - Option + + for(i=0;ilength() + 1]; + char *text = textbuf->text(); + memset(style, 'A', textbuf->length()); + style[textbuf->length()] = '\0'; + if (!stylebuf) stylebuf = new Fl_Text_Buffer(textbuf->length()); + style_parse(text, style, textbuf->length()); + stylebuf->text(style); + delete[] style; + free(text); +} +//----------------------------------------------------------------------------- +// Update unfinished styles. +void style_unfinished_cb(int, void*) {} +//----------------------------------------------------------------------------- +// Update the style buffer... +void style_update(int pos, // Position of update + int nInserted, // Number of inserted chars + int nDeleted, // Number of deleted chars + int /*nRestyled*/, // Number of restyled chars + const char */*deletedText*/,// Text that was deleted + void *cbArg) // Callback data +{ + long start, end; // Start and end of text + char last, // Last style on line + *style, // Style data + *text; // Text data + + // If this is just a selection change, just unselect the style buffer... + if (nInserted == 0 && nDeleted == 0) { stylebuf->unselect(); return; } + // Track changes in the text buffer... + if (nInserted > 0) + { + // Insert characters into the style buffer... + style = new char[nInserted + 1]; + memset(style, 'A', nInserted); + style[nInserted] = '\0'; + + stylebuf->replace(pos, pos + nDeleted, style); + delete[] style; + } + else // Just delete characters in the style buffer... + stylebuf->remove(pos, pos + nDeleted); + + // Select the area that was just updated to avoid unnecessary callbacks... + stylebuf->select(pos, pos + nInserted - nDeleted); + + // Re-parse the changed region; we do this by parsing from the + // beginning of the previous line of the changed region to the end of + // the line of the changed region... Then we check the last + // style character and keep updating if we have a multi-line + // comment character... + start = textbuf->line_start(pos); + end = textbuf->line_end(pos + nInserted); + text = textbuf->text_range(start, end); + style = stylebuf->text_range(start, end); + if (start==end) last = 0; + else last = style[end-start-1]; + style_parse(text, style, end - start); + stylebuf->replace(start, end, style); + ((Fl_Text_Editor *)cbArg)->redisplay_range(start, end); + + if (start==end || last != style[end-start-1]) + { + // Either the user deleted some text, or the last character on + // the line changed styles, so reparse the remainder of the buffer... + free(text); free(style); + + end = textbuf->length(); + text = textbuf->text_range(start, end); + style = stylebuf->text_range(start, end); + style_parse(text, style, end - start); + stylebuf->replace(start, end, style); + ((Fl_Text_Editor *)cbArg)->redisplay_range(start, end); + } + free(text); free(style); +} +//----------------------------------------------------------------------------- +ScriptWindow::ScriptWindow(int w, int h, const char* t) : Fl_Double_Window(w, h, t) +{ + replace_dlg = new Fl_Window(300, 105, gettext("Replace")); + replace_find = new Fl_Input(80, 10, 210, 25, gettext("Find:")); + replace_find->align(FL_ALIGN_LEFT); + + replace_with = new Fl_Input(80, 40, 210, 25, gettext("Replace:")); + replace_with->align(FL_ALIGN_LEFT); + + replace_all = new Fl_Button(10, 70, 90, 25, gettext("Replace All")); + replace_all->callback((Fl_Callback *)replall_cb, this); + replace_all->box(UDAV_UP_BOX); replace_all->down_box(UDAV_DOWN_BOX); + + replace_next = new Fl_Return_Button(105, 70, 120, 25, "Replace Next"); + replace_next->callback((Fl_Callback *)replace2_cb, this); + replace_next->box(UDAV_UP_BOX); replace_next->down_box(UDAV_DOWN_BOX); + + replace_cancel = new Fl_Button(230, 70, 60, 25, gettext("Cancel")); + replace_cancel->callback((Fl_Callback *)replcan_cb, this); + replace_cancel->box(UDAV_UP_BOX); replace_cancel->down_box(UDAV_DOWN_BOX); + + replace_dlg->end(); + replace_dlg->set_non_modal(); + editor = 0; *search = 0; + + setup_dlg = new SetupDlg; + setup_dlg->CreateDlg(); +} +//----------------------------------------------------------------------------- +ScriptWindow::~ScriptWindow() +{ + delete replace_dlg; + delete setup_dlg->wnd; +} +//----------------------------------------------------------------------------- +int check_save(void) +{ + if (!changed) return 1; + int r = fl_choice(gettext("The current file has not been saved.\n" + "Would you like to save it now?"), + gettext("Cancel"), gettext("Save"), gettext("Don't Save")); + if(r==1) { save_cb(0,0); return !changed; } // Save the file... + return (r==2) ? 1 : 0; +} +//----------------------------------------------------------------------------- +int loading = 0; +void load_file(char *newfile, int ipos) +{ + long len = strlen(newfile); + pref.set("last_file",newfile); + if(ipos==-1 && (!strcmp(newfile+len-4,".dat") || !strcmp(newfile+len-4,".csv"))) + { + data_file(newfile); + strncpy(newfile+len-4,".mgl",4); + strncpy(filename, newfile,256); + } + else + { + loading = 1; + int insert = (ipos != -1); + changed = insert; + if(!insert) *filename=0; + long r; + if(!insert) r = textbuf->loadfile(newfile); + else r = textbuf->insertfile(newfile, ipos); + + char *t = textbuf->text(); +#ifndef WIN32 + register size_t i,l=strlen(t); + for(i=0;itext(t); +#endif + fill_animate(t); free(t); + + if (r) + fl_alert(gettext("Error reading from file \'%s\':\n%s."), newfile, strerror(errno)); + else if(!insert) strncpy(filename, newfile,256); + loading = 0; + textbuf->call_modify_callbacks(); + } +} +//----------------------------------------------------------------------------- +void save_file(char *newfile) +{ + pref.set("last_file",newfile); + if (textbuf->savefile(newfile)) + fl_alert(gettext("Error writing to file \'%s\':\n%s."), newfile, strerror(errno)); + else + strncpy(filename, newfile,256); + changed = 0; + textbuf->call_modify_callbacks(); +} +//----------------------------------------------------------------------------- +void copy_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + Fl_Text_Editor::kf_copy(0, e->editor); +} +//----------------------------------------------------------------------------- +void cut_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + Fl_Text_Editor::kf_cut(0, e->editor); +} +//----------------------------------------------------------------------------- +void delete_cb(Fl_Widget*, void*) { textbuf->remove_selection(); } +//----------------------------------------------------------------------------- +void find_cb(Fl_Widget* w, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + const char *val; + val = fl_input(gettext("Search String:"), e->search); + if (val != NULL) { strncpy(e->search, val,256); find2_cb(w, v); } +} +//----------------------------------------------------------------------------- +void find2_cb(Fl_Widget* w, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + if (e->search[0] == '\0') { find_cb(w, v); return; } + + int pos = e->editor->insert_position(); + long found = textbuf->search_forward(pos, e->search, &pos); + if (found) { + // Found a match; select and update the position... + textbuf->select(pos, pos+strlen(e->search)); + e->editor->insert_position(pos+strlen(e->search)); + e->editor->show_insert_position(); + } + else fl_alert(gettext("No occurrences of \'%s\' found!"), e->search); +} +//----------------------------------------------------------------------------- +void changed_cb(int, int nInserted, int nDeleted,int, const char*, void* v) +{ + if ((nInserted || nDeleted) && !loading) changed = 1; + ScriptWindow *w = (ScriptWindow *)v; + set_title(w); + if (loading) w->editor->show_insert_position(); +} +//----------------------------------------------------------------------------- +void insert_cb(Fl_Widget*, void *v) +{ + char *newfile = fl_file_chooser(gettext("Insert File?"), "*", filename); + ScriptWindow *w = (ScriptWindow *)v; + if (newfile != NULL) load_file(newfile, w->editor->insert_position()); +} +//----------------------------------------------------------------------------- +void paste_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + Fl_Text_Editor::kf_paste(0, e->editor); +} +//----------------------------------------------------------------------------- +void replace_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + e->replace_dlg->show(); +} +//----------------------------------------------------------------------------- +void replace2_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + const char *find = e->replace_find->value(); + const char *replace = e->replace_with->value(); + if (find[0] == '\0') { e->replace_dlg->show(); return; } + e->replace_dlg->hide(); + + int pos = e->editor->insert_position(); + long found = textbuf->search_forward(pos, find, &pos); + if (found) + { + // Found a match; update the position and replace text... + textbuf->select(pos, pos+strlen(find)); + textbuf->remove_selection(); + textbuf->insert(pos, replace); + textbuf->select(pos, pos+strlen(replace)); + e->editor->insert_position(pos+strlen(replace)); + e->editor->show_insert_position(); + } + else fl_alert(gettext("No occurrences of \'%s\' found!"), find); +} +//----------------------------------------------------------------------------- +void replall_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + const char *find = e->replace_find->value(); + const char *replace = e->replace_with->value(); + + find = e->replace_find->value(); + if (find[0] == '\0') { e->replace_dlg->show(); return; } + e->replace_dlg->hide(); + e->editor->insert_position(0); + long times = 0; + + // Loop through the whole string + for (long found = 1; found;) + { + int pos = e->editor->insert_position(); + found = textbuf->search_forward(pos, find, &pos); + if (found) + { + // Found a match; update the position and replace text... + textbuf->select(pos, pos+strlen(find)); + textbuf->remove_selection(); + textbuf->insert(pos, replace); + e->editor->insert_position(pos+strlen(replace)); + e->editor->show_insert_position(); + times++; + } + } + if (times) fl_message(gettext("Replaced %ld occurrences."), times); + else fl_alert(gettext("No occurrences of \'%s\' found!"), find); +} +//----------------------------------------------------------------------------- +void replcan_cb(Fl_Widget*, void* v) +{ + ScriptWindow* e = (ScriptWindow*)v; + e->replace_dlg->hide(); +} +//----------------------------------------------------------------------------- +void view_cb(Fl_Widget*, void*); +//#include "xpm/window.xpm" +//#include "xpm/option.xpm" +//#include "xpm/table.xpm" +#include "xpm/plot.xpm" +#include "xpm/help-contents.xpm" +#include "xpm/edit-cut.xpm" +#include "xpm/edit-copy.xpm" +#include "xpm/edit-paste.xpm" +#include "xpm/edit-find.xpm" +#include "xpm/document-open.xpm" +#include "xpm/document-new.xpm" +#include "xpm/document-save.xpm" +Fl_Widget *add_editor(ScriptWindow *w) +{ + Fl_Window *w1=new Fl_Window(0,30,300,430,0); + Fl_Group *g = new Fl_Group(0,0,290,30); + Fl_Button *o; + + o = new Fl_Button(0, 1, 25, 25); o->image(new Fl_Pixmap(document_new_xpm)); + o->tooltip(gettext("New script")); o->callback(new_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(25, 1, 25, 25); o->tooltip(gettext("Open script or data file")); + o->image(new Fl_Pixmap(document_open_xpm)); o->callback(open_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(50, 1, 25, 25); o->tooltip(gettext("Save script to file")); + o->image(new Fl_Pixmap(document_save_xpm)); o->callback(save_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(80, 1, 25, 25); o->tooltip(gettext("Cut selection to clipboard")); + o->image(new Fl_Pixmap(edit_cut_xpm)); o->callback(cut_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(105, 1, 25, 25); o->tooltip(gettext("Copy selection to clipboard")); + o->image(new Fl_Pixmap(edit_copy_xpm)); o->callback(copy_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(130, 1, 25, 25); o->tooltip(gettext("Paste text from clipboard")); + o->image(new Fl_Pixmap(edit_paste_xpm)); o->callback(paste_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(155, 1, 25, 25); o->tooltip(gettext("Find text")); + o->image(new Fl_Pixmap(edit_find_xpm)); o->callback(find_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(185, 1, 25, 25); o->tooltip(gettext("Insert MGL command")); + o->image(new Fl_Pixmap(plot_xpm)); o->callback(command_cb,w); + o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); +// o = new Fl_Button(185, 1, 25, 25); o->tooltip(gettext("Insert command options")); +// o->image(new Fl_Pixmap(option_xpm)); o->callback(option_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); +// o = new Fl_Button(210, 1, 25, 25); o->tooltip(gettext("Edit data array")); +// o->image(new Fl_Pixmap(table_xpm)); o->callback(table_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); +// o = new Fl_Button(235, 1, 25, 25); o->tooltip(gettext("New view window")); +// o->image(new Fl_Pixmap(window_xpm));o->callback(view_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(210, 1, 25, 25); o->tooltip(gettext("Show help window")); + o->image(new Fl_Pixmap(help_contents_xpm)); o->callback(help_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + g->end(); g->resizable(0); + + w->editor = new Fl_Text_Editor(0, 28, 300, 400); + w->editor->buffer(textbuf); + w->editor->highlight_data(stylebuf, styletable, sizeof(styletable) / sizeof(styletable[0]), 'A', style_unfinished_cb, 0); + w->editor->textfont(FL_COURIER); + + textbuf->add_modify_callback(style_update, w->editor); + textbuf->add_modify_callback(changed_cb, w); + textbuf->call_modify_callbacks(); + + w1->end(); + w1->resizable(w->editor); //w->graph); + return w1; +} +//----------------------------------------------------------------------------- diff --git a/mgllab/grid.cpp b/mgllab/grid.cpp new file mode 100644 index 0000000..e192818 --- /dev/null +++ b/mgllab/grid.cpp @@ -0,0 +1,110 @@ +/* grid.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +Fl_Callback input_cb; +//----------------------------------------------------------------------------- +void input_cb(Fl_Widget*, void* v) { ((Fl_Data_Table*)v)->set_value(); } +//----------------------------------------------------------------------------- +Fl_Data_Table::Fl_Data_Table(int x, int y, int w, int h, const char *l) : Fl_Table(x,y,w,h,l) +{ + callback(&event_callback, (void*)this); + input = new Fl_Input(w/2,h/2,0,0); + input->hide(); + input->callback(input_cb, (void*)this); + input->when(FL_WHEN_ENTER_KEY_ALWAYS); + input->maximum_size(16); +// (new Fl_Box(9999,9999,0,0))->hide(); // HACK: prevent flickering in Fl_Scroll + end(); +} +//----------------------------------------------------------------------------- +// Handle drawing all cells in table +void Fl_Data_Table::draw_cell(TableContext context, int R, int C, int X, int Y, int W, int H) +{ + static char s[32]; + fl_push_clip(X, Y, W, H); + switch ( context ) + { + case CONTEXT_COL_HEADER: + fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color()); + fl_font(FL_HELVETICA | FL_BOLD, 14); + fl_color(FL_BLACK); snprintf(s,32,"%d",C); + fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); + break; + case CONTEXT_ROW_HEADER: + fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, col_header_color()); + fl_font(FL_HELVETICA | FL_BOLD, 14); + fl_color(FL_BLACK); snprintf(s,32,"%d",R); + fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER); + break; + case CONTEXT_CELL: + if (R == row && C == col && input->visible()) break; + fl_draw_box(FL_THIN_DOWN_BOX, X, Y, W, H, FL_WHITE); + fl_pop_clip(); + fl_push_clip(X+3, Y+3, W-6, H-6); + fl_font(FL_HELVETICA, 14); + fl_color(FL_BLACK); + if(mgl_isnan(data[C+nx*R])) strcpy(s,"nan"); + else snprintf(s,32,"%g",data[C+nx*R]); + fl_draw(s, X+3, Y+3, W-6, H-6, FL_ALIGN_RIGHT); + break; + case CONTEXT_RC_RESIZE: + if (!input->visible()) break; + find_cell(CONTEXT_TABLE, row, col, X, Y, W, H); + if (X!=input->x() || Y!=input->y() || W!=input->w() || H!=input->h()) + input->resize(X,Y,W,H); + break; + default: break; + } + fl_pop_clip(); +} +//----------------------------------------------------------------------------- +void Fl_Data_Table::cell_click() +{ + int R = callback_row(), C = callback_col(); + TableContext context = callback_context(); + + if(context==CONTEXT_CELL) + { + if (input->visible()) //input->do_callback(); + { + const char *s = input->value(); + data[col + nx*row] = (s[0]==0 || !strcmp(s,"nan")) ? NAN : atof(s); + } + row = R; col = C; + int XX,YY,WW,HH; + find_cell(CONTEXT_CELL, R, C, XX, YY, WW, HH); + input->resize(XX,YY,WW,HH); + char s[32]; + if(mgl_isnan(data[C+nx*R])) strcpy(s,"nan"); + else snprintf(s,32,"%g",data[C+nx*R]); + input->value(s); input->show(); + input->take_focus(); + } +} +//----------------------------------------------------------------------------- +void Fl_Data_Table::set_value() +{ + const char *s = input->value(); + data[col + nx*row] = (s[0]==0 || !strcmp(s,"nan")) ? NAN : atof(s); +} +//----------------------------------------------------------------------------- diff --git a/mgllab/help.cpp b/mgllab/help.cpp new file mode 100644 index 0000000..1fd19af --- /dev/null +++ b/mgllab/help.cpp @@ -0,0 +1,244 @@ +/* help.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "udav.h" +#include +#include +//----------------------------------------------------------------------------- +void help_cb(Fl_Widget*, void*v) +{ + ScriptWindow* e = (ScriptWindow*)v; + long i=e->editor->insert_position(), j0=textbuf->line_start(i),j; + + static char str[300]; + char s[32]="", *buf = textbuf->text(); + memset(s,0,32*sizeof(char)); + for(j=j0;!isspace(buf[j]) && buf[j]!='#' && buf[j]!=';' && j<31+j0;j++) + s[j-j0] = buf[j]; + free(buf); +#ifdef WIN32 + snprintf(str,300,"%s\\mgl_en.html#%s",docdir,s); +#else + snprintf(str,300,"%s/mgl_en.html#%s",docdir,s); +#endif + e->hd->load(str); + if(e->rtab) e->rtab->value(e->ghelp); +} +//----------------------------------------------------------------------------- +void link_cb(Fl_Widget*, void*v) +{ + ScriptWindow* e = (ScriptWindow*)v; + static char str[300]; +#ifdef WIN32 + snprintf(str,300,"%s\\mgl_en.html#%s",docdir,e->link_cmd->value()); +#else + snprintf(str,300,"%s/mgl_en.html#%s",docdir,e->link_cmd->value()); +#endif + e->hd->load(str); + if(e->rtab) e->rtab->value(e->ghelp); +} +//----------------------------------------------------------------------------- +void example_cb(Fl_Widget*, void*v) +{ + static char str[300]; + ScriptWindow* e = (ScriptWindow*)v; +#ifdef WIN32 + snprintf(str,300,"%s\\mgl_en.html\\mgl_en_2.html",docdir); +#else + snprintf(str,300,"%s/mgl_en.html/mgl_en_2.html",docdir); +#endif + e->hd->load(str); e->rtab->value(e->ghelp); + if(e->rtab) e->rtab->value(e->ghelp); +} +//----------------------------------------------------------------------------- +void help_in_cb(Fl_Widget*, void*v) +{ + ScriptWindow* e = (ScriptWindow*)v; + e->hd->textsize(e->hd->textsize()+1); +} +//----------------------------------------------------------------------------- +void help_out_cb(Fl_Widget*, void*v) +{ + ScriptWindow* e = (ScriptWindow*)v; + e->hd->textsize(e->hd->textsize()-1); +} +//----------------------------------------------------------------------------- +#include "xpm/udav.xpm" +void about_cb(Fl_Widget*, void*) +{ + static char s[128]; + snprintf(s,128,gettext("UDAV v. 2.%g\n(c) Alexey Balakin, 2007\nhttp://udav.sf.net/"), MGL_VER2); + Fl_Double_Window* w = new Fl_Double_Window(355, 130, "About UDAV"); + Fl_Box* o = new Fl_Box(10, 15, 65, 65); + o->box(FL_UP_BOX); o->color(55); o->image(new Fl_Pixmap(udav_xpm)); + o = new Fl_Box(85, 15, 260, 65); o->box(UDAV_DOWN_BOX); + o->label(s); + Fl_Button *b = new Fl_Return_Button(255, 90, 90, 30, "Close"); + b->callback(close_dlg_cb,w); + b->box(UDAV_UP_BOX); b->down_box(UDAV_DOWN_BOX); + w->end(); w->set_modal(); w->show(); +} +//----------------------------------------------------------------------------- +#include "xpm/zoom-out.xpm" +#include "xpm/zoom-in.xpm" +#include "xpm/help-faq.xpm" +Fl_Widget *add_help(ScriptWindow *w) +{ + Fl_Window *w1=new Fl_Window(300,30,630,430,0); + Fl_Group *g = new Fl_Group(0,0,290,30); + Fl_Button *o; + + w->link_cmd = new Fl_Input(0,1,150,25); + w->link_cmd->when(FL_WHEN_CHANGED); + w->link_cmd->callback(link_cb,w); + + o = new Fl_Button(155, 1, 25, 25); o->tooltip(gettext("MGL samples and hints")); + o->image(new Fl_Pixmap(help_faq_xpm)); o->callback(example_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(180, 1, 25, 25); o->tooltip(gettext("Increase font size")); + o->image(new Fl_Pixmap(zoom_in_xpm)); o->callback(help_in_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(205, 1, 25, 25); o->tooltip(gettext("Decrease font size")); + o->image(new Fl_Pixmap(zoom_out_xpm)); o->callback(help_out_cb,w); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + g->end(); g->resizable(0); + + w->hd = new Fl_Help_View(0,28,630,400); + w1->end(); link_cb(w,w); + w1->resizable(w->hd); return w1; +} +//----------------------------------------------------------------------------- +void mem_dlg_cb0(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_pressed(0); } +//----------------------------------------------------------------------------- +void mem_dlg_cb1(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_pressed(1); } +//----------------------------------------------------------------------------- +void mem_dlg_cb2(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_pressed(2); } +//----------------------------------------------------------------------------- +void mem_dlg_cb3(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_pressed(3); } +//----------------------------------------------------------------------------- +void mem_update_cb(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_init(); } +//----------------------------------------------------------------------------- +Fl_Widget *add_mem(ScriptWindow *w) +{ + static int widths[] = {220,205,0}; + Fl_Button *o; + Fl_Box *b; +// wnd = new Fl_Double_Window(335, 405, gettext("Data browser")); + Fl_Window *wnd = new Fl_Window(300,30,630,430,0); + +// Fl_Group *g = new Fl_Group(10,10,610,395); + b = new Fl_Box(0, 10, 630, 25, gettext("Existed data arrays")); b->labeltype(FL_ENGRAVED_LABEL); + b = new Fl_Box(0, 35, 220, 25, gettext("name")); + b->box(FL_THIN_UP_BOX); b->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + b = new Fl_Box(220, 35, 205, 25, gettext("dimensions")); + b->box(FL_THIN_UP_BOX); b->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + b = new Fl_Box(425, 35, 205, 25, gettext("mem. usage")); + b->box(FL_THIN_UP_BOX); b->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + + w->var = new Fl_Select_Browser(0, 60, 630, 335); w->var->column_char('\t'); + w->var->align(FL_ALIGN_TOP); w->var->column_widths(widths); + w->var->tooltip(gettext("List of available data.")); +// g->end(); + + o = new Fl_Button(10, 400, 95, 25, gettext("Edit")); o->callback(mem_dlg_cb0,w); + o->tooltip(gettext("Open table with selected data for editing.")); + o = new Fl_Button(120, 400, 95, 25, gettext("Plot")); o->callback(mem_dlg_cb1,w); + o->tooltip(gettext("Plot selected data.")); + o = new Fl_Button(230, 400, 95, 25, gettext("Delete")); o->callback(mem_dlg_cb2,w); + o->tooltip(gettext("Delete selected data.")); + o = new Fl_Button(340, 400, 95, 25, gettext("New")); o->callback(mem_dlg_cb3,w); + o->tooltip(gettext("Open dialog for new data creation.")); + o = new Fl_Button(450, 400, 95, 25, gettext("Refresh")); o->callback(mem_update_cb,w); + o->tooltip(gettext("Refresh list of variables.")); +// o = new Fl_Button(120, 335, 95, 25, gettext("Load")); o->callback(mem_dlg_cb,(void *)4); +// o = new Fl_Button(230, 335, 95, 25, gettext("Save")); o->callback(mem_dlg_cb,(void *)5); +// o = new Fl_Button(10, 370, 95, 25, gettext("Update")); o->callback(mem_upd_cb,0); + wnd->end(); wnd->resizable(w->var); return wnd; +} +//----------------------------------------------------------------------------- +void ScriptWindow::mem_init() +{ + char str[128]; + var->clear(); + mglVar *v=Parse->FindVar(""); + while(v) + { + snprintf(str,128,"%ls\t%ld*%ld*%ld\t%ld\t", v->s.c_str(), v->nx, v->ny, v->nz, sizeof(mreal)*v->nx*v->ny*v->nz); + var->add(str,v); + v = v->next; + } +} +//----------------------------------------------------------------------------- +void ScriptWindow::mem_pressed(int kind) +{ + TableWindow *w; + int ind = var->value(); + mglVar *v = (mglVar *)var->data(ind); + static char res[128]; + if(!v && kind!=3) return; + if(kind==0) + { + w = (TableWindow *)v->o; + if(!w) + { + char ss[1024]; + wcstombs(ss,v->s.c_str(),1024); ss[v->s.length()]=0; + ltab->begin(); + Fl_Group *gg = new Fl_Group(0,30,300,430); + w = new TableWindow(0,30,300,430); + gg->label(ss); gg->end(); ltab->end(); + } + w->update(v); ltab->value(w->parent()); w->show(); + } + else if(kind==1) + { + if(v->nz>1) snprintf(res,128,"box\nsurf3 %ls\n",v->s.c_str()); + else if(v->ny>1) snprintf(res,128,"box\nsurf %ls\n",v->s.c_str()); + else snprintf(res,128,"box\nplot %ls\n",v->s.c_str()); + textbuf->text(res); + } + else if(kind==2) + Parse->DeleteVar(v->s.c_str()); + else if(kind==3) + { + const char *name = fl_input(gettext("Enter name for new variable"),"dat"); + if(!name) return; + v = Parse->AddVar(name); + + ltab->begin(); + Fl_Group *gg = new Fl_Group(0,30,300,430); + w = new TableWindow(0,30,300,430); + gg->label(name); gg->end(); ltab->end(); + w->update(v); ltab->value(w->parent()); w->show(); + } + mem_init(); +} +//----------------------------------------------------------------------------- +void variables_cb(Fl_Widget *, void *v) +{ +/* MemDlg *s = &mem_dlg; + s->wnd->set_modal(); + s->init(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait();*/ +} +//----------------------------------------------------------------------------- diff --git a/mgllab/main.cpp b/mgllab/main.cpp new file mode 100644 index 0000000..aa7ccae --- /dev/null +++ b/mgllab/main.cpp @@ -0,0 +1,304 @@ +/* main.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +#ifndef MGL_DOC_DIR +#ifdef WIN32 +#define MGL_DOC_DIR "" +#else +#define MGL_DOC_DIR "/usr/local/share/doc/mathgl/" +#endif +#endif +//----------------------------------------------------------------------------- +char title[256]; +int num_windows = 0, auto_exec=1, plastic_scheme=1, internal_font=0; +Fl_Preferences pref(Fl_Preferences::USER,"abalakin","mgllab"); +char *docdir=0; +//----------------------------------------------------------------------------- +void set_title(Fl_Window* w) +{ + if (filename[0] == '\0') strcpy(title, "Untitled"); + else + { + char *slash; + slash = strrchr(filename, '/'); +#ifdef WIN32 + if (slash == NULL) slash = strrchr(filename, '\\'); +#endif + if (slash != NULL) strncpy(title, slash + 1,256); + else strncpy(title, filename,256); + } + if (changed) strcat(title, gettext(" (modified)")); + w->label(title); +} +//----------------------------------------------------------------------------- +void fname_cb(Fl_Widget*, void *v) +{ + ScriptWindow* e = (ScriptWindow*)v; + char *file = fl_file_chooser(gettext("Insert File Name?"), gettext("All Files (*)"), 0); + if(file) + { + char *str = new char[strlen(file)+4]; + snprintf(str,strlen(file)+4," '%s'",file); + e->editor->insert(str); + delete []str; + } +} +//----------------------------------------------------------------------------- +void new_cb(Fl_Widget*, void*) +{ + if (!check_save()) return; + filename[0] = '\0'; + textbuf->select(0, textbuf->length()); + textbuf->remove_selection(); + changed = 0; + textbuf->call_modify_callbacks(); +} +//----------------------------------------------------------------------------- +void open_cb(Fl_Widget*, void *v) +{ + if (!check_save()) return; + char *lastname=0; + if(*filename==0) { pref.get("last_file",lastname,""); strncpy(filename, lastname,256); } + char *newfile = fl_file_chooser(gettext("Open File?"), + gettext("MGL Files (*.mgl)\tDAT Files (*.{dat,csv})\tAll Files (*)"), filename); + if(lastname) free(lastname); + if(newfile != NULL) + { + load_file(newfile, -1); + if(auto_exec) ((ScriptWindow*)v)->graph->update(); + } +} +//----------------------------------------------------------------------------- +void close_cb(Fl_Widget*, void* v) +{ + Fl_Window* w = (Fl_Window*)v; + if (num_windows == 1 && !check_save()) return; + + w->hide(); + textbuf->remove_modify_callback(changed_cb, w); + delete w; + num_windows--; + if (!num_windows) exit(0); +} +//----------------------------------------------------------------------------- +void quit_cb(Fl_Widget*, void*) +{ + if (changed && !check_save()) return; + exit(0); +} +//----------------------------------------------------------------------------- +void save_cb(Fl_Widget*w, void*v) +{ + if (filename[0] == '\0') { saveas_cb(w,v); return; } // No filename - get one! + else save_file(filename); +} +//----------------------------------------------------------------------------- +void saveas_cb(Fl_Widget*, void*) +{ + char *newfile, *fname=0; + FILE *fp=0; + while(1) + { + newfile = fl_file_chooser(gettext("Save File As?"), "*.mgl", filename); + if(!newfile || !newfile[0]) break; + if(!strchr(newfile,'.')) + { + if(fname) delete []fname; + fname = new char[strlen(newfile)+5]; + strcpy(fname,newfile); strcat(fname,".mgl"); + newfile = fname; + } + fp = fopen(newfile,"r"); + if(fp) + { + fclose(fp); + if(fl_choice(gettext("File is exesist. Overwrite it?"),0,gettext("No"),gettext(" Yes "))==2) + break; + } + else break; + } + if (newfile != NULL) save_file(newfile); + if(fname) delete []fname; +} +//----------------------------------------------------------------------------- +ScriptWindow *new_view(); +void view_cb(Fl_Widget*, void*) +{ Fl_Window* w = new_view(); w->show(); } +//----------------------------------------------------------------------------- +void hint_cb(Fl_Widget*, void*) {} +//----------------------------------------------------------------------------- +Fl_Menu_Item menuitems[] = { +// { gettext("File"), 0, 0, 0, FL_SUBMENU }, + { gettext("File/New File"), 0, new_cb }, + { gettext("File/Open File..."), FL_CTRL + 'o', open_cb }, + { gettext("File/Insert File..."), FL_CTRL + 'i', insert_cb }, + { gettext("File/Save File"), FL_CTRL + 's', save_cb }, + { gettext("File/Save File As..._"), FL_CTRL + FL_SHIFT + 's', saveas_cb, 0, FL_MENU_DIVIDER }, +/*TODO { gettext("Export"), 0, 0, 0, FL_SUBMENU },*/ + { gettext("File/New View"), FL_ALT + 'w', view_cb }, + { gettext("File/Close View_"), FL_CTRL + 'w', close_cb, 0, FL_MENU_DIVIDER }, + { gettext("File/Exit"), FL_ALT + 'x', quit_cb }, +// { 0 }, + { gettext("Edit"), 0, 0, 0, FL_SUBMENU }, + { gettext("Cut"), FL_CTRL + 'x', cut_cb }, + { gettext("Copy"), FL_CTRL + 'c', copy_cb }, + { gettext("Paste"), FL_CTRL + 'v', paste_cb }, + { gettext("Delete"), 0, delete_cb, 0, FL_MENU_DIVIDER }, + { gettext("Insert"), 0, 0, 0, FL_SUBMENU }, + { gettext("options"), FL_ALT + 'o', option_cb }, + { gettext("style"), FL_ALT + 'i', style_cb }, + { gettext("filename"), 0, fname_cb }, + { gettext("command"), FL_ALT + 'c', command_cb }, + { 0 }, + { gettext("Properties"), 0, settings_cb }, + { 0 }, + { gettext("Search"), 0, 0, 0, FL_SUBMENU }, + { gettext("Find..."), FL_CTRL + 'f', find_cb }, + { gettext("Find Again"), FL_F + 3, find2_cb }, + { gettext("Replace..."), FL_CTRL + 'r', replace_cb }, + { gettext("Replace Again"), FL_F + 4, replace2_cb }, + { 0 }, +/*TODO{ gettext("Graphics"), 0, 0, 0, FL_SUBMENU },*/ +/*TODO{ gettext("Data"), 0, 0, 0, FL_SUBMENU },*/ + { gettext("Help"), 0, 0, 0, FL_SUBMENU }, + { gettext("MGL Help"), FL_F + 1, help_cb }, + { gettext("MGL Examples"), 0, example_cb }, + { gettext("Hints and FAQ"), 0, hint_cb , 0, FL_MENU_INACTIVE}, + { gettext("About UDAV"), 0, about_cb }, + { 0 }, + { 0 } +}; +//----------------------------------------------------------------------------- +void mem_upd_cb(Fl_Widget *, void *v) +{ ((ScriptWindow*)v)->mem_init(); } +//----------------------------------------------------------------------------- +ScriptWindow *new_view() +{ + Fl_Tabs* tt; + Fl_Group *gg; + ScriptWindow *w = new ScriptWindow(930, 510, title); + w->begin(); + w->menu = new Fl_Menu_Bar(0, 0, 930, 30); + +// w->menu->add(gettext("File"), 0, 0, 0, FL_SUBMENU); + w->menu->add(gettext("File/New File"), "", new_cb); + w->menu->add(gettext("File/Open File..."), "^o", open_cb, w); + w->menu->add(gettext("File/Insert File..."), "^i", insert_cb, w); + w->menu->add(gettext("File/Save File"), "^s", save_cb, w); + w->menu->add(gettext("File/Save File As..."), 0, saveas_cb, w, FL_MENU_DIVIDER); + /*TODO { gettext("Export"), 0, 0, 0, FL_SUBMENU },*/ + w->menu->add(gettext("File/New View"), "#w", view_cb, w); + w->menu->add(gettext("File/Close View"), "^w", close_cb, w, FL_MENU_DIVIDER); + w->menu->add(gettext("File/Exit"), "#x", quit_cb); +// w->menu->copy(menuitems, w); + + Fl_Tile *t = new Fl_Tile(0,30,930,455); + tt = new Fl_Tabs(0,30,300,455,0); tt->box(UDAV_UP_BOX); w->ltab = tt; + gg = new Fl_Group(0,30,300,430); gg->label(gettext("Script")); + add_editor(w); gg->end(); + tt->end(); + + tt = new Fl_Tabs(300,30,630,455,0); tt->box(UDAV_UP_BOX); w->rtab = tt; + gg = new Fl_Group(300,30,630,430,gettext("Canvas")); + w->graph = new Fl_MGL(300,30,630,430); gg->end(); + gg = new Fl_Group(300,30,630,430,gettext("Help")); + w->ghelp = gg; add_help(w); gg->end(); + gg = new Fl_Group(300,30,630,430,gettext("Memory")); + add_mem(w); gg->end(); + tt->end(); + + w->status = new Fl_Box(0,485,930,25,"Ready"); + w->status->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + w->status->color(FL_BACKGROUND_COLOR); + w->status->box(FL_DOWN_BOX); + w->graph->status = w->status; + + t->end(); w->end(); w->resizable(t); + tt->callback(mem_upd_cb, w); + w->callback((Fl_Callback *)close_cb, w); + + num_windows++; + return w; +} +//----------------------------------------------------------------------------- +void argument_set(int n, const char *s); +int main(int argc, char **argv) +{ +// Fl::lock(); + mgl_ask_func = mgl_ask_fltk; + char *buf, *buf2, ch; + pref.get("locale",buf,"ru_RU.cp1251"); setlocale(LC_CTYPE, buf); free(buf); + pref.get("plastic_scheme",plastic_scheme,1); + pref.get("internal_font",internal_font,0); + pref.get("auto_exec",auto_exec,1); + pref.get("help_dir",docdir,MGL_DOC_DIR); // docdir should be freed at exit + + Fl::visual(FL_DOUBLE|FL_RGB); + if(plastic_scheme) Fl::scheme("gtk+"); + +#ifdef USE_GETTEXT +// setlocale (LC_NUMERIC, ""); +// bindtextdomain (PACKAGE, LOCALEDIR); +// textdomain (PACKAGE); +#endif + + textbuf = new Fl_Text_Buffer; + style_init(); + ScriptWindow *w = new_view(); + + pref.get("font_dir",buf2,""); + pref.get("font_name",buf,""); + mgl_load_font(w->graph->FMGL->get_graph(),buf,buf2); + if(buf) free(buf); + if(buf2) free(buf2); + + buf = 0; + while(1) + { + ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:ho:L:"); + if(ch>='1' && ch<='9') argument_set(ch-'0', optarg); + else if(ch=='L') setlocale(LC_CTYPE, optarg); + else if(ch=='h') + { + printf("mglconv convert mgl script to bitmap png file.\nCurrent version is 2.%g\n",MGL_VER2); + printf("Usage:\tmgllab [parameter(s)] scriptfile\n"); + printf( "\t-1 str set str as argument $1 for script\n" + "\t... ...\n" + "\t-9 str set str as argument $9 for script\n" + "\t-L loc set locale to loc\n" +// "\t- get script from standard input\n" + "\t-h print this message\n" ); + free(docdir); return 0; + } + // NOTE: I will not parse stdin here + else if(ch==-1 && optind=argc) break; + } + + w->show(1, argv); + if(buf && *buf && *buf!='-') + { + load_file(buf, -1); + if(auto_exec) w->graph->update(); + } + return Fl::run(); +} +//----------------------------------------------------------------------------- diff --git a/mgllab/mathgl.cpp b/mgllab/mathgl.cpp new file mode 100644 index 0000000..15716f0 --- /dev/null +++ b/mgllab/mathgl.cpp @@ -0,0 +1,139 @@ +/* mathgl.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "mgl2/mgl.h" +#include "udav.h" +//----------------------------------------------------------------------------- +#include "xpm/alpha.xpm" +#include "xpm/light.xpm" +#include "xpm/alpha_on.xpm" +#include "xpm/light_on.xpm" +#include "xpm/zoom-fit-best.xpm" +#include "xpm/zoom-fit-best-r.xpm" +#include "xpm/film-r.xpm" +#include "xpm/film-b.xpm" +#include "xpm/media-seek-forward.xpm" +#include "xpm/media-seek-backward.xpm" +#include "xpm/go-previous.xpm" +#include "xpm/go-next.xpm" +#include "xpm/go-down.xpm" +#include "xpm/zoom-out.xpm" +#include "xpm/zoom-in.xpm" +#include "xpm/go-up.xpm" +#include "xpm/zoom-original.xpm" +#include "xpm/view-refresh.xpm" +#include "xpm/rotate.xpm" +#include "xpm/rotate_on.xpm" +#include "xpm/document-properties.xpm" +//#include "xpm/preferences-system.xpm" +#include "xpm/wire.xpm" +//----------------------------------------------------------------------------- +extern int internal_font; +mglParse *Parse=0; +//----------------------------------------------------------------------------- +void udav_error(const char *Message, void *v) +{ ((Fl_MGL*)v)->status->label(Message); } +mreal udav_delay(void *v) +{ return ((Fl_MGL*)v)->AnimDelay; } +void udav_reload(void *v) +{ Parse->RestoreOnce(); ((Fl_MGL*)v)->update(); } +//----------------------------------------------------------------------------- +void udav_next(void *v) { ((Fl_MGL*)v)->next_frame(); } +void Fl_MGL::next_frame() +{ + if(NArgs==0) + { + animate_cb(this,this); + if(NArgs==0) return; + } + ArgCur = (ArgCur+1) % NArgs; + Parse->AddParam(0,Args[ArgCur]); + update(); +} +//----------------------------------------------------------------------------- +void udav_prev(void *v) { ((Fl_MGL*)v)->prev_frame(); } +void Fl_MGL::prev_frame() +{ + if(NArgs==0) + { + animate_cb(this,this); + if(NArgs==0) return; + } + ArgCur = ArgCur>0 ? ArgCur-1 : NArgs-1; + Parse->AddParam(0,Args[ArgCur]); + update(); +} +//----------------------------------------------------------------------------- +Fl_MGL::Fl_MGL(int x, int y, int w, int h, const char *label) : Fl_MGLView(x,y,w,h,label) +{ + if(!Parse) Parse = new mglParse; + Parse->AllowSetSize(true); + ArgBuf = 0; NArgs = ArgCur = 0; + script = script_pre = 0; par = this; + next = udav_next; delay = udav_delay; + prev = udav_prev; reload = udav_reload; +/*#ifdef WIN32 +// setlocale(LC_TYPE,"russian_Russia.CP1251"); + char *path; + get_doc_dir(path); + if(!FMGL->GetFont()->Load("STIX",path && path[0] ? path : ".")) FMGL->GetFont()->Restore(); + free(path); +#endif*/ +} +//----------------------------------------------------------------------------- +Fl_MGL::~Fl_MGL() { clear_scripts(); if(ArgBuf) delete []ArgBuf; } +//----------------------------------------------------------------------------- +void Fl_MGL::clear_scripts() +{ + if(script) free(script); + if(script_pre) free(script_pre); +} +//----------------------------------------------------------------------------- +void Fl_MGL::scripts(char *scr, char *pre) +{ clear_scripts(); script=scr; script_pre=pre; } +//----------------------------------------------------------------------------- +int Fl_MGL::Draw(mglGraph *gr) +{ + Parse->Execute(gr,script_pre); + Parse->Execute(gr,script); + status->label(gr->Message()); + return 0; +} +//----------------------------------------------------------------------------- +void Fl_MGL::update() +{ + // NOTE: hint for old style View(). May be I should remove it! + if(!script || !strstr(script,"rotate")) mgl_rotate(FMGL->get_graph(),0,0,0); + + Fl_MGLView::update(); + + mglVar *v = Parse->FindVar(""); + while(v) + { + if(v->o) ((TableWindow *)v->o)->update(v); + v = v->next; + } +} +//----------------------------------------------------------------------------- +void add_suffix(char *fname, const char *ext) +{ + long n=strlen(fname); + if(n>4 && fname[n-4]=='.') + { fname[n-3]=ext[0]; fname[n-2]=ext[1]; fname[n-1]=ext[2]; } + else { strcat(fname,"."); strcat(fname,ext); } + +} +//----------------------------------------------------------------------------- diff --git a/mgllab/option.cpp b/mgllab/option.cpp new file mode 100644 index 0000000..afff0d5 --- /dev/null +++ b/mgllab/option.cpp @@ -0,0 +1,439 @@ +/* option.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +extern Fl_Menu_Item colors[]; +extern Fl_Text_Buffer *textbuf; +//----------------------------------------------------------------------------- +struct OptionDlg +{ +public: + Fl_Window* wnd; + int OK; + char result[256]; + OptionDlg() { memset(this,0,sizeof(OptionDlg)); create_dlg(); } + ~OptionDlg() { delete wnd; } + void FillResult(); +protected: + Fl_Input *xmin, *xmax, *ymin, *ymax, *zmin, *zmax, *cmin, *cmax; + Fl_Input *alpha, *amb, *mesh, *font; + Fl_Choice *cut; + + void create_dlg(); +} option_dlg; +//----------------------------------------------------------------------------- +struct StyleDlg +{ +public: +friend void style_set_cb(Fl_Widget *, void *v); +friend void style_rdo_cb(Fl_Widget *, void *v); +friend void font_cb(Fl_Widget *, void *v); +friend void line_cb(Fl_Widget *, void *v); +friend void face_cb(Fl_Widget *, void *v); + Fl_Window* wnd; + int OK; + char result[16]; + StyleDlg() { memset(this,0,sizeof(StyleDlg)); create_dlg(); } + ~StyleDlg() { delete wnd; } +protected: + Fl_Tabs *tab; + Fl_Group *ltab, *stab, *ftab; + Fl_Choice *cl, *cf, *c[7], *ae, *as; + Fl_Choice *dash, *mark, *dir, *text; + Fl_Spinner *lw; + Fl_Output *res; + Fl_Check_Button *d, *w, *sc, *rm, *it, *bf, *gt; + Fl_Round_Button *rl, *rc, *rr; + + void create_dlg(); +} style_dlg; +//----------------------------------------------------------------------------- +void option_dlg_cb(Fl_Widget *, void *v) +{ option_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void style_dlg_cb(Fl_Widget *, void *v) +{ style_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void OptionDlg::create_dlg() +{ + Fl_Button *o; + wnd = new Fl_Window(490, 180, gettext("Command options")); + new Fl_Box(10, 15, 75, 25, gettext("X-Range")); + xmin = new Fl_Input(85, 15, 75, 25); + xmin->tooltip(gettext("Minimal value of X for cutting or for coordinate filling")); + xmax = new Fl_Input(165, 15, 75, 25); + xmax->tooltip(gettext("Maximal value of X for cutting or for coordinate filling")); + new Fl_Box(245, 15, 75, 25, gettext("Y-Range")); + ymin = new Fl_Input(320, 15, 75, 25); + ymin->tooltip(gettext("Minimal value of Y for cutting or for coordinate filling")); + ymax = new Fl_Input(400, 15, 75, 25); + ymax->tooltip(gettext("Maximal value of Y for cutting or for coordinate filling")); + new Fl_Box(10, 45, 75, 25, gettext("Z-Range")); + zmin = new Fl_Input(85, 45, 75, 25); + zmin->tooltip(gettext("Minimal value of Z for cutting or for coordinate filling")); + zmax = new Fl_Input(165, 45, 75, 25); + zmax->tooltip(gettext("Maximal value of Z for cutting or for coordinate filling")); + new Fl_Box(245, 45, 75, 25, gettext("C-Range")); + cmin = new Fl_Input(320, 45, 75, 25); + cmin->tooltip(gettext("Low border for determining color or alpha")); + cmax = new Fl_Input(400, 45, 75, 25); + cmax->tooltip(gettext("Upper border for determining color or alpha")); + { Fl_Box *o = new Fl_Box(15, 75, 460, 5); o->box(FL_UP_BOX); } + alpha = new Fl_Input(25, 105, 75, 25, "Alpha"); alpha->align(FL_ALIGN_TOP); + alpha->tooltip(gettext("Alpha value (transparency) of surface or cloud")); + amb = new Fl_Input(110, 105, 75, 25, gettext("Ambient")); amb->align(FL_ALIGN_TOP); + amb->tooltip(gettext("Own brightness of the surface")); + mesh = new Fl_Input(195, 105, 75, 25, gettext("Mesh Num")); mesh->align(FL_ALIGN_TOP); + mesh->tooltip(gettext("Approximate number of mesh lines in plot")); + font = new Fl_Input(280, 105, 75, 25, gettext("Font Size")); font->align(FL_ALIGN_TOP); + font->tooltip(gettext("Act as default value for font size")); + cut = new Fl_Choice(365, 105, 75, 25, gettext("Cutting")); cut->align(FL_ALIGN_TOP); + cut->add(gettext("on")); cut->add(gettext("off")); + cut->tooltip(gettext("Set cutting off/on for particular plot")); + + o = new Fl_Button(320, 145, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(405, 145, 75, 25, gettext("OK")); o->callback(option_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +void OptionDlg::FillResult() +{ + double x1=0,y1=0,z1=0,x2=0,y2=0,z2=0; + bool u1,v1,w1,u2,v2,w2; + char str[64]; + result[0]=0; + + u1 = xmin->value()[0]; if(u1) x1 = atof(xmin->value()); + u2 = xmax->value()[0]; if(u2) x2 = atof(xmax->value()); + v1 = ymin->value()[0]; if(v1) y1 = atof(ymin->value()); + v2 = ymin->value()[0]; if(v2) y2 = atof(ymax->value()); + w1 = zmin->value()[0]; if(w1) z1 = atof(zmin->value()); + w2 = zmin->value()[0]; if(w2) z2 = atof(zmax->value()); + if(u1 && u2) {snprintf(str,64,"; xrange %g %g",x1,x2); strcat(result,str);} + if(v1 && v2) {snprintf(str,64,"; yrange %g %g",y1,y2); strcat(result,str);} + if(w1 && w2) {snprintf(str,64,"; zrange %g %g",z1,z2); strcat(result,str);} + + u1 = cmin->value()[0]; if(u1) x1 = atof(cmin->value()); + u2 = cmax->value()[0]; if(u2) x2 = atof(cmax->value()); + if(u1&&u2) {snprintf(str,64,"; crange %g %g",x1,x2); strcat(result,str);} + + if(alpha->value()[0]) + { snprintf(str,64,"; alpha %g",atof(alpha->value())); strcat(result,str);} + if(amb->value()[0]) + { snprintf(str,64,"; ambient %g",atof(amb->value())); strcat(result,str);} + if(mesh->value()[0]) + { snprintf(str,64,"; meshnum %g",atof(mesh->value()));strcat(result,str);} + if(font->value()[0]) + { snprintf(str,64,"; fontsize '%g'",atof(font->value())); strcat(result,str);} + if(cut->value()>=0) + {snprintf(str,64,"; cut %s",cut->value()==0?"on":"off"); strcat(result,str);} +} +//----------------------------------------------------------------------------- +void option_cb(Fl_Widget *, void *v) +{ + ScriptWindow* e = (ScriptWindow*)v; + OptionDlg *s = &option_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // insert at the end of string + { + long i=e->editor->insert_position(), j=textbuf->line_end(i); + s->FillResult(); + e->editor->insert_position(j); + e->editor->insert(s->result); + } +} +//----------------------------------------------------------------------------- +void option_in_cb(Fl_Widget *, void *v) +{ + Fl_Input* e = (Fl_Input*)v; + OptionDlg *s = &option_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) + { + s->FillResult(); + e->value(s->result); + } +} +//----------------------------------------------------------------------------- +Fl_Menu_Item arrows[] = { + {("none")}, //_ + {("arrow")}, //A + {("back arrow")}, //V + {("stop")}, //I + {("size")}, //K + {("triangle")}, //T + {("square")}, //S + {("rhomb")}, //D + {("circle")}, //O + {0}}; +//----------------------------------------------------------------------------- +Fl_Menu_Item dashing[] = { + {("solid")}, //- + {("dash")}, //| + {("dash dot")}, //j + {("small dash")}, //; + {("small dash dot")}, //i + {("dots")}, //: + {("none")}, // + {0}}; +//----------------------------------------------------------------------------- +Fl_Menu_Item markers[] = { + {("none")}, // + {("circle")}, //o + {("cross")}, //+ + {("skew cross")}, //x + {("square")}, //s + {("rhomb")}, //d + {("point")}, //. + {("triangle up")}, //^ + {("triangle down")}, //v + {0}}; +//----------------------------------------------------------------------------- +void style_set_cb(Fl_Widget *,void *) +{ + StyleDlg *s = &style_dlg; + Fl_Widget *t = s->tab->value(); + const char *cols = " wbgrcmylenuqphkWBGRCMYLENUQPH"; + char *r = s->result; + long i=0,j; + if(t==s->ltab) // line style + { + const char *aa = "_AVIKTSDO", *dd="-|j;i: ", *mm="#o+xsd.^v"; + if(s->cl->value()>0) r[i++]=cols[s->cl->value()]; + if(s->dash->value()>0) r[i++]=dd[s->dash->value()]; + if(s->mark->value()>0) r[i++]=mm[s->mark->value()]; + if(s->lw->value()>1 || s->lw->value()==0) + r[i++] = '0'+int(0.1+s->lw->value()); + if(s->as->value()>0) + { r[i++]=aa[s->ae->value()]; r[i++]=aa[s->as->value()]; } + else if(s->ae->value()>0) r[i++]=aa[s->ae->value()]; + } + else if(t==s->stab) // surf style + { + for(j=0;j<7;j++) + { + if(s->c[j]->value()>0) r[i++]=cols[s->c[j]->value()]; + else break; + } + if(s->d->value()) r[i++] = 'd'; + if(s->w->value()) r[i++] = '#'; + if(s->dir->value()>=0) r[i++] = 'x'+s->dir->value(); + if(s->text->value()>0) r[i++] = s->text->value()==1 ? 't':'T'; + } + else if(t==s->ftab) // text style + { + if(s->rm->value()) r[i++] = 'r'; + if(s->sc->value()) r[i++] = 's'; + if(s->it->value()) r[i++] = 'i'; + if(s->bf->value()) r[i++] = 'b'; + if(s->gt->value() && !s->rm->value()) r[i++] = 'g'; + if(s->rl->value()) r[i++] = 'L'; + else if(s->rc->value()) r[i++] = 'C'; + else if(s->rr->value()) r[i++] = 'R'; + if(s->cf->value()>0) + { r[i++]=':'; r[i++]=cols[s->cf->value()]; } + } + r[i]=0; + s->res->value(r); +} +//----------------------------------------------------------------------------- +void style_rdo_cb(Fl_Widget *,void *v) +{ + StyleDlg *s = &style_dlg; + s->rl->value(0); s->rc->value(0); s->rr->value(0); + ((Fl_Round_Button *)v)->value(1); + style_set_cb(0,0); +} +//----------------------------------------------------------------------------- +void StyleDlg::create_dlg() +{ + wnd = new Fl_Window(295, 337, gettext("String with line/surf/text style")); + tab = new Fl_Tabs(0, 0, 295, 255); tab->callback(style_set_cb); + tab->box(UDAV_UP_BOX); + + ltab = new Fl_Group(0, 25, 295, 230, gettext("Line style")); + as = new Fl_Choice(10, 50, 80, 25, gettext("Arrow at start")); + as->align(FL_ALIGN_TOP); as->copy(arrows); as->callback(style_set_cb); +// as->tooltip(gettext("Type of arrow at first point of line or curve")); + dash = new Fl_Choice(110, 50, 80, 25, gettext("Dashing")); + dash->align(FL_ALIGN_TOP); dash->copy(dashing);dash->callback(style_set_cb); +// dash->tooltip(gettext("Type dashing for line or curve")); + ae = new Fl_Choice(210, 50, 80, 25, gettext("Arrow at end")); + ae->align(FL_ALIGN_TOP); ae->copy(arrows); ae->callback(style_set_cb); +// ae->tooltip(gettext("Type of arrow at last point of line or curve")); + cl = new Fl_Choice(110, 85, 80, 25, gettext("Color")); cl->copy(colors); + cl->callback(style_set_cb); + mark = new Fl_Choice(110, 120, 80, 25, gettext("Marks")); + mark->copy(markers); mark->callback(style_set_cb); +// mark->tooltip(gettext("Type of marks at positions of data points")); + lw = new Fl_Spinner(110, 155, 80, 25, gettext("Line width")); + lw->range(0,9); lw->step(1); lw->callback(style_set_cb); +// lw->tooltip(gettext("Relative width of line or curve")); + ltab->end(); + + stab = new Fl_Group(0, 25, 295, 230, gettext("Color scheme")); stab->hide(); + c[0] = new Fl_Choice(15, 45, 75, 25, gettext("Color order")); + c[0]->align(FL_ALIGN_TOP); c[0]->copy(colors); c[0]->callback(style_set_cb); + c[1] = new Fl_Choice(15, 75, 75, 25); c[1]->copy(colors); c[1]->callback(style_set_cb); + c[2] = new Fl_Choice(15, 105, 75, 25); c[2]->copy(colors); c[2]->callback(style_set_cb); + c[3] = new Fl_Choice(15, 135, 75, 25); c[3]->copy(colors); c[3]->callback(style_set_cb); + c[4] = new Fl_Choice(15, 165, 75, 25); c[4]->copy(colors); c[4]->callback(style_set_cb); + c[5] = new Fl_Choice(15, 195, 75, 25); c[5]->copy(colors); c[5]->callback(style_set_cb); + c[6] = new Fl_Choice(15, 225, 75, 25); c[6]->copy(colors); c[6]->callback(style_set_cb); + d = new Fl_Check_Button(100, 45, 180, 25, gettext("Colors along coordinates")); +// w->tooltip(gettext("Set face color proportional to its position")); + d->callback(style_set_cb); + w = new Fl_Check_Button(100, 75, 180, 25, gettext("Wire or mesh plot")); + w->callback(style_set_cb); +// w->tooltip(gettext("Switch to draw wire isosurface or set to draw mesh on surface")); + dir = new Fl_Choice(210, 105, 75, 25, gettext("Axial direction")); + dir->add("x"); dir->add("y"); dir->add("z"); dir->callback(style_set_cb); + text = new Fl_Choice(210, 135, 75, 25, gettext("Text on contours")); +// text->tooltip("Draw contour values near contour lines")); + text->add(gettext("none")); text->add(gettext("under")); + text->add(gettext("above")); text->callback(style_set_cb); + stab->end(); + + ftab = new Fl_Group(0, 25, 295, 230, gettext("Text style")); ftab->hide(); + sc = new Fl_Check_Button(15, 40, 120, 25, gettext("Script font/style")); sc->callback(style_set_cb); + rm = new Fl_Check_Button(15, 70, 120, 25, gettext("Roman font")); rm->callback(style_set_cb); + gt = new Fl_Check_Button(15, 100, 120, 25, gettext("Gothic font")); gt->callback(style_set_cb); + it = new Fl_Check_Button(15, 130, 120, 25, gettext("Italic style")); it->callback(style_set_cb); + bf = new Fl_Check_Button(15, 160, 120, 25, gettext("Bold style")); bf->callback(style_set_cb); + cf = new Fl_Choice(200, 40, 80, 25, gettext("Text color")); cf->copy(colors);cf->callback(style_set_cb); + { Fl_Box* o = new Fl_Box(160, 90, 120, 90, gettext("Alignment")); + o->box(FL_DOWN_BOX); o->align(FL_ALIGN_TOP);} + rl = new Fl_Round_Button(170, 100, 100, 25, gettext("left")); rl->callback(style_rdo_cb,rl); + rc = new Fl_Round_Button(170, 125, 100, 25, gettext("at center")); rc->callback(style_rdo_cb,rc); + rr = new Fl_Round_Button(170, 150, 100, 25, gettext("right")); rr->callback(style_rdo_cb,rr); + ftab->end(); + + tab->end(); + res = new Fl_Output(50, 265, 235, 25, gettext("Result")); +// res->tooltip(gettext("Resulting string which will be used as argument of a command")); + Fl_Button *o; + o = new Fl_Button(125, 300, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(210, 300, 75, 25, gettext("OK")); o->callback(style_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +void style_cb(Fl_Widget *, void *v) +{ + ScriptWindow* e = (ScriptWindow*)v; + StyleDlg *s = &style_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + { + int p,q; + char str[20]; + snprintf(str,20,"'%s'",s->result); + textbuf->selection_position(&p, &q); + if(p==q) e->editor->insert(str); + else textbuf->replace_selection(str); + } +} +//----------------------------------------------------------------------------- +void style_in_cb(Fl_Widget *, void *v) +{ + Fl_Input* e = (Fl_Input*)v; + StyleDlg *s = &style_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) e->value(s->result); +} +//----------------------------------------------------------------------------- +void font_cb(Fl_Widget *, void *v) +{ + Fl_Input* e = (Fl_Input *)v; + StyleDlg *s = &style_dlg; + s->OK = false; + s->wnd->set_modal(); + s->tab->value(s->ftab); + s->ltab->deactivate(); + s->stab->deactivate(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + e->value(s->result); + s->ltab->activate(); + s->stab->activate(); +} +//----------------------------------------------------------------------------- +void line_cb(Fl_Widget *, void *v) +{ + Fl_Input* e = (Fl_Input *)v; + StyleDlg *s = &style_dlg; + s->OK = false; + s->wnd->set_modal(); + s->tab->value(s->ltab); + s->ftab->deactivate(); + s->stab->deactivate(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + e->value(s->result); + s->ftab->activate(); + s->stab->activate(); +} +//----------------------------------------------------------------------------- +void face_cb(Fl_Widget *, void *v) +{ + Fl_Input* e = (Fl_Input *)v; + StyleDlg *s = &style_dlg; + s->OK = false; + s->wnd->set_modal(); + s->tab->value(s->stab); + s->ltab->deactivate(); + s->ftab->deactivate(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) // replace current selection + e->value(s->result); + s->ltab->activate(); + s->ftab->activate(); +} +//----------------------------------------------------------------------------- diff --git a/mgllab/setup.cpp b/mgllab/setup.cpp new file mode 100644 index 0000000..44309ce --- /dev/null +++ b/mgllab/setup.cpp @@ -0,0 +1,422 @@ +/* setup.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "mgl2/mgl.h" +#include +#include +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +extern int auto_exec, plastic_scheme, internal_font; +//----------------------------------------------------------------------------- +void setup_dlg_cb(Fl_Widget *, void *v) +{ SetupDlg *s = (SetupDlg *)v; s->OK = true; s->wnd->hide(); } +//----------------------------------------------------------------------------- +void setup_sav_cb(Fl_Widget *, void *v) +{ + SetupDlg *e = (SetupDlg *)v; + char *buf = e->ToScript(); + const char *fname; + if(buf[0]) + { + fname = e->templ->value(); + if(fname[0]==0) fname = "template.mgl"; + FILE *fp = fopen(fname,"w"); + fputs(buf,fp); + fclose(fp); + } + free(buf); +} +//----------------------------------------------------------------------------- +void close_dlg_cb(Fl_Widget *, void *v) +{ ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void SetupDlg::CreateGen() +{ + xmin = new Fl_Input(105, 50, 75, 25); xmax = new Fl_Input(105, 80, 75, 25); + ymin = new Fl_Input(190, 50, 75, 25); ymax = new Fl_Input(190, 80, 75, 25); + zmin = new Fl_Input(275, 50, 75, 25); zmax = new Fl_Input(275, 80, 75, 25); + cmin = new Fl_Input(360, 50, 75, 25); cmax = new Fl_Input(360, 80, 75, 25); + + xorg = new Fl_Input(105, 110, 75, 25); + yorg = new Fl_Input(190, 110, 75, 25); + zorg = new Fl_Input(275, 110, 75, 25); + xlab = new Fl_Input(105, 140, 75, 25); + ylab = new Fl_Input(190, 140, 75, 25); + zlab = new Fl_Input(275, 140, 75, 25); + + xpos = new Fl_Choice(105, 170, 75, 25); xpos->add(gettext("at minumum")); + xpos->add("at center"); xpos->add(gettext("at maxumum")); xpos->value(1); + ypos = new Fl_Choice(190, 170, 75, 25); ypos->add(gettext("at minumum")); + ypos->add("at center"); ypos->add(gettext("at maxumum")); ypos->value(1); + zpos = new Fl_Choice(275, 170, 75, 25); zpos->add(gettext("at minumum")); + zpos->add("at center"); zpos->add(gettext("at maxumum")); zpos->value(1); + xtik = new Fl_Input(105, 200, 75, 25); + ytik = new Fl_Input(190, 200, 75, 25); + ztik = new Fl_Input(275, 200, 75, 25); + xsub = new Fl_Input(105, 230, 75, 25); + ysub = new Fl_Input(190, 230, 75, 25); + zsub = new Fl_Input(275, 230, 75, 25); + + { Fl_Box* o = new Fl_Box(10, 260, 470, 5); o->box(FL_DOWN_BOX); } + alphad = new Fl_Input(20, 285, 75, 25, gettext("AlphaDef")); alphad->align(FL_ALIGN_TOP); + ambient = new Fl_Input(105, 285, 75, 25, gettext("Ambient")); ambient->align(FL_ALIGN_TOP); + basew = new Fl_Input(190, 285, 75, 25, gettext("Base Width")); basew->align(FL_ALIGN_TOP); + mesh = new Fl_Input(275, 285, 75, 25, gettext("Mesh Num")); mesh->align(FL_ALIGN_TOP); + axial = new Fl_Choice(360, 285, 75, 25, gettext("Axial Dir")); axial->align(FL_ALIGN_TOP); + axial->add("x"); axial->add("y"); axial->add("z"); + font = new Fl_Input(20, 330, 50, 25, gettext("Font")); font->align(FL_ALIGN_TOP); + { Fl_Button* o = new Fl_Button(70, 330, 25, 25, ".."); o->callback(font_cb, font); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); } + size = new Fl_Input(105, 330, 75, 25, gettext("Font Size")); size->align(FL_ALIGN_TOP); + alpha = new Fl_Check_Button(190, 330, 75, 25, gettext("Alpha on")); + light = new Fl_Check_Button(275, 330, 75, 25, gettext("Light on")); + rotate = new Fl_Check_Button(360, 330, 90, 25, gettext("Rotate text")); +} +//----------------------------------------------------------------------------- +void SetupDlg::CreateLid() +{ + const char *str[10]={"0:", "1:", "2:", "3:", "4:", "5:", "6:", "7:", "8:", "9:"}; + int h; + for(long i=0;i<10;i++) + { + h = 55 + 30*i; + new Fl_Box(10, h, 25, 25, str[i]); + lid[i] = new Fl_Check_Button(35, h, 40, 25, gettext("on")); + xid[i] = new Fl_Input(85, h, 75, 25); + yid[i] = new Fl_Input(165, h, 75, 25); + zid[i] = new Fl_Input(245, h, 75, 25); + cid[i] = new Fl_Choice(325, h, 75, 25); + cid[i]->copy(colors); + bid[i] = new Fl_Input(405, h, 75, 25); + } +} +//----------------------------------------------------------------------------- +void SetupDlg::CreateDlg() +{ + OK = false; + wnd = new Fl_Window(490, 406, gettext("Setup graphics")); + Fl_Tabs* t = new Fl_Tabs(0, 0, 490, 360); t->box(UDAV_UP_BOX); + + Fl_Group *g = new Fl_Group(0, 25, 485, 330, gettext("General")); + new Fl_Box(105, 30, 75, 20, gettext("X axis")); + new Fl_Box(190, 30, 75, 20, gettext("Y axis")); + new Fl_Box(275, 30, 75, 20, gettext("Z axis")); + new Fl_Box(360, 30, 75, 20, gettext("Color")); + + new Fl_Box(25, 50, 75, 25, gettext("Minimal")); + new Fl_Box(25, 80, 75, 25, gettext("Maximal")); + new Fl_Box(25, 110, 75, 25, gettext("Origin")); + new Fl_Box(25, 140, 75, 25, gettext("Label")); + new Fl_Box(25, 170, 75, 25, gettext("Position")); + new Fl_Box(25, 200, 75, 25, gettext("Ticks")); + new Fl_Box(25, 230, 75, 25, gettext("SubTicks")); + CreateGen(); + g->end(); + + g = new Fl_Group(0, 25, 485, 330, gettext("Light")); g->hide(); + new Fl_Box(10, 30, 25, 25, gettext("ID")); + new Fl_Box(40, 30, 40, 25, gettext("State")); + new Fl_Box(85, 30, 75, 25, gettext("X position")); + new Fl_Box(165, 30, 75, 25, gettext("Y position")); + new Fl_Box(245, 30, 75, 25, gettext("Z position")); + new Fl_Box(325, 30, 75, 25, gettext("Color")); + new Fl_Box(405, 30, 75, 25, gettext("Brightness")); + CreateLid(); + g->end(); + + g = new Fl_Group(0, 25, 485, 330, gettext("Setup code")); g->hide(); + code = new Fl_Help_View(0, 25, 485, 330); + g->end(); + + t->end(); //Fl_Group::current()->resizable(t); + Fl_Button *o; + templ = new Fl_Input(120, 370, 110, 25, gettext("Template name")); + templ->value("template.mgl"); + o = new Fl_Button(230, 370, 80, 25, gettext("Save")); o->callback(setup_sav_cb, wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Save settings to file template.mgl.\nYou may use it later by 'call template.mgl'")); + + o = new Fl_Button(315, 370, 80, 25, gettext("Cancel")); o->callback(close_dlg_cb, wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(400, 370, 80, 25, gettext("OK")); o->callback(setup_dlg_cb, this); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +char *SetupDlg::ToScript() +{ + long i; + double x1=0,y1=0,z1=0,x2=0,y2=0,z2=0; + bool u1,v1,w1,u2,v2,w2; + const char *cols = " wbgrcmylenuqphkWBGRCMYLENUQPH"; + char *buf = (char *)malloc(1024*sizeof(char)), str[128]; + long num = 1024, cur = 0; + buf[0]=0; + if(!OK) return buf; + + for(i=0;i<10;i++) // set light sources + { +//fl_message("before %d lid:%d xid:%s yid:%s zid:%s",i,lid[i]->value(), xid[i]->value(),yid[i]->value(),zid[i]->value()); + if(!lid[i]->value()) continue; + if(!xid[i]->value()[0] || !yid[i]->value()[0] || !zid[i]->value()[0]) continue; + x1=atof(xid[i]->value()); y1=atof(yid[i]->value()); z1=atof(zid[i]->value()); + if(!bid[i]->value()[0]) + cur += snprintf(str,128,"light %ld %g %g %g '%c'\n",i,x1,y1,z1, + cols[cid[i]->value()]); + else + cur += snprintf(str,128,"light %ld %g %g %g '%c' %g\n",i,x1,y1,z1, + cols[cid[i]->value()],atof(bid[i]->value())); + strcat(buf,str); + } + u1 = xmin->value()[0]; if(u1) x1 = atof(xmin->value()); + u2 = xmax->value()[0]; if(u2) x2 = atof(xmax->value()); + v1 = ymin->value()[0]; if(v1) y1 = atof(ymin->value()); + v2 = ymin->value()[0]; if(v2) y2 = atof(ymax->value()); + w1 = zmin->value()[0]; if(w1) z1 = atof(zmin->value()); + w2 = zmin->value()[0]; if(w2) z2 = atof(zmax->value()); + if(u1&&v1&&w1&&u2&&v2&&w2) + { + cur+=snprintf(str,128,"axis %g %g %g %g %g %g\n",x1,y1,z1,x2,y2,z2); + strcat(buf,str); + } + else + { + if(u1 && u2) {cur+=snprintf(str,128,"xrange %g %g\n",x1,x2); strcat(buf,str);} + if(v1 && v2) {cur+=snprintf(str,128,"yrange %g %g\n",y1,y2); strcat(buf,str);} + if(w1 && w2) {cur+=snprintf(str,128,"zrange %g %g\n",z1,z2); strcat(buf,str);} + } + u1 = cmin->value()[0]; if(u1) x1 = atof(cmin->value()); + u2 = cmax->value()[0]; if(u2) x2 = atof(cmax->value()); + if(u1&&u2) {cur+=snprintf(str,128,"crange %g %g\n",x1,x2); strcat(buf,str);} + if(cur>num-256) { num+=512; buf = (char *)realloc(buf,num*sizeof(char)); } + + u1 = xorg->value()[0]; if(u1) x1 = atof(xorg->value()); + v1 = yorg->value()[0]; if(v1) y1 = atof(yorg->value()); + w1 = zorg->value()[0]; if(w1) z1 = atof(zorg->value()); + if(u1&&v1&&w1) {snprintf(str,128,"origin %g %g %g\n",x1,y1,z1); strcat(buf,str);} + + u1 = xtik->value()[0]; if(u1) x1 = atof(xtik->value()); + u2 = xsub->value()[0]; if(u2) x2 = atoi(xsub->value()); + v1 = ytik->value()[0]; if(v1) y1 = atof(ytik->value()); + v2 = ysub->value()[0]; if(v2) y2 = atoi(ysub->value()); + w1 = ztik->value()[0]; if(w1) z1 = atof(ztik->value()); + w2 = zsub->value()[0]; if(w2) z2 = atoi(zsub->value()); + if(u1 && u2) {cur+=snprintf(str,128,"xtick %g %g\n",x1,x2); strcat(buf,str);} + if(v1 && v2) {cur+=snprintf(str,128,"ytick %g %g\n",y1,y2); strcat(buf,str);} + if(w1 && w2) {cur+=snprintf(str,128,"ztick %g %g\n",z1,z2); strcat(buf,str);} + if(u1 && !u2) {cur+=snprintf(str,128,"xtick %g\n",x1); strcat(buf,str);} + if(v1 && !v2) {cur+=snprintf(str,128,"ytick %g\n",y1); strcat(buf,str);} + if(w1 && !w2) {cur+=snprintf(str,128,"ztick %g\n",z1); strcat(buf,str);} + + if(xlab->value()[0]) + { + cur+=snprintf(str,128,"xlabel '%s' %d\n",xlab->value(), xpos->value()-1); + strcat(buf,str); + } + if(ylab->value()[0]) + { + cur+=snprintf(str,128,"ylabel '%s' %d\n",ylab->value(), ypos->value()-1); + strcat(buf,str); + } + if(zlab->value()[0]) + { + cur+=snprintf(str,128,"zlabel '%s' %d\n",zlab->value(), zpos->value()-1); + strcat(buf,str); + } + if(alphad->value()[0]) + { + cur+=snprintf(str,128,"alphadef %g\n",atof(alphad->value())); + strcat(buf,str); + } + if(ambient->value()[0]) + { + cur+=snprintf(str,128,"ambient %g\n",atof(ambient->value())); + strcat(buf,str); + } + + if(basew->value()[0]) + { + cur+=snprintf(str,128,"baselinewidth %g\n",atof(basew->value())); + strcat(buf,str); + } + if(mesh->value()[0]) + { + cur+=snprintf(str,128,"meshnum %g\n",atof(mesh->value())); + strcat(buf,str); + } + if(axial->value()>=0) + { + cur+=snprintf(str,128,"axialdir '%c'\n",'x'+axial->value()); + strcat(buf,str); + } + + if(font->value()[0]) + { + cur+=snprintf(str,128,"font '%s'",font->value()); + strcat(buf,str); + if(size->value()) cur+=snprintf(str,128," %g\n",atof(size->value())); + else cur+=snprintf(str,128,"\n"); + strcat(buf,str); + } + if(rotate->value()) {cur+=snprintf(str,128,"rotatetext on\n"); strcat(buf,str);} + + if(alpha->value()) {cur+=snprintf(str,128,"alpha on\n"); strcat(buf,str);} + if(light->value()) {cur+=snprintf(str,128,"light on\n"); strcat(buf,str);} + + code->value(buf); + return buf; +} +//----------------------------------------------------------------------------- +void setup_cb(Fl_Widget *, void *d) +{ + if(d==0) return; + SetupDlg *s = ((ScriptWindow *)d)->setup_dlg; + s->OK = false; + s->wnd->set_modal(); + s->wnd->show(); + while(s->wnd->shown()) Fl::wait(); + if(s->OK) ((ScriptWindow *)d)->graph->update(); +} +//----------------------------------------------------------------------------- +Fl_Menu_Item colors[] = { + {"-----", 0,0,0,0,0,0,0, 0}, // + {("white"), 0,0,0,0,0,0,0, fl_rgb_color(0,0,0)}, //w + {("blue"), 0,0,0,0,0,0,0, fl_rgb_color(0,0,255)}, //b + {("lime"), 0,0,0,0,0,0,0, fl_rgb_color(0,255,0)}, //g + {("red"), 0,0,0,0,0,0,0, fl_rgb_color(255,0,0)}, //r + {("cyan"), 0,0,0,0,0,0,0, fl_rgb_color(0,255,255)}, //c + {("magenta"), 0,0,0,0,0,0,0, fl_rgb_color(255,0,255)}, //m + {("yellow"), 0,0,0,0,0,0,0, fl_rgb_color(255,255,0)}, //y + {("springgreen"), 0,0,0,0,0,0,0, fl_rgb_color(0,255,127)},//l + {("lawngreen"), 0,0,0,0,0,0,0, fl_rgb_color(127,255,0)}, //e + {("skyblue"), 0,0,0,0,0,0,0, fl_rgb_color(0,127,255)}, //n + {("blueviolet"), 0,0,0,0,0,0,0, fl_rgb_color(127,0,255)}, //u + {("orange"), 0,0,0,0,0,0,0, fl_rgb_color(255,127,0)}, //q + {("deeppink"), 0,0,0,0,0,0,0, fl_rgb_color(255,0,127)}, //p + {("gray"), 0,0,0,0,0,0,0, fl_rgb_color(127,127,127)}, //h + + {("black"), 0,0,0,0,0,0,0, fl_rgb_color(0,0,0)}, //k + {("lightgray"), 0,0,0,0,0,0,0, fl_rgb_color(179,179,179)}, //W + {("navy"), 0,0,0,0,0,0,0, fl_rgb_color(0,0,127)}, //B + {("green"), 0,0,0,0,0,0,0, fl_rgb_color(0,127,0)}, //G + {("maroon"), 0,0,0,0,0,0,0, fl_rgb_color(127,0,0)}, //R + {("teal"), 0,0,0,0,0,0,0, fl_rgb_color(0,127,127)}, //C + {("purple"), 0,0,0,0,0,0,0, fl_rgb_color(127,0,127)}, //M + {("olive"), 0,0,0,0,0,0,0, fl_rgb_color(127,127,0)}, //Y + {("seagreen"), 0,0,0,0,0,0,0, fl_rgb_color(0,127,77)}, //L + {("darklawn"), 0,0,0,0,0,0,0, fl_rgb_color(77,127,0)}, //E + {("darkskyblue"), 0,0,0,0,0,0,0, fl_rgb_color(0,77,127)}, //N + {("indigo"), 0,0,0,0,0,0,0, fl_rgb_color(77,0,127)}, //U + {("brown"), 0,0,0,0,0,0,0, fl_rgb_color(127,77,0)}, //Q + {("darkpink"), 0,0,0,0,0,0,0, fl_rgb_color(127,0,77)}, //P + {("darkgray"), 0,0,0,0,0,0,0, fl_rgb_color(77,77,77)}, //H +{0, 0,0,0,0,0,0,0, 0}}; +//----------------------------------------------------------------------------- +struct PropDlg +{ + Fl_Window *wnd; + Fl_MGL *graph; + + Fl_Input *path, *locale, *font, *fpath; + Fl_Check_Button *plast, *aexec, *ifont; + PropDlg() { memset(this,0,sizeof(PropDlg)); create_dlg(); } + ~PropDlg() { delete wnd; } + void create_dlg(); + void finish(); + void init(); +} prop_dlg; +//----------------------------------------------------------------------------- +void PropDlg::init() +{ + int a, p; + char *buf; + pref.get("plastic_scheme",p,1); plast->value(p); + pref.get("auto_exec",a,1); aexec->value(a); + pref.get("internal_font",a,0); ifont->value(a); + path->value(docdir); + pref.get("font_dir",buf,""); fpath->value(buf); free(buf); + pref.get("font_name",buf,""); font->value(buf); free(buf); + pref.get("locale",buf,"ru_RU.cp1251"); locale->value(buf); free(buf); +} +//----------------------------------------------------------------------------- +void PropDlg::finish() +{ + int a, p; + p = plast->value(); + if(p!=plastic_scheme) + { + plastic_scheme = p; + pref.set("plastic_scheme",p); + Fl::scheme(p?"plastic":"none"); + } + a = aexec->value(); + if(a!=auto_exec) + { + auto_exec = a; + pref.set("auto_exec",a); + } + a = ifont->value(); + if(a!=internal_font) + { + internal_font = a; + pref.set("internal_font",a); + } + if(path->value()[0]) pref.set("help_dir",path->value()); + if(locale->value()[0]) + { + pref.set("locale", locale->value()); + setlocale(LC_CTYPE, locale->value()); + } + pref.set("font_dir",fpath->value()); + pref.set("font_name",font->value()); + if(graph) mgl_load_font(graph->FMGL->get_graph(), font->value(), fpath->value()); +} +//----------------------------------------------------------------------------- +void prop_dlg_cb(Fl_Widget *, void *v) +{ prop_dlg.finish(); ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void PropDlg::create_dlg() +{ + wnd = new Fl_Double_Window(320, 300, gettext("UDAV settings")); + path = new Fl_Input(10, 25, 305, 25, gettext("Path for help files")); path->align(FL_ALIGN_TOP_LEFT); + + font = new Fl_Input(10, 75, 305, 25, gettext("Font typeface")); font->align(FL_ALIGN_TOP_LEFT); + fpath = new Fl_Input(10, 125, 305, 25, gettext("Path for font files")); fpath->align(FL_ALIGN_TOP_LEFT); + locale = new Fl_Input(10, 175, 305, 25, gettext("Select locale")); locale->align(FL_ALIGN_TOP_LEFT); + + plast = new Fl_Check_Button(10, 210, 210, 25, gettext("Use plastic scheme")); + aexec = new Fl_Check_Button(10, 240, 210, 25, gettext("Execute after script loading")); + ifont = new Fl_Check_Button(10, 270, 210, 25, gettext("Use only internal font")); + + Fl_Button *o; + o = new Fl_Button(240, 210, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o = new Fl_Return_Button(240, 240, 75, 25, gettext("OK")); o->callback(prop_dlg_cb,wnd); + wnd->end(); +} +//----------------------------------------------------------------------------- +void settings_cb(Fl_Widget *, void *v) +{ + PropDlg *s = &prop_dlg; + s->graph = ((ScriptWindow *)v)->graph; + s->init(); + s->wnd->set_modal(); + s->wnd->show(); +} +//----------------------------------------------------------------------------- diff --git a/mgllab/table.cpp b/mgllab/table.cpp new file mode 100644 index 0000000..313706d --- /dev/null +++ b/mgllab/table.cpp @@ -0,0 +1,875 @@ +/* table.cpp is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include +#include +#include +#include +#include +#include "udav.h" +//----------------------------------------------------------------------------- +void addto_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *s = fl_input(gettext("Enter number for addition to data values"),0); + if(s) { mgl_data_add_num(e->var, atof(s)); e->refresh(); } +} +//----------------------------------------------------------------------------- +void subto_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *s = fl_input(gettext("Enter number for subtraction from data values"),0); + if(s) { mgl_data_sub_num(e->var, atof(s)); e->refresh(); } +} +//----------------------------------------------------------------------------- +void multo_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *s = fl_input(gettext("Enter number for multiplication of data values"),0); + if(s) { mgl_data_mul_num(e->var, atof(s)); e->refresh(); } +} +//----------------------------------------------------------------------------- +void divto_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *s = fl_input(gettext("Enter number for division of data values"),0); + if(s) { mgl_data_div_num(e->var, atof(s)); e->refresh(); } +} +//----------------------------------------------------------------------------- +struct XYZDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Box *box; + Fl_Check_Button *ch; + Fl_Spinner *mx, *my, *mz; + XYZDlg() { memset(this,0,sizeof(XYZDlg)); create_dlg(); } + ~XYZDlg() { delete wnd; } + void create_dlg(); +} xyz_dlg; +//----------------------------------------------------------------------------- +void xyz_dlg_cb(Fl_Widget *, void *v) +{ xyz_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void XYZDlg::create_dlg() +{ + wnd = new Fl_Double_Window(325, 125, gettext("Change data sizes")); + box = new Fl_Box(10, 10, 305, 40); + box->box(UDAV_THIN_UP_BOX); + box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); + + mx = new Fl_Spinner(30, 55, 75, 25, "mx"); + mx->tooltip(gettext("New size of data on 1st dimension (x-direction)")); + my = new Fl_Spinner(135, 55, 75, 25, "my"); + my->tooltip(gettext("New size of data on 2nd dimension (y-direction)")); + mz = new Fl_Spinner(240, 55, 75, 25, "mz"); + mz->tooltip(gettext("New size of data on 3d dimension (z-direction)")); + ch = new Fl_Check_Button(15, 90, 95, 25); + + Fl_Button *o; + o = new Fl_Button(125, 90, 85, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Do nothing and close this window")); + o = new Fl_Return_Button(230, 90, 85, 25, gettext("Change"));o->callback(xyz_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Change (resize) data")); + wnd->end(); +} +//----------------------------------------------------------------------------- +void new_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + xyz_dlg.box->label(gettext("Specify new data size\nData will be zero filled")); + xyz_dlg.ch->label(gettext("not used")); xyz_dlg.OK = false; + xyz_dlg.wnd->set_modal(); xyz_dlg.wnd->show(); + while(xyz_dlg.wnd->shown()) Fl::wait(); + if(xyz_dlg.OK) + { + e->var->Create(int(xyz_dlg.mx->value()), + int(xyz_dlg.my->value()), int(xyz_dlg.mz->value())); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +void resize_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + xyz_dlg.box->label(gettext("Specify new data size\nData will be interpolated")); + xyz_dlg.ch->label(gettext("not used")); xyz_dlg.OK = false; + xyz_dlg.wnd->set_modal(); xyz_dlg.wnd->show(); + while(xyz_dlg.wnd->shown()) Fl::wait(); + if(xyz_dlg.OK) + { + mglData d = e->var->Resize(int(xyz_dlg.mx->value()), int(xyz_dlg.my->value()), int(xyz_dlg.mz->value())); + mgl_data_set(e->var, &d); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +void squeeze_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + xyz_dlg.box->label(gettext("Specify the skiping step\nEach m-th point will be skiped")); + xyz_dlg.ch->label(gettext("smoothed")); xyz_dlg.OK = false; + xyz_dlg.wnd->set_modal(); xyz_dlg.wnd->show(); + while(xyz_dlg.wnd->shown()) Fl::wait(); + if(xyz_dlg.OK) + { + e->var->Squeeze(int(xyz_dlg.mx->value()), int(xyz_dlg.my->value()), + int(xyz_dlg.mz->value()), xyz_dlg.ch->value()); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +struct ChngDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Check_Button *dx, *dy, *dz; + Fl_Choice *kind, *type; + ChngDlg() { memset(this,0,sizeof(ChngDlg)); create_dlg(); } + ~ChngDlg() { delete wnd; } + void create_dlg(); + void execute(mglData *d); +} chng_dlg; +//----------------------------------------------------------------------------- +void chng_dlg_cb(Fl_Widget *, void *v) +{ chng_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void ChngDlg::execute(mglData *d) +{ + char r[8]="3"; + if(dx->value()) strcat(r,"x"); + if(dy->value()) strcat(r,"y"); + if(dz->value()) strcat(r,"z"); + if(!r[0]) return; + if(type->value()==1) r[0] = '5'; + if(type->value()==2) r[0] = ' '; + switch(kind->value()) + { + case 0: d->Smooth(r); break; + case 1: d->CumSum(r); break; + case 2: d->Integral(r); break; + case 3: d->Diff(r); break; + case 4: d->Diff2(r); break; + case 5: d->Swap(r); break; + } +} +//----------------------------------------------------------------------------- +void ChngDlg::create_dlg() +{ + Fl_Menu_Item k[]={{gettext("Smooth")}, {gettext("CumSum")}, { gettext("Integrate")}, + { gettext("Difference")}, { gettext("Double diff.")}, { gettext("Swap parts")}, {0}}; + Fl_Menu_Item t[]={{gettext("Linear *3")}, {gettext("Linear *5")}, {gettext("Parabolic *5")},{0}}; + wnd = new Fl_Double_Window(165, 215, gettext("Change data")); + kind = new Fl_Choice(10, 25, 145, 25, gettext("Type of operation")); + kind->align(FL_ALIGN_TOP_LEFT); kind->copy(k); + dx = new Fl_Check_Button(10, 55, 140, 25, gettext("apply in x direction")); + dy = new Fl_Check_Button(10, 80, 140, 25, gettext("apply in y direction")); + dz = new Fl_Check_Button(10, 105, 140, 25, gettext("apply in z direction")); + type = new Fl_Choice(10, 145, 145, 25, gettext("Type of smoothing")); + type->align(FL_ALIGN_TOP_LEFT); type->copy(t); + + Fl_Button *o; + o = new Fl_Button(10, 180, 65, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(90, 180, 65, 25, gettext("Do"));o->callback(chng_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +void smooth_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(0); + chng_dlg.type->activate(); chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +void cumsum_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(1); + chng_dlg.type->deactivate();chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +void integr_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(2); + chng_dlg.type->deactivate();chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +void diff_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(3); + chng_dlg.type->deactivate();chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +void diff2_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(4); + chng_dlg.type->deactivate();chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +void swap_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + chng_dlg.kind->value(5); + chng_dlg.type->deactivate();chng_dlg.OK = false; + chng_dlg.wnd->set_modal(); chng_dlg.wnd->show(); + while(chng_dlg.wnd->shown()) Fl::wait(); + if(chng_dlg.OK) + { chng_dlg.execute(e->var); e->refresh(); } +} +//----------------------------------------------------------------------------- +struct NwdtDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Check_Button *dx, *dy, *dz; + Fl_Choice *kind; + Fl_Input *name; + NwdtDlg() { memset(this,0,sizeof(NwdtDlg)); create_dlg(); } + ~NwdtDlg() { delete wnd; } + void create_dlg(); +} nwdt_dlg; +//----------------------------------------------------------------------------- +void nwdt_dlg_cb(Fl_Widget *, void *v) +{ nwdt_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void NwdtDlg::create_dlg() +{ + Fl_Menu_Item k[]={{gettext("Summation of")}, {gettext("Maximum of")}, { gettext("Minimum of")}, {0}}; + wnd = new Fl_Double_Window(165, 215, gettext("Extract data")); + kind = new Fl_Choice(10, 25, 145, 25, gettext("Type of operation")); + kind->align(FL_ALIGN_TOP_LEFT); kind->copy(k); + dx = new Fl_Check_Button(10, 55, 140, 25, gettext("apply in x direction")); + dy = new Fl_Check_Button(10, 80, 140, 25, gettext("apply in y direction")); + dz = new Fl_Check_Button(10, 105, 140, 25, gettext("apply in z direction")); + name = new Fl_Input(10, 145, 145, 25, gettext("Name for output")); + name->align(FL_ALIGN_TOP_LEFT); + + Fl_Button *o; + o = new Fl_Button(10, 180, 65, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o = new Fl_Return_Button(90, 180, 65, 25, gettext("Do"));o->callback(chng_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + wnd->end(); +} +//----------------------------------------------------------------------------- +void asum_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + nwdt_dlg.kind->value(0); nwdt_dlg.OK = false; + nwdt_dlg.wnd->set_modal(); nwdt_dlg.wnd->show(); + while(nwdt_dlg.wnd->shown()) Fl::wait(); + if(nwdt_dlg.OK) + { + char r[8]=""; + if(nwdt_dlg.dx->value()) strcat(r,"x"); + if(nwdt_dlg.dy->value()) strcat(r,"y"); + if(nwdt_dlg.dz->value()) strcat(r,"z"); + if(!r[0]) return; + if(!nwdt_dlg.name->value()[0] || !strcmp(nwdt_dlg.name->value(),e->label())) + fl_alert(gettext("Name for output variable should be differ from this name")); + else + { + mglData d = e->var->Sum(r); + mgl_data_set(Parse->AddVar(nwdt_dlg.name->value()), &d); + } + } +} +//----------------------------------------------------------------------------- +void amax_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + nwdt_dlg.kind->value(0); nwdt_dlg.OK = false; + nwdt_dlg.wnd->set_modal(); nwdt_dlg.wnd->show(); + while(nwdt_dlg.wnd->shown()) Fl::wait(); + if(nwdt_dlg.OK) + { + char r[8]=""; + if(nwdt_dlg.dx->value()) strcat(r,"x"); + if(nwdt_dlg.dy->value()) strcat(r,"y"); + if(nwdt_dlg.dz->value()) strcat(r,"z"); + if(!r[0]) return; + if(!nwdt_dlg.name->value()[0] || !strcmp(nwdt_dlg.name->value(),e->label())) + fl_alert(gettext("Name for output variable should be differ from this name")); + else + { + mglData d = e->var->Max(r); + mgl_data_set(Parse->AddVar(nwdt_dlg.name->value()), &d); + } + } +} +//----------------------------------------------------------------------------- +void amin_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + nwdt_dlg.kind->value(0); nwdt_dlg.OK = false; + nwdt_dlg.wnd->set_modal(); nwdt_dlg.wnd->show(); + while(nwdt_dlg.wnd->shown()) Fl::wait(); + if(nwdt_dlg.OK) + { + char r[8]=""; + if(nwdt_dlg.dx->value()) strcat(r,"x"); + if(nwdt_dlg.dy->value()) strcat(r,"y"); + if(nwdt_dlg.dz->value()) strcat(r,"z"); + if(!r[0]) return; + if(!nwdt_dlg.name->value()[0] || !strcmp(nwdt_dlg.name->value(), e->label())) + fl_alert(gettext("Name for output variable should be differ from this name")); + else + { + mglData d = e->var->Min(r); + mgl_data_set(Parse->AddVar(nwdt_dlg.name->value()), &d); + } + } +} +//----------------------------------------------------------------------------- +void load_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + char *newfile = fl_file_chooser(gettext("Load Data?"), + gettext("DAT Files (*.{dat,csv})\tAll Files (*)"), 0); + if(newfile != NULL) + { e->var->Read(newfile); e->refresh(); } +} +//----------------------------------------------------------------------------- +void save_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + char *newfile = fl_file_chooser(gettext("Save Data?"), + gettext("DAT Files (*.{dat,csv})\tAll Files (*)"), 0); + if(newfile != NULL) e->var->Save(newfile); +} +//----------------------------------------------------------------------------- +void exp_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *scheme, *newfile = fl_file_chooser(gettext("Export Data?"), + gettext("PNG Files (*.png)\tAll Files (*)"), 0); + if(newfile != NULL) + { + scheme = fl_input(gettext("Enter color scheme"),MGL_DEF_SCH); + if(scheme) e->var->Export(newfile,scheme); + } +} +//----------------------------------------------------------------------------- +void imp_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *scheme, *newfile = fl_file_chooser(gettext("Import Data?"), + gettext("PNG Files (*.png)\tAll Files (*)"), 0); + if (newfile != NULL) + { + scheme = fl_input(gettext("Enter color scheme"),MGL_DEF_SCH); + if(scheme) + { e->var->Import(newfile,scheme); e->refresh(); } + } +} +//----------------------------------------------------------------------------- +void list_dat_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + mglData *d = e->var; + if(d->nx*d->ny+d->ny>1020) + { fl_message(gettext("Too many numbers (>1000) on slice")); return; } + if(d->nz>1) fl_message(gettext("Only current slice will be inserted")); + char *list = new char[16384]; + strcpy(list,"list\t"); + register long i,j; + char s[32]; + for(j=0;jny;j++) + { + for(i=0;inx;i++) + { + snprintf(s,32,"%g\t",d->a[i+d->nx*(j+e->get_slice()*d->ny)]); + strcat(list,s); + } + if(jny-1) strcat(list,"|\t"); + } + textbuf->insert(0,list); + delete []list; +} +//----------------------------------------------------------------------------- +void modify_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + const char *eq=fl_input(gettext("Enter formula for data modification\nHere x, y, z in range [0,1], u is data value"),0); + if (eq != NULL) { e->var->Modify(eq); e->refresh(); } +} +//----------------------------------------------------------------------------- +void plot_dat_cb(Fl_Widget *, void *v); +//----------------------------------------------------------------------------- +struct NrmDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Value_Input *min, *max; + Fl_Choice *dir; + Fl_Check_Button *sym; + NrmDlg() { memset(this,0,sizeof(NrmDlg)); create_dlg(); } + ~NrmDlg() { delete wnd; } + void create_dlg(); +} nrm_dlg; +//----------------------------------------------------------------------------- +void nrm_dlg_cb(Fl_Widget *, void *v) +{ nrm_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void NrmDlg::create_dlg() +{ + Fl_Menu_Item k[]={{"x"}, {"y"}, { "z"}, {0}}; + wnd = new Fl_Double_Window(135, 215); + min = new Fl_Value_Input(10, 25, 115, 25, gettext("Minimal value (v1)")); + min->align(FL_ALIGN_TOP_LEFT); + min->tooltip(gettext("Minimal value for resulting data values")); + max = new Fl_Value_Input(10, 70, 115, 25, gettext("Maximal value (v2)")); + max->align(FL_ALIGN_TOP_LEFT); + max->tooltip(gettext("Maximal value for resulting data values")); + dir = new Fl_Choice(10, 115, 115, 25, gettext("Direction")); + dir->align(FL_ALIGN_TOP_LEFT); dir->copy(k); + dir->tooltip(gettext("Direction along which data will be filled")); + sym = new Fl_Check_Button(10, 115, 115, 25, gettext("Symetrical range")); + sym->tooltip(gettext("Normalize in symmetrical range: -max(|v1|,|v2|) ... max(|v1|,|v2|)")); + + Fl_Button *o; + o = new Fl_Button(25, 150, 85, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Do nothing and close this window")); + o = new Fl_Return_Button(25, 180, 85, 25, gettext("Change"));o->callback(nrm_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Change data values and close this window")); + wnd->end(); +} +//----------------------------------------------------------------------------- +void fill_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + nrm_dlg.OK = false; nrm_dlg.wnd->label(gettext("Fill in range")); + nrm_dlg.dir->show(); nrm_dlg.sym->hide(); + nrm_dlg.wnd->set_modal(); nrm_dlg.wnd->show(); + while(nrm_dlg.wnd->shown()) Fl::wait(); + if(nrm_dlg.OK) + { + char r='x'; + if(nrm_dlg.dir->value()==1) r='y'; + if(nrm_dlg.dir->value()==2) r='z'; + e->var->Fill(nrm_dlg.min->value(),nrm_dlg.max->value(),r); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +void normal_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + nrm_dlg.OK = false; nrm_dlg.wnd->label(gettext("Normalize data")); + nrm_dlg.dir->hide(); nrm_dlg.sym->show(); + nrm_dlg.wnd->set_modal(); nrm_dlg.wnd->show(); + while(nrm_dlg.wnd->shown()) Fl::wait(); + if(nrm_dlg.OK) + { + e->var->Norm(nrm_dlg.min->value(), nrm_dlg.max->value(), nrm_dlg.sym->value()); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +struct CropDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Input *x1,*x2, *y1,*y2, *z1,*z2; + CropDlg() { memset(this,0,sizeof(CropDlg)); create_dlg(); } + ~CropDlg() { delete wnd; } + void create_dlg(); +} crop_dlg; +//----------------------------------------------------------------------------- +void crop_dlg_cb(Fl_Widget *, void *v) +{ crop_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void CropDlg::create_dlg() +{ + wnd = new Fl_Double_Window(230, 155, gettext("Crop data")); + x1 = new Fl_Input(45, 25, 80, 25, gettext("Lower bound")); x1->align(FL_ALIGN_TOP); + x2 = new Fl_Input(140, 25, 80, 25, gettext("Upper bound")); x2->align(FL_ALIGN_TOP); + y1 = new Fl_Input(45, 55, 80, 25); + y2 = new Fl_Input(140, 55, 80, 25); + z1 = new Fl_Input(45, 85, 80, 25); + z2 = new Fl_Input(140, 85, 80, 25); + + new Fl_Box(15, 25, 25, 25, "X"); + new Fl_Box(15, 55, 25, 25, "Y"); + new Fl_Box(15, 85, 25, 25, "Z"); + Fl_Button *o; + o = new Fl_Button(45, 120, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Do nothing and close this window")); + o = new Fl_Return_Button(145, 120, 75, 25, gettext("Crop")); o->callback(crop_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Change data values and close this window")); + wnd->end(); +} +//----------------------------------------------------------------------------- +void crop_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + crop_dlg.OK = false; + crop_dlg.wnd->set_modal(); crop_dlg.wnd->show(); + while(crop_dlg.wnd->shown()) Fl::wait(); + if(crop_dlg.OK) + { + int n1,n2; + n1 = 0; n2 = e->var->nx; + if(crop_dlg.x1->value()[0]) n1 = atoi(crop_dlg.x1->value()); + if(crop_dlg.x2->value()[0]) n2 = atoi(crop_dlg.x2->value()); + e->var->Crop(n1, n2, 'x'); + n1 = 0; n2 = e->var->ny; + if(crop_dlg.y1->value()[0]) n1 = atoi(crop_dlg.y1->value()); + if(crop_dlg.y2->value()[0]) n2 = atoi(crop_dlg.y2->value()); + e->var->Crop(n1, n2, 'y'); + n1 = 0; n2 = e->var->nz; + if(crop_dlg.z1->value()[0]) n1 = atoi(crop_dlg.z1->value()); + if(crop_dlg.z2->value()[0]) n2 = atoi(crop_dlg.z2->value()); + e->var->Crop(n1, n2, 'z'); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +struct TrspDlg +{ + Fl_Window *wnd; + bool OK; + + Fl_Round_Button *xyz, *xzy, *yxz, *yzx, *zxy, *zyx; + TrspDlg() { memset(this,0,sizeof(TrspDlg)); create_dlg(); } + ~TrspDlg() { delete wnd; } + void create_dlg(); +} trsp_dlg; +//----------------------------------------------------------------------------- +void trsp_dlg_cb(Fl_Widget *, void *v) +{ trsp_dlg.OK = true; ((Fl_Window *)v)->hide(); } +//----------------------------------------------------------------------------- +void trsp_rad_cb(Fl_Widget *w, void *v) +{ + TrspDlg* e = (TrspDlg*)v; + e->xyz->value(0); e->xzy->value(0); + e->yxz->value(0); e->yzx->value(0); + e->zxy->value(0); e->zyx->value(0); + ((Fl_Round_Button *)w)->setonly(); +} +//----------------------------------------------------------------------------- +void TrspDlg::create_dlg() +{ + wnd = new Fl_Double_Window(220, 170, gettext("Transpose data")); + Fl_Group *g = new Fl_Group(10, 30, 200, 90, gettext("Select new order of dimensions")); + g->box(FL_DOWN_BOX); + yxz = new Fl_Round_Button(20, 40, 75, 25, "y - x - z"); yxz->callback(trsp_rad_cb,this); + zyx = new Fl_Round_Button(20, 65, 75, 25, "z - y - x"); zyx->callback(trsp_rad_cb,this); + zxy = new Fl_Round_Button(20, 90, 75, 25, "z - x - y"); zxy->callback(trsp_rad_cb,this); + yzx = new Fl_Round_Button(100, 40, 75, 25, "y - z - x");yzx->callback(trsp_rad_cb,this); + xzy = new Fl_Round_Button(100, 65, 75, 25, "x - z - y");xzy->callback(trsp_rad_cb,this); + xyz = new Fl_Round_Button(100, 90, 75, 25, "x - y - z");xyz->callback(trsp_rad_cb,this); + g->end(); + + Fl_Button *o; + o = new Fl_Button(25, 130, 75, 25, gettext("Cancel")); o->callback(close_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Do nothing and close this window")); + o = new Fl_Return_Button(125, 130, 75, 25, gettext("Do")); o->callback(trsp_dlg_cb,wnd); + o->box(UDAV_UP_BOX); o->down_box(UDAV_DOWN_BOX); + o->tooltip(gettext("Change data values and close this window")); + wnd->end(); +} +//----------------------------------------------------------------------------- +void transp_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + trsp_dlg.OK = false; + trsp_dlg.wnd->set_modal(); trsp_dlg.wnd->show(); + while(trsp_dlg.wnd->shown()) Fl::wait(); + if(trsp_dlg.OK) + { + if(trsp_dlg.xyz->value()) e->var->Transpose("xyz"); + if(trsp_dlg.xzy->value()) e->var->Transpose("xzy"); + if(trsp_dlg.yxz->value()) e->var->Transpose("yxz"); + if(trsp_dlg.yzx->value()) e->var->Transpose("yzx"); + if(trsp_dlg.zxy->value()) e->var->Transpose("zxy"); + if(trsp_dlg.zyx->value()) e->var->Transpose("zyx"); + e->refresh(); + } +} +//----------------------------------------------------------------------------- +void first_sl_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + e->slice->value(0); + e->set_slice(0); + e->go_home(); +} +//----------------------------------------------------------------------------- +void last_sl_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + e->slice->value(e->num_slice()-1); + e->set_slice(e->num_slice()-1); + e->go_home(); +} +//----------------------------------------------------------------------------- +void prev_sl_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + int p = int(e->slice->value())-1; + if(p<0) p = 0; + e->slice->value(p); e->set_slice(p); + e->go_home(); +} +//----------------------------------------------------------------------------- +void next_sl_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + int p = int(e->slice->value())+1; + if(p>=e->num_slice()) p = e->num_slice()-1; + e->slice->value(p); e->set_slice(p); + e->go_home(); +} +//----------------------------------------------------------------------------- +void first_cl_cb(Fl_Widget*, void*v) +{ + TableWindow* e = (TableWindow*)v; + e->go_home(); +} +//----------------------------------------------------------------------------- +void change_sl_cb(Fl_Widget*w, void*v) +{ + TableWindow* e = (TableWindow*)v; + e->set_slice(long(e->slice->value())); + e->go_home(); +} +//----------------------------------------------------------------------------- +Fl_Menu_Item tablemenu[60] = { + { gettext("General"), 0, 0, 0, FL_SUBMENU }, + { gettext("Load from file"), 0, load_dat_cb }, + { gettext("Import from PNG"),0, imp_dat_cb }, + { gettext("Save to file"), 0, save_dat_cb }, + { gettext("Export to PNG"), 0, exp_dat_cb, 0, FL_MENU_DIVIDER }, + { gettext("Insert as list"), 0, list_dat_cb }, + { gettext("Plot data"), 0, plot_dat_cb }, +// { gettext("Info for data"), 0, info_dat_cb }, + { 0 }, + { gettext("Sizes"), 0, 0, 0, FL_SUBMENU }, + { gettext("Create new"), 0, new_dat_cb }, + { gettext("Resize"), 0, resize_cb }, + { gettext("Squeeze"), 0, squeeze_cb }, + { gettext("Crop"), 0, crop_cb }, + { gettext("Transpose"), 0, transp_cb }, +// { gettext("Extend"), 0, extend_cb }, + { 0 }, + { gettext("Fill"), 0, 0, 0, FL_SUBMENU }, + { gettext("By formula"), 0, modify_cb }, + { gettext("In range"), 0, fill_cb }, + { gettext("Normalize"), 0, normal_cb }, + { 0 }, + { gettext("Change"), 0, 0, 0, FL_SUBMENU }, + { gettext("Smooth"), 0, smooth_cb }, + { gettext("CumSum"), 0, cumsum_cb }, + { gettext("Integrate"), 0, integr_cb }, + { gettext("Difference"), 0, diff_cb }, + { gettext("Double diff."), 0, diff2_cb }, + { gettext("Swap parts"), 0, swap_cb }, + { 0 }, + { gettext("Another"), 0, 0, 0, FL_SUBMENU }, +// { gettext("Histogram of"), 0, hist_cb }, + { gettext("Summation of"), 0, asum_cb }, + { gettext("Maximum of"), 0, amax_cb }, + { gettext("Minimum of"), 0, amin_cb }, + { 0 }, + { gettext("Operations"), 0, 0, 0, FL_SUBMENU }, + { gettext("Add to"), 0, addto_cb }, + { gettext("Subtract to"),0, subto_cb }, + { gettext("Multiply by"),0, multo_cb }, + { gettext("Divide by"), 0, divto_cb }, + { 0 }, + { gettext("Navigation"), 0, 0, 0, FL_SUBMENU }, + { gettext("First slice"), FL_CTRL + FL_F + 1, first_sl_cb }, + { gettext("Prev slice"), FL_CTRL + FL_F + 2, prev_sl_cb }, + { gettext("Next slice"), FL_CTRL + FL_F + 3, next_sl_cb }, + { gettext("Last slice"), FL_CTRL + FL_F + 4, last_sl_cb, 0, FL_MENU_DIVIDER }, + { gettext("First cell"), FL_ALT + FL_F + 1, first_cl_cb }, +// { gettext("Last cell"), FL_ALT + FL_F + 2, last_cl_cb }, +// { gettext("Center grid"), FL_ALT + FL_F + 3, center_cl_cb }, + { 0 }, + { 0 } +}; +//----------------------------------------------------------------------------- +#include "xpm/document-new.xpm" +#include "xpm/plot.xpm" +#include "xpm/document-open.xpm" +#include "xpm/document-save.xpm" +#include "xpm/document-import.xpm" +#include "xpm/document-export.xpm" +#include "xpm/format-indent-more.xpm" +#include "xpm/diff.xpm" +#include "xpm/func.xpm" +#include "xpm/size.xpm" +#include "xpm/tran.xpm" +#include "xpm/crop.xpm" +#include "xpm/go-first.xpm" +#include "xpm/go-last.xpm" +TableWindow::TableWindow(int x, int y, int w, int h, const char* t) : Fl_Window(x, y, w, h, t) +{ + var = 0; +// menu = new Fl_Menu_Bar(0, 0, w, 30); +// menu->copy(tablemenu, this); + Fl_Button *o; + Fl_Group *g; + + + g = new Fl_Group(0,0,30,350); + o = new Fl_Button(0, 0, 25, 25); o->image(new Fl_Pixmap(document_new_xpm)); + o->callback(new_dat_cb,this); o->tooltip(gettext("Create new data with zero filling")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 25, 25, 25); o->image(new Fl_Pixmap(document_open_xpm)); + o->callback(load_dat_cb,this); o->tooltip(gettext("Load data from file")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 50, 25, 25); o->image(new Fl_Pixmap(document_import_xpm)); + o->callback(imp_dat_cb,this); o->tooltip(gettext("Import data from PNG file")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 75, 25, 25); o->image(new Fl_Pixmap(document_save_xpm)); + o->callback(save_dat_cb,this); o->tooltip(gettext("Save data to file")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 100, 25, 25); o->image(new Fl_Pixmap(document_export_xpm)); + o->callback(exp_dat_cb,this); o->tooltip(gettext("Export data to PNG file")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(0, 130, 25, 25); o->image(new Fl_Pixmap(format_indent_more_xpm)); + o->callback(list_dat_cb,this); o->tooltip(gettext("Insert to script as 'list' command")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 155, 25, 25); o->image(new Fl_Pixmap(plot_xpm)); + o->callback(plot_dat_cb,this); o->tooltip(gettext("Plot data")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(0, 185, 25, 25); o->image(new Fl_Pixmap(diff_xpm)); + o->callback(smooth_cb,this); o->tooltip(gettext("Apply operator (smoothing, integration, difference ...) to data")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 210, 25, 25); o->image(new Fl_Pixmap(func_xpm)); + o->callback(modify_cb,this); o->tooltip(gettext("Fill data by formula")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 235, 25, 25); o->image(new Fl_Pixmap(size_xpm)); + o->callback(resize_cb,this); o->tooltip(gettext("Resize data with smoothing")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 260, 25, 25); o->image(new Fl_Pixmap(crop_xpm)); + o->callback(crop_cb,this); o->tooltip(gettext("Crop (cut off edges) data")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(0, 285, 25, 25); o->image(new Fl_Pixmap(tran_xpm)); + o->callback(transp_cb,this); o->tooltip(gettext("Transpose data dimensions")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + g->end(); g->resizable(0); + + + g = new Fl_Group(30,0,200,30); + o = new Fl_Button(30, 0, 25, 25); o->image(new Fl_Pixmap(go_first_xpm)); + o->callback(first_sl_cb,this); o->tooltip(gettext("Go to first slice (Ctrl-F1)")); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + slice = new Fl_Counter(55, 0, 90, 25, 0); slice->callback(change_sl_cb,this); + slice->lstep(10); slice->step(1); slice->tooltip(gettext("Id of slice on third (z-) dimension")); +// slice->box(FL_PLASTIC_UP_BOX);// slice->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(147, 0, 25, 25); o->image(new Fl_Pixmap(go_last_xpm)); + o->callback(last_sl_cb,this); o->tooltip(gettext("Go to last slice (Ctrl-F4)")); + g->end(); g->resizable(0); + + data = new Fl_Data_Table(30,30,w-30,h-30); + data->row_header(1); data->row_header_width(70); + data->row_resize(1); data->rows(1); + data->row_height_all(25); + data->col_header(1); data->col_header_height(25); + data->col_resize(1); data->cols(1); + data->col_width_all(70); + + end(); resizable(data); +// callback(close_table_cb, this); +} +//----------------------------------------------------------------------------- +TableWindow::~TableWindow() +{ parent()->deactivate(); + (parent()->parent())->remove(parent()); + parent()->remove(this); delete parent(); } +//----------------------------------------------------------------------------- +void delete_cb(void *v) { if(v) delete (TableWindow *)v; } +//----------------------------------------------------------------------------- +void TableWindow::update(mglVar *v) +{ + if(v==0) return; + char ss[1024]; + wcstombs(ss,v->s.c_str(),1024); + label(ss); v->func = delete_cb; +// if(var) var->o = 0; + var = v; v->o = this; + refresh(); +} +//----------------------------------------------------------------------------- +void TableWindow::refresh() +{ + if(var==0) return; + deactivate(); nz = var->nz; + sl = 0; slice->range(0,nz-1); + + data->rows(var->ny); data->cols(var->nx); + data->ny = var->ny; data->nx = var->nx; + data->data = var->a; + activate(); +// show(); +} +//----------------------------------------------------------------------------- +void TableWindow::set_slice(long s) +{ + if(s>=0 && sdata = var->a + var->nx * var->ny * sl; + refresh(); + } +} +//----------------------------------------------------------------------------- +void TableWindow::go_home() +{ +} +//----------------------------------------------------------------------------- diff --git a/mgllab/udav.h b/mgllab/udav.h new file mode 100644 index 0000000..83788f8 --- /dev/null +++ b/mgllab/udav.h @@ -0,0 +1,291 @@ +/* udav.h is part of UDAV + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +//----------------------------------------------------------------------------- +#ifndef _UDAV_H_ +#define _UDAV_H_ +//----------------------------------------------------------------------------- +#ifdef __MWERKS__ +# define FL_DLL +#endif +#ifdef USE_GETTEXT + #include +#else + #define gettext(x) (x) +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#ifdef USE_PLASTIC + #define UDAV_UP_BOX FL_PLASTIC_UP_BOX + #define UDAV_DOWN_BOX FL_PLASTIC_DOWN_BOX + #define UDAV_EDIT_BOX FL_PLASTIC_THIN_DOWN_BOX + #define UDAV_THIN_UP_BOX FL_PLASTIC_THIN_UP_BOX +#else + #define UDAV_UP_BOX FL_GTK_UP_BOX + #define UDAV_DOWN_BOX FL_GTK_DOWN_BOX + #define UDAV_EDIT_BOX FL_GTK_DOWN_BOX + #define UDAV_THIN_UP_BOX FL_GTK_THIN_UP_BOX +#endif +//----------------------------------------------------------------------------- +#include "mgl2/fltk.h" +//----------------------------------------------------------------------------- +extern mglParse *Parse; +extern Fl_Menu_Item colors[]; +extern Fl_Preferences pref; +extern char *docdir; +class Fl_MGL; +//----------------------------------------------------------------------------- +class Fl_Data_Table : public Fl_Table +{ +private: + int row, col; + Fl_Input* input; +protected: + void draw_cell(TableContext context, int R, int C, int X, int Y, int W, int H); + static void event_callback(Fl_Widget*, void*v) + { ((Fl_Data_Table*)v)->cell_click(); } + void cell_click(); + +public: + mreal *data; + int nx, ny; + + Fl_Data_Table(int x, int y, int w, int h, const char *l=0); + ~Fl_Data_Table() { } + + void set_value(); + void rows(int val) { if (input->visible()) input->do_callback(); Fl_Table::rows(val); } + void cols(int val) { if (input->visible()) input->do_callback(); Fl_Table::cols(val); } + inline int rows() { return Fl_Table::rows(); } + inline int cols() { return Fl_Table::cols(); } +}; +//----------------------------------------------------------------------------- +struct AnimateDlg +{ + friend void animate_dlg_cb(Fl_Widget *, void *v); + friend void animate_rad_cb(Fl_Widget *, void *v); + friend void fill_animate(const char *text); + friend void animate_put_cb(Fl_Widget *, void *); +public: + Fl_Window* wnd; + int OK; + AnimateDlg() { memset(this,0,sizeof(AnimateDlg)); create_dlg(); } + ~AnimateDlg() { delete wnd; } + void FillResult(Fl_MGL* e); +protected: + bool swap; + Fl_Round_Button *rt, *rv; + Fl_Multiline_Input *txt; + Fl_Float_Input *x0, *x1, *dx, *dt; + Fl_Check_Button *save; + void create_dlg(); +}; +//----------------------------------------------------------------------------- +class Fl_MGL : public Fl_MGLView, public mglDraw +{ +friend class AnimateDlg; +public: + Fl_Widget *status; ///< StatusBar for mouse coordinates + const char *AnimBuf; ///< buffer for animation + const char **AnimS0; + int AnimNum; + mreal AnimDelay; + + Fl_MGL(int x, int y, int w, int h, const char *label=0); + ~Fl_MGL(); + + /// Drawing itself + int Draw(mglGraph *); + /// Update (redraw) plot + void update(); + /// Set main scr and optional pre scripts for execution + void scripts(char *scr, char *pre); + /// Clear scripts internally saved + void clear_scripts(); + /// Show next frame + void next_frame(); + /// Show prev frame + void prev_frame(); + +protected: + char *Args[1000], *ArgBuf; + int NArgs, ArgCur; + + char *script; ///< main script + char *script_pre; ///< script with settings +}; +//----------------------------------------------------------------------------- +struct TableWindow : public Fl_Window +{ +public: + TableWindow(int x, int y, int w, int h, const char* t=0); + ~TableWindow(); + void update(mglVar *v); + void refresh(); + void set_slice(long s); + inline long get_slice() { return sl; } + inline long num_slice() { return nz; } + void go_home(); + + Fl_Data_Table *data; + Fl_Menu_Bar *menu; +// Fl_Output *main; + Fl_Counter *slice; + mglData *var; +protected: +// long nx,ny,nz; + long nz; + long sl; // current slice + char sl_id[64]; // slice id +}; +//----------------------------------------------------------------------------- +class SetupDlg +{ +public: + Fl_Window *wnd; + bool OK; + Fl_Input *templ; + + SetupDlg() { memset(this,0,sizeof(SetupDlg)); } + ~SetupDlg() { delete wnd; } + void CreateDlg(); + char *ToScript(); +private: + Fl_Input *xmin, *ymin, *zmin, *cmin; + Fl_Input *xmax, *ymax, *zmax, *cmax; + Fl_Input *xorg, *yorg, *zorg; + Fl_Input *xlab, *ylab, *zlab, *font; + Fl_Choice *xpos, *ypos, *zpos, *axial, *cid[10]; + Fl_Input *xtik, *ytik, *ztik; + Fl_Input *xsub, *ysub, *zsub; + Fl_Input *alphad, *ambient, *basew, *mesh, *size; + Fl_Check_Button *alpha, *light, *rotate, *lid[10]; + Fl_Input *xid[10], *yid[10], *zid[10], *bid[10]; + Fl_Help_View *code; + + void CreateGen(); + void CreateLid(); +}; +//----------------------------------------------------------------------------- +class ScriptWindow : public Fl_Double_Window +{ +public: + ScriptWindow(int w, int h, const char* t); + ~ScriptWindow(); + + Fl_Window *replace_dlg; + Fl_Input *replace_find; + Fl_Input *replace_with; + Fl_Button *replace_all; + Fl_Return_Button *replace_next; + Fl_Button *replace_cancel; + Fl_Text_Editor *editor; + Fl_Menu_Bar *menu; + Fl_Tabs *ltab, *rtab; + Fl_Help_View *hd; + Fl_Input *link_cmd; + Fl_Group *ghelp; + Fl_Browser *var; + Fl_Box *status; + + void mem_init(); + void mem_pressed(int n); + SetupDlg *setup_dlg; + char search[256]; + Fl_MGL *graph; +}; +//----------------------------------------------------------------------------- +// Editor window functions +void find2_cb(Fl_Widget *, void *); +void replall_cb(Fl_Widget *, void *); +void replace2_cb(Fl_Widget *, void *); +void replcan_cb(Fl_Widget *, void *); +void insert_cb(Fl_Widget *, void *); +void paste_cb(Fl_Widget *, void *); +void replace_cb(Fl_Widget *, void *); +void copy_cb(Fl_Widget *, void *); +void cut_cb(Fl_Widget *, void *); +void find_cb(Fl_Widget *, void *); +void delete_cb(Fl_Widget *, void *); +void changed_cb(int, int nInserted, int nDeleted,int, const char*, void* v); +//----------------------------------------------------------------------------- +// General callback functions +void new_cb(Fl_Widget *, void *); +void open_cb(Fl_Widget *, void *); +void save_cb(Fl_Widget*, void*); +void saveas_cb(Fl_Widget*, void*); +void help_cb(Fl_Widget*, void*); +//----------------------------------------------------------------------------- +// Graphical callback functions +void setup_cb(Fl_Widget *, void *); +void style_cb(Fl_Widget *, void *); +void option_cb(Fl_Widget *, void *); +void argument_cb(Fl_Widget *, void *); +void variables_cb(Fl_Widget *, void *); +void settings_cb(Fl_Widget *, void *); +void command_cb(Fl_Widget *, void *); +//----------------------------------------------------------------------------- +// Dialogs callback functions +void close_dlg_cb(Fl_Widget *w, void *); +void font_cb(Fl_Widget *, void *v); +void line_cb(Fl_Widget *, void *v); +void face_cb(Fl_Widget *, void *v); +void data_cb(Fl_Widget *, void *v); +//----------------------------------------------------------------------------- +void style_init(void); +int check_save(void); +void load_file(char *newfile, int ipos); +void save_file(char *newfile); +Fl_Widget *add_editor(ScriptWindow *w); +Fl_Widget *add_mem(ScriptWindow *w); +void set_title(Fl_Window* w); +//----------------------------------------------------------------------------- +// Animation +void animate_cb(Fl_Widget *, void *v); +void fill_animate(const char *text); +//----------------------------------------------------------------------------- +Fl_Widget *add_help(ScriptWindow *w); +void help_cb(Fl_Widget*, void*v); +void example_cb(Fl_Widget*, void*v); +void about_cb(Fl_Widget*, void*); +//----------------------------------------------------------------------------- +void newcmd_cb(Fl_Widget*,void*); +//----------------------------------------------------------------------------- +extern Fl_Text_Buffer *textbuf; +extern char filename[256]; +extern int changed; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/mgllab/udav.rc b/mgllab/udav.rc new file mode 100644 index 0000000..e557119 --- /dev/null +++ b/mgllab/udav.rc @@ -0,0 +1,24 @@ +/* udav.rc is part of UDAV + * Copyright (C) 2007 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +//----------------------------------------------------------------------------- +#include + +#define APPICON 1001 +#define APPICON48 1002 + +APPICON ICON "udav.ico" +APPICON48 ICON "udav48.ico" diff --git a/mgllab/udav48.ico b/mgllab/udav48.ico new file mode 100644 index 0000000..a286d6d Binary files /dev/null and b/mgllab/udav48.ico differ diff --git a/mgllab/write.cpp b/mgllab/write.cpp new file mode 100644 index 0000000..ff461aa --- /dev/null +++ b/mgllab/write.cpp @@ -0,0 +1,17 @@ +/* write.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +//----------------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..73b7eee --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,151 @@ +set(mgl_src + addon.cpp axis.cpp base_cf.cpp base.cpp canvas_cf.cpp canvas.cpp cont.cpp crust.cpp + complex.cpp complex_io.cpp fft.cpp data_gr.cpp + data.cpp data_io.cpp data_ex.cpp data_png.cpp def_font.cpp + export_2d.cpp export_3d.cpp eval.cpp evalp.cpp exec.cpp export.cpp + fit.cpp font.cpp obj.cpp other.cpp parser.cpp pde.cpp pixel.cpp + plot.cpp prim.cpp surf.cpp tex_table.cpp vect.cpp volume.cpp evalc.cpp + s_hull/s_hull_pro.cpp window.cpp +) + +set(mgl_hdr + ../include/mgl2/base_cf.h ../include/mgl2/fit.h ../include/mgl2/plot.h + ../include/mgl2/base.h ../include/mgl2/prim.h ../include/mgl2/canvas_cf.h + ../include/mgl2/font.h ../include/mgl2/canvas.h ../include/mgl2/surf.h + ../include/mgl2/mgl_cf.h ../include/mgl2/type.h ${MathGL_BINARY_DIR}/include/mgl2/config.h +${MathGL_BINARY_DIR}/include/mgl2/dllexport.h + ../include/mgl2/cont.h ../include/mgl2/mgl.h ../include/mgl2/vect.h + ../include/mgl2/data.h ../include/mgl2/volume.h ../include/mgl2/data_cf.h + ../include/mgl2/define.h ../include/mgl2/other.h ../include/mgl2/eval.h + ../include/mgl2/parser.h ../include/mgl2/addon.h ../include/mgl2/evalc.h + s_hull/s_hull_pro.h ../include/mgl2/wnd.h ../include/mgl2/canvas_wnd.h + ../include/mgl2/thread.h ../include/mgl2/abstract.h ../include/mgl2/pde.h +) + +add_definitions(-DMGL_SRC) + +if(MGL_HAVE_PNG) + set(prc_src prc/PRCbitStream.cc prc/PRCdouble.cc prc/oPRCFile.cc prc/writePRC.cc prc.cpp ) + set(prc_hdr prc/PRC.h prc/PRCbitStream.h prc/PRCdouble.h prc/oPRCFile.h prc/writePRC.h ) + + set(mgl_src ${mgl_src} ${prc_src} ) + set(mgl_hdr ${mgl_hdr} ${prc_hdr} ) + include_directories(prc) +endif(MGL_HAVE_PNG) + +if(MGL_HAVE_OPENGL) + set(mgl_src ${mgl_src} opengl.cpp ) + set(mgl_hdr ${mgl_hdr} ../include/mgl2/opengl.h ) +endif(MGL_HAVE_OPENGL) + +include(GenerateExportHeader) +add_compiler_export_flags() +add_library(mgl SHARED ${mgl_src} ${mgl_hdr}) +add_library(mgl-static STATIC ${mgl_src} ${mgl_hdr}) +set_target_properties(mgl PROPERTIES CLEAN_DIRECT_OUTPUT 1) +set_target_properties(mgl-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) +set_target_properties(mgl-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) +generate_export_header(mgl EXPORT_FILE_NAME ../include/mgl2/dllexport.h) + +if(enable-mgl2) + set_target_properties(mgl PROPERTIES OUTPUT_NAME "mgl2") + set_target_properties(mgl-static PROPERTIES OUTPUT_NAME "mgl2") +else(enable-mgl2) + set_target_properties(mgl-static PROPERTIES OUTPUT_NAME "mgl") +endif(enable-mgl2) + +# if(MGL_HAVE_LTDL) +# target_link_libraries(mgl ${LTDL_LIB}) +# include_directories(${LTDL_INCLUDE_DIR}) +# endif(MGL_HAVE_LTDL) + +if(MGL_HAVE_PDF) + include_directories(${HPDF_INCLUDE_DIR}) + target_link_libraries(mgl ${HPDF_LIB}) +endif(MGL_HAVE_PDF) + +if(MGL_HAVE_PTHREAD) + target_link_libraries(mgl ${CMAKE_THREAD_LIBS_INIT}) +endif(MGL_HAVE_PTHREAD) + +if(MGL_HAVE_JPEG) + target_link_libraries(mgl ${JPEG_LIBRARIES}) + include_directories(${JPEG_INCLUDE_DIR}) +endif(MGL_HAVE_JPEG) + +if(MGL_HAVE_GIF) + target_link_libraries(mgl ${GIF_LIBRARIES}) + include_directories(${GIF_INCLUDE_DIR}) +endif(MGL_HAVE_GIF) + +if(MGL_HAVE_HDF5) + target_link_libraries(mgl ${HDF5_LIBRARIES}) + include_directories(${HDF5_INCLUDE_DIR}) +endif(MGL_HAVE_HDF5) + +if(MGL_HAVE_HDF4) + target_link_libraries(mgl ${HDF4MF_LIB} ${HDF4_LIB}) + include_directories(${HDF4_INCLUDE_DIR}) +endif(MGL_HAVE_HDF4) + +if(MGL_HAVE_GSL) + target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} ) + include_directories(${GSL_INCLUDE_DIR}) +endif(MGL_HAVE_GSL) + +if(MGL_HAVE_OPENGL) + target_link_libraries(mgl ${OPENGL_LIBRARIES} ) + include_directories(${OPENGL_INCLUDE_DIR} ) +endif(MGL_HAVE_OPENGL) + +if(MGL_HAVE_PNG) + target_link_libraries(mgl ${PNG_LIBRARIES} ) + include_directories(${PNG_INCLUDE_DIR}) +endif(MGL_HAVE_PNG) + +if(MGL_HAVE_ZLIB) + target_link_libraries(mgl ${ZLIB_LIBRARIES} ) + include_directories(${ZLIB_INCLUDE_DIR}) +endif(MGL_HAVE_ZLIB) + +if(MGL_HAVE_MPI) + add_library(mgl-mpi SHARED mpi.cpp ../include/mgl2/mpi.h) + add_library(mgl-mpi-static STATIC mpi.cpp ../include/mgl2/mpi.h) + set_target_properties(mgl-mpi PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-mpi PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") + set_target_properties(mgl-mpi-static PROPERTIES OUTPUT_NAME "mgl-mpi") + set_target_properties(mgl-mpi-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-mpi-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) + + if(enable-mgl2) + set_target_properties(mgl-mpi PROPERTIES OUTPUT_NAME "mgl2-mpi") + set_target_properties(mgl-mpi-static PROPERTIES OUTPUT_NAME "mgl2-mpi") + else(enable-mgl2) + set_target_properties(mgl-mpi-static PROPERTIES OUTPUT_NAME "mgl-mpi") + endif(enable-mgl2) + + target_link_libraries(mgl-mpi ${MPI_LIBRARIES} ) +# include_directories(${MPI_C_INCLUDE_PATH}) + include_directories(${MPI_CXX_INCLUDE_PATH}) + + set_target_properties(mgl-mpi PROPERTIES SOVERSION ${MathGL_SOVERSION}) + install( + TARGETS mgl-mpi mgl-mpi-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} + ) +endif(MGL_HAVE_MPI) + +if(M_LIB) + target_link_libraries(mgl ${M_LIB}) +endif(M_LIB) + +set_target_properties(mgl PROPERTIES SOVERSION ${MathGL_SOVERSION}) +install( + TARGETS mgl mgl-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} +) +install(FILES ${MathGL_BINARY_DIR}/include/mgl2/dllexport.h DESTINATION ${MGL_INCLUDE_PATH}) diff --git a/src/addon.cpp b/src/addon.cpp new file mode 100644 index 0000000..ef6f932 --- /dev/null +++ b/src/addon.cpp @@ -0,0 +1,273 @@ +/*************************************************************************** + * addon.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#ifdef WIN32 +#include +#include +#else +#include +#endif +#include +#include "mgl2/addon.h" +#include "mgl2/data.h" +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_strcls(char *str) +{ + size_t len = strlen(str),i,n; + char *tmp = new char[len+1]; memset(tmp,0,len); + for(i=0;i0;i--) if(tmp[i]!=' ') break; + tmp[i+1]=0; strcpy(str,&(tmp[n])); + delete []tmp; +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_strpos(const char *str,char *fnd) +{ + const char *p=strstr(str,fnd); + int res; + if(p) res = p-str; + else res = -1; + return res; +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_chrpos(const char *str,char ch) +{ + const char *p=str?strchr(str,ch):0; + int res; + if(p) res = p-str; + else res = -1; + return res; +} +//----------------------------------------------------------------------------- +MGL_EXPORT char *mgl_fgetstr(FILE *fp) +{ + const long size=10240; // NOTE: this set maximal length of string to be read + static char s[size]; + do + { + if(!fgets(s,size,fp)) break; + mgl_strtrim(s); + // strlwr(s); + } while(!feof(fp) && (s[0]==0 || s[0]=='%' || s[0]=='#')); + for(long i=0;s[i];i++) if(s[i]=='#') { s[i]=0; break; } + mgl_strtrim(s); + return s; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fgetpar(FILE *fp, const char *str, ...) +{ + if(!str || !str[0]) return; + long len=strlen(str), *n; double *v; + char *s, *t; + va_list lst; + va_start(lst,str); + t = mgl_fgetstr(fp); + for(long i=0;i0) pos = p; + if(fname==NULL) return NULL; + if(pos==0) { if(!getcwd(path,256)) return 0; } // remember ini dyrectory + else { if(chdir(path)==-1) return 0; } + + // read the initial (common) data + FILE *fp=fopen(fname,"rt"); + if(fp==NULL) return NULL; + fseek(fp,0,SEEK_END); + len = ftell(fp); + if(pos>=len) // no more data + { fclose(fp); return NULL; } + fseek(fp,pos,SEEK_SET); + //printf("pos 1 = %d\t",pos); + do + { + s = mgl_fgetstr(fp); + fflush(stdout); + if(s[0]=='$' || s[1]=='$' || s[3]=='$') + { fclose(fp); return NULL; } + } while(!feof(fp) && (s[0]!='-' || s[1]!='-' || s[3]!='-')); + if(feof(fp)) // no more data + { fclose(fp); return NULL; } + return fp; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_difr_grid(dual *a,int n,int step,dual q,int Border,dual *tmp,int kk) +{ mgl_difr_grid_old(a,n,step,q,Border,tmp,tmp+n,kk); } +void MGL_EXPORT mgl_difr_grid_old(dual *a,int n,int step,dual q,int Border,dual *b, dual *d,int kk) +{ + const dual adt = dual(0.,1.)*q; + if(step==1) memcpy(b,a,n*sizeof(dual)); + else for(long i=0;i0;k--) // 3 iterations + { +//#pragma omp parallel for + for(long i=1;i0;k--) // kk iterations + { + d[ii] = a[ii] + adt*(b[ii+1]-b[ii])*(ff/k); +//#pragma omp parallel for + for(long i=ii+1;i0) freq[nn-i] = -(double)(i); + } +} +//----------------------------------------------------------------------------- diff --git a/src/axis.cpp b/src/axis.cpp new file mode 100644 index 0000000..c0a81e5 --- /dev/null +++ b/src/axis.cpp @@ -0,0 +1,1048 @@ +/*************************************************************************** + * axis.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include "mgl2/data.h" +#include "mgl2/canvas.h" +#include "mgl2/prim.h" +//----------------------------------------------------------------------------- +#define islog(a, b) (((a)>0 && (b)>10*(a)) || ((b)<0 && (a)<10*(b))) +// NOTE: I use <=0 for proper tick labels rotation. But this mirror labels for central origin! +#define sign(a) ((a)<0 ? -1:1) +//#define sign(a) ((a)<0 ? -1:((a)>0 ? 1:0)) +//----------------------------------------------------------------------------- +MGL_NO_EXPORT inline struct tm *mgl_localtime (const time_t *clock, tm *result, bool use_utc) +{ if (!clock || !result) return NULL; + const tm *res = use_utc?gmtime(clock):localtime(clock); + memcpy(result,res,sizeof(tm)); return result; } +//----------------------------------------------------------------------------- +long MGL_EXPORT mgl_have_color(const char *stl) +{ + register long i,j=0; + if(stl) for(i=0;stl[i];i++) + { + if(strchr(MGL_COLORS,stl[i])) j++; + if(stl[i]=='{' && stl[i+1]=='x') j++; + } + return j; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_wcstrim(wchar_t *str) +{ + if(!str || *str==0) return; + size_t n=mgl_wcslen(str), k, i; + for(k=0;k' ') break; + for(i=n;i>k;i--) if(str[i-1]>' ') break; + memmove(str, str+k, (i-k)*sizeof(wchar_t)); + str[i-k]=0; +} +//----------------------------------------------------------------------------- +size_t MGL_EXPORT mgl_wcslen(const wchar_t *str) +{ + long i=0; + if(str) while(str[i]) i++; + return i; +} +//----------------------------------------------------------------------------- +// Ticks setup +//----------------------------------------------------------------------------- +void mglCanvas::SetAxisStl(const char *stl, const char *tck, const char *sub) +{ + if(!stl || !(*stl)) strncpy(AxisStl,"k",32); + else strncpy(AxisStl,stl,32); + if(!tck || !(*tck)) strncpy(TickStl,AxisStl,32); + else strncpy(TickStl,tck,32); + if(!sub || !(*sub)) strncpy(SubTStl,TickStl,32); + else strncpy(SubTStl,sub,32); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTickLen(mreal tlen, mreal stt) +{ TickLen = tlen?tlen:0.02; st_t=stt>0?stt:1; } +//----------------------------------------------------------------------------- +void mglCanvas::SetTicks(char dir, mreal d, int ns, mreal org) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + + if(aa.f==1) aa.t.clear(); + aa.d=d; aa.f=0; aa.ns=ns; aa.o=org; + aa.txt.clear(); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, HCDT v, const wchar_t *lbl, bool add) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + bool ff = (dir=='x' ? fx : (dir=='y' ? fy : (dir=='z' ? fz : fa))); + + aa.txt.clear(); + if(add) { UpdateAxis(); AdjustTicks(aa,ff); } + if(!v || !lbl || !lbl[0]) { aa.f = 0; return; } + aa.f = 2; aa.ns=0; aa.ds=0; + register long i,j,l=0,n=v->GetNx(); + for(i=j=l=0;iv(i)); + i++; l=j+1; + } + if(j>1 && lbl[j]=='n' && lbl[j-1]=='\\') + { + aa.AddLabel(std::wstring(lbl+l,j-l-1),v->v(i)); + i++; l=j+1; + } + } + if(iv(i)); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, HCDT v, const char *lbl, bool add) +{ + MGL_TO_WCS(lbl,SetTicksVal(dir,v,wcs,add)); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, const wchar_t *lbl, bool add) +{ + register long i,j,len=mgl_wcslen(lbl); + for(i=0,j=1;j63) i=63; + mglData val(i+1); val.Fill(Min.x,Max.x); + SetTicksVal(dir, &val, lbl, add); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, const char *lbl, bool add) +{ + register long i,j,len=strlen(lbl); + for(i=0,j=1;j63) i=63; + mglData val(i+1); val.Fill(Min.x,Max.x); + SetTicksVal(dir, &val, lbl, add); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, HCDT v, const wchar_t **lbl, bool add) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + bool ff = (dir=='x' ? fx : (dir=='y' ? fy : (dir=='z' ? fz : fa))); + + aa.txt.clear(); + if(add) { UpdateAxis(); AdjustTicks(aa,ff); } + if(!v || !lbl) { aa.f = 0; return; } + aa.f = 2; aa.ns=0; aa.ds=0; + register long i,n=v->GetNx(); + for(i=0;iv(i)); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTicksVal(char dir, HCDT v, const char **lbl, bool add) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + bool ff = (dir=='x' ? fx : (dir=='y' ? fy : (dir=='z' ? fz : fa))); + + aa.txt.clear(); + if(add) { UpdateAxis(); AdjustTicks(aa,ff); } + if(!v || !lbl) { aa.f = 0; return; } + aa.f = 2; aa.ns=0; aa.ds=0; + for(long i=0;iGetNx();i++) MGL_TO_WCS(lbl[i],aa.AddLabel(wcs,v->v(i))); +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTickTempl(char dir, const wchar_t *t) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + + if(aa.f==1) aa.f = 0; // remove time ticks + if(!t) aa.t.clear(); else aa.t=t; +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTickTempl(char dir, const char *t) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + + if(aa.f==1) aa.f = 0; // remove time ticks + if(!t || !t[0]) aa.t.clear(); + else MGL_TO_WCS(t,aa.t=wcs); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT double mgl_adj_val(double v,mreal *ds=0) +{ + double n = floor(log10(v)), s; + v = floor(v*pow(10.,-n)); n = pow(10.,n); + + if(v==1) { v = n/5; s=n/10; } + else if(v<4){ v = n/2; s=n/10; } + else if(v<7){ v = n; s=n/5; } + else { v = 2*n; s=n/2; } + if(ds) *ds=s; + return v; +} +//----------------------------------------------------------------------------- +void mglCanvas::SetTickTime(char dir, mreal d, const char *t) +{ + if(!strchr("xyzca",dir)) return; + mglAxis &aa = (dir=='x' ? ax : (dir=='y' ? ay : (dir=='z' ? az : ac))); + UpdateAxis(); + + time_t tt; tm t1,t2; + tt=aa.v1; mgl_localtime(&tt, &t1, get(MGL_USE_GMTIME)); + tt=aa.v2; mgl_localtime(&tt, &t2, get(MGL_USE_GMTIME)); + if(aa.v11 ? "%x" : "%X"; + if(abs(t1.tm_year-t2.tm_year)>3) t = "%Y"; + } + if(d==0) // try to select opimal step + { + // TODO add subticks for drawing + if(abs(t1.tm_year-t2.tm_year)>1) + d = 365.25*24*3600*mgl_adj_val(abs(t1.tm_year-t2.tm_year)); // number of second in year NOTE: improve it + // NOTE here should be months ... but it is too unregular ... so omit it now +// else if(t1.tm_mon!=t2.tm_mon) d = 30*24*3600; // number of second in month + else if(abs(t1.tm_yday-t2.tm_yday)>1) // localtime("%x") cannot print time < 1 day + { d = 24*3600.*mgl_adj_val(abs(t1.tm_yday-t2.tm_yday)); d = d>24*3600?d:24*3600; } + else if(abs(t1.tm_hour-t2.tm_hour)>1) + d = 3600.*mgl_adj_val(abs(t1.tm_hour-t2.tm_hour)); + else if(abs(t1.tm_min-t2.tm_min)>1) + d = 60*mgl_adj_val(abs(t1.tm_min-t2.tm_min)); + else if(abs(t1.tm_sec-t2.tm_sec)>1) // localtime("%X") cannot print time < 1 sec + { d = mgl_adj_val(abs(t1.tm_sec-t2.tm_sec)); d = d>1?d:1; } + else // adjust msec. NOTE: this is not supported by localtime() !!! + d = mgl_adj_val(fabs(aa.v2-aa.v1)); + } + + aa.ds = 0; aa.dv = d; aa.f = 1; aa.txt.clear(); + MGL_TO_WCS(t,aa.t=wcs); + + if(strchr("xyztuvw",aa.ch)) + aa.org = mglPoint(GetOrgX(aa.ch,aa.inv), GetOrgY(aa.ch,aa.inv), GetOrgZ(aa.ch,aa.inv)); + if(aa.ch=='x') aa.v0 = aa.org.x; + if(aa.ch=='y') aa.v0 = aa.org.y; + if(aa.ch=='z') aa.v0 = aa.org.z; + + wchar_t buf[64]; + mreal v, v0 = mgl_isnan(aa.o) ? aa.v0 : aa.o, v1; + if(aa.v2>aa.v1) + { v1 = aa.v2; v0 = v0 - aa.dv*floor((v0-aa.v1)/aa.dv+1e-3); } + else + { v1 = aa.v1; v0 = v0 - aa.dv*floor((v0-aa.v2)/aa.dv+1e-3); } + if(v0+aa.dv!=v0 && v1+aa.dv!=v1) for(v=v0;v<=v1;v+=aa.dv) + { + tt = v; tm tp; mgl_localtime(&tt, &tp, get(MGL_USE_GMTIME)); + wcsftime(buf,64,aa.t.c_str(),&tp); aa.AddLabel(buf,v); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::AdjustTicks(const char *dir, bool force) +{ + if(force) SetTuneTicks(3); + UpdateAxis(); + if(strchr(dir,'x') || strchr(dir,'X')) // NOTE dir have to be non-NULL here !!! + { if(force) ax.d=0; AdjustTicks(ax,fx!=0); } + if(strchr(dir,'y') || strchr(dir,'Y')) + { if(force) ay.d=0; AdjustTicks(ay,fy!=0); } + if(strchr(dir,'z') || strchr(dir,'Z')) + { if(force) az.d=0; AdjustTicks(az,fz!=0); } + if(strchr(dir,'a') || strchr(dir,'c')) + { if(force) ac.d=0; AdjustTicks(ac,fa!=0); } +} +//----------------------------------------------------------------------------- +void mglCanvas::AdjustTicks(mglAxis &aa, bool ff) +{ + double d = fabs(aa.v2-aa.v1), n; + if(aa.f>0) return; + if(ff && islog(aa.v1,aa.v2)) + { aa.dv = 0; aa.ds=0; } + else if(aa.d>0) + { aa.dv = aa.d; aa.ds = aa.d/(abs(aa.ns)+1); } + else if(aa.d>-1.5) // like =0 or =-1 + { aa.dv = mgl_adj_val(d,&aa.ds); aa.o=0; } + else + { + d /= -aa.d; n = floor(log10(d)); + int k = int(d*pow(10.,-n)+0.5); + aa.dv = pow(10.,n)*k; + aa.o=0; aa.ds = pow(10.,n); + } + LabelTicks(aa); +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_tick_ext(mreal a, mreal b, wchar_t s[32], mreal &v) +{ + int kind = 0; + if(fabs(a-b)<=0.01*fabs(a)) + { + kind = 1; + v = fabs(a-b); + if(v>1000.f) + { + int k=int(log10(v)-0.01); + kind=3; v=mgl_ipow(10.,k); + mglprintf(s, 32, L" (@{\\times{}10^{%d}})", k); + } + else if(v<0.02f) + { + int k=int(log10(v)-0.01)-1; + kind=3; v=mgl_ipow(10.,k); + mglprintf(s, 32, L" (@{\\times{}10^{%d}})", k); + } + } + else + { + v = fabs(b)>fabs(a)?fabs(b):fabs(a); + if(v>=1000.f) + { + kind = 2; + int k=int(log10(v)-0.01); + v=mgl_ipow(10.,k); + mglprintf(s, 32, L" \\times 10^{%d}", k); + } + else if(v<=1e-3f) + { + kind = 2; + int k=int(log10(v)-0.01)-1; + v=mgl_ipow(10.,k); + mglprintf(s, 32, L" \\times 10^{%d}", k); + } + } + return kind; +} +//----------------------------------------------------------------------------- +std::wstring MGL_NO_EXPORT mgl_format(mreal v1, mreal v2, bool zero) +{ + v1=fabs(v1); v2=fabs(v2); if(v1>v2) v2=v1; + wchar_t str[5]=L"%.3g"; + int prec=int(2-log10(v2)); if(prec<0) prec=0; + if(v2<=0.001 || v2>=10000) + { str[2] = '2'; str[3]='e'; } + else if(zero) + { str[2] = '0'+prec; str[3]='f'; } + return str; +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_tick_text(mreal z, mreal z0, mreal d, std::wstring fmt, mreal v, int kind, wchar_t str[64]) +{ + mreal u = fabs(z)z0) u = fabs(z-z0)z0)) u /= v; + if(kind&1) fmt = z>z0?L"@{(+"+fmt+L")}":L"%g"; + mglprintf(str,64,fmt.c_str(), u); + +/* mreal u = fabs(z)z0) u = fabs(z-z0)z0)) u /= v; + if((kind&1) && z>z0) + { + size_t n1,n2; + mglprintf(str, 64, L"@{(+%.2g)}",u); + n1=mgl_wcslen(str); mglprintf(str, 64, L"@{(+%g)}",u); n2=mgl_wcslen(str); + if(n10) // positive log-scale + { + v0 = exp(M_LN10*floor(0.1+log10(aa.v1))); + ds = int(floor(0.1+log10(aa.v2/v0))/7)+1; + for(v=v0;v<=aa.v2*MGL_EPSILON;v*=10) if(v*MGL_EPSILON>=aa.v1) + { + d = int(floor(0.1+log10(v))); + if(d==0) wcscpy(buf,L"1"); + else if(d==1) wcscpy(buf,L"10"); + else mglprintf(buf,64,L"10^{%d}",d); + if(d%ds!=0) *buf=0; // remove too often log ticks + aa.AddLabel(buf,v); + } + } + else if(aa.dv==0 && aa.v2<0) // negative log-scale + { + v0 = -exp(M_LN10*floor(0.1+log10(-aa.v2))); + ds = int(floor(0.1+log10(aa.v1/v0))/7)+1; + for(v=v0;v>=aa.v1*MGL_EPSILON;v*=10) if(v*MGL_EPSILON<=aa.v2) + { + d = int(floor(0.1+log10(-v))); + if(d==0) wcscpy(buf,L"-1"); + else if(d==1) wcscpy(buf,L"-10"); + else mglprintf(buf,64,L"-10^{%d}",d); + if(d%ds!=0) *buf=0; // remove too often log ticks + aa.AddLabel(buf,v); + } + } + else if(aa.dv) // ticks drawing + { + int kind=0; + wchar_t s[32]=L""; + if(aa.t.empty() && TuneTicks) kind = mgl_tick_ext(aa.v2, aa.v1, s, w); + if((TuneTicks&1)==0 && kind==2) kind=0; + if((TuneTicks&2)==0 && kind!=2) kind=0; + + v0 = mgl_isnan(aa.o) ? aa.v0 : aa.o; + if(aa.v2>aa.v1) + { v1 = aa.v2; v0 = v0 - aa.dv*floor((v0-aa.v1)/aa.dv+1e-3); } + else + { v1 = aa.v1; v0 = v0 - aa.dv*floor((v0-aa.v2)/aa.dv+1e-3); } + + std::wstring fmt; + switch(kind) + { + case 1: fmt=mgl_format(0,v1-v0,TuneTicks&4); break; + case 2: fmt=mgl_format(v0/w,v1/w,TuneTicks&4); break; + case 3: fmt=mgl_format(0,(v1-v0)/w,TuneTicks&4);break; + default:fmt=mgl_format(v0,v1,TuneTicks&4); break; + } + + if(v0+aa.dv!=v0 && v1+aa.dv!=v1) for(v=v0;v<=v1;v+=aa.dv) + { + if(aa.t.empty()) + mgl_tick_text(v,v0,aa.dv/100,fmt,w,kind,buf); + else + mglprintf(buf, 64, aa.t.c_str(), fabs(v)0) for(long i=0;iaa.v1 && fabs(u-exp(M_LN10*floor(0.1+log10(u))))<0.01*u) + for(long j=2;j<10 && v*j0 && !get(MGL_NOSUBTICKS)) + { + if(aa.v2>aa.v1) v0 = v0 - aa.ds*floor((v0-aa.v1)/aa.ds+1e-3); + else v0 = v0 - aa.ds*floor((v0-aa.v2)/aa.ds+1e-3); + if(v0+aa.ds!=v0 && aa.v2+aa.ds!=aa.v2) + { + if(*SubTStl && !have_color) SetPenPal(SubTStl); + for(v=v0;(v-aa.v2)*(v-aa.v1)<=0;v+=aa.ds) + tick_draw(o+d*v,da,db,1); + } + } + if(!have_color) SetPenPal(AxisStl); + if(text) DrawLabels(aa); + EndGroup(); +} +//----------------------------------------------------------------------------- +void mglCanvas::DrawLabels(mglAxis &aa, bool inv, const mglMatrix *M) +{ + if(strchr("xyz",aa.ch)) + aa.org = mglPoint(GetOrgX(aa.ch,aa.inv), GetOrgY(aa.ch,aa.inv), GetOrgZ(aa.ch,aa.inv)); + mglPoint d = aa.dir, o = aa.org; // "transverse" org + if(strchr("xyz",aa.ch)) o -= d*(o*d); + mglPoint p,q, s=(Min+Max)/2, nn; + s = s - d*(s*d); + if(M==0) M=&B; + + register long i,n = aa.txt.size(); + char pos[4]="t:C"; + if(aa.ch=='c') pos[0]=(aa.ns==0 || aa.ns==3)?'t':'T'; + if(aa.ch=='T') pos[0]='T'; + mreal *w=new mreal[n], h = TextHeight(FontDef,-1), c=NAN, l=NAN, tet=0, v, vv; // find sizes + long *kk=new long[n]; + for(i=0;iaa.v2 || aa.txt[i+1].val>aa.v2)) + continue; + if(kk[i]<0 || kk[i+1]<0) continue; + v = (GetPntP(kk[i+1])-GetPntP(kk[i])).norm(); // distance between ticks + vv = (w[i]+w[i+1])/2; // length of labels + if(v>0 && l < vv/v) l = vv/v; + if(c>v) c = v; + } + if(get(MGL_ENABLE_RTEXT) && get(MGL_TICKS_ROTATE) && l>1 && c>0) // try rotate first + { tet = c>1.1*h ? asin(1.1*h/c) : M_PI/2; pos[2]=(aa.ch=='c' && !inv)?'R':'L'; + l=0.99*h/sin(tet)/c; for(i=0;i0) for(i=0;iaa.v1 && c0 ? 't':'T'; + if(ts>0 && tet && nn.x==0) pos[2]='R'; + text_plot(kk[i], aa.txt[i].text.c_str(), pos, -1, aa.sh+0.07,CDef,tet?false:true); + } + delete []w; delete []kk; +} +//----------------------------------------------------------------------------- +char mglCanvas::GetLabelPos(mreal c, long kk, mglAxis &aa) +{ + if(strchr("xyz",aa.ch)) + aa.org = mglPoint(GetOrgX(aa.ch,aa.inv), GetOrgY(aa.ch,aa.inv), GetOrgZ(aa.ch,aa.inv)); + mglPoint d = aa.dir, o = aa.org; // "transverse" org + if(strchr("xyz",aa.ch)) o -= d*(o*d); + mglPoint p,q, s=(Min+Max)/2, nn; + s = s - d*(s*d); + + int ts = 1; + if(aa.ch=='c') ts=(aa.ns==0 || aa.ns==3)?1:-1; + if(aa.ch=='T') ts=-1; + + p = o+d*c; nn = (s-o)/(Max-Min); ScalePoint(&B,p,nn); + mglPnt &qq = Pnt[kk]; + + if(aa.ch=='c') qq.u = qq.v = NAN; + if(!get(MGL_DISABLE_SCALE)) ts = sign(qq.v*nn.x-qq.u*nn.y)*sign(aa.v2-aa.v1); + if(aa.ch=='T') ts *= -1; + if(aa.pos=='T') ts *= -1; + return ts>0 ? 't':'T'; +} +//----------------------------------------------------------------------------- +void mglCanvas::tick_draw(mglPoint o, mglPoint d1, mglPoint d2, int f) +{ + if(TickLen==0) return; + // try to exclude ticks out of axis range + if(f && ((o.x-Min.x)*(o.x-Max.x)>0 || (o.y-Min.y)*(o.y-Max.y)>0 || (o.z-Min.z)*(o.z-Max.z)>0)) + return; + mreal v = font_factor*TickLen/sqrt(1.f+f*st_t); + mglPoint p=o; + + ScalePoint(&B,o, d1, false); d1.Normalize(); + ScalePoint(&B,p, d2, false); d2.Normalize(); + long k2 = AddPnt(&B, p, CDef, mglPoint(NAN), 0, 0); + long k1 = AddPnt(&B, p+d1*v, CDef, mglPoint(NAN), 0, 0); + long k3 = AddPnt(&B, p+d2*v, CDef, mglPoint(NAN), 0, 0); + line_plot(k1,k2); line_plot(k2,k3); +} +//----------------------------------------------------------------------------- +void mglCanvas::Grid(const char *dir, const char *pen, const char *opt) +{ + SaveState(opt); + if(!dir || !dir[0]) dir="xyz"; + AdjustTicks(dir,false); + SetPenPal(pen); + + static int cgid=1; StartGroup("AxisGrid",cgid++); + if(strchr(dir,'x')) DrawGrid(ax); + if(strchr(dir,'y')) DrawGrid(ay); + if(strchr(dir,'z')) DrawGrid(az); + EndGroup(); +} +//----------------------------------------------------------------------------- +void mglCanvas::DrawGrid(mglAxis &aa) +{ + mglPoint pp[8]={Min,Min,Min,Min,Max,Max,Max,Max},nan=mglPoint(NAN), oo[8], org=Min; + pp[1].x=Max.x; pp[2].y=Max.y; pp[3].z=Max.z; + pp[4].x=Min.x; pp[5].y=Min.y; pp[6].z=Min.z; + mreal zm=INFINITY; + memcpy(oo,pp,8*sizeof(mglPoint)); + for(int i=0;i<8;i++) // find deepest point + { + ScalePoint(&B,pp[i],nan,false); + if(pp[i].z0) for(i=0;i0.2) ff[1]='R'; + strncpy(font,FontDef,63); strcat(font,ff); + long kk = AddPnt(&B, p,-1,q,0,7); ff[1]=0; + ff[0] = GetLabelPos(t, kk, *aa); strcat(font,ff); + text_plot(kk,text,font,-1.4,0.35+shift); + } + LoadState(); +} +//----------------------------------------------------------------------------- +void mglCanvas::Box(const char *col, bool ticks) +{ + mglPoint o = Org; + mreal tl=TickLen; + if(!ticks) TickLen=0; + set(MGL_NOSUBTICKS); Org = Min; + static int cgid=1; StartGroup("Box",cgid++); + Axis("xyz_",col); + if(TernAxis&1) + { + Org.x=Max.x; Org.y=Min.y; Org.z=Max.z; + DrawAxis(ax, false, 0,col); DrawAxis(az, false, 0,col); + Org.x=Min.x; Org.y=Max.y; Org.z=Max.z; + DrawAxis(az, false, 0,col); + + mglAxis ty(ay); ty.ch='T'; + ty.dir = mglPoint(-1,1); ty.org = mglPoint(1,0,Max.z); + DrawAxis(ty, false, 0,col); ty.ch='t'; + ty.dir = mglPoint(0,-1); ty.org = mglPoint(0,1,Max.z); + DrawAxis(ty, false, 0,col); + } + else if(TernAxis&2) + { + mglAxis ty(az); + ty.ch='T'; ty.a=mglPoint(1,0); ty.b=mglPoint(-1,1); + ty.dir = mglPoint(-1,0,1); ty.org = mglPoint(1,0,0); + DrawAxis(ty, false, 0,col); + ty.ch='t'; ty.a=mglPoint(0,1); ty.b=mglPoint(-1,1); + ty.dir = mglPoint(0,-1,1); ty.org = mglPoint(0,1,0); + DrawAxis(ty, false, 0,col); + } + else + { + Org.z=Max.z; Axis("xy_",col); + Org = Max; Axis("xyz_",col); + Org.z=Min.z; Axis("xy_",col); + Org.x=Min.x; DrawAxis(az,0,0,col); + Org.x=Max.x; Org.y=Min.y; DrawAxis(az,0,0,col); + if(mglchr(col,'@')) + { + // edge points + mglPoint p[8]={Min,Min,Min,Min,Max,Max,Max,Max},nan=mglPoint(NAN),oo[8]; + p[1].x=Max.x; p[2].y=Max.y; p[3].z=Max.z; + p[4].x=Min.x; p[5].y=Min.y; p[6].z=Min.z; + mreal zm=INFINITY; int im=0; + memcpy(oo,p,8*sizeof(mglPoint)); + for(int i=0;i<8;i++) // find deepest point + { + ScalePoint(&B,p[i],nan,false); + if(p[i].z1 && col[i-1]=='{') { color[1]=col[i]; color[2]=col[i+1]; break; } + else { color[0]=col[i]; color[1]=0; break; } + } + } + long *pos = new long[3*31*31]; + SetPenPal(color); + mreal dx = (Max.x-Min.x)/30, dy = (Max.y-Min.y)/30, dz = (Max.z-Min.z)/30; + for(long i=0;i<31;i++) for(long j=0;j<31;j++) + { + register long i0=3*(i+31*j); + pos[i0] = AddPnt(mglPoint(oo[im].x,Min.y+dy*i,Min.z+dz*j)); + pos[i0+1] = AddPnt(mglPoint(Min.x+dx*i,oo[im].y,Min.z+dz*j)); + pos[i0+2] = AddPnt(mglPoint(Min.x+dx*i,Min.y+dy*j,oo[im].z)); + } + for(long i=0;i<30;i++) for(long j=0;j<30;j++) + { + register long i0=3*(i+31*j); + quad_plot(pos[i0],pos[i0+3],pos[i0+93],pos[i0+96]); + quad_plot(pos[i0+1],pos[i0+4],pos[i0+94],pos[i0+97]); + quad_plot(pos[i0+2],pos[i0+5],pos[i0+95],pos[i0+98]); + } + delete []pos; +// mgl_facex(this, oo[im].x, Min.y, Min.z, Max.y-Min.y, Max.z-Min.z, color,0,0); +// mgl_facey(this, Min.x, oo[im].y, Min.z, Max.x-Min.x, Max.z-Min.z, color,0,0); +// mgl_facez(this, Min.x, Min.y, oo[im].z, Max.x-Min.x, Max.y-Min.y, color,0,0); + } + } + EndGroup(); + clr(MGL_NOSUBTICKS); Org=o; TickLen=tl; +} +//----------------------------------------------------------------------------- +void mglCanvas::Colorbar(const char *sch) +{ + bool in = mglchr(sch,'I'); + mreal sx = (fabs(B.b[0])+fabs(B.b[1])+fabs(B.b[2]))/B.pf/B1.b[0], x=1; + mreal sy = (fabs(B.b[3])+fabs(B.b[4])+fabs(B.b[5]))/B.pf/B1.b[4], y=0; + if(mglchr(sch,'>')) { x=in?(1+sx)/2:1; y=0; } + if(mglchr(sch,'<')) { x=in?(1-sx)/2:0; y=0; } + if(mglchr(sch,'^')) { x=0; y=in?(1+sy)/2:1; } + if(mglchr(sch,'_')) { x=0; y=in?(1-sy)/2:0; } + Colorbar(sch, x, y, 1, 1); +} +//----------------------------------------------------------------------------- +void mglCanvas::Colorbar(const char *sch, mreal x, mreal y, mreal w, mreal h) +{ + bool in = mglchr(sch,'I'); + bool text = !mglchr(sch,'~'); + int where = 0; // ‘0’ - right, ‘1’ - left, ‘2’ - above, ‘3’ - under + if(mglchr(sch,'>')) where = in?1:0; + if(mglchr(sch,'<')) where = in?0:1; + if(mglchr(sch,'^')) where = in?3:2; + if(mglchr(sch,'_')) where = in?2:3; + if(mglchr(sch,'A')) { Push(); Identity(); } + + long n=256, s = AddTexture(sch); + mglData v(n); + if(ac.d || Min.c*Max.c<=0) v.Fill(Min.c,Max.c); + else if(Max.c>Min.c && Min.c>0) + { v.Fill(log(Min.c), log(Max.c)); v.Modify("exp(u)"); } + else if(Min.c')) { x=in?(1+sx)/2:1; y=0; } + if(mglchr(sch,'<')) { x=in?(1-sx)/2:0; y=0; } + if(mglchr(sch,'^')) { x=0; y=in?(1+sy)/2:1; } + if(mglchr(sch,'_')) { x=0; y=in?(1-sy)/2:0; } + Colorbar(v, sch, x, y, 1, 1); +} +//----------------------------------------------------------------------------- +void mglCanvas::Colorbar(HCDT v, const char *sch, mreal x, mreal y, mreal w, mreal h) +{ + bool in = mglchr(sch,'I'); + bool text = !mglchr(sch,'~'); + int where = 0; + if(mglchr(sch,'>')) where = in?1:0; + if(mglchr(sch,'<')) where = in?0:1; + if(mglchr(sch,'^')) where = in?3:2; + if(mglchr(sch,'_')) where = in?2:3; + if(mglchr(sch,'A')) { Push(); Identity(); } + + mreal *c=new mreal[v->GetNx()]; + if(!mgl_have_color(sch)) sch = MGL_DEF_PAL; + long s = AddTexture(sch); + int nc = GetNumPal(s*256); + mreal dc = nc>1 ? 1/(MGL_EPSILON*(nc-1)):0; + for(long i=0;iGetNx();i++) c[i] = s+i*dc; + colorbar(v, c, where, x, y, w, h, text); + delete []c; + if(mglchr(sch,'A')) Pop(); +} +//----------------------------------------------------------------------------- +void mglCanvas::colorbar(HCDT vv, const mreal *c, int where, mreal x, mreal y, mreal w, mreal h, bool text) +{ + static int cgid=1; StartGroup("Colorbar",cgid++); + long n=vv->GetNx(); + long n1,n2,n3,n4; + mreal d,s3=B.pf,ss=1/s3; // NOTE: colorbar was wider ss=0.9; + mglPoint p1,p2; + mglMatrix M=B1; M.pf=s3; M.norot=true; + + set(MGL_DISABLE_SCALE); // NOTE this make colorbar non-thread-safe!!! + x = s3*(2*x-1); y = s3*(2*y-1); w *= s3; h *= s3; + mask = MGL_SOLID_MASK; + for(long i=0;iv(i))*2-1; + p1 = p2 = mglPoint((ss*d+1)*w+x, (ss*d+1)*h+y, s3); + switch(where) + { + case 1: p1.x = x; p2.x = x+0.1*w; break; + case 2: p1.y = y-0.1*h; p2.y = y; break; + case 3: p1.y = y; p2.y = y+0.1*h; break; + default:p1.x = x-0.1*w; p2.x = x; break; + } + n1 = AddPnt(&M, p1,c[i]); n2 = AddPnt(&M, p2,c[i]); + d = GetA(vv->v(i+1))*2-1; + p1 = p2 = mglPoint((ss*d+1)*w+x, (ss*d+1)*h+y, s3); + switch(where) + { + case 1: p1.x = x; p2.x = x+0.1*w; break; + case 2: p1.y = y-0.1*h; p2.y = y; break; + case 3: p1.y = y; p2.y = y+0.1*h; break; + default:p1.x = x-0.1*w; p2.x = x; break; + } + n3 = AddPnt(&M, p1,c[i]); n4 = AddPnt(&M, p2,c[i]); + quad_plot(n1,n2,n3,n4); + } + if(n<64) + { + wchar_t buf[64]; ac.txt.clear(); + for(long i=0;iv(i); + mglprintf(buf,64,ac.t.empty()?(fabs(d)<1 ? L"%.2g" : L"%.3g"):ac.t.c_str(),d); + ac.AddLabel(buf,d); + } + } + else { UpdateAxis(); AdjustTicks(ac,fa!=0); } + // hint for using standard label drawing function + SetPenPal(TickStl); + for(size_t i=0;i1 && fabs(y)>1; + bool inv = where!=3 && where!=0; + ac.ns = where; + if(text) DrawLabels(ac,inv,&M); // NOTE ns isn't used for colorbar + clr(MGL_DISABLE_SCALE); EndGroup(); +} +//----------------------------------------------------------------------------- diff --git a/src/base.cpp b/src/base.cpp new file mode 100644 index 0000000..0686552 --- /dev/null +++ b/src/base.cpp @@ -0,0 +1,1404 @@ +/*************************************************************************** + * base.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/font.h" +#include "mgl2/base.h" +#include "mgl2/eval.h" +//----------------------------------------------------------------------------- +char *mgl_strdup(const char *s) +{ + char *r = (char *)malloc((strlen(s)+1)*sizeof(char)); + memcpy(r,s,(strlen(s)+1)*sizeof(char)); + return r; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_create_cpp_font(HMGL gr, const wchar_t *how) +{ + unsigned long l=mgl_wcslen(how), i, n=0, m; + wchar_t ch=*how; + const mglFont *f = gr->GetFont(); + std::vector s; s.push_back(ch); + for(i=1;iInternal(s[i]); + l += 2*f->GetNl(0,ch); + n += 6*f->GetNt(0,ch); + } + printf("unsigned mgl_numg=%lu, mgl_cur=%lu;\n",(unsigned long)s.size(),l+n); + printf("float mgl_fact=%g;\n",f->GetFact(0)/mgl_fgen); + printf("long mgl_gen_fnt[%lu][6] = {\n", (unsigned long)s.size()); + for(i=m=0;iInternal(s[i]); + int m1 = f->GetNl(0,ch), m2 = f->GetNt(0,ch); + printf("\t{0x%x,%d,%d,%lu,%d,%lu},\n",unsigned(s[i]),f->GetWidth(0,ch),m1,m,m2,m+2*m1); + m += 2*m1+6*m2; + } + if(m!=l+n) printf("#error \"%lu !=%lu + %lu\"",m,l,n); + printf("};\nshort mgl_buf_fnt[%lu] = {\n",m); + for(i=0;iInternal(s[i]); + unsigned m1 = f->GetNl(0,ch), m2 = f->GetNt(0,ch); + const short *ln = f->GetLn(0,ch), *tr = f->GetTr(0,ch); + for(l=0;l<2*m1;l++) printf("%d,",ln[l]); + printf("\n"); + for(l=0;l<6*m2;l++) printf("%d,",tr[l]); + printf("\n"); + } + printf("};\n"); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_strtrim(char *str) +{ + if(!str || *str==0) return; + size_t n=strlen(str), k, i; + for(k=0;k' ') break; + for(i=n;i>k;i--) if(str[i-1]>' ') break; + memmove(str, str+k, (i-k)); + str[i-k]=0; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_strlwr(char *str) +{ + register size_t k,l=strlen(str); + for(k=0;k='A' && str[k]<='Z') ? str[k]+'a'-'A' : str[k]; +} +//----------------------------------------------------------------------------- +mglBase::mglBase() +{ + Flag=0; saved=false; +#if MGL_HAVE_PTHREAD + pthread_mutex_init(&mutexPnt,0); + pthread_mutex_init(&mutexTxt,0); + pthread_mutex_init(&mutexSub,0); + pthread_mutex_init(&mutexLeg,0); + pthread_mutex_init(&mutexPrm,0); + pthread_mutex_init(&mutexPtx,0); + pthread_mutex_init(&mutexStk,0); + pthread_mutex_init(&mutexGrp,0); + pthread_mutex_init(&mutexGlf,0); + pthread_mutex_init(&mutexAct,0); + pthread_mutex_init(&mutexDrw,0); +#endif + fnt=0; *FontDef=0; fx=fy=fz=fa=fc=0; + AMin = mglPoint(0,0,0,0); AMax = mglPoint(1,1,1,1); + + InUse = 1; SetQuality(); FaceNum = 0; + // Always create default palette txt[0] and default scheme txt[1] +#pragma omp critical(txt) + { + mglTexture t1(MGL_DEF_PAL,-1), t2(MGL_DEF_SCH,1); + Txt.reserve(3); + MGL_PUSH(Txt,t1,mutexTxt); + MGL_PUSH(Txt,t2,mutexTxt); + } + memcpy(last_style,"{k5}-1\0",8); + MinS=mglPoint(-1,-1,-1); MaxS=mglPoint(1,1,1); + fnt = new mglFont; fnt->gr = this; PrevState=NAN; +} +mglBase::~mglBase() { ClearEq(); delete fnt; } +//----------------------------------------------------------------------------- +void mglBase::RestoreFont() { fnt->Restore(); } +void mglBase::LoadFont(const char *name, const char *path) +{ if(name && *name) fnt->Load(name,path); else fnt->Restore(); } +void mglBase::CopyFont(mglBase *gr) { fnt->Copy(gr->GetFont()); } +//----------------------------------------------------------------------------- +mreal mglBase::TextWidth(const char *text, const char *font, mreal size) const +{ return (size<0?-size*FontSize:size)*font_factor*fnt->Width(text,(font&&*font)?font:FontDef)/20.16; } +mreal mglBase::TextWidth(const wchar_t *text, const char *font, mreal size) const +{ return (size<0?-size*FontSize:size)*font_factor*fnt->Width(text,(font&&*font)?font:FontDef)/20.16; } +mreal mglBase::TextHeight(const char *font, mreal size) const +{ return (size<0?-size*FontSize:size)*font_factor*fnt->Height(font?font:FontDef)/20.16; } +void mglBase::AddActive(long k,int n) +{ + if(k<0 || (size_t)k>=Pnt.size()) return; + mglActivePos p; + const mglPnt &q=Pnt[k]; + int h=GetHeight(); + p.x = int(q.x); p.y = h>1?h-1-int(q.y):int(q.y); + p.id = ObjId; p.n = n; +#pragma omp critical(act) + MGL_PUSH(Act,p,mutexAct); +} +//----------------------------------------------------------------------------- +mreal mglBase::GetRatio() const { return 1; } +int mglBase::GetWidth() const { return 1; } +int mglBase::GetHeight() const { return 1; } +//----------------------------------------------------------------------------- +void mglBase::StartGroup(const char *name, int id) +{ + LightScale(&B); + char buf[128]; + snprintf(buf,128,"%s_%d",name,id); + StartAutoGroup(buf); +} +//----------------------------------------------------------------------------- +const char *mglWarn[mglWarnEnd] = {"data dimension(s) is incompatible", //mglWarnDim + "data dimension(s) is too small", //mglWarnLow + "minimal data value is negative", //mglWarnNeg + "no file or wrong data dimensions", //mglWarnFile + "not enough memory", //mglWarnMem + "data values are zero", //mglWarnZero + "no legend entries", //mglWarnLeg + "slice value is out of range", //mglWarnSlc + "number of contours is zero or negative",//mglWarnCnt + "couldn't open file", //mglWarnOpen + "light: ID is out of range", //mglWarnLId + "size(s) is zero or negative", //mglWarnSize + "format is not supported for that build",//mglWarnFmt + "axis ranges are incompatible", //mglWarnTern + "pointer is NULL", //mglWarnNull + "not enough space for plot", //mglWarnSpc + "There are wrong argument(s) in script",//mglScrArg + "There are wrong command in script", //mglScrCmd + "There are too long string in script", //mglScrLong + "There are unbalanced ' in script"}; //mglScrStr +//----------------------------------------------------------------------------- +void mglBase::SetWarn(int code, const char *who) +{ + WarnCode = code>0 ? code:0; + if(code>0 && code0?new short[6*nt]:0; + if(line) delete []line; + line = nl>0?new short[2*nl]:0; +} +//----------------------------------------------------------------------------- +bool mglGlyph::operator==(const mglGlyph &g) +{ + if(nl!=g.nl || nt!=g.nt) return false; + if(trig && memcmp(trig,g.trig,6*nt*sizeof(short))) return false; + if(line && memcmp(line,g.line,2*nl*sizeof(short))) return false; + return true; +} +//----------------------------------------------------------------------------- +long mglBase::AddGlyph(int s, long j) +{ + // first create glyph for current typeface + s = s&3; + mglGlyph g(fnt->GetNt(s,j), fnt->GetNl(s,j)); + memcpy(g.trig, fnt->GetTr(s,j), 6*g.nt*sizeof(short)); + memcpy(g.line, fnt->GetLn(s,j), 2*g.nl*sizeof(short)); + // now let find the similar glyph + for(size_t i=0;i0) ScalePoint(mat,p,n,!(scl&2)); + if(mgl_isnan(p.x)) return -1; + a = (a>=0 && a<=1) ? a : AlphaDef; + c = (c>=0) ? c:CDef; + + mglPnt q; + if(get(MGL_REDUCEACC)) + { + q.x=q.xx=int(p.x*10)*0.1; q.y=q.yy=int(p.y*10)*0.1; q.z=q.zz=int(p.z*10)*0.1; + q.c=int(c*100)*0.01; q.t=q.ta=int(a*100)*0.01; + q.u=mgl_isnum(n.x)?int(n.x*100)*0.01:NAN; + q.v=mgl_isnum(n.y)?int(n.y*100)*0.01:NAN; + q.w=mgl_isnum(n.z)?int(n.z*100)*0.01:NAN; + } + else + { + q.x=q.xx=p.x; q.y=q.yy=p.y; q.z=q.zz=p.z; + q.c=c; q.t=q.ta=a; q.u=n.x; q.v=n.y; q.w=n.z; + } + register long ci=long(c); + if(ci<0 || ci>=(long)Txt.size()) ci=0; // NOTE never should be here!!! + const mglTexture &txt=Txt[ci]; + txt.GetC(c,a,q); // RGBA color + + // add gap for texture coordinates for compatibility with OpenGL + const mreal gap = 0./MGL_TEXTURE_COLOURS; + q.c = ci+(q.c-ci)*(1-2*gap)+gap; + q.t = q.t*(1-2*gap)+gap; + q.ta = q.t; + + if(scl&8 && scl>0) q.a=a; // bypass palette for enabling alpha in Error() + if(!get(MGL_ENABLE_ALPHA)) { q.a=1; if(txt.Smooth!=2) q.ta=1-gap; } + if(norefr) q.v=0; + if(!get(MGL_ENABLE_LIGHT) && !(scl&4)) q.u=q.v=NAN; + if(mat->norot) q.sub=-1; // NOTE: temporary -- later should be mglInPlot here + long k; +#pragma omp critical(pnt) + {k=Pnt.size(); MGL_PUSH(Pnt,q,mutexPnt);} return k; +} +//----------------------------------------------------------------------------- +long mglBase::CopyNtoC(long from, mreal c) +{ + if(from<0) return -1; + mglPnt p=Pnt[from]; + if(mgl_isnum(c)) { p.c=c; p.t=0; Txt[long(c)].GetC(c,0,p); } + long k; +#pragma omp critical(pnt) + {k=Pnt.size(); MGL_PUSH(Pnt,p,mutexPnt);} return k; +} +//----------------------------------------------------------------------------- +long mglBase::CopyProj(long from, mglPoint p, mglPoint n) +{ + if(from<0) return -1; + mglPnt q=Pnt[from]; + q.x=q.xx=p.x; q.y=q.yy=p.y; q.z=q.zz=p.z; + q.u = n.x; q.v = n.y; q.w = n.z; + long k; +#pragma omp critical(pnt) + {k=Pnt.size(); MGL_PUSH(Pnt,q,mutexPnt);} return k; +} +//----------------------------------------------------------------------------- +void mglBase::Reserve(long n) +{ + if(TernAxis&4) n*=4; +#pragma omp critical(pnt) + Pnt.reserve(n); +#pragma omp critical(prm) + Prm.reserve(n); +} +//----------------------------------------------------------------------------- +// Boundaries and scaling +//----------------------------------------------------------------------------- +bool mglBase::RecalcCRange() +{ + bool wrong=false; + if(!fa) + { FMin.c = Min.c; FMax.c = Max.c; } + else + { + FMin.c = INFINITY; FMax.c = -INFINITY; + register int i; + mreal a; + int n=30; + for(i=0;i<=n;i++) + { + a = fa->Calc(0,0,0,Min.c+i*(Max.c-Min.c)/n); + if(mgl_isbad(a)) wrong=true; + if(aFMax.c) FMax.c=a; + } + } + return wrong; +} +//----------------------------------------------------------------------------- +void mglBase::RecalcBorder() +{ + ZMin = 1.; + bool wrong=false; + if(!fx && !fy && !fz) + { FMin = Min; FMax = Max; } + else + { + FMin = mglPoint( INFINITY, INFINITY, INFINITY); + FMax = mglPoint(-INFINITY,-INFINITY,-INFINITY); + register int i,j; + int n=30; + for(i=0;i<=n;i++) for(j=0;j<=n;j++) // x range + { + if(SetFBord(Min.x, Min.y+i*(Max.y-Min.y)/n, Min.z+j*(Max.z-Min.z)/n)) wrong=true; + if(SetFBord(Max.x, Min.y+i*(Max.y-Min.y)/n, Min.z+j*(Max.z-Min.z)/n)) wrong=true; + } + for(i=0;i<=n;i++) for(j=0;j<=n;j++) // y range + { + if(SetFBord(Min.x+i*(Max.x-Min.x)/n, Min.y, Min.z+j*(Max.z-Min.z)/n)) wrong=true; + if(SetFBord(Min.x+i*(Max.x-Min.x)/n, Max.y, Min.z+j*(Max.z-Min.z)/n)) wrong=true; + } + for(i=0;i<=n;i++) for(j=0;j<=n;j++) // x range + { + if(SetFBord(Min.x+i*(Max.x-Min.x)/n, Min.y+j*(Max.y-Min.y)/n, Min.z)) wrong=true; + if(SetFBord(Min.x+i*(Max.x-Min.x)/n, Min.y+j*(Max.y-Min.y)/n, Max.z)) wrong=true; + } + mreal d; + if(!fx) { FMin.x = Min.x; FMax.x = Max.x; } + else { d=0.01*(FMax.x-FMin.x); FMin.x-=d; FMax.x+=d; } + if(!fy) { FMin.y = Min.y; FMax.y = Max.y; } + else { d=0.01*(FMax.y-FMin.y); FMin.y-=d; FMax.y+=d; } + if(!fz) { FMin.z = Min.z; FMax.z = Max.z; } + else { d=0.01*(FMax.z-FMin.z); FMin.z-=d; FMax.z+=d; } + } + if(RecalcCRange()) wrong=true; + if(wrong) SetWarn(mglWarnTern, "Curved coordinates"); +} +//----------------------------------------------------------------------------- +bool mglBase::SetFBord(mreal x,mreal y,mreal z) +{ + bool wrong=false; + if(fx) + { + mreal v = fx->Calc(x,y,z); + if(mgl_isbad(v)) wrong = true; + if(FMax.x < v) FMax.x = v; + if(FMin.x > v) FMin.x = v; + } + if(fy) + { + mreal v = fy->Calc(x,y,z); + if(mgl_isbad(v)) wrong = true; + if(FMax.y < v) FMax.y = v; + if(FMin.y > v) FMin.y = v; + } + if(fz) + { + mreal v = fz->Calc(x,y,z); + if(mgl_isbad(v)) wrong = true; + if(FMax.z < v) FMax.z = v; + if(FMin.z > v) FMin.z = v; + } + return wrong; +} +//----------------------------------------------------------------------------- +bool mglBase::ScalePoint(const mglMatrix *, mglPoint &p, mglPoint &n, bool use_nan) const +{ + mreal &x=p.x, &y=p.y, &z=p.z; + if(mgl_isnan(x) || mgl_isnan(y) || mgl_isnan(z)) { x=NAN; return false; } + mreal x1,y1,z1,x2,y2,z2; + x1 = x>0?x*MGL_EPSILON:x/MGL_EPSILON; x2 = x<0?x*MGL_EPSILON:x/MGL_EPSILON; + y1 = y>0?y*MGL_EPSILON:y/MGL_EPSILON; y2 = y<0?y*MGL_EPSILON:y/MGL_EPSILON; + z1 = z>0?z*MGL_EPSILON:z/MGL_EPSILON; z2 = z<0?z*MGL_EPSILON:z/MGL_EPSILON; + bool res = true; + if(x2>CutMin.x && x1CutMin.y && y1CutMin.z && z1Calc(x,y,z)!=0) res = false; + + if(get(MGL_ENABLE_CUT) || !use_nan) + { +// if(x1Max.x || y1Max.y || z1Max.z) res = false; + if((x1-Min.x)*(x1-Max.x)>0 && (x2-Min.x)*(x2-Max.x)>0) res = false; + if((y1-Min.y)*(y1-Max.y)>0 && (y2-Min.y)*(y2-Max.y)>0) res = false; + if((z1-Min.z)*(z1-Max.z)>0 && (z2-Min.z)*(z2-Max.z)>0) res = false; + } + else + { + if(x1Max.x) {x=Max.x; n=mglPoint(1,0,0);} + if(y1Max.y) {y=Max.y; n=mglPoint(0,1,0);} + if(z1Max.z) {z=Max.z; n=mglPoint(0,0,1);} + } + + x1=x; y1=y; z1=z; x2=y2=z2=1; + if(fx) { x1 = fx->Calc(x,y,z); x2 = fx->CalcD('x',x,y,z); } + if(fy) { y1 = fy->Calc(x,y,z); y2 = fy->CalcD('y',x,y,z); } + if(fz) { z1 = fz->Calc(x,y,z); z2 = fz->CalcD('z',x,y,z); } + if(mgl_isnan(x1) || mgl_isnan(y1) || mgl_isnan(z1)) { x=NAN; return false; } + + register mreal d; // TODO: should I update normale for infinite light source (x=NAN)?!? + d = 1/(FMax.x - FMin.x); x = (2*x1 - FMin.x - FMax.x)*d; x2 *= 2*d; + d = 1/(FMax.y - FMin.y); y = (2*y1 - FMin.y - FMax.y)*d; y2 *= 2*d; + d = 1/(FMax.z - FMin.z); z = (2*z1 - FMin.z - FMax.z)*d; z2 *= 2*d; + n.x *= y2*z2; n.y *= x2*z2; n.z *= x2*y2; + if((TernAxis&3)==1) // usual ternary axis + { + if(x+y>0) + { + if(get(MGL_ENABLE_CUT)) res = false; + else y = -x; + } + x += (y+1)/2; n.x += n.y/2; + } + else if((TernAxis&3)==2) // quaternary axis + { + if(x+y+z>-1) + { + if(get(MGL_ENABLE_CUT)) res = false; + else z = -1-y-x; + } + x += 1+(y+z)/2; y += (z+1)/3; + n.x += (n.y+n.z)/2; n.y += n.z/3; + } + if(fabs(x)>MGL_FEPSILON || fabs(y)>MGL_FEPSILON || fabs(z)>MGL_FEPSILON) res = false; + + if(!res && use_nan) x = NAN; // extra sign that point shouldn't be plotted + return res; +} +//----------------------------------------------------------------------------- +// Ranges +//----------------------------------------------------------------------------- +void mglScaleAxis(mreal &v1, mreal &v2, mreal &v0, mreal x1, mreal x2) +{ + if(x1==x2 || v1==v2) return; + mreal dv,d0; x2-=1; + if(v1*v2>0 && (v2/v1>=100 || v2/v1<=0.01)) // log scale + { + dv=log(v2/v1); d0 = log(v0/v1)/log(v2/v1); + v1*=exp(dv*x1); v2*=exp(dv*x2); v0=v1*exp(d0*log(v2/v1)); + } + else + { + dv=v2-v1; d0=(v0-v1)/(v2-v1); + v1+=dv*x1; v2+=dv*x2; v0=v1+d0*(v2-v1); + } +} +//----------------------------------------------------------------------------- +void mglBase::SetOrigin(mreal x0, mreal y0, mreal z0, mreal c0) +{ + Org=mglPoint(x0,y0,z0,c0); + if((TernAxis&3)==0) + { + Min = OMin; Max = OMax; + mglScaleAxis(Min.x, Max.x, Org.x, AMin.x, AMax.x); + mglScaleAxis(Min.y, Max.y, Org.y, AMin.y, AMax.y); + mglScaleAxis(Min.z, Max.z, Org.z, AMin.z, AMax.z); + mglScaleAxis(Min.c, Max.c, Org.c, AMin.c, AMax.c); + } +} +//----------------------------------------------------------------------------- +void mglBase::SetRanges(mglPoint m1, mglPoint m2) +{ + if(m1.x!=m2.x) { Min.x=m1.x; Max.x=m2.x; } + if(m1.y!=m2.y) { Min.y=m1.y; Max.y=m2.y; } + if(m1.z!=m2.z) { Min.z=m1.z; Max.z=m2.z; } + if(m1.c!=m2.c) { Min.c=m1.c; Max.c=m2.c; } + else { Min.c=Min.z;Max.c=Max.z;} + + if(Org.xMax.x && mgl_isnum(Org.x)) Org.x = Max.x; + if(Org.yMax.y && mgl_isnum(Org.y)) Org.y = Max.y; + if(Org.zMax.z && mgl_isnum(Org.z)) Org.z = Max.z; + + if((TernAxis&3)==0) + { + OMax = Max; OMin = Min; + mglScaleAxis(Min.x, Max.x, Org.x, AMin.x, AMax.x); + mglScaleAxis(Min.y, Max.y, Org.y, AMin.y, AMax.y); + mglScaleAxis(Min.z, Max.z, Org.z, AMin.z, AMax.z); + mglScaleAxis(Min.c, Max.c, Org.c, AMin.c, AMax.c); + } + + CutMin = mglPoint(0,0,0); CutMax = mglPoint(0,0,0); + RecalcBorder(); +} +//----------------------------------------------------------------------------- +void mglBase::CRange(HCDT a,bool add, mreal fact) +{ + mreal v1=a->Minimal(), v2=a->Maximal(), dv; + dv=(v2-v1)*fact; v1 -= dv; v2 += dv; + CRange(v1,v2,add); +} +void mglBase::CRange(mreal v1,mreal v2,bool add) +{ + if(v1==v2 && !add) return; + if(!add) + { + if(v1==v1) Min.c = v1; + if(v2==v2) Max.c = v2; + } + else if(Min.cv1) Min.c=v1; + if(Max.cdv ? v2:dv; + } + if(Org.cMax.c && mgl_isnum(Org.c)) Org.c = Max.c; + if((TernAxis&3)==0) + { + OMax.c = Max.c; OMin.c = Min.c; + mglScaleAxis(Min.c, Max.c, Org.c, AMin.c, AMax.c); + } + RecalcCRange(); +} +//----------------------------------------------------------------------------- +void mglBase::XRange(HCDT a,bool add,mreal fact) +{ + mreal v1=a->Minimal(), v2=a->Maximal(), dv; + dv=(v2-v1)*fact; v1 -= dv; v2 += dv; + XRange(v1,v2,add); +} +void mglBase::XRange(mreal v1,mreal v2,bool add) +{ + if(v1==v2 && !add) return; + if(!add) + { + if(v1==v1) Min.x = v1; + if(v2==v2) Max.x = v2; + } + else if(Min.xv1) Min.x=v1; + if(Max.xdv ? v2:dv; + } + if(Org.xMax.x && mgl_isnum(Org.x)) Org.x = Max.x; + if((TernAxis&3)==0) + { + OMax.x = Max.x; OMin.x = Min.x; + mglScaleAxis(Min.x, Max.x, Org.x, AMin.x, AMax.x); + } + RecalcBorder(); +} +//----------------------------------------------------------------------------- +void mglBase::YRange(HCDT a,bool add,mreal fact) +{ + mreal v1=a->Minimal(), v2=a->Maximal(), dv; + dv=(v2-v1)*fact; v1 -= dv; v2 += dv; + YRange(v1,v2,add); +} +void mglBase::YRange(mreal v1,mreal v2,bool add) +{ + if(v1==v2 && !add) return; + if(!add) + { + if(v1==v1) Min.y = v1; + if(v2==v2) Max.y = v2; + } + else if(Min.yv1) Min.y=v1; + if(Max.ydv ? v2:dv; + } + if(Org.yMax.y && mgl_isnum(Org.y)) Org.y = Max.y; + if((TernAxis&3)==0) + { + OMax.y = Max.y; OMin.y = Min.y; + mglScaleAxis(Min.y, Max.y, Org.y, AMin.y, AMax.y); + + } + RecalcBorder(); +} +//----------------------------------------------------------------------------- +void mglBase::ZRange(HCDT a,bool add,mreal fact) +{ + mreal v1=a->Minimal(), v2=a->Maximal(), dv; + dv=(v2-v1)*fact; v1 -= dv; v2 += dv; + ZRange(v1,v2,add); +} +void mglBase::ZRange(mreal v1,mreal v2,bool add) +{ + if(v1==v2 && !add) return; + if(!add) + { + if(v1==v1) Min.z = v1; + if(v2==v2) Max.z = v2; + } + else if(Min.zv1) Min.z=v1; + if(Max.zdv ? v2:dv; + } + if(Org.zMax.z && mgl_isnum(Org.z)) Org.z = Max.z; + if((TernAxis&3)==0) + { + OMax.z = Max.z; OMin.z = Min.z; + mglScaleAxis(Min.z, Max.z, Org.z, AMin.z, AMax.z); + } + RecalcBorder(); +} +//----------------------------------------------------------------------------- +void mglBase::SetAutoRanges(mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2, mreal c1, mreal c2) +{ + if(x1!=x2) { Min.x = x1; Max.x = x2; } + if(y1!=y2) { Min.y = y1; Max.y = y2; } + if(z1!=z2) { Min.z = z1; Max.z = z2; } + if(c1!=c2) { Min.c = c1; Max.c = c2; } +} +//----------------------------------------------------------------------------- +void mglBase::Ternary(int t) +{ + static mglPoint x1(-1,-1,-1),x2(1,1,1),o(NAN,NAN,NAN); + static bool c = true; + TernAxis = t; + if(t&3) + { + if(c) { x1 = Min; x2 = Max; o = Org; } + SetRanges(mglPoint(0,0,0),mglPoint(1,1,(t&3)==1?0:1)); + Org=mglPoint(0,0,(t&3)==1?NAN:0); c = false; + } + else if(!c) { SetRanges(x1,x2); Org=o; c=true; } +} +//----------------------------------------------------------------------------- +// Transformation functions +//----------------------------------------------------------------------------- +void mglBase::SetFunc(const char *EqX,const char *EqY,const char *EqZ,const char *EqA) +{ + if(fa) delete fa; if(fx) delete fx; + if(fy) delete fy; if(fz) delete fz; + if(EqX && *EqX && (EqX[0]!='x' || EqX[1]!=0)) + fx = new mglFormula(EqX); + else fx = 0; + if(EqY && *EqY && (EqY[0]!='y' || EqY[1]!=0)) + fy = new mglFormula(EqY); + else fy = 0; + if(EqZ && *EqZ && (EqZ[0]!='z' || EqZ[1]!=0)) + fz = new mglFormula(EqZ); + else fz = 0; + if(EqA && *EqA && ((EqA[0]!='c' && EqA[0]!='a') || EqA[1]!=0)) + fa = new mglFormula(EqA); + else fa = 0; + RecalcBorder(); +} +//----------------------------------------------------------------------------- +void mglBase::CutOff(const char *EqC) +{ + if(fc) delete fc; + if(EqC && EqC[0]) fc = new mglFormula(EqC); else fc = 0; +} +//----------------------------------------------------------------------------- +void mglBase::SetCoor(int how) +{ + switch(how) + { + case mglCartesian: SetFunc(0,0); break; + case mglPolar: + SetFunc("x*cos(y)","x*sin(y)"); break; + case mglSpherical: + SetFunc("x*sin(y)*cos(z)","x*sin(y)*sin(z)","x*cos(y)"); break; + case mglParabolic: + SetFunc("x*y","(x*x-y*y)/2"); break; + case mglParaboloidal: + SetFunc("(x*x-y*y)*cos(z)/2","(x*x-y*y)*sin(z)/2","x*y"); break; + case mglOblate: + SetFunc("cosh(x)*cos(y)*cos(z)","cosh(x)*cos(y)*sin(z)","sinh(x)*sin(y)"); break; +// SetFunc("x*y*cos(z)","x*y*sin(z)","(x*x-1)*(1-y*y)"); break; + case mglProlate: + SetFunc("sinh(x)*sin(y)*cos(z)","sinh(x)*sin(y)*sin(z)","cosh(x)*cos(y)"); break; + case mglElliptic: + SetFunc("cosh(x)*cos(y)","sinh(x)*sin(y)"); break; + case mglToroidal: + SetFunc("sinh(x)*cos(z)/(cosh(x)-cos(y))","sinh(x)*sin(z)/(cosh(x)-cos(y))", + "sin(y)/(cosh(x)-cos(y))"); break; + case mglBispherical: + SetFunc("sin(y)*cos(z)/(cosh(x)-cos(y))","sin(y)*sin(z)/(cosh(x)-cos(y))", + "sinh(x)/(cosh(x)-cos(y))"); break; + case mglBipolar: + SetFunc("sinh(x)/(cosh(x)-cos(y))","sin(y)/(cosh(x)-cos(y))"); break; + case mglLogLog: SetFunc("lg(x)","lg(y)"); break; + case mglLogX: SetFunc("lg(x)",""); break; + case mglLogY: SetFunc("","lg(y)"); break; + default: SetFunc(0,0); break; + } +} +//----------------------------------------------------------------------------- +void mglBase::ClearEq() +{ + if(fx) delete fx; if(fy) delete fy; if(fz) delete fz; + if(fa) delete fa; if(fc) delete fc; + fx = fy = fz = fc = fa = 0; + RecalcBorder(); +} +//----------------------------------------------------------------------------- +// Colors ids +//----------------------------------------------------------------------------- +MGL_EXPORT mglColorID mglColorIds[31] = {{'k', mglColor(0,0,0)}, + {'r', mglColor(1,0,0)}, {'R', mglColor(0.5,0,0)}, + {'g', mglColor(0,1,0)}, {'G', mglColor(0,0.5,0)}, + {'b', mglColor(0,0,1)}, {'B', mglColor(0,0,0.5)}, + {'w', mglColor(1,1,1)}, {'W', mglColor(0.7,0.7,0.7)}, + {'c', mglColor(0,1,1)}, {'C', mglColor(0,0.5,0.5)}, + {'m', mglColor(1,0,1)}, {'M', mglColor(0.5,0,0.5)}, + {'y', mglColor(1,1,0)}, {'Y', mglColor(0.5,0.5,0)}, + {'h', mglColor(0.5,0.5,0.5)}, {'H', mglColor(0.3,0.3,0.3)}, + {'l', mglColor(0,1,0.5)}, {'L', mglColor(0,0.5,0.25)}, + {'e', mglColor(0.5,1,0)}, {'E', mglColor(0.25,0.5,0)}, + {'n', mglColor(0,0.5,1)}, {'N', mglColor(0,0.25,0.5)}, + {'u', mglColor(0.5,0,1)}, {'U', mglColor(0.25,0,0.5)}, + {'q', mglColor(1,0.5,0)}, {'Q', mglColor(0.5,0.25,0)}, + {'p', mglColor(1,0,0.5)}, {'P', mglColor(0.5,0,0.25)}, + {' ', mglColor(-1,-1,-1)}, {0, mglColor(-1,-1,-1)} // the last one MUST have id=0 +}; +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_chrrgb(char p, float c[3]) +{ + c[0]=c[1]=c[2]=-1; + for(long i=0; mglColorIds[i].id; i++) + if(mglColorIds[i].id==p) + { + c[0]=mglColorIds[i].col.r; + c[1]=mglColorIds[i].col.g; + c[2]=mglColorIds[i].col.b; + break; + } +} +//----------------------------------------------------------------------------- +void mglTexture::Set(const char *s, int smooth, mreal alpha) +{ + // NOTE: New syntax -- colors are CCCCC or {CNCNCCCN}; options inside [] + if(!s || !s[0]) return; + strncpy(Sch,s,259); Smooth=smooth; Alpha=alpha; + + register long i,j=0,m=0,l=strlen(s); + const char *dig = "0123456789abcdefABCDEF"; + bool map = smooth==2 || mglchr(s,'%'), sm = smooth>=0 && !strchr(s,'|'); // Use mapping, smoothed colors + for(i=0;i=0 && s[i]==':' && j<1) break; + if(s[i]=='[') j++; if(s[i]==']') j--; + if(strchr(MGL_COLORS,s[i]) && j<1) n++; + if(s[i]=='x' && i>0 && s[i-1]=='{' && j<1) n++; +// if(smooth && s[i]==':') break; // NOTE: should use [] + } + if(!n) + { + if((strchr(s,'|') || strchr(s,'!')) && !smooth) // sharp colors + { n=l=6; s=MGL_DEF_SCH; sm = false; } + else if(smooth==0) // none colors but color scheme + { n=l=6; s=MGL_DEF_SCH; } + else return; + } + bool man=sm; + mglColor *c = new mglColor[2*n]; // Colors itself + mreal *val = new mreal[n]; + for(i=j=n=0;i=0 && s[i]==':' && j<1) break; + if(s[i]=='[') j++; if(s[i]==']') j--; + if(s[i]=='{') m++; if(s[i]=='}') m--; + if(strchr(MGL_COLORS,s[i]) && j<1 && (m==0 || s[i-1]=='{')) // {CN,val} format, where val in [0,1] + { + if(m>0 && s[i+1]>'0' && s[i+1]<='9')// ext color + { c[2*n] = mglColor(s[i],(s[i+1]-'0')/5.f); i++; } + else c[2*n] = mglColor(s[i]); // usual color + val[n]=-1; n++; + } + if(s[i]=='x' && i>0 && s[i-1]=='{' && j<1) // {xRRGGBB,val} format, where val in [0,1] + { + if(strchr(dig,s[i+1]) && strchr(dig,s[i+2]) && strchr(dig,s[i+3]) && strchr(dig,s[i+4]) && strchr(dig,s[i+5]) && strchr(dig,s[i+6])) + { + char ss[3]="00"; c[2*n].a = 1; + ss[0] = s[i+1]; ss[1] = s[i+2]; c[2*n].r = strtol(ss,0,16)/255.; + ss[0] = s[i+3]; ss[1] = s[i+4]; c[2*n].g = strtol(ss,0,16)/255.; + ss[0] = s[i+5]; ss[1] = s[i+6]; c[2*n].b = strtol(ss,0,16)/255.; + if(strchr(dig,s[i+7]) && strchr(dig,s[i+8])) + { ss[0] = s[i+7]; ss[1] = s[i+8]; c[2*n].a = strtol(ss,0,16)/255.; i+=2; } + val[n]=-1; i+=6; n++; + } + } + if(s[i]==',' && m>0 && j<1 && n>0) + val[n-1] = atof(s+i+1); + // NOTE: User can change alpha if it placed like {AN} + if(s[i]=='A' && j<1 && m>0 && s[i+1]>'0' && s[i+1]<='9') + { man=false; alpha = 0.1*(s[i+1]-'0'); i++; } + } + for(long i=0;i def; + val[0]=0; val[n-1]=1; // boundary have to be [0,1] + for(long i=0;i0 && val[i]<1) def.push_back(i); + def.push_back(n-1); + long i1=0,i2; + for(size_t j=0;j0?def[j-1]:0; i2 = def[j]; + v1 = val[i1]; v2 = val[i2]; + v2 = i2-i1>1?(v2-v1)/(i2-i1):0; + val[i]=v1+v2*(i-i1); + } + // fill texture itself + mreal v=sm?(n-1)/255.:n/256.; + if(!sm) +//#pragma omp parallel for // remove parallel here due to possible race conditions for v<1 + for(long i=0;i<256;i++) + { + register long j = 2*long(v*i); //u-=j; + col[2*i] = c[j]; col[2*i+1] = c[j+1]; + } + else for(i=i1=0;i<256;i++) + { + register mreal u = v*i; j = long(u); //u-=j; + if(j=255*val[i1];i1++); + v2 = i1=0) SetMask(cols); + mglTexture t(cols,smooth,smooth==2?AlphaDef:1); + if(t.n==0) return smooth<0 ? 0:1; + if(smooth<0) CurrPal=0; + // check if already exist + for(size_t i=0;i=0) { p=(p+1)%n; id = 256*i+p; } + mglColor c = Txt[i].col[int(MGL_TEXTURE_COLOURS*(p+0.5)/n)]; + mreal dif, dmin=1; + // try to find closest color + for(long j=0;mglColorIds[j].id;j++) for(long k=1;k<10;k++) + { + mglColor cc; cc.Set(mglColorIds[j].col,k/5.); + dif = (c-cc).NormS(); + if(dif0 ? (p+0.5)/n : 0); CurrPal++; + return CDef; +} +//----------------------------------------------------------------------------- +mreal mglBase::NextColor(long id, long sh) +{ + long i=abs(id)/256, n=Txt[i].n, p=abs(id)&0xff; + if(id>=0) p=(p+sh)%n; + return i + (n>0 ? (p+0.5)/n : 0); +} +//----------------------------------------------------------------------------- +const char *mglchrs(const char *str, const char *chr) +{ + if(!str || !str[0] || !chr || !chr[0]) return NULL; + size_t l=strlen(chr); + for(size_t i=0;i0) continue; + s = mglchr(stl,p[i]); + if(s) { PDef = val[s-stl]; last_style[4]=p[i]; } + else if(mglchr(mrk,p[i])) mk = p[i]; + else if(mglchr(wdh,p[i])) + { last_style[5] = p[i]; PenWidth = p[i]-'0'; } + else if(mglchr(arr,p[i])) + { + if(!Arrow2) Arrow2 = p[i]; + else Arrow1 = p[i]; + } + } + if(Arrow1=='_') Arrow1=0; if(Arrow2=='_') Arrow2=0; + if(mglchr(p,'#')) + { + s = mglchr(mrk,mk); + if(s) mk = MRK[s-mrk]; + } + } + if(pal) + { + last_style[6]=mk; + long tt, n; + tt = AddTexture(p,-1); n=Txt[tt].n; + CDef = tt+((n+CurrPal-1)%n+0.5)/n; + if(Id) *Id=long(tt)*256+(n+CurrPal-1)%n; + } + return mk; +} +//----------------------------------------------------------------------------- +// keep this for restore default mask +uint64_t mgl_mask_def[16]={0x000000FF00000000, 0x080808FF08080808, 0x0000FF00FF000000, 0x0000007700000000, + 0x0000182424180000, 0x0000183C3C180000, 0x00003C24243C0000, 0x00003C3C3C3C0000, + 0x0000060990600000, 0x0060584658600000, 0x00061A621A060000, 0x0000005F00000000, + 0x0008142214080000, 0x00081C3E1C080000, 0x8142241818244281, 0x0000001824420000}; +uint64_t mgl_mask_val[16]={0x000000FF00000000, 0x080808FF08080808, 0x0000FF00FF000000, 0x0000007700000000, + 0x0000182424180000, 0x0000183C3C180000, 0x00003C24243C0000, 0x00003C3C3C3C0000, + 0x0000060990600000, 0x0060584658600000, 0x00061A621A060000, 0x0000005F00000000, + 0x0008142214080000, 0x00081C3E1C080000, 0x8142241818244281, 0x0000001824420000}; +void mglBase::SetMask(const char *p) +{ + mask = MGL_SOLID_MASK; // reset to solid face + PenWidth = 1; MaskAn=DefMaskAn; + if(p && *p) + { + const char *msk = MGL_MASK_ID, *s; + const char *wdh = "123456789"; + long m=0, l=strlen(p); + for(long i=0;i0) continue; + if(p[i]==':') break; + s = mglchr(msk, p[i]); + if(s) mask = mgl_mask_val[s-msk]; + else if(mglchr(wdh,p[i])) PenWidth = p[i]-'0'; + else if(p[i]=='I') MaskAn=90; + else if(p[i]=='/') MaskAn=315; // =360-45 + else if(p[i]=='\\') MaskAn=45; + } + // use line if rotation only specified + if(mask==MGL_SOLID_MASK && MaskAn!=0) mask = mgl_mask_val[0]; + } +} +//----------------------------------------------------------------------------- +mreal mglBase::GetA(mreal a) const +{ + if(fa) a = fa->Calc(0,0,0,a); + a = (a-FMin.c)/(FMax.c-FMin.c); + a = (a<1?(a>0?a:0):1)/MGL_FEPSILON; // for texture a must be <1 always!!! + return a; +} +//----------------------------------------------------------------------------- +mglPoint GetX(HCDT x, int i, int j, int k) +{ + k = kGetNz() ? k : 0; + if(x->GetNy()>1) + return mglPoint(x->v(i,j,k),x->dvx(i,j,k),x->dvy(i,j,k)); + else + return mglPoint(x->v(i),x->dvx(i),0); +} +//----------------------------------------------------------------------------- +mglPoint GetY(HCDT y, int i, int j, int k) +{ + k = kGetNz() ? k : 0; + if(y->GetNy()>1) + return mglPoint(y->v(i,j,k),y->dvx(i,j,k),y->dvy(i,j,k)); + else + return mglPoint(y->v(j),0,y->dvx(j)); +} +//----------------------------------------------------------------------------- +mglPoint GetZ(HCDT z, int i, int j, int k) +{ + if(z->GetNy()>1) + return mglPoint(z->v(i,j,k),z->dvx(i,j,k),z->dvy(i,j,k)); + else + return mglPoint(z->v(k),0,0); +} +//----------------------------------------------------------------------------- +void mglBase::vect_plot(long p1, long p2, mreal s) +{ + if(p1<0 || p2<0) return; + const mglPnt &q1=Pnt[p1], &q2=Pnt[p2]; + mglPnt s1=q2,s2=q2; + s = s<=0 ? 0.1 : s*0.1; + s1.x=s1.xx = q2.x - 3*s*(q2.x-q1.x) + s*(q2.y-q1.y); + s2.x=s2.xx = q2.x - 3*s*(q2.x-q1.x) - s*(q2.y-q1.y); + s1.y=s1.yy = q2.y - 3*s*(q2.y-q1.y) - s*(q2.x-q1.x); + s2.y=s2.yy = q2.y - 3*s*(q2.y-q1.y) + s*(q2.x-q1.x); + s1.z=s1.zz=s2.z=s2.zz = q2.z - 3*s*(q2.z-q1.z); + long n1,n2; +#pragma omp critical(pnt) + { + n1=Pnt.size(); MGL_PUSH(Pnt,s1,mutexPnt); + n2=Pnt.size(); MGL_PUSH(Pnt,s2,mutexPnt); + } + line_plot(p1,p2); line_plot(n1,p2); line_plot(p2,n2); +} +//----------------------------------------------------------------------------- +int mglFindArg(const char *str) +{ + long l=0,k=0,len=strlen(str); + for(long i=0;i0) { s[n]=0; s=s+n+1; } + mgl_strtrim(a); b=s; + n=mglFindArg(s); if(n>0) { s[n]=0; s=s+n+1; } + mgl_strtrim(b); + + mreal ff=atof(b),ss; + if(!strcmp(b,"on")) ff=1; + if(!strcmp(a+1,"range")) + { + n=mglFindArg(s); c=s; + if(n>0) { s[n]=0; s=s+n+1; } + mgl_strtrim(c); ss = atof(c); + if(a[0]=='x') { Min.x=ff; Max.x=ss; } + else if(a[0]=='y') { Min.y=ff; Max.y=ss; } + else if(a[0]=='z') { Min.z=ff; Max.z=ss; } +// else if(a[0]=='c') { Min.c=ff; Max.c=ss; } // Bad idea since there is formula for coloring + } + else if(!strcmp(a,"cut")) SetCut(ff!=0); + else if(!strcmp(a,"meshnum")) SetMeshNum(ff); + else if(!strcmp(a,"alpha")) {Alpha(true); SetAlphaDef(ff);} + else if(!strcmp(a,"light")) Light(ff!=0); + else if(!strcmp(a,"ambient")) SetAmbient(ff); + else if(!strcmp(a,"diffuse")) SetDifLight(ff); + else if(!strcmp(a,"size")) + { SetMarkSize(ff); SetFontSize(ff); SetArrowSize(ff); } + else if(!strcmp(a,"num") || !strcmp(a,"number") || !strcmp(a,"value")) res=ff; + else if(!strcmp(a,"legend")) + { if(*b=='\'') { b++; b[strlen(b)-1]=0; } leg_str = b; } + } + free(qi); PrevState=res; return res; +} +//----------------------------------------------------------------------------- +void mglBase::LoadState() +{ + if(!saved) return; + MarkSize=MSS; ArrowSize=ASS; + FontSize=FSS; AlphaDef=ADS; + MeshNum=MNS; Flag=CSS; AmbBr=LSS; + Min=MinS; Max=MaxS; saved=false; +} +//----------------------------------------------------------------------------- +void mglBase::AddLegend(const wchar_t *text,const char *style) +{ + if(text) +#pragma omp critical(leg) + MGL_PUSH(Leg,mglText(text,style),mutexLeg); +} +//----------------------------------------------------------------------------- +void mglBase::AddLegend(const char *str,const char *style) +{ + MGL_TO_WCS(str,AddLegend(wcs, style)); +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_dim2(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *name, bool less) +{ +// if(!gr || !x || !y || !z) return true; // if data is absent then should be segfault!!! + register long n=z->GetNx(),m=z->GetNy(); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,name); return true; } + if(a && n*m*z->GetNz()!=a->GetNx()*a->GetNy()*a->GetNz()) + { gr->SetWarn(mglWarnDim,name); return true; } + if(less) + { + if(x->GetNx()SetWarn(mglWarnDim,name); return true; } + if(y->GetNx()GetNy()GetNx()GetNy()SetWarn(mglWarnDim,name); return true; } + } + else + { + if(x->GetNx()!=n) + { gr->SetWarn(mglWarnDim,name); return true; } + if(y->GetNx()!=m && (x->GetNy()!=m || y->GetNx()!=n || y->GetNy()!=m)) + { gr->SetWarn(mglWarnDim,name); return true; } + } + return false; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_dim0(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *name, bool less) +{ +// if(!gr || !x || !y) return true; // if data is absent then should be segfault!!! + register long n=y->GetNx(); + if(less) + { + if(x->GetNx()SetWarn(mglWarnDim,name); return true; } + if(z && z->GetNx()SetWarn(mglWarnDim,name); return true; } + if(r && r->GetNx()SetWarn(mglWarnDim,name); return true; } + } + else + { + if(x->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + if(z && z->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + if(r && r->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + } + return false; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_dim1(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *name, bool less) +{ +// if(!gr || !x || !y) return true; // if data is absent then should be segfault!!! + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,name); return true; } + if(less) + { + if(x->GetNx()SetWarn(mglWarnDim,name); return true; } + if(z && z->GetNx()SetWarn(mglWarnDim,name); return true; } + if(r && r->GetNx()SetWarn(mglWarnDim,name); return true; } + } + else + { + if(x->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + if(z && z->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + if(r && r->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + } + return false; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_dim3(HMGL gr, bool both, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *name) +{ +// if(!gr || !x || !y || !z || !a) return true; // if data is absent then should be segfault!!! + register long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(n<2 || m<2 || l<2) + { gr->SetWarn(mglWarnLow,name); return true; } + if(!(both || (x->GetNx()==n && y->GetNx()==m && z->GetNx()==l))) + { gr->SetWarn(mglWarnDim,name); return true; } + if(b && b->GetNx()*b->GetNy()*b->GetNz()!=n*m*l) + { gr->SetWarn(mglWarnDim,name); return true; } + return false; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_trig(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *name, int d) +{ +// if(!gr || !x || !y || !z || !a || !nums) return true; // if data is absent then should be segfault!!! + long n = x->GetNx(), m = nums->GetNy(); + if(nums->GetNx()SetWarn(mglWarnLow,name); return true; } + if(y->GetNx()!=n || z->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + if(a->GetNx()!=m && a->GetNx()!=n) { gr->SetWarn(mglWarnDim,name); return true; } + return false; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_isboth(HCDT x, HCDT y, HCDT z, HCDT a) +{ + register long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + return x->GetNx()*x->GetNy()*x->GetNz()==n*m*l && y->GetNx()*y->GetNy()*y->GetNz()==n*m*l && z->GetNx()*z->GetNy()*z->GetNz()==n*m*l; +} +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_check_vec3(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *name) +{ +// if(!gr || !x || !y || !z || !ax || !ay || !az) return true; // if data is absent then should be segfault!!! + register long n=ax->GetNx(),m=ax->GetNy(),l=ax->GetNz(); + if(n*m*l!=ay->GetNx()*ay->GetNy()*ay->GetNz() || n*m*l!=az->GetNx()*az->GetNy()*az->GetNz()) + { gr->SetWarn(mglWarnDim,name); return true; } + if(n<2 || m<2 || l<2) { gr->SetWarn(mglWarnLow,name); return true; } + bool both = x->GetNx()*x->GetNy()*x->GetNz()==n*m*l && y->GetNx()*y->GetNy()*y->GetNz()==n*m*l && z->GetNx()*z->GetNy()*z->GetNz()==n*m*l; + if(!(both || (x->GetNx()==n && y->GetNx()==m && z->GetNx()==l))) + { gr->SetWarn(mglWarnDim,name); return true; } + return false; +} +//----------------------------------------------------------------------------- +void mglBase::SetFontDef(const char *font) { strncpy(FontDef, font, 31); } +//----------------------------------------------------------------------------- +void mglBase::ClearUnused() +{ +#if MGL_HAVE_PTHREAD + pthread_mutex_lock(&mutexPnt); pthread_mutex_lock(&mutexPrm); +#endif +#pragma omp critical + { + size_t l=Prm.size(); + // find points which are actually used + long *used = new long[Pnt.size()]; memset(used,0,Pnt.size()*sizeof(long)); + for(size_t i=0;i=0) used[p.n2] = 1; break; + case 2: if(p.n2>=0 && p.n3>=0) + used[p.n2] = used[p.n3] = 1; break; + case 3: if(p.n2>=0 && p.n3>=0 && p.n4>=0) + used[p.n2] = used[p.n3] = used[p.n4] = 1; break; + } + } + // now add proper indexes + l=Pnt.size(); + std::vector pnt; + for(size_t i=0;i * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/font.h" +#include "mgl2/base_cf.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// C interfaces +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_quality(HMGL gr, int qual) { gr->SetQuality(qual); } +void MGL_EXPORT mgl_set_quality_(uintptr_t *gr, int *qual) { _GR_->SetQuality(*qual); } +int MGL_EXPORT mgl_get_quality(HMGL gr) { return gr->GetQuality(); } +int MGL_EXPORT mgl_get_quality_(uintptr_t *gr) { return _GR_->GetQuality(); } +int MGL_EXPORT mgl_is_frames(HMGL gr) +{ return gr->get(MGL_VECT_FRAME) && !(gr->GetQuality()&MGL_DRAW_LMEM); } +void MGL_EXPORT mgl_set_draw_reg(HMGL gr, long nx, long ny, long m) { gr->SetDrawReg(nx,ny,m); } +void MGL_EXPORT mgl_set_draw_reg_(uintptr_t *gr, int *nx, int *ny, int *m) { _GR_->SetDrawReg(*nx,*ny,*m); } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_get_flag(HMGL gr, uint32_t flag) { return gr->get(flag); } +int MGL_EXPORT mgl_get_flag_(uintptr_t *gr, unsigned long *flag) { return _GR_->get(*flag); } +void MGL_EXPORT mgl_set_flag(HMGL gr, int val, uint32_t flag) { gr->set(val,flag); } +void MGL_EXPORT mgl_set_flag_(uintptr_t *gr, int *val, unsigned long *flag) { _GR_->set(*val,*flag); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_color(char id, double r, double g, double b) +{ + for(long i=0;mglColorIds[i].id;i++) + if(mglColorIds[i].id==id) mglColorIds[i].col = mglColor(r,g,b); +} +void MGL_EXPORT mgl_set_color_(char *id, mreal *r, mreal *g, mreal *b, int) { mgl_set_color(*id,*r,*g,*b); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_def_sch(HMGL gr, const char *sch) { gr->SetDefScheme(sch); } +void MGL_EXPORT mgl_set_def_sch_(uintptr_t *gr, const char *sch,int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + mgl_set_def_sch(_GR_, s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_plotid(HMGL gr, const char *id) { gr->PlotId = id; } +void MGL_EXPORT mgl_set_plotid_(uintptr_t *gr, const char *id,int l) +{ char *s=new char[l+1]; memcpy(s,id,l); s[l]=0; + _GR_->PlotId = s; delete []s; } +MGL_EXPORT const char *mgl_get_plotid(HMGL gr) { return gr->PlotId.c_str(); } +//----------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_get_mess(HMGL gr) { return gr->Mess.c_str(); } +int MGL_EXPORT mgl_get_warn(HMGL gr) { return gr->GetWarn(); } +void MGL_EXPORT mgl_set_warn(HMGL gr, int code, const char *txt) +{ gr->SetWarn(code,txt); } +void MGL_EXPORT mgl_set_origin(HMGL gr, double x0, double y0, double z0) +{ gr->SetOrigin(x0,y0,z0); } +void MGL_EXPORT mgl_set_palette(HMGL gr, const char *colors) +{ gr->SetPalette(colors); } +void MGL_EXPORT mgl_set_meshnum(HMGL gr, int num) { gr->SetMeshNum(num); } +void MGL_EXPORT mgl_set_facenum(HMGL gr, int num) { gr->FaceNum=num; } +void MGL_EXPORT mgl_set_alpha_default(HMGL gr, double alpha) { gr->SetAlphaDef(alpha); } +void MGL_EXPORT mgl_set_light_dif(HMGL gr, int enable) { gr->SetDifLight(enable); } +void MGL_EXPORT mgl_clear_unused(HMGL gr) { gr->ClearUnused(); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_rdc_acc(HMGL gr, int reduce) { gr->SetReduceAcc(reduce); } +void MGL_EXPORT mgl_highlight(HMGL gr, int id) { gr->Highlight(id); } +void MGL_EXPORT mgl_set_cut(HMGL gr, int cut) { gr->SetCut(cut); } +void MGL_EXPORT mgl_set_cut_box(HMGL gr, double x1,double y1,double z1,double x2,double y2,double z2) +{ gr->SetCutBox(x1,y1,z1,x2,y2,z2); } +void MGL_EXPORT mgl_set_cutoff(HMGL gr, const char *EqC) { gr->CutOff(EqC); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_ternary(HMGL gr, int enable) { gr->Ternary(enable); } +void MGL_EXPORT mgl_set_range_val(HMGL gr, char dir, double v1,double v2) +{ + if(dir=='c' || dir=='a') gr->CRange(v1,v2); + else if(dir=='x') gr->XRange(v1,v2); + else if(dir=='y') gr->YRange(v1,v2); + else if(dir=='z') gr->ZRange(v1,v2); +} +void MGL_EXPORT mgl_add_range_val(HMGL gr, char dir, double v1,double v2) +{ + if(dir=='c' || dir=='a') gr->CRange(v1,v2,true); + else if(dir=='x') gr->XRange(v1,v2,true); + else if(dir=='y') gr->YRange(v1,v2,true); + else if(dir=='z') gr->ZRange(v1,v2,true); +} +void MGL_EXPORT mgl_set_range_dat(HMGL gr, char dir, HCDT a, int add) +{ + if(dir=='c' || dir=='a') gr->CRange(a,add); + else if(dir=='x') gr->XRange(a,add); + else if(dir=='y') gr->YRange(a,add); + else if(dir=='z') gr->ZRange(a,add); +} +void MGL_EXPORT mgl_set_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2) +{ gr->SetRanges(x1,x2,y1,y2,z1,z2); } +void MGL_EXPORT mgl_set_auto_ranges(HMGL gr, double x1, double x2, double y1, double y2, double z1, double z2, double c1, double c2) +{ gr->SetAutoRanges(x1,x2,y1,y2,z1,z2,c1,c2); } +void MGL_EXPORT mgl_set_func(HMGL gr, const char *EqX,const char *EqY,const char *EqZ,const char *EqA) +{ gr->SetFunc(EqX,EqY,EqZ,EqA); } +void MGL_EXPORT mgl_set_coor(HMGL gr, int how) { gr->SetCoor(how); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_bar_width(HMGL gr, double width) { gr->SetBarWidth(width); } +//----------------------------------------------------------------------------- +// +// Fortran interfaces +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_rdc_acc_(uintptr_t *gr, int *reduce) +{ _GR_->SetReduceAcc(*reduce); } +void MGL_EXPORT mgl_highlight_(uintptr_t *gr, int *id) { _GR_->Highlight(*id); } +void MGL_EXPORT mgl_set_origin_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0) +{ _GR_->SetOrigin(*x0,*y0,*z0); } +int MGL_EXPORT mgl_get_warn_(uintptr_t *gr) { return _GR_->GetWarn(); } +void MGL_EXPORT mgl_set_warn_(uintptr_t *gr, int *code, const char *txt, int l) +{ char *s=new char[l+1]; memcpy(s,txt,l); s[l]=0; + _GR_->SetWarn(*code, s); delete []s; } +void MGL_EXPORT mgl_set_palette_(uintptr_t *gr, const char *colors, int l) +{ char *s=new char[l+1]; memcpy(s,colors,l); s[l]=0; + _GR_->SetPalette(s); delete []s; } +void MGL_EXPORT mgl_set_meshnum_(uintptr_t *gr, int *num) { _GR_->SetMeshNum(*num); } +void MGL_EXPORT mgl_set_facenum_(uintptr_t *gr, int *num) { _GR_->FaceNum=*num; } +void MGL_EXPORT mgl_set_alpha_default_(uintptr_t *gr, mreal *alpha) { _GR_->SetAlphaDef(*alpha); } +void MGL_EXPORT mgl_set_light_dif_(uintptr_t *gr, int *enable) { _GR_->SetDifLight(*enable); } +void MGL_EXPORT mgl_clear_unused_(uintptr_t *gr) { _GR_->ClearUnused(); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_cut_box_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2) +{ _GR_->SetCutBox(*x1,*y1,*z1,*x2,*y2,*z2); } +void MGL_EXPORT mgl_set_cut_(uintptr_t *gr, int *cut) { _GR_->SetCut(*cut); } +void MGL_EXPORT mgl_set_cutoff_(uintptr_t *gr, const char *EqC, int l) +{ char *s=new char[l+1]; memcpy(s,EqC,l); s[l]=0; + _GR_->CutOff(s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_ternary_(uintptr_t *gr, int *enable) { _GR_->Ternary(*enable); } +void MGL_EXPORT mgl_set_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int) +{ mgl_set_range_val(_GR_,*dir,*v1,*v2); } +void MGL_EXPORT mgl_add_range_val_(uintptr_t *gr, const char *dir, mreal *v1, mreal *v2,int) +{ mgl_add_range_val(_GR_,*dir,*v1,*v2); } +void MGL_EXPORT mgl_set_range_dat_(uintptr_t *gr, const char *dir, uintptr_t *a, int *add,int) +{ mgl_set_range_dat(_GR_,*dir,_DA_(a),*add); } +void MGL_EXPORT mgl_set_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2) +{ _GR_->SetRanges(*x1,*x2,*y1,*y2,*z1,*z2); } +void MGL_EXPORT mgl_set_auto_ranges_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2, mreal *c1, mreal *c2) +{ _GR_->SetAutoRanges(*x1,*x2,*y1,*y2,*z1,*z2,*c1,*c2); } +void MGL_EXPORT mgl_set_func_(uintptr_t *gr, const char *EqX,const char *EqY,const char *EqZ,const char *EqA,int lx,int ly,int lz,int la) +{ + char *sx=new char[lx+1]; memcpy(sx,EqX,lx); sx[lx]=0; + char *sy=new char[ly+1]; memcpy(sy,EqY,ly); sy[ly]=0; + char *sz=new char[lz+1]; memcpy(sz,EqZ,lz); sz[lz]=0; + char *sa=new char[la+1]; memcpy(sa,EqA,la); sa[la]=0; + _GR_->SetFunc(sx,sy,sz,sa); + delete []sx; delete []sy; delete []sz; delete []sa; +} +void MGL_EXPORT mgl_set_coor_(uintptr_t *gr, int *how) +{ _GR_->SetCoor(*how); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_tick_rotate(HMGL gr, int enable){ gr->SetTickRotate(enable); } +void MGL_EXPORT mgl_set_tick_skip(HMGL gr, int enable) { gr->SetTickSkip(enable); } +void MGL_EXPORT mgl_set_tick_rotate_(uintptr_t *gr,int *enable){ _GR_->SetTickRotate(*enable); } +void MGL_EXPORT mgl_set_tick_skip_(uintptr_t *gr, int *enable) { _GR_->SetTickSkip(*enable); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_rotated_text(HMGL gr, int enable) { gr->SetRotatedText(enable); } +void MGL_EXPORT mgl_set_mark_size(HMGL gr, double size) { gr->SetMarkSize(size); } +void MGL_EXPORT mgl_set_arrow_size(HMGL gr, double size) { gr->SetArrowSize(size); } +void MGL_EXPORT mgl_set_font_size(HMGL gr, double size) { gr->SetFontSize(size); } +void MGL_EXPORT mgl_set_font_def(HMGL gr, const char *fnt) { gr->SetFontDef(fnt); } +void MGL_EXPORT mgl_load_font(HMGL gr, const char *name, const char *path) +{ gr->LoadFont(name,path); } +void MGL_EXPORT mgl_copy_font(HMGL gr, HMGL gr_from) { gr->CopyFont(gr_from); } +void MGL_EXPORT mgl_restore_font(HMGL gr) { gr->RestoreFont(); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_bar_width_(uintptr_t *gr, mreal *width) { _GR_->SetBarWidth(*width); } +void MGL_EXPORT mgl_set_rotated_text_(uintptr_t *gr, int *rotated) { _GR_->SetRotatedText(*rotated); } +void MGL_EXPORT mgl_set_mark_size_(uintptr_t *gr, mreal *size) { _GR_->SetMarkSize(*size); } +void MGL_EXPORT mgl_set_arrow_size_(uintptr_t *gr, mreal *size) { _GR_->SetArrowSize(*size); } +void MGL_EXPORT mgl_set_font_size_(uintptr_t *gr, mreal *size) { _GR_->SetFontSize(*size); } +void MGL_EXPORT mgl_set_font_def_(uintptr_t *gr, const char *name, int l) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + _GR_->SetFontDef(s); delete []s; } +void MGL_EXPORT mgl_load_font_(uintptr_t *gr, char *name, char *path, int l,int n) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,path,n); d[n]=0; + _GR_->LoadFont(s,d); delete []s; delete []d; } +void MGL_EXPORT mgl_copy_font_(uintptr_t *gr, uintptr_t *gr_from) +{ _GR_->CopyFont((mglBase *)(*gr_from)); } +void MGL_EXPORT mgl_restore_font_(uintptr_t *gr) { _GR_->RestoreFont(); } +//----------------------------------------------------------------------------- +extern mglFont mglDefFont; +void MGL_EXPORT mgl_def_font(const char *name, const char *path) +{ mglDefFont.Load(name,path); } +void MGL_EXPORT mgl_def_font_(const char *name, const char *path,int l,int n) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,path,n); d[n]=0; + mglDefFont.Load(name,path); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_start_group(HMGL gr, const char *s) { gr->StartAutoGroup(s); } +void MGL_EXPORT mgl_end_group(HMGL gr) { gr->EndGroup(); } +void MGL_EXPORT mgl_start_group_(uintptr_t *gr, const char *name,int l) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + _GR_->StartAutoGroup(s); delete []s; } +void MGL_EXPORT mgl_end_group_(uintptr_t *gr) { _GR_->EndGroup(); } +//----------------------------------------------------------------------------- +#include +bool mglTestMode=false; +void MGL_EXPORT mgl_test_txt(const char *str, ...) +{ + if(mglTestMode) + { + char buf[256]; + va_list lst; + va_start(lst,str); + vsnprintf(buf,256,str,lst); + va_end(lst); + printf("TEST: %s\n",buf); + fflush(stdout); + } +} +void MGL_EXPORT mgl_set_test_mode(int enable) { mglTestMode=enable; } +//--------------------------------------------------------------------------- +long MGL_EXPORT mgl_use_graph(HMGL gr, int inc) +{ if(!gr) return 0; gr->InUse+=inc; return gr->InUse; } +long MGL_EXPORT mgl_use_graph_(uintptr_t *gr, int *inc) +{ return mgl_use_graph(_GR_,*inc); } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_ambbr(HMGL gr, double i) { gr->SetAmbient(i); } +void MGL_EXPORT mgl_set_ambbr_(uintptr_t *gr, mreal *i){ _GR_->SetAmbient(*i); } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_difbr(HMGL gr, double i) { gr->SetDiffuse(i); } +void MGL_EXPORT mgl_set_difbr_(uintptr_t *gr, mreal *i){ _GR_->SetDiffuse(*i); } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_zoom_axis(HMGL gr, double x1,double y1,double z1,double c1,double x2,double y2,double z2,double c2) +{ gr->ZoomAxis(mglPoint(x1,y1,z1,c1), mglPoint(x2,y2,z2,c2)); } +void MGL_EXPORT mgl_zoom_axis_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *c1, mreal *x2, mreal *y2, mreal *z2, mreal *c2) +{ _GR_->ZoomAxis(mglPoint(*x1,*y1,*z1,*c1), mglPoint(*x2,*y2,*z2,*c2)); } +//--------------------------------------------------------------------------- +extern uint64_t mgl_mask_def[16]; +void MGL_EXPORT mgl_set_mask(char id, const char *mask) +{ + const char *msk = MGL_MASK_ID, *s = mglchr(msk, id); + if(s) + { + uint64_t val = (mask && *mask) ? strtoull(mask,NULL,16) : mgl_mask_def[s-msk]; + mgl_mask_val[s-msk] = val; + } +} +void MGL_EXPORT mgl_set_mask_(const char *id, const char *mask,int,int l) +{ char *s=new char[l+1]; memcpy(s,mask,l); s[l]=0; mgl_set_mask(*id,s); delete []s; } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_mask_val(char id, uint64_t mask) +{ + const char *msk = MGL_MASK_ID, *s = mglchr(msk, id); + if(s) mgl_mask_val[s-msk]=mask; +} +void MGL_EXPORT mgl_set_mask_val_(const char *id, uint64_t *mask,int) +{ mgl_set_mask_val(*id,*mask); } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_mask_angle(HMGL gr, int angle) { gr->SetMaskAngle(angle); } +void MGL_EXPORT mgl_set_mask_angle_(uintptr_t *gr, int *angle) { _GR_->SetMaskAngle(*angle); } +//--------------------------------------------------------------------------- diff --git a/src/canvas.cpp b/src/canvas.cpp new file mode 100644 index 0000000..bbe7fb2 --- /dev/null +++ b/src/canvas.cpp @@ -0,0 +1,1007 @@ +/*************************************************************************** + * canvas.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/font.h" +#include "mgl2/canvas.h" +//----------------------------------------------------------------------------- +MGL_EXPORT std::string mglGlobalMess; ///< Buffer for receiving global messages +//----------------------------------------------------------------------------- +mglCanvas::mglCanvas(int w, int h) : mglBase() +{ + clr(MGL_DISABLE_SCALE); + set(MGL_VECT_FRAME); // NOTE: require a lot of memory! + Z=0; C=G=G4=0; OI=0; gif=0; + CurFrameId=0; Delay=0.5; + Width=Height=Depth=0; ObjId=-1; + fscl=ftet=0; PlotId = "frame"; + + ac.ch='c'; + ax.dir = mglPoint(1,0,0); ax.a = mglPoint(0,1,0); ax.b = mglPoint(0,0,1); ax.ch='x'; + ay.dir = mglPoint(0,1,0); ay.a = mglPoint(1,0,0); ay.b = mglPoint(0,0,1); ay.ch='y'; + az.dir = mglPoint(0,0,1); az.a = mglPoint(0,1,0); az.b = mglPoint(1,0,0); az.ch='z'; + + SetSize(w,h); SetQuality(MGL_DRAW_NORM); DefaultPlotParam(); +} +//----------------------------------------------------------------------------- +mglCanvas::~mglCanvas() +{ + if(G) { delete []G; delete []C; delete []Z; delete []G4;delete []OI; } +} +//----------------------------------------------------------------------------- +long mglCanvas::PushDrwDat() +{ + mglDrawDat d; + d.Pnt=Pnt; d.Prm=Prm; d.Glf=Glf; d.Ptx=Ptx; d.Txt=Txt; +#pragma omp critical(drw) + MGL_PUSH(DrwDat,d,mutexDrw); + return DrwDat.size(); +} +//----------------------------------------------------------------------------- +void mglCanvas::ResetFrames() { CurFrameId=0; DrwDat.clear(); } +//----------------------------------------------------------------------------- +void mglCanvas::SetFrame(long i) +{ + if(get(MGL_VECT_FRAME) && i>=0 && i=DrwDat.size()) return; + Clf(); + const mglDrawDat &d=DrwDat[k]; +#if MGL_HAVE_PTHREAD + pthread_mutex_lock(&mutexPnt); + pthread_mutex_lock(&mutexPrm); + pthread_mutex_lock(&mutexGlf); + pthread_mutex_lock(&mutexPtx); + pthread_mutex_lock(&mutexTxt); +#endif +#pragma omp critical + { Pnt=d.Pnt; Prm=d.Prm; Glf=d.Glf; Ptx=d.Ptx; Txt=d.Txt; } +#if MGL_HAVE_PTHREAD + pthread_mutex_unlock(&mutexTxt); + pthread_mutex_unlock(&mutexPtx); + pthread_mutex_unlock(&mutexGlf); + pthread_mutex_unlock(&mutexPrm); + pthread_mutex_unlock(&mutexPnt); +#endif +} +//----------------------------------------------------------------------------- +void mglCanvas::ShowFrame(long k) +{ + if(k<0 || (size_t)k>=DrwDat.size()) return; + ClfZB(); + size_t npnt=Pnt.size(), nglf=Glf.size(), nptx=Ptx.size(), ntxt=Txt.size(); +#if MGL_HAVE_PTHREAD + pthread_mutex_lock(&mutexPnt); + pthread_mutex_lock(&mutexPrm); + pthread_mutex_lock(&mutexGlf); + pthread_mutex_lock(&mutexPtx); + pthread_mutex_lock(&mutexTxt); +#endif +#pragma omp critical + { + const mglDrawDat &d=DrwDat[k]; + Glf.reserve(d.Glf.size()); for(size_t i=0;i=0) + { + a.z = Pnt[a.n1].z; // this is a bit less accurate but simpler for transformation + a.id = ObjId; +#pragma omp critical(prm) + MGL_PUSH(Prm,a,mutexPrm); + clr(MGL_FINISHED); + } +} +//----------------------------------------------------------------------------- +extern uint64_t mgl_mask_def[16]; +void mglCanvas::DefaultPlotParam() +{ +/* NOTE: following variables and mutex will not be changed by DefaultPlotParam() +long InUse; ///< Smart pointer (number of users) +mglFont *fnt; ///< Class for printing vector text +int Quality; ///< Quality of plot (0x0-pure, 0x1-fast; 0x2-fine; 0x4 - low memory) +int Width; ///< Width of the image +int Height; ///< Height of the image +int Depth; ///< Depth of the image +int CurFrameId; ///< Number of automaticle created frames +GifFileType *gif;*/ + SetDrawReg(1,1,0); + memcpy(mgl_mask_val, mgl_mask_def, 16*sizeof(uint64_t)); // should be > 16*8 + mgl_clear_fft(); DefMaskAn=0; ResetMask(); + SetTickRotate(true); SetTickSkip(true); + SetWarn(mglWarnNone,""); mglGlobalMess = ""; + ObjId = -1; HighId = INT_MIN; + SetFunc(0,0); Stop=false; CutOff(0); Ternary(0); + SetRanges(mglPoint(-1,-1,-1,-1), mglPoint(1,1,1,1)); + SetOrigin(NAN,NAN,NAN,NAN); + SetBarWidth(0.7); SetMarkSize(1); SetArrowSize(1); + SetAlphaDef(0.5); FontDef[0]=0; + SetTranspType(0); SetMeshNum(0); // NOTE: default MeshNum=0 + SetRotatedText(true); CurrPal = 0; + SetLegendMarks(); SetFontSize(4); + SetTuneTicks(3); SetAmbient(); SetDiffuse(); + clr(MGL_DISABLE_SCALE); + clr(MGL_USE_GMTIME); clr(MGL_NOSUBTICKS); + SetDifLight(false); SetReduceAcc(false); + SetDefScheme(MGL_DEF_SCH); SetPalette(MGL_DEF_PAL); + SetPenPal("k-1"); Alpha(false); + SetTicks('x'); SetTicks('y'); SetTicks('z'); SetTicks('c'); + stack.clear(); Restore(); DefColor('k'); + SetPlotFactor(0); InPlot(0,1,0,1,false); + SetTickLen(0); SetCut(true); + AdjustTicks("xyzc",true); Clf('w'); + + for(int i=0;i<10;i++) { AddLight(i, mglPoint(0,0,1)); Light(i,false); } + Light(0,true); Light(false); SetDifLight(true); +} +//----------------------------------------------------------------------------- +// Optimal axis position +//----------------------------------------------------------------------------- +mreal mglCanvas::FindOptOrg(char dir, int ind) const +{ + static mglPoint px, py, pz; + static mglMatrix bb; + mglPoint nn[8]={mglPoint(0,0,0), mglPoint(0,0,1), mglPoint(0,1,0,0), mglPoint(0,1,1), + mglPoint(1,0,0), mglPoint(1,0,1), mglPoint(1,1,0), mglPoint(1,1,1)}, pp[8]; + memcpy(pp, nn, 8*sizeof(mglPoint)); + // do nothing if transformation matrix is the same + if(B!=bb) + { + bb = B; +#pragma omp parallel for + for(long i=0;i<8;i++) PostScale(&B,pp[i]); + // find point with minimal y + long j=0; + for(long i=1;i<8;i++) if(pp[i].ypp[2].x) pz.y=1-pz.y; else pz.x=1-pz.x; } + else if(tx==0 && ty==0) // x- && y-axis is vertical + { + py.x=1-py.x; + if(pp[1].x>pp[3].x) + { px.z=1-px.z; py.z=1-py.z; } + } + else if(tzpp[2].x) pz.y=1-pz.y; else pz.x=1-pz.x; } + else if(typp[3].x) py.z=1-py.z; else py.x=1-py.x; } + else if(txpp[2].x) px.y=1-px.y; else px.z=1-px.z; } + } + // return to normal variables + mglPoint rx = Min+(Max-Min)/px; + mglPoint ry = Min+(Max-Min)/py; + mglPoint rz = Min+(Max-Min)/pz; + mreal res = rx.val(ind); + if(dir=='y') res = ry.val(ind); + if(dir=='z') res = rz.val(ind); + return res; +} +//----------------------------------------------------------------------------- +mreal mglCanvas::GetOrgX(char dir, bool inv) const +{ + mreal res = Org.x; + if(mgl_isnan(res)) + { + if(strchr("xyz",dir)) res = FindOptOrg(dir,0); + else if(dir=='t') res = Min.x; + else res = B.b[6]>0 ? Max.x:Min.x; + if(inv) res = Min.x+Max.x-res; + } + return res; +} +//----------------------------------------------------------------------------- +mreal mglCanvas::GetOrgY(char dir, bool inv) const +{ + mreal res = Org.y; + if(mgl_isnan(res)) + { + if(strchr("xyz",dir)) res = FindOptOrg(dir,1); + else if(dir=='t') res = Min.y; + else res = B.b[7]>0 ? Max.y:Min.y; + if(inv) res = Min.y+Max.y-res; + } + return res; +} +//----------------------------------------------------------------------------- +mreal mglCanvas::GetOrgZ(char dir, bool inv) const +{ + mreal res = Org.z; + if(mgl_isnan(res)) + { + if(strchr("xyz",dir)) res = FindOptOrg(dir,2); + else if(dir=='t') res = Min.z; + else res = B.b[8]>0 ? Max.z:Min.z; + if(inv) res = Min.z+Max.z-res; + } + return res; +} +//----------------------------------------------------------------------------- +// Put primitives +//----------------------------------------------------------------------------- +#define MGL_MARK_PLOT if(Quality&MGL_DRAW_LMEM) mark_draw(Pnt[p],type,size,&d);else \ + { mglPrim a; a.w = pw; a.s = size; \ + a.n1 = p; a.n4 = type; a.angl=0; add_prim(a); } +void mglCanvas::mark_plot(long p, char type, mreal size) +{ + if(p<0 || mgl_isnan(Pnt[p].x) || mgl_isnan(size)) return; + long pp=p; +// mreal pw = fabs(PenWidth)*0.15/sqrt(font_factor); + mreal pw = 0.15/sqrt(font_factor); + mglDrawReg d; d.set(this,dr_x,dr_y,dr_p); + d.PDef = PDef; d.pPos = pPos; d.PenWidth=pw; +// if(size>=0) size *= MarkSize; +// if(size==0) size = MarkSize; + size = size?fabs(size):1; + size *= MarkSize*0.35*font_factor; + if(type=='.') size = fabs(PenWidth)*sqrt(font_factor/400); + if(TernAxis&4) for(int i=0;i<4;i++) + { p = ProjScale(i, pp); MGL_MARK_PLOT } + else { MGL_MARK_PLOT } +} +//----------------------------------------------------------------------------- +#define MGL_LINE_PLOT if(Quality&MGL_DRAW_LMEM) line_draw(Pnt[p1],Pnt[p2],&dd);else \ + { mglPrim a(1); a.n3=PDef; a.s = pPos; \ + a.n1 = p1; a.n2 = p2; a.w = pw; a.angl=0; add_prim(a); } +void mglCanvas::line_plot(long p1, long p2) +{ + if(PDef==0) return; + if(p1<0 || p2<0 || mgl_isnan(Pnt[p1].x) || mgl_isnan(Pnt[p2].x)) return; + if(p1>p2) { long kk=p1; p1=p2; p2=kk; } // rearrange start/end for proper dashing + long pp1=p1,pp2=p2; + mreal pw = fabs(PenWidth)*sqrt(font_factor/400), d; + d = hypot(Pnt[p1].x-Pnt[p2].x, Pnt[p1].y-Pnt[p2].y); + + mglDrawReg dd; dd.set(this,dr_x,dr_y,dr_p); + dd.PDef = PDef; dd.pPos = pPos; dd.PenWidth=pw; + + if(TernAxis&4) for(int i=0;i<4;i++) + { p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2); + MGL_LINE_PLOT } + else { MGL_LINE_PLOT } + pPos = fmod(pPos+d/pw/1.5, 16); +} +//----------------------------------------------------------------------------- +#define MGL_TRIG_PLOT if(Quality&MGL_DRAW_LMEM) trig_draw(Pnt[p1],Pnt[p2],Pnt[p3],true,&d);else \ + { mglPrim a(2); a.n1 = p1; a.n2 = p2; a.n3 = p3; \ + a.m=mask; a.angl=MaskAn; a.w = pw; add_prim(a);} +void mglCanvas::trig_plot(long p1, long p2, long p3) +{ + if(p1<0 || p2<0 || p3<0 || mgl_isnan(Pnt[p1].x) || mgl_isnan(Pnt[p2].x) || mgl_isnan(Pnt[p3].x)) return; + long pp1=p1,pp2=p2,pp3=p3; + mreal pw = fabs(PenWidth)*sqrt(font_factor/400); + mglDrawReg d; d.set(this,dr_x,dr_y,dr_p); d.PenWidth=pw; + if(TernAxis&4) for(int i=0;i<4;i++) + { p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2); + p3 = ProjScale(i, pp3); MGL_TRIG_PLOT } + else { MGL_TRIG_PLOT } +} +//----------------------------------------------------------------------------- +#define MGL_QUAD_PLOT if(Quality&MGL_DRAW_LMEM) quad_draw(Pnt[p1],Pnt[p2],Pnt[p3],Pnt[p4],&d);else \ + { mglPrim a(3); a.n1 = p1; a.n2 = p2; a.n3 = p3; a.n4 = p4; \ + a.m=mask; a.angl=MaskAn; a.w = pw; add_prim(a); } +void mglCanvas::quad_plot(long p1, long p2, long p3, long p4) +{ + if(p1<0 || mgl_isnan(Pnt[p1].x)) { trig_plot(p4,p2,p3); return; } + if(p2<0 || mgl_isnan(Pnt[p2].x)) { trig_plot(p1,p4,p3); return; } + if(p3<0 || mgl_isnan(Pnt[p3].x)) { trig_plot(p1,p2,p4); return; } + if(p4<0 || mgl_isnan(Pnt[p4].x)) { trig_plot(p1,p2,p3); return; } + long pp1=p1,pp2=p2,pp3=p3,pp4=p4; + mreal pw = fabs(PenWidth)*sqrt(font_factor/400); + mglDrawReg d; d.set(this,dr_x,dr_y,dr_p); d.PenWidth=pw; + if(TernAxis&4) for(int i=0;i<4;i++) + { p1 = ProjScale(i, pp1); p2 = ProjScale(i, pp2); + p3 = ProjScale(i, pp3); p4 = ProjScale(i, pp4); + MGL_QUAD_PLOT } + else { MGL_QUAD_PLOT } +} +//----------------------------------------------------------------------------- +mreal mglCanvas::text_plot(long p,const wchar_t *text,const char *font,mreal size,mreal sh,mreal col,bool rot) +{ + if(p<0 || mgl_isnan(Pnt[p].x) || !text || *text==0) return 0; + if(size<0) size *= -FontSize; + if(!font) font=""; + + if(TernAxis&4) // text at projections + { + mreal res; + TernAxis = TernAxis&(~4); + for(int i=0;i<4;i++) + res = text_plot(ProjScale(i,p,true),text,font,size/2,sh,col); + TernAxis = TernAxis|4; + return res; + } + + mglPnt q=Pnt[p]; + mreal ll = q.u*q.u+q.v*q.v; + bool inv=false; + if(rot && (q.u<0 || (q.u==0 && q.v<0))) + { q.u=-q.u; q.v=-q.v; q.w=-q.w; inv=true; } + + mreal fsize=size/6.5*font_factor, h = fnt->Height(font)*fsize, w, shift = -(sh+0.02)*h; + // text drawing itself + +#if MGL_HAVE_PTHREAD +pthread_mutex_lock(&mutexPtx); +#endif +#pragma omp critical(ptx) + { + Bt = B; Bt.norot=(q.sub<0); // NOTE check this later for mglInPlot + inv = inv ^ (strchr(font,'T')!=0); + if(inv) shift = 0.2*h-shift; + shift += 0.015*h; // Correction for glyph rotation around proper point + // shift *= h; + + int align; + char cc = mglGetStyle(font,0,&align); align = align&3; + if(cc) col = -cc; + Bt.x = q.x; Bt.y = q.y - shift; Bt.z = q.z; + if(ll>0) + { + Bt.x += shift*q.v/sqrt(ll); Bt.y += shift*(1-q.u/sqrt(ll)); + if(q.u==0 && !get(MGL_ENABLE_RTEXT)) Bt.y -= 0.1*h; + } + fscl = fsize; forg = p; + + if(mgl_isnan(ll) || !get(MGL_ENABLE_RTEXT)) ftet = 0; + else if(ll) ftet = -180*atan2(q.v,q.u)/M_PI; + else ftet = NAN; + + if(!(Quality&MGL_DRAW_LMEM)) // add text itself + { + char ch = mglGetStyle(font,0,0); + mglColor mc(ch); + if(!ch) mc = col<0 ? mglColor(char(0.5-col)):Txt[long(col)].GetC(col); + + mglPrim a(6); a.n1 = p; + a.n2 = int(255*mc.r) + 256*(int(255*mc.g) + 256*int(255*mc.b)); + mglText txt(text,font); + a.n3 = Ptx.size(); Ptx.push_back(txt); + a.s = size; a.w = shift; a.p=ftet; + add_prim(a); + } + + col = col<0 ? AddTexture(char(0.5-col)):col; + q.c=col; q.t=0; Txt[long(col)].GetC(col,0,q); + q.u = q.v = NAN; + memset(Bt.b,0,9*sizeof(mreal)); + Bt.b[0] = Bt.b[4] = Bt.b[8] = fscl; + register mreal opf = Bt.pf; + Bt.RotateN(ftet,0,0,1); Bt.pf = Bt.norot?1.55:opf; + if(strchr(font,'@')) // draw box around text + { + long k1,k2,k3,k4; mglPnt pt; mglPoint pp; + w = fnt->Width(text,font); h = fnt->Height(font); +// int align; mglGetStyle(font,0,&align); align = align&3; + mreal d=-w*align/2.-h*0.2; w+=h*0.4; + pt = q; pp = mglPoint(d,-h*0.4); PostScale(&Bt,pp); + pt.x=pt.xx=pp.x; pt.y=pt.yy=pp.y; +#pragma omp critical(pnt) + {k1=Pnt.size(); MGL_PUSH(Pnt,pt,mutexPnt);} + pt = q; pp = mglPoint(w+d,-h*0.4); PostScale(&Bt,pp); + pt.x=pt.xx=pp.x; pt.y=pt.yy=pp.y; +#pragma omp critical(pnt) + {k2=Pnt.size(); MGL_PUSH(Pnt,pt,mutexPnt);} + pt = q; pp = mglPoint(d,h*1.2); PostScale(&Bt,pp); + pt.x=pt.xx=pp.x; pt.y=pt.yy=pp.y; +#pragma omp critical(pnt) + {k3=Pnt.size(); MGL_PUSH(Pnt,pt,mutexPnt);} + pt = q; pp = mglPoint(w+d,h*1.2); PostScale(&Bt,pp); + pt.x=pt.xx=pp.x; pt.y=pt.yy=pp.y; +#pragma omp critical(pnt) + {k4=Pnt.size(); MGL_PUSH(Pnt,pt,mutexPnt);} + line_plot(k1,k2); line_plot(k1,k3); + line_plot(k4,k2); line_plot(k4,k3); + mreal bl = AddTexture('w'); + k1 = CopyNtoC(k1,bl); k2 = CopyNtoC(k2,bl); + k3 = CopyNtoC(k3,bl); k4 = CopyNtoC(k4,bl); + quad_plot(k1,k2,k3,k4); + } + fsize *= fnt->Puts(text,font,col)/2; + } +#if MGL_HAVE_PTHREAD + pthread_mutex_unlock(&mutexPtx); +#endif + return fsize; +} +//----------------------------------------------------------------------------- +void mglCanvas::Glyph(mreal x, mreal y, mreal f, int s, long j, mreal col) +{ + mglPrim a(4); // NOTE: no projection since text_plot() did it + a.s = fscl/Bt.pf; + a.w = get(MGL_ENABLE_RTEXT)?ftet:1e5; + a.p = f/fnt->GetFact(s&3); + mreal cc = col<0 ? AddTexture(char(0.5-col)):col; + if(cc<0) cc = CDef; + a.n1 = AddPnt(&Bt, mglPoint(Bt.x,Bt.y,Bt.z), cc, mglPoint(x,y,NAN), -1, -1); + a.n2 = forg; a.n3 = s; a.n4 = AddGlyph(s,j); + if(a.n1<0) return; + + mglDrawReg d; d.set(this,dr_x,dr_y,dr_p); + d.PDef = s; d.pPos = a.s; d.PenWidth=a.w; + + if(Quality&MGL_DRAW_LMEM) glyph_draw(a,&d); + else add_prim(a); +} +//----------------------------------------------------------------------------- +// Plot positioning functions +//----------------------------------------------------------------------------- +void mglCanvas::InPlot(mreal x1,mreal x2,mreal y1,mreal y2, const char *st) +{ + if(Width<=0 || Height<=0 || Depth<=0) return; + if(!st) { InPlot(x1,x2,y1,y2,false); return; } + inW = Width*(x2-x1); inH = Height*(y2-y1); + inX=Width*x1; inY=Height*y1; ZMin=1; + mglPrim p; p.id = ObjId; + p.n1=x1*Width; p.n2=x2*Width; p.n3=y1*Height; p.n4=y2*Height; +#pragma omp critical(sub) + MGL_PUSH(Sub,p,mutexSub); + + if(strchr(st,'T')) { y1*=0.9; y2*=0.9; } // general title + bool r = !(strchr(st,'r') || strchr(st,'R') || strchr(st,'>') || strchr(st,'g')); + bool l = !(strchr(st,'l') || strchr(st,'L') || strchr(st,'<') || strchr(st,'g')); + bool u = !(strchr(st,'u') || strchr(st,'U') || strchr(st,'_') || strchr(st,'g')); + bool a = !(strchr(st,'a') || strchr(st,'A') || strchr(st,'^') || strchr(st,'g') || strchr(st,'t')); + // let use simplified scheme -- i.e. no differences between axis, colorbar and/or title + register mreal xs=(x1+x2)/2, ys=(y1+y2)/2, f1 = 1.3, f2 = 1.1; + if(strchr(st,'#')) f1=f2=1.55; + if(r && l) { x2=xs+(x2-xs)*f1; x1=xs+(x1-xs)*f1; } + else if(r) { x2=xs+(x2-xs)*f1; x1=xs+(x1-xs)*f2; } + else if(l) { x2=xs+(x2-xs)*f2; x1=xs+(x1-xs)*f1; } + if(a && u) { y2=ys+(y2-ys)*f1; y1=ys+(y1-ys)*f1; } + else if(a) { y2=ys+(y2-ys)*f1; y1=ys+(y1-ys)*f2; } + else if(u) { y2=ys+(y2-ys)*f2; y1=ys+(y1-ys)*f1; } + + B.clear(); + if(get(MGL_AUTO_FACTOR)) B.pf = 1.55; // Automatically change plot factor !!! + B.x = (x1+x2)/2*Width; + B.y = (y1+y2)/2*Height; + B.b[0] = Width*(x2-x1); B.b[4] = Height*(y2-y1); + B.b[8] = sqrt(B.b[0]*B.b[4]); + B.z = (1.f-B.b[8]/(2*Depth))*Depth; + B1=B; font_factor = B.b[0] < B.b[4] ? B.b[0] : B.b[4]; +} +//----------------------------------------------------------------------------- +void mglCanvas::InPlot(mglMatrix &M,mreal x1,mreal x2,mreal y1,mreal y2, bool rel) +{ + if(Width<=0 || Height<=0 || Depth<=0) return; + M.clear(); + if(get(MGL_AUTO_FACTOR)) M.pf = 1.55; // Automatically change plot factor !!! + if(rel) + { + M.x = B1.x + (x1+x2-1)/2*B1.b[0]/1.55; + M.y = B1.y + (y1+y2-1)/2*B1.b[4]/1.55; + M.b[0] = B1.b[0]*(x2-x1); M.b[4] = B1.b[4]*(y2-y1); + M.b[8] = sqrt(M.b[0]*M.b[4]); + M.z = B1.z + (1.f-M.b[8]/(2*Depth))*B1.b[8]; + } + else + { + M.x = (x1+x2)/2*Width; + M.y = (y1+y2)/2*Height; + M.b[0] = Width*(x2-x1); M.b[4] = Height*(y2-y1); + M.b[8] = sqrt(M.b[0]*M.b[4]); + M.z = (1.f-M.b[8]/(2*Depth))*Depth; + B1=B; + } + inW=M.b[0]; inH=M.b[4]; ZMin=1; + inX=Width*x1; inY=Height*y1; + font_factor = M.b[0] < M.b[4] ? M.b[0] : M.b[4]; + mglPrim p; p.id = ObjId; + p.n1=x1*Width; p.n2=x2*Width; p.n3=y1*Height; p.n4=y2*Height; +#pragma omp critical(sub) + MGL_PUSH(Sub,p,mutexSub); +} +//----------------------------------------------------------------------------- +void mglCanvas::StickPlot(int num, int id, mreal tet, mreal phi) +{ + mreal dx,dy,wx,wy,x1,y1,f1,f2; + mglPoint p1(-1,0,0), p2(1,0,0); + // first iteration + InPlot(0,1,0,1,true); Rotate(tet, phi); + PostScale(GetB(),p1); PostScale(GetB(),p2); f1 = B.pf; + dx=(p2.x-p1.x)*1.55/B1.b[0]; dy=(p2.y-p1.y)*1.55/B1.b[4]; + wx=1/(1+(num-1)*fabs(dx)); wy=1/(1+(num-1)*fabs(dy)); + x1=dx>0?dx*id:dx*(id-num+1); y1=dy>0?dy*id:dy*(id-num+1); + InPlot(x1*wx,(x1+1)*wx,y1*wy,(y1+1)*wy,true); Rotate(tet,phi); + f2 = B.pf; dx*=f1/f2; dy*=f1/f2; // add correction due to PlotFactor + wx=1/(1+(num-1)*fabs(dx)); wy=1/(1+(num-1)*fabs(dy)); + x1=dx>0?dx*id:dx*(id-num+1); y1=dy>0?dy*id:dy*(id-num+1); + InPlot(x1*wx,(x1+1)*wx,y1*wy,(y1+1)*wy,true); Rotate(tet,phi); + f1=f2; f2 = B.pf; dx*=f1/f2; dy*=f1/f2; // add correction due to PlotFactor + wx=1/(1+(num-1)*fabs(dx)); wy=1/(1+(num-1)*fabs(dy)); + x1=dx>0?dx*id:dx*(id-num+1); y1=dy>0?dy*id:dy*(id-num+1); + InPlot(x1*wx,(x1+1)*wx,y1*wy,(y1+1)*wy,true); Rotate(tet,phi); +} +//----------------------------------------------------------------------------- +void mglCanvas::Rotate(mreal tetz,mreal tetx,mreal tety) +{ + B.Rotate(tetz,tetx,tety); + if(get(MGL_AUTO_FACTOR)) + { + mreal w=(fabs(B.b[3])+fabs(B.b[4])+fabs(B.b[5]))/B1.b[4]; + mreal h=(fabs(B.b[0])+fabs(B.b[1])+fabs(B.b[2]))/B1.b[0]; + B.pf = 1.55+0.6147*(w=0;i--) + { + const mglPrim &p = Sub[i]; + if(p.n1<=x && p.n2>=x && p.n3<=y && p.n4>=y) + { id=p.id; break; } + } + return id; +} +//----------------------------------------------------------------------------- +#define islog(a, b) (((a)>0 && (b)>10*(a)) || ((b)<0 && (a)<10*(b))) +void mglCanvas::Aspect(mreal Ax,mreal Ay,mreal Az) +{ + if(mgl_isnan(Ax)) + { + mreal dy = (Max.y-Min.y), dx = (Max.x-Min.x), dz = (Max.z-Min.z); + if(islog(Min.x,Max.x) && fx) dx = log10(Max.x/Min.x); + if(islog(Min.y,Max.y) && fy) dy = log10(Max.y/Min.y); + if(islog(Min.z,Max.z) && fz) dz = log10(Max.z/Min.z); + mreal fy=exp(M_LN10*floor(0.5+log10(fabs(dy/dx)))); + mreal fz=exp(M_LN10*floor(0.5+log10(fabs(dz/dx)))); + if(Ay>0) fy*=Ay; + if(Az>0) fz*=Az; + Ax = Height*dx; Ay = Width*dy*fy; Az = Depth*dz*fz; + } + mreal a = fabs(Ax) > fabs(Ay) ? fabs(Ax) : fabs(Ay); + a = a > fabs(Az) ? a : fabs(Az); + if(a==0) { SetWarn(mglWarnZero,"Aspect"); return; } + Ax/=a; Ay/=a; Az/=a; + B.b[0] *= Ax; B.b[3] *= Ax; B.b[6] *= Ax; + B.b[1] *= Ay; B.b[4] *= Ay; B.b[7] *= Ay; + B.b[2] *= Az; B.b[5] *= Az; B.b[8] *= Az; +} +//----------------------------------------------------------------------------- +// Lighting and transparency +//----------------------------------------------------------------------------- +void mglCanvas::Fog(mreal d, mreal dz) { FogDist=d; FogDz = dz; } +//----------------------------------------------------------------------------- +void mglCanvas::Light(int n, bool enable) +{ + if(n<0 || n>9) { SetWarn(mglWarnLId,"Light"); return; } + light[n].n = enable; +} +//----------------------------------------------------------------------------- +void mglCanvas::AddLight(int n, mglPoint r, mglPoint d, char col, mreal br, mreal ap) +{ + if(n<0 || n>9) { SetWarn(mglWarnLId,"AddLight"); return; } + light[n].n = true; light[n].a = ap>0?ap*ap:3; + light[n].b = br; light[n].r = r; + light[n].d = d; light[n].c = mglColor(col); +} +//----------------------------------------------------------------------------- +void mglCanvas::arrow_plot(long n1, long n2, char st) +{ + if(n1<0 || n2<0 || !strchr("AVKSDTIO",st)) return; + float ll = PenWidth*ArrowSize*0.35*font_factor; + uint64_t m=mask; int ma=MaskAn; + ResetMask(); + if((Quality&3)==3) + arrow_plot_3d(n1, n2, st, ll); + else + arrow_draw(n1, n2, st, ll); + mask=m; MaskAn=ma; +} +//----------------------------------------------------------------------------- +void mglCanvas::Legend(const std::vector &leg, mreal x, mreal y, const char *font, const char *opt) +{ + long n=leg.size(); + mreal iw, ih; + if(n<1) { SetWarn(mglWarnLeg,"Legend"); return; } + mreal ll = SaveState(opt); if(mgl_isnan(ll)) ll=0.1; + if(saved) MarkSize=MSS; // restore back size of marks + static int cgid=1; StartGroup("Legend",cgid++); + if(ll<=0 || mgl_isnan(ll)) ll=0.1; + ll *=font_factor; + mreal size = 0.8*FontSize; + // setup font and parse absolute coordinates + if(!font) font="#"; + char *pA, *ff = new char[strlen(font)+3]; + strcpy(ff,font); strcat(ff,":L"); Push(); + if((pA=strchr(ff,'A'))) + { *pA = ' '; InPlot(0,1,0,1,false); iw=B1.b[0]; ih=B1.b[4]; } + else { iw=B1.b[0]/B1.pf; ih=B1.b[4]/B1.pf; } + // find sizes + mreal h=TextHeight(font,size); + mreal dx = 0.03*iw, dy = 0.03*ih, w=0, t, sp=TextWidth(" ",font,size); + register long i,j; + for(i=0;it ? w:t; + } + w += ll+0.01*iw; // add space for lines + j = long((ih*0.95)/h); + long ncol = 1+(n-1)/j, nrow = (n+ncol-1)/ncol; + if(strchr(font,'-')) // horizontal legend + { + j = long((iw*0.95)/w); + nrow = 1+(n-1)/j; + ncol = (n+nrow-1)/nrow; + } + if(mglchr(font,'^')) // use "external" positioning + { + x = x>=0.5 ? x*iw : x*iw-w*ncol-2*dx; + y = y>=0.5 ? y*ih : y*ih-h*nrow-2*dy; + } + else + { + x *= iw-w*ncol-2*dx; + y *= ih-h*nrow-2*dy; + } + x += B.x-iw/2+dx; y += B.y-ih/2+dy; + // draw it + long k1=0,k2=0,k3=0,k4=0; + mglPoint p,q=mglPoint(NAN,NAN,NAN); + + for(i=0;ff[i] && ff[i]!=':';i++) if(strchr(MGL_COLORS,ff[i])) + { + + if(k1 && k2) { k3=ff[i]; k4++; } // NOTE: keep k3 for future usage + if(k1 && !k2) { k2=ff[i]; k4++; } + if(!k1) { k1=ff[i]; k4++; } + } + if(k4==2) k2=0; + if(k4==1) k1=k2=0; + mreal c1=AddTexture(char(k1?k1:'w')), c2=AddTexture(char(k2?k2:'k')); + if((Flag&3)==2) { mreal cc=c1; c2=c1; c1=cc; } + + mglMatrix M=B; M.norot=true; + if(strchr(ff,'#')) // draw bounding box + { + SetPenPal("k-"); + k1=AddPnt(&M,mglPoint(x,y,Depth/MGL_FEPSILON),c1,q,-1,0); + k2=AddPnt(&M,mglPoint(x+w*ncol,y,Depth/MGL_FEPSILON),c1,q,-1,0); + k3=AddPnt(&M,mglPoint(x,y+h*nrow,Depth/MGL_FEPSILON),c1,q,-1,0); + k4=AddPnt(&M,mglPoint(x+w*ncol,y+h*nrow,Depth/MGL_FEPSILON),c1,q,-1,0); + quad_plot(k1,k2,k3,k4); + k1=CopyNtoC(k1,c2); k2=CopyNtoC(k2,c2); + k3=CopyNtoC(k3,c2); k4=CopyNtoC(k4,c2); + line_plot(k1,k2); line_plot(k2,k4); + line_plot(k4,k3); line_plot(k3,k1); + } + for(i=0;i=1) { SetWarn(mglWarnSpc,"Table"); return; } + long i,j,m=val->GetNy(),n=val->GetNx(); +// mreal pos=SaveState(opt); + mreal vw = SaveState(opt); + static int cgid=1; StartGroup("Table",cgid++); + bool grid = mglchr(frm,'#'), eqd = mglchr(frm,'='), lim = mglchr(frm,'|'); + if(mgl_isnan(vw)) vw=1; else lim = true; + if(!text) text=L""; + if(x<0) x=0; if(y<0) y=0; if(y>1) y=1; +// if(vw>1-x) vw=1-x; + + wchar_t *buf = new wchar_t[m*32], sng[32]; + std::vector str; + for(i=0;iv(i,j)); + wcscat(buf,sng); + } + mglprintf(sng,32,L"%.3g",val->v(i,m-1)); + wcscat(buf,sng); str.push_back(buf); + } + delete []buf; + + mreal sp=2*TextWidth(" ",frm,-1), w=*text ? sp+TextWidth(text,frm,-1):0, w1=0, ww, h; + for(i=0;ivw*inW) + { h=vw*inW/w; SetFontSize(-h); w*=h; w1*=h; sp*=h; } + h = TextHeight(frm,-1); // now we can determine text height + + x = x*(inW-w)+B.x-inW/2; + y = y*(inH-h*m)+B.y-inH/2; + + mglPoint p,q=mglPoint(NAN,NAN); + long k1,k2; + mreal xx,yy; + if(grid) // draw bounding box + { + SetPenPal("k-"); + k1=AddPnt(&B,mglPoint(x,y,Depth),-1,q,-1,0); + k2=AddPnt(&B,mglPoint(x,y+m*h,Depth),-1,q,-1,0); + line_plot(k1,k2); + ww = *text ? TextWidth(text,frm,-1)+sp:0; + k1=AddPnt(&B,mglPoint(x+ww,y,Depth),-1,q,-1,0); + k2=AddPnt(&B,mglPoint(x+ww,y+m*h,Depth),-1,q,-1,0); + line_plot(k1,k2); + for(i=0,xx=x+ww,yy=y;i0 ? size/FontSize:-size, h=TextHeight(stl,size)*s/2; + if(h>=inH) { SetWarn(mglWarnSpc,"Title"); return; } + static int cgid=1; StartGroup("Title",cgid++); + bool box=mglchr(stl,'#'); + int align; + char col = mglGetStyle(stl,0,&align); align = align&3; + if(col==0) col = 'k'; + mreal y=inY+inH-h; + mglPoint p(inX + inW*align/2.,y,3*Depth),q(NAN,NAN,NAN); + mglMatrix M=B; M.norot=true; + if(title) text_plot(AddPnt(&M,p,-1,q,-1,0),title,stl,size); + if(box) // draw boungind box + { + mreal c1=AddTexture('w'), c2=AddTexture(col); + if((Flag&3)==2) { mreal cc=c1; c2=c1; c1=cc; } + long k1,k2,k3,k4; + k1=AddPnt(&M,mglPoint(inX,y-h*0.4,3*Depth),c1,q,-1,0); + k2=AddPnt(&M,mglPoint(inX+inW,y-h*0.4,3*Depth),c1,q,-1,0); + k3=AddPnt(&M,mglPoint(inX,y+h,3*Depth),c1,q,-1,0); + k4=AddPnt(&M,mglPoint(inX+inW,y+h,3*Depth),c1,q,-1,0); + quad_plot(k1,k2,k3,k4); + k1=CopyNtoC(k1,c2); k2=CopyNtoC(k2,c2); + k3=CopyNtoC(k3,c2); k4=CopyNtoC(k4,c2); + line_plot(k1,k2); line_plot(k2,k4); + line_plot(k4,k3); line_plot(k3,k1); + } + B1.y -= h/2; B1.b[4] -= h; B=B1; + inH-=h; font_factor = B.b[0] < B.b[4] ? B.b[0] : B.b[4]; + EndGroup(); +} +//----------------------------------------------------------------------------- +void mglCanvas::StartAutoGroup (const char *lbl) +{ + static int id=1; + if(lbl==NULL) { id=1; grp_counter=0; return; } + grp_counter++; + if(grp_counter>1) return; // do nothing in "subgroups" + if(ObjId<0) { ObjId = -id; id++; } + register size_t len = Grp.size(); + if(ObjId>=0 && len>0 && ObjId!=Grp[len-1].Id) +#pragma omp critical(grp) + { MGL_PUSH(Grp,mglGroup(lbl,ObjId),mutexGrp);} + else if(ObjId<0) +#pragma omp critical(grp) + { MGL_PUSH(Grp,mglGroup(lbl,ObjId),mutexGrp);} +} +//----------------------------------------------------------------------------- +void mglCanvas::EndGroup() +{ + LoadState(); + if(Quality&MGL_DRAW_LMEM) + { + Pnt.clear(); Prm.clear(); Ptx.clear(); + Glf.clear(); Act.clear(); Grp.clear(); + } + if(grp_counter>0) grp_counter--; +} +//----------------------------------------------------------------------------- +int mglCanvas::IsActive(int xs, int ys,int &n) +{ + long i, h = (Width>Height ? Height:Width)/100; + for(i=0;i<(long)Act.size();i++) + { + const mglActivePos &p=Act[i]; + if(abs(xs-p.x)<=h && abs(ys-p.y)<=h) + { n=p.n; return p.id; } + } + n=-1; return GetObjId(xs,ys); +} +//----------------------------------------------------------------------------- +void mglCanvas::Push() +{ +#pragma omp critical(stk) + {MGL_PUSH(stack,B,mutexStk);} +} +//----------------------------------------------------------------------------- diff --git a/src/canvas_cf.cpp b/src/canvas_cf.cpp new file mode 100644 index 0000000..7cc3a29 --- /dev/null +++ b/src/canvas_cf.cpp @@ -0,0 +1,437 @@ +/*************************************************************************** + * canvas_cf.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" +#include "mgl2/eval.h" +#include "mgl2/evalc.h" +//----------------------------------------------------------------------------- +#undef _GR_ +#define _GR_ ((mglCanvas *)(*gr)) +//----------------------------------------------------------------------------- +MGL_EXPORT const unsigned char *mgl_get_rgb(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetBits():0; } +MGL_EXPORT const unsigned char *mgl_get_rgba(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetRGBA():0; } +int MGL_EXPORT mgl_get_width(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetWidth():0; } +int MGL_EXPORT mgl_get_height(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetHeight():0; } +void MGL_EXPORT mgl_calc_xyz(HMGL gr, int xs, int ys, mreal *x, mreal *y, mreal *z) +{ mglCanvas *g = dynamic_cast(gr); + mglPoint p = g?g->CalcXYZ(xs,ys):mglPoint(NAN,NAN,NAN); + *x = p.x; *y = p.y; *z = p.z; } +void MGL_EXPORT mgl_calc_scr(HMGL gr, double x, double y, double z, int *xs, int *ys) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->CalcScr(mglPoint(x,y,z),xs,ys); } +void MGL_EXPORT mgl_set_obj_id(HMGL gr, int id) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetObjId(id); } +int MGL_EXPORT mgl_get_obj_id(HMGL gr, int x, int y) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetObjId(x,y):-1; } +int MGL_EXPORT mgl_get_spl_id(HMGL gr, int x, int y) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetSplId(x,y):-1; } +//----------------------------------------------------------------------------- +long MGL_EXPORT mgl_is_active(HMGL gr, int xs, int ys, int d) +{ + if(d<=0) d=1; + for(size_t i=0;iAct.size();i++) + { + const mglActivePos &p = gr->Act[i]; + if(abs(xs-p.x)(gr); return g?g->NewFrame():-1; } +void MGL_EXPORT mgl_end_frame(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->EndFrame(); } +int MGL_EXPORT mgl_get_num_frame(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetNumFrame():0; } +void MGL_EXPORT mgl_reset_frames(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->ResetFrames(); } +void MGL_EXPORT mgl_get_frame(HMGL gr, int i) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->GetFrame(i); } +void MGL_EXPORT mgl_set_frame(HMGL gr, int i) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetFrame(i); } +void MGL_EXPORT mgl_show_frame(HMGL gr, int i) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->ShowFrame(i); } +void MGL_EXPORT mgl_del_frame(HMGL gr, int i) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->DelFrame(i); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_transp_type(HMGL gr, int type) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTranspType(type); } +void MGL_EXPORT mgl_set_alpha(HMGL gr, int enable) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Alpha(enable); } +void MGL_EXPORT mgl_set_fog(HMGL gr, double d, double dz) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Fog(d,dz); } +void MGL_EXPORT mgl_set_light(HMGL gr, int enable) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Light(enable); } +void MGL_EXPORT mgl_set_light_n(HMGL gr, int n, int enable) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Light(n, enable); } +void MGL_EXPORT mgl_add_light_ext(HMGL gr, int n, double x, double y, double z, char c, double br, double ap) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AddLight(n,mglPoint(x,y,z),c,br,ap); } +void MGL_EXPORT mgl_add_light_loc(HMGL gr, int n, double x, double y, double z, double dx, double dy, double dz, char c, double br, double ap) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AddLight(n,mglPoint(x,y,z),mglPoint(dx,dy,dz),c,br,ap); } +void MGL_EXPORT mgl_add_light(HMGL gr, int n, double x, double y, double z) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AddLight(n,mglPoint(x,y,z)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mat_push(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Push(); } +void MGL_EXPORT mgl_mat_pop(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Pop(); } +void MGL_EXPORT mgl_clf(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Clf(); } +void MGL_EXPORT mgl_clf_chr(HMGL gr, char ch) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Clf(mglColor(ch)); } +void MGL_EXPORT mgl_clf_rgb(HMGL gr, double r, double g, double b) +{ mglCanvas *gg = dynamic_cast(gr); if(gg) gg->Clf(mglColor(r,g,b)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_subplot_d(HMGL gr, int nx,int ny,int m,const char *style,double dx,double dy) +{ + double x1,x2,y1,y2; + int mx = m%nx, my = m/nx; + if(gr->get(MGL_AUTO_FACTOR)) { dx /= 1.55; dy /= 1.55; } + else { dx /= 2; dy /= 2; } + x1 = (mx+dx)/nx; x2 = (mx+1+dx)/nx; + y2 = 1.f-(my+dy)/ny; y1 = 1.f-(my+1+dy)/ny; + mglCanvas *g = dynamic_cast(gr); + if(g) g->InPlot(x1,x2,y1,y2,style); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_subplot(HMGL gr, int nx,int ny,int m,const char *style) +{ mgl_subplot_d(gr,nx,ny,m,style,0,0); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_multiplot(HMGL gr, int nx,int ny,int m,int dx,int dy,const char *style) +{ + double x1,x2,y1,y2; + int mx = m%nx, my = m/nx; + dx = (dx<1 || dx+mx>nx) ? 1 : dx; + dy = (dy<1 || dy+my>ny) ? 1 : dy; + x1 = double(mx)/nx; x2 = double(mx+dx)/nx; + y2 = 1-double(my)/ny; y1 = 1-double(my+dy)/ny; + mglCanvas *g = dynamic_cast(gr); if(g) g->InPlot(x1,x2,y1,y2,style); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_inplot(HMGL gr, double x1,double x2,double y1,double y2) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->InPlot(x1,x2,y1,y2,false); } +void MGL_EXPORT mgl_relplot(HMGL gr, double x1,double x2,double y1,double y2) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->InPlot(x1,x2,y1,y2,true); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_columnplot(HMGL gr, int num, int i, double dd) +{ + register double w = 1./num; + mglCanvas *g = dynamic_cast(gr); + if(g) g->InPlot(0,1,1-w*(i+1-dd),1-i*w,true); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_gridplot(HMGL gr, int nx, int ny, int i, double dd) +{ + register int ix=i%nx, iy=i/nx; + register double wx = 1./nx, wy = 1./ny; + mglCanvas *g = dynamic_cast(gr); + if(g) g->InPlot(ix*wx,wx*(ix+1-dd),1-wy*(iy+1-dd),1-iy*wy,true); +} +void MGL_EXPORT mgl_gridplot_(uintptr_t *gr, int *nx, int *ny, int *m, mreal *d) +{ mgl_gridplot(_GR_,*nx,*ny,*m,*d); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stickplot(HMGL gr, int num, int i, double tet, double phi) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->StickPlot(num, i, tet, phi); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_aspect(HMGL gr, double Ax,double Ay,double Az) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Aspect(Ax,Ay,Az); } +void MGL_EXPORT mgl_rotate(HMGL gr, double TetX,double TetZ,double TetY) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Rotate(TetX,TetZ,TetY); } +void MGL_EXPORT mgl_view(HMGL gr, double TetX,double TetZ,double TetY) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->View(TetX,TetZ,TetY); } +void MGL_EXPORT mgl_zoom(HMGL gr, double x1, double y1, double x2, double y2) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Zoom(x1,y1,x2,y2); } +void MGL_EXPORT mgl_rotate_vector(HMGL gr, double Tet,double x,double y,double z) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->RotateN(Tet,x,y,z); } +void MGL_EXPORT mgl_perspective(HMGL gr, double val) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Perspective(val); } +void MGL_EXPORT mgl_title(HMGL gr, const char *title, const char *stl, double size) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Title(title,stl,size); } +void MGL_EXPORT mgl_titlew(HMGL gr, const wchar_t *title, const char *stl, double size) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Title(title,stl,size); } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_new_frame_(uintptr_t *gr) { return _GR_->NewFrame(); } +void MGL_EXPORT mgl_end_frame_(uintptr_t *gr) { _GR_->EndFrame(); } +int MGL_EXPORT mgl_get_num_frame_(uintptr_t *gr) { return _GR_->GetNumFrame(); } +void MGL_EXPORT mgl_reset_frames_(uintptr_t *gr) { _GR_->ResetFrames(); } +void MGL_EXPORT mgl_get_frame_(uintptr_t *gr, int *i) { _GR_->GetFrame(*i); } +void MGL_EXPORT mgl_set_frame_(uintptr_t *gr, int *i) { _GR_->SetFrame(*i); } +void MGL_EXPORT mgl_show_frame_(uintptr_t *gr, int *i) { _GR_->ShowFrame(*i); } +void MGL_EXPORT mgl_del_frame_(uintptr_t *gr, int *i) { _GR_->DelFrame(*i); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_transp_type_(uintptr_t *gr, int *type) { _GR_->SetTranspType(*type); } +void MGL_EXPORT mgl_set_alpha_(uintptr_t *gr, int *enable) { _GR_->Alpha(*enable); } +void MGL_EXPORT mgl_set_fog_(uintptr_t *gr, mreal *d, mreal *dz) { _GR_->Fog(*d, *dz); } +void MGL_EXPORT mgl_set_light_(uintptr_t *gr, int *enable) { _GR_->Light(*enable); } +void MGL_EXPORT mgl_set_light_n_(uintptr_t *gr, int *n, int *enable) +{ _GR_->Light(*n, *enable); } +void MGL_EXPORT mgl_add_light_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z) +{ _GR_->AddLight(*n,mglPoint(*x,*y,*z)); } +void MGL_EXPORT mgl_add_light_ext_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z, char *c, mreal *br, mreal *ap, int) +{ _GR_->AddLight(*n,mglPoint(*x,*y,*z),*c,*br,*ap); } +void MGL_EXPORT mgl_add_light_loc_(uintptr_t *gr, int *n, mreal *x, mreal *y, mreal *z, mreal *dx, mreal *dy, mreal *dz, char *c, mreal *br, mreal *ap, int) +{ _GR_->AddLight(*n,mglPoint(*x,*y,*z),mglPoint(*dx,*dy,*dz),*c,*br,*ap); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mat_push_(uintptr_t *gr) { _GR_->Push(); } +void MGL_EXPORT mgl_mat_pop_(uintptr_t *gr) { _GR_->Pop(); } +void MGL_EXPORT mgl_clf_(uintptr_t *gr) +{ _GR_->Clf(); } +void MGL_EXPORT mgl_clf_chr_(uintptr_t *gr, const char *ch, int) +{ _GR_->Clf(mglColor(*ch)); } +void MGL_EXPORT mgl_clf_rgb_(uintptr_t *gr, mreal *r, mreal *g, mreal *b) +{ _GR_->Clf(mglColor(*r,*g,*b)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_subplot_d_(uintptr_t *gr, int *nx,int *ny,int *m,const char *st, mreal *dx, mreal *dy,int l) +{ char *s=new char[l+1]; memcpy(s,st,l); s[l]=0; + mgl_subplot_d(_GR_,*nx,*ny,*m,s,*dx,*dy); delete []s; } +void MGL_EXPORT mgl_subplot_(uintptr_t *gr, int *nx,int *ny,int *m,const char *st,int l) +{ char *s=new char[l+1]; memcpy(s,st,l); s[l]=0; + mgl_subplot(_GR_,*nx,*ny,*m,s); delete []s; } +void MGL_EXPORT mgl_multiplot_(uintptr_t *gr, int *nx,int *ny,int *m,int *dx,int *dy,const char *st,int l) +{ char *s=new char[l+1]; memcpy(s,st,l); s[l]=0; + mgl_multiplot(_GR_,*nx,*ny,*m,*dx,*dy,s); delete []s; } +void MGL_EXPORT mgl_inplot_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2) +{ _GR_->InPlot(*x1,*x2,*y1,*y2,false); } +void MGL_EXPORT mgl_relplot_(uintptr_t *gr, mreal *x1, mreal *x2, mreal *y1, mreal *y2) +{ _GR_->InPlot(*x1,*x2,*y1,*y2,true); } +void MGL_EXPORT mgl_columnplot_(uintptr_t *gr, int *num, int *i, mreal *d) +{ mgl_columnplot(_GR_,*num,*i,*d); } +void MGL_EXPORT mgl_columnplot_d_(uintptr_t *gr, int *nx, int *ny, int *i, mreal *d) +{ mgl_gridplot(_GR_,*nx,*ny,*i,*d); } +void MGL_EXPORT mgl_stickplot_(uintptr_t *gr, int *num, int *i, mreal *tet, mreal *phi) +{ _GR_->StickPlot(*num, *i, *tet, *phi); } + +void MGL_EXPORT mgl_title_(uintptr_t *gr, const char *title, const char *stl, mreal *size, int l,int m) +{ char *t=new char[l+1]; memcpy(t,title,l); t[l]=0; + char *s=new char[m+1]; memcpy(s,stl,m); s[m]=0; + _GR_->Title(t,s,*size); delete []s; delete []t; } +void MGL_EXPORT mgl_aspect_(uintptr_t *gr, mreal *Ax, mreal *Ay, mreal *Az) +{ _GR_->Aspect(*Ax,*Ay,*Az); } +void MGL_EXPORT mgl_rotate_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY) +{ _GR_->Rotate(*TetX,*TetZ,*TetY); } +void MGL_EXPORT mgl_view_(uintptr_t *gr, mreal *TetX, mreal *TetZ, mreal *TetY) +{ _GR_->View(*TetX,*TetZ,*TetY); } +void MGL_EXPORT mgl_zoom_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *x2, mreal *y2) +{ _GR_->Zoom(*x1,*y1,*x2,*y2); } +void MGL_EXPORT mgl_rotate_vector_(uintptr_t *gr, mreal *Tet, mreal *x, mreal *y, mreal *z) +{ _GR_->RotateN(*Tet,*x,*y,*z); } +void MGL_EXPORT mgl_perspective_(uintptr_t *gr, double val) +{ _GR_->Perspective(val); } +//----------------------------------------------------------------------------- +MGL_EXPORT const unsigned char *mgl_get_rgb_(uintptr_t *gr) { return gr ? _GR_->GetBits():0; } +MGL_EXPORT const unsigned char *mgl_get_rgba_(uintptr_t *gr){ return gr ? _GR_->GetRGBA():0; } +int MGL_EXPORT mgl_get_width_(uintptr_t *gr) { return gr ? _GR_->GetWidth():0; } +int MGL_EXPORT mgl_get_height_(uintptr_t *gr) { return gr ? _GR_->GetHeight():0;} +void MGL_EXPORT mgl_calc_xyz_(uintptr_t *gr, int *xs, int *ys, mreal *x, mreal *y, mreal *z) +{ mglPoint p = _GR_->CalcXYZ(*xs,*ys); *x = p.x; *y = p.y; *z = p.z; } +void MGL_EXPORT mgl_calc_scr_(uintptr_t *gr, mreal *x, mreal *y, mreal *z, int *xs, int *ys) +{ _GR_->CalcScr(mglPoint(*x,*y,*z),xs,ys); } +void MGL_EXPORT mgl_set_obj_id_(uintptr_t *gr, int *id) { _GR_->SetObjId(*id); } +int MGL_EXPORT mgl_get_obj_id_(uintptr_t *gr, int *x, int *y) { return _GR_->GetObjId(*x,*y); } +int MGL_EXPORT mgl_get_spl_id_(uintptr_t *gr, int *x, int *y) { return _GR_->GetSplId(*x,*y); } +//----------------------------------------------------------------------------- +HMGL MGL_EXPORT mgl_create_graph(int width, int height) +{ return new mglCanvas(width,height); } +void MGL_EXPORT mgl_delete_graph(HMGL gr) { if(gr) delete gr; } +void MGL_EXPORT mgl_set_size(HMGL gr, int width, int height) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetSize(width, height); } +void MGL_EXPORT mgl_set_def_param(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->DefaultPlotParam(); } +void MGL_EXPORT mgl_combine_gr(HMGL gr, HMGL in) +{ const mglCanvas *gg = dynamic_cast(in); + mglCanvas *g = dynamic_cast(gr); if(g && gg) g->Combine(gg); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_tick_len(HMGL gr, double len, double stt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTickLen(len,stt); } +void MGL_EXPORT mgl_set_axis_stl(HMGL gr, const char *stl, const char *tck, const char *sub) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetAxisStl(stl,tck,sub); } +void MGL_EXPORT mgl_tune_ticks(HMGL gr, int tune, double pos) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTuneTicks(tune,pos); } +void MGL_EXPORT mgl_adjust_ticks(HMGL gr, const char *dir) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AdjustTicks(dir,true); } +void MGL_EXPORT mgl_set_ticks(HMGL gr, char dir, double d, int ns, double org) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTicks(dir,d,ns,org); } +void MGL_EXPORT mgl_set_ticks_str(HMGL gr, char dir, const char *lbl, int add) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTicksVal(dir,lbl,add); } +void MGL_EXPORT mgl_set_ticks_wcs(HMGL gr, char dir, const wchar_t *lbl, int add) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTicksVal(dir,lbl,add); } +void MGL_EXPORT mgl_set_ticks_val(HMGL gr, char dir, HCDT val, const char *lbl, int add) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTicksVal(dir,val,lbl,add); } +void MGL_EXPORT mgl_set_ticks_valw(HMGL gr, char dir, HCDT val, const wchar_t *lbl, int add) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTicksVal(dir,val,lbl,add); } +void MGL_EXPORT mgl_set_tick_templ(HMGL gr, char dir, const char *templ) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTickTempl(dir,templ); } +void MGL_EXPORT mgl_set_tick_templw(HMGL gr, char dir, const wchar_t *templ) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTickTempl(dir,templ); } +void MGL_EXPORT mgl_set_ticks_time(HMGL gr, char dir, double d, const char *t) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTickTime(dir,d,t); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_box(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Box(); } +void MGL_EXPORT mgl_box_str(HMGL gr, const char *col, int ticks) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Box(col,ticks); } +void MGL_EXPORT mgl_axis(HMGL gr, const char *dir, const char *stl, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Axis(dir,stl,opt); } +void MGL_EXPORT mgl_axis_grid(HMGL gr, const char *dir,const char *pen, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Grid(dir,pen,opt); } +void MGL_EXPORT mgl_label(HMGL gr, char dir, const char *text, double pos, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Label(dir,text,pos,opt); } +void MGL_EXPORT mgl_labelw(HMGL gr, char dir, const wchar_t *text, double pos, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Labelw(dir,text,pos,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_colorbar(HMGL gr, const char *sch) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Colorbar(sch); } +void MGL_EXPORT mgl_colorbar_ext(HMGL gr, const char *sch, double x, double y, double w, double h) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Colorbar(sch,x,y,w,h); } +void MGL_EXPORT mgl_colorbar_val(HMGL gr, HCDT dat, const char *sch) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Colorbar(dat,sch); } +void MGL_EXPORT mgl_colorbar_val_ext(HMGL gr, HCDT dat, const char *sch,double x, double y, double w, double h) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Colorbar(dat,sch,x,y,w,h); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_add_legend(HMGL gr, const char *text,const char *style) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AddLegend(text,style); } +void MGL_EXPORT mgl_add_legendw(HMGL gr, const wchar_t *text,const char *style) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->AddLegend(text,style); } +void MGL_EXPORT mgl_clear_legend(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->ClearLegend(); } +void MGL_EXPORT mgl_legend_pos(HMGL gr, double x, double y, const char *font, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Legend(x,y,font,opt); } +void MGL_EXPORT mgl_legend(HMGL gr, int where, const char *font, const char *opt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Legend(where,font,opt); } +void MGL_EXPORT mgl_set_legend_marks(HMGL gr, int num) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetLegendMarks(num); } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_graph_(int *width, int *height) +{ return uintptr_t(new mglCanvas(*width,*height)); } +void MGL_EXPORT mgl_delete_graph_(uintptr_t *gr) { delete _GR_; } +void MGL_EXPORT mgl_set_size_(uintptr_t *gr, int *width, int *height) +{ _GR_->SetSize(*width,*height); } +void MGL_EXPORT mgl_set_def_param_(uintptr_t *gr) { _GR_->DefaultPlotParam(); } +void MGL_EXPORT mgl_combine_gr_(uintptr_t *gr, uintptr_t *in) +{ _GR_->Combine((mglCanvas *)in); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_tick_len_(uintptr_t *gr, mreal *len, mreal *stt) +{ _GR_->SetTickLen(*len, *stt); } +void MGL_EXPORT mgl_set_axis_stl_(uintptr_t *gr, const char *stl, const char *tck, const char *sub, int l,int m,int n) +{ char *a=new char[l+1]; memcpy(a,stl,l); a[l]=0; + char *t=new char[m+1]; memcpy(t,tck,m); t[m]=0; + char *s=new char[n+1]; memcpy(s,sub,n); s[n]=0; + _GR_->SetAxisStl(a,t,s); delete []a; delete []s; delete []t; } +void MGL_EXPORT mgl_adjust_ticks_(uintptr_t *gr, const char *dir, int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + _GR_->AdjustTicks(s); delete []s; } +void MGL_EXPORT mgl_set_ticks_(uintptr_t *gr, char *dir, mreal *d, int *ns, mreal *org, int) +{ _GR_->SetTicks(*dir, *d, *ns, *org); } +void MGL_EXPORT mgl_set_ticks_str_(uintptr_t *gr, const char *dir, const char *lbl, int *add,int,int l) +{ char *s=new char[l+1]; memcpy(s,lbl,l); s[l]=0; + _GR_->SetTicksVal(*dir,s,*add); delete []s; } +void MGL_EXPORT mgl_set_ticks_val_(uintptr_t *gr, const char *dir, uintptr_t *val, const char *lbl, int *add,int,int l) +{ char *s=new char[l+1]; memcpy(s,lbl,l); s[l]=0; + _GR_->SetTicksVal(*dir,_DA_(val),s,*add); delete []s; } +void MGL_EXPORT mgl_tune_ticks_(uintptr_t *gr, int *tune, mreal *fact_pos) +{ _GR_->SetTuneTicks(*tune, *fact_pos); } +void MGL_EXPORT mgl_set_tick_templ_(uintptr_t *gr, const char *dir, const char *templ,int,int l) +{ char *s=new char[l+1]; memcpy(s,templ,l); s[l]=0; + _GR_->SetTickTempl(*dir,s); delete []s; } +void MGL_EXPORT mgl_set_ticks_time_(uintptr_t *gr, const char *dir, mreal *d, const char *t,int,int l) +{ char *s=new char[l+1]; memcpy(s,t,l); s[l]=0; + _GR_->SetTickTime(*dir,*d,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_box_(uintptr_t *gr) { _GR_->Box(); } +void MGL_EXPORT mgl_box_str_(uintptr_t *gr, const char *col, int *ticks, int l) +{ char *s=new char[l+1]; memcpy(s,col,l); s[l]=0; + _GR_->Box(s,*ticks); delete []s; } +void MGL_EXPORT mgl_axis_(uintptr_t *gr, const char *dir, const char *stl, const char *opt,int l,int n,int m) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + char *p=new char[n+1]; memcpy(p,stl,l); p[n]=0; + char *o=new char[m+1]; memcpy(o,opt,m); o[m]=0; + _GR_->Axis(s,p,o); delete []s; delete []p; delete []o; } +void MGL_EXPORT mgl_axis_grid_(uintptr_t *gr, const char *dir,const char *pen, const char *opt,int l,int n,int m) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + char *p=new char[n+1]; memcpy(p,pen,n); p[n]=0; + char *o=new char[m+1]; memcpy(o,opt,m); o[m]=0; + _GR_->Grid(s,p,o); delete []s; delete []p; delete []o; } +void MGL_EXPORT mgl_label_(uintptr_t *gr, const char *dir, const char *text, mreal *pos, const char *opt,int,int l,int m) +{ char *s=new char[l+1]; memcpy(s,text,l); s[l]=0; + char *o=new char[m+1]; memcpy(o,opt,m); o[m]=0; + _GR_->Label(*dir, s, *pos, o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_colorbar_(uintptr_t *gr, const char *sch,int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + _GR_->Colorbar(s); delete []s; } +void MGL_EXPORT mgl_colorbar_ext_(uintptr_t *gr, const char *sch, mreal *x, mreal *y, mreal *w, mreal *h, int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + _GR_->Colorbar(s,*x,*y,*w,*h); delete []s; } +void MGL_EXPORT mgl_colorbar_val_(uintptr_t *gr, uintptr_t *dat, const char *sch,int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + _GR_->Colorbar(_DA_(dat), s); delete []s; } +void MGL_EXPORT mgl_colorbar_val_ext_(uintptr_t *gr, uintptr_t *dat, const char *sch, mreal *x, mreal *y, mreal *w, mreal *h, int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + _GR_->Colorbar(_DA_(dat),s,*x,*y,*w,*h); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_add_legend_(uintptr_t *gr, const char *text,const char *style,int l,int n) +{ char *s=new char[l+1]; memcpy(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,style,n); f[n]=0; + _GR_->AddLegend(s,f); delete []s; delete []f; } +void MGL_EXPORT mgl_clear_legend_(uintptr_t *gr) { if(gr) _GR_->ClearLegend(); } +void MGL_EXPORT mgl_legend_pos_(uintptr_t *gr, mreal *x, mreal *y, const char *font, const char *opt,int l,int m) +{ char *s=new char[l+1]; memcpy(s,font,l); s[l]=0; + char *o=new char[m+1]; memcpy(o,opt,m); o[m]=0; + _GR_->Legend(*x, *y, s, o); delete []s; delete []o; } +void MGL_EXPORT mgl_legend_(uintptr_t *gr, int *where, const char *font, const char *opt,int l,int m) +{ char *s=new char[l+1]; memcpy(s,font,l); s[l]=0; + char *o=new char[m+1]; memcpy(o,opt,m); o[m]=0; + _GR_->Legend(*where, s, o); delete []s; delete []o; } +void MGL_EXPORT mgl_set_legend_marks_(uintptr_t *gr, int *num) +{ _GR_->SetLegendMarks(*num); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_wnd_set_delay(HMGL gr, double dt) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetDelay(dt); } +double MGL_EXPORT mgl_wnd_get_delay(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); return g?g->GetDelay():0; } +void MGL_EXPORT mgl_wnd_set_delay_(uintptr_t *gr, mreal *dt) { _GR_->SetDelay(*dt); } +double MGL_EXPORT mgl_wnd_get_delay_(uintptr_t *gr) { return _GR_->GetDelay(); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_plotfactor(HMGL gr, double val) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetPlotFactor(val); } +void MGL_EXPORT mgl_set_plotfactor_(uintptr_t *gr, mreal *val) +{ _GR_->SetPlotFactor(*val); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_set_tick_shift(HMGL gr, double sx, double sy, double sz, double sc) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->SetTickShift(mglPoint(sx,sy,sz,sc)); } +void MGL_EXPORT mgl_set_tick_shift_(uintptr_t *gr, mreal *sx, mreal *sy, mreal *sz, mreal *sc) +{ _GR_->SetTickShift(mglPoint(*sx,*sy,*sz,*sc)); } +//----------------------------------------------------------------------------- +#if !MGL_HAVE_PNG +void MGL_EXPORT mgl_write_prc(HMGL gr, const char *fname,const char *descr, int make_pdf) +{ mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; } +void MGL_EXPORT mgl_write_prc_(uintptr_t *graph, const char *fname,const char *descr, int *make_pdf,int lf,int ld) +{ mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; } +#endif +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_finish(HMGL gr) +{ mglCanvas *g = dynamic_cast(gr); if(g) g->Finish(); } +void MGL_EXPORT mgl_finish_(uintptr_t *gr) { _GR_->Finish(); } +//----------------------------------------------------------------------------- diff --git a/src/complex.cpp b/src/complex.cpp new file mode 100644 index 0000000..8b43c3c --- /dev/null +++ b/src/complex.cpp @@ -0,0 +1,1125 @@ +/*************************************************************************** + * complex.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/datac.h" +#include "mgl2/evalc.h" +#include "mgl2/thread.h" + +#include "interp.hpp" + +//----------------------------------------------------------------------------- +void MGL_EXPORT mglStartThreadC(void *(*func)(void *), void (*post)(mglThreadC *,dual *), long n, + dual *a, const dual *b, const dual *c, const long *p, + const void *v, const dual *d, const dual *e, const char *s) +{ + if(!func) return; +#if MGL_HAVE_PTHREAD + if(mglNumThr<1) mgl_set_num_thr(0); + if(mglNumThr>1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadC *par=new mglThreadC[mglNumThr]; + register long i; + for(i=0;i1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadV *par=new mglThreadV[mglNumThr]; + register long i; + for(i=0;ip[0], kind=t->p[2]; + dual *b=t->a; + const dual *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>1 && jp[0],ny=t->p[1], kind=t->p[2]; + dual *b=t->a; + const dual *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>1 && jp[0]*t->p[1], nz=t->n/nn, kind=t->p[2]; + dual *b=t->a; + const dual *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>1 && jnx,ny=d->ny,nz=d->nz; +// if(Type == SMOOTH_NONE) return; + long p[3]={nx,ny,Type}; + dual *b = new dual[nx*ny*nz]; + // ����������� �� x + memset(b,0,nx*ny*nz*sizeof(dual)); + if(nx>4 && strchr(dirs,'x')) + { + mglStartThreadC(mgl_csmth_x,0,nx*ny*nz,b,d->a,0,p); + memcpy(d->a,b,nx*ny*nz*sizeof(dual)); + memset(b,0,nx*ny*nz*sizeof(dual)); + } + if(ny>4 && strchr(dirs,'y')) + { + mglStartThreadC(mgl_csmth_y,0,nx*ny*nz,b,d->a,0,p); + memcpy(d->a,b,nx*ny*nz*sizeof(dual)); + memset(b,0,nx*ny*nz*sizeof(dual)); + } + if(nz>4 && strchr(dirs,'z')) + { + mglStartThreadC(mgl_csmth_z,0,nx*ny*nz,b,d->a,0,p); + memcpy(d->a,b,nx*ny*nz*sizeof(dual)); + } + delete []b; +} +void MGL_EXPORT mgl_datac_smooth_(uintptr_t *d, const char *dir, mreal *delta,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_smooth(_DC_,s,*delta); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_ccsum_z(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + long nz=t->p[2], nn=t->n; + dual *b=t->a; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + dual *b=t->a; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + dual *b=t->a; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + dual *b = new dual[nn]; + memcpy(b,d->a,nn*sizeof(dual)); + if(strchr(dir,'z') && nz>1) + { + mglStartThreadC(mgl_ccsum_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThreadC(mgl_ccsum_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThreadC(mgl_ccsum_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + delete []b; +} +void MGL_EXPORT mgl_datac_cumsum_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_cumsum(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cint_z(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + long nz=t->p[2], nn=t->n; + dual *b=t->a, dd=0.5/nz; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + dual *b=t->a, dd=0.5/ny; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + dual *b=t->a, dd=0.5/nx; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + dual *b = new dual[nn]; + memcpy(b,d->a,nn*sizeof(dual)); + if(strchr(dir,'z') && nz>1) + { + mglStartThreadC(mgl_cint_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThreadC(mgl_cint_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThreadC(mgl_cint_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + delete []b; +} +void MGL_EXPORT mgl_datac_integral_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_integral(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cdif_z(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + long nz=t->p[2], nn=t->n; + dual *b=t->a, dd=0.5*nz; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + dual *b=t->a, dd=0.5*ny; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + dual *b=t->a, dd=0.5*nx; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + dual *b = new dual[nn]; + if(strchr(dir,'z') && nz>1) + { + mglStartThreadC(mgl_cdif_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThreadC(mgl_cdif_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThreadC(mgl_cdif_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + delete []b; +} +void MGL_EXPORT mgl_datac_diff_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_diff(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cdif2_z(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + long nz=t->p[2], nn=t->n; + dual *b=t->a, dd=0.5*nz*nz; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + dual *b=t->a, dd=0.5*ny*ny; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + dual *b=t->a, dd=0.5*nx*nx; + const dual *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + dual *b = new dual[nn]; + if(strchr(dir,'z') && nz>1) + { + mglStartThreadC(mgl_cdif2_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThreadC(mgl_cdif2_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThreadC(mgl_cdif2_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(dual)); + } + delete []b; +} +void MGL_EXPORT mgl_datac_diff2_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_diff2(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_swap(HADT d, const char *dir) +{ + if(!dir || *dir==0) return; + if(strchr(dir,'z') && d->nz>1) mgl_datac_roll(d,'z',d->nz/2); + if(strchr(dir,'y') && d->ny>1) mgl_datac_roll(d,'y',d->ny/2); + if(strchr(dir,'x') && d->nx>1) mgl_datac_roll(d,'x',d->nx/2); +} +void MGL_EXPORT mgl_datac_swap_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_swap(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_roll(HADT dd, char dir, long num) +{ + long nx=dd->nx,ny=dd->ny,nz=dd->nz, d; + dual *b,*a=dd->a; + if(dir=='z' && nz>1) + { + d = num>0 ? num%nz : (num+nz*(1+num/nz))%nz; + if(d==0) return; // nothing to do + b = new dual[nx*ny*nz]; + memcpy(b,a+nx*ny*d,nx*ny*(nz-d)*sizeof(dual)); + memcpy(b+nx*ny*(nz-d),a,nx*ny*d*sizeof(dual)); + memcpy(a,b,nx*ny*nz*sizeof(dual)); delete []b; + } + if(dir=='y' && ny>1) + { + d = num>0 ? num%ny : (num+ny*(1+num/ny))%ny; + if(d==0) return; // nothing to do + b = new dual[nx*ny*nz]; + memcpy(b,a+nx*d,(nx*ny*nz-nx*d)*sizeof(dual)); +#pragma omp parallel for + for(long i=0;i1) + { + d = num>0 ? num%nx : (num+nx*(1+num/nx))%nx; + if(d==0) return; // nothing to do + b = new dual[nx*ny*nz]; + memcpy(b,a+d,(nx*ny*nz-d)*sizeof(dual)); +#pragma omp parallel for + for(long i=0;inx,ny=d->ny,nz=d->nz; + dual *a=d->a; + if(strchr(dir,'z') && nz>1) + { +#pragma omp parallel for collapse(2) + for(long i=0;i1) + { +#pragma omp parallel for collapse(2) + for(long i=0;i1) + { +#pragma omp parallel for collapse(2) + for(long j=0;j(a,nx,ny,nz,x,y,z,dx,dy,dz); } +//----------------------------------------------------------------------------- +dual mglLinearC(const dual *a, long nx, long ny, long nz, mreal x, mreal y, mreal z) +{ return mglLineart(a,nx,ny,nz,x,y,z); } +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_spline(HCDT d, mreal x,mreal y,mreal z) +{ + const mglDataC *dd=dynamic_cast(d); + if(!dd) return mgl_data_spline(d,x,y,z); + return dd->ny*dd->nz==1?mglSpline1st(dd->a,dd->nx,x):mglSpline3st(dd->a,dd->nx,dd->ny,dd->nz,x,y,z); +} +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_spline_ext(HCDT d, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz) +{ + const mglDataC *dd=dynamic_cast(d); + if(!dd) + { + mreal rx,ry,rz,res; + res=mgl_data_spline_ext(d,x,y,z,&rx,&ry,&rz); + if(dx) *dx=rx; if(dy) *dy=ry; if(dz) *dz=rz; + return res; + } + return mglSpline3t(dd->a,dd->nx,dd->ny,dd->nz,x,y,z,dx,dy,dz); +} +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_spline_(uintptr_t *d, mreal *x,mreal *y,mreal *z) +{ return mgl_datac_spline(_DA_(d),*x,*y,*z); } +dual MGL_EXPORT mgl_datac_spline_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz) +{ return mgl_datac_spline_ext(_DA_(d),*x,*y,*z,dx,dy,dz); } +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_linear_ext(HCDT d, mreal x,mreal y,mreal z, dual *dx,dual *dy,dual *dz) +{ + long kx=long(x), ky=long(y), kz=long(z); + dual b0,b1; + const mglDataC *dd=dynamic_cast(d); + if(!dd) + { + mreal rx,ry,rz,res; + res=mgl_data_linear_ext(d,x,y,z,&rx,&ry,&rz); + if(dx) *dx=rx; if(dy) *dy=ry; if(dz) *dz=rz; + return res; + } + + long nx=dd->nx, ny=dd->ny, nz=dd->nz, dn=ny>1?nx:0; + kx = kx>=0 ? kx:0; kx = kx=0 ? ky:0; ky = ky=0 ? kz:0; kz = kza, *bb; + if(kz>=0) + { + aa=dd->a+kx+nx*(ky+ny*kz); bb = aa+nx*ny; + b0 = aa[0]*(1-x-y+x*y) + x*(1-y)*aa[1] + y*(1-x)*aa[dn] + x*y*aa[1+dn]; + b1 = bb[0]*(1-x-y+x*y) + x*(1-y)*bb[1] + y*(1-x)*bb[dn] + x*y*bb[1+dn]; + } + else + { + z=0; + if(ky>=0) + { + aa=dd->a+kx+nx*ky; + b0 = b1 = aa[0]*(1-x-y+x*y) + x*(1-y)*aa[1] + y*(1-x)*aa[dn] + x*y*aa[1+dn]; + } + else if(kx>=0) + { + aa=dd->a+kx; b0 = b1 = aa[0]*(1-x) + x*aa[1]; + } + else b0 = b1 = dd->a[0]; + } + if(dx) *dx = kx>=0?aa[1]-aa[0]:0; + if(dy) *dy = ky>=0?aa[dn]-aa[0]:0; + if(dz) *dz = b1-b0; + + return b0 + z*(b1-b0); +} +dual MGL_EXPORT mgl_datac_linear(HCDT d, mreal x,mreal y,mreal z) +{ return mgl_datac_linear_ext(d, x,y,z, 0,0,0); } +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_linear_(uintptr_t *d, mreal *x,mreal *y,mreal *z) +{ return mgl_datac_linear(_DA_(d),*x,*y,*z); } +dual MGL_EXPORT mgl_datac_linear_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, dual *dx,dual *dy,dual *dz) +{ return mgl_datac_linear_ext(_DA_(d),*x,*y,*z,dx,dy,dz); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_crop(HADT d, long n1, long n2, char dir) +{ + long nx=d->nx,ny=d->ny,nz=d->nz, nn; + dual *b; + if(n1<0) n1=0; + switch(dir) + { + case 'x': + n2 = n2>0 ? n2 : nx+n2; + if(n2<0 || n2>=nx || n2a+nx*i+n1,nn*sizeof(dual)); + d->nx = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; d->NewId(); + break; + case 'y': + n2 = n2>0 ? n2 : ny+n2; + if(n2<0 || n2>=ny || n2a+nx*(n1+i+ny*j),nx*sizeof(dual)); + d->ny = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; + break; + case 'z': + n2 = n2>0 ? n2 : nz+n2; + if(n2<0 || n2>=nz || n2a+nx*ny*n1,nn*nx*ny*sizeof(dual)); + d->nz = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; + break; + } +} +void MGL_EXPORT mgl_datac_crop_(uintptr_t *d, int *n1, int *n2, const char *dir,int) +{ mgl_datac_crop(_DC_,*n1,*n2,*dir); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_insert(HADT d, char dir, long at, long num) +{ + if(num<1) return; + at = at<0 ? 0:at; + long nx=d->nx, ny=d->ny, nz=d->nz, nn; + mglDataC b; + if(dir=='x') + { + if(at>nx) at=nx; + nn=nx+num; b.Create(nn,ny,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nn*k, d->a+nx*k,at*sizeof(dual)); + if(ata+at+nx*k,(nx-at)*sizeof(dual)); + for(long i=0;ia[nx*k+at]; // copy values + } + d->Set(b); nx+=num; + } + if(dir=='y') + { + if(at>ny) at=ny; + nn=num+ny; b.Create(nx,nn,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nx*nn*k, d->a+nx*ny*k,at*nx*sizeof(dual)); + if(ata+nx*(at+ny*k),(ny-at)*nx*sizeof(dual)); + for(long i=0;ia+nx*(ny*k+at),nx*sizeof(dual)); + } + d->Set(b); ny+=num; + } + if(dir=='z') + { + if(at>nz) at=nz; + b.Create(nx,ny,nz+num); + if(at>0) memcpy(b.a, d->a,at*nx*ny*sizeof(dual)); + if(ata+nx*ny*at,(nz-at)*nx*ny*sizeof(dual)); +#pragma omp parallel for + for(long i=0;ia+nx*ny*at,nx*ny*sizeof(dual)); + d->Set(b); nz+=num; + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_delete(HADT d, char dir, long at, long num) +{ + if(num<1 || at<0) return; + mglDataC b; + long nx=d->nx, ny=d->ny, nz=d->nz, nn; + if(dir=='x') + { + if(at+num>=nx) return; + nn=nx-num; b.Create(nn,ny,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nn*k, d->a+nx*k,at*sizeof(dual)); + memcpy(b.a+at+nn*k, d->a+at+num+nx*k,(nx-at-num)*sizeof(dual)); + } + d->Set(b); nx-=num; + } + if(dir=='y') + { + if(at+num>=ny) return; + nn=ny-num; b.Create(nx,nn,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nx*nn*k, d->a+nx*ny*k,at*nx*sizeof(dual)); + memcpy(b.a+nx*(at+nn*k), d->a+nx*(at+num+ny*k),(ny-at-num)*nx*sizeof(dual)); + } + d->Set(b); ny-=num; + } + if(dir=='z') + { + if(at+num>=nz) return; + b.Create(nx,ny,nz-num); + if(at>0) memcpy(b.a, d->a,at*nx*ny*sizeof(dual)); + memcpy(b.a+nx*ny*at, d->a+nx*ny*(at+num),(nz-at-num)*nx*ny*sizeof(dual)); + d->Set(b); nz-=num; + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_insert_(uintptr_t *d, const char *dir, int *at, int *num, int) +{ mgl_datac_insert(_DC_,*dir,*at,*num); } +void MGL_EXPORT mgl_datac_delete_(uintptr_t *d, const char *dir, int *at, int *num, int) +{ mgl_datac_delete(_DC_,*dir,*at,*num); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_value(HADT dat, dual v, long i, long j, long k) +{ + if(i>=0 && inx && j>=0 && jny && k>=0 && knz) + dat->a[i+dat->nx*(j+dat->ny*k)]=v; +} +void MGL_EXPORT mgl_datac_set_value_(uintptr_t *d, dual *v, int *i, int *j, int *k) +{ mgl_datac_set_value(_DC_,*v,*i,*j,*k); } +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_datac_get_value(HCDT dat, long i, long j, long k) +{ + if(i<0 || i>=dat->GetNx() || j<0 || j>=dat->GetNy() || k<0 || k>=dat->GetNz()) + return NAN; + const mglDataC *d = dynamic_cast(dat); + return d ? d->a[i+d->nx*(j+d->nz*k)] : dual(dat->v(i,j,k),0); +} +dual MGL_EXPORT mgl_datac_get_value_(uintptr_t *d, int *i, int *j, int *k) +{ return mgl_datac_get_value(_DA_(d),*i,*j,*k); } +//----------------------------------------------------------------------------- +MGL_EXPORT dual *mgl_datac_data(HADT dat) { return dat->a; } +//----------------------------------------------------------------------------- +MGL_EXPORT dual *mgl_datac_value(HADT dat, long i,long j,long k) +{ register long ii=i*dat->nx*(j+dat->ny*k); + return ii>=0 && iiGetNN() ? dat->a+ii : 0; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_join(HADT d, HCDT v) +{ + register long nx=d->nx, ny=d->ny, nz=d->nz; + const mglDataC *mv = dynamic_cast(v); + long vx=v->GetNx(), vy=v->GetNy(), vz=v->GetNz(), k=nx*ny*nz; + + if(nx==vx && ny==vy && (nz>1 || vz>1)) + { + dual *b = new dual[nx*ny*(nz+vz)]; + memcpy(b,d->a,nx*ny*nz*sizeof(dual)); + if(mv) memcpy(b+nx*ny*nz,mv->a,nx*ny*vz*sizeof(dual)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; d->nz += vz; + d->a = b; d->link=false; d->NewId(); + } + else if(nx==vx && (ny>1 || vy>1)) + { + ny *= nz; vy *= vz; + dual *b = new dual[nx*(ny+vy)]; + memcpy(b,d->a,nx*ny*sizeof(dual)); + if(mv) memcpy(b+nx*ny,mv->a,nx*vy*sizeof(dual)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; + d->nz = 1; d->ny = ny+vy; + d->a = b; d->link=false; d->NewId(); + } + else + { + nx *= ny*nz; vx *= vy*vz; + dual *b = new dual[nx+vx]; + memcpy(b,d->a,nx*sizeof(dual)); + if(mv) memcpy(b+nx,mv->a,vx*sizeof(dual)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; + d->nz = d->ny = 1; d->nx = nx+vx; + d->a = b; d->link=false; d->NewId(); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_join_(uintptr_t *d, uintptr_t *val) +{ mgl_datac_join(_DC_,_DA_(val)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_put_val(HADT d, dual val, long xx, long yy, long zz) +{ + long nx=d->nx, ny=d->ny, nz=d->nz; + if(xx>=nx || yy>=ny || zz>=nz) return; + dual *a=d->a; + if(xx<0 && yy<0 && zz<0) +#pragma omp parallel for + for(long i=0;inx, ny=d->ny, nz=d->nz; + if(xx>=nx || yy>=ny || zz>=nz) return; + const mglDataC *mv = dynamic_cast(v); + dual *a=d->a, vv=v->v(0); + const dual *b = mv?mv->a:0; + long vx=v->GetNx(), vy=v->GetNy(), vz=v->GetNz(); + if(xx<0 && yy<0 && zz<0) // whole array + { + if(vx>=nx && vy>=ny && vz>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j,k); } + else if(vx>=nx && vy>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx && vy>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=ny && vy>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx && vy>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;i=ny) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;i=nz) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;ip[0], st=t->p[1], bord=t->p[3], nn=t->n; + dual *b=t->a, q = *(t->b); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + dual *tmp = new dual[2*n]; + if(t->p[2]) +#if !MGL_HAVE_PTHREAD +#pragma omp for +#endif + for(long i=t->id;iid;inx,ny=d->ny,nz=d->nz,ll=strlen(how); + long p[4]={0,0,(mglchr(how,'a')||mglchr(how,'r'))?1:0,0}; + dual qq=q; + for(long i=0;i='0' && how[i]<='9') p[3] = how[i]-'0'; + if(mglchr(how,'z') && nz>1) + { + p[0]=nz; p[1]=nx*ny; + mglStartThreadC(mgl_difr,0,nx*ny,0,&qq,0,p); + } + if(mglchr(how,'y') && ny>1) + { + p[0]=ny; p[1]=nx; + mglStartThreadC(mgl_difr,0,nx*nz,0,&qq,0,p); + } + if((mglchr(how,'x')||mglchr(how,'r')) && nx>1) + { + p[0]=nx; p[1]=1; + mglStartThreadC(mgl_difr,0,ny*nz,0,&qq,0,p); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_diffr_(uintptr_t *d, const char *how, double q,int l) +{ char *s=new char[l+1]; memcpy(s,how,l); s[l]=0; + mgl_datac_diffr(_DC_,s,q); delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/complex_io.cpp b/src/complex_io.cpp new file mode 100644 index 0000000..cc214b8 --- /dev/null +++ b/src/complex_io.cpp @@ -0,0 +1,863 @@ +/*************************************************************************** + * data_io.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include + +#ifndef WIN32 +#include +#endif + +#include "mgl2/datac.h" +#include "mgl2/evalc.h" +#include "mgl2/thread.h" + +#if MGL_HAVE_HDF5 +#define H5_USE_16_API +#include +#endif + +#define isn(ch) ((ch)=='\n') +MGL_NO_EXPORT char *mgl_read_gz(gzFile fp); +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_create_datac() { return new mglDataC; } +HADT MGL_EXPORT mgl_create_datac_size(long nx, long ny, long nz){ return new mglDataC(nx,ny,nz); } +HADT MGL_EXPORT mgl_create_datac_file(const char *fname) { return new mglDataC(fname); } +void MGL_EXPORT mgl_delete_datac(HADT d) { if(d) delete d; } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_datac_() +{ return uintptr_t(new mglDataC()); } +uintptr_t MGL_EXPORT mgl_create_datac_size_(int *nx, int *ny, int *nz) +{ return uintptr_t(new mglDataC(*nx,*ny,*nz)); } +uintptr_t MGL_EXPORT mgl_create_datac_file_(const char *fname,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + uintptr_t r = uintptr_t(new mglDataC(s)); delete []s; return r; } +void MGL_EXPORT mgl_delete_datac_(uintptr_t *d) +{ if(_DC_) delete _DC_; } +//----------------------------------------------------------------------------- +void mglFromStr(HADT d,char *buf,long NX,long NY,long NZ) // TODO: add multithreading read +{ + if(NX<1 || NY <1 || NZ<1) return; + mgl_datac_create(d, NX,NY,NZ); + long nb = strlen(buf); + register long i=0, j=0; + setlocale(LC_NUMERIC, "C"); + while(j0 || buf[j+1]!='#') // this is columns id + while(!isn(buf[j]) && j='a' && buf[j]<='z') + d->id.push_back(buf[j]); + j++; + } + } + while(buf[j]<=' ' && j=' ' && buf[j]!=';' && ja[i] = dual(re,im); + i++; if(i>=NX*NY*NZ) break; + } + setlocale(LC_NUMERIC, ""); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set(HADT d, HCDT a) +{ + if(!a) return; + const mglDataC *dd = dynamic_cast(a); // faster for mglData + mgl_datac_create(d, a->GetNx(), a->GetNy(), a->GetNz()); + if(dd) // this one should be much faster + memcpy(d->a, dd->a, d->nx*d->ny*d->nz*sizeof(dual)); + else // very inefficient!!! + { + register long i,j,k; + for(k=0;knz;k++) for(j=0;jny;j++) for(i=0;inx;i++) + d->a[i+d->nx*(j+d->ny*k)] = a->v(i,j,k); + } +} +void MGL_EXPORT mgl_datac_set_(uintptr_t *d, uintptr_t *a) { mgl_datac_set(_DC_,_DA_(a)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_values(HADT d, const char *v,long NX,long NY,long NZ) +{ + if(NX<1 || NY <1 || NZ<1) return; + register long n=strlen(v)+1; + char *buf = new char[n]; + memcpy(buf,v,n); + mglFromStr(d,buf,NX,NY,NZ); + delete []buf; +} +void MGL_EXPORT mgl_datac_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l) +{ char *s=new char[l+1]; memcpy(s,val,l); s[l]=0; + mgl_datac_set_values(_DC_,s,*nx,*ny,*nz); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_vector(HADT d, gsl_vector *v) +{ +#if MGL_HAVE_GSL + if(!v || v->size<1) return; + mgl_datac_create(d, v->size,1,1); + for(long i=0;inx;i++) d->a[i] = v->data[i*v->stride]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_matrix(HADT d, gsl_matrix *m) +{ +#if MGL_HAVE_GSL + if(!m || m->size1<1 || m->size2<1) return; + mgl_datac_create(d, m->size1,m->size2,1); + register long i,j; + for(j=0;jny;j++) for(i=0;inx;i++) + d->a[i+j*d->nx] = m->data[i * m->tda + j]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_float(HADT d, const float *A,long NX,long NY,long NZ) +{ + if(NX<=0 || NY<=0 || NZ<=0) return; + mgl_datac_create(d, NX,NY,NZ); if(!A) return; +#pragma omp parallel for + for(long i=0;ia[i] = A[i]; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_double(HADT d, const double *A,long NX,long NY,long NZ) +{ + if(NX<=0 || NY<=0 || NZ<=0) return; + mgl_datac_create(d, NX,NY,NZ); if(!A) return; +#pragma omp parallel for + for(long i=0;ia[i] = A[i]; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_complex(HADT d, const dual *A,long NX,long NY,long NZ) +{ + if(NX<=0 || NY<=0 || NZ<=0) return; + mgl_datac_create(d, NX,NY,NZ); if(!A) return; + memcpy(d->a,A,NX*NY*NZ*sizeof(float)); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_float_(uintptr_t *d, const float *A,int *NX,int *NY,int *NZ) +{ mgl_datac_set_float(_DC_,A,*NX,*NY,*NZ); } +void MGL_EXPORT mgl_datac_set_double_(uintptr_t *d, const double *A,int *NX,int *NY,int *NZ) +{ mgl_datac_set_double(_DC_,A,*NX,*NY,*NZ); } +void MGL_EXPORT mgl_datac_set_complex_(uintptr_t *d, const dual *A,int *NX,int *NY,int *NZ) +{ mgl_datac_set_complex(_DC_,A,*NX,*NY,*NZ); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_rearrange(HADT d, long mx,long my,long mz) +{ + if(mx<1) return; // wrong mx + if(my<1) { my = d->nx*d->ny*d->nz/mx; mz = 1; } + else if(mz<1) mz = (d->nx*d->ny*d->nz)/(mx*my); + long m = mx*my*mz; + if(m==0 || m>d->nx*d->ny*d->nz) return; // too high desired dimensions + d->nx = mx; d->ny = my; d->nz = mz; d->NewId(); +} +void MGL_EXPORT mgl_datac_rearrange_(uintptr_t *d, int *mx, int *my, int *mz) +{ mgl_datac_rearrange(_DC_,*mx,*my,*mz); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_id(HADT d, const char *ids) { d->id = ids; } +void MGL_EXPORT mgl_datac_set_id_(uintptr_t *d, const char *eq,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_datac_set_id(_DC_, s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_save(HCDT d, const char *fname,long ns) +{ + const mglDataC *dd = dynamic_cast(d); + if(!dd) { mgl_data_save(d,fname,ns); return; } + FILE *fp = fopen(fname,"w"); + if(!fp) return; + register long i,j,k; + long nx=dd->nx, ny=dd->ny, nz=dd->nz; + setlocale(LC_NUMERIC, "C"); + if(ns<0 || (ns>=nz && nz>1)) for(k=0;ka[j+nx*(i+ny*k)]), imag(dd->a[j+nx*(i+ny*k)])); + fprintf(fp,"%g+i%g\n", real(dd->a[nx-1+nx*(i+ny*k)]), imag(dd->a[nx-1+nx*(i+ny*k)])); + } + fprintf(fp,"\n"); + } + else + { // save selected slice + if(nz>1) for(i=0;ia[j+nx*(i+ny*ns)]), imag(dd->a[j+nx*(i+ny*ns)])); + fprintf(fp,"%g+i%g\n", real(dd->a[nx-1+nx*(i+ny*ns)]), imag(dd->a[nx-1+nx*(i+ny*ns)])); + } + else if(nsa[j+nx*ns]), imag(dd->a[j+nx*ns])); + } + setlocale(LC_NUMERIC, ""); + fclose(fp); +} +void MGL_EXPORT mgl_datac_save_(uintptr_t *d, const char *fname,int *ns,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + mgl_datac_save(_DC_,s,*ns); delete []s; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read(HADT d, const char *fname) +{ + long l=1,m=1,k=1; + long nb,i; + gzFile fp = gzopen(fname,"r"); + if(!fp) + { + if(!d->a) mgl_datac_create(d, 1,1,1); + return false; + } + char *buf = mgl_read_gz(fp); + nb = strlen(buf); gzclose(fp); + + bool first=false; // space is not allowed delimiter for file with complex numbers + register char ch; + for(i=nb-1;i>=0;i--) if(buf[i]>' ') break; + buf[i+1]=0; nb = i; // remove tailing spaces + for(i=0;i' ' && !first) first=true; + if(first && (ch=='\t' || ch==';') && buf[i+1]!='\t') k++; // ',' is not valid delimiter for complex arrays + } + first = false; + for(i=0;inx = mx>0 ? mx:1; d->ny = my>0 ? my:1; d->nz = mz>0 ? mz:1; + if(d->a && !d->link) delete [](d->a); + d->a = new dual[d->nx*d->ny*d->nz]; + d->id.clear(); d->link=false; + memset(d->a,0,d->nx*d->ny*d->nz*sizeof(dual)); +} +void MGL_EXPORT mgl_datac_create_(uintptr_t *d, int *nx,int *ny,int *nz) +{ mgl_datac_create(_DC_,*nx,*ny,*nz); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_link(HADT d, dual *A, long mx,long my,long mz) +{ + if(!A) return; + if(!d->link && d->a) delete [](d->a); + d->nx = mx>0 ? mx:1; d->ny = my>0 ? my:1; d->nz = mz>0 ? mz:1; + d->link=true; d->a=A; d->NewId(); +} +void MGL_EXPORT mgl_datac_link_(uintptr_t *d, dual *A, int *nx,int *ny,int *nz) +{ mgl_datac_link(_DC_,A,*nx,*ny,*nz); } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_dim(HADT d, const char *fname,long mx,long my,long mz) +{ + if(mx<=0 || my<=0 || mz<=0) return false; + gzFile fp = gzopen(fname,"r"); + if(!fp) return false; + char *buf = mgl_read_gz(fp); + gzclose(fp); + mglFromStr(d,buf,mx,my,mz); + free(buf); return true; +} +int MGL_EXPORT mgl_datac_read_dim_(uintptr_t *d, const char *fname,int *mx,int *my,int *mz,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_datac_read_dim(_DC_,s,*mx,*my,*mz); delete []s; return r; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_mat(HADT d, const char *fname, long dim) +{ + if(dim<=0 || dim>3) return false; + gzFile fp = gzopen(fname,"r"); + if(!fp) return false; + long nx=1, ny=1, nz=1; + char *buf = mgl_read_gz(fp); + long nb = strlen(buf); gzclose(fp); + + register long j=0,i,l; + while(j' ') j++; + } + else if(dim==2) + { + sscanf(buf+j,"%ld%ld",&nx,&ny); + while(buf[j]!='\n' && j' ' && !first) first=true; + if(first && (ch=='\t' || ch==';') && b[i+1]!='\t') nx++; + } + } + } + else if(dim==3) + { + sscanf(buf+j,"%ld%ld%ld",&nx,&ny,&nz); + while(buf[j]!='\n' && jp[0],ny=t->p[1]; + dual *b=t->a, x1=t->b[0], dx=t->b[1]; + char dir = t->s[0]; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + if(dir=='x') b[i0] = x1+dx*mreal(i0%nx); + else if(dir=='y') b[i0] = x1+dx*mreal((i0/nx)%ny); + else if(dir=='z') b[i0] = x1+dx*mreal(i0/(nx*ny)); + } + return 0; +} +void MGL_EXPORT mgl_datac_fill(HADT d, dual x1,dual x2,char dir) +{ + if(mgl_isnan(x2)) x2=x1; + if(dir<'x' || dir>'z') dir='x'; + long par[2]={d->nx,d->ny}; + dual b[2]={x1,x2-x1}; + if(dir=='x') b[1] *= d->nx>1 ? 1./(d->nx-1):0; + if(dir=='y') b[1] *= d->ny>1 ? 1./(d->ny-1):0; + if(dir=='z') b[1] *= d->nz>1 ? 1./(d->nz-1):0; + mglStartThreadC(mgl_cfill_x,0,d->nx*d->ny*d->nz,d->a,b,0,par,0,0,0,&dir); +} +void MGL_EXPORT mgl_datac_fill_(uintptr_t *d, dual *x1,dual *x2,const char *dir,int) +{ mgl_datac_fill(_DC_,*x1,*x2,*dir); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_squeeze(HADT d, long rx,long ry,long rz,long smooth) +{ + long kx,ky,kz, nx=d->nx, ny=d->ny, nz=d->nz; + dual *b; + + // simple checking + if(rx>=nx) rx=nx-1; if(rx<1) rx=1; + if(ry>=ny) ry=ny-1; if(ry<1) ry=1; + if(rz>=nz) rz=nz-1; if(rz<1) rz=1; + // new sizes + kx = 1+(nx-1)/rx; ky = 1+(ny-1)/ry; kz = 1+(nz-1)/rz; + b = new dual[kx*ky*kz]; + if(!smooth) +#pragma omp parallel for collapse(3) + for(long k=0;ka[i*rx+nx*(j*ry+ny*rz*k)]; + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i1+nx*(j1+ny*k1)]; + b[i+kx*(j+ky*k)] = s/mreal(dx*dy*dz); + } + if(!d->link) delete [](d->a); + d->a=b; d->nx = kx; d->ny = ky; d->nz = kz; d->NewId(); d->link=false; +} +void MGL_EXPORT mgl_datac_squeeze_(uintptr_t *d, int *rx,int *ry,int *rz,int *smooth) +{ mgl_datac_squeeze(_DC_,*rx,*ry,*rz,*smooth); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_extend(HADT d, long n1, long n2) +{ + long nx=d->nx, ny=d->ny, nz=d->nz; + if(nz>2 || n1==0) return; + long mx, my, mz; + dual *b=0; + if(n1>0) // extend to higher dimension(s) + { + n2 = n2>0 ? n2:1; + mx = nx; my = ny>1?ny:n1; mz = ny>1 ? n1 : n2; + b = new dual[mx*my*mz]; + if(ny>1) +#pragma omp parallel for + for(long i=0;ia, nx*ny*sizeof(dual)); + else +#pragma omp parallel for + for(long i=0;ia, nx*sizeof(dual)); + } + else + { + mx = -n1; my = n2<0 ? -n2 : nx; mz = n2<0 ? nx : ny; + if(n2>0 && ny==1) mz = n2; + b = new dual[mx*my*mz]; + dual v; + if(n2<0) +#pragma omp parallel for collapse(2) + for(long j=0;ja[j]; + else +#pragma omp parallel for collapse(2) + for(long j=0;ja[j]; + if(n2>0 && ny==1) +#pragma omp parallel for + for(long i=0;ia, mx*my*sizeof(dual)); + } + if(!d->link) delete [](d->a); + d->a=b; d->nx=mx; d->ny=my; d->nz=mz; + d->NewId(); d->link=false; +} +void MGL_EXPORT mgl_datac_extend_(uintptr_t *d, int *n1, int *n2) +{ mgl_datac_extend(_DC_,*n1,*n2); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_transpose(HADT d, const char *dim) +{ + long nx=d->nx, ny=d->ny, nz=d->nz, n; + dual *b=new dual[nx*ny*nz], *a=d->a; + if(!strcmp(dim,"xyz")) memcpy(b,a,nx*ny*nz*sizeof(dual)); + else if(!strcmp(dim,"xzy") || !strcmp(dim,"zy")) + { +#pragma omp parallel for collapse(3) + for(long j=0;jnx; d->nx=nx; d->ny=ny; d->nz=nz; + if(nx!=n) d->NewId(); +} +void MGL_EXPORT mgl_datac_transpose_(uintptr_t *d, const char *dim,int l) +{ char *s=new char[l+1]; memcpy(s,dim,l); s[l]=0; + mgl_datac_transpose(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cmodify(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + const mglFormulaC *f = (const mglFormulaC *)(t->v); + long nx=t->p[0],ny=t->p[1],nz=t->p[2]; + dual *b=t->a; + mreal dx,dy,dz; + const dual *v=t->b, *w=t->c; + dx=nx>1?1/(nx-1.):0; dy=ny>1?1/(ny-1.):0; dz=nz>1?1/(nz-1.):0; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(i*dx, j*dy, k*dz, b[i0], v?v[i0]:dual(0,0), w?w[i0]:dual(0,0)); + } + return 0; +} +void MGL_EXPORT mgl_datac_modify(HADT d, const char *eq,long dim) +{ + long nx=d->nx, ny=d->ny, nz=d->nz, par[3]={nx,ny,nz}; + mglFormulaC f(eq); + if(dim<0) dim=0; + if(nz>1) // 3D array + { + par[2] -= dim; if(par[2]<0) par[2]=0; + mglStartThreadC(mgl_cmodify,0,nx*ny*par[2],d->a+nx*ny*dim,0,0,par,&f); + } + else // 2D or 1D array + { + par[1] -= dim; if(par[1]<0) par[1]=0; + mglStartThreadC(mgl_cmodify,0,nx*par[1],d->a+nx*dim,0,0,par,&f); + } +} +void MGL_EXPORT mgl_datac_modify_(uintptr_t *d, const char *eq,int *dim,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_datac_modify(_DC_,s,*dim); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cmodify_gen(void *par) +{ + mglThreadV *t=(mglThreadV *)par; + const mglFormulaC *f = (const mglFormulaC *)(t->v); + long nx=t->p[0],ny=t->p[1],nz=t->p[2]; + dual *b=t->aa; + mreal dx,dy,dz; + HCDT v=(HCDT)t->b, w=(HCDT)t->c; + dx=nx>1?1/(nx-1.):0; dy=ny>1?1/(ny-1.):0; dz=nz>1?1/(nz-1.):0; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(i*dx, j*dy, k*dz, b[i0], v?v->vthr(i0):0, w?w->vthr(i0):0); + } + return 0; +} +void MGL_EXPORT mgl_datac_modify_vw(HADT d, const char *eq,HCDT vdat,HCDT wdat) +{ + const mglDataC *v = dynamic_cast(vdat); + const mglDataC *w = dynamic_cast(wdat); + long nn = d->nx*d->ny*d->nz, par[3]={d->nx,d->ny,d->nz}; + if(vdat && vdat->GetNN()!=nn) return; + if(wdat && wdat->GetNN()!=nn) return; + mglFormulaC f(eq); + if(v && w) mglStartThreadC(mgl_cmodify,0,nn,d->a,v->a,w->a,par,&f); + else if(vdat && wdat) mglStartThreadV(mgl_cmodify_gen,nn,d->a,vdat,wdat,par,&f); + else if(v) mglStartThreadC(mgl_cmodify,0,nn,d->a,v->a,0,par,&f); + else if(vdat) mglStartThreadV(mgl_cmodify_gen,nn,d->a,vdat,0,par,&f); + else mglStartThreadC(mgl_cmodify,0,nn,d->a,0,0,par,&f); +} +void MGL_EXPORT mgl_datac_modify_vw_(uintptr_t *d, const char *eq, uintptr_t *v, uintptr_t *w,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_datac_modify_vw(_DC_,s,_DA_(v),_DA_(w)); delete []s; } +//----------------------------------------------------------------------------- +bool MGL_NO_EXPORT mgl_add_file(long &kx,long &ky, long &kz, dual *&b, mglDataC *d,bool as_slice) +{ + if(as_slice && d->nz==1) + { + if(kx==d->nx && d->ny==1) + { + b = (dual *)realloc(b,kx*(ky+1)*sizeof(dual)); + memcpy(b+kx*ky,d->a,kx*sizeof(dual)); ky++; + } + else if(kx==d->nx && ky==d->ny) + { + b = (dual *)realloc(b,kx*ky*(kz+1)*sizeof(dual)); + memcpy(b+kx*ky*kz,d->a,kx*ky*sizeof(dual)); kz++; + } + else return false; + } + else + { + if(d->ny*d->nz==1 && ky*kz==1) + { + b = (dual *)realloc(b,(kx+d->nx)*sizeof(dual)); + memcpy(b+kx,d->a,d->nx*sizeof(dual)); kx+=d->nx; + } + else if(kx==d->nx && kz==1 && d->nz==1) + { + b = (dual *)realloc(b,kx*(ky+d->ny)*sizeof(dual)); + memcpy(b+kx*ky,d->a,kx*d->ny*sizeof(dual)); ky+=d->ny; + } + else if(kx==d->nx && ky==d->ny) + { + b = (dual *)realloc(b,kx*kx*(kz+d->nz)*sizeof(dual)); + memcpy(b+kx*ky*kz,d->a,kx*ky*d->nz*sizeof(dual)); kz+=d->nz; + } + else return false; + } + return true; +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_range(HADT dat, const char *templ, double from, double to, double step, int as_slice) +{ + mglDataC d; + double t = from; + dual *b; + long kx,ky,kz,n=strlen(templ)+20; + char *fname = new char[n]; + + //read first file + do{ snprintf(fname,n,templ,t); t+= step; } while(!mgl_datac_read(&d,fname) && t<=to); + + if(t>to) { delete []fname; return false; } + kx = d.nx; ky = d.ny; kz = d.nz; + b = (dual *)malloc(kx*ky*kz*sizeof(dual)); + memcpy(b,d.a,kx*ky*kz*sizeof(dual)); + + // read other files + for(;t<=to;t+=step) + { + snprintf(fname,n,templ,t); + if(mgl_datac_read(&d,fname)) + if(!mgl_add_file(kx,ky,kz,b,&d,as_slice)) + { delete []fname; free(b); return false; } + } + dat->Set(b,kx,ky,kz); + delete []fname; free(b); + return true; +} +int MGL_EXPORT mgl_datac_read_range_(uintptr_t *d, const char *fname, mreal *from, mreal *to, mreal *step, int *as_slice,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_datac_read_range(_DC_,s,*from,*to,*step,*as_slice); delete []s; return r; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_all(HADT dat, const char *templ, int as_slice) +{ +#ifndef WIN32 + mglDataC d; + glob_t res; + size_t i; + dual *b; + long kx,ky,kz; + glob (templ, GLOB_TILDE, NULL, &res); + + //read first file + for(i=0;i=res.gl_pathc) { globfree (&res); return false; } + kx = d.nx; ky = d.ny; kz = d.nz; + b = (dual *)malloc(kx*ky*kz*sizeof(dual)); + memcpy(b,d.a,kx*ky*kz*sizeof(dual)); + + for(;iSet(b,kx,ky,kz); + + globfree (&res); free(b); + return true; +#else + return false; +#endif +} +int MGL_EXPORT mgl_datac_read_all_(uintptr_t *d, const char *fname, int *as_slice,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_datac_read_all(_DC_,s,*as_slice); delete []s; return r; } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_datac_real(HCDT d) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mglData *r=new mglData(nx,ny,nz); + const mglDataC *dd = dynamic_cast(d); + if(dd) +#pragma omp parallel for + for(long i=0;ia[i] = real(dd->a[i]); + else r->Set(d); + return r; +} +uintptr_t MGL_EXPORT mgl_datac_real_(uintptr_t *d) +{ return uintptr_t(mgl_datac_real(_DC_)); } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_datac_imag(HCDT d) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mglData *r=new mglData(nx,ny,nz); + const mglDataC *dd = dynamic_cast(d); + if(dd) +#pragma omp parallel for + for(long i=0;ia[i] = imag(dd->a[i]); + return r; +} +uintptr_t MGL_EXPORT mgl_datac_imag_(uintptr_t *d) +{ return uintptr_t(mgl_datac_imag(_DC_)); } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_datac_abs(HCDT d) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mglData *r=new mglData(nx,ny,nz); + const mglDataC *dd = dynamic_cast(d); + if(dd) +#pragma omp parallel for + for(long i=0;ia[i] = abs(dd->a[i]); + else +#pragma omp parallel for + for(long i=0;ia[i] = fabs(d->vthr(i)); + return r; +} +uintptr_t MGL_EXPORT mgl_datac_abs_(uintptr_t *d) +{ return uintptr_t(mgl_datac_abs(_DC_)); } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_datac_arg(HCDT d) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mglData *r=new mglData(nx,ny,nz); + const mglDataC *dd = dynamic_cast(d); + if(dd) +#pragma omp parallel for + for(long i=0;ia[i] = arg(dd->a[i]); + return r; +} +uintptr_t MGL_EXPORT mgl_datac_arg_(uintptr_t *d) +{ return uintptr_t(mgl_datac_arg(_DC_)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_ri(HADT d, HCDT re, HCDT im) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + d->Create(nx,ny,nz); +#pragma omp parallel for + for(long i=0;ia[i] = dual(re->vthr(i),im->vthr(i)); +} +void MGL_EXPORT mgl_datac_set_ri_(uintptr_t *d, uintptr_t *re, uintptr_t *im) +{ mgl_datac_set_ri(_DC_,_DA_(re),_DA_(im)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_set_ap(HADT d, HCDT a, HCDT p) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + d->Create(nx,ny,nz); +#pragma omp parallel for + for(long i=0;ivthr(i), pp=p->vthr(i); + d->a[i] = dual(aa*cos(pp), aa*sin(pp)); + } +} +void MGL_EXPORT mgl_datac_set_ap_(uintptr_t *d, uintptr_t *a, uintptr_t *p) +{ mgl_datac_set_ap(_DC_,_DA_(a),_DA_(p)); } +//----------------------------------------------------------------------------- +#if MGL_HAVE_HDF5 +void MGL_EXPORT mgl_datac_save_hdf(HCDT dat,const char *fname,const char *data,int rewrite) +{ + const mglDataC *d = dynamic_cast(dat); // NOTE: only for mglDataC + if(!d) { mgl_data_save_hdf(dat,fname,data,rewrite); return; } + hid_t hf,hd,hs; + hsize_t dims[4]; + long rank = 3, res; + H5Eset_auto(0,0); + res=H5Fis_hdf5(fname); + if(res>0 && !rewrite) hf = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); + else hf = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(hf<0) return; + if(d->nz==1 && d->ny == 1) { rank=2; dims[0]=d->nx; dims[1]=2; } + else if(d->nz==1) { rank=3; dims[0]=d->ny; dims[1]=d->nx; dims[2]=2; } + else { rank=4; dims[0]=d->nz; dims[1]=d->ny; dims[2]=d->nx; dims[3]=2; } + hs = H5Screate_simple(rank, dims, 0); +#if MGL_USE_DOUBLE + hid_t mem_type_id = H5T_NATIVE_DOUBLE; +#else + hid_t mem_type_id = H5T_NATIVE_FLOAT; +#endif + hd = H5Dcreate(hf, data, mem_type_id, hs, H5P_DEFAULT); + H5Dwrite(hd, mem_type_id, hs, hs, H5P_DEFAULT, d->a); + H5Dclose(hd); H5Sclose(hs); H5Fclose(hf); +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_hdf(HADT d,const char *fname,const char *data) +{ + hid_t hf,hd,hs; + hsize_t dims[4]; + long rank, res = H5Fis_hdf5(fname); + if(res<=0) { return false; } + hf = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + if(hf<0) return false; + hd = H5Dopen(hf,data); + if(hd<0) return false; + hs = H5Dget_space(hd); + rank = H5Sget_simple_extent_ndims(hs); + if(rank>0 && rank<=3) + { + H5Sget_simple_extent_dims(hs,dims,0); + if(rank==2) { dims[2]=dims[0]; dims[0]=dims[1]=1; } + else if(rank==3) { dims[2]=dims[1]; dims[1]=dims[0]; dims[0]=1; } +// else if(rank>3) continue; + mgl_datac_create(d,dims[2],dims[1],dims[0]); +#if MGL_USE_DOUBLE + H5Dread(hd, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, d->a); +#else + H5Dread(hd, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, d->a); +#endif + } + H5Sclose(hs); H5Dclose(hd); H5Fclose(hf); return true; +} +//----------------------------------------------------------------------------- +#else +void MGL_EXPORT mgl_datac_save_hdf(HCDT ,const char *,const char *,int ) +{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; } +int MGL_EXPORT mgl_datac_read_hdf(HADT ,const char *,const char *) +{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return false;} +#endif +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datac_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *t=new char[n+1]; memcpy(t,data,n); t[n]=0; + int r = mgl_datac_read_hdf(_DC_,s,t); delete []s; delete []t; return r; } +void MGL_EXPORT mgl_datac_save_hdf_(uintptr_t *d, const char *fname, const char *data, int *rewrite,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *t=new char[n+1]; memcpy(t,data,n); t[n]=0; + mgl_datac_save_hdf(_DC_,s,t,*rewrite); delete []s; delete []t; } +//----------------------------------------------------------------------------- diff --git a/src/cont.cpp b/src/cont.cpp new file mode 100644 index 0000000..31f0e92 --- /dev/null +++ b/src/cont.cpp @@ -0,0 +1,1656 @@ +/*************************************************************************** + * cont.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +// NOTE: Borland before 2007 (i.e. < 0x0600) use , after 0x0630 it use . +// I don't find information about 2009, 2010 versions (i.e. 0x0610 and 0x0620). +// May be condition below can be rewritten as (__CODEGEARC__ >= 0x0600) +#if !defined(__BORLANDC__) || (__CODEGEARC__ >= 0x0630) +#include +#else +#include +#endif + +#include "mgl2/surf.h" +#include "mgl2/cont.h" +#include "mgl2/data.h" +#include "mgl2/eval.h" +#include "mgl2/font.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// Text printing along a curve +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_string_curve(mglBase *gr,long f,long ,const long *ff,const long *nn,const wchar_t *text, const char *font, mreal size) +{ + if(f<0 || nn[f]==-1) return; // do nothing since there is no curve + if(!font) font=""; + int pos = strchr(font,'T') ? 1:-1, align; + char cc=mglGetStyle(font,0,&align); align = align&3; + mreal c=cc ? -cc : gr->GetClrC(ff[f]); + mreal h=gr->TextHeight(font,size)/2, tet, tt; + wchar_t L[2]=L"a"; + register long i,j,k,m; + + std::vector qa, qb; // curves above and below original + mglPoint p=gr->GetPntP(ff[f]), q=p, s=gr->GetPntP(ff[nn[f]]), l=!(s-q), t=l; + qa.push_back(q+l*h); qb.push_back(q-l*h); + for(i=nn[f];i>=0 && i!=f;i=nn[i]) // construct curves + { + if(gr->Stop) return; + p=q; q=s; l=t; + if(nn[i]>=0 && ff[nn[i]]>=0) { s=gr->GetPntP(ff[nn[i]]); t=!(s-q); } + tet = t.x*l.y-t.y*l.x; + tt = 1+fabs(t.x*l.x+t.y*l.y); + if(tet>0) + { qa.push_back(q+l*h); qa.push_back(q+t*h); qb.push_back(q-(l+t)*(h/tt)); } + else if(tet<0) + { qb.push_back(q-l*h); qb.push_back(q-t*h); qa.push_back(q+(l+t)*(h/tt)); } + else + { qa.push_back(q+l*h); qb.push_back(q-l*h); } + } + if(pos>0) qa=qb; + // adjust text direction + bool rev = align==2; + char *fnt = new char[strlen(font)+3]; strcpy(fnt,font); + if(qa[0].x>qa[1].x) + { + if(align==0){ strcat(fnt,":R"); align=2; } + else if(align==1) rev = true; + else { strcat(fnt,":L"); align=0; } + } + if(rev) reverse(qa.begin(),qa.end()); + long len = mgl_wcslen(text); + mreal *wdt=new mreal[len+1]; + for(j=0;jTextWidth(L,font,size); } + wdt[len]=0; + + // place glyphs points + mglPoint *pt=new mglPoint[len+1]; + pt[0] = qa[0]; m = qa.size(); + + mreal a,b,d,w,t1,t2; + for(i=j=0,tt=0;jStop) { delete []wdt; delete []pt; delete []fnt; return; } + w = align==1 ? wdt[j] : (wdt[j]+wdt[j+1])/2; p = pt[j]; + for(k=i+1;kw) break; + if(k>i+1 && ka*d should be here! + if(b*b>1e3*a*d) { t1 = d/(b+w); t2 = d/(b-w); } // keep precision + else { t1 = (b-w)/a; t2 = (b+w)/a; } + if(t1<0 || t1text_plot(gr->AddPnt(pt[j]+(pos*h)*l,c,s,-1,-1),L,font,size,0.05,c); + } + delete []wdt; delete []pt; delete []fnt; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textw_xyz(HMGL gr, HCDT x, HCDT y, HCDT z,const wchar_t *text, const char *font, const char *opt) +{ + long n=y->GetNx(); + if(mgl_check_dim1(gr,x,y,z,0,"Text")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("TextC",cgid++); + + long *nn = new long[n], *ff = new long[n]; + const mglData *mdx = dynamic_cast(x); + const mglData *mdy = dynamic_cast(y); + const mglData *mdz = dynamic_cast(z); + if(mdx && mdy && mdz) +#pragma omp parallel for + for(long i=0;iAddPnt(mglPoint(mdx->a[i],mdy->a[i],mdz->a[i]),-1); + else +#pragma omp parallel for + for(long i=0;iAddPnt(mglPoint(x->v(i),y->v(i),z->v(i)),-1); +#pragma omp parallel for + for(long i=1;iEndGroup(); + delete []ff; delete []nn; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textw_xy(HMGL gr, HCDT x, HCDT y, const wchar_t *text, const char *font, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_textw_xyz(gr,x,y,&z,text,font,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textw_y(HMGL gr, HCDT y, const wchar_t *text, const char *font, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()), z(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_textw_xyz(gr,&x,y,&z,text,font,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_xyz(HMGL gr, HCDT x, HCDT y, HCDT z,const char *text, const char *font, const char *opt) +{ + MGL_TO_WCS(text,mgl_textw_xyz(gr,x,y,z, wcs, font, opt)); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_xy(HMGL gr, HCDT x, HCDT y, const char *text, const char *font, const char *opt) +{ + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_text_xyz(gr,x,y,&z,text,font,opt); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_y(HMGL gr, HCDT y, const char *text, const char *font, const char *opt) +{ + mglData x(y->GetNx()), z(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_text_xyz(gr,&x,y,&z,text,font,opt); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z,const char *text,const char *font, const char *opt,int l,int n,int lo) +{ char *s=new char[l+1]; memcpy(s,text,l); s[l]=0; +char *f=new char[n+1]; memcpy(f,font,n); f[n]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_text_xyz(_GR_, _DA_(x),_DA_(y), _DA_(z), s, f, o); +delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *text, const char *font, const char *opt, int l,int n,int lo) +{ char *s=new char[l+1]; memcpy(s,text,l); s[l]=0; +char *f=new char[n+1]; memcpy(f,font,n); f[n]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_text_xy(_GR_, _DA_(x),_DA_(y),s,f,o); +delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_text_y_(uintptr_t *gr, uintptr_t *y, const char *text, const char *font, const char *opt, int l,int n,int lo) +{ char *s=new char[l+1]; memcpy(s,text,l); s[l]=0; +char *f=new char[n+1]; memcpy(f,font,n); f[n]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_text_y(_GR_, _DA_(y),s,f,o); delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +// +// Cont series +// +//----------------------------------------------------------------------------- +struct mglSegment +{ + long next,prev; + mglPoint p1,p2; + mglSegment(mglPoint q1,mglPoint q2) {p1=q1;p2=q2;next=prev=-1;} +}; +// function for connecting arbitrary line segments +/*void MGL_NO_EXPORT mgl_connect(HMGL gr, mreal val, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, int text,long ak) +{ + long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m) + { gr->SetWarn(mglWarnDim,"ContGen"); return; } + std::vector ss,cc; + + register long i,j; + mreal d1,d2,d3,d4; + bool o1,o2,o3,o4; + mglPoint p1,p2,p3,p4,q1,q2,q3,q4; + for(i=0;iStop) return; + d1 = mgl_d(val,a->v(i,j,ak),a->v(i+1,j,ak)); o1 = d1>=0 && d1<1; + d2 = mgl_d(val,a->v(i,j,ak),a->v(i,j+1,ak)); o2 = d2>=0 && d2<1; + d3 = mgl_d(val,a->v(i+1,j+1,ak),a->v(i+1,j,ak)); o3 = d3>=0 && d3<1; + d4 = mgl_d(val,a->v(i+1,j+1,ak),a->v(i,j+1,ak)); o4 = d4>=0 && d4<1; + p1 = mglPoint(x->v(i,j), y->v(i,j),z->v(i,j)); + p2 = mglPoint(x->v(i+1,j), y->v(i+1,j),z->v(i+1,j)); + p3 = mglPoint(x->v(i,j+1), y->v(i,j+1),z->v(i,j+1)); + p4 = mglPoint(x->v(i+1,j+1), y->v(i+1,j+1),z->v(i+1,j+1)); + q1 = p1*(1-d1)+p2*d1; q2 = p1*(1-d2)+p3*d1; + q3 = p4*(1-d3)+p2*d3; q4 = p4*(1-d4)+p3*d4; + if(o1 && o2) { o1 = o2 = false; ss.push_back(mglSegment(q1,q2)); } + if(o1 && o3) { o1 = o3 = false; ss.push_back(mglSegment(q1,q3)); } + if(o1 && o4) { o1 = o4 = false; ss.push_back(mglSegment(q1,q4)); } + if(o2 && o3) { o2 = o3 = false; ss.push_back(mglSegment(q2,q3)); } + if(o2 && o4) { o2 = o4 = false; ss.push_back(mglSegment(q2,q4)); } + if(o3 && o4) { o3 = o4 = false; ss.push_back(mglSegment(q3,q4)); } + } + // connect it + if(ss.size()==0) return; + for(i=0;i &kk) +{ + long n=a->GetNx(), m=a->GetNy(); + mreal d, r, kx, ky; + register long i,j,k, pc=0; + kk.clear(); + // add intersection point of isoline and Y axis + const mglData *ma = dynamic_cast(a); + if(ma) + { + for(j=0;ja[i+n*(j+m*ak)],ma->a[i+1+n*(j+m*ak)]); + if(d>=0 && d<1) kk.push_back(mglPnt2(i+d,j)); + } + // add intersection point of isoline and X axis + for(j=0;ja[i+n*(j+m*ak)],ma->a[i+n*(j+1+m*ak)]); + if(d>=0 && d<1) kk.push_back(mglPnt2(i,j+d)); + } + } + else for(j=0;jv(i,j,ak); + d = (iv(i+1,j,ak)):-1; + if(d>=0 && d<1) kk.push_back(mglPnt2(i+d,j)); + d = (jv(i,j+1,ak)):-1; + if(d>=0 && d<1) kk.push_back(mglPnt2(i,j+d)); + } + + pc = kk.size(); + if(pc==0) return NULL; // deallocate arrays and finish if no point + // allocate arrays for curve (nn - next, ff - prev) + long *nn = new long[pc], *ff = new long[pc]; + // -1 is not parsed, -2 starting + for(i=0;i=0) + { + kx = kk[j].x; ky = kk[j].y; i = -1; + i11 = long(kx+1e-5); i12 = long(kx-1e-5); + j11 = long(ky+1e-5); j12 = long(ky-1e-5); + r=10; + for(k=0;k=0); + delete []ff; return nn; +} +//----------------------------------------------------------------------------- +// NOTE! All data MUST have the same size! Only first slice is used! +void MGL_EXPORT mgl_cont_gen(HMGL gr, mreal val, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, int text,long ak) +{ + long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m) + { gr->SetWarn(mglWarnDim,"ContGen"); return; } + + std::vector kk; + long *nn = mgl_cont_prep(val, a, ak, kk), *ff; + if(!nn) return; // nothing to do + register long i, pc=kk.size(); + register mreal xx, yy; + ff = new long[pc]; gr->Reserve(pc); + for(i=0;iAddPnt(mglPoint(mgl_data_linear(x,xx,yy,ak), mgl_data_linear(y,xx,yy,ak), mgl_data_linear(z,xx,yy,ak)), c); + } + + if(text && pc>1) + { + wchar_t wcs[64]; + mglprintf(wcs,64,L"%4.3g",val); + mglPoint t; + mreal del = 2*gr->TextWidth(wcs,"",-0.5); + // find width and height of drawing area + mreal ar=gr->GetRatio(), w=gr->FontFactor(), h; + if(delGetPntP(ff[k]); + i = long(t.x/del); t.x -= i*del; + j = long(t.y/del); t.y -= j*del; + if(i<0 || i>=m || j<0 || j>=n) continue; // never should be here! + xx = t.x*t.x+t.y*t.y; i += m*j; + if(rr[i]>xx) { rr[i]=xx; oo[i]=k; } + } + for(i=0;i=0) + mgl_string_curve(gr,oo[i],pc,ff,nn,wcs,"t:C",-0.5); + delete []oo; delete []rr; + } + for(i=0;i=0) gr->line_plot(ff[i], ff[nn[i]]); + delete []nn; delete []ff; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_gen(HMGL gr, double val, HCDT a, HCDT x, HCDT y, HCDT z, const char *sch) +{ + bool text=(mglchr(sch,'t')); + gr->SetPenPal(sch); + mgl_cont_gen(gr,val,a,x,y,z,gr->CDef,text,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Cont")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Cont",cgid++); + + bool text=(mglchr(sch,'t')); + bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z); + long s=gr->AddTexture(sch); + gr->SetPenPal(sch); + + mglData xx, yy; + if(x->GetNx()*x->GetNy()!=m*n || y->GetNx()*y->GetNy()!=m*n) // make + { + xx.Create(n, m); yy.Create(n, m); + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + if(mx && my) +#pragma omp parallel for collapse(2) + for(long i=0;ia[i]; yy.a[i+n*j] = my->a[j]; } + else +#pragma omp parallel for collapse(2) + for(long i=0;iv(i); yy.a[i+n*j] = y->v(j); } + x = &xx; y = &yy; + } + // x, y -- have the same size z +#pragma omp parallel + { + mglData zz(n, m); +#pragma omp for collapse(2) + for(long j=0;jGetNz();j++) for(long i=0;iGetNx();i++) + { + if(gr->Stop) continue; + mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; + if(z->GetNz()>1) + z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); + zz.Fill(z0,z0); + mgl_cont_gen(gr,v0,z,x,y,&zz,gr->GetC(s,v0),text,j); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt) +{ + register long n = z->GetNx(), m = z->GetNy(); + if(m<2 || n<2) { gr->SetWarn(mglWarnLow,"Cont"); return; } + gr->SaveState(opt); + mglData x(n, m), y(n, m); + x.Fill(gr->Min.x,gr->Max.x,'x'); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_cont_xy_val(gr,v,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont_xy_val(gr,&v,x,y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont_val(gr,&v,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_cont_xy_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(a), s, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_cont_val(_GR_, _DA_(v), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_cont_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_cont(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContF series +// +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_add_pnt(HMGL gr, mreal d, HCDT x, HCDT y, HCDT z, long i1, long j1, long i2, long j2, mreal c, bool edge) +{ + long res=-1; + if(edge || (d>0 && d<1)) + { + mglPoint p,u,v; + p = mglPoint(x->v(i1,j1)*(1-d)+x->v(i2,j2)*d, + y->v(i1,j1)*(1-d)+y->v(i2,j2)*d, + z->v(i1,j1)*(1-d)+z->v(i2,j2)*d); + u = mglPoint(x->dvx(i1,j1)*(1-d)+x->dvx(i2,j2)*d, + y->dvx(i1,j1)*(1-d)+y->dvx(i2,j2)*d, + z->dvx(i1,j1)*(1-d)+z->dvx(i2,j2)*d); + v = mglPoint(x->dvy(i1,j1)*(1-d)+x->dvy(i2,j2)*d, + y->dvy(i1,j1)*(1-d)+y->dvy(i2,j2)*d, + z->dvy(i1,j1)*(1-d)+z->dvy(i2,j2)*d); + res = gr->AddPnt(p,c,u^v); + } + return res; +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_add_range(HMGL gr, HCDT a, HCDT x, HCDT y, HCDT z, long i1, long j1, long di, long dj, mreal c, long &u1, long &u2, long ak, mreal v1, mreal v2) +{ + long i2=i1+di, j2=j1+dj; + + mreal f1 = a->v(i1,j1,ak), f2 = a->v(i2,j2,ak), d1, d2; + d1 = mgl_d(v1,f1,f2); + u1 = mgl_add_pnt(gr,d1,x,y,z,i1,j1,i2,j2,c,false); + d2 = mgl_d(v2,f1,f2); + u2 = mgl_add_pnt(gr,d2,x,y,z,i1,j1,i2,j2,c,false); + if(d1>d2) { j2=u1; u1=u2; u2=j2; } +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_add_edges(HMGL gr, HCDT a, HCDT x, HCDT y, HCDT z, long i1, long j1, long di, long dj, mreal c, long &u1, long &u2, long ak, mreal v1, mreal v2) +{ + long i2=i1+di, j2=j1+dj; + u1 = u2 = -1; + + mreal f1 = a->v(i1,j1,ak), f2 = a->v(i2,j2,ak); + if(f1<=v2 && f1>=v1) + u1 = mgl_add_pnt(gr,0,x,y,z,i1,j1,i2,j2,c,true); + if(f2<=v2 && f2>=v1) + u2 = mgl_add_pnt(gr,1,x,y,z,i1,j1,i2,j2,c,true); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_gen(HMGL gr, mreal v1, mreal v2, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, long ak) +{ + long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m) + { gr->SetWarn(mglWarnDim,"ContFGen"); return; } + + register long i,j; + gr->Reserve(n*m); + long *kk = new long[4*n], l1,l2, r1,r2, t1,t2, u1,u2, b1,b2, d1,d2, p[8],num; + memset(kk,-1,2*n*sizeof(long)); + for(i=0;iStop) { delete []kk; return; } + mgl_add_range(gr,a,x,y,z, i,0,1,0, c,u1,u2, ak,v1,v2); + kk[4*i]=u1; kk[4*i+1]=u2; + mgl_add_edges(gr,a,x,y,z, i,0,1,0, c,d1,d2, ak,v1,v2); + kk[4*i+2]=d1; kk[4*i+3]=d2; + } + for(j=1;jStop) { delete []kk; return; } + l1 = r1; l2 = r2; num=0; + t1 = kk[4*i]; t2 = kk[4*i+1]; + b1 = kk[4*i+2]; b2 = kk[4*i+3]; + // right edge + mgl_add_range(gr,a,x,y,z, i+1,j-1,0,1, c,r1,r2, ak,v1,v2); + // top edge + mgl_add_range(gr,a,x,y,z, i,j,1,0, c,u1,u2, ak,v1,v2); + kk[4*i]=u1; kk[4*i+1]=u2; + mgl_add_edges(gr,a,x,y,z, i,j,1,0, c,d1,d2, ak,v1,v2); + kk[4*i+2]=d1; kk[4*i+3]=d2; + // collect points + if(b1>=0) p[num++] = b1; if(t1>=0) p[num++] = t1; + if(t2>=0) p[num++] = t2; if(b2>=0) p[num++] = b2; + if(r1>=0) p[num++] = r1; if(r2>=0) p[num++] = r2; + if(d2>=0) p[num++] = d2; if(u2>=0) p[num++] = u2; + if(u1>=0) p[num++] = u1; if(d1>=0) p[num++] = d1; + if(l2>=0) p[num++] = l2; if(l1>=0) p[num++] = l1; + // draw it + if(num<3) continue; + if(num==4) gr->quad_plot(p[0],p[1],p[3],p[2]); + else if(num==3) gr->trig_plot(p[0],p[1],p[2]); + else if(num==5) + { + gr->quad_plot(p[0],p[1],p[3],p[2]); + gr->trig_plot(p[0],p[3],p[4]); + } + else if(num==6) + { + gr->quad_plot(p[0],p[1],p[3],p[2]); + gr->quad_plot(p[0],p[3],p[5],p[4]); + } + } + } + delete []kk; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_gen(HMGL gr, double v1, double v2, HCDT a, HCDT x, HCDT y, HCDT z, const char *c) +{ + gr->SetPenPal(c); + mgl_contf_gen(gr,v1,v2,a,x,y,z,gr->CDef,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"ContF")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContF",cgid++); + long s=gr->AddTexture(sch); + + bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z); + mglData xx, yy; + if(x->GetNx()*x->GetNy()!=m*n || y->GetNx()*y->GetNy()!=m*n) // make + { + xx.Create(n, m); yy.Create(n, m); + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + if(mx && my) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; yy.a[i+n*j] = my->a[j]; } + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); yy.a[i+n*j] = y->v(j); } + x = &xx; y = &yy; + } + // x, y -- have the same size z +#pragma omp parallel + { + mglData zz(n, m); +#pragma omp for collapse(2) + for(long j=0;jGetNz();j++) for(long i=0;iGetNx()-1;i++) + { + if(gr->Stop) continue; + mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; + if(z->GetNz()>1) + z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); + zz.Fill(z0,z0); + mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,gr->GetC(s,v0),j); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt) +{ + register long n = z->GetNx(), m = z->GetNy(); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"Cont"); return; } + gr->SaveState(opt); + mglData x(n, m), y(n, m); + x.Fill(gr->Min.x,gr->Max.x,'x'); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_contf_xy_val(gr,v,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num+2); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf_xy_val(gr,&v,x,y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num+2); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf_val(gr,&v,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_xy_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(a), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_val(_GR_, _DA_(v), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContD series +// +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_get_ncol(const char *sch, char *res) +{ + register long i,j=0; + if(sch) for(i=0;sch[i]&&sch[i]!=':';i++) if(strchr(MGL_COLORS,sch[i])) + { if(res) res[j]=sch[i]; j++; } + return j?j:strlen(MGL_DEF_PAL); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long i,j=0,n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"ContD")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContD",cgid++); + + bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z); + if(sch) for(i=0;sch[i];i++) if(strchr(MGL_COLORS,sch[i])) j++; + if(j==0) sch = MGL_DEF_PAL; + long s = gr->AddTexture(sch,1); + int nc = gr->GetNumPal(s*256); + mglData xx, yy; + if(x->GetNx()*x->GetNy()!=m*n || y->GetNx()*y->GetNy()!=m*n) // make + { + xx.Create(n, m); yy.Create(n, m); + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + if(mx && my) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; yy.a[i+n*j] = my->a[j]; } + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); yy.a[i+n*j] = y->v(j); } + x = &xx; y = &yy; + } + // x, y -- have the same size z + mreal dc = nc>1 ? 1/(MGL_FEPSILON*(nc-1)) : 0; +#pragma omp parallel + { + mglData zz(n, m); +#pragma omp for collapse(2) + for(long j=0;jGetNz();j++) for(long i=0;iGetNx()-1;i++) + { + if(gr->Stop) continue; + mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; + if(z->GetNz()>1) + z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); + zz.Fill(z0,z0); + mgl_contf_gen(gr,v0,v->v(i+1),z,x,y,&zz,s+i*dc,j); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt) +{ + register long n = z->GetNx(), m = z->GetNy(); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContD"); return; } + gr->SaveState(opt); + mglData x(n, m), y(n, m); + x.Fill(gr->Min.x,gr->Max.x,'x'); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_contd_xy_val(gr,v,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData v(mgl_get_ncol(sch,0)+1); + v.Fill(gr->Min.c, gr->Max.c); + mgl_contd_xy_val(gr,&v,x,y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData v(mgl_get_ncol(sch,0)+1); + v.Fill(gr->Min.c, gr->Max.c); + mgl_contd_val(gr,&v,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contd_xy_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(a), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contd_val(_GR_, _DA_(v), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contd_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contd_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contd(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContV series +// +//----------------------------------------------------------------------------- +// NOTE! All data MUST have the same size! Only first slice is used! +void MGL_EXPORT mgl_contv_gen(HMGL gr, mreal val, mreal dval, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, long ak) +{ + long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m || z->GetNx()*z->GetNy()!=n*m) + { gr->SetWarn(mglWarnDim,"ContGen"); return; } + + std::vector kk; + long *nn = mgl_cont_prep(val, a, ak, kk), *ff; + if(!nn) return; // nothing to do + register long i, pc=kk.size(); + register mreal xx, yy; + ff = new long[2*pc]; gr->Reserve(2*pc); + mglPoint p,q; + for(i=0;iAddPnt(p, c, q); + ff[i+pc] = gr->AddPnt(mglPoint(p.x, p.y, p.z+dval), c, q); + } + + for(i=0;i=0) gr->quad_plot(ff[i], ff[nn[i]], ff[i+pc], ff[nn[i]+pc]); + delete []nn; delete []ff; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"ContV")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContV",cgid++); + bool fixed=(mglchr(sch,'_')) || (gr->Min.z==gr->Max.z); + long s=gr->AddTexture(sch); + gr->SetPenPal(sch); + + mglData xx, yy; + if(x->GetNx()*x->GetNy()!=m*n || y->GetNx()*y->GetNy()!=m*n) // make + { + xx.Create(n, m); yy.Create(n, m); + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + if(mx && my) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; yy.a[i+n*j] = my->a[j]; } + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); yy.a[i+n*j] = y->v(j); } + x = &xx; y = &yy; + } + // x, y -- have the same size z +#pragma omp parallel + { + mglData zz(n, m); +#pragma omp for collapse(2) + for(long j=0;jGetNz();j++) for(long i=0;iGetNx();i++) + { + if(gr->Stop) continue; + mreal v0 = v->v(i), z0 = fixed ? gr->Min.z : v0; + if(z->GetNz()>1) z0 = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(j)/(z->GetNz()-1); + zz.Fill(z0,z0); + mreal dv = (gr->Max.c-gr->Min.c)/8; + if(i>0) dv = v->v(i-1)-v->v(i); + else if(iGetNx()-1) dv = v->v(i)-v->v(i+1); + if(fixed) dv=-dv; + mgl_contv_gen(gr,v0,dv,z,x,y,&zz,gr->GetC(s,v0),j); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_val(HMGL gr, HCDT v, HCDT z, const char *sch, const char *opt) +{ + register long n = z->GetNx(), m = z->GetNy(); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"Cont"); return; } + gr->SaveState(opt); + mglData x(n, m), y(n, m); + x.Fill(gr->Min.x,gr->Max.x,'x'); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_contv_xy_val(gr,v,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_contv_xy_val(gr,&v,x,y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_contv_val(gr,&v,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contv_xy_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(a), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contv_val(_GR_, _DA_(v), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contv_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contv_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contv(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Cont3 series +// +//----------------------------------------------------------------------------- +struct _mgl_slice { mglData x,y,z,a; }; +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_get_slice(_mgl_slice &s, HCDT x, HCDT y, HCDT z, HCDT a, char dir, mreal d, bool both) +{ + register long i,j,i0,n=a->GetNx(),m=a->GetNy(),l=a->GetNz(), nx=1,ny=1,p; + + if(dir=='x') { nx = m; ny = l; if(d<0) d = n/2.; } + if(dir=='y') { nx = n; ny = l; if(d<0) d = m/2.; } + if(dir=='z') { nx = n; ny = m; if(d<0) d = l/2.; } + s.x.Create(nx,ny); s.y.Create(nx,ny); + s.z.Create(nx,ny); s.a.Create(nx,ny); + p = long(d); d -= p; + if(dir=='x' && p>=n-1) { d+=p-n+2; p=n-2; } + if(dir=='y' && p>=m-1) { d+=p-m+2.; p=m-2; } + if(dir=='z' && p>=l-1) { d+=p-l+2; p=l-2; } + mreal v; + + if(both) + { + if(dir=='x') for(j=0;jv(p,i,j)*(1-d) + x->v(p+1,i,j)*d; + s.y.a[i0] = y->v(p,i,j)*(1-d) + y->v(p+1,i,j)*d; + s.z.a[i0] = z->v(p,i,j)*(1-d) + z->v(p+1,i,j)*d; + s.a.a[i0] = a->v(p,i,j)*(1-d) + a->v(p+1,i,j)*d; + } + if(dir=='y') for(j=0;jv(i,p,j)*(1-d) + x->v(i,p+1,j)*d; + s.y.a[i0] = y->v(i,p,j)*(1-d) + y->v(i,p+1,j)*d; + s.z.a[i0] = z->v(i,p,j)*(1-d) + z->v(i,p+1,j)*d; + s.a.a[i0] = a->v(i,p,j)*(1-d) + a->v(i,p+1,j)*d; + } + if(dir=='z') for(j=0;jv(i,j,p)*(1-d) + x->v(i,j,p+1)*d; + s.y.a[i0] = y->v(i,j,p)*(1-d) + y->v(i,j,p+1)*d; + s.z.a[i0] = z->v(i,j,p)*(1-d) + z->v(i,j,p+1)*d; + s.a.a[i0] = a->v(i,j,p)*(1-d) + a->v(i,j,p+1)*d; + } + } + else // x, y, z -- vectors + { + if(dir=='x') + { + v = x->v(p)*(1-d)+x->v(p+1)*d; + for(j=0;jv(i); s.z.a[i0] = z->v(j); + s.a.a[i0] = a->v(p,i,j)*(1-d) + a->v(p+1,i,j)*d; + } + } + if(dir=='y') + { + v = y->v(p)*(1-d)+y->v(p+1)*d; + for(j=0;jv(i); s.z.a[i0] = z->v(j); + s.a.a[i0] = a->v(i,p,j)*(1-d) + a->v(i,p+1,j)*d; + } + } + if(dir=='z') + { + v = z->v(p)*(1-d)+z->v(p+1)*d; + for(j=0;jv(i); s.y.a[i0] = y->v(j); + s.a.a[i0] = a->v(i,j,p)*(1-d) + a->v(i,j,p+1)*d; + } + } + } +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_get_slice_md(_mgl_slice &s, const mglData *x, const mglData *y, const mglData *z, const mglData *a, char dir, mreal d, bool both) +{ + long n=a->nx,m=a->ny,l=a->nz, nx=1,ny=1,p; + + if(dir=='x') { nx = m; ny = l; if(d<0) d = n/2.; } + if(dir=='y') { nx = n; ny = l; if(d<0) d = m/2.; } + if(dir=='z') { nx = n; ny = m; if(d<0) d = l/2.; } + s.x.Create(nx,ny); s.y.Create(nx,ny); + s.z.Create(nx,ny); s.a.Create(nx,ny); + p = long(d); d -= p; + if(dir=='x' && p>=n-1) { d+=p-n+2; p=n-2; } + if(dir=='y' && p>=m-1) { d+=p-m+2.; p=m-2; } + if(dir=='z' && p>=l-1) { d+=p-l+2; p=l-2; } + mreal v; + + if(both) + { + if(dir=='x') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+1]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+1]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+1]*d; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+1]*d; + } + if(dir=='y') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+n]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+n]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+n]*d; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+n]*d; + } + if(dir=='z') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+n*m]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+n*m]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+n*m]*d; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+n*m]*d; + } + } + else // x, y, z -- vectors + { + if(dir=='x') + { + v = x->a[p]*(1-d)+x->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.z.a[i0] = z->a[j]; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+1]*d; + } + } + if(dir=='y') + { + v = y->a[p]*(1-d)+y->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.y.a[i0] = v; s.z.a[i0] = z->a[j]; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+n]*d; + } + } + if(dir=='z') + { + v = z->a[p]*(1-d)+z->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.y.a[i0] = y->a[j]; s.z.a[i0] = v; + s.a.a[i0] = a->a[i1]*(1-d) + a->a[i1+n*m]*d; + } + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + bool both = mgl_isboth(x,y,z,a); + if(mgl_check_dim3(gr,both,x,y,z,a,0,"Cont3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Cont3",cgid++); + char dir='y'; + if(mglchr(sch,'x')) dir='x'; + if(mglchr(sch,'z')) dir='z'; + + bool text=(mglchr(sch,'t')); + long ss=gr->AddTexture(sch); + gr->SetPenPal(sch); + + _mgl_slice s; + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *mz = dynamic_cast(z); + const mglData *ma = dynamic_cast(a); + if(mx&&my&&mz&&ma) mgl_get_slice_md(s,mx,my,mz,ma,dir,sVal,both); + else mgl_get_slice(s,x,y,z,a,dir,sVal,both); +#pragma omp parallel for + for(long i=0;iGetNx();i++) + { + register mreal v0 = v->v(i); + mgl_cont_gen(gr,v0,&s.a,&s.x,&s.y,&s.z,gr->GetC(ss,v0),text,0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sVal, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_cont3_xyz_val(gr,v,&x,&y,&z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont3"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont3_xyz_val(gr,&v,x,y,z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Cont3"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont3_val(gr,&v,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_xyz_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont3_xyz_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont3_val(_GR_, _DA_(v), _DA_(a), s, *sVal, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont3(_GR_, _DA_(a), s, *sVal, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Dens3 series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + bool both = mgl_isboth(x,y,z,a); + if(mgl_check_dim3(gr,both,x,y,z,a,0,"Dens3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Dens3",cgid++); + char dir='y'; + if(mglchr(sch,'x')) dir='x'; + if(mglchr(sch,'z')) dir='z'; + + _mgl_slice s; + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *mz = dynamic_cast(z); + const mglData *ma = dynamic_cast(a); + if(mx&&my&&mz&&ma) mgl_get_slice_md(s,mx,my,mz,ma,dir,sVal,both); + else mgl_get_slice(s,x,y,z,a,dir,sVal,both); + mgl_surfc_xy(gr,&s.x,&s.y,&s.z,&s.a,sch,0); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_dens3_xyz(gr,&x,&y,&z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_dens3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_dens3(_GR_, _DA_(a), s, *sVal, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Grid3 series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + bool both = mgl_isboth(x,y,z,a); + if(mgl_check_dim3(gr,both,x,y,z,a,0,"Grid3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Grid3",cgid++); + char dir='y'; + if(mglchr(sch,'x')) dir='x'; + if(mglchr(sch,'z')) dir='z'; + + _mgl_slice s; + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *mz = dynamic_cast(z); + const mglData *ma = dynamic_cast(a); + if(mx&&my&&mz&&ma) mgl_get_slice_md(s,mx,my,mz,ma,dir,sVal,both); + else mgl_get_slice(s,x,y,z,a,dir,sVal,both); + mgl_mesh_xy(gr,&s.x,&s.y,&s.z,sch,0); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()), z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_grid3_xyz(gr,&x,&y,&z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_grid3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_grid3(_GR_, _DA_(a), s, *sVal, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContF3 series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_xyz_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + bool both = mgl_isboth(x,y,z,a); + if(mgl_check_dim3(gr,both,x,y,z,a,0,"ContF3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContF3",cgid++); + char dir='y'; + if(mglchr(sch,'x')) dir='x'; + if(mglchr(sch,'z')) dir='z'; + + long ss=gr->AddTexture(sch); + _mgl_slice s; + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *mz = dynamic_cast(z); + const mglData *ma = dynamic_cast(a); + if(mx&&my&&mz&&ma) mgl_get_slice_md(s,mx,my,mz,ma,dir,sVal,both); + else mgl_get_slice(s,x,y,z,a,dir,sVal,both); +#pragma omp parallel for + for(long i=0;iGetNx()-1;i++) + { + register mreal v0 = v->v(i); + mgl_contf_gen(gr,v0,v->v(i+1),&s.a,&s.x,&s.y,&s.z,gr->GetC(ss,v0),0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sVal, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_contf3_xyz_val(gr,v,&x,&y,&z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, double sVal, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"ContF3"); return; } + mglData v(Num+2); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf3_xyz_val(gr,&v,x,y,z,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3(HMGL gr, HCDT a, const char *sch, double sVal, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?7:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"ContF3"); return; } + mglData v(Num+2); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf3_val(gr,&v,a,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_xyz_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_contf3_xyz_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_contf3_val(_GR_, _DA_(v), _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_contf3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf3_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_contf3(_GR_, _DA_(a), s, *sVal, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Axial series +// +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_find_prev(long i, long pc, long *nn) +{ + for(long k=0;kReserve(pc*82); + for(i=0;iStop) return; + k = mgl_find_prev(i,pc,nn); + if(nn[i]<0) continue; + q1 = k<0 ? ff[nn[i]]-ff[i] : (ff[nn[i]]-ff[k])*0.5; + q2 = nn[nn[i]]<0 ? ff[nn[i]]-ff[i] : (ff[nn[nn[i]]]-ff[i])*0.5; + + p = a*ff[i].y + c*ff[i].x; + p1 = wire ? gr->AddPnt(p,cc) : gr->AddPnt(p,cc,(a*q1.y + c*q1.x)^b); + p = a*ff[nn[i]].y + c*ff[nn[i]].x; + p2 = wire ? gr->AddPnt(p,cc) : gr->AddPnt(p,cc,(a*q2.y + c*q2.x)^b); + if(wire==1) gr->line_plot(p1,p2); + else if(wire) { gr->mark_plot(p1,'.'); gr->mark_plot(p2,'.'); } + + for(j=1;j<41;j++) + { + p3 = p1; p4 = p2; + register float co = mgl_cos[(j*18)%360], si = mgl_cos[(270+j*18)%360]; +// fi = j*M_PI/20; si = sin(fi); co = cos(fi); + p = a*ff[i].y + b*(si*ff[i].x) + c*(co*ff[i].x); + p1 = wire ? gr->AddPnt(p,cc) : gr->AddPnt(p,cc,(a*q1.y + b*(si*q1.x) + c*(co*q1.x))^(b*co-c*si)); + p = a*ff[nn[i]].y + b*(si*ff[nn[i]].x) + c*(co*ff[nn[i]].x); + p2 = wire ? gr->AddPnt(p,cc) : gr->AddPnt(p,cc,(a*q2.y + b*(si*q2.x) + c*(co*q2.x))^(b*co-c*si)); + if(wire==1) + { gr->line_plot(p1,p2); gr->line_plot(p1,p3); + gr->line_plot(p4,p2); gr->line_plot(p4,p3); } + else if(wire) { gr->mark_plot(p1,'.'); gr->mark_plot(p2,'.'); } + else gr->quad_plot(p3,p4,p1,p2); + } + } +} +//----------------------------------------------------------------------------- +// NOTE! All data MUST have the same size! Only first slice is used! +void MGL_EXPORT mgl_axial_gen(HMGL gr, mreal val, HCDT a, HCDT x, HCDT y, mreal c, char dir,long ak,int wire) +{ + long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2 || x->GetNx()*x->GetNy()!=n*m || y->GetNx()*y->GetNy()!=n*m) + { gr->SetWarn(mglWarnDim,"ContGen"); return; } + + mglPoint *kk = new mglPoint[2*n*m],*pp = new mglPoint[2*n*m],p; + mreal d, kx, ky; + register long i,j,k, pc=0,i0; + // Usually number of points is much smaller. So, there is no reservation. + // gr->Reserve(2*n*m); + + // add intersection point of isoline and X or Y axis + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *ma = dynamic_cast(a); + if(mx&&my&&ma) for(j=0;jStop) { delete []kk; delete []pp; return; } + i0 = i+n*j; + d = (ia[i0+n*m*ak],ma->a[i0+1+n*m*ak]):-1; + if(d>=0 && d<1) + { + pp[pc] = mglPoint(mx->a[i0]*(1-d)+mx->a[i0+1]*d, my->a[i0]*(1-d)+my->a[i0+1]*d); + kk[pc] = mglPoint(i+d,j); pc++; + } + d = (ja[i0+n*m*ak],ma->a[i0+n*m*ak+n]):-1; + if(d>=0 && d<1) + { + pp[pc] = mglPoint(mx->a[i0]*(1-d)+mx->a[i0+n]*d, my->a[i0]*(1-d)+my->a[i0+n]*d); + kk[pc] = mglPoint(i,j+d); pc++; + } + } + else for(j=0;jStop) { delete []kk; delete []pp; return; } + register mreal va=a->v(i,j,ak),vx=x->v(i,j),vy=y->v(i,j); + d = (iv(i+1,j,ak)):-1; + if(d>=0 && d<1) + { + pp[pc] = mglPoint(vx*(1-d)+x->v(i+1,j)*d, vy*(1-d)+y->v(i+1,j)*d); + kk[pc] = mglPoint(i+d,j); pc++; + } + d = (jv(i,j+1,ak)):-1; + if(d>=0 && d<1) + { + pp[pc] = mglPoint(vx*(1-d)+x->v(i,j+1)*d, vy*(1-d)+y->v(i,j+1)*d); + kk[pc] = mglPoint(i,j+d); pc++; + } + } + // deallocate arrays and finish if no point + if(pc==0) { delete []kk; delete []pp; return; } + // allocate arrays for curve + long *nn = new long[pc], *ff = new long[pc]; + for(i=0;iStop) { delete []kk; delete []pp; delete []nn; delete []ff; return; } + if(j>=0) + { + kx = kk[j].x; ky = kk[j].y; i = -1; + i11 = long(kx+1e-5); i12 = long(kx-1e-5); + j11 = long(ky+1e-5); j12 = long(ky-1e-5); + for(k=0;k=0); + mgl_axial_plot(gr,pc,pp,nn,dir,c,wire); + delete []kk; delete []nn; delete []ff; delete []pp; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_xy_val(HMGL gr, HCDT v, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Axial")) return; + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Axial",cgid++); + long s=gr->AddTexture(sch); + char dir='y'; + if(mglchr(sch,'x')) dir = 'x'; + if(mglchr(sch,'z')) dir = 'z'; + + mglData xx, yy; + if(x->GetNx()*x->GetNy()!=m*n || y->GetNx()*y->GetNy()!=m*n) // make + { + xx.Create(n, m); yy.Create(n, m); + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + if(mx && my) +#pragma omp parallel for collapse(2) + for(long i=0;ia[i]; yy.a[i+n*j] = my->a[j]; } + else +#pragma omp parallel for collapse(2) + for(long i=0;iv(i); yy.a[i+n*j] = y->v(j); } + x = &xx; y = &yy; + } + // x, y -- have the same size z + int wire = mglchr(sch,'#')?1:0; + if(mglchr(sch,'.')) wire = 2; +#pragma omp parallel for collapse(2) + for(long j=0;jGetNz();j++) for(long i=0;iGetNx();i++) + { + if(gr->Stop) continue; + register mreal v0 = v->v(i); + mgl_axial_gen(gr,v0,z,x,y,gr->GetC(s,v0),dir,j,wire); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_val(HMGL gr, HCDT v, HCDT a, const char *sch, const char *opt) +{ + register long n=a->GetNx(), m=a->GetNy(); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"Axial"); return; } + gr->SaveState(opt); + mglData x(n, m), y(n, m); + if(gr->Max.x*gr->Min.x>=0) x.Fill(gr->Min.x,gr->Max.x,'x'); + else x.Fill(0,gr->Max.x,'x'); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_axial_xy_val(gr,v,&x,&y,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_xy(HMGL gr, HCDT x, HCDT y, HCDT a, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?3:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Axial"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_axial_xy_val(gr,&v,x,y,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial(HMGL gr, HCDT a, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = mgl_isnan(r)?3:long(r+0.5); + if(Num<1) { gr->SetWarn(mglWarnCnt,"Axial"); return; } + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_axial_val(gr,&v,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_xy_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_axial_xy_val(_GR_, _DA_(v), _DA_(x), _DA_(y), _DA_(a), s, o); +delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_axial_val(_GR_, _DA_(v), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_axial_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_axial_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_axial(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Torus series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_torus(HMGL gr, HCDT r, HCDT z, const char *sch, const char *opt) +{ + long i,j,n=r->GetNx(); + if(n*r->GetNy()!=z->GetNx()*z->GetNy()) { gr->SetWarn(mglWarnDim,"Torus"); return; } + if(n<2) { gr->SetWarn(mglWarnLow,"Torus"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Torus",cgid++); + + mglPoint *pp = new mglPoint[n]; + long *nn = new long[n]; + long ss=gr->AddTexture(sch); + char dir='y'; + if(mglchr(sch,'x')) dir = 'x'; + if(mglchr(sch,'z')) dir = 'z'; + + mreal c = gr->GetC(ss,gr->Min.c); + const mglData *mr = dynamic_cast(r); + const mglData *mz = dynamic_cast(z); + int wire = mglchr(sch,'#')?1:0; + if(mglchr(sch,'.')) wire = 2; + for(j=0;jGetNy();j++) + { + if(mr&&mz) for(i=0;ia[i+n*j], mz->a[i+n*j]); + } + else for(i=0;iv(i,j), z->v(i,j)); + } + mgl_axial_plot(gr,n,pp,nn,dir,c,wire); + } + gr->EndGroup(); + delete []nn; delete []pp; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_torus_(uintptr_t *gr, uintptr_t *r, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; +char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; +mgl_torus(_GR_, _DA_(r), _DA_(z), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/crust.cpp b/src/crust.cpp new file mode 100644 index 0000000..95f4c44 --- /dev/null +++ b/src/crust.cpp @@ -0,0 +1,653 @@ +/*************************************************************************** + * crust.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/other.h" +#include "mgl2/data.h" +#include "mgl2/thread.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// TriPlot series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + long n = x->GetNx(), m = nums->GetNy(); + if(mgl_check_trig(gr,nums,x,y,z,a,"TriPlot")) return; + + long ss=gr->AddTexture(sch); + gr->SaveState(opt); gr->SetPenPal("-"); + static int cgid=1; gr->StartGroup("TriPlot",cgid++); + mglPoint p1,p2,p3,q; + + bool wire = mglchr(sch,'#'); + long nc = a->GetNx(); + if(nc!=n && nc>=m) // colors per triangle + { + gr->Reserve(m*3); +#pragma omp parallel for private(p1,p2,p3,q) + for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.5); + p1 = mglPoint(x->v(k1), y->v(k1), z->v(k1)); + register long k2 = long(nums->v(1,i)+0.5); + p2 = mglPoint(x->v(k2), y->v(k2), z->v(k2)); + register long k3 = long(nums->v(2,i)+0.5); + p3 = mglPoint(x->v(k3), y->v(k3), z->v(k3)); + q = wire ? mglPoint(NAN,NAN) : (p2-p1) ^ (p3-p1); + k1 = gr->AddPnt(p1,gr->GetC(ss,a->v(k1)),q); + k2 = gr->AddPnt(p2,gr->GetC(ss,a->v(k2)),q); + k3 = gr->AddPnt(p3,gr->GetC(ss,a->v(k3)),q); + gr->trig_plot(k1,k2,k3); + } + } + else if(nc>=n) // colors per point + { + gr->Reserve(n); + long *kk = new long[n]; + mglPoint *pp = new mglPoint[n]; +#pragma omp parallel for + for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.5); + register long k2 = long(nums->v(1,i)+0.5); + register long k3 = long(nums->v(2,i)+0.5); + if(!wire) + { + mglPoint q = mglPoint(x->v(k2)-x->v(k1), y->v(k2)-y->v(k1), z->v(k2)-z->v(k1)) ^ + mglPoint(x->v(k3)-x->v(k1), y->v(k3)-y->v(k1), z->v(k3)-z->v(k1)); + q.Normalize(); + // try be sure that in the same direction ... + if(q.z<0) q *= -1; +#pragma omp critical(quadplot) + {pp[k1] += q; pp[k2] += q; pp[k3] += q;} + } + else pp[k1]=pp[k2]=pp[k3]=mglPoint(NAN,NAN); + } +#pragma omp parallel for + for(long i=0;iStop) continue; + kk[i] = gr->AddPnt(mglPoint(x->v(i), y->v(i), z->v(i)), gr->GetC(ss,a->v(i)), pp[i]); + } +#pragma omp parallel for + for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.5); + register long k2 = long(nums->v(1,i)+0.5); + register long k3 = long(nums->v(2,i)+0.5); + if(wire) + { + gr->line_plot(kk[k1],kk[k2]); gr->line_plot(kk[k1],kk[k3]); + gr->line_plot(kk[k3],kk[k2]); + } + else gr->trig_plot(kk[k1],kk[k2],kk[k3]); + } + delete []kk; delete []pp; + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xyz(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ mgl_triplot_xyzc(gr,nums,x,y,z,z,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData z(x->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_triplot_xyzc(gr,nums,x,y,&z,&z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_triplot_xyzc(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), _DA_(c), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xyz_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_triplot_xyz(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_triplot_xy_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_triplot_xy(_GR_, _DA_(nums), _DA_(x), _DA_(y), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// QuadPlot series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + long n = x->GetNx(), m = nums->GetNy(); + if(mgl_check_trig(gr,nums,x,y,z,a,"QuadPlot",4)) return; + + long ss=gr->AddTexture(sch); + gr->SaveState(opt); gr->SetPenPal("-"); + static int cgid=1; gr->StartGroup("QuadPlot",cgid++); + mglPoint p1,p2,p3,p4; + + long nc = a->GetNx(); + bool wire = mglchr(sch,'#'); + if(nc!=n && nc>=m) // colors per triangle + { + gr->Reserve(m*4); +#pragma omp parallel for private(p1,p2,p3,p4) + for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.5); + p1 = mglPoint(x->v(k1), y->v(k1), z->v(k1)); + register long k2 = long(nums->v(1,i)+0.5); + p2 = mglPoint(x->v(k2), y->v(k2), z->v(k2)); + register long k3 = long(nums->v(2,i)+0.5); + p3 = mglPoint(x->v(k3), y->v(k3), z->v(k3)); + register long k4 = floor(nums->v(3,i)+0.5); + p4 = mglPoint(x->v(k4), y->v(k4), z->v(k4)); + mglPoint q = wire ? mglPoint(NAN,NAN):(p2-p1) ^ (p3-p1); + k1 = gr->AddPnt(p1,gr->GetC(ss,a->v(k1)),q); + k2 = gr->AddPnt(p2,gr->GetC(ss,a->v(k2)),q); + k3 = gr->AddPnt(p3,gr->GetC(ss,a->v(k3)),q); + k4 = gr->AddPnt(p4,gr->GetC(ss,a->v(k4)),q); + gr->quad_plot(k1,k2,k3,k4); + } + } + else if(nc>=n) // colors per point + { + gr->Reserve(n); + long *kk = new long[n]; + mglPoint *pp = new mglPoint[n]; +#pragma omp parallel for private(p1,p2,p3,p4) + for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.5); + p1 = mglPoint(x->v(k1), y->v(k1), z->v(k1)); + register long k2 = long(nums->v(1,i)+0.5); + p2 = mglPoint(x->v(k2), y->v(k2), z->v(k2)); + register long k3 = long(nums->v(2,i)+0.5); + p3 = mglPoint(x->v(k3), y->v(k3), z->v(k3)); + register long k4 = floor(nums->v(3,i)+0.5); + p4 = mglPoint(x->v(k4), y->v(k4), z->v(k4)); + + if(wire) pp[k1]=pp[k2]=pp[k3]=pp[k4]=mglPoint(NAN,NAN); + else + { + mglPoint q1 = (p2-p1) ^ (p3-p1); if(q1.z<0) q1*=-1; + mglPoint q2 = (p2-p4) ^ (p3-p4); if(q2.z<0) q2*=-1; + mglPoint q3 = (p1-p2) ^ (p4-p2); if(q3.z<0) q3*=-1; + mglPoint q4 = (p1-p4) ^ (p4-p3); if(q4.z<0) q4*=-1; +#pragma omp critical(quadplot) + {pp[k1] += q1; pp[k2] += q2; pp[k3] += q3; pp[k4] += q4;} + } + } +#pragma omp parallel for + for(long i=0;iStop) continue; + kk[i] = gr->AddPnt(mglPoint(x->v(i), y->v(i), z->v(i)),gr->GetC(ss,a->v(i)), pp[i]); + } +#pragma omp parallel for + for(long i=0;iStop) continue; + register long k1 = floor(nums->v(0,i)+0.5); + register long k2 = floor(nums->v(1,i)+0.5); + register long k3 = floor(nums->v(2,i)+0.5); + register long k4 = floor(nums->v(3,i)+0.5); + if(wire) + { + gr->line_plot(kk[k1],kk[k2]); gr->line_plot(kk[k1],kk[k3]); + gr->line_plot(kk[k4],kk[k2]); gr->line_plot(kk[k4],kk[k3]); + } + else gr->quad_plot(kk[k1],kk[k2],kk[k3],kk[k4]); + } + delete []kk; delete []pp; + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xyz(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ mgl_quadplot_xyzc(gr,nums,x,y,z,z,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xy(HMGL gr, HCDT nums, HCDT x, HCDT y, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData z(x->GetNx()); z.Fill(gr->Min.z,gr->Min.z); + mgl_quadplot_xyzc(gr,nums,x,y,&z,&z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_quadplot_xyzc(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), _DA_(c), s, o); + delete []o; delete []s;} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xyz_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_quadplot_xyzc(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), _DA_(z), s, o); + delete []o; delete []s;} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_quadplot_xy_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_quadplot_xy(_GR_, _DA_(nums), _DA_(x), _DA_(y), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// TriCont series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyzcv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + long n = x->GetNx(), m = nums->GetNy(); + if(mgl_check_trig(gr,nums,x,y,z,a,"TriCont")) return; + + long ss=gr->AddTexture(sch); + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("TriCont",cgid++); + bool zVal = !(mglchr(sch,'_')); + mglPoint p1,p2,p3; +#pragma omp parallel for private(p1,p2,p3) collapse(2) + for(long k=0;kGetNx();k++) for(long i=0;iStop) continue; + register long k1 = long(nums->v(0,i)+0.1); if(k1<0 || k1>=n) continue; + register long k2 = long(nums->v(1,i)+0.1); if(k2<0 || k2>=n) continue; + register long k3 = long(nums->v(2,i)+0.1); if(k3<0 || k3>=n) continue; + register mreal val = v->v(k), c = gr->GetC(ss,val), d1,d2,d3; + + d1 = mgl_d(val,a->v(k1),a->v(k2)); + p1 = mglPoint(x->v(k1)*(1-d1)+x->v(k2)*d1, y->v(k1)*(1-d1)+y->v(k2)*d1, + zVal?z->v(k1)*(1-d1)+z->v(k2)*d1:gr->Min.z); + d2 = mgl_d(val,a->v(k1),a->v(k3)); + p2 = mglPoint(x->v(k1)*(1-d2)+x->v(k3)*d2, y->v(k1)*(1-d2)+y->v(k3)*d2, + zVal?z->v(k1)*(1-d2)+z->v(k3)*d2:gr->Min.z); + d3 = mgl_d(val,a->v(k2),a->v(k3)); + p3 = mglPoint(x->v(k2)*(1-d3)+x->v(k3)*d3, y->v(k2)*(1-d3)+y->v(k3)*d3, + zVal?z->v(k2)*(1-d3)+z->v(k3)*d3:gr->Min.z); + if(d1>=0 && d1<=1 && d2>=0 && d2<=1) + { + k1 = gr->AddPnt(p1,c); k2 = gr->AddPnt(p2,c); + gr->line_plot(k1,k2); + } + else if(d1>=0 && d1<=1 && d3>=0 && d3<=1) + { + k1 = gr->AddPnt(p1,c); k2 = gr->AddPnt(p3,c); + gr->line_plot(k1,k2); + } + else if(d3>=0 && d3<=1 && d2>=0 && d2<=1) + { + k1 = gr->AddPnt(p3,c); k2 = gr->AddPnt(p2,c); + gr->line_plot(k1,k2); + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyzc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long n = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(n); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(n+1); + mgl_tricont_xyzcv(gr,&v,nums,x,y,z,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyc(HMGL gr, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ mgl_tricont_xyzc(gr,nums,x,y,z,z,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xycv(HMGL gr, HCDT v, HCDT nums, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ mgl_tricont_xyzcv(gr,v,nums,x,y,z,z,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyzcv_(uintptr_t *gr, uintptr_t *v, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tricont_xyzcv(_GR_, _DA_(v), _DA_(nums), _DA_(x), _DA_(y), _DA_(z), _DA_(c), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xycv_(uintptr_t *gr, uintptr_t *v, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tricont_xycv(_GR_, _DA_(v), _DA_(nums), _DA_(x), _DA_(y), _DA_(z), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyzc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tricont_xyzc(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), _DA_(c), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tricont_xyc_(uintptr_t *gr, uintptr_t *nums, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tricont_xyc(_GR_, _DA_(nums), _DA_(x), _DA_(y), _DA_(z), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Dots series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots_ca(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, HCDT a, const char *sch, const char *opt) +{ + long n = x->GetNN(), d, k=1; + if(x->GetNz()>1) k=3; else if(x->GetNy()>1) k=2; + + if(y->GetNN()!=n || z->GetNN()!=n || c->GetNN()!=n || (a && a->GetNN()!=n)) + { gr->SetWarn(mglWarnDim,"Dots"); return; } + gr->SaveState(opt); + + d = gr->MeshNum>0 ? mgl_ipow(gr->MeshNum+1,k) : n; + d = n>d ? n/d:1; + + static int cgid=1; gr->StartGroup("Dots",cgid++); + char mk=gr->SetPenPal(sch); + long ss=gr->AddTexture(sch); + if(mk==0) mk='.'; + gr->Reserve(n); + +#pragma omp parallel for + for(long i=0;iStop) continue; + mglPoint p = mglPoint(x->vthr(i),y->vthr(i),z->vthr(i)); + long pp = gr->AddPnt(p,gr->GetC(ss,c->vthr(i)),mglPoint(NAN),a?gr->GetA(a->vthr(i)):-1); + gr->mark_plot(pp, mk); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots_a(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ mgl_dots_ca(gr, x, y, z, z, a, sch, opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ mgl_dots_ca(gr, x, y, z, z, NULL, sch, opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dots(_GR_, _DA_(x),_DA_(y),_DA_(z),s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots_a_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dots_a(_GR_, _DA_(x),_DA_(y),_DA_(z),_DA_(a),s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dots_ca_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dots_ca(_GR_, _DA_(x),_DA_(y),_DA_(z),_DA_(c),_DA_(a),s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// mglTriangulation +// +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_crust(long n,mglPoint *pp,long **nn,mreal ff); +HMDT MGL_EXPORT mgl_triangulation_3d(HCDT x, HCDT y, HCDT z) +{ // TODO: should be used s-hull or q-hull + mglData *nums=0; + long n = x->GetNx(), m; + if(y->GetNx()!=n || z->GetNx()!=n) return nums; + mglPoint *pp = new mglPoint[n]; + long *nn=0; +#pragma omp parallel for + for(long i=0;iv(i), y->v(i), z->v(i)); + m = mgl_crust(n,pp,&nn,0); + + if(m>0) + { + nums=new mglData(3,m); +#pragma omp parallel for + for(long i=0;i<3*m;i++) nums->a[i]=nn[i]; + } + delete []pp; free(nn); return nums; +} +//----------------------------------------------------------------------------- +#include "s_hull/s_hull_pro.h" +HMDT MGL_EXPORT mgl_triangulation_2d(HCDT x, HCDT y) +{ + mglData *nums=0; + long n = x->GetNN(); + if(y->GetNN()!=n) return nums; + // use s-hull here + std::vector pts; + std::vector out; + Shx pt; + + for(long i=0;ivthr(i); pt.c = y->vthr(i); pt.id = i; pts.push_back(pt); } + std::vector triads; + if(de_duplicate(pts, out)) + mglGlobalMess += "There are duplicated points for triangulation.\n"; + s_hull_pro(pts, triads); + long m = triads.size(); + nums=new mglData(3,m); +#pragma omp parallel for + for(long i=0;ia[3*i] = triads[i].a; + nums->a[3*i+1] = triads[i].b; + nums->a[3*i+2] = triads[i].c; + } + return nums; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_triangulation_3d_(uintptr_t *x, uintptr_t *y, uintptr_t *z) +{ return uintptr_t(mgl_triangulation_3d(_DA_(x),_DA_(y),_DA_(z))); } +uintptr_t MGL_EXPORT mgl_triangulation_2d_(uintptr_t *x, uintptr_t *y) +{ return uintptr_t(mgl_triangulation_2d(_DA_(x),_DA_(y))); } +//----------------------------------------------------------------------------- +// +// DataGrid +// +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_grid_t(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0],ny=t->p[1]; + mreal *b=t->a; + const mreal *x=t->b, *y=t->c, *d=t->d, *z=t->e; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { // TODO check if rounding needed + register long k1 = long(d[3*i0]), k2 = long(d[3*i0+1]), k3 = long(d[3*i0+2]); + mreal dxu,dxv,dyu,dyv; + mglPoint d1=mglPoint(x[k2]-x[k1],y[k2]-y[k1],z[k2]-z[k1]), d2=mglPoint(x[k3]-x[k1],y[k3]-y[k1],z[k3]-z[k1]), p; + + dxu = d2.x*d1.y - d1.x*d2.y; + if(fabs(dxu)<1e-5) continue; // points lies on the same line + dyv =-d1.x/dxu; dxv = d1.y/dxu; + dyu = d2.x/dxu; dxu =-d2.y/dxu; + + long x1,y1,x2,y2; + x1 = long(fmin(fmin(x[k1],x[k2]),x[k3])); // bounding box + y1 = long(fmin(fmin(y[k1],y[k2]),y[k3])); + x2 = long(fmax(fmax(x[k1],x[k2]),x[k3])); + y2 = long(fmax(fmax(y[k1],y[k2]),y[k3])); + x1 = x1>0 ? x1:0; x2 = x20 ? y1:0; y2 = y2x2) | (y1>y2)) continue; + + register mreal u,v,xx,yy, x0 = x[k1], y0 = y[k1]; + register long i,j; + for(i=x1;i<=x2;i++) for(j=y1;j<=y2;j++) + { + xx = (i-x0); yy = (j-y0); + u = dxu*xx+dyu*yy; v = dxv*xx+dyv*yy; + if((u<0) | (v<0) | (u+v>1)) continue; + b[i+nx*j] = z[k1] + d1.z*u + d2.z*v; + } + } + return 0; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_grid_xy(HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, mreal x1, mreal x2, mreal y1, mreal y2) +{ // NOTE: only for mglData + const mglData *x = dynamic_cast(xdat); + const mglData *y = dynamic_cast(ydat); + const mglData *z = dynamic_cast(zdat); + if(!x || !y || !z) return; + long n=x->GetNN(); + if((n<3) || (y->GetNN()!=n) || (z->GetNN()!=n)) return; + + mglData *nums = mgl_triangulation_2d(x,y); + if(nums->nx<3) { delete nums; return; } + long nn = nums->ny, par[3]={d->nx,d->ny,d->nz}; + mreal xx[4]={x1,0, y1,0}; + if(d->nx>1) xx[1] = (d->nx-1.)/(x2-x1); + if(d->ny>1) xx[3] = (d->ny-1.)/(y2-y1); + + mreal *xc=new mreal[n], *yc=new mreal[n]; +#pragma omp parallel for + for(long i=0;ia[i]-xx[0]); yc[i]=xx[3]*(y->a[i]-xx[2]); } +#pragma omp parallel for + for(long i=0;inx*d->ny*d->nz;i++) d->a[i] = NAN; + + mglStartThread(mgl_grid_t,0,nn,d->a,xc,yc,par,0,nums->a,z->a); + delete nums; delete []xc; delete []yc; +} +void MGL_EXPORT mgl_data_grid_xy_(uintptr_t *d, uintptr_t *x, uintptr_t *y, uintptr_t *z, mreal *x1, mreal *x2, mreal *y1, mreal *y2) +{ mgl_data_grid_xy(_DT_,_DA_(x),_DA_(y),_DA_(z),*x1,*x2,*y1,*y2); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_grid(HMGL gr, HMDT d, HCDT xdat, HCDT ydat, HCDT zdat, const char *opt) +{ + gr->SaveState(opt); + mgl_data_grid_xy(d,xdat,ydat,zdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y); + gr->LoadState(); +} +void MGL_EXPORT mgl_data_grid_(uintptr_t *gr, uintptr_t *d, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *opt,int lo) +{ char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_data_grid(_GR_,_DT_,_DA_(x),_DA_(y),_DA_(z),o); delete []o; } +//----------------------------------------------------------------------------- +// +// Crust series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_crust(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + if(y->GetNx()!=x->GetNx() || z->GetNx()!=x->GetNx()) + { gr->SetWarn(mglWarnDim,"Crust"); return; } + HMDT nums = mgl_triangulation_3d(x, y, z); + mgl_triplot_xyzc(gr,nums,x,y,z,z,sch,opt); + mgl_delete_data(nums); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_crust_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_crust(_GR_, _DA_(x),_DA_(y),_DA_(z),s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_insert_trig(long i1,long i2,long i3,long **n) +{ + static long Cur=0,Max=0; + if(i1<0 || i2<0 || i3<0) return Cur; + if(*n==0) + { + Max = 1024; Cur = 0; + *n = (long *)malloc(Max*3*sizeof(long)); + memset(*n,0,Max*3*sizeof(long)); + } + if(Cur>=Max) + { + Max += 1024; + *n = (long *)realloc(*n,Max*3*sizeof(long)); + memset(*n+3*(Max-1024),0,3*1024*sizeof(long)); + } + long *nn; + register long i,k1; + if(i1>i3) { k1=i1; i1=i3; i3=k1; } // simple sorting + if(i1>i2) { k1=i1; i1=i2; i2=k1; } + if(i2>i3) { k1=i2; i2=i3; i3=k1; } + for(i=0;i0) continue; + r = mgl_norm(qq[i]-qq[k1]); + if(rr) rm = r; + } + rs += sqrt(rm); + } + rs *= ff/n; rs = rs*rs; // "average" distance + long ind[100], set[100], ii; // indexes of "close" points, flag that it was added and its number + mglPoint qq[100]; // normalized point coordinates + long k1,k2,k3,m=0; + for(i=0;i0) + { + set[k1]=1; + mgl_insert_trig(i,ind[k1],ind[k2],nn); + k1 = k2; + } + m = mgl_insert_trig(i,ind[k1],ind[0],nn); + } + return m; +} +//----------------------------------------------------------------------------- diff --git a/src/data.cpp b/src/data.cpp new file mode 100644 index 0000000..b886cd8 --- /dev/null +++ b/src/data.cpp @@ -0,0 +1,2227 @@ +/*************************************************************************** + * data.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/data.h" +#include "mgl2/eval.h" +#include "mgl2/thread.h" +#include "interp.hpp" + +MGL_EXPORT int mglNumThr=0; +//----------------------------------------------------------------------------- +#if MGL_HAVE_PTHREAD +#ifdef WIN32 +#include +#include +#elif defined(__APPLE__) || defined (__FreeBSD__) +#include +#elif defined(unix) || defined(__unix) || defined(__unix__) +#include +#endif +void MGL_EXPORT mgl_set_num_thr(int n) +{ +#ifdef WIN32 + SYSTEM_INFO systemInfo; + GetSystemInfo(&systemInfo); + mglNumThr = n>0 ? n : systemInfo.dwNumberOfProcessors; +#elif defined (__APPLE__) || defined(__FreeBSD__) + int numProcessors = 1; + size_t size = sizeof(numProcessors); + sysctlbyname("hw.ncpu", &numProcessors, &size, NULL, 0); + mglNumThr = n>0 ? n : numProcessors; +#else + mglNumThr = n>0 ? n : get_nprocs_conf(); +#endif +} +#else +void MGL_EXPORT mgl_set_num_thr(int) { mglNumThr = 1; } +#endif +void MGL_EXPORT mgl_set_num_thr_(int *n) { mgl_set_num_thr(*n); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mglStartThread(void *(*func)(void *), void (*post)(mglThreadD *,mreal *), long n, + mreal *a, const mreal *b, const mreal *c, const long *p, + const void *v, const mreal *d, const mreal *e, const char *s) +{ + if(!func) return; +#if MGL_HAVE_PTHREAD + if(mglNumThr<1) mgl_set_num_thr(0); + if(mglNumThr>1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadD *par=new mglThreadD[mglNumThr]; + register long i; + for(i=0;i1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadV *par=new mglThreadV[mglNumThr]; + register long i; + for(i=0;i(a,nx,ny,nz,x,y,z,dx,dy,dz); } +//----------------------------------------------------------------------------- +mreal mglLinear(const mreal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z) +{ return mglLineart(a,nx,ny,nz,x,y,z); } +//----------------------------------------------------------------------------- +double mgl_ipow(double x,int n) +{ + double t; + if(n==2) return x*x; + if(n==1) return x; + if(n<0) return 1./mgl_ipow(x,-n); + if(n==0) return 1; + t = mgl_ipow(x,n/2); t = t*t; + if(n%2==1) t *= x; + return t; +} +double mgl_ipow_(mreal *x,int *n) { return mgl_ipow(*x,*n); } +//----------------------------------------------------------------------------- +double mgl_get_time(const char *time, const char *fmt) +{ +#if !defined(WIN32) + tm t; + strptime(time,fmt,&t); + return timegm(&t); +#else + return NAN; +#endif +} +double mgl_get_time_(const char *time, const char *fmt,int l,int m) +{ char *s=new char[l+1]; memcpy(s,time,l); s[l]=0; + char *f=new char[m+1]; memcpy(f,fmt,m); f[m]=0; + double t=mgl_get_time(s,f); delete []s; delete []f; return t; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_smth_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], kind=t->p[2]; + mreal *b=t->a, delta=t->c[0]; + const mreal *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = i%nx; + if(j>1 && j0) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + b[i] = mgl_max(a[i]-delta,mgl_min(a[i]+delta,b[i])); + return 0; +} +MGL_NO_EXPORT void *mgl_smth_y(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0],ny=t->p[1], kind=t->p[2]; + mreal *b=t->a, delta=t->c[0]; + const mreal *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = (i/nx)%ny; + if(j>1 && j0) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + b[i] = mgl_max(a[i]-delta,mgl_min(a[i]+delta,b[i])); + return 0; +} +MGL_NO_EXPORT void *mgl_smth_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + register long nn=t->p[0]*t->p[1], nz=t->n/nn, kind=t->p[2]; + mreal *b=t->a, delta=t->c[0]; + const mreal *a=t->b; + if(kind==SMOOTH_LINE_3) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>0 && jid;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>1 && jid;in;i+=mglNumThr) + { + register long j = i/nn; + if(j>1 && j0) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + b[i] = mgl_max(a[i]-delta,mgl_min(a[i]+delta,b[i])); + return 0; +} +void MGL_EXPORT mgl_data_smooth(HMDT d, const char *dirs, mreal delta) +{ + long Type = SMOOTH_QUAD_5; + if(!dirs || *dirs==0) dirs = "xyz"; + if(strchr(dirs,'0') || strchr(dirs,'1')) return; + if(strchr(dirs,'3')) Type = SMOOTH_LINE_3; + if(strchr(dirs,'5')) Type = SMOOTH_LINE_5; + long nx=d->nx,ny=d->ny,nz=d->nz; +// if(Type == SMOOTH_NONE) return; + long p[3]={nx,ny,Type}; + mreal *b = new mreal[nx*ny*nz],dd=delta; + // ����������� �� x + memset(b,0,nx*ny*nz*sizeof(mreal)); + if(nx>4 && strchr(dirs,'x')) + { + mglStartThread(mgl_smth_x,0,nx*ny*nz,b,d->a,&dd,p); + memcpy(d->a,b,nx*ny*nz*sizeof(mreal)); + memset(b,0,nx*ny*nz*sizeof(mreal)); + } + if(ny>4 && strchr(dirs,'y')) + { + mglStartThread(mgl_smth_y,0,nx*ny*nz,b,d->a,&dd,p); + memcpy(d->a,b,nx*ny*nz*sizeof(mreal)); + memset(b,0,nx*ny*nz*sizeof(mreal)); + } + if(nz>4 && strchr(dirs,'z')) + { + mglStartThread(mgl_smth_z,0,nx*ny*nz,b,d->a,&dd,p); + memcpy(d->a,b,nx*ny*nz*sizeof(mreal)); + } + delete []b; +} +void MGL_EXPORT mgl_data_smooth_(uintptr_t *d, const char *dir, mreal *delta,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_smooth(_DT_,s,*delta); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_csum_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nn]; + memcpy(b,d->a,nn*sizeof(mreal)); + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_csum_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_csum_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_csum_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + delete []b; +} +void MGL_EXPORT mgl_data_cumsum_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_cumsum(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_int_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a, dd=0.5/nz; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a, dd=0.5/ny; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a, dd=0.5/nx; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nn]; + memcpy(b,d->a,nn*sizeof(mreal)); + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_int_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_int_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_int_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + delete []b; +} +void MGL_EXPORT mgl_data_integral_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_integral(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_dif_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a, dd=0.5*nz; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a, dd=0.5*ny; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a, dd=0.5*nx; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nn]; + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_dif_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_dif_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_dif_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + delete []b; +} +void MGL_EXPORT mgl_data_diff_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_diff(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_dif2_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a, dd=0.5*nz*nz; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a, dd=0.5*ny*ny; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a, dd=0.5*nx*nx; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;inx,ny=d->ny,nz=d->nz,nn=nx*ny*nz; + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nn]; + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_dif2_z,0,nx*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_dif2_y,0,nx*nz,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_dif2_x,0,nz*ny,b,d->a,0,p); + memcpy(d->a,b,nn*sizeof(mreal)); + } + delete []b; +} +void MGL_EXPORT mgl_data_diff2_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_diff2(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_swap(HMDT d, const char *dir) +{ + if(!dir || *dir==0) return; + if(strchr(dir,'z') && d->nz>1) mgl_data_roll(d,'z',d->nz/2); + if(strchr(dir,'y') && d->ny>1) mgl_data_roll(d,'y',d->ny/2); + if(strchr(dir,'x') && d->nx>1) mgl_data_roll(d,'x',d->nx/2); +} +void MGL_EXPORT mgl_data_swap_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_swap(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_roll(HMDT dd, char dir, long num) +{ + long nx=dd->nx,ny=dd->ny,nz=dd->nz, d; + mreal *b,*a=dd->a; + if(dir=='z' && nz>1) + { + d = num>0 ? num%nz : (num+nz*(1+num/nz))%nz; + if(d==0) return; // nothing to do + b = new mreal[nx*ny*nz]; + memcpy(b,a+nx*ny*d,nx*ny*(nz-d)*sizeof(mreal)); + memcpy(b+nx*ny*(nz-d),a,nx*ny*d*sizeof(mreal)); + memcpy(a,b,nx*ny*nz*sizeof(mreal)); delete []b; + } + if(dir=='y' && ny>1) + { + d = num>0 ? num%ny : (num+ny*(1+num/ny))%ny; + if(d==0) return; // nothing to do + b = new mreal[nx*ny*nz]; + memcpy(b,a+nx*d,(nx*ny*nz-nx*d)*sizeof(mreal)); +#pragma omp parallel for + for(long i=0;i1) + { + d = num>0 ? num%nx : (num+nx*(1+num/nx))%nx; + if(d==0) return; // nothing to do + b = new mreal[nx*ny*nz]; + memcpy(b,a+d,(nx*ny*nz-d)*sizeof(mreal)); +#pragma omp parallel for + for(long i=0;inx,ny=d->ny,nz=d->nz; + mreal *a=d->a; + if(strchr(dir,'z') && nz>1) + { +#pragma omp parallel for collapse(2) + for(long j=0;j1) + { +#pragma omp parallel for + for(long i=0;i1) + { +#pragma omp parallel for + for(long j=0;jd->nx) return; + register long i,j,n=d->nx,m=d->ny; + mreal *b = new mreal[m*n], *a=d->a; + for(i=j=0;i+1ny = j; + delete []b; +} +void MGL_EXPORT mgl_data_clean_(uintptr_t *d, int *id) { mgl_data_clean(_DT_,*id); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_solve_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + HCDT d=(HCDT)t->v; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], n1=t->p[3]?nx-1:1, nn=t->n; + const mreal *a=t->b, *ii=t->c; + mreal *b=t->a,val=t->d[0],da = 1e-5*(val?fabs(val):1); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long l=t->id;lnx-2) continue; + if(a) for(long i=i0+1;ida || dx==0) + { + x += (val-v)/dx; kk++; + v = mglSpline3(a,nx,ny,nz,x,j,k, &dx,0,0); + if(kk>=10) + { + b[l] = x = fabs(v-val)v(i-1,j,k), y2=d->v(i,j,k); + if((y1-val)*(y2-val)<=0) + { b[l] = i-1 + (val-y1)/(y2-y1); break; } + } + b[l] /= n1; + } + return 0; +} +MGL_NO_EXPORT void *mgl_solve_y(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + HCDT d=(HCDT)t->v; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], n1=t->p[3]?ny-1:1, nn=t->n; + const mreal *a=t->b, *ii=t->c; + mreal *b=t->a,val=t->d[0],da = 1e-5*(val?fabs(val):1); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long l=t->id;lny-2) continue; + if(a) for(long i=i0+1;ida || dy==0) + { + x += (val-v)/dy; kk++; + v = mglSpline3(a,nx,ny,nz,j,x,k, 0,&dy,0); + if(kk>=10) + { + b[l] = x = fabs(v-val)v(j,i-1,k), y2=d->v(j,i,k); + if((y1-val)*(y2-val)<=0) + { b[l] = i-1 + (val-y1)/(y2-y1); break; } + } + b[l] /= n1; + } + return 0; +} +MGL_NO_EXPORT void *mgl_solve_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + HCDT d=(HCDT)t->v; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], n1=t->p[3]?nz-1:1, nn=t->n; + const mreal *a=t->b, *ii=t->c; + mreal *b=t->a,val=t->d[0],da = 1e-5*(val?fabs(val):1); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long l=t->id;lnz-2) continue; + if(a) for(long i=i0+1;ida || dz==0) + { + x += (val-v)/dz; kk++; + v = mglSpline3(a,nx,ny,nz,j,k,x, 0,0,&dz); + if(kk>=10) + { + b[l] = x = fabs(v-val)v(j,k,i-1), y2=d->v(j,k,i); + if((y1-val)*(y2-val)<=0) + { b[l] = i-1 + (val-y1)/(y2-y1); break; } + } + b[l] /= n1; + } + return 0; +} +HMDT MGL_EXPORT mgl_data_solve(HCDT dat, mreal val, char dir, HCDT i0, int norm) +{ + const mglData *i = dynamic_cast(i0); + const mglData *d = dynamic_cast(dat); + long p[4]={dat->GetNx(), dat->GetNy(), dat->GetNz(), norm}; + const mreal *ii=0; + mglData *r=new mglData; + if(dir=='x' && p[0]>1) + { + r->Create(p[1],p[2]); + if(i && i->nx*i->ny==p[1]*p[2]) ii = i->a; + mglStartThread(mgl_solve_x,0,p[1]*p[2],r->a,d?d->a:0,ii,p,dat,&val); + } + if(dir=='y' && p[1]>1) + { + r->Create(p[0],p[2]); + if(i && i->nx*i->ny==p[0]*p[2]) ii = i->a; + mglStartThread(mgl_solve_y,0,p[0]*p[2],r->a,d?d->a:0,ii,p,dat,&val); + } + if(dir=='z' && p[2]>1) + { + r->Create(p[0],p[1]); + if(i && i->nx*i->ny==p[0]*p[1]) ii = i->a; + mglStartThread(mgl_solve_z,0,p[0]*p[1],r->a,d?d->a:0,ii,p,dat,&val); + } + return r; +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_solve_1d(HCDT d, mreal val, int spl, long i0) +{ + mreal x=0, y1, y2, a, a0, dx=0, da = 1e-5*(val?fabs(val):1); + long nx = d->GetNx(); + if(i0<0 || i0>=nx) i0=0; + if(val==d->v(i0+1)) return i0+1; + const mglData *dd=dynamic_cast(d); + if(dd) for(long i=i0+1;ia[i-1]; y2=dd->a[i]; + if((y1-val)*(y2-val)<=0) + { + x = i-1 + (val-y1)/(y2-y1); + a0 = a = mglSpline1t(dd->a,nx,x,&dx); + if(spl) for(unsigned k=0;fabs(a-val)>da || dx==0;) + { + x += (val-a)/dx; k++; + a = mglSpline1t(dd->a,nx,x,&dx); + if(k>=10) + return fabs(a-val)v(i-1); y2=d->v(i); + if((y1-val)*(y2-val)<=0) + return i-1 + (val-y1)/(y2-y1); + } + return NAN; +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_linear_ext(HCDT d, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz) +{ + long kx=long(x), ky=long(y), kz=long(z); + mreal b0,b1; + const mglData *dd=dynamic_cast(d); + if(dd) + { + long nx=dd->nx, ny=dd->ny, nz=dd->nz, dn=ny>1?nx:0; + kx = kx>=0 ? kx:0; kx = kx=0 ? ky:0; ky = ky=0 ? kz:0; kz = kza, *bb; + if(kz>=0) + { + aa=dd->a+kx+nx*(ky+ny*kz); bb = aa+nx*ny; + b0 = aa[0]*(1-x-y+x*y) + x*(1-y)*aa[1] + y*(1-x)*aa[dn] + x*y*aa[1+dn]; + b1 = bb[0]*(1-x-y+x*y) + x*(1-y)*bb[1] + y*(1-x)*bb[dn] + x*y*bb[1+dn]; + } + else + { + z=0; + if(ky>=0) + { + aa=dd->a+kx+nx*ky; + b0 = b1 = aa[0]*(1-x-y+x*y) + x*(1-y)*aa[1] + y*(1-x)*aa[dn] + x*y*aa[1+dn]; + } + else if(kx>=0) + { + aa=dd->a+kx; b0 = b1 = aa[0]*(1-x) + x*aa[1]; + } + else b0 = b1 = dd->a[0]; + } + if(dx) *dx = kx>=0?aa[1]-aa[0]:0; + if(dy) *dy = ky>=0?aa[dn]-aa[0]:0; + if(dz) *dz = b1-b0; + } + else + { + long nx=d->GetNx(), ny=d->GetNy(), nz=d->GetNz(); + kx = kx>=0 ? kx:0; kx = kx=0 ? ky:0; ky = ky=0 ? kz:0; kz = kz=0) + { + a0 = d->v(kx,ky,kz); a1 = d->v(kx+1,ky,kz); a2 = d->v(kx,ky+1,kz); + b0 = a0*(1-x-y+x*y) + x*(1-y)*a1 + y*(1-x)*a2 + x*y*d->v(kx+1,ky+1,kz);; + b1 = d->v(kx,ky,kz+1)*(1-x-y+x*y) + x*(1-y)*d->v(kx+1,ky,kz+1) + y*(1-x)*d->v(kx,ky+1,kz+1) + x*y*d->v(kx+1,ky+1,kz+1); + } + else + { + z=0; + if(ky>=0) + { + a0 = d->v(kx,ky); a1 = d->v(kx+1,ky); a2 = d->v(kx,ky+1); + b0 = b1 = a0*(1-x-y+x*y) + x*(1-y)*a1 + y*(1-x)*a2 + x*y*d->v(kx+1,ky+1); + } + else if(kx>=0) + { + a2=a0 = d->v(kx); a1 = d->v(kx+1); b0 = b1 = a0*(1-x) + x*a1; + } + else b0 = b1 = dd->a[0]; + } + if(dx) *dx = a1-a0; + if(dy) *dy = a2-a0; + if(dz) *dz = b1-b0; + } + return b0 + z*(b1-b0); +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_linear(HCDT d, mreal x,mreal y,mreal z) +{ return mgl_data_linear_ext(d, x,y,z, 0,0,0); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_spline(HCDT d, mreal x,mreal y,mreal z) +{ + const mglData *dd=dynamic_cast(d); + if(!d) return 0; // NOTE: don't support general arrays + return dd->ny*dd->nz==1?mglSpline1st(dd->a,dd->nx,x):mglSpline3st(dd->a,dd->nx,dd->ny,dd->nz,x,y,z); +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_spline_ext(HCDT d, mreal x,mreal y,mreal z, mreal *dx,mreal *dy,mreal *dz) +{ + const mglData *dd=dynamic_cast(d); + if(!d) return 0; // NOTE: don't support general arrays + return mglSpline3t(dd->a,dd->nx,dd->ny,dd->nz,x,y,z,dx,dy,dz); +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_spline_(uintptr_t *d, mreal *x,mreal *y,mreal *z) +{ return mgl_data_spline(_DA_(d),*x,*y,*z); } +mreal MGL_EXPORT mgl_data_linear_(uintptr_t *d, mreal *x,mreal *y,mreal *z) +{ return mgl_data_linear(_DA_(d),*x,*y,*z); } +mreal MGL_EXPORT mgl_data_spline_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz) +{ return mgl_data_spline_ext(_DA_(d),*x,*y,*z,dx,dy,dz); } +mreal MGL_EXPORT mgl_data_linear_ext_(uintptr_t *d, mreal *x,mreal *y,mreal *z, mreal *dx,mreal *dy,mreal *dz) +{ return mgl_data_linear_ext(_DA_(d),*x,*y,*z,dx,dy,dz); } +mreal MGL_EXPORT mgl_data_solve_1d_(uintptr_t *d, mreal *val, int *spl, int *i0) +{ return mgl_data_solve_1d(_DA_(d),*val, *spl, *i0); } +uintptr_t MGL_EXPORT mgl_data_solve_(uintptr_t *d, mreal *val, const char *dir, uintptr_t *i0, int *norm,int) +{ return uintptr_t(mgl_data_solve(_DA_(d),*val, *dir, _DA_(i0), *norm)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_crop(HMDT d, long n1, long n2, char dir) +{ + long nx=d->nx,ny=d->ny,nz=d->nz, nn; + mreal *b; + if(n1<0) n1=0; + switch(dir) + { + case 'x': + n2 = n2>0 ? n2 : nx+n2; + if(n2<0 || n2>=nx || n2a+nx*i+n1,nn*sizeof(mreal)); + d->nx = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; d->NewId(); + break; + case 'y': + n2 = n2>0 ? n2 : ny+n2; + if(n2<0 || n2>=ny || n2a+nx*(n1+i+ny*j),nx*sizeof(mreal)); + d->ny = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; + break; + case 'z': + n2 = n2>0 ? n2 : nz+n2; + if(n2<0 || n2>=nz || n2a+nx*ny*n1,nn*nx*ny*sizeof(mreal)); + d->nz = nn; if(!d->link) delete []d->a; + d->a = b; d->link=false; + break; + } +} +void MGL_EXPORT mgl_data_crop_(uintptr_t *d, int *n1, int *n2, const char *dir,int) +{ mgl_data_crop(_DT_,*n1,*n2,*dir); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_last(HCDT d, const char *cond, long *i, long *j, long *k) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + if(!cond) cond = "u"; + mglFormula eq(cond); + if(*i<0 || *i>=nx) *i=nx; + if(*j<0 || *j>=ny) *j=ny-1; + if(*k<0 || *k>=nz) *k=nz-1; + register long i0 = *i+nx*(*j+ny*(*k))-1; + mreal x,y,z,dx=nx>1?1/(nx-1.):0,dy=ny>1?1/(ny-1.):0,dz=nz>1?1/(nz-1.):0; + for(;i0>=0;i0--) + { + x = dx*(i0%nx); y = dy*((i0/nx)%ny); z = dz*(i0/(nx*ny)); + if(eq.Calc(x,y,z,d->vthr(i0))) break; + } + *i = i0%nx; *j = (i0/nx)%ny; *k = i0/(nx*ny); + return i0>=0 ? d->vthr(i0) : NAN; // NOTE: Return NAN if false +} +mreal MGL_EXPORT mgl_data_last_(uintptr_t *d, const char *cond, int *i, int *j, int *k, int l) +{ long ii=*i,jj=*j,kk=*k; char *s=new char[l+1]; memcpy(s,cond,l); s[l]=0; + mreal res = mgl_data_last(_DT_,s,&ii,&jj,&kk); *i=ii; *j=jj; *k=kk; + delete []s; return res; } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_first(HCDT d, const char *cond, long *i, long *j, long *k) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + if(!cond) cond = "u"; + mglFormula eq(cond); + if(*i<0 || *i>=nx) *i=nx; + if(*j<0 || *j>=ny) *j=ny-1; + if(*k<0 || *k>=nz) *k=nz-1; + register long i0 = *i+nx*(*j+ny*(*k))-1; + mreal x,y,z,dx=nx>1?1/(nx-1.):0,dy=ny>1?1/(ny-1.):0,dz=nz>1?1/(nz-1.):0; + for(;i0vthr(i0))) break; + } + *i = i0%nx; *j = (i0/nx)%ny; *k = i0/(nx*ny); + return i0vthr(i0) : NAN; // NOTE: Return NAN if false +} +mreal MGL_EXPORT mgl_data_first_(uintptr_t *d, const char *cond, int *i, int *j, int *k, int l) +{ long ii=*i,jj=*j,kk=*k; char *s=new char[l+1]; memcpy(s,cond,l); s[l]=0; + mreal res = mgl_data_first(_DT_,s,&ii,&jj,&kk); *i=ii; *j=jj; *k=kk; + delete []s; return res; } +//----------------------------------------------------------------------------- +long MGL_EXPORT mgl_data_find(HCDT d, const char *cond, char dir, long i, long j, long k) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + register long m=-1; + if(!cond) cond = "u"; + mglFormula eq(cond); + mreal x=i/(nx-1.),y=j/(ny-1.),z=k/(nz-1.); + if(dir=='x' && nx>1) for(m=i;mv(m,j,k))) break; + if(dir=='y' && ny>1) for(m=j;mv(i,m,k))) break; + if(dir=='z' && nz>1) for(m=k;mv(i,j,m))) break; + return m; +} +int MGL_EXPORT mgl_data_find_(uintptr_t *d, const char *cond, char *dir, int *i, int *j, int *k, int l, int) +{ char *s=new char[l+1]; memcpy(s,cond,l); s[l]=0; + int res = mgl_data_find(_DT_,s,*dir,*i,*j,*k); delete []s; return res; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_find_any(HCDT d, const char *cond) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + bool cc = false; + if(!cond || *cond==0) cond = "u"; + mglFormula eq(cond); +#pragma omp parallel for collapse(3) + for(long k=0;kv(i,j,k))) cc = true; + } + return cc; +} +int MGL_EXPORT mgl_data_find_any_(uintptr_t *d, const char *cond, int l) +{ char *s=new char[l+1]; memcpy(s,cond,l); s[l]=0; + int res = mgl_data_find_any(_DT_,s); delete []s; return res; } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_momentum_val(HCDT dd, char dir, mreal *x, mreal *w, mreal *s, mreal *k) +{ + long nx=dd->GetNx(),ny=dd->GetNy(),nz=dd->GetNz(); + mreal i0=0,i1=0,i2=0,i3=0,i4=0; + const mglData *md = dynamic_cast(dd); + if(dd) switch(dir) + { + case 'x': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ia[i]; + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + case 'y': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ia[i]; + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + case 'z': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ia[i]; + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + default: // "self-dispersion" + i0 = nx*ny*nz; +#pragma omp parallel for reduction(+:i1,i2,i3,i4) + for(long i=0;ia[i], t = v*v; + i1+= v; i2+= t; + i3+= v*t; i4+= t*t; + } + } + else switch(dir) + { + case 'x': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ivthr(i); + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + case 'y': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ivthr(i); + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + case 'z': +#pragma omp parallel for reduction(+:i0,i1,i2,i3,i4) + for(long i=0;ivthr(i); + i0+= v; i1+= v*d; i2+= v*t; + i3+= v*d*t; i4+= v*t*t; + } + break; + default: // "self-dispersion" + i0 = nx*ny*nz; +#pragma omp parallel for reduction(+:i1,i2,i3,i4) + for(long i=0;ivthr(i), t = v*v; + i1+= v; i2+= t; + i3+= v*t; i4+= t*t; + } + } + if(i0==0) return 0; + register mreal d=i1/i0; + if(x) *x=d; + if(w) *w=i2>d*d*i0 ? sqrt(i2/i0-d*d) : 0; + if(s) *s=i3/i0; + if(k) *k=i4/(i0*3); + return i0; +} +mreal MGL_EXPORT mgl_data_momentum_val_(uintptr_t *d, char *dir, mreal *m, mreal *w, mreal *s, mreal *k,int) +{ mreal mm,ww,ss,kk,aa; + aa = mgl_data_momentum_val(_DT_,*dir,&mm,&ww,&ss,&kk); + *m=mm; *w=ww; *s=ss; *k=kk; return aa; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_norm_slice(HMDT d, mreal v1,mreal v2,char dir,long keep_en,long sym) +{ + long nx=d->nx, ny=d->ny, nz=d->nz; + mreal *a=d->a; + mglData b(*d); + register mreal e0=1, e, m1, m2, aa; + if(sym) { v2 = -v1>v2 ? -v1:v2; v1 = -v2; } + if(dir=='z' && nz>1) + { +//#pragma omp parallel for private(m1,m2,aa,e,e0) // TODO add omp comparison here + for(long k=0;kaa ? m2 : aa; + e += aa*aa; + } + if(m1==m2) m2+=1; + if(sym) { m2 = -m1>m2 ? -m1:m2; m1 = -m2; } + if(keep_en && k) e = e0>0?sqrt(e/e0):1; + else { e0 = e; e=1; } + for(long i=0;i1) + { +//#pragma omp parallel for private(m1,m2,aa,e,e0) // TODO add omp comparison here + for(long j=0;jaa ? m2 : aa; + e += aa*aa; + } + if(m1==m2) m2+=1; + if(sym) { m2 = -m1>m2 ? -m1:m2; m1 = -m2; } + if(keep_en && j) e = e0>0?sqrt(e/e0):1; + else { e0 = e; e=1; } +#pragma omp parallel for collapse(2) + for(long k=0;k1) + { +//#pragma omp parallel for private(m1,m2,aa,e,e0) // TODO add omp comparison here + for(long i=0;iaa ? m2 : aa; + e += aa*aa; + } + if(m1==m2) m2+=1; + if(sym) { m2 = -m1>m2 ? -m1:m2; m1 = -m2; } + if(keep_en && i) e = e0>0?sqrt(e/e0):1; + else { e0 = e; e=1; } +#pragma omp parallel for + for(long k=0;ka, b.a, nx*ny*nz*sizeof(mreal)); +} +void MGL_EXPORT mgl_data_norm_slice_(uintptr_t *d, mreal *v1,mreal *v2,char *dir,int *keep_en,int *sym,int ) +{ mgl_data_norm_slice(_DT_,*v1,*v2,*dir,*keep_en,*sym); } +//----------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_data_info(HCDT d) // NOTE: Not thread safe function! +{ + static char buf[512]; + char s[128]; buf[0]=0; + snprintf(s,128,"nx = %ld\tny = %ld\tnz = %ld\n",d->GetNx(),d->GetNy(),d->GetNz()); strcat(buf,s); + + long i=0,j=0,k=0; + mreal A=0,Wa=0,X=0,Y=0,Z=0,Wx=0,Wy=0,Wz=0, b; + b = mgl_data_max_int(d,&i,&j,&k); + snprintf(s,128,"Maximum is %g\t at x = %ld\ty = %ld\tz = %ld\n", b,i,j,k); strcat(buf,s); + b = mgl_data_min_int(d,&i,&j,&k); + snprintf(s,128,"Minimum is %g\t at x = %ld\ty = %ld\tz = %ld\n", b,i,j,k); strcat(buf,s); + + mgl_data_momentum_val(d,'a',&A,&Wa,0,0); mgl_data_momentum_val(d,'x',&X,&Wx,0,0); + mgl_data_momentum_val(d,'y',&Y,&Wy,0,0); mgl_data_momentum_val(d,'z',&Z,&Wz,0,0); + snprintf(s,128,"Averages are:\n = %g\t = %g\t = %g\t = %g\n", A,X,Y,Z); strcat(buf,s); + snprintf(s,128,"Widths are:\nWa = %g\tWx = %g\tWy = %g\tWz = %g\n", Wa,Wx,Wy,Wz); strcat(buf,s); + return buf; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_insert(HMDT d, char dir, long at, long num) +{ + if(num<1) return; + at = at<0 ? 0:at; + long nn, nx=d->nx, ny=d->ny, nz=d->nz; + mglData b; + if(dir=='x') + { + if(at>nx) at=nx; + nn=nx+num; b.Create(nn,ny,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nn*k, d->a+nx*k,at*sizeof(mreal)); + if(ata+at+nx*k,(nx-at)*sizeof(mreal)); + for(long i=0;ia[nx*k+at]; // copy values + } + d->Set(b); nx+=num; + } + if(dir=='y') + { + if(at>ny) at=ny; + nn=num+ny; b.Create(nx,nn,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nx*nn*k, d->a+nx*ny*k,at*nx*sizeof(mreal)); + if(ata+nx*(at+ny*k),(ny-at)*nx*sizeof(mreal)); + for(long i=0;ia+nx*(ny*k+at),nx*sizeof(mreal)); + } + d->Set(b); ny+=num; + } + if(dir=='z') + { + if(at>nz) at=nz; + b.Create(nx,ny,nz+num); + if(at>0) memcpy(b.a, d->a,at*nx*ny*sizeof(mreal)); + if(ata+nx*ny*at,(nz-at)*nx*ny*sizeof(mreal)); +#pragma omp parallel for + for(long i=0;ia+nx*ny*at,nx*ny*sizeof(mreal)); + d->Set(b); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_delete(HMDT d, char dir, long at, long num) +{ + if(num<1 || at<0) return; + mglData b; + long nx=d->nx, ny=d->ny, nz=d->nz, nn; + if(dir=='x') + { + if(at+num>=nx) return; + nn=nx-num; b.Create(nn,ny,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nn*k, d->a+nx*k,at*sizeof(mreal)); + memcpy(b.a+at+nn*k, d->a+at+num+nx*k,(nx-at-num)*sizeof(mreal)); + } + d->Set(b); nx-=num; + } + if(dir=='y') + { + if(at+num>=ny) return; + nn=ny-num; b.Create(nx,nn,nz); +#pragma omp parallel for + for(long k=0;k0) memcpy(b.a+nx*nn*k, d->a+nx*ny*k,at*nx*sizeof(mreal)); + memcpy(b.a+nx*(at+nn*k), d->a+nx*(at+num+ny*k),(ny-at-num)*nx*sizeof(mreal)); + } + d->Set(b); ny-=num; + } + if(dir=='z') + { + if(at+num>=nz) return; + b.Create(nx,ny,nz-num); + if(at>0) memcpy(b.a, d->a,at*nx*ny*sizeof(mreal)); + memcpy(b.a+nx*ny*at, d->a+nx*ny*(at+num),(nz-at-num)*nx*ny*sizeof(mreal)); + d->Set(b); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_insert_(uintptr_t *d, const char *dir, int *at, int *num, int) +{ mgl_data_insert(_DT_,*dir,*at,*num); } +void MGL_EXPORT mgl_data_delete_(uintptr_t *d, const char *dir, int *at, int *num, int) +{ mgl_data_delete(_DT_,*dir,*at,*num); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_spline5(mreal y1[5], mreal y2[5], long n1, long n2, mreal d, mreal &dy) +{ + mreal a1[4], a2[4], f0,d0,t0,f1,d1,t1, b[6]; + a1[0] = -(3*y1[4]-16*y1[3]+36*y1[2]-48*y1[1]+25*y1[0])/12; + a1[1] = (11*y1[4]-56*y1[3]+114*y1[2]-104*y1[1]+35*y1[0])/12; + a1[2] = -(3*y1[4]-14*y1[3]+24*y1[2]-18*y1[1]+5*y1[0])/4; + a1[3] = (y1[4]-4*y1[3]+6*y1[2]-4*y1[1]+y1[0])/6; + a2[0] = -(3*y2[4]-16*y2[3]+36*y2[2]-48*y2[1]+25*y2[0])/12; + a2[1] = (11*y2[4]-56*y2[3]+114*y2[2]-104*y2[1]+35*y2[0])/12; + a2[2] = -(3*y2[4]-14*y2[3]+24*y2[2]-18*y2[1]+5*y2[0])/4; + a2[3] = (y2[4]-4*y2[3]+6*y2[2]-4*y2[1]+y2[0])/6; + n2++; + f0 = y1[n1]; d0 = a1[0]+n1*(a1[1]+n1*(a1[2]+n1*a1[3])); t0 = a1[1]/2+a1[2]*n1+1.5*n2*n2*a2[3]; + f1 = y2[n2]; d1 = a2[0]+n2*(a2[1]+n2*(a2[2]+n2*a2[3])); t1 = a2[1]/2+a2[2]*n2+1.5*n2*n2*a2[3]; + b[0] = f0; b[1] = d0; b[2] = t0; + b[3] = 10*(f1-f0)+t1-3*t0-4*d1-6*d0; + b[4] = 15*(f0-f1)-2*t1+3*t0+7*d1+8*d0; + b[5] = 6*(f1-f0)+t1-t0-3*d1-3*d0; + dy = b[1] + d*(2*b[2]+d*(3*b[3]+d*(4*b[4]+d*5*b[5]))); + return b[0] + d*(b[1]+d*(b[2]+d*(b[3]+d*(b[4]+d*b[5])))); +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_spline3(mreal y1[3], mreal y2[3], long n1, long n2, mreal d, mreal &dy) +{ + mreal a1[2], a2[2], f0,d0,d1,f1, b[4]; + a1[0] = -(y1[2]-4*y1[1]+3*y1[0])/2; + a1[1] = y1[2]-2*y1[1]+y1[0]; + a2[0] = -(y2[2]-4*y2[1]+3*y2[0])/2; + a2[1] = y2[2]-2*y2[1]+y2[0]; + n2++; + f0 = y1[n1]; d0 = a1[0]+a1[1]*n1; + f1 = y2[n2]; d1 = a2[0]+a2[1]*n2; + b[0] = f0; b[1] = d0; + b[2] = 3*(f1-f0)-d1-2*d0; + b[3] = 2*(f0-f1)+d1+d0; + dy = b[1] + d*(2*b[2]+d*3*b[3]); + return b[0] + d*(b[1]+d*(b[2]+d*b[3])); +} +//----------------------------------------------------------------------------- +/*mreal mglData::Spline5(mreal x,mreal y,mreal z,mreal &dx,mreal &dy,mreal &dz) const +{ + mreal res=0; + if(nx<5) return 0; // not interpolation for points < 5 !!! + dx = dy = dz = 0; x*=nx-1; y*=ny-1; z*=nz-1; + if(ny==1 && nz==1) // 1D case + { + long n = long(x), n1 = n>1 ? 2:n, n2 = n0?int((x)/(y)+0.5):int((x)/(y)-0.5)) +void MGL_NO_EXPORT mgl_omod(mreal *a, mreal da, int nx, int n) +{ + register long i,ii; + bool qq=true; + register mreal q; + for(i=1;ip[2], nn=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia+i, t->b[0], nz, nn); + return 0; +} +MGL_NO_EXPORT void *mgl_sew_y(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nn=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia+(i%nx)+nx*ny*(i/nx), t->b[0], ny, nx); + return 0; +} +MGL_NO_EXPORT void *mgl_sew_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], nn=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia+i*nx, t->b[0], nx, 1); + return 0; +} +void MGL_EXPORT mgl_data_sew(HMDT d, const char *dirs, mreal delta) +{ + if(!dirs || *dirs==0) return; + long nx=d->nx, ny=d->ny, nz=d->nz; + long p[3]={nx,ny,nz}; + mreal da = delta; + if(strchr(dirs,'x') && nx>1) mglStartThread(mgl_sew_x,0,nz*ny,d->a,&da,0,p); + if(strchr(dirs,'y') && ny>1) mglStartThread(mgl_sew_y,0,nz*nx,d->a,&da,0,p); + if(strchr(dirs,'z') && nz>1) mglStartThread(mgl_sew_z,0,nx*ny,d->a,&da,0,p); +} +void MGL_EXPORT mgl_data_sew_(uintptr_t *d, const char *dirs, mreal *da, int l) +{ char *s=new char[l+1]; memcpy(s,dirs,l); s[l]=0; + mgl_data_sew(_DT_,s,*da); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_put_val(HMDT d, mreal val, long xx, long yy, long zz) +{ + register long nx=d->nx, ny=d->ny, nz=d->nz; + if(xx>=nx || yy>=ny || zz>=nz) return; + mreal *a=d->a; + if(xx<0 && yy<0 && zz<0) +#pragma omp parallel for + for(long i=0;inx, ny=d->ny, nz=d->nz; + if(xx>=nx || yy>=ny || zz>=nz) return; + const mglData *mv = dynamic_cast(v); + mreal *a=d->a, vv=v->v(0); + const mreal *b = mv?mv->a:0; + long vx=v->GetNx(), vy=v->GetNy(), vz=v->GetNz(); + if(xx<0 && yy<0 && zz<0) // whole array + { + if(vx>=nx && vy>=ny && vz>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j,k); } + else if(vx>=nx && vy>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx && vy>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=ny && vy>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=ny) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx && vy>=nz) +#pragma omp parallel for + for(long ii=0;iiv(i,j); } + else if(vx>=nx) +#pragma omp parallel for + for(long ii=0;iiv(i); } + else +#pragma omp parallel for + for(long ii=0;ii=nx) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;i=ny) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;i=nz) +#pragma omp parallel for + for(long i=0;iv(i); + else +#pragma omp parallel for + for(long i=0;ip[0], ny=t->p[1], nz=t->p[2], nn=t->n; + mreal *b=t->a,au,av,aw,xu,xv,xw,yu,yv,yw,zu,zv,zw; + const mreal *a=t->b, *x=t->c, *y=t->d, *z=t->e; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for private(au,av,aw,xu,xv,xw,yu,yv,yw,zu,zv,zw) +#endif + for(long i0=t->id;i0p[0], ny=t->p[1], nn=t->n, same=t->p[2]; + mreal *b=t->a,au,av,xu,xv,yu,yv; + const mreal *a=t->b, *x=t->c, *y=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for private(au,av,xu,xv,yu,yv) +#endif + for(long i0=t->id;i0p[0], nn=t->n, same=t->p[1]; + mreal *b=t->a,au,xu; + const mreal *a=t->b, *x=t->c; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for private(au,xu) +#endif + for(long i0=t->id;i0(v1); + const mglData *y = dynamic_cast(v2); + const mglData *z = dynamic_cast(v3); + long nx=d->nx,ny=d->ny,nz=d->nz, nn=nx*ny*nz; + if(nx<2 || ny<2) return; + mreal *b = new mreal[nn]; memset(b,0,nn*sizeof(mreal)); + long p[3]={nx,ny,nz}; + + if(x&&y&&z && x->nx*x->ny*x->nz==nn && y->nx*y->ny*y->nz==nn && z->nx*z->ny*z->nz==nn) + mglStartThread(mgl_diff_3,0,nn,b,d->a,x->a,p,0,y->a,z->a); + else if(x&&y && x->nx*x->ny==nx*ny && y->nx*y->ny==nx*ny) + { + p[2]=(x->nz==nz && y->nz==nz); + mglStartThread(mgl_diff_2,0,nn,b,d->a,x->a,p,0,y->a); + } + else if(x && x->nx==nx) + { + p[1]=(x->ny*x->nz==ny*nz); + mglStartThread(mgl_diff_1,0,nn,b,d->a,x->a,p,0,0); + } + memcpy(d->a,b,nn*sizeof(mreal)); delete []b; +} +void MGL_EXPORT mgl_data_diff_par_(uintptr_t *d, uintptr_t *v1, uintptr_t *v2, uintptr_t *v3) +{ mgl_data_diff_par(_DT_,_DA_(v1),_DA_(v2),_DA_(v3)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_value(HMDT dat, mreal v, long i, long j, long k) +{ if(i>=0 && inx && j>=0 && jny && k>=0 && knz) dat->a[i+dat->nx*(j+dat->ny*k)]=v; } +void MGL_EXPORT mgl_data_set_value_(uintptr_t *d, mreal *v, int *i, int *j, int *k) +{ mgl_data_set_value(_DT_,*v,*i,*j,*k); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_get_value(HCDT dat, long i, long j, long k) +{ return (i>=0 && iGetNx() && j>=0 && jGetNy() && k>=0 && kGetNz()) ? dat->v(i,j,k):NAN; } +mreal MGL_EXPORT mgl_data_get_value_(uintptr_t *d, int *i, int *j, int *k) +{ return mgl_data_get_value(_DA_(d),*i,*j,*k); } +//----------------------------------------------------------------------------- +MGL_EXPORT mreal *mgl_data_data(HMDT dat) { return dat->a; } +//----------------------------------------------------------------------------- +MGL_EXPORT mreal *mgl_data_value(HMDT dat, long i,long j,long k) +{ register long ii=i*dat->nx*(j+dat->ny*k); + return ii>=0 && iiGetNN() ? dat->a+ii : 0; } +//----------------------------------------------------------------------------- +long MGL_EXPORT mgl_data_get_nx(HCDT dat) { return dat->GetNx(); } +long MGL_EXPORT mgl_data_get_ny(HCDT dat) { return dat->GetNy(); } +long MGL_EXPORT mgl_data_get_nz(HCDT dat) { return dat->GetNz(); } +long MGL_EXPORT mgl_data_get_nx_(uintptr_t *d) { return _DA_(d)->GetNx(); } +long MGL_EXPORT mgl_data_get_ny_(uintptr_t *d) { return _DA_(d)->GetNy(); } +long MGL_EXPORT mgl_data_get_nz_(uintptr_t *d) { return _DA_(d)->GetNz(); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_join(HMDT d, HCDT v) +{ + long nx=d->nx, ny=d->ny, nz=d->nz, k=nx*ny*nz; + const mglData *mv = dynamic_cast(v); + long vx=v->GetNx(), vy=v->GetNy(), vz=v->GetNz(); + + if(nx==vx && ny==vy && (nz>1 || vz>1)) + { + mreal *b = new mreal[nx*ny*(nz+vz)]; + memcpy(b,d->a,nx*ny*nz*sizeof(mreal)); + if(mv) memcpy(b+nx*ny*nz,mv->a,nx*ny*vz*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; d->nz += vz; + d->a = b; d->link=false; d->NewId(); + } + else if(nx==vx && (ny>1 || vy>1)) + { + ny *= nz; vy *= vz; + mreal *b = new mreal[nx*(ny+vy)]; + memcpy(b,d->a,nx*ny*sizeof(mreal)); + if(mv) memcpy(b+nx*ny,mv->a,nx*vy*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; + d->nz = 1; d->ny = ny+vy; + d->a = b; d->link=false; d->NewId(); + } + else + { + nx *= ny*nz; vx *= vy*vz; + mreal *b = new mreal[nx+vx]; + memcpy(b,d->a,nx*sizeof(mreal)); + if(mv) memcpy(b+nx,mv->a,vx*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(!d->link) delete []d->a; + d->nz = d->ny = 1; d->nx = nx+vx; + d->a = b; d->link=false; d->NewId(); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_join_(uintptr_t *d, uintptr_t *val) +{ mgl_data_join(_DT_,_DA_(val)); } +//----------------------------------------------------------------------------- +mreal MGL_NO_EXPORT mgl_index_1(mreal v, const mglData *dat, mreal acx) +{ + long mx=dat->nx; + mreal d,d1=0,d2=mx-1,v1,v2; + v1 = mglSpline1t(dat->a,mx,d1); + v2 = mglSpline1t(dat->a,mx,d2); + long count=0; + + if(v1==v) return d1; + if(v2==v) return d2; + if((v1-v)*(v2-v)>0) return NAN; + do + { + d = count<10?(d2-d1)*(v-v1)/(v2-v1)+d1:(d1+d2)/2; count++; + register mreal val = mglSpline1st(dat->a,mx,d); + if(fabs(val-v)1e-3); + return d; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_refill_x(HMDT dat, HCDT xdat, HCDT vdat, mreal x1, mreal x2, long sl) +{ + long nx=dat->nx,mx=vdat->GetNx(),nn=dat->ny*dat->nz; + mreal acx=1e-6*fabs(x2-x1); + const mglData *xxd=dynamic_cast(xdat); + const mglData *vvd=dynamic_cast(vdat); + if(!xxd || !vvd || mx!=xxd->nx) return; // incompatible dimensions and for mglData only +#pragma omp parallel for + for(long i=0;i(vvd->a,mx,u); + if(sl<0) for(long j=0;ja[i+j*nx] = d; + else dat->a[i+sl*nx] = d; + } +} +//----------------------------------------------------------------------------- +mglPoint MGL_NO_EXPORT mgl_index_2(mreal x, mreal y, const mglData *xdat, const mglData *ydat, mreal acx, mreal acy) +{ + long mx=xdat->nx, my=xdat->ny; + mreal u=fabs(x),u1=0,u2=mx-1, v=fabs(y),v1=0,v2=my-1; + mreal x11 = mgl_data_spline(xdat,u1,v1,0), y11 = mgl_data_spline(ydat,u1,v1,0); + mreal x21 = mgl_data_spline(xdat,u2,v1,0), y21 = mgl_data_spline(ydat,u2,v1,0); + mreal x12 = mgl_data_spline(xdat,u1,v2,0), y12 = mgl_data_spline(ydat,u1,v2,0); + mreal x22 = mgl_data_spline(xdat,u2,v2,0), y22 = mgl_data_spline(ydat,u2,v2,0); + long count=0; + + if(fabs(x11-x)0 && (x11-x)*(x12-x)*(x21-x)>0) return mglPoint(NAN,NAN); + if((y11-y)*(y12-y)*(y21-y)*(y22-y)>0 && (y11-y)*(y12-y)*(y21-y)>0) return mglPoint(NAN,NAN); + + do + { + if(count<10) + { + register mreal dx0=x-x11, dx1=x21-x11, dx2=x12-x11, dx3=x22+x11-x12-x21; + register mreal dy0=y-y11, dy1=y21-y11, dy2=y12-y11, dy3=y22+y11-y12-y21; + register mreal t1 = dx0*dx0*dy3*dy3 + 2*dx0*dx1*dy2*dy3 + 2*dx0*dx2*dy1*dy3 - + 2*dx0*dx3*dy0*dy3 - 4*dx1*dx2*dy0*dy3 + dx1*dx1*dy2*dy2 - + 4*dx0*dx3*dy1*dy2 - 2*dx1*dx2*dy1*dy2 + 2*dx1*dx3*dy0*dy2 + + dx2*dx2*dy1*dy1 + 2*dx2*dx3*dy0*dy1 + dx3*dx3*dy0*dy0, + t2 = dx2*dy1+dx3*dy0-dx0*dy3-dx1*dy2, t3 = 2*(dx2*dy3-dx3*dy2); + if(t1<0 || t3==0) { count=10; continue; } + t1 = sqrt(t1); v = (t2-t1)/t3; + if(v<0 || v>1) v = (t2+t1)/t3; + u = (dx0-dx2*v)/(dx1+dx3*v); + if(u<0 || v<0 || u>1 || v>1) { count=10; continue; } + u = u1+(u2-u1)*u; v = v1+(v2-v1)*v; count++; + } + else { u = (u1+u2)/2; v = (v1+v2)/2; } + + mreal tx = mgl_data_spline(xdat,u,v,0), ty = mgl_data_spline(ydat,u,v,0); + if(fabs(tx-x)0 || (x11-x)*(sx1-x)*(tx1-x)>0) && ((y11-y)*(sy1-y)*(ty1-y)*(ty-y)>0 && (y11-y)*(sy1-y)*(ty1-y)>0) ) + { x12 = tx1; y12 = ty1; x21 = sx1; y21 = sy1; x22 = tx; y22 = ty; u2 = u; v2 = v; } + if( ((tx1-x)*(tx-x)*(x12-x)*(sx2-x)>0 || (tx1-x)*(tx-x)*(x12-x)>0) && ((ty1-y)*(ty-y)*(y12-y)*(sy2-y)>0 && (ty1-y)*(ty-y)*(y12-y)>0) ) + { x11 = tx1; y11 = ty1; x21 = tx; y21 = ty; x22 = sx2; y22 = sy2; u2 = u; v1 = v; } + if( ((tx-x)*(sx2-x)*(tx2-x)*(x22-x)>0 || (tx-x)*(sx2-x)*(tx2-x)>0) && ((ty-y)*(sy2-y)*(ty2-y)*(y22-y)>0 && (ty-y)*(sy2-y)*(ty2-y)>0) ) + { x11 = tx; y11 = ty; x12 = sx2; y12 = sy2; x21 = tx2; y21 = ty2; u1 = u; v1 = v; } + if( ((sx1-x)*(tx-x)*(x21-x)*(tx2-x)>0 || (sx1-x)*(tx-x)*(x21-x)>0) && ((sy1-y)*(ty-y)*(y21-y)*(ty2-y)>0 && (sy1-y)*(ty-y)*(y21-y)>0) ) + { x11 = sx1; y11 = sy1; x12 = tx; y12 = ty; x22 = tx2; y22 = ty2; u1 = u; v2 = v; } + } while(fabs(u2-u1)>1e-3 || fabs(v2-v1)>1e-3); + return mglPoint(u,v); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_refill_xy(HMDT dat, HCDT xdat, HCDT ydat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, long sl) +{ + long nx=dat->nx,ny=dat->ny,nz=dat->nz,mx=vdat->GetNx(),my=vdat->GetNy(),nn=nx*ny; + const mglData *xxd=dynamic_cast(xdat); + const mglData *yyd=dynamic_cast(ydat); + const mglData *vvd=dynamic_cast(vdat); + if(!xxd || !vvd || !yyd) return; // for mglData only + bool both=(xdat->GetNN()==vdat->GetNN() && ydat->GetNN()==vdat->GetNN()); + if(!both && (xdat->GetNx()!=mx || ydat->GetNx()!=my)) return; // incompatible dimensions + mreal acx=1e-6*fabs(x2-x1), acy=1e-6*fabs(y2-y1); + if(both) + mgl_data_grid_xy(dat,xdat,ydat,vdat,x1,x2,y1,y2); +/*#pragma omp parallel for collapse(2) + for(long j=0;ja[i0+k*nn] = d; + else dat->a[i0+sl*nn] = d; + }*/ + else + { + mglData u(nx), v(ny); +#pragma omp parallel for + for(long i=0;ia[i0+k*nn] = d; + else dat->a[i0+sl*nn] = d; + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_refill_xyz(HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, mreal x1, mreal x2, mreal y1, mreal y2, mreal z1, mreal z2) +{ + long nx=dat->nx,ny=dat->ny,nz=dat->nz,mx=vdat->GetNx(),my=vdat->GetNy(),mz=vdat->GetNz(); + const mglData *xxd=dynamic_cast(xdat); + const mglData *yyd=dynamic_cast(ydat); + const mglData *zzd=dynamic_cast(zdat); + const mglData *vvd=dynamic_cast(vdat); + if(!xxd || !vvd || !yyd || !zzd) return; // for mglData only + bool both=(xdat->GetNN()==vdat->GetNN() && ydat->GetNN()==vdat->GetNN() && zdat->GetNN()==vdat->GetNN()); + if(!both && (xdat->GetNx()!=mx || ydat->GetNx()!=my || zdat->GetNx()!=mz)) return; // incompatible dimensions + mreal acx=1e-6*fabs(x2-x1), acy=1e-6*fabs(y2-y1), acz=1e-6*fabs(z2-z1); + if(both) +#pragma omp parallel for collapse(3) + for(long k=0;k50) { dx=NAN; break; } count++; + dd = -dxx*dyy*dzz+dxy*dyx*dzz+dxx*dyz*dzy-dxz*dyx*dzy-dxy*dyz*dzx+dxz*dyy*dzx; + dx += ((dyz*dzy-dyy*dzz)*(xx-vx)+(dxy*dzz-dxz*dzy)*(yy-vy)+(dxz*dyy-dxy*dyz)*(zz-vz))/dd; + dy += ((dyx*dzz-dyz*dzx)*(xx-vx)+(dxz*dzx-dxx*dzz)*(yy-vy)+(dxx*dyz-dxz*dyx)*(zz-vz))/dd; + dz += ((dyy*dzx-dyx*dzy)*(xx-vx)+(dxx*dzy-dxy*dzx)*(yy-vy)+(dxy*dyx-dxx*dyy)*(zz-vz))/dd; + vx = mgl_data_spline_ext(xdat,dx,dy,dz,&dxx,&dxy,&dxz); + vy = mgl_data_spline_ext(ydat,dx,dy,dz,&dyx,&dyy,&dyz); + vz = mgl_data_spline_ext(zdat,dx,dy,dz,&dzx,&dzy,&dzz); + } while(fabs(xx-vx)>acx && fabs(yy-vy)>acy && fabs(zz-vz)>acz); // this valid for linear interpolation + dat->a[i+nx*(j+ny*k)] = mgl_isnan(dx)?NAN:mgl_data_spline(vdat,dx,dy,dz); + } + else + { + mglData u(nx), v(ny), w(nz); +#pragma omp parallel for + for(long i=0;ia[i+nx*(j+ny*k)] = mgl_data_spline(vdat,u.a[i],v.a[j],w.a[k]); + } +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_eval(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], n1=t->p[3], nn=t->n; + const mreal *a=t->b, *ii=t->c, *jj=t->d, *kk=t->e; + mreal *b=t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;i(a,nx,ny,nz,x,y,z):NAN; + } + return 0; +} +MGL_NO_EXPORT void *mgl_eval_s(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], n1=t->p[3], nn=t->n; + const mreal *ii=t->c, *jj=t->d, *kk=t->e; + HCDT a = (HCDT)t->v; + mreal *b=t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;i(dat); + const mglData *i=dynamic_cast(idat); + const mglData *j=dynamic_cast(jdat); + const mglData *k=dynamic_cast(kdat); + if(!i) return 0; + + long p[4]={dat->GetNx(), dat->GetNy(), dat->GetNz(),norm}; + register long n=i->nx*i->ny*i->nz; + if(j && j->nx*j->ny*j->nz!=n) return 0; + if(k && k->nx*k->ny*k->nz!=n) return 0; + mglData *r=new mglData(i->nx,i->ny,i->nz); + if(d) mglStartThread(mgl_eval,0,n,r->a,d->a,i->a,p,0,j?j->a:0,k?k->a:0); + else mglStartThread(mgl_eval_s,0,n,r->a,0,i->a,p,dat,j?j->a:0,k?k->a:0); + return r; +} +uintptr_t MGL_EXPORT mgl_data_evaluate_(uintptr_t *d, uintptr_t *idat, uintptr_t *jdat, uintptr_t *kdat, int *norm) +{ return uintptr_t(mgl_data_evaluate(_DT_,_DA_(idat),_DA_(jdat),_DA_(kdat),*norm)); } +//----------------------------------------------------------------------------- diff --git a/src/data_ex.cpp b/src/data_ex.cpp new file mode 100644 index 0000000..d112516 --- /dev/null +++ b/src/data_ex.cpp @@ -0,0 +1,920 @@ +/*************************************************************************** + * data_new.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/data.h" +#include "mgl2/eval.h" +#include "mgl2/thread.h" +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_trace(HCDT d) +{ + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mglData *r=new mglData(nx); + if(ny>=nx && nz>=nx) +#pragma omp parallel for + for(long i=0;ia[i] = d->v(i,i,i); + else if(ny>=nx) +#pragma omp parallel for + for(long i=0;ia[i] = d->v(i,i); + else +#pragma omp parallel for + for(long i=0;ia[i] = d->v(i); + return r; +} +uintptr_t MGL_EXPORT mgl_data_trace_(uintptr_t *d) +{ return uintptr_t(mgl_data_trace(_DT_)); } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_subdata_ext(HCDT d, HCDT xx, HCDT yy, HCDT zz) +{ + long n=0,m=0,l=0,j,k; + bool ix=false, iy=false, iz=false; + if(xx->GetNz()>1) // 3d data + { + n = xx->GetNx(); m = xx->GetNy(); l = xx->GetNz(); + j = yy->GetNx()*yy->GetNy()*yy->GetNz(); if(j>1 && j!=n*m*l) return 0; // wrong sizes + k = zz->GetNx()*zz->GetNy()*zz->GetNz(); if(k>1 && k!=n*m*l) return 0; // wrong sizes + ix = true; iy = j>1; iz = k>1; + } + else if(yy->GetNz()>1) + { + n = yy->GetNx(); m = yy->GetNy(); l = yy->GetNz(); + j = xx->GetNx()*xx->GetNy()*xx->GetNz(); if(j>1 && j!=n*m*l) return 0; // wrong sizes + k = zz->GetNx()*zz->GetNy()*zz->GetNz(); if(k>1 && k!=n*m*l) return 0; // wrong sizes + iy = true; ix = j>1; iz = k>1; + } + else if(zz->GetNz()>1) + { + n = zz->GetNx(); m = zz->GetNy(); l = zz->GetNz(); + j = yy->GetNx()*yy->GetNy()*yy->GetNz(); if(j>1 && j!=n*m*l) return 0; // wrong sizes + k = xx->GetNx()*xx->GetNy()*xx->GetNz(); if(k>1 && k!=n*m*l) return 0; // wrong sizes + iz = true; iy = j>1; ix = k>1; + } + else if(xx->GetNy()>1) // 2d data + { + n = xx->GetNx(); m = xx->GetNy(); l = 1; + j = yy->GetNx()*yy->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes + k = zz->GetNx()*zz->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes + ix = true; iy = j>1; iz = k>1; + } + else if(yy->GetNy()>1) + { + n = yy->GetNx(); m = yy->GetNy(); l = 1; + j = xx->GetNx()*xx->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes + k = zz->GetNx()*zz->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes + iy = true; ix = j>1; iz = k>1; + } + else if(zz->GetNy()>1) + { + n = zz->GetNx(); m = zz->GetNy(); l = 1; + j = yy->GetNx()*yy->GetNy(); if(j>1 && j!=n*m) return 0; // wrong sizes + k = xx->GetNx()*xx->GetNy(); if(k>1 && k!=n*m) return 0; // wrong sizes + iz = true; iy = j>1; ix = k>1; + } + long nx=d->GetNx(),ny=d->GetNy(),nz=d->GetNz(); + mreal vx=xx->v(0), vy=yy->v(0), vz=zz->v(0); + mglData *r=new mglData; + if(n*m*l>1) // this is 2d or 3d data + { + r->Create(n,m,l); +#pragma omp parallel for + for(long i0=0;i0vthr(i0):vx; + register mreal y = iy?yy->vthr(i0):vy; + register mreal z = iz?zz->vthr(i0):vz; + r->a[i0] = mgl_data_linear(d,x,y,z); + } + return r; + } + // this is 1d data -> try as normal SubData() + if(xx->GetNx()>1 || vx>=0) { n=xx->GetNx(); ix=true; } + else { n=nx; ix=false; } + if(yy->GetNx()>1 || vy>=0) { m=yy->GetNx(); iy=true; } + else { m=ny; iy=false; } + if(zz->GetNx()>1 || vz>=0) { l=zz->GetNx(); iz=true; } + else { l=nz; iz=false; } + r->Create(n,m,l); +#pragma omp parallel for collapse(3) + for(long k=0;kv(i):i, y = iy?yy->v(j):j, z = iz?zz->v(k):k; + r->a[i+n*(j+m*k)] = mgl_data_linear(d,x,y,z); + } + if(m==1) { r->ny=r->nz; r->nz=1; }// "squeeze" dimensions + if(n==1) { r->nx=r->ny; r->ny=r->nz; r->nz=1; r->NewId();} + return r; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_subdata(HCDT d, long xx,long yy,long zz) +{ + mglData x,y,z; + x.a[0]=xx; y.a[0]=yy; z.a[0]=zz; + return mgl_data_subdata_ext(d,&x,&y,&z); +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_data_subdata_(uintptr_t *d, int *xx,int *yy,int *zz) +{ return uintptr_t(mgl_data_subdata(_DT_,*xx,*yy,*zz)); } +uintptr_t MGL_EXPORT mgl_data_subdata_ext_(uintptr_t *d, uintptr_t *xx, uintptr_t *yy, uintptr_t *zz) +{ return uintptr_t(mgl_data_subdata_ext(_DT_,_DA_(xx),_DA_(yy),_DA_(zz))); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_column(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + const mglFormula *f = (const mglFormula *)t->v; + long nx=t->p[0]; + mreal *b=t->a, var[MGL_VS]; + const mreal *a=t->b; + memset(var,0,('z'-'a')*sizeof(mreal)); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;js[j]>='a' && t->s[j]<='z') + var[t->s[j]-'a'] = a[j+nx*i]; + b[i] = f->Calc(var); + } + return 0; +} +HMDT MGL_EXPORT mgl_data_column(HCDT dat, const char *eq) +{ // NOTE: only for mglData (for speeding up) + long nx=dat->GetNx(),ny=dat->GetNy(),nz=dat->GetNz(); + mglFormula f(eq); + mglData *r=new mglData(ny,nz); + const mglData *d=dynamic_cast(dat); + if(d) mglStartThread(mgl_column,0,ny*nz,r->a,d->a,0,&nx,&f,0,0,d->id.c_str()); + return r; +} +uintptr_t MGL_EXPORT mgl_data_column_(uintptr_t *d, const char *eq,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + uintptr_t r = uintptr_t(mgl_data_column(_DT_,s)); + delete []s; return r; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_resize(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]+0.1, ny=t->p[1]+0.1; + long n1=t->p[3]+0.1,n2=t->p[4]+0.1,n3=t->p[5]+0.1; + mreal *b=t->a; + const mreal *a=t->b, *c=t->c; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = mglSpline3(a,n1,n2,n3, c[0]+i*c[1], c[2]+j*c[3], c[4]+k*c[5]); + } + return 0; +} +HMDT MGL_EXPORT mgl_data_resize_box(HCDT dat, long mx,long my,long mz, mreal x1,mreal x2, mreal y1,mreal y2, mreal z1,mreal z2) +{ // NOTE: only for mglData (for speeding up) + const mglData *d=dynamic_cast(dat); + if(!d) return 0; + register long nx = d->nx-1, ny = d->ny-1, nz = d->nz-1; + mx = mx<1 ? nx+1:mx; my = my<1 ? ny+1:my; mz = mz<1 ? nz+1:mz; + mglData *r=new mglData(mx,my,mz); + + mreal par[6]={nx*x1,0,ny*y1,0,nz*z1,0}; + long nn[6]={mx,my,mz,nx+1,ny+1,nz+1}; + if(mx>1) par[1] = nx*(x2-x1)/(mx-1); + if(my>1) par[3] = ny*(y2-y1)/(my-1); + if(mz>1) par[5] = nz*(z2-z1)/(mz-1); + mglStartThread(mgl_resize,0,mx*my*mz,r->a,d->a,par,nn); + return r; +} +HMDT MGL_EXPORT mgl_data_resize(HCDT d, long mx,long my,long mz) +{ return mgl_data_resize_box(d, mx,my,mz,0,1,0,1,0,1); } +uintptr_t MGL_EXPORT mgl_data_resize_(uintptr_t *d, int *mx,int *my,int *mz) +{ return uintptr_t(mgl_data_resize(_DT_,*mx,*my,*mz)); } +uintptr_t MGL_EXPORT mgl_data_resize_box_(uintptr_t *d, int *mx,int *my,int *mz, mreal *x1,mreal *x2, mreal *y1,mreal *y2, mreal *z1,mreal *z2) +{ return uintptr_t(mgl_data_resize_box(_DT_,*mx,*my,*mz,*x1,*x2,*y1,*y2,*z1,*z2)); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_combine(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]; + mreal *b=t->a; + const mreal *c=t->b, *d=t->c; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) b[i0] = c[i0%nx]*d[i0/nx]; + return 0; +} +HMDT MGL_EXPORT mgl_data_combine(HCDT d1, HCDT d2) +{ // NOTE: only for mglData (for speeding up) + const mglData *a=dynamic_cast(d1); + const mglData *b=dynamic_cast(d2); + + if(!a || !b || a->nz>1 || (a->ny>1 && b->ny>1) || b->nz>1) return 0; + mglData *r=new mglData; + long n1=a->ny,n2=b->nx; + bool dim2=true; + if(a->ny==1) { n1=b->nx; n2=b->ny; dim2 = false; } + r->Create(a->nx,n1,n2); + if(dim2) n1=a->nx*a->ny; else { n1=a->nx; n2=b->nx*b->ny; } + mglStartThread(mgl_combine,0,n1*n2,r->a,a->a,b->a,&n1); + return r; +} +uintptr_t MGL_EXPORT mgl_data_combine_(uintptr_t *a, uintptr_t *b) +{ return uintptr_t(mgl_data_combine(_DA_(a),_DA_(b))); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_sum_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;iGetNx(),ny=dat->GetNy(),nz=dat->GetNz(); + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nx*ny*nz]; + mreal *c = new mreal[nx*ny*nz]; + + const mglData *d=dynamic_cast(dat); + if(d) memcpy(c,d->a,nx*ny*nz*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_sum_z,0,nx*ny,b,c,0,p); + memcpy(c,b,nx*ny*sizeof(mreal)); p[2] = 1; + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_sum_y,0,nx*p[2],b,c,0,p); + memcpy(c,b,nx*p[2]*sizeof(mreal)); p[1] = p[2]; p[2] = 1; + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_sum_x,0,p[1]*p[2],b,c,0,p); + p[0] = p[1]; p[1] = p[2]; p[2] = 1; + } + mglData *r=new mglData(p[0],p[1],p[2]); + memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + delete []b; delete []c; return r; +} +uintptr_t MGL_EXPORT mgl_data_sum_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + uintptr_t r=uintptr_t(mgl_data_sum(_DT_,s)); delete []s; return r; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_max_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], ny=t->p[1], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ip[0], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;iGetNx(),ny=dat->GetNy(),nz=dat->GetNz(); + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nx*ny*nz]; + mreal *c = new mreal[nx*ny*nz]; + + const mglData *d=dynamic_cast(dat); + if(d) memcpy(c,d->a,nx*ny*nz*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_max_z,0,nx*ny,b,c,0,p); + memcpy(c,b,nx*ny*sizeof(mreal)); p[2] = 1; + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_max_y,0,nx*p[2],b,c,0,p); + memcpy(c,b,nx*p[2]*sizeof(mreal)); p[1] = p[2]; p[2] = 1; + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_max_x,0,p[1]*p[2],b,c,0,p); + p[0] = p[1]; p[1] = p[2]; p[2] = 1; + } + mglData *r=new mglData(p[0],p[1],p[2]); + memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + delete []b; delete []c; return r; +} +uintptr_t MGL_EXPORT mgl_data_max_dir_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + uintptr_t r=uintptr_t(mgl_data_max_dir(_DT_,s)); delete []s; return r; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_min_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia[i+nn*j]) b[i] = a[i+nn*j]; + } + return 0; +} +MGL_NO_EXPORT void *mgl_min_y(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia[k+nx*j]) b[i]=a[k+nx*j]; + } + return 0; +} +MGL_NO_EXPORT void *mgl_min_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;ia[j+k]) b[i]=a[j+k]; + } + return 0; +} +HMDT MGL_EXPORT mgl_data_min_dir(HCDT dat, const char *dir) +{ + if(!dir || *dir==0) return 0; + long nx=dat->GetNx(),ny=dat->GetNy(),nz=dat->GetNz(); + long p[3]={nx,ny,nz}; + mreal *b = new mreal[nx*ny*nz]; + mreal *c = new mreal[nx*ny*nz]; + + const mglData *d=dynamic_cast(dat); + if(d) memcpy(c,d->a,nx*ny*nz*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ivthr(i); + + if(strchr(dir,'z') && nz>1) + { + mglStartThread(mgl_min_z,0,nx*ny,b,c,0,p); + memcpy(c,b,nx*ny*sizeof(mreal)); p[2] = 1; + } + if(strchr(dir,'y') && ny>1) + { + mglStartThread(mgl_min_y,0,nx*p[2],b,c,0,p); + memcpy(c,b,nx*p[2]*sizeof(mreal)); p[1] = p[2]; p[2] = 1; + } + if(strchr(dir,'x') && nx>1) + { + mglStartThread(mgl_min_x,0,p[1]*p[2],b,c,0,p); + p[0] = p[1]; p[1] = p[2]; p[2] = 1; + } + mglData *r=new mglData(p[0],p[1],p[2]); + memcpy(r->a,b,p[0]*p[1]*p[2]*sizeof(mreal)); + delete []b; delete []c; return r; +} +uintptr_t MGL_EXPORT mgl_data_min_dir_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + uintptr_t r=uintptr_t(mgl_data_min_dir(_DT_,s)); delete []s; return r; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_mom_z(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; + const mglFormula *eq = (const mglFormula *)t->v; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;iCalc(x,y,z,a[ii]); + } + b[i] = i0>0 ? i1/i0 : 0; + } + return 0; +} +MGL_NO_EXPORT void *mgl_mom_y(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; + const mglFormula *eq = (const mglFormula *)t->v; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;iCalc(x,y,z,a[ii]); + } + b[i] = i0>0 ? i1/i0 : 0; + } + return 0; +} +MGL_NO_EXPORT void *mgl_mom_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2], nn=t->n; + mreal *b=t->a; + const mreal *a=t->b; + const mglFormula *eq = (const mglFormula *)t->v; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;iCalc(x,y,z,a[ii]); + } + b[i] = i0>0 ? i1/i0 : 0; + } + return 0; +} +HMDT MGL_EXPORT mgl_data_momentum(HCDT dat, char dir, const char *how) +{ // NOTE: only for mglData (for speeding up) + long nx=dat->GetNx(),ny=dat->GetNy(),nz=dat->GetNz(); + const mglData *d=dynamic_cast(dat); + if(!d) return 0; + mglFormula eq(how); + long p[3]={nx,ny,nz}; + mglData *b=0; + if(dir=='x') + { b=new mglData(nx); mglStartThread(mgl_mom_x,0,nx,b->a,d->a,0,p,&eq); } + if(dir=='y') + { b=new mglData(ny); mglStartThread(mgl_mom_y,0,ny,b->a,d->a,0,p,&eq); } + if(dir=='z') + { b=new mglData(nz); mglStartThread(mgl_mom_z,0,nz,b->a,d->a,0,p,&eq); } + return b; +} +uintptr_t MGL_EXPORT mgl_data_momentum_(uintptr_t *d, char *dir, const char *how, int,int l) +{ char *s=new char[l+1]; memcpy(s,how,l); s[l]=0; + uintptr_t r=uintptr_t(mgl_data_momentum(_DT_,*dir, s)); + delete []s; return r; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_eqmul(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) b[i] *= a[i%nx]; + return 0; +} +void MGL_EXPORT mgl_data_mul_dat(HMDT d, HCDT a) +{ + long n, nx=d->nx, ny=d->ny, nz=d->nz; + const mglData *b = dynamic_cast(a); + if(b) + { + if(b->nz==1 && b->ny==1 && nx==b->nx) + { n=nx; mglStartThread(mgl_eqmul,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(b->nz==1 && ny==b->ny && nx==b->nx) + { n=nx*ny; mglStartThread(mgl_eqmul,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(nz==b->nz && ny==b->ny && nx==b->nx) + { n=nx*ny*nz; mglStartThread(mgl_eqmul,0,nx*ny*nz,d->a,b->a,0,&n); } + } + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i+nx*(j+ny*k)] *= a->v(i,j,k); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_mul_num(HMDT d, mreal a) +{ + long n=1, nx=d->nx, ny=d->ny, nz=d->nz; mreal aa=a; + mglStartThread(mgl_eqmul,0,nx*ny*nz,d->a,&aa,0,&n); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_eqdiv(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) b[i] /= a[i%nx]; + return 0; +} +void MGL_EXPORT mgl_data_div_dat(HMDT d, HCDT a) +{ + long n, nx=d->nx, ny=d->ny, nz=d->nz; + const mglData *b = dynamic_cast(a); + if(b) + { + if(b->nz==1 && b->ny==1 && nx==b->nx) + { n=nx; mglStartThread(mgl_eqdiv,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(b->nz==1 && ny==b->ny && nx==b->nx) + { n=nx*ny; mglStartThread(mgl_eqdiv,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(nz==b->nz && ny==b->ny && nx==b->nx) + { n=nx*ny*nz; mglStartThread(mgl_eqdiv,0,nx*ny*nz,d->a,b->a,0,&n); } + } + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i+nx*(j+ny*k)] /= a->v(i,j,k); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_div_num(HMDT d, mreal a) +{ + long n=1, nx=d->nx, ny=d->ny, nz=d->nz; mreal aa=a; + mglStartThread(mgl_eqdiv,0,nx*ny*nz,d->a,&aa,0,&n); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_eqadd(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) b[i] += a[i%nx]; + return 0; +} +void MGL_EXPORT mgl_data_add_dat(HMDT d, HCDT a) +{ + long n, nx=d->nx, ny=d->ny, nz=d->nz; + const mglData *b = dynamic_cast(a); + if(b) + { + if(b->nz==1 && b->ny==1 && nx==b->nx) + { n=nx; mglStartThread(mgl_eqadd,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(b->nz==1 && ny==b->ny && nx==b->nx) + { n=nx*ny; mglStartThread(mgl_eqadd,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(nz==b->nz && ny==b->ny && nx==b->nx) + { n=nx*ny*nz; mglStartThread(mgl_eqadd,0,nx*ny*nz,d->a,b->a,0,&n); } + } + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i+nx*(j+ny*k)] += a->v(i,j,k); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_add_num(HMDT d, mreal a) +{ + long n=1, nx=d->nx, ny=d->ny, nz=d->nz; mreal aa=a; + mglStartThread(mgl_eqadd,0,nx*ny*nz,d->a,&aa,0,&n); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_eqsub(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0]; + mreal *b=t->a; + const mreal *a=t->b; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;in;i+=mglNumThr) b[i] -= a[i%nx]; + return 0; +} +void MGL_EXPORT mgl_data_sub_dat(HMDT d, HCDT a) +{ + long n, nx=d->nx, ny=d->ny, nz=d->nz; + const mglData *b = dynamic_cast(a); + if(b) + { + if(b->nz==1 && b->ny==1 && nx==b->nx) + { n=nx; mglStartThread(mgl_eqsub,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(b->nz==1 && ny==b->ny && nx==b->nx) + { n=nx*ny; mglStartThread(mgl_eqsub,0,nx*ny*nz,d->a,b->a,0,&n); } + else if(nz==b->nz && ny==b->ny && nx==b->nx) + { n=nx*ny*nz; mglStartThread(mgl_eqsub,0,nx*ny*nz,d->a,b->a,0,&n); } + } + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i+nx*(j+ny*k)] -= a->v(i,j,k); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_sub_num(HMDT d, mreal a) +{ + long n=1, nx=d->nx, ny=d->ny, nz=d->nz; mreal aa=a; + mglStartThread(mgl_eqsub,0,nx*ny*nz,d->a,&aa,0,&n); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_mul_dat_(uintptr_t *d, uintptr_t *b) { mgl_data_mul_dat(_DT_, _DA_(b)); } +void MGL_EXPORT mgl_data_div_dat_(uintptr_t *d, uintptr_t *b) { mgl_data_div_dat(_DT_, _DA_(b)); } +void MGL_EXPORT mgl_data_add_dat_(uintptr_t *d, uintptr_t *b) { mgl_data_add_dat(_DT_, _DA_(b)); } +void MGL_EXPORT mgl_data_sub_dat_(uintptr_t *d, uintptr_t *b) { mgl_data_sub_dat(_DT_, _DA_(b)); } +void MGL_EXPORT mgl_data_mul_num_(uintptr_t *d, mreal *b) { mgl_data_mul_num(_DT_, *b); } +void MGL_EXPORT mgl_data_div_num_(uintptr_t *d, mreal *b) { mgl_data_div_num(_DT_, *b); } +void MGL_EXPORT mgl_data_add_num_(uintptr_t *d, mreal *b) { mgl_data_add_num(_DT_, *b); } +void MGL_EXPORT mgl_data_sub_num_(uintptr_t *d, mreal *b) { mgl_data_sub_num(_DT_, *b); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_hist_p(mglThreadD *t,mreal *a) +{ + long n=t[0].p[0]; + memset(a,0,n*sizeof(mreal)); +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=0;in, n = t->p[0]; + mreal *b=new mreal[n]; + memset(b,0,n*sizeof(mreal)); + const mreal *a=t->b, *c=t->c, *v=(const mreal *)t->v; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;i=0 && ka = b; return 0; +} +MGL_NO_EXPORT void *mgl_hist_2(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nn=t->n, n = t->p[0]; + long ns=t->p[1], nx=t->p[2], ny=t->p[3], nz=t->p[4]; + mreal *b=new mreal[n], d=1./ns; + memset(b,0,n*sizeof(mreal)); + const mreal *a=t->b, *c=t->c, *v=(const mreal *)t->v; + bool sp = n>0; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;i=0 && ka = b; return 0; +} +HMDT MGL_EXPORT mgl_data_hist(HCDT dat, long n, mreal v1, mreal v2, long nsub) +{ + const mglData *d = dynamic_cast(dat); + if(n<2 || v1==v2 || !d) return 0; // NOTE: For mglData only! + mglData *b=new mglData(n); + mreal v[2]={v1,v2}; + long nx=d->nx, ny=d->ny, nz=d->nz; + long ns=abs(nsub)+1, p[5]={n,ns,nx,ny,nz}; + if(nsub==0) mglStartThread(mgl_hist_1,mgl_hist_p, nx*ny*nz, b->a,d->a,0,p,v); + else mglStartThread(mgl_hist_2,mgl_hist_p, nx*ny*nz*ns*ns*ns, b->a,d->a,0,p,v); + return b; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_hist_w(HCDT dat, HCDT weight, long n, mreal v1, mreal v2, long nsub) +{ + const mglData *d = dynamic_cast(dat); + const mglData *w = dynamic_cast(weight); + if(n<2 || v1==v2 || !d || !w) return 0; // NOTE: For mglData only! + mglData *b=new mglData(n); + mreal v[2]={v1,v2}; + + long nx=d->nx, ny=d->ny, nz=d->nz; + long ns=abs(nsub)+1, p[5]={n,ns,nx,ny,nz}; + if(nsub==0) mglStartThread(mgl_hist_1,mgl_hist_p, nx*ny*nz, b->a,d->a,w->a,p,v); + else mglStartThread(mgl_hist_2,mgl_hist_p, nx*ny*nz*ns*ns*ns, b->a,d->a,w->a,p,v); + return b; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_data_hist_(uintptr_t *d, int *n, mreal *v1, mreal *v2, int *nsub) +{ return uintptr_t(mgl_data_hist(_DT_,*n,*v1,*v2,*nsub)); } +uintptr_t MGL_EXPORT mgl_data_hist_w_(uintptr_t *d, uintptr_t *w, int *n, mreal *v1, mreal *v2, int *nsub) +{ return uintptr_t(mgl_data_hist_w(_DT_,_DA_(w),*n,*v1,*v2,*nsub)); } +//----------------------------------------------------------------------------- +long MGL_NO_EXPORT mgl_idx_var; +int MGL_NO_EXPORT mgl_cmd_idx(const void *a, const void *b) +{ + mreal *aa = (mreal *)a, *bb = (mreal *)b; + return (aa[mgl_idx_var]>bb[mgl_idx_var] ? 1:(aa[mgl_idx_var](dat); + if(!d || idx>=d->nx || idx<0) return; + bool single = (d->nz==1 || idy<0); + if(idy<0 || idy>d->ny) idy=0; + mgl_idx_var = idx+d->nx*idy; // NOTE: not thread safe!!! + if(single) qsort(d->a, d->ny*d->nz, d->nx*sizeof(mreal), mgl_cmd_idx); + else qsort(d->a, d->nz, d->ny*d->nx*sizeof(mreal), mgl_cmd_idx); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_sort_(uintptr_t *d, int *idx, int *idy) +{ mgl_data_sort(_DT_,*idx,*idy); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_find_root(mreal (*func)(mreal x, void *par), mreal x0, void *par) +{ + mreal x1=x0+1e-2*(x0?x0:1), f0=func(x0,par), f1=func(x1,par), x, f; + if(fabs(f0)<1e-7) return x0; + if(fabs(f1)<1e-7) return x1; + if(f0==f1) return NAN; + for(long i=0;i<20;i++) + { + x = x1-f1*(x1-x0)/(f1-f0); f = func(x,par); + if(fabs(f)<1e-7) return x; +/* if(fabs(f-f1)>0.5*fmin(fabs(f),fabs(f1))) // TODO switch to bisection if slow + { + x = (x1+x0)/2; f = func(x,par); + if(fabs(f)<1e-7) return x; + }*/ + x0=x1; f0=f1; x1=x; f1=f; // new points + } + return NAN; // no roots found +} +//----------------------------------------------------------------------------- +struct MGL_NO_EXPORT mglFuncV { mglFormula *eq; char var; }; +mreal MGL_NO_EXPORT mgl_funcv(mreal v, void *par) +{ + mglFuncV *f = (mglFuncV *)par; + mreal var[MGL_VS]; memset(var,0,('z'-'a')*sizeof(mreal)); + var[f->var-'a'] = v; + return f->eq->Calc(var); +} +HMDT MGL_EXPORT mgl_data_roots(const char *func, HCDT ini, char var) +{ + if(!ini) return 0; + mglData *res = new mglData(ini); + + mglFormula eq(func); + mglFuncV f; f.eq = &eq; f.var = var; + long n = res->nx*res->ny*res->nz; +#pragma omp parallel for + for(long i=0;ia[i] = mgl_find_root(mgl_funcv,res->a[i],&f); + return res; +} +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_find_root_txt(const char *func, mreal ini, char var) +{ + mglFormula eq(func); + mglFuncV f; f.eq = &eq; f.var = var; + return mgl_find_root(mgl_funcv,ini,&f); +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_data_roots_(const char *func, uintptr_t *ini, const char *var,int l,int) +{ char *s=new char[l+1]; memcpy(s,func,l); s[l]=0; + uintptr_t r = uintptr_t(mgl_data_roots(s,_DA_(ini),*var)); + delete []s; return r; } +mreal MGL_EXPORT mgl_find_root_txt_(const char *func, mreal *ini, const char *var,int l,int) +{ char *s=new char[l+1]; memcpy(s,func,l); s[l]=0; + mreal r = mgl_find_root_txt(s,*ini,*var); + delete []s; return r; } +//----------------------------------------------------------------------------- diff --git a/src/data_gr.cpp b/src/data_gr.cpp new file mode 100644 index 0000000..fcdc558 --- /dev/null +++ b/src/data_gr.cpp @@ -0,0 +1,177 @@ +/*************************************************************************** + * data_gr.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include + +#ifndef WIN32 +#include +#endif + +#include "mgl2/datac.h" +#include "mgl2/evalc.h" +#include "mgl2/thread.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_refill_gr(HMGL gr, HMDT dat, HCDT xdat, HCDT ydat, HCDT zdat, HCDT vdat, long sl, const char *opt) +{ + if(!vdat) return; + gr->SaveState(opt); + if(!ydat && !zdat) mgl_data_refill_x(dat,xdat,vdat,gr->Min.x,gr->Max.x,sl); +// else if(!xdat && !zdat) mgl_data_refill_x(dat,ydat,vdat,gr->Min.y,gr->Max.y,sl); +// else if(!xdat && !ydat) mgl_data_refill_x(dat,zdat,vdat,gr->Min.z,gr->Max.z,sl); + else if(!zdat) mgl_data_refill_xy(dat,xdat,ydat,vdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y,sl); +// else if(!ydat) mgl_data_refill_xy(dat,xdat,zdat,vdat,gr->Min.x,gr->Max.x,gr->Min.z,gr->Max.z,sl); +// else if(!xdat) mgl_data_refill_xy(dat,ydat,zdat,vdat,gr->Min.y,gr->Max.y,gr->Min.z,gr->Max.z,sl); + else mgl_data_refill_xyz(dat,xdat,ydat,zdat,vdat,gr->Min.x,gr->Max.x,gr->Min.y,gr->Max.y,gr->Min.z,gr->Max.z); + gr->LoadState(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_refill_x_(uintptr_t *d, uintptr_t *xdat, uintptr_t *vdat, mreal *x1, mreal *x2, long *sl) +{ mgl_data_refill_x(_DT_,_DA_(xdat),_DA_(vdat),*x1,*x2,*sl); } +void MGL_EXPORT mgl_data_refill_xy_(uintptr_t *d, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, long *sl) +{ mgl_data_refill_xy(_DT_,_DA_(xdat),_DA_(ydat),_DA_(vdat),*x1,*x2,*y1,*y2,*sl); } +void MGL_EXPORT mgl_data_refill_xyz_(uintptr_t *d, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, mreal *x1, mreal *x2, mreal *y1, mreal *y2, mreal *z1, mreal *z2) +{ mgl_data_refill_xyz(_DT_,_DA_(xdat),_DA_(ydat),_DA_(zdat),_DA_(vdat),*x1,*x2,*y1,*y2,*z1,*z2); } +void MGL_EXPORT mgl_data_refill_gr_(uintptr_t *gr, uintptr_t *d, uintptr_t *xdat, uintptr_t *ydat, uintptr_t *zdat, uintptr_t *vdat, long *sl, const char *opt,int l) +{ char *s=new char[l+1]; memcpy(s,opt,l); s[l]=0; + mgl_data_refill_gr(_GR_,_DT_,_DA_(xdat),_DA_(ydat),_DA_(zdat),_DA_(vdat),*sl,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_fill_f(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + const mglFormula *f = (const mglFormula *)(t->v); + long nx=t->p[0],ny=t->p[1]; + mreal *b=t->a; + const mreal *v=t->b, *w=t->c, *x=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(x[0]+i*x[1], x[2]+j*x[3], x[4]+k*x[5], b[i0], v?v[i0]:0, w?w[i0]:0); + } + return 0; +} +MGL_NO_EXPORT void *mgl_fill_fgen(void *par) +{ + mglThreadV *t=(mglThreadV *)par; + const mglFormula *f = (const mglFormula *)(t->v); + long nx=t->p[0],ny=t->p[1]; + mreal *b=t->a; + HCDT v=(HCDT)t->b, w=(HCDT)t->c; + const mreal *x=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(x[0]+i*x[1], x[2]+j*x[3], x[4]+k*x[5], b[i0], v?v->vthr(i0):0, w?w->vthr(i0):0); + } + return 0; +} +void MGL_EXPORT mgl_data_fill_eq(HMGL gr, HMDT d, const char *eq, HCDT vdat, HCDT wdat, const char *opt) +{ + const mglData *v = dynamic_cast(vdat); + const mglData *w = dynamic_cast(wdat); + long nn = d->nx*d->ny*d->nz, par[3]={d->nx,d->ny,d->nz}; + if(vdat && vdat->GetNN()!=nn) return; + if(wdat && wdat->GetNN()!=nn) return; + gr->SaveState(opt); + mreal xx[6]={gr->Min.x,0, gr->Min.y,0, gr->Min.z,0}; + if(d->nx>1) xx[1] = (gr->Max.x-gr->Min.x)/(d->nx-1.); + if(d->ny>1) xx[3] = (gr->Max.y-gr->Min.y)/(d->ny-1.); + if(d->nz>1) xx[5] = (gr->Max.z-gr->Min.z)/(d->nz-1.); + mglFormula f(eq); + if(v && w) mglStartThread(mgl_fill_f,0,nn,d->a,v->a,w->a,par,&f,xx); + else if(vdat && wdat) mglStartThreadV(mgl_fill_fgen,nn,d->a,vdat,wdat,par,&f,xx); + else if(v) mglStartThread(mgl_fill_f,0,nn,d->a,v->a,0,par,&f,xx); + else if(vdat) mglStartThreadV(mgl_fill_fgen,nn,d->a,vdat,0,par,&f,xx); + else mglStartThread(mgl_fill_f,0,nn,d->a,0,0,par,&f,xx); + gr->LoadState(); +} +void MGL_EXPORT mgl_data_fill_eq_(uintptr_t *gr, uintptr_t *d, const char *eq, uintptr_t *v, uintptr_t *w, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_data_fill_eq(_GR_,_DT_,s,_DA_(v),_DA_(w),o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_cfill_f(void *par) +{ + mglThreadC *t=(mglThreadC *)par; + const mglFormulaC *f = (const mglFormulaC *)(t->v); + long nx=t->p[0],ny=t->p[1]; + dual *b=t->a; + const dual *v=t->b, *w=t->c, *x=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(x[0]+mreal(i)*x[1], x[2]+mreal(j)*x[3], x[4]+mreal(k)*x[5], + b[i0], v?v[i0]:dual(0,0), w?w[i0]:dual(0,0)); + } + return 0; +} +MGL_NO_EXPORT void *mgl_cfill_fgen(void *par) +{ + mglThreadV *t=(mglThreadV *)par; + const mglFormulaC *f = (const mglFormulaC *)(t->v); + long nx=t->p[0],ny=t->p[1]; + dual *b=t->aa; + HCDT v=(HCDT)t->b, w=(HCDT)t->c; + const mreal *x=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(x[0]+i*x[1], x[2]+j*x[3], x[4]+k*x[5], + b[i0], v?v->vthr(i0):0, w?w->vthr(i0):0); + } + return 0; +} +void MGL_EXPORT mgl_datac_fill_eq(HMGL gr, HADT d, const char *eq, HCDT vdat, HCDT wdat, const char *opt) +{ + const mglDataC *v = dynamic_cast(vdat); + const mglDataC *w = dynamic_cast(wdat); + long nn = d->nx*d->ny*d->nz, par[3]={d->nx,d->ny,d->nz}; + if(v && v->nx*v->ny*v->nz!=nn) return; + if(w && w->nx*w->ny*w->nz!=nn) return; + gr->SaveState(opt); + mreal xx[6]={gr->Min.x,0, gr->Min.y,0, gr->Min.z,0}; + if(d->nx>1) xx[1] = (gr->Max.x-gr->Min.x)/(d->nx-1.); + if(d->ny>1) xx[3] = (gr->Max.y-gr->Min.y)/(d->ny-1.); + if(d->nz>1) xx[5] = (gr->Max.z-gr->Min.z)/(d->nz-1.); + dual cc[6]={xx[0],xx[1],xx[2],xx[3],xx[4],xx[5]}; + mglFormulaC f(eq); + if(v && w) mglStartThreadC(mgl_cfill_f,0,nn,d->a,v->a,w->a,par,&f,cc); + else if(vdat && wdat) mglStartThreadV(mgl_cfill_fgen,nn,d->a,vdat,wdat,par,&f,xx); + else if(v) mglStartThreadC(mgl_cfill_f,0,nn,d->a,v->a,0,par,&f,cc); + else if(vdat) mglStartThreadV(mgl_cfill_fgen,nn,d->a,vdat,0,par,&f,xx); + else mglStartThreadC(mgl_cfill_f,0,nn,d->a,0,0,par,&f,cc); + gr->LoadState(); +} +void MGL_EXPORT mgl_datac_fill_eq_(uintptr_t *gr, uintptr_t *d, const char *eq, uintptr_t *v, uintptr_t *w, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_datac_fill_eq(_GR_,_DC_,s,_DA_(v),_DA_(w),o); delete []o; delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/data_io.cpp b/src/data_io.cpp new file mode 100644 index 0000000..1ac3472 --- /dev/null +++ b/src/data_io.cpp @@ -0,0 +1,1173 @@ +/*************************************************************************** + * data_io.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include + +#ifndef WIN32 +#include +#endif + +#include "mgl2/data.h" +#include "mgl2/datac.h" +#include "mgl2/eval.h" +#include "mgl2/thread.h" + +#if MGL_HAVE_HDF5 +//#define H5_NO_DEPRECATED_SYMBOLS +#define H5_USE_16_API +#include +#endif +#if MGL_HAVE_HDF4 +#define intf hdf4_intf +#include +#undef intf +#endif + +//#define isn(ch) ((ch)<' ' && (ch)!='\t') +#define isn(ch) ((ch)=='\n') +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_create_data() { return new mglData; } +HMDT MGL_EXPORT mgl_create_data_size(long nx, long ny, long nz){ return new mglData(nx,ny,nz); } +HMDT MGL_EXPORT mgl_create_data_file(const char *fname) { return new mglData(fname); } +void MGL_EXPORT mgl_delete_data(HMDT d) { if(d) delete d; } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_data_() +{ return uintptr_t(new mglData()); } +uintptr_t MGL_EXPORT mgl_create_data_size_(int *nx, int *ny, int *nz) +{ return uintptr_t(new mglData(*nx,*ny,*nz)); } +uintptr_t MGL_EXPORT mgl_create_data_file_(const char *fname,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + uintptr_t r = uintptr_t(new mglData(s)); delete []s; return r; } +void MGL_EXPORT mgl_delete_data_(uintptr_t *d) +{ if(_DT_) delete _DT_; } +//----------------------------------------------------------------------------- +void mglFromStr(HMDT d,char *buf,long NX,long NY,long NZ) // TODO: add multithreading read +{ + if(NX<1 || NY <1 || NZ<1) return; + mgl_data_create(d, NX,NY,NZ); + long nb = strlen(buf); + register long i=0, j=0; + setlocale(LC_NUMERIC, "C"); + while(j0 || buf[j+1]!='#') // this is columns id + while(!isn(buf[j]) && j='a' && buf[j]<='z') + d->id.push_back(buf[j]); + j++; + } + } + while(buf[j]<=' ' && j' ' && buf[j]!=',' && buf[j]!=';' && ja[i] = strstr(s,"NAN")?NAN:atof(s); + i++; if(i>=NX*NY*NZ) break; + } + setlocale(LC_NUMERIC, ""); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set(HMDT d, HCDT a) +{ + if(!a) return; + const mglData *dd = dynamic_cast(a); // faster for mglData + mgl_data_create(d, a->GetNx(), a->GetNy(), a->GetNz()); + if(dd) // this one should be much faster + memcpy(d->a, dd->a, d->nx*d->ny*d->nz*sizeof(mreal)); + else // very inefficient!!! +#pragma omp parallel for collapse(3) + for(long k=0;knz;k++) for(long j=0;jny;j++) for(long i=0;inx;i++) + d->a[i+d->nx*(j+d->ny*k)] = a->v(i,j,k); +} +void MGL_EXPORT mgl_data_set_(uintptr_t *d, uintptr_t *a) { mgl_data_set(_DT_,_DA_(a)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_values(HMDT d, const char *v,long NX,long NY,long NZ) +{ + if(NX<1 || NY <1 || NZ<1) return; + register long n=strlen(v)+1; + char *buf = new char[n]; + memcpy(buf,v,n); + mglFromStr(d,buf,NX,NY,NZ); + delete []buf; +} +void MGL_EXPORT mgl_data_set_values_(uintptr_t *d, const char *val, int *nx, int *ny, int *nz, int l) +{ char *s=new char[l+1]; memcpy(s,val,l); s[l]=0; + mgl_data_set_values(_DT_,s,*nx,*ny,*nz); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_vector(HMDT d, gsl_vector *v) +{ +#if MGL_HAVE_GSL + if(!v || v->size<1) return; + mgl_data_create(d, v->size,1,1); +#pragma omp parallel for + for(long i=0;inx;i++) d->a[i] = v->data[i*v->stride]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_matrix(HMDT d, gsl_matrix *m) +{ +#if MGL_HAVE_GSL + if(!m || m->size1<1 || m->size2<1) return; + mgl_data_create(d, m->size1,m->size2,1); +#pragma omp parallel for collapse(2) + for(long j=0;jny;j++) for(long i=0;inx;i++) + d->a[i+j*d->nx] = m->data[i * m->tda + j]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_float(HMDT d, const float *A,long NX,long NY,long NZ) +{ + if(NX<=0 || NY<=0 || NZ<=0) return; + mgl_data_create(d, NX,NY,NZ); if(!A) return; +#if MGL_USE_DOUBLE +#pragma omp parallel for + for(long i=0;ia[i] = A[i]; +#else + memcpy(d->a,A,NX*NY*NZ*sizeof(float)); +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_double(HMDT d, const double *A,long NX,long NY,long NZ) +{ + if(NX<=0 || NY<=0 || NZ<=0) return; + mgl_data_create(d, NX,NY,NZ); if(!A) return; +#if MGL_USE_DOUBLE + memcpy(d->a,A,NX*NY*NZ*sizeof(double)); +#else +#pragma omp parallel for + for(long i=0;ia[i] = A[i]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_float2(HMDT d, float const * const *A,long N1,long N2) +{ + if(N1<=0 || N2<=0) return; + mgl_data_create(d, N2,N1,1); if(!A) return; +#if MGL_USE_DOUBLE +#pragma omp parallel for collapse(2) + for(long i=0;ia[j+i*N2] = A[i][j]; +#else +#pragma omp parallel for + for(long i=0;ia+i*N2,A[i],N2*sizeof(float)); +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_double2(HMDT d, double const *const *A,long N1,long N2) +{ + if(N1<=0 || N2<=0) return; + mgl_data_create(d, N2,N1,1); if(!A) return; +#if MGL_USE_DOUBLE +#pragma omp parallel for + for(long i=0;ia+i*N2,A[i],N2*sizeof(double)); +#else +#pragma omp parallel for collapse(2) + for(long i=0;ia[j+i*N2] = A[i][j]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_float3(HMDT d, float const * const * const *A,long N1,long N2,long N3) +{ + if(N1<=0 || N2<=0 || N3<=0) return; + mgl_data_create(d, N3,N2,N1); if(!A) return; +#if MGL_USE_DOUBLE +#pragma omp parallel for collapse(3) + for(long i=0;ia[k+N3*(j+i*N2)] = A[i][j][k]; +#else +#pragma omp parallel for collapse(2) + for(long i=0;ia+N3*(j+i*N2),A[i][j],N3*sizeof(float)); +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_double3(HMDT d, double const * const * const *A,long N1,long N2,long N3) +{ + if(N1<=0 || N2<=0 || N3<=0) return; + mgl_data_create(d, N3,N2,N1); if(!A) return; +#if MGL_USE_DOUBLE +#pragma omp parallel for collapse(2) + for(long i=0;ia+N3*(j+i*N2),A[i][j],N3*sizeof(double)); +#else +#pragma omp parallel for collapse(3) + for(long i=0;ia[k+N3*(j+i*N2)] = A[i][j][k]; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_float1_(uintptr_t *d, const float *A,int *NX) +{ mgl_data_set_float(_DT_,A,*NX,1,1); } +void MGL_EXPORT mgl_data_set_double1_(uintptr_t *d, const double *A,int *NX) +{ mgl_data_set_double(_DT_,A,*NX,1,1); } +void MGL_EXPORT mgl_data_set_float_(uintptr_t *d, const float *A,int *NX,int *NY,int *NZ) +{ mgl_data_set_float(_DT_,A,*NX,*NY,*NZ); } +void MGL_EXPORT mgl_data_set_double_(uintptr_t *d, const double *A,int *NX,int *NY,int *NZ) +{ mgl_data_set_double(_DT_,A,*NX,*NY,*NZ); } +void MGL_EXPORT mgl_data_set_float2_(uintptr_t *d, const float *A,int *N1,int *N2) +{ mgl_data_set_float(_DT_,A,*N1,*N2,1); } +void MGL_EXPORT mgl_data_set_double2_(uintptr_t *d, const double *A,int *N1,int *N2) +{ mgl_data_set_double(_DT_,A,*N1,*N2,1); } +void MGL_EXPORT mgl_data_set_float3_(uintptr_t *d, const float *A,int *N1,int *N2,int *N3) +{ mgl_data_set_float(_DT_,A,*N1,*N2,*N3); } +void MGL_EXPORT mgl_data_set_double3_(uintptr_t *d, const double *A,int *N1,int *N2,int *N3) +{ mgl_data_set_double(_DT_,A,*N1,*N2,*N3); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_rearrange(HMDT d, long mx,long my,long mz) +{ + if(mx<1) return; // wrong mx + if(my<1) { my = d->nx*d->ny*d->nz/mx; mz = 1; } + else if(mz<1) mz = (d->nx*d->ny*d->nz)/(mx*my); + long m = mx*my*mz; + if(m==0 || m>d->nx*d->ny*d->nz) return; // too high desired dimensions + d->nx = mx; d->ny = my; d->nz = mz; d->NewId(); +} +void MGL_EXPORT mgl_data_rearrange_(uintptr_t *d, int *mx, int *my, int *mz) +{ mgl_data_rearrange(_DT_,*mx,*my,*mz); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_set_id(HMDT d, const char *ids) { d->id = ids; } +void MGL_EXPORT mgl_data_set_id_(uintptr_t *d, const char *eq,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_data_set_id(_DT_, s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_save(HCDT d, const char *fname,long ns) +{ + FILE *fp = fopen(fname,"w"); + if(!fp) return; + register long i,j,k; + long nx=d->GetNx(), ny=d->GetNy(), nz=d->GetNz(); + setlocale(LC_NUMERIC, "C"); + if(ns<0 || (ns>=nz && nz>1)) for(k=0;k(d); + if(dr && !dr->id.empty()) fprintf(fp,"## %s\n",dr->id.c_str()); + const mglDataC *dc = dynamic_cast(d); + if(dc && !dc->id.empty()) fprintf(fp,"## %s\n",dc->id.c_str()); + for(i=0;iv(j,i,k)); + fprintf(fp,"%g\n",d->v(nx-1,i,k)); + } + fprintf(fp,"\n"); + } + else + { // save selected slice + if(nz>1) for(i=0;iv(j,i,ns)); + fprintf(fp,"%g\n",d->v(nx-1,i,ns)); + } + else if(nsv(j,ns)); + } + setlocale(LC_NUMERIC, ""); + fclose(fp); +} +void MGL_EXPORT mgl_data_save_(uintptr_t *d, const char *fname,int *ns,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + mgl_data_save(_DT_,s,*ns); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT char *mgl_read_gz(gzFile fp) +{ + long size=1024,n=0,m; + char *buf=(char*)malloc(size); + while((m=gzread(fp,buf+size*n,size))>0) + { + if(ma) mgl_data_create(d, 1,1,1); + return false; + } + char *buf = mgl_read_gz(fp); + nb = strlen(buf); gzclose(fp); + + bool first=false; + register char ch; + for(i=nb-1;i>=0;i--) if(buf[i]>' ') break; + buf[i+1]=0; nb = i; // remove tailing spaces + for(i=0;i' ' && !first) first=true; + if(first && (ch==' ' || ch=='\t' || ch==',' || ch==';') && buf[i+1]>' ') k++; + } + first = false; + for(i=0;inx = mx>0 ? mx:1; d->ny = my>0 ? my:1; d->nz = mz>0 ? mz:1; + if(d->a && !d->link) delete [](d->a); + d->a = new mreal[d->nx*d->ny*d->nz]; + d->id.clear(); d->link=false; + memset(d->a,0,d->nx*d->ny*d->nz*sizeof(mreal)); +} +void MGL_EXPORT mgl_data_create_(uintptr_t *d, int *nx,int *ny,int *nz) +{ mgl_data_create(_DT_,*nx,*ny,*nz); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_link(HMDT d, mreal *A, long mx,long my,long mz) +{ + if(!A) return; + if(!d->link && d->a) delete [](d->a); + d->nx = mx>0 ? mx:1; d->ny = my>0 ? my:1; d->nz = mz>0 ? mz:1; + d->link=true; d->a=A; d->NewId(); +} +void MGL_EXPORT mgl_data_link_(uintptr_t *d, mreal *A, int *nx,int *ny,int *nz) +{ mgl_data_link(_DT_,A,*nx,*ny,*nz); } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_dim(HMDT d, const char *fname,long mx,long my,long mz) +{ + if(mx<=0 || my<=0 || mz<=0) return false; + gzFile fp = gzopen(fname,"r"); + if(!fp) return false; + char *buf = mgl_read_gz(fp); + gzclose(fp); + mglFromStr(d,buf,mx,my,mz); + free(buf); return true; +} +int MGL_EXPORT mgl_data_read_dim_(uintptr_t *d, const char *fname,int *mx,int *my,int *mz,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_data_read_dim(_DT_,s,*mx,*my,*mz); delete []s; return r; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_mat(HMDT d, const char *fname, long dim) +{ + if(dim<=0 || dim>3) return false; + gzFile fp = gzopen(fname,"r"); + if(!fp) return false; + long nx=1, ny=1, nz=1; + char *buf = mgl_read_gz(fp); + long nb = strlen(buf); gzclose(fp); + + register long j=0,i,l; + while(j' ') j++; + } + else if(dim==2) + { + sscanf(buf+j,"%ld%ld",&nx,&ny); + while(buf[j]!='\n' && j' ' && !first) first=true; + if(first && (ch==' ' || ch=='\t' || ch==',' || ch==';') && b[i+1]>' ') nx++; + } + } + } + else if(dim==3) + { + sscanf(buf+j,"%ld%ld%ld",&nx,&ny,&nz); + while(buf[j]!='\n' && j' ' && j' ' && j' ' && jGetNN(); + const mglData *b = dynamic_cast(d); +#pragma omp parallel + { + register mreal m=-INFINITY, v; + if(b) +#pragma omp for nowait + for(long i=0;ia[i]; m = mvthr(i); m = mm ? m1:m; } + } + return m1; +} +mreal MGL_EXPORT mgl_data_max_(uintptr_t *d) { return mgl_data_max(_DT_); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_min(HCDT d) +{ + mreal m1=INFINITY; + long nn=d->GetNN(); + const mglData *b = dynamic_cast(d); +#pragma omp parallel + { + register mreal m=INFINITY, v; + if(b) +#pragma omp for nowait + for(long i=0;ia[i]; m = m>v ? v:m; } + else +#pragma omp for nowait + for(long i=0;ivthr(i); m = m>v ? v:m; } +#pragma omp critical(min_dat) + { m1 = m1GetNN(); + const mglData *b = dynamic_cast(d); +#pragma omp parallel + { + register mreal m=0, v; + if(b) +#pragma omp for nowait + for(long i=0;ia[i]; m = mvthr(i); m = mm ? m1:m; } + } + return m1; +} +mreal MGL_EXPORT mgl_data_neg_max_(uintptr_t *d) { return mgl_data_neg_max(_DT_); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_pos_min(HCDT d) +{ + mreal m1=INFINITY; + long nn=d->GetNN(); + const mglData *b = dynamic_cast(d); +#pragma omp parallel + { + register mreal m=INFINITY, v; + if(b) +#pragma omp for nowait + for(long i=0;ia[i]; m = m>v && v>0 ? v:m; } + else +#pragma omp for nowait + for(long i=0;ivthr(i); m = m>v && v>0 ? v:m; } +#pragma omp critical(min_dat) + { m1 = m1GetNx(), ny=d->GetNy(), nn=d->GetNN(); +#pragma omp parallel + { + register mreal m=-INFINITY, v; + long im=-1,jm=-1,km=-1; +#pragma omp for nowait + for(long ii=0;iivthr(ii); + if(m < v) + { m=v; im=ii%nx; jm=(ii/nx)%ny; km=ii/(nx*ny); } + } +#pragma omp critical(max_int) + if(m1 < m) { m1=m; *i=im; *j=jm; *k=km; } + } + return m1; +} +mreal MGL_EXPORT mgl_data_max_int_(uintptr_t *d, int *i, int *j, int *k) +{ long ii,jj,kk; mreal res=mgl_data_max_int(_DT_,&ii,&jj,&kk); + *i=ii; *j=jj; *k=kk; return res; } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_min_int(HCDT d, long *i, long *j, long *k) +{ + mreal m1=INFINITY; + long nx=d->GetNx(), ny=d->GetNy(), nn=d->GetNN(); +#pragma omp parallel + { + register mreal m=INFINITY, v; + long im=-1,jm=-1,km=-1; +#pragma omp for nowait + for(long ii=0;iivthr(ii); + if(m > v) + { m=v; im=ii%nx; jm=(ii/nx)%ny; km=ii/(nx*ny); } + } +#pragma omp critical(min_int) + if(m1 > m) { m1=m; *i=im; *j=jm; *k=km; } + } + return m1; +} +mreal MGL_EXPORT mgl_data_min_int_(uintptr_t *d, int *i, int *j, int *k) +{ long ii,jj,kk; mreal res=mgl_data_min_int(_DT_,&ii,&jj,&kk); + *i=ii; *j=jj; *k=kk; return res; } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_max_real(HCDT d, mreal *x, mreal *y, mreal *z) +{ + long im=-1,jm=-1,km=-1; + long nx=d->GetNx(), ny=d->GetNy(), nz=d->GetNz(); + mreal m=mgl_data_max_int(d,&im,&jm,&km), v, v1, v2; + *x=im; *y=jm; *z=km; + + v = d->v(im,jm,km); + if(nx>2) + { + if(im==0) im=1; + if(im==nx-1)im=nx-2; + v1 = d->v(im+1,jm,km); v2 = d->v(im-1,jm,km); + *x = (v1+v2-2*v)==0 ? im : im+(v1-v2)/(v1+v2-2*v)/2; + } + if(ny>2) + { + if(jm==0) jm=1; + if(jm==ny-1)jm=ny-2; + v1 = d->v(im,jm+1,km); v2 = d->v(im,jm-1,km); + *y = (v1+v2-2*v)==0 ? jm : jm+(v1-v2)/(v1+v2-2*v)/2; + } + if(nz>2) + { + if(km==0) km=1; + if(km==nz-1)km=nz-2; + v1 = d->v(im,jm,km+1); v2 = d->v(im,jm,km-1); + *z = (v1+v2-2*v)==0 ? km : km+(v1-v2)/(v1+v2-2*v)/2; + } + return m; +} +mreal MGL_EXPORT mgl_data_max_real_(uintptr_t *d, mreal *x, mreal *y, mreal *z) +{ return mgl_data_max_real(_DT_,x,y,z); } +//----------------------------------------------------------------------------- +mreal MGL_EXPORT mgl_data_min_real(HCDT d, mreal *x, mreal *y, mreal *z) +{ + long im=-1,jm=-1,km=-1; + long nx=d->GetNx(), ny=d->GetNy(), nz=d->GetNz(); + mreal m=mgl_data_min_int(d,&im,&jm,&km), v, v1, v2; + *x=im; *y=jm; *z=km; + + v = d->v(im,jm,km); + if(nx>2) + { + if(im==0) im=1; + if(im==nx-1)im=nx-2; + v1 = d->v(im+1,jm,km); v2 = d->v(im-1,jm,km); + *x = (v1+v2-2*v)==0 ? im : im+(v1-v2)/(v1+v2-2*v)/2; + } + if(ny>2) + { + if(jm==0) jm=1; + if(jm==ny-1)jm=ny-2; + v1 = d->v(im,jm+1,km); v2 = d->v(im,jm-1,km); + *y = (v1+v2-2*v)==0 ? jm : jm+(v1-v2)/(v1+v2-2*v)/2; + } + if(nz>2) + { + if(km==0) km=1; + if(km==nz-1)km=nz-2; + v1 = d->v(im,jm,km+1); v2 = d->v(im,jm,km-1); + *z = (v1+v2-2*v)==0 ? km : km+(v1-v2)/(v1+v2-2*v)/2; + } + return m; +} +mreal MGL_EXPORT mgl_data_min_real_(uintptr_t *d, mreal *x, mreal *y, mreal *z) +{ return mgl_data_min_real(_DT_,x,y,z); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_fill_x(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0],ny=t->p[1]; + mreal *b=t->a, x1=t->b[0], dx=t->b[1]; + register char dir = t->s[0]; + if(dir=='x') +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) b[i0] = x1+dx*(i0%nx); + else if(dir=='y') +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) b[i0] = x1+dx*((i0/nx)%ny); + else if(dir=='z') +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) b[i0] = x1+dx*(i0/(nx*ny)); + return 0; +} +void MGL_EXPORT mgl_data_fill(HMDT d, mreal x1,mreal x2,char dir) +{ + if(mgl_isnan(x2)) x2=x1; + if(dir<'x' || dir>'z') dir='x'; + long par[2]={d->nx,d->ny}; + mreal b[2]={x1,x2-x1}; + if(dir=='x') b[1] *= d->nx>1 ? 1./(d->nx-1):0; + if(dir=='y') b[1] *= d->ny>1 ? 1./(d->ny-1):0; + if(dir=='z') b[1] *= d->nz>1 ? 1./(d->nz-1):0; + mglStartThread(mgl_fill_x,0,d->nx*d->ny*d->nz,d->a,b,0,par,0,0,0,&dir); +} +void MGL_EXPORT mgl_data_fill_(uintptr_t *d, mreal *x1,mreal *x2,const char *dir,int) +{ mgl_data_fill(_DT_,*x1,*x2,*dir); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_norm(HMDT d, mreal v1,mreal v2,long sym,long dim) +{ + long s,nn=d->nx*d->ny*d->nz; + mreal a1=INFINITY,a2=-INFINITY,v,*a=d->a; + s = dim*d->ny*(d->nz>1 ? d->nx : 1); + for(long i=s;ia[i] ? a[i]:a1; a2 = a2v2) { v=v1; v1=v2; v2=v; } // swap if uncorrect + if(sym) // use symmetric + { + v2 = -v1>v2 ? -v1:v2; v1 = -v2; + a2 = -a1>a2 ? -a1:a2; a1 = -a2; + } + v2 = (v2-v1)/(a2-a1); v1 = v1-a1*v2; +#pragma omp parallel for + for(long i=s;inx, ny=d->ny, nz=d->nz; + mreal *b; + + // simple checking + if(rx>=nx) rx=nx-1; if(rx<1) rx=1; + if(ry>=ny) ry=ny-1; if(ry<1) ry=1; + if(rz>=nz) rz=nz-1; if(rz<1) rz=1; + // new sizes + kx = 1+(nx-1)/rx; ky = 1+(ny-1)/ry; kz = 1+(nz-1)/rz; + b = new mreal[kx*ky*kz]; + if(!smooth) +#pragma omp parallel for collapse(3) + for(long k=0;ka[i*rx+nx*(j*ry+ny*rz*k)]; + else +#pragma omp parallel for collapse(3) + for(long k=0;ka[i1+nx*(j1+ny*k1)]; + b[i+kx*(j+ky*k)] = s/(dx*dy*dz); + } + if(!d->link) delete [](d->a); + d->a=b; d->nx = kx; d->ny = ky; d->nz = kz; d->NewId(); d->link=false; +} +void MGL_EXPORT mgl_data_squeeze_(uintptr_t *d, int *rx,int *ry,int *rz,int *smooth) +{ mgl_data_squeeze(_DT_,*rx,*ry,*rz,*smooth); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_extend(HMDT d, long n1, long n2) +{ + long nx=d->nx, ny=d->ny, nz=d->nz; + if(nz>2 || n1==0) return; + long mx, my, mz; + mreal *b=0; + if(n1>0) // extend to higher dimension(s) + { + n2 = n2>0 ? n2:1; + mx = nx; my = ny>1?ny:n1; mz = ny>1 ? n1 : n2; + b = new mreal[mx*my*mz]; + if(ny>1) +#pragma omp parallel for + for(long i=0;ia, nx*ny*sizeof(mreal)); + else +#pragma omp parallel for + for(long i=0;ia, nx*sizeof(mreal)); + } + else + { + mx = -n1; my = n2<0 ? -n2 : nx; mz = n2<0 ? nx : ny; + if(n2>0 && ny==1) mz = n2; + b = new mreal[mx*my*mz]; + if(n2<0) +#pragma omp parallel for collapse(2) + for(long j=0;ja[j]; + else +#pragma omp parallel for collapse(2) + for(long j=0;ja[j]; + if(n2>0 && ny==1) +#pragma omp parallel for + for(long i=0;ia, mx*my*sizeof(mreal)); + } + if(!d->link) delete [](d->a); + d->a=b; d->nx=mx; d->ny=my; d->nz=mz; + d->NewId(); d->link=false; +} +void MGL_EXPORT mgl_data_extend_(uintptr_t *d, int *n1, int *n2) +{ mgl_data_extend(_DT_,*n1,*n2); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_transpose(HMDT d, const char *dim) +{ + long nx=d->nx, ny=d->ny, nz=d->nz, n; + mreal *b=new mreal[nx*ny*nz], *a=d->a; + if(!strcmp(dim,"xyz")) memcpy(b,a,nx*ny*nz*sizeof(mreal)); + else if(!strcmp(dim,"xzy") || !strcmp(dim,"zy")) + { +#pragma omp parallel for collapse(3) + for(long j=0;jnx; d->nx=nx; d->ny=ny; d->nz=nz; + if(nx!=n) d->NewId(); +} +void MGL_EXPORT mgl_data_transpose_(uintptr_t *d, const char *dim,int l) +{ char *s=new char[l+1]; memcpy(s,dim,l); s[l]=0; + mgl_data_transpose(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_modify(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + const mglFormula *f = (const mglFormula *)(t->v); + long nx=t->p[0],ny=t->p[1],nz=t->p[2]; + mreal *b=t->a, dx,dy,dz; + const mreal *v=t->b, *w=t->c; + dx=nx>1?1/(nx-1.):0; dy=ny>1?1/(ny-1.):0; dz=nz>1?1/(nz-1.):0; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(i*dx, j*dy, k*dz, b[i0], v?v[i0]:0, w?w[i0]:0); + } + return 0; +} +void MGL_EXPORT mgl_data_modify(HMDT d, const char *eq,long dim) +{ + long nx=d->nx, ny=d->ny, nz=d->nz, par[3]={nx,ny,nz}; + mglFormula f(eq); + if(dim<0) dim=0; + if(nz>1) // 3D array + { + par[2] -= dim; if(par[2]<0) par[2]=0; + mglStartThread(mgl_modify,0,nx*ny*par[2],d->a+nx*ny*dim,0,0,par,&f); + } + else // 2D or 1D array + { + par[1] -= dim; if(par[1]<0) par[1]=0; + mglStartThread(mgl_modify,0,nx*par[1],d->a+nx*dim,0,0,par,&f); + } +} +void MGL_EXPORT mgl_data_modify_(uintptr_t *d, const char *eq,int *dim,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_data_modify(_DT_,s,*dim); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_modify_gen(void *par) +{ + mglThreadV *t=(mglThreadV *)par; + const mglFormula *f = (const mglFormula *)(t->v); + register long nx=t->p[0],ny=t->p[1],nz=t->p[2]; + mreal *b=t->a, dx,dy,dz; + HCDT v=(HCDT)t->b, w=(HCDT)t->c; + dx=nx>1?1/(nx-1.):0; dy=ny>1?1/(ny-1.):0; dz=nz>1?1/(nz-1.):0; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=((i0/nx)%ny), k=i0/(nx*ny); + b[i0] = f->Calc(i*dx, j*dy, k*dz, b[i0], v?v->vthr(i0):0, w?w->vthr(i0):0); + } + return 0; +} +void MGL_EXPORT mgl_data_modify_vw(HMDT d, const char *eq,HCDT vdat,HCDT wdat) +{ + const mglData *v = dynamic_cast(vdat); + const mglData *w = dynamic_cast(wdat); + long nn = d->nx*d->ny*d->nz, par[3]={d->nx,d->ny,d->nz}; + if(vdat && vdat->GetNN()!=nn) return; + if(wdat && wdat->GetNN()!=nn) return; + mglFormula f(eq); + if(v && w) mglStartThread(mgl_modify,0,nn,d->a,v->a,w->a,par,&f); + else if(vdat && wdat) mglStartThreadV(mgl_modify_gen,nn,d->a,vdat,wdat,par,&f); + else if(v) mglStartThread(mgl_modify,0,nn,d->a,v->a,0,par,&f); + else if(vdat) mglStartThreadV(mgl_modify_gen,nn,d->a,vdat,0,par,&f); + else mglStartThread(mgl_modify,0,nn,d->a,0,0,par,&f); +} +void MGL_EXPORT mgl_data_modify_vw_(uintptr_t *d, const char *eq, uintptr_t *v, uintptr_t *w,int l) +{ char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + mgl_data_modify_vw(_DT_,s,_DA_(v),_DA_(w)); delete []s; } +//----------------------------------------------------------------------------- +#if MGL_HAVE_HDF4 +int MGL_EXPORT mgl_data_read_hdf4(HMDT d,const char *fname,const char *data) +{ + int32 sd = SDstart(fname,DFACC_READ), nn, i; + if(sd==-1) return false; // is not a HDF4 file + char name[64]; + SDfileinfo(sd,&nn,&i); + for(i=0;i3) continue; + long mm=dims[0]*dims[1]*dims[2]; + if(type==DFNT_FLOAT32) + { + float *b = new float[mm]; + SDreaddata(sds,in,0,dims,b); + mgl_data_set_float(d,b,dims[2],dims[1],dims[0]); + delete []b; + } + if(type==DFNT_FLOAT64) + { + double *b = new double[mm]; + SDreaddata(sds,in,0,dims,b); + mgl_data_set_double(d,b,dims[2],dims[1],dims[0]); + delete []b; + } + } + SDendaccess(sds); + } + SDend(sd); + return true; +} +#else +int MGL_EXPORT mgl_data_read_hdf4(HMDT ,const char *,const char *) +{ mglGlobalMess += "HDF4 support was disabled. Please, enable it and rebuild MathGL.\n"; return false; } +#endif +//----------------------------------------------------------------------------- +#if MGL_HAVE_HDF5 +void MGL_EXPORT mgl_data_save_hdf(HCDT dat,const char *fname,const char *data,int rewrite) +{ + const mglData *d = dynamic_cast(dat); // NOTE: only for mglData + if(!d) { mglData d(dat); mgl_data_save_hdf(&d,fname,data,rewrite); return; } + hid_t hf,hd,hs; + hsize_t dims[3]; + long rank = 3, res; + H5Eset_auto(0,0); + res=H5Fis_hdf5(fname); + if(res>0 && !rewrite) hf = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); + else hf = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(hf<0) return; + if(d->nz==1 && d->ny == 1) { rank=1; dims[0]=d->nx; } + else if(d->nz==1) { rank=2; dims[0]=d->ny; dims[1]=d->nx; } + else { rank=3; dims[0]=d->nz; dims[1]=d->ny; dims[2]=d->nx; } + hs = H5Screate_simple(rank, dims, 0); +#if MGL_USE_DOUBLE + hid_t mem_type_id = H5T_NATIVE_DOUBLE; +#else + hid_t mem_type_id = H5T_NATIVE_FLOAT; +#endif + hd = H5Dcreate(hf, data, mem_type_id, hs, H5P_DEFAULT); + H5Dwrite(hd, mem_type_id, hs, hs, H5P_DEFAULT, d->a); + H5Dclose(hd); H5Sclose(hs); H5Fclose(hf); +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_hdf(HMDT d,const char *fname,const char *data) +{ + hid_t hf,hd,hs; + hsize_t dims[3]; + long rank, res = H5Fis_hdf5(fname); + if(res<=0) return mgl_data_read_hdf4(d,fname,data); + hf = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + if(hf<0) return false; + hd = H5Dopen(hf,data); + if(hd<0) return false; + hs = H5Dget_space(hd); + rank = H5Sget_simple_extent_ndims(hs); + if(rank>0 && rank<=3) + { + H5Sget_simple_extent_dims(hs,dims,0); + if(rank==1) { dims[2]=dims[0]; dims[0]=dims[1]=1; } + else if(rank==2) { dims[2]=dims[1]; dims[1]=dims[0]; dims[0]=1; } +// else if(rank>3) continue; + mgl_data_create(d,dims[2],dims[1],dims[0]); +#if MGL_USE_DOUBLE + H5Dread(hd, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, d->a); +#else + H5Dread(hd, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, d->a); +#endif + } + H5Sclose(hs); H5Dclose(hd); H5Fclose(hf); return true; +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_datas_hdf(const char *fname, char *buf, long size) +{ + hid_t hf,hg,hd,ht; + if(!buf || size<1) return 0; + buf[0]=0; + hf = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); + if(!hf) return 0; + hg = H5Gopen(hf,"/"); + hsize_t num, i; + char name[256]; + long pos=0,len; + H5Gget_num_objs(hg, &num); // replace by H5G_info_t t; H5Gget_info(hg,&t); num=t.nlinks; + for(i=0;isize) break; + if(H5Tget_class(ht)==H5T_FLOAT || H5Tget_class(ht)==H5T_INTEGER) + { strcat(buf,name); strcat(buf,"\t"); pos += len+1; } + H5Dclose(hd); H5Tclose(ht); + } + H5Gclose(hg); H5Fclose(hf); + return i; +} +#else +void MGL_EXPORT mgl_data_save_hdf(HCDT ,const char *,const char *,int ) +{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; } +int MGL_EXPORT mgl_datas_hdf(const char *, char *, long ) +{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return 0;} +int MGL_EXPORT mgl_data_read_hdf(HMDT ,const char *,const char *) +{ mglGlobalMess += "HDF5 support was disabled. Please, enable it and rebuild MathGL.\n"; return false;} +#endif +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_hdf_(uintptr_t *d, const char *fname, const char *data,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *t=new char[n+1]; memcpy(t,data,n); t[n]=0; + int r = mgl_data_read_hdf(_DT_,s,t); delete []s; delete []t; return r; } +void MGL_EXPORT mgl_data_save_hdf_(uintptr_t *d, const char *fname, const char *data, int *rewrite,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *t=new char[n+1]; memcpy(t,data,n); t[n]=0; + mgl_data_save_hdf(_DT_,s,t,*rewrite); delete []s; delete []t; } +//----------------------------------------------------------------------------- +bool MGL_EXPORT mgl_add_file(long &kx,long &ky, long &kz, mreal *&b, mglData *d,bool as_slice) +{ + if(as_slice && d->nz==1) + { + if(kx==d->nx && d->ny==1) + { + b = (mreal *)realloc(b,kx*(ky+1)*sizeof(mreal)); + memcpy(b+kx*ky,d->a,kx*sizeof(mreal)); ky++; + } + else if(kx==d->nx && ky==d->ny) + { + b = (mreal *)realloc(b,kx*ky*(kz+1)*sizeof(mreal)); + memcpy(b+kx*ky*kz,d->a,kx*ky*sizeof(mreal)); kz++; + } + else return false; + } + else + { + if(d->ny*d->nz==1 && ky*kz==1) + { + b = (mreal *)realloc(b,(kx+d->nx)*sizeof(mreal)); + memcpy(b+kx,d->a,d->nx*sizeof(mreal)); kx+=d->nx; + } + else if(kx==d->nx && kz==1 && d->nz==1) + { + b = (mreal *)realloc(b,kx*(ky+d->ny)*sizeof(mreal)); + memcpy(b+kx*ky,d->a,kx*d->ny*sizeof(mreal)); ky+=d->ny; + } + else if(kx==d->nx && ky==d->ny) + { + b = (mreal *)realloc(b,kx*kx*(kz+d->nz)*sizeof(mreal)); + memcpy(b+kx*ky*kz,d->a,kx*ky*d->nz*sizeof(mreal)); kz+=d->nz; + } + else return false; + } + return true; +} +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_range(HMDT dat, const char *templ, double from, double to, double step, int as_slice) +{ + mglData d; + mreal t = from, *b; + long kx,ky,kz,n=strlen(templ)+20; + char *fname = new char[n]; + + //read first file + do{ snprintf(fname,n,templ,t); t+= step; } while(!mgl_data_read(&d,fname) && t<=to); + + if(t>to) { delete []fname; return false; } + kx = d.nx; ky = d.ny; kz = d.nz; + b = (mreal *)malloc(kx*ky*kz*sizeof(mreal)); + memcpy(b,d.a,kx*ky*kz*sizeof(mreal)); + + // read other files + for(;t<=to;t+=step) + { + snprintf(fname,n,templ,t); + if(mgl_data_read(&d,fname)) + if(!mgl_add_file(kx,ky,kz,b,&d,as_slice)) + { delete []fname; free(b); return false; } + } + dat->Set(b,kx,ky,kz); + delete []fname; free(b); + return true; +} +int MGL_EXPORT mgl_data_read_range_(uintptr_t *d, const char *fname, mreal *from, mreal *to, mreal *step, int *as_slice,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_data_read_range(_DT_,s,*from,*to,*step,*as_slice); delete []s; return r; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_data_read_all(HMDT dat, const char *templ, int as_slice) +{ +#ifndef WIN32 + mglData d; + glob_t res; + size_t i; + mreal *b; + long kx,ky,kz; + glob (templ, GLOB_TILDE, NULL, &res); + + //read first file + for(i=0;i=res.gl_pathc) + { globfree (&res); return false; } + kx = d.nx; ky = d.ny; kz = d.nz; + b = (mreal *)malloc(kx*ky*kz*sizeof(mreal)); + memcpy(b,d.a,kx*ky*kz*sizeof(mreal)); + + for(;iSet(b,kx,ky,kz); + + globfree (&res); free(b); + return true; +#else + return false; +#endif +} +int MGL_EXPORT mgl_data_read_all_(uintptr_t *d, const char *fname, int *as_slice,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + int r = mgl_data_read_all(_DT_,s,*as_slice); delete []s; return r; } +//----------------------------------------------------------------------------- diff --git a/src/data_png.cpp b/src/data_png.cpp new file mode 100644 index 0000000..1f907f6 --- /dev/null +++ b/src/data_png.cpp @@ -0,0 +1,197 @@ +/*************************************************************************** + * data_png.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/data.h" +#if MGL_HAVE_PNG +#include +#endif +//----------------------------------------------------------------------------- +size_t MGL_NO_EXPORT mgl_col_dif(unsigned char *c1,unsigned char *c2,bool sum) +{ + size_t res,d1=abs(long(c1[0])-long(c2[0])), + d2=abs(long(c1[1])-long(c2[1])),d3=abs(long(c1[2])-long(c2[2])); + if(sum) res = d1+d2+d3; + else res = mgl_max(d1,mgl_max(d2,d3)); + return res; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT unsigned char *mgl_create_scheme(const char *scheme,long &num) +{ + unsigned char *c=0,*cc=new unsigned char[3*strlen(scheme)+3],*c1,*c2; + size_t nc=1,np=0,l=strlen(scheme); + mglColor col; + for(size_t i=0;i=v2) return; + long num=0; + FILE *fp = fopen(fname, "rb"); + if (!fp) return; + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + if (!png_ptr) { fclose(fp); return; } + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { png_destroy_read_struct(&png_ptr,0,0); fclose(fp); return; } + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { png_destroy_read_struct(&png_ptr,&info_ptr,0); fclose(fp); return; } + + png_init_io(png_ptr, fp); + png_read_png(png_ptr, info_ptr, + PNG_TRANSFORM_STRIP_ALPHA|PNG_TRANSFORM_PACKING| + PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_EXPAND,0); + unsigned char **rows = png_get_rows(png_ptr, info_ptr); + unsigned char *c = mgl_create_scheme(scheme,num); + if(num>1) + { + long w=png_get_image_width(png_ptr, info_ptr); + long h=png_get_image_height(png_ptr, info_ptr); + d->Create(w,h,1); +#pragma omp parallel for collapse(2) + for(long i=0;iny;i++) for(long j=0;jnx;j++) + { + size_t pos=0,val,mval=256; + for(long k=0;kny-i-1]+3*j,true); + if(val==0) { pos=k; break; } + if(vala[j+d->nx*i] = v1 + pos*(v2-v1)/num; + } + } + png_destroy_read_struct(&png_ptr, &info_ptr,&end_info); + fclose(fp); delete []c; +#else + mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_export(HCDT dd, const char *fname, const char *scheme,mreal v1,mreal v2,long ns) +{ +#if MGL_HAVE_PNG + long nx=dd->GetNx(), ny=dd->GetNy(), nz=dd->GetNz(); + const mglData *md = dynamic_cast(dd); + if(v1>v2) return; + if(ns<0 || ns>=nz) ns=0; + if(v1==v2) + { + v1 = INFINITY; v2=-INFINITY; + if(md) +//#pragma omp parallel for // NOTE comparison here + for(long i=0;ia[i]; if(vvv2) v2=vv; } + else +//#pragma omp parallel for // NOTE comparison here + for(long i=0;ivthr(i); if(vvv2) v2=vv; } + } + if(v1==v2) return; + long num=0; + unsigned char *c = mgl_create_scheme(scheme,num); + if(num<2) { delete []c; return; } + + unsigned char **p = new unsigned char*[ny]; + unsigned char *d = new unsigned char[3*nx*ny]; +#pragma omp parallel for + for(long i=0;ia[j+nx*(i+ny*ns)]; + register long k = long(num*(vv-v1)/(v2-v1)); + if(k<0) k=0; if(k>=num) k=num-1; + memcpy(d+3*(j+i*nx),c+3*k,3); + } + else +#pragma omp parallel for collapse(2) + for(long i=0;iv(j,i,ns)-v1)/(v2-v1)); + if(k<0) k=0; if(k>=num) k=num-1; + memcpy(d+3*(j+i*nx),c+3*k,3); + } + delete []c; + + FILE *fp = fopen(fname, "wb"); + if (!fp) { delete []p; delete []d; return; } + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + if (!png_ptr) { delete []p; delete []d; fclose(fp); return; } + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { png_destroy_write_struct(&png_ptr,0); delete []p; delete []d; fclose(fp); return; } + png_init_io(png_ptr, fp); + png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + png_set_IHDR(png_ptr, info_ptr, nx, ny, 8, PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_set_rows(png_ptr, info_ptr, p); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0); + png_write_end(png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); delete []p; delete []d; +#else + mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_export_(uintptr_t *d, const char *fname, const char *scheme,mreal *v1,mreal *v2,int *ns,int l,int n) +{ + char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0; + mgl_data_export(_DT_,s,f,*v1,*v2,*ns); + delete []s; delete []f; +} +void MGL_EXPORT mgl_data_import_(uintptr_t *d, const char *fname, const char *scheme,mreal *v1,mreal *v2,int l,int n) +{ + char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,scheme,n); f[n]=0; + mgl_data_import(_DT_,s,f,*v1,*v2); + delete []s; delete []f; +} +//----------------------------------------------------------------------------- diff --git a/src/def_font.cpp b/src/def_font.cpp new file mode 100644 index 0000000..e2b5de1 --- /dev/null +++ b/src/def_font.cpp @@ -0,0 +1,1240 @@ +#include "mgl2/define.h" +unsigned MGL_EXPORT mgl_numg=411, mgl_cur=243136; +float MGL_EXPORT mgl_fact=35.7143; +long MGL_EXPORT mgl_gen_fnt[411][6] = { + {0x21,166,41,0,39,164}, + {0x22,204,43,398,38,570}, + {0x23,250,33,798,32,930}, + {0x24,250,81,1122,80,1446}, + {0x25,373,130,1926,129,2446}, + {0x26,388,128,3220,127,3732}, + {0x27,89,20,4494,19,4574}, + {0x28,166,22,4688,20,4776}, + {0x29,166,22,4896,21,4984}, + {0x2a,250,154,5110,169,5726}, + {0x2b,342,12,6740,8,6788}, + {0x2c,125,34,6836,34,6972}, + {0x2d,166,4,7176,2,7192}, + {0x2e,125,21,7204,18,7288}, + {0x2f,138,4,7396,2,7412}, + {0x30,250,43,7424,41,7596}, + {0x31,250,28,7842,27,7954}, + {0x32,250,43,8116,41,8288}, + {0x33,250,91,8534,90,8898}, + {0x34,250,15,9438,12,9498}, + {0x35,250,72,9570,77,9858}, + {0x36,250,68,10320,66,10592}, + {0x37,250,13,10988,11,11040}, + {0x38,250,85,11106,83,11446}, + {0x39,250,68,11944,67,12216}, + {0x3a,138,43,12618,36,12790}, + {0x3b,138,57,13006,52,13234}, + {0x3c,342,7,13546,5,13574}, + {0x3d,342,9,13604,4,13640}, + {0x3e,342,7,13664,5,13692}, + {0x3f,222,77,13722,73,14030}, + {0x40,460,136,14468,136,15012}, + {0x41,361,47,15828,50,16016}, + {0x42,333,90,16316,90,16676}, + {0x43,333,72,17216,72,17504}, + {0x44,361,67,17936,68,18204}, + {0x45,305,57,18612,54,18840}, + {0x46,277,51,19164,47,19368}, + {0x47,361,88,19650,86,20002}, + {0x48,361,60,20518,56,20758}, + {0x49,166,27,21094,26,21202}, + {0x4a,186,45,21358,43,21538}, + {0x4b,361,70,21796,69,22076}, + {0x4c,305,37,22490,39,22638}, + {0x4d,444,49,22872,47,23068}, + {0x4e,361,47,23350,50,23538}, + {0x4f,361,63,23838,60,24090}, + {0x50,278,66,24450,69,24714}, + {0x51,361,85,25128,83,25468}, + {0x52,333,69,25966,69,26242}, + {0x53,277,91,26656,94,27020}, + {0x54,305,32,27584,30,27712}, + {0x55,361,68,27892,68,28164}, + {0x56,361,42,28572,41,28740}, + {0x57,472,72,28986,75,29274}, + {0x58,361,82,29724,80,30052}, + {0x59,361,55,30532,54,30752}, + {0x5a,305,32,31076,30,31204}, + {0x5b,166,18,31384,16,31456}, + {0x5c,138,4,31552,2,31568}, + {0x5d,166,17,31580,16,31648}, + {0x5e,234,7,31744,5,31772}, + {0x5f,250,4,31802,2,31818}, + {0x60,166,17,31830,16,31898}, + {0x61,222,112,31994,115,32442}, + {0x62,250,70,33132,71,33412}, + {0x63,222,62,33838,60,34086}, + {0x64,250,72,34446,79,34734}, + {0x65,222,53,35208,53,35420}, + {0x66,166,57,35738,53,35966}, + {0x67,250,139,36284,149,36840}, + {0x68,250,60,37734,67,37974}, + {0x69,138,45,38376,44,38556}, + {0x6a,138,71,38820,71,39104}, + {0x6b,250,69,39530,72,39806}, + {0x6c,138,30,40238,30,40358}, + {0x6d,388,102,40538,108,40946}, + {0x6e,250,66,41594,67,41858}, + {0x6f,250,53,42260,50,42472}, + {0x70,250,68,42772,72,43044}, + {0x71,250,64,43476,68,43732}, + {0x72,166,61,44140,61,44384}, + {0x73,194,79,44750,86,45066}, + {0x74,138,47,45582,49,45770}, + {0x75,250,54,46064,56,46280}, + {0x76,250,54,46616,53,46832}, + {0x77,361,72,47150,81,47438}, + {0x78,250,83,47924,89,48256}, + {0x79,250,74,48790,79,49086}, + {0x7a,222,27,49560,25,49668}, + {0x7b,239,55,49818,54,50038}, + {0x7c,99,4,50362,2,50378}, + {0x7d,239,55,50390,55,50610}, + {0x7e,270,41,50940,40,51104}, + {0xa1,165,41,51344,39,51508}, + {0xa2,250,81,51742,84,52066}, + {0xa3,250,135,52570,148,53110}, + {0xa4,250,73,53998,72,54290}, + {0xa5,250,71,54722,69,55006}, + {0xa6,99,9,55420,4,55456}, + {0xa7,250,152,55480,156,56088}, + {0xa8,166,43,57024,36,57196}, + {0xa9,380,92,57412,87,57780}, + {0xaa,137,95,58302,103,58682}, + {0xab,250,69,59300,73,59576}, + {0xac,300,6,60014,4,60038}, + {0xad,166,4,60062,2,60078}, + {0xae,380,106,60090,106,60514}, + {0xaf,166,4,61150,2,61166}, + {0xb0,199,43,61178,41,61350}, + {0xb1,342,17,61596,10,61664}, + {0xb2,150,41,61724,41,61888}, + {0xb3,150,74,62134,75,62430}, + {0xb4,166,16,62880,16,62944}, + {0xb5,250,68,63040,67,63312}, + {0xb6,295,48,63714,47,63906}, + {0xb7,125,21,64188,18,64272}, + {0xb8,166,40,64380,43,64540}, + {0xb9,150,23,64798,26,64890}, + {0xba,155,46,65046,45,65230}, + {0xbb,250,73,65500,72,65792}, + {0xbc,375,43,66224,40,66396}, + {0xbd,375,74,66636,69,66932}, + {0xbe,375,95,67346,89,67726}, + {0xbf,222,86,68260,82,68604}, + {0xc0,361,65,69096,66,69356}, + {0xc1,361,65,69752,66,70012}, + {0xc2,361,55,70408,55,70628}, + {0xc3,361,89,70958,92,71314}, + {0xc4,361,91,71866,86,72230}, + {0xc5,361,91,72746,90,73110}, + {0xc6,444,86,73650,85,73994}, + {0xc7,333,108,74504,116,74936}, + {0xc8,305,74,75632,70,75928}, + {0xc9,305,74,76348,70,76644}, + {0xca,305,65,77064,59,77324}, + {0xcb,305,101,77678,90,78082}, + {0xcc,166,45,78622,42,78802}, + {0xcd,166,45,79054,42,79234}, + {0xce,166,36,79486,31,79630}, + {0xcf,166,72,79816,62,80104}, + {0xd0,361,70,80476,69,80756}, + {0xd1,361,88,81170,92,81522}, + {0xd2,361,80,82074,76,82394}, + {0xd3,361,81,82850,76,83174}, + {0xd4,361,71,83630,65,83914}, + {0xd5,361,104,84304,102,84720}, + {0xd6,361,107,85332,96,85760}, + {0xd7,319,12,86336,10,86384}, + {0xd8,361,78,86444,80,86756}, + {0xd9,361,87,87236,84,87584}, + {0xda,361,87,88088,84,88436}, + {0xdb,361,76,88940,73,89244}, + {0xdc,361,112,89682,104,90130}, + {0xdd,361,73,90754,70,91046}, + {0xde,277,70,91466,75,91746}, + {0xdf,250,98,92196,98,92588}, + {0xe0,222,130,93176,131,93696}, + {0xe1,222,129,94482,131,94998}, + {0xe2,222,120,95784,120,96264}, + {0xe3,222,155,96984,157,97604}, + {0xe4,222,156,98546,151,99170}, + {0xe5,222,156,100076,155,100700}, + {0xe6,333,127,101630,132,102138}, + {0xe7,222,97,102930,99,103318}, + {0xe8,222,71,103912,69,104196}, + {0xe9,222,72,104610,69,104898}, + {0xea,222,61,105312,58,105556}, + {0xeb,222,97,105904,89,106292}, + {0xec,138,40,106826,42,106986}, + {0xed,138,41,107238,42,107402}, + {0xee,138,33,107654,31,107786}, + {0xef,138,70,107972,62,108252}, + {0xf0,250,74,108624,72,108920}, + {0xf1,250,109,109352,109,109788}, + {0xf2,250,71,110442,66,110726}, + {0xf3,250,71,111122,66,111406}, + {0xf4,250,61,111802,55,112046}, + {0xf5,250,94,112376,92,112752}, + {0xf6,250,97,113304,86,113692}, + {0xf7,281,48,114208,38,114400}, + {0xf8,250,73,114628,76,114920}, + {0xf9,250,73,115376,72,115668}, + {0xfa,250,73,116100,72,116392}, + {0xfb,250,62,116824,61,117072}, + {0xfc,250,98,117438,92,117830}, + {0xfd,250,92,118382,95,118750}, + {0xfe,250,71,119320,72,119604}, + {0xff,250,118,120036,115,120508}, + {0x300,0,15,121198,16,121258}, + {0x301,0,16,121354,16,121418}, + {0x302,0,7,121514,5,121542}, + {0x303,0,40,121572,40,121732}, + {0x304,0,4,121972,2,121988}, + {0x305,0,4,122000,2,122016}, + {0x306,0,22,122028,20,122116}, + {0x307,0,21,122236,18,122320}, + {0x308,0,43,122428,36,122600}, + {0x309,0,44,122816,43,122992}, + {0x30a,0,43,123250,40,123422}, + {0x30b,0,36,123662,32,123806}, + {0x30c,0,7,123998,5,124026}, + {0x30d,0,4,124056,2,124072}, + {0x30e,0,9,124084,4,124120}, + {0x30f,0,36,124144,32,124288}, + {0x391,361,45,124480,46,124660}, + {0x392,333,71,124936,70,125220}, + {0x393,293,35,125640,33,125780}, + {0x394,361,8,125978,7,126010}, + {0x395,305,56,126052,52,126276}, + {0x396,305,32,126588,30,126716}, + {0x397,361,60,126896,56,127136}, + {0x398,361,105,127472,104,127892}, + {0x399,166,27,128516,26,128624}, + {0x39a,365,70,128780,69,129060}, + {0x39b,351,41,129474,40,129638}, + {0x39c,444,49,129878,47,130074}, + {0x39d,361,47,130356,50,130544}, + {0x39e,321,62,130844,54,131092}, + {0x39f,361,63,131416,60,131668}, + {0x3a0,361,52,132028,52,132236}, + {0x3a1,278,66,132548,69,132812}, + {0x3a2,0,0,133226,0,133226}, + {0x3a3,311,24,133226,22,133322}, + {0x3a4,305,32,133454,30,133582}, + {0x3a5,361,55,133762,56,133982}, + {0x3a6,381,76,134318,77,134622}, + {0x3a7,361,82,135084,80,135412}, + {0x3a8,372,81,135892,81,136216}, + {0x3a9,372,62,136702,60,136950}, + {0x3aa,166,71,137310,62,137594}, + {0x3ab,361,99,137966,92,138362}, + {0x3ac,271,84,138914,80,139250}, + {0x3ad,219,111,139730,110,140174}, + {0x3ae,256,71,140834,72,141118}, + {0x3af,137,52,141550,54,141758}, + {0x3b0,262,119,142082,110,142558}, + {0x3b1,271,66,143218,64,143482}, + {0x3b2,247,96,143866,99,144250}, + {0x3b3,237,47,144844,48,145032}, + {0x3b4,250,83,145320,80,145652}, + {0x3b5,219,94,146132,94,146508}, + {0x3b6,220,100,147072,101,147472}, + {0x3b7,256,55,148078,56,148298}, + {0x3b8,247,57,148634,56,148862}, + {0x3b9,137,34,149198,38,149334}, + {0x3ba,250,64,149562,66,149818}, + {0x3bb,248,48,150214,47,150406}, + {0x3bc,263,64,150688,63,150944}, + {0x3bd,227,33,151322,35,151454}, + {0x3be,220,137,151664,139,152212}, + {0x3bf,252,43,153046,41,153218}, + {0x3c0,250,67,153464,69,153732}, + {0x3c1,247,55,154146,53,154366}, + {0x3c2,220,79,154684,79,155000}, + {0x3c3,273,45,155474,43,155654}, + {0x3c4,238,46,155912,44,156096}, + {0x3c5,262,58,156360,58,156592}, + {0x3c6,311,73,156940,72,157232}, + {0x3c7,250,52,157664,51,157872}, + {0x3c8,347,54,158178,55,158394}, + {0x3c9,312,91,158724,90,159088}, + {0x3d1,276,96,159628,99,160012}, + {0x3d5,311,63,160606,64,160858}, + {0x3d6,381,95,161242,96,161622}, + {0x3f0,275,77,162198,76,162506}, + {0x3f1,250,63,162962,62,163214}, + {0x3f5,219,51,163586,50,163790}, + {0x410,356,47,164090,50,164278}, + {0x411,305,63,164578,60,164830}, + {0x412,325,92,165190,90,165558}, + {0x413,285,38,166098,38,166250}, + {0x414,332,71,166478,73,166762}, + {0x415,314,56,167200,54,167424}, + {0x416,510,145,167748,143,168328}, + {0x417,287,90,169186,89,169546}, + {0x418,361,58,170080,55,170312}, + {0x419,361,107,170642,104,171070}, + {0x41a,344,100,171694,99,172094}, + {0x41b,341,64,172688,64,172944}, + {0x41c,446,48,173328,47,173520}, + {0x41d,362,60,173802,56,174042}, + {0x41e,364,63,174378,60,174630}, + {0x41f,362,52,174990,52,175198}, + {0x420,285,65,175510,69,175770}, + {0x421,338,71,176184,72,176468}, + {0x422,309,32,176900,30,177028}, + {0x423,355,75,177208,78,177508}, + {0x424,384,76,177976,77,178280}, + {0x425,358,82,178742,80,179070}, + {0x426,357,59,179550,63,179786}, + {0x427,328,64,180164,63,180420}, + {0x428,497,71,180798,78,181082}, + {0x429,497,81,181550,89,181874}, + {0x42a,368,53,182408,50,182620}, + {0x42b,441,80,182920,75,183240}, + {0x42c,305,51,183690,48,183894}, + {0x42d,325,76,184182,76,184486}, + {0x42e,450,93,184942,89,185314}, + {0x42f,318,64,185848,64,186104}, + {0x430,224,113,186488,114,186940}, + {0x431,253,79,187624,78,187940}, + {0x432,237,84,188408,84,188744}, + {0x433,196,34,189248,32,189384}, + {0x434,231,59,189576,64,189812}, + {0x435,233,49,190196,48,190392}, + {0x436,360,144,190680,148,191256}, + {0x437,194,85,192144,88,192484}, + {0x438,262,56,193012,55,193236}, + {0x439,262,106,193566,103,193990}, + {0x43a,251,85,194608,87,194948}, + {0x43b,249,63,195470,64,195722}, + {0x43c,308,48,196106,48,196298}, + {0x43d,262,58,196586,56,196818}, + {0x43e,256,53,197154,50,197366}, + {0x43f,262,52,197666,52,197874}, + {0x440,249,71,198186,72,198470}, + {0x441,228,63,198902,60,199154}, + {0x442,217,40,199514,38,199674}, + {0x443,245,69,199902,73,200178}, + {0x444,338,134,200616,136,201152}, + {0x445,244,77,201968,81,202276}, + {0x446,262,57,202762,59,202990}, + {0x447,256,62,203344,63,203592}, + {0x448,383,76,203970,78,204274}, + {0x449,383,82,204742,85,205070}, + {0x44a,269,56,205580,54,205804}, + {0x44b,334,77,206128,75,206436}, + {0x44c,228,49,206886,48,207082}, + {0x44d,222,54,207370,55,207586}, + {0x44e,368,81,207916,79,208240}, + {0x44f,235,59,208714,59,208950}, + {0x210f,289,94,209304,101,209680}, + {0x2111,381,130,210286,125,210806}, + {0x2113,0,0,211556,0,211556}, + {0x211c,436,132,211556,135,212084}, + {0x2190,463,40,212894,44,213054}, + {0x2191,255,39,213318,44,213474}, + {0x2192,463,41,213738,44,213902}, + {0x2193,255,38,214166,44,214318}, + {0x2194,463,75,214582,86,214882}, + {0x2195,255,74,215398,86,215694}, + {0x2196,463,50,216210,66,216410}, + {0x2197,463,50,216806,65,217006}, + {0x2198,463,45,217396,63,217576}, + {0x2199,463,49,217954,64,218150}, + {0x2200,280,12,218534,11,218582}, + {0x2201,231,48,218648,47,218840}, + {0x2202,235,70,219122,72,219402}, + {0x2203,280,12,219834,10,219882}, + {0x2204,280,30,219942,30,220062}, + {0x2205,381,70,220242,70,220522}, + {0x2206,365,8,220942,7,220974}, + {0x2207,365,8,221016,7,221048}, + {0x2208,342,29,221090,27,221206}, + {0x2209,342,52,221368,56,221576}, + {0x220a,242,29,221912,27,222028}, + {0x220b,342,30,222190,27,222310}, + {0x220c,342,56,222472,55,222696}, + {0x220d,242,29,223026,28,223142}, + {0x220e,272,4,223310,2,223326}, + {0x220f,500,49,223338,47,223534}, + {0x2210,500,49,223816,47,224012}, + {0x2211,457,22,224294,20,224382}, + {0x2212,342,4,224502,2,224518}, + {0x2213,342,17,224530,10,224598}, + {0x2214,342,34,224658,26,224794}, + {0x2215,261,4,224950,2,224966}, + {0x2216,213,4,224978,2,224994}, + {0x2217,261,135,225006,133,225546}, + {0x2218,175,43,226344,40,226516}, + {0x2219,175,21,226756,18,226840}, + {0x221a,463,19,226948,18,227024}, + {0x221b,463,93,227132,93,227504}, + {0x221c,463,35,228062,30,228202}, + {0x221d,342,65,228382,65,228642}, + {0x221e,463,85,229032,85,229372}, + {0x221f,342,6,229882,4,229906}, + {0x2220,342,6,229930,4,229954}, + {0x2221,342,33,229978,42,230110}, + {0x2222,342,48,230362,52,230554}, + {0x2223,132,4,230866,2,230882}, + {0x2224,202,12,230894,8,230942}, + {0x2225,261,9,230990,4,231026}, + {0x2226,304,20,231050,14,231130}, + {0x2227,310,7,231214,5,231242}, + {0x2228,310,7,231272,5,231300}, + {0x2229,310,26,231330,25,231434}, + {0x222a,310,26,231584,24,231688}, + {0x222b,229,67,231832,70,232100}, + {0x222c,350,137,232520,140,233068}, + {0x222d,471,205,233908,210,234728}, + {0x222e,249,117,235988,126,236456}, + {0x222f,370,209,237212,232,238048}, + {0x2260,342,20,239440,18,239520}, + {0x2261,342,14,239628,6,239684}, + {0x2262,342,28,239720,26,239832}, + {0x2263,342,19,239988,8,240064}, + {0x2264,342,12,240112,7,240160}, + {0x2265,342,12,240202,7,240250}, + {0x2266,342,17,240292,9,240360}, + {0x2267,342,17,240414,9,240482}, + {0x2268,342,28,240536,23,240648}, + {0x2269,342,28,240786,23,240898}, + {0x226a,466,15,241036,10,241096}, + {0x226b,466,15,241156,10,241216}, + {0x226c,233,80,241276,84,241596}, + {0x226d,342,55,242100,60,242320}, + {0x226e,342,20,242680,19,242760}, + {0x226f,342,20,242874,19,242954}, + {0x27c2,346,8,243068,6,243100} +}; +short MGL_EXPORT mgl_buf_fnt[243136] = { +88,88,94,88,117,278,117,282,118,286,118,297,117,311,113,322,108,331,101,336,92,338,81,336,74,331,69,323,66,312,65,300,65,289,66,284,66,278,16383,16383,118,21,116,30,113,37,107,43,100,47,92,49,83,47,76,43,70,37,66,30,65,22,66,13,70,6,75,0,82,-2,91,-3,100,-2,107,0,113,6,116,13,118,21,150,215,154,243,158,268,162,289,165,306,166,318,165,324,162,330,157,334,151,337,145,338,138,337,132,334,127,330,124,324,123,316,124,307,126,291,129,270,134,244,139,215,16383,16383,65,215,70,243,75,268,78,289,80,306,81,318,80,324,77,330,73,334,67,337,60,338,53,337,47,334,42,330,40,324,39,316,39,307,42,291,45,270, +107,43,107,0,113,37,113,37,107,0,113,6,113,37,113,6,116,30,116,30,113,6,116,13,116,30,116,13,118,21,65,22,66,13,66,30,66,30,66,13,70,6,66,30,70,6,70,37,70,37,70,6,75,0,70,37,75,0,76,43,76,43,75,0,82,-2,76,43,82,-2,83,47,83,47,82,-2,91,-3,83,47,91,-3,92,49,92,49,91,-3,100,-2,92,49,100,-2,100,47,100,47,100,-2,107,0,100,47,107,0,107,43,118,297,117,311,117,278,118,297,117,278,117,282,118,297,117,282,118,286,118,297,118,286,118,290,118,297,118,290,118,294,117,278,117,311,113,322,117,278,113,322,108,331,117,278,108,331,101,336,117,278,101,336,94,88,92,338,81,336,88,88,92,338,88,88,94,88,92,338,94,88,101,336,66,284,66,278,69,323,69,323,66,278,88,88,69,323,88,88,74,331,74,331,88,88,81,336,66,312,65,300,65,297,66,312,65,297,65,293,66,312,65,293,65,289,66,312,65,289,66,284,66,312,66,284,69,323, +150,215,154,243,158,268,162,289,165,306,166,318,165,324,162,330,157,334,151,337,145,338,138,337,132,334,127,330,124,324,123,316,124,307,126,291,129,270,134,244,139,215,16383,16383,65,215,70,243,75,268,78,289,80,306,81,318,80,324,77,330,73,334,67,337,60,338,53,337,47,334,42,330,40,324,39,316,39,307,42,291,45,270,50,244,55,215,248,203,248,230,200,230,214,331,185,331,171,230,104,230,119,331,90,331,75,230,17,230,17,203,71,203,60,136,3,136,3,108,56,108,40,0,69,0,85,108,152,108,137,0,166,0,181,108,235,108,235,136,185,136,195,203,16383,16383,166,203,156,136,89,136,100,203,132,319,154,314,172,304,186,291,197,273,205,250,213,250,213,305,202,314,189,321, +123,316,124,307,124,324,124,324,124,307,126,291,124,324,126,291,127,330,127,330,126,291,129,270,127,330,129,270,132,334,132,334,129,270,134,244,132,334,134,244,138,337,138,337,134,244,139,215,138,337,139,215,145,338,145,338,139,215,150,215,145,338,150,215,151,337,151,337,150,215,154,243,151,337,154,243,157,334,157,334,154,243,158,268,157,334,158,268,162,330,162,330,158,268,162,289,162,330,162,289,165,324,165,324,162,289,165,306,165,324,165,306,166,318,39,316,39,307,40,324,40,324,39,307,42,291,40,324,42,291,42,330,42,330,42,291,45,270,42,330,45,270,47,334,47,334,45,270,50,244,47,334,50,244,53,337,53,337,50,244,55,215,53,337,55,215,60,338,60,338,55,215,65,215,60,338,65,215,67,337,67,337,65,215,70,243,67,337,70,243,73,334,73,334,70,243,75,268,73,334,75,268,77,330,77,330,75,268,78,289,77,330,78,289,80,324,80,324,78,289,80,306,80,324,80,306,81,318, +248,203,248,230,200,230,214,331,185,331,171,230,104,230,119,331,90,331,75,230,17,230,17,203,71,203,60,136,3,136,3,108,56,108,40,0,69,0,85,108,152,108,137,0,166,0,181,108,235,108,235,136,185,136,195,203,16383,16383,166,203,156,136,89,136,100,203,132,319,154,314,172,304,186,291,197,273,205,250,213,250,213,305,202,314,189,321,173,326,155,330,132,332,132,363,115,363,115,332,88,328,64,319,44,304,31,283,26,257,29,234,38,214,54,196,79,177,115,155,115,14,90,17,69,27,52,42,38,63,30,90,22,90, +90,331,75,230,85,108,85,108,75,230,71,203,85,108,71,203,69,0,69,0,71,203,60,136,69,0,60,136,56,108,56,108,60,136,3,136,56,108,3,136,3,108,17,230,17,203,71,203,17,230,71,203,75,230,90,331,85,108,89,136,90,331,89,136,100,203,90,331,100,203,104,230,90,331,104,230,119,331,185,331,171,230,181,108,181,108,171,230,166,203,181,108,166,203,166,0,166,0,166,203,156,136,166,0,156,136,152,108,152,108,156,136,89,136,152,108,89,136,85,108,104,230,100,203,166,203,104,230,166,203,171,230,200,230,214,331,195,203,195,203,214,331,185,331,195,203,185,331,185,136,185,136,185,331,181,108,185,136,181,108,235,108,200,230,195,203,248,203,200,230,248,203,248,230,185,136,235,108,235,136,166,0,152,108,137,0,69,0,56,108,40,0, +132,319,154,314,172,304,186,291,197,273,205,250,213,250,213,305,202,314,189,321,173,326,155,330,132,332,132,363,115,363,115,332,88,328,64,319,44,304,31,283,26,257,29,234,38,214,54,196,79,177,115,155,115,14,90,17,69,27,52,42,38,63,30,90,22,90,22,26,38,16,54,9,71,4,91,1,115,0,115,-43,132,-43,132,0,164,6,191,17,211,32,224,54,229,85,228,96,227,105,225,115,222,123,219,130,210,141,199,152,185,164,163,178,132,195,16383,16383,115,204,93,219,79,232,69,243,64,254,63,266,65,281,71,293,81,304,96,313,115,319,16383,16383,132,147,156,132,172,118,182,105,188,90,189,74,187,55,181,40,170,28,154,20,132,14,343,107,341,127,335,143,325,155,312,163,295,165,267,159,241,143,220,120,206,91,200,60,203,38,212,18,225,4,242,-5,261,-8,286,-2,309,14,327,39,339,71,343,107,16383,16383,331,108,328,77,318,48,303,25,285,10,265,4,255,6,248,10,242,18,238,27,237,38,239,59,244,82,252,103,263,123,276,140,280,144,284,147,290,149,295,151,300,151,311,149,319,143,326,134,330,122,331,108,16383,16383,310,353,289,353,265,331,248,317,235,309,221,305,194,305,185,307,176,311,167,317,157,324,150,330,144,334,138,336,133,338,127,338,97,332,71,317,50,293,36,264,31,232,34,209,42,191,54,176,70,166,89,163,99,164,108,166,116,169,132,181,146,197,157,215, +132,319,154,314,155,330,155,330,154,314,172,304,155,330,172,304,173,326,173,326,172,304,186,291,173,326,186,291,189,321,189,321,186,291,197,273,189,321,197,273,202,314,202,314,197,273,205,250,202,314,205,250,213,305,213,305,205,250,213,250,228,96,227,105,229,85,229,85,227,105,225,115,229,85,225,115,224,54,224,54,225,115,222,123,224,54,222,123,219,130,211,32,224,54,219,130,211,32,219,130,210,141,211,32,210,141,199,152,211,32,199,152,191,17,191,17,199,152,189,74,191,17,189,74,187,55,191,17,187,55,181,40,191,17,181,40,170,28,191,17,170,28,164,6,188,90,189,74,199,152,188,90,199,152,185,164,188,90,185,164,182,105,132,147,156,132,163,178,163,178,156,132,172,118,163,178,172,118,185,164,185,164,172,118,182,105,132,14,132,147,132,195,132,14,132,195,115,155,132,14,115,155,132,-43,132,332,132,363,115,155,132,332,115,155,132,195,132,332,132,195,132,319,132,332,132,319,155,330,115,0,115,155,115,14,115,0,115,14,91,1,91,1,115,14,90,17,91,1,90,17,71,4,71,4,90,17,69,27,71,4,69,27,54,9,54,9,69,27,52,42,54,9,52,42,38,63,38,16,54,9,38,63,38,16,38,63,30,90,38,16,30,90,22,90,38,16,22,90,22,26,132,363,115,363,115,319,115,319,115,363,115,332,115,319,115,155,132,363,71,293,81,304,88,328,88,328,81,304,96,313,88,328,96,313,115,332,115,332,96,313,115,319,64,319,44,304,54,196,64,319,54,196,63,266,64,319,63,266,65,281,64,319,65,281,71,293,64,319,71,293,88,328,63,266,54,196,64,254,64,254,54,196,79,177,64,254,79,177,69,243,69,243,79,177,79,232,26,257,29,234,31,283,31,283,29,234,38,214,31,283,38,214,44,304,44,304,38,214,54,196,79,232,79,177,93,219,93,219,79,177,115,155,93,219,115,155,115,204,115,204,115,155,115,319,164,6,170,28,154,20,164,6,154,20,132,14,164,6,132,14,132,0,132,-43,115,155,115,0,132,-43,115,0,115,-43,132,195,132,147,163,178, +343,107,341,127,335,143,325,155,312,163,295,165,267,159,241,143,220,120,206,91,200,60,203,38,212,18,225,4,242,-5,261,-8,286,-2,309,14,327,39,339,71,343,107,16383,16383,331,108,328,77,318,48,303,25,285,10,265,4,255,6,248,10,242,18,238,27,237,38,239,59,244,82,252,103,263,123,276,140,280,144,284,147,290,149,295,151,300,151,311,149,319,143,326,134,330,122,331,108,16383,16383,310,353,289,353,265,331,248,317,235,309,221,305,194,305,185,307,176,311,167,317,157,324,150,330,144,334,138,336,133,338,127,338,97,332,71,317,50,293,36,264,31,232,34,209,42,191,54,176,70,166,89,163,99,164,108,166,116,169,132,181,146,197,157,215,165,234,171,255,172,276,172,289,171,294,171,299,179,296,187,294,194,292,201,292,209,291,223,292,236,295,247,301,258,309,269,320,72,-8,95,-8,16383,16383,161,285,157,251,148,222,133,198,115,182,94,176,85,178,77,183,71,190,67,200,66,211,67,228,70,245,75,262,82,278,90,293,95,302,101,309,107,314,115,319,126,325,135,316,140,312,144,310,148,307,153,305,157,301,159,297,160,292,161,285,368,55,359,45,350,38,342,33,332,30,321,29,304,31,288,36,274,46,259,58,246,75,260,96,273,115,284,134,296,152,309,173,316,184,323,192,332,198,342,201,355,203,355,213,248,213,248,203,261,201,270,197,276,193,279,187,280,179,278,165,273,150,264,133,251,113,234,89,218,107,205,126,192,146,180,167,168,192,199,207,221,222,235,238,243,256,246,276,242,298,233,315,218,328,199,335,177,338,153,335,132,325,116,309,105,288,101,263,101,250,103,237,106,223,111,207,118,189,99,177,72,158,50,138,34,116,24,92,21,69,25,42,36,20,53,5,77,-3,107,-6,130,-4,151,0,172,9,193,22,214,39,233,22,250,9,266,0,283,-4,300,-6,319,-3,336,3,352,14,365,30,375,50,16383,16383,219,278,217,261,211,246,200,233,183,220,161,208,152,225,146,239,143,253,141,266,141,281,142,294,148,306,156,315,167,320,180,322,193,320,204,314,212,304,217,292,219,278,16383,16383,202,52,185,40,170,31,155,25,142,21,129,20,109,23,92,31,79,45,70,64,67,87,69,106,75,124,86,140,103,155,126,171,142,141,156,115,170,92,202,52,50,215,56,244, +326,134,330,122,335,143,335,143,330,122,331,108,339,71,331,108,328,77,339,71,328,77,327,39,327,39,328,77,318,48,327,39,318,48,309,14,309,14,318,48,303,25,309,14,303,25,286,-2,286,-2,303,25,285,10,286,-2,285,10,265,4,265,4,255,6,261,-8,261,-8,255,6,248,10,261,-8,248,10,242,18,242,-5,261,-8,242,18,242,-5,242,18,238,27,242,-5,238,27,237,38,242,-5,237,38,225,4,244,82,252,103,267,159,267,159,252,103,263,123,267,159,263,123,276,140,276,140,280,144,295,165,295,165,280,144,284,147,295,165,284,147,290,149,241,143,220,120,225,4,241,143,225,4,237,38,241,143,237,38,239,59,241,143,239,59,244,82,241,143,244,82,267,159,200,60,203,38,206,91,206,91,203,38,212,18,206,91,212,18,220,120,220,120,212,18,225,4,326,134,325,155,319,143,319,143,325,155,312,163,319,143,312,163,311,149,311,149,312,163,300,151,295,151,300,151,295,165,295,151,295,165,290,149,295,165,267,159,276,140,312,163,295,165,300,151,339,71,343,107,341,127,339,71,341,127,335,143,339,71,335,143,331,108,265,4,261,-8,286,-2,67,228,70,245,71,317,71,317,70,245,75,262,71,317,75,262,97,332,97,332,75,262,82,278,97,332,82,278,90,293,90,293,95,302,97,332,97,332,95,302,101,309,97,332,101,309,127,338,127,338,101,309,107,314,127,338,107,314,115,319,77,183,89,163,85,178,85,178,89,163,94,176,115,182,94,176,99,164,115,182,99,164,108,166,71,190,67,200,70,166,71,190,70,166,89,163,71,190,89,163,77,183,67,200,66,211,70,166,70,166,66,211,54,176,54,176,66,211,71,317,71,317,66,211,67,228,148,307,153,305,150,330,148,307,150,330,144,310,144,310,150,330,144,334,144,310,144,334,140,312,140,312,144,334,138,336,140,312,138,336,135,316,135,316,138,336,133,338,135,316,133,338,131,320,131,320,133,338,127,338,131,320,127,338,126,325,247,301,248,317,236,295,236,295,248,317,235,309,236,295,235,309,223,292,223,292,235,309,221,305,223,292,221,305,209,291,209,291,221,305,205,305,194,305,185,307,187,294,194,305,187,294,194,292,194,305,194,292,201,292,194,305,201,292,205,305,176,311,171,299,179,296,176,311,179,296,185,307,185,307,179,296,187,294,167,317,157,324,157,301,167,317,157,301,159,297,167,317,159,297,160,292,167,317,160,292,161,285,167,317,161,285,165,234,167,317,165,234,171,255,167,317,171,255,171,299,167,317,171,299,176,311,124,175,132,181,133,198,133,198,132,181,146,197,133,198,146,197,148,222,148,222,146,197,157,215,148,222,157,215,157,251,157,251,157,215,165,234,157,251,165,234,161,285,310,353,289,353,269,320,269,320,289,353,265,331,269,320,265,331,258,309,258,309,265,331,248,317,258,309,248,317,247,301,269,320,72,-8,95,-8,269,320,95,-8,310,353,172,276,172,281,172,285,172,276,172,285,172,289,172,276,172,289,171,294,172,276,171,294,171,299,172,276,171,299,171,255,116,169,124,175,133,198,116,169,133,198,115,182,116,169,115,182,108,166,157,324,150,330,153,305,157,324,153,305,157,301,31,232,34,209,36,264,36,264,34,209,42,191,36,264,42,191,50,293,50,293,42,191,54,176,50,293,54,176,71,317,94,176,89,163,99,164,127,338,115,319,126,325,209,291,205,305,201,292,325,155,326,134,335,143, +368,55,359,45,350,38,342,33,332,30,321,29,304,31,288,36,274,46,259,58,246,75,260,96,273,115,284,134,296,152,309,173,316,184,323,192,332,198,342,201,355,203,355,213,248,213,248,203,261,201,270,197,276,193,279,187,280,179,278,165,273,150,264,133,251,113,234,89,218,107,205,126,192,146,180,167,168,192,199,207,221,222,235,238,243,256,246,276,242,298,233,315,218,328,199,335,177,338,153,335,132,325,116,309,105,288,101,263,101,250,103,237,106,223,111,207,118,189,99,177,72,158,50,138,34,116,24,92,21,69,25,42,36,20,53,5,77,-3,107,-6,130,-4,151,0,172,9,193,22,214,39,233,22,250,9,266,0,283,-4,300,-6,319,-3,336,3,352,14,365,30,375,50,16383,16383,219,278,217,261,211,246,200,233,183,220,161,208,152,225,146,239,143,253,141,266,141,281,142,294,148,306,156,315,167,320,180,322,193,320,204,314,212,304,217,292,219,278,16383,16383,202,52,185,40,170,31,155,25,142,21,129,20,109,23,92,31,79,45,70,64,67,87,69,106,75,124,86,140,103,155,126,171,142,141,156,115,170,92,202,52,50,215,56,244,60,269,64,290,66,306,66,324,63,330,59,334,53,337,46,338,39,337,33,334,28,330,25,324,24,317,25,306,27,289,31,268,35,243,40,215,152,-79,116,-44,92,-8,77,31,69,76,67,127,69,180,77,223,92,261,116,295,152,330,147,338,104,307,69,270,44,227,29,179,24,126,29,75,44,27,69,-17,103,-56,146,-88,15,330,51,295,76,259,90,219,97,174,99,122,97,69,90,26,75,-11,51,-45,15,-79,19,-88,62,-56,97,-19,122,23,137,71,142,123,137,174,121,222,96,267,63,306,21,338,134,235,147,243,158,248,178,254,190,256,200,258,207,261,212,265,215,270,216,277,215,284,213,289,209,293,204,295,198,296,190,294,183,288,174,281,166,272,159,264,154,259,144,251,130,243,130,262,131,270,133,278,135,287,140,302,142,307,143,312,144,316,144,320,143,326,140,331,136,335,131,337,126,338,120,337,115,335,111,331,109,326,108,321,108,317,110,307,111,301,113,295,115,285,118,276,121,249,121,243,110,249,101,255,93,262,85,270,76,280,70,286,65,290,60,293,56,295,51,296,46,295,41,292,38,288,36,283, +153,335,132,325,142,294,142,294,132,325,141,281,142,141,141,281,132,325,142,141,132,325,126,171,118,189,103,155,126,171,118,189,126,171,132,325,118,189,132,325,116,309,118,189,116,309,111,207,99,177,72,158,75,124,99,177,75,124,86,140,99,177,86,140,103,155,99,177,103,155,118,189,72,158,50,138,53,5,72,158,53,5,67,87,72,158,67,87,69,106,72,158,69,106,75,124,79,45,70,64,77,-3,77,-3,70,64,67,87,53,5,50,138,36,20,36,20,50,138,34,116,36,20,34,116,25,42,25,42,34,116,24,92,25,42,24,92,21,69,101,250,103,237,105,288,105,288,103,237,106,223,105,288,106,223,116,309,116,309,106,223,111,207,185,40,170,31,172,9,172,9,170,31,155,25,172,9,155,25,151,0,151,0,155,25,142,21,151,0,142,21,130,-4,130,-4,142,21,129,20,109,23,92,31,107,-6,109,23,107,-6,130,-4,109,23,130,-4,129,20,79,45,77,-3,107,-6,79,45,107,-6,92,31,246,75,251,113,234,89,246,75,234,89,250,9,250,9,234,89,233,22,233,22,234,89,218,107,233,22,218,107,214,39,214,39,218,107,205,126,214,39,205,126,202,52,202,52,205,126,192,146,202,52,192,146,186,72,186,72,192,146,180,167,186,72,180,167,170,92,170,92,180,167,168,192,170,92,168,192,161,208,156,115,170,92,161,208,156,115,161,208,152,225,156,115,152,225,146,239,156,115,146,239,143,253,156,115,143,253,142,141,141,266,141,281,142,141,141,266,142,141,143,253,142,294,148,306,153,335,153,335,148,306,156,315,153,335,156,315,177,338,177,338,156,315,167,320,177,338,167,320,180,322,180,322,193,320,199,335,199,335,193,320,204,314,199,335,204,314,218,328,218,328,204,314,212,304,218,328,212,304,217,292,217,261,221,222,219,278,219,278,221,222,233,315,233,315,221,222,235,238,233,315,235,238,242,298,242,298,235,238,243,256,242,298,243,256,246,276,218,328,217,292,219,278,218,328,219,278,233,315,199,335,177,338,180,322,183,220,168,192,199,207,183,220,199,207,200,233,200,233,199,207,221,222,200,233,221,222,211,246,211,246,221,222,217,261,183,220,161,208,168,192,193,22,214,39,202,52,193,22,202,52,185,40,193,22,185,40,172,9,246,75,250,9,259,58,259,58,250,9,266,0,259,58,266,0,274,46,274,46,266,0,283,-4,274,46,283,-4,288,36,288,36,283,-4,300,-6,288,36,300,-6,304,31,304,31,300,-6,319,-3,304,31,319,-3,321,29,321,29,319,-3,336,3,321,29,336,3,332,30,270,197,276,193,355,213,355,213,276,193,279,187,355,213,279,187,280,179,280,179,284,134,296,152,280,179,296,152,309,173,309,173,316,184,280,179,280,179,316,184,323,192,280,179,323,192,332,198,342,201,355,203,355,213,342,201,355,213,332,198,332,198,355,213,280,179,261,201,270,197,355,213,261,201,355,213,248,213,261,201,248,213,248,203,280,179,278,165,284,134,284,134,278,165,273,150,284,134,273,150,273,115,273,115,273,150,264,133,273,115,264,133,260,96,260,96,264,133,251,113,260,96,251,113,246,75,375,50,368,55,365,30,365,30,368,55,359,45,365,30,359,45,352,14,352,14,359,45,350,38,352,14,350,38,342,33,342,33,332,30,336,3,342,33,336,3,352,14,77,-3,67,87,53,5,101,250,105,288,101,263, +50,215,56,244,60,269,64,290,66,306,66,324,63,330,59,334,53,337,46,338,39,337,33,334,28,330,25,324,24,317,25,306,27,289,31,268,35,243,40,215,152,-79,116,-44,92,-8,77,31,69,76,67,127,69,180,77,223,92,261,116,295,152,330,147,338,104,307,69,270,44,227,29,179,24,126,29,75,44,27,69,-17, +24,317,25,306,25,324,25,324,25,306,27,289,25,324,27,289,28,330,28,330,27,289,31,268,28,330,31,268,33,334,33,334,31,268,35,243,33,334,35,243,39,337,39,337,35,243,40,215,39,337,40,215,46,338,46,338,40,215,50,215,46,338,50,215,53,337,53,337,50,215,56,244,53,337,56,244,59,334,59,334,56,244,60,269,59,334,60,269,63,330,63,330,60,269,64,290,63,330,64,290,66,324,66,324,64,290,66,306,66,324,66,306,66,318, +152,-79,116,-44,92,-8,77,31,69,76,67,127,69,180,77,223,92,261,116,295,152,330,147,338,104,307,69,270,44,227,29,179,24,126,29,75,44,27,69,-17,103,-56,146,-88,15,330,51,295,76,259,90,219,97,174,99,122,97,69,90,26,75,-11,51,-45,15,-79,19,-88,62,-56,97,-19,122,23,137,71,142,123,137,174,121,222,96,267,63,306,21,338, +24,126,29,75,29,179,29,179,29,75,44,27,29,179,44,27,44,227,44,227,44,27,69,-17,44,227,69,-17,67,127,67,127,69,270,44,227,116,295,152,330,147,338,116,295,147,338,104,307,116,295,104,307,92,261,67,127,69,180,69,270,69,270,69,180,77,223,69,270,77,223,104,307,104,307,77,223,92,261,116,-44,92,-8,103,-56,116,-44,103,-56,146,-88,116,-44,146,-88,152,-79,77,31,69,76,69,-17,77,31,69,-17,103,-56,77,31,103,-56,92,-8,67,127,69,-17,69,76, +15,330,51,295,76,259,90,219,97,174,99,122,97,69,90,26,75,-11,51,-45,15,-79,19,-88,62,-56,97,-19,122,23,137,71,142,123,137,174,121,222,96,267,63,306,21,338,134,235,147,243,158,248,178,254,190,256,200,258,207,261,212,265,215,270,216,277,215,284,213,289,209,293,204,295,198,296,190,294,183,288,174,281,166,272,159,264,154,259,144,251, +97,174,99,122,99,122,122,23,99,122,97,69,122,23,97,69,97,-19,97,-19,97,69,90,26,97,-19,90,26,75,-11,97,174,99,122,121,222,121,222,99,122,122,23,121,222,122,23,137,174,137,174,122,23,137,71,137,174,137,71,142,123,96,267,63,306,76,259,96,267,76,259,90,219,96,267,90,219,97,174,96,267,97,174,121,222,51,295,76,259,63,306,51,295,63,306,21,338,51,295,21,338,15,330,15,-79,19,-88,51,-45,51,-45,19,-88,62,-56,51,-45,62,-56,75,-11,75,-11,62,-56,97,-19, +134,235,147,243,158,248,178,254,190,256,200,258,207,261,212,265,215,270,216,277,215,284,213,289,209,293,204,295,198,296,190,294,183,288,174,281,166,272,159,264,154,259,144,251,130,243,130,262,131,270,133,278,135,287,140,302,142,307,143,312,144,316,144,320,143,326,140,331,136,335,131,337,126,338,120,337,115,335,111,331,109,326,108,321,108,317,110,307,111,301,113,295,115,285,118,276,121,249,121,243,110,249,101,255,93,262,85,270,76,280,70,286,65,290,60,293,56,295,51,296,46,295,41,292,38,288,36,283,35,277,36,270,40,265,46,261,56,257,69,254,78,252,87,249,97,246,106,242,117,235,106,229,97,224,88,221,78,218,65,215,53,213,45,210,39,205,35,200,34,193,35,187,37,182,41,178,46,176,52,175,57,176,61,177,65,179,74,188,81,196,92,207,94,210,97,212,105,218,112,222,121,228,121,224,120,212,119,201,118,192,115,183,113,174,111,169,109,163,108,159,107,154,107,151,108,145,110,140,114,136,119,133,124,132,130,133,136,136,140,141,143,146,145,152,144,154,144,157,143,161,141,164,140,169,136,179,130,212,130,228,134,225,140,221,147,217,153,212,161,205,169,196,175,188,182,182,187,178,193,175,199,175,205,176,210,178,216,188,217,194,215,201,212,206,206,210,198,213,186,215,176,218,165,220,147,228,138,233,318,110,318,143,188,143,188,273,155,273,155,143,24,143,24,110,155,110,155,-20,188,-20,188,110,41,-69,60,-58,76,-44,88,-27,95,-10,98,7,96,22,90,34,81,43,70,49,57,51,47,49,39,46,33,40,29,32,27,22,29,13,32,6,38,1,46,-1,56,-2,60,-2,63,-1,66,-1,68,0,73,0,75,-1,78,-4,78,-6,76,-16,71,-27,63,-38,51,-49,36,-60,142,97,142,128,20,128,20,97,90,22,89,30,85,38,79,44,71,49,63,50,54,49,46,45,40,39,37,31,35,22,37,13,40,6,46,0,54,-3,63,-5,71,-3,79,0,85,6,89,13,90,22,143,338,110,338,-3,-6,30,-6,238,165,232,222,218,270,194,307,164,330,127,338,84,329,52,304,29,266,16,220,12,168,16,118,27,71,48,31,80,3,125,-6,168,2,200,29,222,67,234,114,238,165,16383,16383,190,162,187,108,179,65,166,33,148,13,125,6,102,13,84,33,71,65,63,109,60,165,63,220,71,265,84,298,101,318,124,325,148,318,166,298,179,265,187,219,190,162,197,0,197,7,178,8,164,12,155,18,151,27,150,38,150,336,145,338,55,292,55,286,69,291,74,293,84,295,88,296,92,296,97,295,101,293,104,288,106,281,107,272,107,47,105,33,100,22,92,14,78,10,59,7,59,0,237,69,230,71,221,57,212,48,203,42,193,39,182,38,65,38, +69,254,69,254,78,252,69,254,78,252,70,286,69,254,70,286,65,290,69,254,65,290,60,293,69,254,60,293,56,295,69,254,56,295,56,257,51,296,46,295,46,261,51,296,46,261,56,257,51,296,56,257,56,295,36,283,36,270,38,288,38,288,36,270,40,265,38,288,40,265,41,292,41,292,40,265,46,261,41,292,46,261,46,295,81,196,86,201,88,221,88,221,86,201,89,204,88,221,89,204,97,224,97,224,89,204,92,207,97,224,92,207,94,210,94,210,97,212,97,224,97,224,97,212,106,229,78,218,65,215,69,183,78,218,69,183,74,188,78,218,74,188,81,196,78,218,81,196,88,221,110,140,114,136,111,169,111,169,114,136,113,174,115,183,113,174,114,136,115,183,114,136,119,133,144,157,143,161,143,146,144,157,143,146,145,152,144,157,145,152,144,154,141,164,140,169,140,141,141,164,140,141,143,146,141,164,143,146,143,161,136,179,134,190,136,136,136,179,136,136,140,141,136,179,140,141,140,169,134,190,132,201,136,136,136,136,132,201,130,212,136,136,130,212,130,133,130,133,130,212,130,224,126,338,120,337,120,258,126,338,120,258,121,249,126,338,121,249,121,228,126,338,121,228,124,132,126,338,124,132,130,133,126,338,130,133,130,224,126,338,130,224,130,243,126,338,130,243,130,255,126,338,130,255,131,337,121,243,121,228,121,249,120,337,115,335,115,285,120,337,115,285,118,276,120,337,118,276,119,267,120,337,119,267,120,258,113,295,115,285,115,335,113,295,115,335,111,331,113,295,111,331,111,301,204,295,198,296,200,258,200,258,198,296,190,294,200,258,190,294,190,256,190,256,190,294,183,288,190,256,183,288,178,254,178,254,183,288,174,281,178,254,174,281,168,251,168,251,174,281,166,272,168,251,166,272,159,264,159,264,154,259,158,248,158,248,154,259,149,255,158,248,149,255,147,243,147,243,149,255,144,251,147,243,144,251,137,247,130,243,130,228,134,225,130,243,134,225,134,235,130,243,134,235,137,247,137,247,134,235,147,243,176,218,165,220,169,196,176,218,169,196,175,188,176,218,175,188,182,182,176,218,182,182,186,215,199,175,205,176,206,210,206,210,205,176,210,178,206,210,210,178,212,206,212,206,210,178,213,183,212,206,213,183,215,201,215,201,213,183,216,188,215,201,216,188,217,194,198,213,186,215,187,178,198,213,187,178,193,175,198,213,193,175,199,175,198,213,199,175,206,210,216,277,215,284,215,270,215,270,215,284,213,289,215,270,213,289,212,265,212,265,213,289,209,293,212,265,209,293,207,261,207,261,209,293,204,295,207,261,204,295,200,258,159,264,158,248,168,251,161,205,169,196,165,220,161,205,165,220,156,224,161,205,156,224,153,212,147,228,138,233,140,221,147,228,140,221,147,217,147,228,147,217,153,212,147,228,153,212,156,224,143,326,140,331,142,307,143,326,142,307,143,312,143,326,143,312,144,316,143,326,144,316,144,320,133,278,135,287,136,335,136,335,135,287,138,296,136,335,138,296,140,331,140,331,138,296,140,302,140,331,140,302,142,307,131,337,130,255,130,262,131,337,130,262,131,270,131,337,131,270,133,278,131,337,133,278,136,335,134,235,134,225,140,221,134,235,140,221,138,233,124,132,121,228,121,224,124,132,121,224,120,212,124,132,120,212,119,201,124,132,119,201,119,133,118,192,115,183,119,133,118,192,119,133,119,201,101,215,105,218,106,229,106,229,105,218,112,222,106,229,112,222,117,235,117,235,112,222,121,228,117,235,121,228,121,243,76,280,78,252,85,270,85,270,78,252,87,249,85,270,87,249,93,262,93,262,87,249,97,246,93,262,97,246,101,255,101,255,97,246,106,242,101,255,106,242,110,249,110,249,106,242,117,235,110,249,117,235,121,243,108,317,109,312,109,326,109,326,109,312,110,307,109,326,110,307,111,331,111,331,110,307,111,301,111,169,109,163,110,140,110,140,109,163,108,159,110,140,108,159,108,145,108,145,108,159,107,154,108,145,107,154,107,151,65,215,53,213,57,176,65,215,57,176,61,177,65,215,61,177,65,179,65,215,65,179,69,183,34,193,35,187,35,200,35,200,35,187,37,182,35,200,37,182,39,205,39,205,37,182,41,178,39,205,41,178,45,210,45,210,41,178,46,176,45,210,46,176,53,213,53,213,46,176,52,175,53,213,52,175,57,176,70,286,78,252,76,280,106,229,97,212,101,215,108,317,109,326,108,321,187,178,186,215,182,182,36,270,36,283,35,277, +318,110,318,143,188,143,188,273,155,273,155,143,24,143,24,110,155,110,155,-20,188,-20,188,110,41,-69,60,-58,76,-44,88,-27,95,-10,98,7,96,22,90,34,81,43,70,49,57,51,47,49, +188,273,155,273,188,-20,188,-20,155,273,155,143,188,-20,155,143,155,110,155,110,155,143,24,143,155,110,24,143,24,110,188,110,318,110,188,143,188,143,318,110,318,143,188,-20,155,110,155,-20, +41,-69,60,-58,76,-44,88,-27,95,-10,98,7,96,22,90,34,81,43,70,49,57,51,47,49,39,46,33,40,29,32,27,22,29,13,32,6,38,1,46,-1,56,-2,60,-2,63,-1,66,-1,68,0,73,0,75,-1,78,-4,78,-6,76,-16,71,-27,63,-38,51,-49,36,-60,142,97,142,128,20,128,20,97,90,22,89,30,85,38,79,44,71,49,63,50,54,49,46,45,40,39,37,31,35,22,37,13,40,6,46,0,54,-3,63,-5,71,-3,79,0,85,6,89,13,90,22,143,338,110,338,-3,-6,30,-6,238,165,232,222,218,270,194,307,164,330, +63,-1,66,-1,70,49,70,49,66,-1,68,0,70,49,68,0,71,0,71,0,73,0,81,43,81,43,73,0,75,-1,81,43,75,-1,77,-3,27,22,29,13,29,32,29,32,29,13,32,6,29,32,32,6,33,40,33,40,32,6,38,1,33,40,38,1,39,46,39,46,38,1,46,-1,39,46,46,-1,47,49,47,49,46,-1,56,-2,47,49,56,-2,57,51,57,51,56,-2,60,-2,57,51,60,-2,70,49,70,49,60,-2,63,-1,98,7,96,22,95,-10,95,-10,96,22,90,34,95,-10,90,34,88,-27,88,-27,90,34,81,43,88,-27,81,43,78,-6,78,-6,76,-16,88,-27,88,-27,76,-16,76,-44,81,43,77,-3,78,-4,81,43,78,-4,78,-6,81,43,70,49,71,0,36,-60,41,-69,51,-49,51,-49,41,-69,60,-58,51,-49,60,-58,63,-38,63,-38,60,-58,76,-44,63,-38,76,-44,71,-27,71,-27,76,-44,76,-16, +142,97,142,128,20,128,20,97,90,22,89,30,85,38,79,44, +142,97,142,128,20,128,142,97,20,128,20,97, +90,22,89,30,85,38,79,44,71,49,63,50,54,49,46,45,40,39,37,31,35,22,37,13,40,6,46,0,54,-3,63,-5,71,-3,79,0,85,6,89,13,90,22,143,338,110,338,-3,-6,30,-6,238,165,232,222,218,270,194,307,164,330,127,338,84,329,52,304,29,266,16,220,12,168,16,118,27,71,48,31,80,3,125,-6,168,2, +35,22,37,13,37,31,37,31,37,13,40,6,37,31,40,6,40,39,40,39,40,6,46,0,40,39,46,0,46,45,46,45,46,0,54,-3,46,45,54,-3,54,49,54,49,54,-3,62,-5,54,49,62,-5,63,50,63,50,62,-5,71,-3,63,50,71,-3,71,49,71,49,71,-3,79,0,71,49,79,0,79,44,79,44,79,0,85,6,79,44,85,6,85,38,85,38,85,6,89,13,85,38,89,13,89,30,89,30,89,13,90,22, +143,338,110,338,-3,-6,30,-6,238,165,232,222,218,270,194,307, +143,338,110,338,-3,-6,143,338,-3,-6,30,-6, +238,165,232,222,218,270,194,307,164,330,127,338,84,329,52,304,29,266,16,220,12,168,16,118,27,71,48,31,80,3,125,-6,168,2,200,29,222,67,234,114,238,165,16383,16383,190,162,187,108,179,65,166,33,148,13,125,6,102,13,84,33,71,65,63,109,60,165,63,220,71,265,84,298,101,318,124,325,148,318,166,298,179,265,187,219,190,162,197,0,197,7,178,8,164,12,155,18,151,27,150,38,150,336,145,338,55,292,55,286,69,291,74,293,84,295,88,296,92,296,97,295,101,293,104,288,106,281,107,272,107,47,105,33,100,22,92,14,78,10,59,7,59,0,237,69,230,71,221,57,212,48,203,42,193,39,182,38,65,38,147,126,171,153,189,179,202,203,209,226,211,250,207,278, +101,318,124,325,124,325,127,338,124,325,148,318,127,338,148,318,164,330,164,330,148,318,166,298,164,330,166,298,194,307,194,307,166,298,179,265,194,307,179,265,187,219,166,33,168,2,179,65,179,65,168,2,200,29,179,65,200,29,187,108,187,108,200,29,190,162,194,307,190,162,200,29,194,307,200,29,218,270,218,270,200,29,222,67,218,270,222,67,232,222,232,222,222,67,234,114,232,222,234,114,238,165,125,6,125,-6,148,13,148,13,125,-6,168,2,148,13,168,2,166,33,71,265,84,298,84,329,84,329,84,298,101,318,84,329,101,318,127,338,127,338,101,318,124,325,12,168,16,118,16,220,16,220,16,118,27,71,16,220,27,71,29,266,29,266,27,71,48,31,29,266,48,31,52,304,52,304,48,31,63,109,52,304,63,109,60,165,60,165,63,220,52,304,52,304,63,220,71,265,52,304,71,265,84,329,102,13,84,33,80,3,102,13,80,3,125,-6,102,13,125,-6,125,6,80,3,84,33,71,65,80,3,71,65,63,109,80,3,63,109,48,31,194,307,187,219,190,162, +197,0,197,7,178,8,164,12,155,18,151,27,150,38,150,336,145,338,55,292,55,286,69,291,74,293,84,295,88,296,92,296,97,295,101,293,104,288,106,281,107,272,107,47,105,33,100,22,92,14,78,10,59,7,59,0,237,69,230,71,221,57,212,48,203,42,193,39,182,38,65,38,147,126,171,153,189,179,202,203,209,226,211,250,207,278,195,302,176,321,150,334,119,338,86,333,59,320,39,299,24,271,15,238,26,236,38,262,50,280,63,292, +100,22,92,14,197,0,197,0,92,14,78,10,197,0,78,10,59,7,79,294,84,295,145,338,145,338,84,295,88,296,145,338,88,296,92,296,92,296,97,295,145,338,145,338,97,295,101,293,145,338,101,293,104,288,164,12,155,18,107,47,107,47,155,18,151,27,107,47,151,27,107,272,106,281,107,272,145,338,106,281,145,338,104,288,145,338,55,292,69,291,145,338,69,291,74,293,145,338,74,293,79,294,150,38,150,336,145,338,150,38,145,338,107,272,150,38,107,272,151,27,197,0,197,7,178,8,197,0,178,8,164,12,197,0,164,12,105,33,197,0,105,33,100,22,197,0,59,7,59,0,105,33,164,12,107,47,69,291,55,292,55,286, +237,69,230,71,221,57,212,48,203,42,193,39,182,38,65,38,147,126,171,153,189,179,202,203,209,226,211,250,207,278,195,302,176,321,150,334,119,338,86,333,59,320,39,299,24,271,15,238,26,236,38,262,50,280,63,292,79,299,99,301,123,298,142,289,156,275,165,255,169,230,166,205,159,181,146,155,128,129,103,100,15,6,15,0,210,0,31,255,43,275,57,290,71,300,87,306,105,308,123,306,138,300,149,290,157,275,159,257,157,240,152,224,143,211,132,199,118,190,112,186,105,183,96,179,87,176,76,172,76,165,92,165,104,164,113,163,121,162,127,160,146,152,161,141,171,127,178,109,180,88,176,63,167,42,153,26,135,15,114,11,106,11,99,13,90,15,82,20,71,26,64,31, +26,236,38,262,39,299,39,299,38,262,50,280,39,299,50,280,59,320,59,320,50,280,63,292,59,320,63,292,86,333,86,333,63,292,79,299,86,333,79,299,99,301,99,301,123,298,119,338,119,338,123,298,150,334,24,271,15,238,26,236,24,271,26,236,39,299,166,205,171,153,169,230,169,230,171,153,176,321,176,321,171,153,189,179,176,321,189,179,195,302,195,302,189,179,202,203,195,302,202,203,207,278,207,278,202,203,209,226,207,278,209,226,211,250,176,321,150,334,156,275,176,321,156,275,165,255,176,321,165,255,169,230,150,334,123,298,142,289,150,334,142,289,156,275,159,181,146,155,147,126,159,181,147,126,171,153,159,181,171,153,166,205,15,0,210,0,15,6,15,6,210,0,65,38,15,6,65,38,103,100,103,100,65,38,147,126,103,100,147,126,128,129,128,129,147,126,146,155,119,338,86,333,99,301,212,48,203,42,210,0,210,0,203,42,193,39,210,0,193,39,182,38,210,0,182,38,65,38,237,69,230,71,221,57,237,69,221,57,212,48,237,69,212,48,210,0, +31,255,43,275,57,290,71,300,87,306,105,308,123,306,138,300,149,290,157,275,159,257,157,240,152,224,143,211,132,199,118,190,112,186,105,183,96,179,87,176,76,172,76,165,92,165,104,164,113,163,121,162,127,160,146,152,161,141,171,127,178,109,180,88,176,63,167,42,153,26,135,15,114,11,106,11,99,13,90,15,82,20,71,26,64,31,57,35,51,38,41,40,34,39,29,36,25,32,22,27,21,22,23,12,30,4,41,-1,57,-5,76,-6,103,-4,130,0,154,9,175,22,193,40,200,52,207,65,211,79,214,94,215,109,214,125,212,139,207,152,201,164,194,174,187,180,181,185,173,190,164,195,152,200,170,213,183,226,192,241,197,255,199,270,195,292,184,311,168,326,146,335,121,338,92,334,68,323,48,306,33,284,22,257,237,84,237,116,185,116,185,338,163,338,6,116,6,84,146,84,146,0,185,0,185,84,16383,16383,146,116,26,116,146,287,219,340,214,344,210,339,206,335,202,333,197,331,87,331,32,213,32,208,34,206,38,206,65,204,89,199,110,191,129,182,145,171,156,159,166,146,172,131,177,114,178,96,174,71,164,48,149,29,131,16,110,12,104,12,98,14,90,17,83,21,75,27,66,34,58,39,51,41,45,43,38,43,30,42,24,40,19,36,17,31,16,24,19,13,27,5,40,-1,58,-5,79,-6,99,-5,117,-2,134,1,149,8,164,17,182,33,196,51,206,71,211,95,213,122,213,137,211,150,207,162,202,174,195,185,178,205,159,220,137,232,108,241,70,249,90,291,188,291,192,292,198,294,200,296,201,298,223,342,185,337,152,329,123,317, +22,257,31,255,33,284,33,284,31,255,43,275,33,284,43,275,48,306,48,306,43,275,57,290,48,306,57,290,68,323,68,323,57,290,71,300,68,323,71,300,92,334,92,334,71,300,87,306,92,334,87,306,105,308,105,308,123,306,121,338,121,338,123,306,146,335,123,306,138,300,146,335,146,335,138,300,149,290,146,335,149,290,168,326,168,326,149,290,157,275,168,326,157,275,159,257,159,257,157,240,170,213,170,213,157,240,152,200,170,213,183,226,184,311,184,311,183,226,192,241,184,311,192,241,195,292,195,292,192,241,197,255,195,292,197,255,199,270,170,213,184,311,168,326,170,213,168,326,159,257,152,200,157,240,152,224,152,200,152,224,146,152,152,200,146,152,161,141,152,200,161,141,164,195,164,195,171,127,173,190,173,190,171,127,178,109,173,190,178,109,181,185,181,185,178,109,180,88,193,40,180,88,176,63,193,40,176,63,175,22,175,22,176,63,167,42,175,22,167,42,154,9,154,9,167,42,153,26,154,9,153,26,135,15,132,199,127,160,146,152,132,199,146,152,143,211,143,211,146,152,152,224,215,109,214,125,214,94,214,94,214,125,212,139,214,94,212,139,211,79,211,79,212,139,207,152,211,79,207,152,207,65,207,65,207,152,201,164,207,65,201,164,200,52,200,52,201,164,194,174,200,52,194,174,193,40,193,40,194,174,187,180,193,40,187,180,181,185,103,-4,130,0,106,11,106,11,130,0,114,11,135,15,114,11,130,0,135,15,130,0,154,9,87,176,76,172,92,165,87,176,92,165,96,179,96,179,92,165,104,164,96,179,104,164,105,183,105,183,104,164,113,163,105,183,113,163,112,186,112,186,113,163,118,190,132,199,118,190,121,162,132,199,121,162,127,160,121,338,92,334,105,308,118,190,113,163,121,162,103,-4,106,11,99,13,103,-4,99,13,90,15,103,-4,90,15,82,20,103,-4,82,20,76,-6,76,-6,82,20,71,26,76,-6,71,26,64,31,76,-6,64,31,57,35,76,-6,57,35,57,-5,57,35,51,38,57,-5,57,-5,51,38,46,39,57,-5,46,39,41,-1,41,-1,46,39,41,40,41,-1,41,40,34,39,30,4,41,-1,34,39,30,4,34,39,29,36,30,4,29,36,25,32,30,4,25,32,23,12,22,27,21,22,23,12,22,27,23,12,25,32,92,165,76,172,76,165,180,88,193,40,181,185,164,195,161,141,171,127, +237,84,237,116,185,116,185,338,163,338,6,116,6,84,146,84,146,0,185,0,185,84,16383,16383,146,116,26,116,146,287,219,340,214,344,210,339,206,335,202,333,197,331,87,331,32,213,32,208,34,206,38,206,65,204,89,199,110,191,129,182, +6,84,146,84,6,116,6,116,146,84,26,116,6,116,26,116,163,338,163,338,26,116,146,287,163,338,146,287,185,0,185,0,146,287,146,116,185,0,146,116,146,84,146,84,146,116,26,116,163,338,185,0,185,338,185,116,185,84,237,84,185,116,237,84,237,116,185,0,146,84,146,0, +219,340,214,344,210,339,206,335,202,333,197,331,87,331,32,213,32,208,34,206,38,206,65,204,89,199,110,191,129,182,145,171,156,159,166,146,172,131,177,114,178,96,174,71,164,48,149,29,131,16,110,12,104,12,98,14,90,17,83,21,75,27,66,34,58,39,51,41,45,43,38,43,30,42,24,40,19,36,17,31,16,24,19,13,27,5,40,-1,58,-5,79,-6,99,-5,117,-2,134,1,149,8,164,17,182,33,196,51,206,71,211,95,213,122,213,137,211,150,207,162,202,174,195,185,178,205,159,220,137,232,108,241,70,249,90,291,188,291,192,292,198,294,200,296,201,298,223,342,185,337,152,329,123,317,97,300,71,277,52,254,37,229,26,201,19,171,17,140,18,118,21,98,26,78,33,60,41,44,53,26,68,12,86,1,106,-4,129,-6,148,-5,166,0,182,7,196,17,209,30,218,43,225,57,230,73,233,91,234,109,230,145,217,174,198,196,172,209,140,214,127,213,115,211,103,207,90,201,76,191,89,234,111,270,142,300,180,321,224,334,16383,16383,189,94,187,65,180,41,169,23,154,11,134,7,109,13,89,30,75,56,66,91,64,133,67,157,76,173,89,184,105,189,122,191,146,187,165,175,179,156,187,128,189,94,224,323,224,331,40,331,10,257, +211,95,213,122,213,137,211,95,213,137,211,150,211,95,211,150,207,162,211,95,207,162,206,71,178,205,178,96,182,33,178,205,182,33,195,185,195,185,182,33,196,51,195,185,196,51,202,174,202,174,196,51,206,71,202,174,206,71,207,162,149,8,164,17,164,48,164,48,164,17,182,33,164,48,182,33,174,71,174,71,182,33,178,96,110,12,117,-2,131,16,131,16,117,-2,134,1,131,16,134,1,149,29,149,29,134,1,149,8,149,29,149,8,164,48,202,333,197,331,198,294,202,333,198,294,200,296,202,333,200,296,201,298,202,333,201,298,219,340,202,333,219,340,206,335,190,331,192,292,197,331,197,331,192,292,195,293,197,331,195,293,198,294,210,339,206,335,219,340,210,339,219,340,214,344,87,331,70,249,90,291,87,331,90,291,190,331,190,331,90,291,188,291,190,331,188,291,192,292,38,206,65,204,70,249,70,249,65,204,89,199,70,249,89,199,108,241,108,241,89,199,110,191,108,241,110,191,137,232,137,232,110,191,129,182,137,232,129,182,145,171,145,171,156,159,159,220,159,220,156,159,166,146,159,220,166,146,178,205,178,205,166,146,172,131,178,205,172,131,177,114,87,331,32,213,33,207,87,331,33,207,34,206,87,331,34,206,36,206,87,331,36,206,38,206,87,331,38,206,70,249,32,213,32,212,33,207,33,207,32,212,32,208,32,208,32,212,32,211,79,-6,99,-5,83,21,79,-6,83,21,75,27,79,-6,75,27,66,34,79,-6,66,34,58,39,79,-6,58,39,58,-5,58,39,51,41,58,-5,58,-5,51,41,45,43,58,-5,45,43,40,-1,40,-1,45,43,38,43,40,-1,38,43,30,42,27,5,40,-1,30,42,27,5,30,42,24,40,27,5,24,40,19,36,27,5,19,36,19,13,17,31,16,24,19,13,17,31,19,13,19,36,104,12,98,14,99,-5,104,12,99,-5,117,-2,104,12,117,-2,110,12,159,220,137,232,145,171,90,17,83,21,99,-5,90,17,99,-5,98,14,178,205,177,114,178,96,32,208,32,211,32,210, +223,342,185,337,152,329,123,317,97,300,71,277,52,254,37,229,26,201,19,171,17,140,18,118,21,98,26,78,33,60,41,44,53,26,68,12,86,1,106,-4,129,-6,148,-5,166,0,182,7,196,17,209,30,218,43,225,57,230,73,233,91,234,109,230,145,217,174,198,196,172,209,140,214,127,213,115,211,103,207,90,201,76,191,89,234,111,270,142,300,180,321,224,334,16383,16383,189,94,187,65,180,41,169,23,154,11,134,7,109,13,89,30,75,56,66,91,64,133,67,157,76,173,89,184,105,189,122,191,146,187,165,175,179,156,187,128,189,94,224,323,224,331,40,331,10,257,19,253,30,270,40,282,51,289,62,293,78,294,185,294,86,-3,118,-3,223,78,220,100,213,121,199,141,177,162,145,185,171,200,190,215,203,229,210,246,212,267,208,289,197,309,179,324,156,334,128,338,97,335,70,324,49,308,36,287,31,260,33,242,38,225,49,208,67,189,93,166,66,145,47,127,35,111,30,94,28,75,32,48,45,25,66,8,92,-2,124,-6,157,-2,185,8,205,26,218,49,223,78,16383,16383,177,267,176,249,171,234,162,220,149,207,131,195,107,210,90,225,77,240,70,257,68,275,71,292,78,305, +140,214,127,213,146,187,146,187,127,213,122,191,105,189,122,191,115,211,105,189,115,211,103,207,64,133,67,157,71,277,71,277,67,157,76,173,71,277,76,173,76,191,76,191,76,173,89,184,76,191,89,184,90,201,90,201,89,184,105,189,90,201,105,189,103,207,127,213,115,211,122,191,187,65,180,41,182,7,182,7,180,41,169,23,182,7,169,23,166,0,166,0,169,23,154,11,166,0,154,11,148,-5,148,-5,154,11,134,7,148,-5,134,7,129,-6,129,-6,134,7,109,13,129,-6,109,13,106,-4,106,-4,109,13,89,30,106,-4,89,30,86,1,86,1,89,30,75,56,86,1,75,56,68,12,68,12,75,56,66,91,68,12,66,91,64,133,53,26,68,12,64,133,64,133,71,277,53,26,53,26,71,277,52,254,53,26,52,254,41,44,41,44,52,254,37,229,41,44,37,229,33,60,33,60,37,229,26,78,218,43,225,57,230,145,230,145,225,57,230,73,230,145,230,73,234,109,234,109,230,73,233,91,189,94,196,17,198,196,198,196,196,17,209,30,198,196,209,30,217,174,217,174,209,30,218,43,217,174,218,43,230,145,146,187,165,175,172,209,172,209,165,175,179,156,172,209,179,156,198,196,198,196,179,156,187,128,198,196,187,128,189,94,187,65,182,7,196,17,187,65,196,17,189,94,76,191,89,234,97,300,97,300,89,234,111,270,97,300,111,270,123,317,123,317,111,270,142,300,123,317,142,300,152,329,152,329,142,300,180,321,152,329,180,321,185,337,185,337,180,321,224,334,185,337,224,334,223,342,97,300,71,277,76,191,17,140,18,118,19,171,19,171,18,118,21,98,19,171,21,98,26,201,26,201,21,98,26,78,26,201,26,78,37,229,140,214,146,187,172,209, +224,323,224,331,40,331,10,257,19,253,30,270,40,282,51,289,62,293,78,294,185,294,86,-3,118,-3,223,78,220,100,213,121,199,141,177,162,145,185,171,200,190,215,203,229,210,246,212,267,208,289,197,309, +118,-3,224,323,185,294,185,294,224,323,224,331,185,294,224,331,78,294,62,293,78,294,224,331,62,293,224,331,40,331,40,331,10,257,19,253,40,331,19,253,30,270,40,331,30,270,40,282,40,331,40,282,51,289,40,331,51,289,62,293,118,-3,185,294,86,-3, +223,78,220,100,213,121,199,141,177,162,145,185,171,200,190,215,203,229,210,246,212,267,208,289,197,309,179,324,156,334,128,338,97,335,70,324,49,308,36,287,31,260,33,242,38,225,49,208,67,189,93,166,66,145,47,127,35,111,30,94,28,75,32,48,45,25,66,8,92,-2,124,-6,157,-2,185,8,205,26,218,49,223,78,16383,16383,177,267,176,249,171,234,162,220,149,207,131,195,107,210,90,225,77,240,70,257,68,275,71,292,78,305,89,316,104,322,123,324,142,322,157,314,168,302,175,286,177,267,16383,16383,136,136,154,122,167,109,177,95,183,79,185,62,182,44,175,29,163,17,148,10,129,7,108,10,91,19,77,34,69,54,66,79,67,97,71,113,79,128,90,142,106,156,30,-10,65,-4,95,3,121,13,145,28,170,49,191,72,208,100,220,130,227,163,229,197,228,221,224,244,217,265,209,284,198,300,185,313,171,324,155,332,138,337,119,338,85,332,57,316,35,291,20,258,15,220,19,186,31,158,50,137,75,123,105,118,122,119,138,122,153,128,167,136,180,147,164,101,140,63,109,33,71,12,28,0,16383,16383,181,177,177,163,167,153,153,146,137,141,123,140,102,144,85,157,72,177,64,204,61,237,62,253,64,269,68,284,73,297,79,307,84,313,91,318,98,321,106,323,115,324,139,319,157,304,170,278,178,243,181,197,96,201,95,210,91,218,85,224,77,228,69,229,60,228,52,224,46,218,42,211,41,201,42,193,46,185,52,179,60,176,69,174,77,176, +167,109,177,162,154,122,154,122,177,162,145,185,154,122,145,185,136,136,136,136,145,185,149,207,136,136,149,207,131,195,131,195,107,210,136,136,136,136,107,210,106,156,90,142,106,156,93,166,66,8,69,54,66,79,66,79,67,97,66,145,66,145,67,97,71,113,66,145,71,113,93,166,93,166,71,113,79,128,93,166,79,128,90,142,30,94,32,48,35,111,35,111,32,48,45,25,35,111,45,25,47,127,47,127,45,25,66,8,47,127,66,8,66,145,66,145,66,8,66,79,107,210,90,225,93,166,107,210,93,166,106,156,90,225,77,240,93,166,93,166,77,240,70,257,93,166,70,257,67,189,67,189,70,257,68,275,70,324,68,275,71,292,70,324,71,292,78,305,128,338,123,324,142,322,128,338,142,322,156,334,156,334,142,322,157,314,156,334,157,314,179,324,179,324,157,314,168,302,179,324,168,302,175,286,182,44,175,29,185,8,185,8,175,29,163,17,185,8,163,17,157,-2,157,-2,163,17,148,10,157,-2,148,10,129,7,129,7,108,10,124,-6,124,-6,108,10,92,-2,92,-2,108,10,91,19,92,-2,91,19,77,34,92,-2,77,34,69,54,92,-2,69,54,66,8,78,305,89,316,97,335,97,335,89,316,104,322,97,335,104,322,128,338,128,338,104,322,123,324,49,308,36,287,38,225,49,308,38,225,49,208,49,308,49,208,67,189,49,308,67,189,68,275,49,308,68,275,70,324,36,287,31,260,33,242,36,287,33,242,38,225,171,200,190,215,176,249,176,249,190,215,177,267,179,324,177,267,190,215,179,324,190,215,197,309,197,309,190,215,203,229,197,309,203,229,208,289,208,289,203,229,210,246,208,289,210,246,212,267,171,200,176,249,171,234,171,200,171,234,162,220,171,200,162,220,149,207,171,200,149,207,145,185,223,78,220,100,218,49,218,49,220,100,213,121,218,49,213,121,205,26,205,26,213,121,199,141,205,26,199,141,185,62,185,62,199,141,183,79,177,95,183,79,199,141,177,95,199,141,177,162,177,95,177,162,167,109,185,62,185,8,205,26,129,7,124,-6,157,-2,182,44,185,8,185,62,179,324,175,286,177,267,70,324,78,305,97,335,32,48,30,94,28,75, +30,-10,65,-4,95,3,121,13,145,28,170,49,191,72,208,100,220,130,227,163,229,197,228,221,224,244,217,265,209,284,198,300,185,313,171,324,155,332,138,337,119,338,85,332,57,316,35,291,20,258,15,220,19,186,31,158,50,137,75,123,105,118,122,119,138,122,153,128,167,136,180,147,164,101,140,63,109,33,71,12,28,0,16383,16383,181,177,177,163,167,153,153,146,137,141,123,140,102,144,85,157,72,177,64,204,61,237,62,253,64,269,68,284,73,297,79,307,84,313,91,318,98,321,106,323,115,324,139,319,157,304,170,278,178,243,181,197,96,201,95,210,91,218,85,224,77,228,69,229,60,228,52,224,46,218,42,211,41,201,42,193,46,185,52,179,60,176,69,174,77,176,85,179,91,185,95,193,96,201,16383,16383,96,22,95,31,91,38,85,45,77,49,69,50,60,49,52,45,46,39,42,31,41,22,42,13,46,6,52,0,60,-3,69,-5,77,-3,85,0,91,6,95,13,96,22,95,201,94,210,90,218,84,224,77,228,68,229,59,228,51,224,45,218,42,211,40,201,42,193,46,185,52,179,59,176,68,174,77,176,84,179,90,185,94,193,95,201,16383,16383,54,-69,73,-58,88,-44, +62,253,64,269,57,316,57,316,64,269,68,284,57,316,68,284,85,332,85,332,68,284,73,297,85,332,73,297,79,307,79,307,84,313,85,332,85,332,84,313,91,318,85,332,91,318,119,338,119,338,91,318,98,321,119,338,98,321,106,323,119,338,106,323,115,324,115,324,139,319,119,338,119,338,139,319,138,337,123,140,105,118,122,119,123,140,122,119,138,122,123,140,102,144,105,118,85,157,72,177,75,123,85,157,75,123,105,118,85,157,105,118,102,144,61,237,62,253,57,316,61,237,57,316,50,137,61,237,50,137,64,204,64,204,50,137,75,123,64,204,75,123,72,177,15,220,19,186,20,258,20,258,19,186,31,158,20,258,31,158,35,291,35,291,31,158,50,137,35,291,50,137,57,316,137,141,123,140,138,122,137,141,138,122,153,146,153,146,138,122,153,128,153,146,153,128,167,153,167,153,153,128,167,136,167,153,167,136,177,163,177,163,167,136,180,147,177,163,180,147,181,177,181,177,180,147,191,72,181,177,191,72,181,197,178,243,181,197,185,313,178,243,185,313,171,324,138,337,139,319,155,332,155,332,139,319,157,304,155,332,157,304,171,324,171,324,157,304,170,278,171,324,170,278,178,243,229,197,228,221,227,163,227,163,228,221,224,244,227,163,224,244,220,130,220,130,224,244,217,265,220,130,217,265,209,284,220,130,209,284,208,100,208,100,209,284,198,300,208,100,198,300,191,72,191,72,198,300,185,313,191,72,185,313,181,197,30,-10,65,-4,71,12,71,12,65,-4,95,3,71,12,95,3,109,33,109,33,95,3,121,13,109,33,121,13,140,63,140,63,121,13,145,28,140,63,145,28,164,101,164,101,145,28,170,49,164,101,170,49,180,147,180,147,170,49,191,72,71,12,28,0,30,-10, +96,201,95,210,91,218,85,224,77,228,69,229,60,228,52,224,46,218,42,211,41,201,42,193,46,185,52,179,60,176,69,174,77,176,85,179,91,185,95,193,96,201,16383,16383,96,22,95,31,91,38,85,45,77,49,69,50,60,49,52,45,46,39,42,31,41,22,42,13,46,6,52,0,60,-3,69,-5,77,-3,85,0,91,6,95,13,96,22,95,201,94,210,90,218,84,224,77,228,68,229,59,228,51,224,45,218,42,211,40,201,42,193,46,185,52,179,59,176,68,174,77,176,84,179,90,185,94,193,95,201,16383,16383,54,-69,73,-58,88,-44,100,-28,107,-11,109,7,107,22,102,34,93,43,82,49,70,51,60,49,52,46,46,40,42,32,40,23,41,14,45,7,51,2,59,-1,69,-2, +42,211,42,193,46,218,46,218,42,193,46,185,46,218,46,185,52,224,52,224,46,185,52,179,52,224,52,179,60,228,60,228,52,179,60,176,60,228,60,176,69,229,69,229,60,176,69,174,69,229,69,174,77,228,77,228,69,174,77,176,77,228,77,176,85,224,85,224,77,176,85,179,85,224,85,179,91,218,91,218,85,179,91,185,91,218,91,185,95,210,95,210,91,185,95,193,95,210,95,193,96,201,42,31,42,13,46,39,46,39,42,13,46,6,46,39,46,6,52,45,52,45,46,6,52,0,52,45,52,0,60,49,60,49,52,0,60,-3,60,49,60,-3,69,50,69,50,60,-3,69,-5,69,50,69,-5,77,49,77,49,69,-5,77,-3,77,49,77,-3,85,45,85,45,77,-3,85,0,85,45,85,0,91,38,91,38,85,0,91,6,91,38,91,6,95,31,95,31,91,6,95,13,95,31,95,13,96,22,42,13,42,31,41,22,42,193,42,211,41,201, +95,201,94,210,90,218,84,224,77,228,68,229,59,228,51,224,45,218,42,211,40,201,42,193,46,185,52,179,59,176,68,174,77,176,84,179,90,185,94,193,95,201,16383,16383,54,-69,73,-58,88,-44,100,-28,107,-11,109,7,107,22,102,34,93,43,82,49,70,51,60,49,52,46,46,40,42,32,40,23,41,14,45,7,51,2,59,-1,69,-2,72,-2,75,-1,78,-1,81,0,85,0,87,-2,89,-3,90,-5,90,-7,88,-17,83,-28,75,-38,63,-49,49,-60,310,-11,310,20,94,127,310,234,310,267,28,129,28,124,319,160,319,193,24,193,24,160,16383,16383,319,60,319,93,24,93,24,60,310,124,310,129,28,267,28,234,244,127,28,20,28,-11,122,82,126,101,131,118,137,133,145,147,155,161,176,187,191,208,201,226,206,242,207,259,202,286,189,308,169,324,144,335,116,338,89,335,66,325,49,310,38,290,34,267,35,255,38,246,44,239,50,235,58,233,65,234,71,237,75,242,78,248,79,255,77,264,72,270,66,276, +42,211,42,193,45,218,45,218,42,193,46,185,45,218,46,185,51,224,51,224,46,185,52,179,51,224,52,179,59,228,59,228,52,179,59,176,59,228,59,176,68,229,68,229,59,176,68,174,68,229,68,174,77,228,77,228,68,174,77,176,77,228,77,176,84,224,84,224,77,176,84,179,84,224,84,179,90,218,90,218,84,179,90,185,90,218,90,185,94,210,94,210,90,185,94,193,94,210,94,193,95,201,75,-1,78,-1,82,49,82,49,78,-1,81,0,82,49,81,0,83,0,83,0,85,0,93,43,93,43,85,0,87,-2,93,43,87,-2,89,-3,40,23,41,14,42,32,42,32,41,14,45,7,42,32,45,7,46,40,46,40,45,7,51,2,46,40,51,2,52,46,52,46,51,2,59,-1,52,46,59,-1,60,49,60,49,59,-1,69,-2,60,49,69,-2,70,51,70,51,69,-2,72,-2,70,51,72,-2,82,49,82,49,72,-2,75,-1,109,7,107,22,107,-11,107,-11,107,22,102,34,107,-11,102,34,100,-28,100,-28,102,34,93,43,100,-28,93,43,90,-7,90,-7,88,-44,100,-28,93,43,89,-3,90,-5,93,43,90,-5,90,-7,93,43,82,49,83,0,88,-44,90,-7,88,-17,88,-44,88,-17,83,-28,88,-44,83,-28,75,-38,88,-44,75,-38,73,-58,63,-49,49,-60,54,-69,63,-49,54,-69,73,-58,63,-49,73,-58,75,-38,42,193,42,211,40,201, +310,-11,310,20,94,127,310,234,310,267,28,129,28,124,319,160,319,193,24,193,24,160,16383,16383,319,60,319,93, +94,127,310,234,310,267,94,127,310,267,28,129,94,127,28,129,310,-11,94,127,310,-11,310,20,310,-11,28,129,28,124, +319,160,319,193,24,193,24,160,16383,16383,319,60,319,93,24,93,24,60,310,124,310,129,28,267,28,234,244,127,28,20,28,-11,122,82,126,101, +24,193,24,160,319,160,24,193,319,160,319,193,24,93,24,60,319,60,24,93,319,60,319,93, +310,124,310,129,28,267,28,234,244,127,28,20,28,-11,122,82,126,101,131,118,137,133,145,147,155,161,176,187, +310,124,310,129,28,267,310,124,28,267,28,234,310,124,28,234,244,127,310,124,244,127,28,20,310,124,28,20,28,-11, +122,82,126,101,131,118,137,133,145,147,155,161,176,187,191,208,201,226,206,242,207,259,202,286,189,308,169,324,144,335,116,338,89,335,66,325,49,310,38,290,34,267,35,255,38,246,44,239,50,235,58,233,65,234,71,237,75,242,78,248,79,255,77,264,72,270,66,276,62,283,60,292,62,301,69,310,80,317,92,321,107,323,124,320,139,312,151,300,159,283,161,264,160,246,156,227,150,209,136,171,126,147,120,127,116,109,114,95,113,82,16383,16383,145,22,144,30,140,38,134,44,127,48,119,49,110,48,103,44,97,38,93,31,92,22,93,14,97,7,102,1,110,-2,119,-3,127,-2,135,1,140,7,144,14,145,22,344,36,323,27,303,20,283,16,263,13,243,12,196,19,156,40,126,71,107,112,100,161,101,184,105,206,112,227,120,247,131,265,148,285,167,301,189,313,214,320,241,323,286,316,326,296,357,267,377,229,384,186,381,157,372,130,358,108,341,94,321,88,314,89,308,92,304,96,301,103,300,112,300,115,301,117,301,120,334,247,300,247,295,228,294,228,289,238,284,245,276,250,268,253,257,254,242,252,229,248,216,241,204,231,194,219,183,203,174,185,167,167,162,147,161,128,163,109,169,93,179,82,191,75,204,72,219,74,232,78,245,86,257,96,267,108,268,108,271,96,279,86,288,78,300,73,313,71,341,78,366,95,386,121, +60,292,60,292,60,292,60,292,66,325,49,310,60,292,49,310,50,235,60,292,50,235,58,233,144,335,116,338,124,320,124,320,116,338,107,323,92,321,107,323,116,338,92,321,116,338,89,335,60,292,62,301,66,325,66,325,62,301,69,310,66,325,69,310,89,335,89,335,69,310,80,317,89,335,80,317,92,321,34,267,35,255,38,290,38,290,35,255,38,246,38,290,38,246,49,310,49,310,38,246,44,239,49,310,44,239,50,235,62,283,65,234,66,276,66,276,65,234,71,237,66,276,71,237,72,270,72,270,71,237,75,242,72,270,75,242,77,264,77,264,75,242,78,248,77,264,78,248,79,255,65,234,62,283,60,292,65,234,60,292,58,233,119,49,119,-3,127,48,127,48,119,-3,127,-2,127,48,127,-2,134,44,134,44,127,-2,135,1,134,44,135,1,140,38,140,38,135,1,140,7,140,38,140,7,144,30,144,30,140,7,144,14,144,30,144,14,145,22,92,22,93,14,93,31,93,31,93,14,97,7,93,31,97,7,97,38,97,38,97,7,102,1,97,38,102,1,103,44,103,44,102,1,110,-2,103,44,110,-2,110,48,110,48,110,-2,119,-3,110,48,119,-3,119,49,124,320,139,312,144,335,144,335,139,312,151,300,144,335,151,300,169,324,169,324,151,300,159,283,169,324,159,283,161,264,161,264,160,246,176,187,176,187,160,246,156,227,176,187,156,227,155,161,155,161,156,227,150,209,155,161,150,209,145,147,145,147,150,209,143,190,145,147,143,190,137,133,137,133,143,190,136,171,137,133,136,171,131,118,131,118,136,171,126,147,131,118,126,147,126,101,126,101,126,147,122,82,202,286,189,308,191,208,202,286,191,208,201,226,202,286,201,226,206,242,202,286,206,242,207,259,176,187,191,208,189,308,176,187,189,308,169,324,176,187,169,324,161,264,122,82,126,147,120,127,122,82,120,127,116,109,122,82,116,109,114,95,122,82,114,95,113,82, +344,36,323,27,303,20,283,16,263,13,243,12,196,19,156,40,126,71,107,112,100,161,101,184,105,206,112,227,120,247,131,265,148,285,167,301,189,313,214,320,241,323,286,316,326,296,357,267,377,229,384,186,381,157,372,130,358,108,341,94,321,88,314,89,308,92,304,96,301,103,300,112,300,115,301,117,301,120,334,247,300,247,295,228,294,228,289,238,284,245,276,250,268,253,257,254,242,252,229,248,216,241,204,231,194,219,183,203,174,185,167,167,162,147,161,128,163,109,169,93,179,82,191,75,204,72,219,74,232,78,245,86,257,96,267,108,268,108,271,96,279,86,288,78,300,73,313,71,341,78,366,95,386,121,400,154,405,191,396,238,374,279,338,310,293,331,241,338,215,337,191,333,169,326,148,316,128,304,105,282,86,257,71,228,61,197,58,164,67,108,93,61,132,24,182,1,241,-6,261,-5,281,-2,302,2,324,10,350,22,16383,16383,286,202,285,187,282,171,277,155,271,138,264,123,257,113,250,105,242,99,234,95,226,94,216,96,207,101,201,110,197,122,196,137,197,150,199,163,203,175,208,186,214,197,223,209,234,219,244,226,254,231,263,232,271,231,277,227,282,221,285,213,286,202,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,211,175,225,178,236,182,245,185,259,195,266,203,272,213,276,224,279,235,280,248,274,277,258,300,232,317,195,327,148,331,8,331,8,321,29,320,43,316,51,308,55,295,56,275,56,56,55,37,51,24,42,16,29,11,8,9,8,0,177,0,217,4,250,15,275,34,291,58,296,89,295,102,292,115,287,126,281,137,272,147,263,154,254,160,242,166,229,170,211,174,16383,16383,108,183,108,303,109,307,112,310,115,312,119,313,140,313,172,309,197,301,214,287,225,268,228,245,225,223,217,205,202,193,181,186,153,183,16383,16383,108,163,139,162,162,161,181,158,198,152,215,143,224,136,231,126,235,115,238,103,239,89,238,77,236,66,232,56,227,47,220,40,207,30,194,24,179,20,161,19,138,18,126,19,118,21,112,26,109,32, +156,40,126,71,132,24,132,24,126,71,107,112,132,24,107,112,93,61,93,61,107,112,100,161,105,282,100,161,101,184,105,282,101,184,105,206,105,206,112,227,128,304,128,304,112,227,120,247,128,304,120,247,131,265,131,265,148,285,148,316,148,316,148,285,167,301,148,316,167,301,169,326,169,326,167,301,189,313,169,326,189,313,191,333,191,333,189,313,214,320,191,333,214,320,215,337,215,337,214,320,241,323,215,337,241,323,241,338,241,338,241,323,293,331,93,61,100,161,105,282,93,61,105,282,86,257,93,61,86,257,71,228,93,61,71,228,67,108,61,197,58,164,67,108,61,197,67,108,71,228,384,186,386,121,396,238,384,186,396,238,377,229,377,229,396,238,374,279,377,229,374,279,357,267,357,267,374,279,338,310,357,267,338,310,326,296,326,296,338,310,293,331,326,296,293,331,286,316,286,316,293,331,241,323,148,316,128,304,131,265,344,36,323,27,324,10,324,10,323,27,303,20,324,10,303,20,302,2,302,2,303,20,283,16,302,2,283,16,281,-2,281,-2,283,16,263,13,281,-2,263,13,261,-5,261,-5,263,13,243,12,261,-5,243,12,241,-6,241,-6,243,12,196,19,241,-6,196,19,182,1,182,1,196,19,156,40,182,1,156,40,132,24,276,250,268,253,271,231,271,231,268,253,263,232,254,231,263,232,257,254,254,231,257,254,244,226,244,226,257,254,242,252,244,226,242,252,234,219,234,219,242,252,229,248,234,219,229,248,223,209,223,209,229,248,216,241,223,209,216,241,214,197,199,163,203,175,204,231,204,231,203,175,208,186,204,231,208,186,216,241,216,241,208,186,214,197,194,219,196,137,197,150,194,219,197,150,204,231,204,231,197,150,199,163,201,110,204,72,207,101,207,101,204,72,219,74,207,101,219,74,216,96,216,96,219,74,226,94,234,95,226,94,232,78,234,95,232,78,245,86,197,122,196,137,191,75,197,122,191,75,204,72,197,122,204,72,201,110,196,137,194,219,191,75,191,75,194,219,183,203,191,75,183,203,179,82,179,82,183,203,174,185,179,82,174,185,169,93,169,93,174,185,167,167,169,93,167,167,163,109,163,109,167,167,162,147,163,109,162,147,161,128,268,253,257,254,263,232,267,108,268,108,271,138,267,108,271,138,264,123,264,123,257,113,267,108,267,108,257,113,257,96,308,92,304,96,312,71,312,71,304,96,301,103,312,71,301,103,300,73,300,73,301,103,300,112,300,115,301,117,300,247,300,247,301,117,301,119,300,247,301,119,301,120,301,120,334,247,300,247,300,247,295,228,300,73,300,247,300,73,300,112,300,247,300,112,300,114,300,247,300,114,300,115,295,228,294,228,300,73,300,73,294,228,289,238,300,73,289,238,288,78,288,78,289,238,286,202,288,78,286,202,285,187,288,78,285,187,282,171,285,213,286,202,289,238,285,213,289,238,284,245,285,213,284,245,282,221,277,227,282,221,284,245,277,227,284,245,276,250,277,227,276,250,271,231,384,186,381,157,386,121,386,121,381,157,372,130,386,121,372,130,366,95,366,95,372,130,358,108,366,95,358,108,341,78,341,78,358,108,341,94,341,78,341,94,321,88,321,88,314,89,341,78,341,78,314,89,312,71,396,238,386,121,400,154,396,238,400,154,405,191,288,78,282,171,279,86,279,86,282,171,277,155,279,86,277,155,271,96,271,96,277,155,271,138,271,96,271,138,268,108,250,105,242,99,245,86,250,105,245,86,257,96,250,105,257,96,257,113,226,94,219,74,232,78,234,95,245,86,242,99,308,92,312,71,314,89,344,36,324,10,350,22,105,282,105,206,128,304, +353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,211,175,225,178,236,182,245,185,259,195,266,203,272,213,276,224,279,235,280,248,274,277,258,300,232,317,195,327,148,331,8,331,8,321,29,320,43,316,51,308,55,295,56,275,56,56,55,37,51,24,42,16,29,11,8,9,8,0,177,0,217,4,250,15,275,34,291,58,296,89,295,102,292,115,287,126,281,137,272,147,263,154,254,160,242,166,229,170,211,174,16383,16383,108,183, +55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0, +211,175,225,178,236,182,245,185,259,195,266,203,272,213,276,224,279,235,280,248,274,277,258,300,232,317,195,327,148,331,8,331,8,321,29,320,43,316,51,308,55,295,56,275,56,56,55,37,51,24,42,16,29,11,8,9,8,0,177,0,217,4,250,15,275,34,291,58,296,89,295,102,292,115,287,126,281,137,272,147,263,154,254,160,242,166,229,170,211,174,16383,16383,108,183,108,303,109,307,112,310,115,312,119,313,140,313,172,309,197,301,214,287,225,268,228,245,225,223,217,205,202,193,181,186,153,183,16383,16383,108,163,139,162,162,161,181,158,198,152,215,143,224,136,231,126,235,115,238,103,239,89,238,77,236,66,232,56,227,47,220,40,207,30,194,24,179,20,161,19,138,18,126,19,118,21,112,26,109,32,108,41,307,65,285,47,265,32,244,23,222,17,197,15,177,17,157,21,139,28,123,38,108,51,95,68,85,88,78,112,73,140,72,171,77,219,93,260,117,291,151,311,192,318,211,316,228,311,244,304,259,293,272,280,279,272,285,263,290,252,295,240,299,224,310,224,305,338,296,338,293,332,290,328,285,324,280,322,275,321,269,322,262,324,254,326,240,330,228,333,204,337,192,338,180,338,153,336,127,330,102,320,80,305,59,286,44,266,31,243,22,218,16,191,14,162,16,133,22,106,32,80,45,57,62,37,81,22,103,9,127,0,153,-4,180,-6,214,-4,245,3,273,16,297,34,316,56,8,331,8,321,27,320,40,316,47,308,51,295,52,275,52,57,51,38,48,25,40,16,27,12,8,9,8,0,148,0,178,1,206,6,231,12, +51,24,42,16,177,0,177,0,42,16,29,11,177,0,29,11,8,9,55,295,56,275,112,310,55,295,112,310,148,331,148,331,112,310,115,312,148,331,115,312,119,313,148,331,119,313,140,313,148,331,140,313,172,309,207,30,194,24,217,4,217,4,194,24,179,20,217,4,179,20,177,0,177,0,179,20,161,19,177,0,161,19,138,18,138,18,126,19,177,0,177,0,126,19,118,21,177,0,118,21,55,37,55,37,118,21,56,56,258,300,232,317,236,182,236,182,232,317,228,245,236,182,228,245,225,223,236,182,225,223,225,178,225,178,225,223,217,205,225,178,217,205,211,175,211,175,217,205,202,193,211,175,202,193,211,174,211,174,202,193,215,143,211,174,215,143,229,170,229,170,215,143,224,136,153,183,162,161,181,186,181,186,162,161,181,158,181,186,181,158,202,193,202,193,181,158,198,152,202,193,198,152,215,143,236,66,232,56,250,15,250,15,232,56,227,47,250,15,227,47,220,40,220,40,207,30,217,4,162,161,153,183,139,162,139,162,153,183,108,183,139,162,108,183,108,163,109,32,108,41,56,275,109,32,56,275,56,56,56,56,118,21,112,26,56,56,112,26,109,32,272,147,263,154,275,34,275,34,263,154,254,160,275,34,254,160,250,15,250,15,254,160,242,166,250,15,242,166,239,89,239,89,238,77,250,15,250,15,238,77,236,66,242,166,229,170,231,126,242,166,231,126,235,115,242,166,235,115,238,103,242,166,238,103,239,89,232,317,195,327,197,301,232,317,197,301,214,287,232,317,214,287,225,268,232,317,225,268,228,245,195,327,148,331,172,309,195,327,172,309,197,301,56,275,108,41,108,296,56,275,108,296,108,303,56,275,108,303,109,307,56,275,109,307,112,310,148,331,8,331,29,320,148,331,29,320,43,316,148,331,43,316,51,308,148,331,51,308,55,295,266,203,272,213,274,277,274,277,272,213,276,224,274,277,276,224,280,248,280,248,276,224,279,235,245,185,252,190,258,300,258,300,252,190,259,195,258,300,259,195,274,277,274,277,259,195,266,203,292,115,287,126,291,58,292,115,291,58,296,89,292,115,296,89,295,102,281,137,272,147,275,34,281,137,275,34,291,58,281,137,291,58,287,126,220,40,217,4,250,15,258,300,236,182,245,185,29,320,8,331,8,321,229,170,224,136,231,126,177,0,8,9,8,0,51,24,177,0,55,37, +307,65,285,47,265,32,244,23,222,17,197,15,177,17,157,21,139,28,123,38,108,51,95,68,85,88,78,112,73,140,72,171,77,219,93,260,117,291,151,311,192,318,211,316,228,311,244,304,259,293,272,280,279,272,285,263,290,252,295,240,299,224,310,224,305,338,296,338,293,332,290,328,285,324,280,322,275,321,269,322,262,324,254,326,240,330,228,333,204,337,192,338,180,338,153,336,127,330,102,320,80,305,59,286,44,266,31,243,22,218,16,191,14,162,16,133,22,106,32,80,45,57,62,37,81,22,103,9,127,0,153,-4,180,-6,214,-4,245,3,273,16,297,34,316,56,8,331,8,321,27,320,40,316,47,308,51,295,52,275,52,57,51,38,48,25,40,16,27,12,8,9,8,0,148,0,178,1,206,6,231,12,254,21,275,32,299,51,318,75,331,102,340,133,343,167,341,196,334,223,324,247,310,267,293,286,270,302,244,314,214,323,180,329,143,331,16383,16383,103,291,104,300,107,306,112,310,119,312,129,313,157,311,182,308,203,301,222,291,241,278,257,260,271,241,280,219,286,193,288,164,286,132,280,104,270,81,255,61,236,45,218,34,200,27,179,22,155,19,127,18,117,19,110,22,106,26,104,33,103,42,299,84,285,84,271,57,255,38,234,26, +62,37,73,140,72,171,72,171,80,305,62,37,62,37,80,305,59,286,62,37,59,286,45,57,45,57,59,286,44,266,45,57,44,266,32,80,32,80,44,266,31,243,32,80,31,243,22,106,22,106,31,243,22,218,22,106,22,218,16,133,16,133,22,218,16,191,16,133,16,191,14,162,78,112,81,22,85,88,85,88,81,22,103,9,85,88,103,9,95,68,95,68,103,9,108,51,123,38,108,51,127,0,123,38,127,0,139,28,139,28,127,0,153,-4,139,28,153,-4,157,21,157,21,153,-4,180,-6,157,21,180,-6,177,17,177,17,180,-6,197,15,222,17,197,15,214,-4,222,17,214,-4,245,3,73,140,62,37,81,22,73,140,81,22,78,112,108,51,103,9,127,0,254,326,259,293,262,324,262,324,259,293,272,280,262,324,272,280,269,322,269,322,272,280,275,321,280,322,275,321,279,272,280,322,279,272,285,263,275,321,272,280,279,272,228,333,228,311,240,330,240,330,228,311,244,304,240,330,244,304,247,328,247,328,244,304,259,293,247,328,259,293,254,326,216,335,204,337,211,316,216,335,211,316,228,311,216,335,228,311,228,333,204,337,192,338,211,316,211,316,192,338,192,318,151,311,192,318,153,336,151,311,153,336,127,330,310,224,305,338,299,224,299,224,305,338,296,338,299,224,296,338,295,240,295,240,296,338,293,332,295,240,293,332,290,252,290,252,293,332,290,328,290,252,290,328,285,263,285,263,290,328,285,324,285,263,285,324,280,322,316,56,307,65,297,34,297,34,307,65,285,47,297,34,285,47,273,16,273,16,285,47,265,32,273,16,265,32,245,3,245,3,265,32,244,23,245,3,244,23,222,17,197,15,180,-6,214,-4,192,318,192,338,180,338,192,318,180,338,153,336,72,171,77,219,80,305,80,305,77,219,93,260,80,305,93,260,102,320,102,320,93,260,117,291,102,320,117,291,127,330,127,330,117,291,151,311, +8,331,8,321,27,320,40,316,47,308,51,295,52,275,52,57,51,38,48,25,40,16,27,12,8,9,8,0,148,0,178,1,206,6,231,12,254,21,275,32,299,51,318,75,331,102,340,133,343,167,341,196,334,223,324,247,310,267,293,286,270,302,244,314,214,323,180,329,143,331,16383,16383,103,291,104,300,107,306,112,310,119,312,129,313,157,311,182,308,203,301,222,291,241,278,257,260,271,241,280,219,286,193,288,164,286,132,280,104,270,81,255,61,236,45,218,34,200,27,179,22,155,19,127,18,117,19,110,22,106,26,104,33,103,42,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,273,259,271,331,6,331,6,321,25,319,38,315,45,307,49,294,50,276,50,61, +48,25,40,16,148,0,148,0,40,16,27,12,148,0,27,12,8,9,52,57,51,38,110,22,110,22,51,38,148,0,110,22,148,0,117,19,117,19,148,0,127,18,155,19,127,18,148,0,155,19,148,0,178,1,104,300,107,306,52,275,52,275,107,306,112,310,52,275,112,310,143,331,143,331,112,310,119,312,143,331,119,312,129,313,129,313,119,312,129,312,129,313,129,312,157,311,129,313,157,311,143,331,143,331,157,311,180,329,206,6,231,12,218,34,218,34,231,12,236,45,255,61,236,45,254,21,255,61,254,21,275,32,155,19,178,1,179,22,179,22,178,1,206,6,179,22,206,6,200,27,200,27,206,6,218,34,244,314,241,278,257,260,244,314,257,260,270,302,270,302,257,260,271,241,270,302,271,241,293,286,293,286,271,241,280,219,293,286,280,219,286,193,182,308,203,301,214,323,214,323,203,301,222,291,214,323,222,291,244,314,244,314,222,291,241,278,180,329,157,311,182,308,180,329,182,308,214,323,343,167,341,196,340,133,340,133,341,196,334,223,340,133,334,223,331,102,331,102,334,223,324,247,331,102,324,247,318,75,318,75,324,247,310,267,318,75,310,267,299,51,299,51,310,267,293,286,299,51,293,286,288,164,288,164,286,132,299,51,299,51,286,132,280,104,299,51,280,104,275,32,275,32,280,104,270,81,275,32,270,81,255,61,236,45,231,12,254,21,110,22,106,26,52,57,52,57,106,26,104,33,52,57,104,33,52,275,52,275,104,33,103,42,52,275,103,42,103,291,40,316,47,308,143,331,143,331,47,308,51,295,143,331,51,295,52,275,27,320,40,316,143,331,27,320,143,331,8,331,27,320,8,331,8,321,148,0,8,9,8,0,48,25,148,0,51,38,104,300,52,275,103,291,293,286,286,193,288,164, +299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,273,259,271,331,6,331,6,321,25,319,38,315,45,307,49,294,50,276,50,61,49,40,45,25,37,16,25,12,6,9,6,0,146,0,146,9,127,12,113,16,105,24,102,37,100,56,100,164,171,164,193,162,209,158,219,150,225,136,228,115,239,115,239,232,228,232,225,212,218,198,208,190,193,185,171,184,100,184,100,292,101,300,102,306,105,310,110,311,118,312,184,312,214,311,234,306,247,297,255,282,261,259,354,177,227,177,227,168,246,166,259,162,267,154, +45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,49,294,50,275,106,310,49,294,106,310,45,307,45,307,106,310,111,312,45,307,111,312,271,331,271,331,111,312,118,312,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,271,331,118,312,184,312,271,331,184,312,213,311,271,331,213,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,271,331,6,331,25,320,271,331,25,320,38,315,271,331,38,315,45,307,255,38,234,26,276,0,276,0,234,26,206,20,276,0,206,20,169,18,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,255,38,276,0,169,18,151,18,276,0,151,18,132,19,276,0,132,19,117,21,276,0,117,21,45,24,276,0,6,9,6,0,25,320,6,331,6,321,176,184,176,164,198,162,233,232,244,115,244,232, +273,259,271,331,6,331,6,321,25,319,38,315,45,307,49,294,50,276,50,61,49,40,45,25,37,16,25,12,6,9,6,0,146,0,146,9,127,12,113,16,105,24,102,37,100,56,100,164,171,164,193,162,209,158,219,150,225,136,228,115,239,115,239,232,228,232,225,212,218,198,208,190,193,185,171,184,100,184,100,292,101,300,102,306,105,310,110,311,118,312,184,312,214,311,234,306,247,297,255,282,261,259,354,177,227,177,227,168,246,166,259,162,267,154,270,142,271,122,271,44,268,34,259,25,244,19,226,14,204,13,161,19,124,39,97,69,79,111,73,162,75,191,79,219,86,244,97,266,112,283,125,295,140,305,157,312,175,317,195,318,211,317,227,314,242,308,256,300,268,291,276,282,283,273,290,262,296,249,304,233,315,233,311,338,300,338,298,333,294,328,289,325,283,322,277,321,274,322,270,322,266,323,261,325, +38,315,45,307,271,331,271,331,45,307,110,311,271,331,110,311,118,312,271,331,118,312,184,312,271,331,184,312,214,311,50,276,102,37,100,56,100,184,100,164,171,164,100,184,171,164,171,184,193,185,171,184,193,162,193,185,193,162,208,190,208,190,193,162,209,158,208,190,209,158,218,198,218,198,209,158,219,150,218,198,219,150,225,212,225,212,219,150,225,136,225,212,225,136,228,232,228,232,225,136,228,115,228,232,228,115,239,115,271,331,214,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,276,100,56,100,292,50,276,100,292,101,300,50,276,101,300,102,306,50,276,102,306,105,310,50,276,105,310,49,294,110,311,45,307,49,294,110,311,49,294,105,310,25,319,38,315,271,331,25,319,271,331,6,331,25,319,6,331,6,321,146,0,146,9,127,12,146,0,127,12,113,16,146,0,113,16,49,40,146,0,49,40,45,25,146,0,45,25,37,16,146,0,37,16,25,12,146,0,25,12,6,9,146,0,6,9,6,0,50,61,49,40,113,16,50,61,113,16,105,24,50,61,105,24,102,37,50,61,102,37,50,276,171,184,171,164,193,162,228,232,239,115,239,232, +354,177,227,177,227,168,246,166,259,162,267,154,270,142,271,122,271,44,268,34,259,25,244,19,226,14,204,13,161,19,124,39,97,69,79,111,73,162,75,191,79,219,86,244,97,266,112,283,125,295,140,305,157,312,175,317,195,318,211,317,227,314,242,308,256,300,268,291,276,282,283,273,290,262,296,249,304,233,315,233,311,338,300,338,298,333,294,328,289,325,283,322,277,321,274,322,270,322,266,323,261,325,256,326,243,331,230,334,218,336,204,338,189,338,161,336,135,331,111,322,89,310,70,295,51,275,36,251,25,225,19,195,16,164,18,135,23,110,31,86,42,65,57,46,79,28,105,13,133,2,162,-4,193,-6,223,-5,251,0,278,6,301,16,320,28,320,128,321,144,324,156,330,162,340,166,354,168,352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,211,331,211,321,231,319,244,315,251,307,255,294,256,274,256,180,104,180,104,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,28,319,41,315,49,307,53,294,54,274,54,61,53,39,49,25,42,16,29,12,9,9,9,0,148,0,148,9,129,12,117,17,109,25,105,38,104,56,104,157,256,157,256,62,255,41,252,26,244,17,232,12,212,9,212,0,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,177,331, +16,164,18,135,19,195,19,195,18,135,23,110,19,195,23,110,25,225,25,225,23,110,31,86,25,225,31,86,36,251,36,251,31,86,42,65,36,251,42,65,51,275,51,275,42,65,57,46,51,275,57,46,70,295,70,295,57,46,73,162,157,312,161,336,140,305,140,305,161,336,135,331,140,305,135,331,125,295,125,295,135,331,112,283,97,266,112,283,111,322,97,266,111,322,89,310,89,310,70,295,75,191,89,310,75,191,79,219,89,310,79,219,86,244,89,310,86,244,97,266,193,-6,204,13,162,-4,162,-4,204,13,161,19,162,-4,161,19,133,2,133,2,161,19,124,39,133,2,124,39,105,13,105,13,124,39,97,69,105,13,97,69,79,28,79,28,97,69,79,111,79,28,79,111,73,162,259,25,244,19,251,0,251,0,244,19,226,14,251,0,226,14,223,-5,223,-5,226,14,204,13,73,162,57,46,79,28,268,291,266,323,261,325,268,291,261,325,256,300,268,291,270,322,266,323,204,338,195,318,211,317,204,338,211,317,218,336,218,336,211,317,227,314,218,336,227,314,230,334,230,334,227,314,242,308,230,334,242,308,243,331,243,331,242,308,256,300,243,331,256,300,256,326,256,326,256,300,261,325,270,322,276,282,274,322,274,322,276,282,277,321,283,322,277,321,283,273,283,322,283,273,290,262,268,291,276,282,270,322,304,233,315,233,311,338,304,233,311,338,300,338,304,233,300,338,298,333,304,233,298,333,296,249,294,328,289,325,290,262,294,328,290,262,296,249,294,328,296,249,298,333,277,321,276,282,283,273,340,166,354,168,354,177,340,166,354,177,330,162,330,162,354,177,270,142,330,162,270,142,271,122,278,6,271,122,271,44,278,6,271,44,268,34,330,162,271,122,324,156,324,156,271,122,278,6,324,156,278,6,321,144,321,144,278,6,301,16,321,144,301,16,320,128,320,128,301,16,320,28,354,177,227,177,246,166,354,177,246,166,259,162,354,177,259,162,267,154,354,177,267,154,270,142,259,25,251,0,278,6,259,25,278,6,268,34,189,338,161,336,175,317,189,338,175,317,195,318,189,338,195,318,204,338,135,331,111,322,112,283,161,336,157,312,175,317,223,-5,204,13,193,-6,246,166,227,177,227,168,283,322,290,262,289,325,75,191,70,295,73,162, +352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,211,331,211,321,231,319,244,315,251,307,255,294,256,274,256,180,104,180,104,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,28,319,41,315,49,307,53,294,54,274,54,61,53,39,49,25,42,16,29,12,9,9,9,0,148,0,148,9,129,12,117,17,109,25,105,38,104,56,104,157,256,157,256,62,255,41,252,26,244,17,232,12,212,9,212,0,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,177,331,33,331,33,321,54,319,67,315,75,308,79,295,80,275,80,47,79,34,78,24,75,17,69,13,61,12,56,13,53,16,51,21,48,27,46,34,42,41,38,47,33,52,28,54,22,55,14,54,7,50,2,44,-1,37,-2,29,0,16,6,6,17,0,31,-5, +49,25,42,16,148,0,148,0,42,16,29,12,148,0,29,12,9,9,149,331,9,331,28,319,149,331,28,319,41,315,149,331,41,315,49,307,149,331,49,307,53,294,149,331,53,294,118,315,149,331,118,315,130,319,149,331,130,319,149,321,54,274,105,38,104,56,104,180,104,157,256,157,104,180,256,157,256,180,256,180,256,157,312,25,256,180,312,25,308,37,54,274,104,56,104,274,54,274,104,274,106,294,54,274,106,294,110,307,54,274,110,307,118,315,54,274,118,315,53,294,252,26,244,17,352,0,352,0,244,17,232,12,352,0,232,12,212,9,333,319,352,321,352,331,333,319,352,331,320,315,320,315,352,331,255,294,320,315,255,294,256,274,308,37,256,274,256,180,307,55,307,274,256,274,256,274,307,274,308,293,256,274,308,293,312,307,352,331,211,331,231,319,352,331,231,319,244,315,352,331,244,315,251,307,352,331,251,307,255,294,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,255,41,352,0,255,41,252,26,256,62,255,41,320,17,256,62,320,17,312,25,256,62,312,25,256,157,148,0,148,9,129,12,148,0,129,12,117,17,148,0,117,17,53,39,148,0,53,39,49,25,54,61,53,39,117,17,54,61,117,17,109,25,54,61,109,25,105,38,54,61,105,38,54,274,148,0,9,9,9,0,352,0,212,9,212,0,256,274,308,37,307,55,231,319,211,331,211,321,320,315,256,274,312,307,28,319,9,331,9,321, +157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,177,331,33,331,33,321,54,319,67,315,75,308,79,295,80,275,80,47,79,34,78,24,75,17,69,13,61,12,56,13,53,16,51,21,48,27,46,34,42,41,38,47,33,52,28,54,22,55,14,54,7,50,2,44, +52,23,44,15,157,0,157,0,44,15,30,11,157,0,30,11,9,9,157,331,9,331,30,320,157,331,30,320,44,316,157,331,44,316,53,308,157,331,53,308,57,295,157,331,57,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,57,295,157,0,157,9,137,11,157,0,137,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,9,9,9,0,56,36,122,16,57,56,30,320,9,331,9,321, +177,331,33,331,33,321,54,319,67,315,75,308,79,295,80,275,80,47,79,34,78,24,75,17,69,13,61,12,56,13,53,16,51,21,48,27,46,34,42,41,38,47,33,52,28,54,22,55,14,54,7,50,2,44,-1,37,-2,29,0,16,6,6,17,0,31,-5,47,-6,76,-2,100,8,117,28,128,56,131,93,131,275,132,294,136,307,143,315,157,319,177,321,362,0,362,9,349,11,336,16,322,25,305,41,283,64,166,192,259,281,278,298,292,309,305,316,320,320,338,321,338,331,208,331,208,321,220,321,229,320,235,318,238,315,240,311,241,305,239,298,234,289,226,280,202,256,113,174,113,293,117,307,124,315,137,319,158,321,158,331,17,331,17,321,37,319,50,315,57,306,61,293,62,275,62,63,61,40,57,26,50,17, +78,24,75,17,76,-2,76,-2,75,17,69,13,76,-2,69,13,61,12,61,12,56,13,76,-2,76,-2,56,13,47,-6,157,319,177,321,177,331,157,319,177,331,143,315,143,315,177,331,79,295,143,315,79,295,80,275,100,8,80,275,80,47,100,8,80,47,79,34,131,275,132,294,117,28,131,275,117,28,128,56,131,275,128,56,131,93,132,294,136,307,80,275,132,294,80,275,100,8,132,294,100,8,117,28,177,331,33,331,54,319,177,331,54,319,67,315,177,331,67,315,75,308,177,331,75,308,79,295,78,24,76,-2,100,8,78,24,100,8,79,34,47,-6,56,13,53,16,47,-6,53,16,51,21,47,-6,51,21,48,27,47,-6,48,27,46,34,47,-6,46,34,42,41,47,-6,42,41,38,47,47,-6,38,47,33,52,47,-6,33,52,31,-5,33,52,28,54,31,-5,31,-5,28,54,22,55,31,-5,22,55,17,0,17,0,22,55,14,54,17,0,14,54,7,50,17,0,7,50,6,6,6,6,7,50,2,44,6,6,2,44,0,16,0,16,2,44,-1,37,0,16,-1,37,-2,29,54,319,33,331,33,321,143,315,80,275,136,307, +362,0,362,9,349,11,336,16,322,25,305,41,283,64,166,192,259,281,278,298,292,309,305,316,320,320,338,321,338,331,208,331,208,321,220,321,229,320,235,318,238,315,240,311,241,305,239,298,234,289,226,280,202,256,113,174,113,293,117,307,124,315,137,319,158,321,158,331,17,331,17,321,37,319,50,315,57,306,61,293,62,275,62,63,61,40,57,26,50,17,36,12,17,9,17,0,157,0,157,9,139,12,126,16,118,23,114,36,113,55,113,148,126,158,176,107,198,84,217,63,232,46,241,32,244,22,244,18,241,15,237,12,231,11,224,10,210,9,210,0,299,87,286,87,277,69,273,62,265,50,254,39,239,30,223,24,203,21,180,20,127,20,114,22,106,26,102,32,100,42,100,274,101,294,105,307,113,315,127,319,147,321,147,331,6,331,6,321,26,319,38,314,46,306,49,292,50,273,50,57,49,38,45,25,37,16,25,12,6,9,6,0,275,0,432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12,6,9,6,0,123,0,123,9, +158,321,158,321,137,319,137,319,158,321,158,331,137,319,158,331,124,315,124,315,158,331,61,293,124,315,61,293,62,275,114,36,62,275,62,63,114,36,62,63,118,23,118,23,62,63,126,16,62,275,114,36,113,55,113,174,113,148,126,158,113,174,126,158,202,256,202,256,126,158,166,192,202,256,166,192,259,281,62,275,113,55,113,274,62,275,113,274,113,293,62,275,113,293,117,307,62,275,117,307,124,315,158,331,17,331,37,319,158,331,37,319,50,315,158,331,50,315,57,306,158,331,57,306,61,293,234,289,226,280,259,281,259,281,226,280,215,269,259,281,215,269,202,256,338,331,208,331,220,321,338,331,220,321,229,320,338,331,229,320,235,318,338,331,235,318,238,315,338,331,238,315,240,311,338,331,240,311,241,305,338,331,241,305,305,316,338,331,305,316,320,320,338,331,320,320,338,321,241,305,259,281,278,298,241,305,278,298,292,309,241,305,292,309,305,316,239,298,234,289,259,281,239,298,259,281,241,305,241,15,237,12,362,0,362,0,237,12,231,11,362,0,231,11,224,10,244,22,362,0,336,16,244,22,336,16,322,25,244,22,322,25,305,41,244,22,305,41,283,64,244,22,283,64,241,32,283,64,166,192,176,107,283,64,176,107,198,84,283,64,198,84,217,63,283,64,217,63,232,46,283,64,232,46,241,32,349,11,336,16,362,0,349,11,362,0,362,9,244,18,241,15,362,0,244,18,362,0,244,22,210,9,210,0,362,0,210,9,362,0,224,10,157,0,157,9,139,12,157,0,139,12,126,16,157,0,126,16,61,40,157,0,61,40,57,26,157,0,57,26,50,17,157,0,50,17,36,12,157,0,36,12,17,9,157,0,17,9,17,0,61,40,126,16,62,63,176,107,166,192,126,158,220,321,208,331,208,321,37,319,17,331,17,321, +299,87,286,87,277,69,273,62,265,50,254,39,239,30,223,24,203,21,180,20,127,20,114,22,106,26,102,32,100,42,100,274,101,294,105,307,113,315,127,319,147,321,147,331,6,331,6,321,26,319,38,314,46,306,49,292,50,273,50,57,49,38,45,25,37,16,25,12,6,9,6,0,275,0,432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12,6,9,6,0,123,0,123,9,103,12,90,18,82,29,78,48, +147,321,147,321,127,319,127,319,147,321,147,331,127,319,147,331,113,315,113,315,147,331,49,292,113,315,49,292,50,273,102,32,50,273,50,57,102,32,50,57,106,26,106,26,50,57,49,38,106,26,49,38,114,22,114,22,49,38,45,25,114,22,45,25,127,20,127,20,45,25,275,0,127,20,275,0,146,20,146,20,275,0,180,20,100,42,100,274,50,273,50,273,100,274,101,294,50,273,101,294,105,307,147,331,6,331,26,319,147,331,26,319,38,314,147,331,38,314,46,306,147,331,46,306,49,292,277,69,273,62,275,0,275,0,273,62,269,56,275,0,269,56,265,50,265,50,254,39,275,0,275,0,254,39,239,30,275,0,239,30,223,24,299,87,286,87,281,77,299,87,281,77,277,69,299,87,277,69,275,0,203,21,180,20,275,0,203,21,275,0,223,24,275,0,45,25,37,16,275,0,37,16,25,12,275,0,25,12,6,9,275,0,6,9,6,0,50,273,102,32,100,42,26,319,6,331,6,321,113,315,50,273,105,307, +432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12,6,9,6,0,123,0,123,9,103,12,90,18,82,29,78,48,76,75,76,275,203,0,209,0,337,286,337,61,336,40,333,26,325,17,312,12,292,9,292,0,353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9,103,13,90,20,82,31,78,49,76,75,76,269,297,-5,306,-5,306,274,308,289,311,299,315,307,320,313,324,315,329,318,335,319,343,320,353,321,344,166,336,222, +49,29,41,18,123,0,123,0,41,18,27,12,123,0,27,12,6,9,333,26,325,17,432,0,432,0,325,17,312,12,432,0,312,12,292,9,413,320,431,321,431,331,413,320,431,331,401,316,401,316,431,331,337,286,401,316,337,286,393,307,393,307,337,286,389,294,401,17,393,25,337,61,337,61,393,25,389,38,337,61,389,38,337,286,337,286,389,38,388,56,337,286,388,56,388,275,203,0,209,0,222,80,222,80,209,0,337,286,222,80,337,286,332,331,332,331,337,286,431,331,106,331,7,331,28,319,106,331,28,319,42,315,106,331,42,315,50,307,106,331,50,307,54,294,106,331,54,294,55,275,106,331,55,275,76,275,106,331,76,275,203,0,106,331,203,0,222,80,76,75,76,275,55,275,76,75,55,275,78,48,78,48,55,275,55,75,78,48,55,75,82,29,82,29,55,75,54,47,82,29,54,47,90,18,90,18,54,47,49,29,90,18,49,29,123,0,432,0,432,9,413,12,432,0,413,12,401,17,432,0,401,17,336,40,432,0,336,40,333,26,103,12,90,18,123,0,103,12,123,0,123,9,123,0,6,9,6,0,432,0,292,9,292,0,336,40,401,17,337,61,28,319,7,331,7,321,389,294,337,286,388,275, +353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9,103,13,90,20,82,31,78,49,76,75,76,269,297,-5,306,-5,306,274,308,289,311,299,315,307,320,313,324,315,329,318,335,319,343,320,353,321,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269, +49,30,41,19,123,0,123,0,41,19,27,13,123,0,27,13,6,9,256,319,263,317,353,331,353,331,263,317,269,313,353,331,269,313,275,309,275,309,278,303,353,331,353,331,278,303,281,295,353,331,281,295,324,315,324,315,281,295,320,313,324,315,320,313,320,312,320,312,320,313,315,307,315,307,320,313,284,274,315,307,284,274,284,259,297,-5,284,259,284,89,297,-5,284,89,91,331,353,331,324,315,329,318,353,331,329,318,335,319,353,331,335,319,343,320,353,331,343,320,353,321,306,-5,306,253,297,-5,297,-5,306,253,306,274,297,-5,306,274,284,259,284,259,306,274,308,289,284,259,308,289,311,299,283,285,284,274,320,313,283,285,320,313,281,295,247,320,256,319,353,331,247,320,353,331,235,331,247,320,235,331,235,321,91,331,6,331,19,321,91,331,19,321,29,318,91,331,29,318,37,313,91,331,37,313,46,306,91,331,46,306,55,295,91,331,55,295,76,269,91,331,76,269,297,-5,55,295,78,49,76,75,54,48,49,30,90,20,90,20,49,30,123,0,90,20,123,0,103,13,103,13,123,0,123,9,55,75,54,48,82,31,55,75,82,31,78,49,55,75,78,49,55,295,123,0,6,9,6,0,54,48,90,20,82,31,19,321,6,331,6,321,76,269,55,295,76,75,315,307,284,259,311,299, +344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,8,331,8,321,27,319,39,315,46,307,49,294,50,276,50,39,47,25,40,16,27,12,8,9,8,0,148,0,148,9,128,12,114,16,106,24,102,37,101,56,101,146,109,145,115,145,122,144,136,144,164,145,188,147,208,153,225,161,243,175,253,185,260,197,266,210,270,225,271,240,270,254,267,268,262,280,255,291,246,300,231,310,213,319,191,325,166,329,137,331,16383,16383,101,295,101,302,103,307,106,310,111,312,118,313,155,310,182,302,202,288,213,266,217,238,213,213,202,192,185,177,162,167,132,164,120,164, +149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19, +8,331,8,321,27,319,39,315,46,307,49,294,50,276,50,39,47,25,40,16,27,12,8,9,8,0,148,0,148,9,128,12,114,16,106,24,102,37,101,56,101,146,109,145,115,145,122,144,136,144,164,145,188,147,208,153,225,161,243,175,253,185,260,197,266,210,270,225,271,240,270,254,267,268,262,280,255,291,246,300,231,310,213,319,191,325,166,329,137,331,16383,16383,101,295,101,302,103,307,106,310,111,312,118,313,155,310,182,302,202,288,213,266,217,238,213,213,202,192,185,177,162,167,132,164,120,164,114,165,108,165,101,166,350,-88,350,-78,318,-74,288,-65,261,-51,236,-30,213,-2,232,1,248,6,263,12,277,21,290,32,309,54,324,77,335,104,342,133,344,166,336,224,314,272,279,308,234,330,180,338,127,330,82,308,47,272,25,224,17,166,18,140,23,115,31,92,42,70,55,50,67,36,79,25,94,16,111,7,132,0,153,-25,177,-48,206,-66,241,-78,282,-85,326,-88,16383,16383,287,169,285,139,281,111,275,85,266,64,255,47,243,35,230,25,215,18,198,13,180,11,163,13,146,18,129,26,115,37,103,50,93,68,85,89,79,113,75,139,74,167,76,196, +111,312,118,312,118,313,137,331,118,313,155,310,137,331,155,310,166,329,166,329,155,310,182,302,166,329,182,302,191,325,191,325,182,302,202,288,191,325,202,288,213,319,213,319,202,288,213,266,213,319,213,266,231,310,231,310,213,266,217,238,231,310,217,238,225,161,225,161,213,213,208,153,208,153,213,213,202,192,208,153,202,192,188,147,188,147,202,192,185,177,188,147,185,177,164,145,164,145,185,177,162,167,164,145,162,167,136,144,136,144,162,167,132,164,136,144,132,164,128,144,128,144,132,164,126,164,128,144,126,164,122,144,122,144,126,164,120,164,122,144,120,164,115,145,115,145,120,164,114,165,115,145,114,165,109,145,109,145,114,165,108,165,109,145,108,165,101,166,101,56,101,166,50,276,101,56,50,276,102,37,102,37,50,276,50,61,101,166,101,146,109,145,271,240,270,254,270,225,270,225,270,254,267,268,270,225,267,268,266,210,266,210,267,268,262,280,266,210,262,280,260,197,260,197,262,280,255,291,260,197,255,291,253,185,253,185,255,291,246,300,253,185,246,300,243,175,243,175,246,300,231,310,243,175,231,310,225,161,137,331,8,331,27,319,137,331,27,319,39,315,137,331,39,315,46,307,137,331,46,307,49,294,137,331,49,294,50,276,137,331,50,276,106,310,137,331,106,310,111,312,137,331,111,312,118,313,101,295,101,302,50,276,101,295,50,276,101,166,103,307,106,310,50,276,103,307,50,276,101,302,148,0,148,9,128,12,148,0,128,12,114,16,148,0,114,16,50,39,148,0,50,39,47,25,148,0,47,25,40,16,148,0,40,16,27,12,148,0,27,12,8,9,148,0,8,9,8,0,50,61,50,39,114,16,50,61,114,16,106,24,50,61,106,24,102,37,27,319,8,331,8,321,213,213,225,161,217,238,155,310,118,313,118,312, +350,-88,350,-78,318,-74,288,-65,261,-51,236,-30,213,-2,232,1,248,6,263,12,277,21,290,32,309,54,324,77,335,104,342,133,344,166,336,224,314,272,279,308,234,330,180,338,127,330,82,308,47,272,25,224,17,166,18,140,23,115,31,92,42,70,55,50,67,36,79,25,94,16,111,7,132,0,153,-25,177,-48,206,-66,241,-78,282,-85,326,-88,16383,16383,287,169,285,139,281,111,275,85,266,64,255,47,243,35,230,25,215,18,198,13,180,11,163,13,146,18,129,26,115,37,103,50,93,68,85,89,79,113,75,139,74,167,76,196,80,222,87,247,96,268,107,285,119,297,133,307,147,314,163,318,179,320,193,319,206,316,219,312,231,306,242,297,257,280,270,258,279,232,285,202,287,169,330,0,330,9,318,11,308,13,299,17,291,24,283,33,183,160,216,168,242,180,260,197,270,217,273,242,272,255,270,268,265,281,258,292,249,301,234,311,217,319,196,326,172,330,145,331,8,331,8,321,28,319,40,315,47,307,50,294,51,276,51,62,50,40,47,25,39,16,27,12,8,9,8,0,147,0,147,9,127,12,114,16,107,24,103,37,102,56,102,153,130,154,249,0,16383,16383,102,291,103,300,106,306,111,310,118,312,127,313,161,310,186,302,205,289,215,270,219,246,218,231,214,218,208,206,200,196,190,189,177,182,163,177,147,174,128,172,102,171,234,232,224,338,213,338,211,332,209,327,206,324,202,322,197,321,194,321,190,322,185,323,175,327,164,331,154,334,134,338,123,338, +79,113,79,25,85,89,85,89,79,25,94,16,85,89,94,16,93,68,93,68,94,16,103,50,115,37,103,50,111,7,115,37,111,7,132,0,79,113,75,139,79,25,79,25,75,139,74,167,67,36,74,167,76,196,67,36,76,196,55,50,55,50,76,196,82,308,55,50,82,308,47,272,147,314,180,338,133,307,133,307,180,338,127,330,133,307,127,330,119,297,119,297,127,330,107,285,96,268,107,285,127,330,96,268,127,330,82,308,129,26,132,0,146,18,146,18,132,0,153,-25,146,18,153,-25,163,13,163,13,153,-25,177,-48,163,13,177,-48,180,11,180,11,177,-48,206,-66,180,11,206,-66,198,13,234,330,180,338,193,319,193,319,180,338,179,320,163,318,179,320,180,338,163,318,180,338,147,314,206,316,219,312,234,330,234,330,219,312,231,306,234,330,231,306,242,297,242,297,257,280,279,308,279,308,257,280,270,258,279,308,270,258,279,232,232,1,248,6,243,35,243,35,248,6,255,47,266,64,255,47,263,12,266,64,263,12,277,21,236,-30,213,-2,241,-78,215,18,213,-2,232,1,215,18,232,1,230,25,230,25,232,1,243,35,206,-66,241,-78,213,-2,206,-66,213,-2,215,18,206,-66,215,18,198,13,336,224,314,272,324,77,336,224,324,77,335,104,336,224,335,104,342,133,336,224,342,133,344,166,285,139,290,32,287,169,287,169,290,32,314,272,314,272,290,32,309,54,314,272,309,54,324,77,285,202,287,169,314,272,285,202,314,272,279,308,285,202,279,308,279,232,279,308,234,330,242,297,281,111,275,85,277,21,281,111,277,21,290,32,281,111,290,32,285,139,255,47,248,6,263,12,326,-88,350,-88,350,-78,326,-88,350,-78,318,-74,326,-88,318,-74,288,-65,326,-88,288,-65,282,-85,261,-51,236,-30,241,-78,261,-51,241,-78,282,-85,261,-51,282,-85,288,-65,82,308,76,196,80,222,82,308,80,222,87,247,82,308,87,247,96,268,18,140,23,115,25,224,25,224,23,115,31,92,25,224,31,92,47,272,47,272,31,92,42,70,47,272,42,70,55,50,103,50,94,16,111,7,18,140,25,224,17,166,266,64,277,21,275,85,234,330,193,319,206,316,115,37,132,0,129,26,79,25,74,167,67,36, +330,0,330,9,318,11,308,13,299,17,291,24,283,33,183,160,216,168,242,180,260,197,270,217,273,242,272,255,270,268,265,281,258,292,249,301,234,311,217,319,196,326,172,330,145,331,8,331,8,321,28,319,40,315,47,307,50,294,51,276,51,62,50,40,47,25,39,16,27,12,8,9,8,0,147,0,147,9,127,12,114,16,107,24,103,37,102,56,102,153,130,154,249,0,16383,16383,102,291,103,300,106,306,111,310,118,312,127,313,161,310,186,302,205,289,215,270,219,246,218,231,214,218,208,206,200,196,190,189,177,182,163,177,147,174,128,172,102,171,234,232,224,338,213,338,211,332,209,327,206,324,202,322,197,321,194,321,190,322,185,323,175,327,164,331,154,334,134,338,123,338,95,334,71,323,52,305,40,281,36,251,38,232,44,214,56,196,73,180,97,165,116,154,135,142,152,130,168,118,180,107,185,100,189,93,192,85,194,77,195,67,192,49,184,33,172,21,155,14,136,11,109,15,85,25,65,42,47,67,32,99,22,99,36,-6,47,-6,48,0,50,4,53,7,57,9,61,10,64,10,79,7,84,4,96,0,107,-2,131,-6,143,-6,176,-2,204,10,226,29,240,55,246,86,243,108,233,128,218,148, +118,312,127,312,127,313,145,331,127,313,161,310,145,331,161,310,172,330,172,330,161,310,186,302,172,330,186,302,196,326,196,326,186,302,205,289,196,326,205,289,217,319,217,319,205,289,215,270,217,319,215,270,219,246,214,218,208,206,216,168,216,168,208,206,200,196,216,168,200,196,190,189,190,189,177,182,183,160,183,160,177,182,163,177,183,160,163,177,249,0,249,0,163,177,147,174,249,0,147,174,130,154,130,154,147,174,128,172,130,154,128,172,102,171,265,281,258,292,260,197,260,197,258,292,249,301,260,197,249,301,242,180,242,180,249,301,234,311,242,180,234,311,219,246,219,246,234,311,217,319,214,218,216,168,218,231,218,231,216,168,242,180,218,231,242,180,219,246,270,217,273,242,272,255,270,217,272,255,270,268,270,217,270,268,265,281,270,217,265,281,260,197,190,189,183,160,216,168,318,11,308,13,330,0,330,0,308,13,299,17,330,0,299,17,249,0,249,0,299,17,291,24,249,0,291,24,283,33,102,56,102,171,51,276,102,56,51,276,103,37,103,37,51,276,51,62,102,171,102,153,130,154,145,331,8,331,28,319,145,331,28,319,40,315,145,331,40,315,47,307,145,331,47,307,50,294,145,331,50,294,51,276,145,331,51,276,111,310,145,331,111,310,118,312,145,331,118,312,127,313,102,291,103,300,51,276,102,291,51,276,102,171,106,306,111,310,51,276,106,306,51,276,103,300,147,0,147,9,127,12,147,0,127,12,114,16,147,0,114,16,50,40,147,0,50,40,47,25,147,0,47,25,39,16,147,0,39,16,27,12,147,0,27,12,8,9,147,0,8,9,8,0,51,62,50,40,114,16,51,62,114,16,107,24,51,62,107,24,103,37,28,319,8,331,8,321,183,160,249,0,283,33,318,11,330,0,330,9,161,310,127,313,127,312, +234,232,224,338,213,338,211,332,209,327,206,324,202,322,197,321,194,321,190,322,185,323,175,327,164,331,154,334,134,338,123,338,95,334,71,323,52,305,40,281,36,251,38,232,44,214,56,196,73,180,97,165,116,154,135,142,152,130,168,118,180,107,185,100,189,93,192,85,194,77,195,67,192,49,184,33,172,21,155,14,136,11,109,15,85,25,65,42,47,67,32,99,22,99,36,-6,47,-6,48,0,50,4,53,7,57,9,61,10,64,10,79,7,84,4,96,0,107,-2,131,-6,143,-6,176,-2,204,10,226,29,240,55,246,86,243,108,233,128,218,148,196,166,168,185,139,202,114,218,95,234,83,251,79,270,81,286,88,299,98,309,112,315,129,318,146,316,162,310,177,302,190,291,201,278,206,271,211,263,215,254,218,244,222,232,296,246,293,331,12,331,8,246,21,246,27,274,37,292,50,303,70,309,97,310,127,310,127,61,126,39,123,25,115,16,101,12,80,9,80,0,226,0,226,9,205,11,192,16,183,23,179,36,178,55,178,310,208,310,235,309,254,303,268,292,277,274,285,246,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45, +50,4,53,7,65,42,65,42,53,7,57,9,65,42,57,9,61,10,61,10,64,10,65,42,65,42,64,10,69,9,65,42,69,9,85,25,85,25,69,9,74,8,85,25,74,8,79,7,95,234,83,251,97,165,97,165,83,251,79,270,73,180,79,270,71,323,73,180,71,323,56,196,56,196,71,323,52,305,56,196,52,305,44,214,44,214,52,305,40,281,44,214,40,281,38,232,38,232,40,281,36,251,81,286,88,299,95,334,95,334,88,299,98,309,95,334,98,309,123,338,123,338,98,309,112,315,123,338,112,315,129,318,129,318,146,316,134,338,134,338,146,316,144,336,81,286,95,334,71,323,81,286,71,323,79,270,134,338,123,338,129,318,144,336,146,316,154,334,154,334,146,316,162,310,154,334,162,310,164,331,164,331,162,310,177,302,164,331,177,302,175,327,175,327,177,302,180,325,95,234,97,165,114,218,114,218,97,165,116,154,114,218,116,154,139,202,139,202,116,154,135,142,139,202,135,142,152,130,136,11,119,-4,131,-6,136,11,131,-6,143,-6,136,11,109,15,119,-4,79,7,84,4,85,25,85,25,84,4,96,0,85,25,96,0,109,15,109,15,96,0,107,-2,109,15,107,-2,119,-4,36,-6,47,-6,47,67,47,67,47,-6,48,0,47,67,48,0,65,42,65,42,48,0,50,4,32,99,22,99,36,-6,32,99,36,-6,47,67,139,202,152,130,168,185,168,185,152,130,168,118,168,185,168,118,180,107,180,107,185,100,196,166,196,166,185,100,189,93,196,166,189,93,192,85,246,86,243,108,240,55,240,55,243,108,233,128,240,55,233,128,226,29,226,29,233,128,218,148,226,29,218,148,204,10,204,10,218,148,196,166,204,10,196,166,195,67,195,67,192,49,204,10,204,10,192,49,184,33,204,10,184,33,176,-2,176,-2,184,33,172,21,176,-2,172,21,155,14,196,166,192,85,194,77,196,166,194,77,195,67,196,166,168,185,180,107,155,14,136,11,143,-6,155,14,143,-6,176,-2,190,291,201,278,194,321,194,321,201,278,197,321,202,322,197,321,201,278,190,291,194,321,190,322,190,291,190,322,185,323,190,291,185,323,180,325,190,291,180,325,177,302,224,338,213,338,215,254,224,338,215,254,218,244,224,338,218,244,222,232,224,338,222,232,234,232,206,324,206,271,209,327,209,327,206,271,211,263,209,327,211,263,211,332,211,332,211,263,215,254,211,332,215,254,213,338,202,322,201,278,206,271,202,322,206,271,206,324,97,165,79,270,73,180, +296,246,293,331,12,331,8,246,21,246,27,274,37,292,50,303,70,309,97,310,127,310,127,61,126,39,123,25,115,16,101,12,80,9,80,0,226,0,226,9,205,11,192,16,183,23,179,36,178,55,178,310,208,310,235,309,254,303,268,292,277,274,285,246,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314, +293,331,12,331,70,309,293,331,70,309,97,310,293,331,97,310,127,310,293,331,127,310,178,310,293,331,178,310,208,310,293,331,208,310,235,309,293,331,235,309,254,303,293,331,254,303,268,292,293,331,268,292,277,274,293,331,277,274,285,246,293,331,285,246,296,246,192,16,183,23,127,61,127,61,183,23,179,36,127,61,179,36,127,310,127,310,179,36,178,55,127,310,178,55,178,310,12,331,8,246,21,246,12,331,21,246,27,274,12,331,27,274,37,292,12,331,37,292,50,303,12,331,50,303,70,309,226,0,226,9,205,11,226,0,205,11,192,16,226,0,192,16,126,39,226,0,126,39,123,25,226,0,123,25,115,16,226,0,115,16,101,12,226,0,101,12,80,9,226,0,80,9,80,0,126,39,192,16,127,61, +353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,349,331,247,331,247,321,258,321,268,319,276,316,281,310,282,301,282,295,281,289,279,282,276,274,273,265,200,80,123,252,116,269,110,283,106,292,104,300,104,305,105,310,107,314,112,317,118,319,127,320,141,321,141,331,8,331,8,321,21,320,31,316,41,307,50,291,62,267,184,-5,191,-5,302,276,311,295,319,308,328,316,338,320,349,321,466,331,368,331,368,321,381,320,391,318,397,314,401,308,402,301,402,294,401,287,399,280,397,271,394,262,331,93,259,275,255,289,253,295,252,300,251,304,253,310,257,315,265,318,276,320,290,321,290,331,157,331, +105,79,106,8,109,63,109,63,106,8,121,1,109,63,121,1,115,50,115,50,121,1,125,37,135,30,125,37,138,-3,135,30,138,-3,146,24,146,24,138,-3,157,-5,146,24,157,-5,158,19,158,19,157,-5,177,-6,158,19,177,-6,173,16,173,16,177,-6,189,15,208,16,189,15,204,-5,208,16,204,-5,227,0,103,118,103,275,93,16,103,118,93,16,104,97,104,97,93,16,106,8,104,97,106,8,105,79,125,37,121,1,138,-3,283,103,282,85,290,45,290,45,282,85,279,70,290,45,279,70,278,30,278,30,279,70,273,57,278,30,273,57,265,45,265,45,254,34,264,17,264,17,254,34,247,6,241,26,225,20,227,0,241,26,227,0,247,6,241,26,247,6,254,34,353,331,237,331,257,319,353,331,257,319,270,312,353,331,270,312,279,301,353,331,279,301,318,311,353,331,318,311,331,318,353,331,331,318,353,321,305,258,306,282,297,62,305,258,297,62,302,81,305,258,302,81,305,104,305,258,305,104,305,131,290,45,297,62,306,282,290,45,306,282,283,257,290,45,283,257,283,125,290,45,283,125,283,103,310,300,318,311,282,283,310,300,282,283,283,257,310,300,283,257,306,282,265,45,264,17,278,30,189,15,177,-6,204,-5,128,319,148,321,148,331,128,319,148,331,115,314,115,314,148,331,51,297,115,314,51,297,52,280,53,95,52,280,52,124,58,69,66,48,104,293,104,293,66,48,78,30,104,293,78,30,103,275,103,275,78,30,93,16,104,293,108,306,52,280,104,293,52,280,53,95,104,293,53,95,58,69,148,331,7,331,27,319,148,331,27,319,40,315,148,331,40,315,47,308,148,331,47,308,51,297,27,319,7,331,7,321,115,314,52,280,108,306,257,319,237,331,237,321,318,311,279,301,282,283,208,16,227,0,225,20, +349,331,247,331,247,321,258,321,268,319,276,316,281,310,282,301,282,295,281,289,279,282,276,274,273,265,200,80,123,252,116,269,110,283,106,292,104,300,104,305,105,310,107,314,112,317,118,319,127,320,141,321,141,331,8,331,8,321,21,320,31,316,41,307,50,291,62,267,184,-5,191,-5,302,276,311,295,319,308,328,316,338,320,349,321,466,331,368,331,368,321,381,320,391,318,397,314,401,308,402,301,402,294,401,287,399,280,397,271,394,262,331,93,259,275,255,289,253,295,252,300,251,304,253,310,257,315,265,318,276,320,290,321,290,331,157,331,157,321,171,320,182,317,191,309,199,295,208,273,222,236,170,94,98,282,96,288,95,293,93,298,93,311,96,316,102,319,111,321, +62,267,184,-5,62,267,62,267,184,-5,104,300,62,267,104,300,104,305,104,305,105,310,62,267,62,267,105,310,107,314,62,267,107,314,50,291,141,331,8,331,21,320,141,331,21,320,31,316,141,331,31,316,41,307,141,331,41,307,50,291,141,331,50,291,112,317,141,331,112,317,118,319,141,331,118,319,127,320,141,331,127,320,141,321,281,289,279,282,302,276,302,276,279,282,276,274,302,276,276,274,273,265,273,265,200,80,302,276,302,276,200,80,191,-5,349,331,247,331,258,321,349,331,258,321,268,319,349,331,268,319,276,316,349,331,276,316,281,310,349,331,281,310,282,301,349,331,282,301,328,316,349,331,328,316,338,320,349,331,338,320,349,321,282,301,302,276,311,295,282,301,311,295,319,308,282,301,319,308,328,316,282,295,281,289,302,276,282,295,302,276,282,301,184,-5,191,-5,200,80,184,-5,200,80,123,252,184,-5,123,252,116,269,184,-5,116,269,110,283,184,-5,110,283,106,292,184,-5,106,292,104,300,258,321,247,331,247,321,21,320,8,331,8,321,112,317,50,291,107,314, +466,331,368,331,368,321,381,320,391,318,397,314,401,308,402,301,402,294,401,287,399,280,397,271,394,262,331,93,259,275,255,289,253,295,252,300,251,304,253,310,257,315,265,318,276,320,290,321,290,331,157,331,157,321,171,320,182,317,191,309,199,295,208,273,222,236,170,94,98,282,96,288,95,293,93,298,93,311,96,316,102,319,111,321,124,321,124,331,2,331,2,321,16,320,27,314,36,303,45,286,55,262,73,210,92,157,132,49,151,-5,158,-5,235,206,251,165,267,123,299,37,315,-5,323,-5,344,61,361,111,377,158,397,212,425,286,430,299,436,308,443,314,453,318,466,321,352,0,352,9,338,12,327,16,317,22,307,32,296,46,200,184,272,272,289,292,303,305,316,314,331,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,263,301,260,296,257,290,251,282,243,272,188,202,166,234,151,255,139,272,131,286,126,297,124,306,125,312,128,316,133,319,139,320,147,321,161,321,161,331,11,331,11,321,29,319,44,312,59,299,78,276,103,242,156,164,78,66,58,42,43,26,31,17,19,12,5,9,5,0,121,0,121,9,106,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,100,57,109,70,169,145,217,74,226,60,233,48, +16,320,27,314,124,331,124,331,27,314,36,303,124,331,36,303,96,316,96,316,36,303,45,286,96,316,45,286,55,262,55,262,73,210,93,311,93,311,73,210,93,306,93,302,93,306,92,157,93,302,92,157,112,103,111,321,124,321,124,331,111,321,124,331,102,319,102,319,124,331,96,316,93,306,73,210,92,157,96,316,55,262,93,311,2,331,2,321,16,320,2,331,16,320,124,331,251,165,267,123,251,304,251,304,253,310,222,236,222,236,253,310,208,273,199,295,208,273,257,315,199,295,257,315,290,331,290,331,257,315,265,318,290,331,265,318,276,320,276,320,290,321,290,331,251,304,222,236,235,206,251,304,235,206,251,165,257,315,208,273,253,310,290,331,157,331,171,320,290,331,171,320,182,317,290,331,182,317,191,309,290,331,191,309,199,295,394,262,361,111,377,158,394,262,377,158,397,212,394,262,331,93,344,61,394,262,344,61,361,111,331,93,259,275,267,123,331,93,267,123,283,80,331,93,283,80,299,37,331,93,299,37,315,-5,331,93,315,-5,323,-5,331,93,323,-5,344,61,267,123,259,275,257,282,267,123,257,282,255,289,267,123,255,289,253,295,267,123,253,295,252,300,267,123,252,300,251,304,402,294,401,287,425,286,425,286,401,287,399,280,425,286,399,280,397,212,397,212,399,280,397,271,397,212,397,271,394,262,402,301,425,286,430,299,402,301,430,299,436,308,402,301,436,308,443,314,402,301,443,314,466,331,402,301,466,331,401,308,402,294,425,286,402,301,453,318,466,321,466,331,453,318,466,331,443,314,466,331,368,331,381,320,466,331,381,320,391,318,466,331,391,318,397,314,466,331,397,314,401,308,170,94,98,282,112,103,170,94,112,103,132,49,170,94,132,49,151,-5,170,94,151,-5,158,-5,170,94,158,-5,235,206,170,94,235,206,222,236,112,103,98,282,96,288,112,103,96,288,95,293,112,103,95,293,93,298,112,103,93,298,93,302,381,320,368,331,368,321,171,320,157,331,157,321, +352,0,352,9,338,12,327,16,317,22,307,32,296,46,200,184,272,272,289,292,303,305,316,314,331,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,263,301,260,296,257,290,251,282,243,272,188,202,166,234,151,255,139,272,131,286,126,297,124,306,125,312,128,316,133,319,139,320,147,321,161,321,161,331,11,331,11,321,29,319,44,312,59,299,78,276,103,242,156,164,78,66,58,42,43,26,31,17,19,12,5,9,5,0,121,0,121,9,106,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,100,57,109,70,169,145,217,74,226,60,233,48,238,38,241,31,242,25,241,20,238,16,233,14,226,12,217,11,204,9,204,0,352,331,243,331,243,321,256,321,266,319,272,316,275,312,276,306,276,302,274,294,272,290,270,285,197,174,124,285,121,289,118,294,116,299,115,304,115,308,116,312,119,316,123,318,130,320,138,321,151,321,151,331,11,331,11,321,24,319,37,313,50,299,68,277,92,243,157,147,157,61,156,39,152,25,144,16,129,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,151,282,266,297,288,310,303,322,313,336,319,352,321,299,88,287,88,282,72,278,59,273,49,266,40,257,33,249,28,240,24,228,21,215,20,199,19,73,19,289,324,289,331,26,331,16,246,29,246,32,260,35,271,38,279,43,287,50,295,58,301,68,306,81,309,97,311, +31,17,121,0,43,26,43,26,121,0,88,17,43,26,88,17,58,42,58,42,88,17,84,21,58,42,84,21,83,26,83,26,84,31,78,66,78,66,84,31,87,38,78,66,87,38,156,164,156,164,87,38,92,46,156,164,92,46,100,57,103,242,156,164,126,297,103,242,126,297,124,306,124,306,125,312,103,242,156,164,100,57,109,70,109,70,169,145,156,164,156,164,169,145,166,234,156,164,166,234,151,255,78,66,58,42,83,26,103,242,125,312,78,276,78,276,125,312,128,316,78,276,128,316,59,299,59,299,128,316,133,319,59,299,133,319,161,331,161,331,133,319,139,320,161,331,139,320,147,321,147,321,161,321,161,331,161,331,11,331,29,319,161,331,29,319,44,312,161,331,44,312,59,299,260,296,257,290,272,272,272,272,257,290,251,282,272,272,251,282,243,272,243,272,188,202,200,184,200,184,188,202,217,74,200,184,217,74,296,46,296,46,217,74,226,60,296,46,226,60,233,48,348,331,229,331,243,320,348,331,243,320,253,319,348,331,253,319,259,316,348,331,259,316,262,311,348,331,262,311,263,305,348,331,263,305,316,314,348,331,316,314,331,319,348,331,331,319,348,321,263,305,272,272,289,292,263,305,289,292,303,305,263,305,303,305,316,314,263,301,260,296,272,272,263,301,272,272,263,305,243,272,200,184,272,272,238,16,233,14,352,0,352,0,233,14,226,12,352,0,226,12,217,11,242,25,352,0,327,16,242,25,327,16,317,22,242,25,317,22,307,32,242,25,307,32,296,46,242,25,296,46,241,31,296,46,233,48,238,38,296,46,238,38,241,31,188,202,166,234,169,145,188,202,169,145,217,74,338,12,327,16,352,0,338,12,352,0,352,9,241,20,238,16,352,0,241,20,352,0,242,25,204,9,204,0,352,0,204,9,352,0,217,11,156,164,151,255,139,272,156,164,139,272,131,286,156,164,131,286,126,297,121,0,121,9,106,11,121,0,106,11,95,13,121,0,95,13,88,17,19,12,5,9,121,0,19,12,121,0,31,17,121,0,5,9,5,0,243,320,229,331,229,321,29,319,11,331,11,321, +352,331,243,331,243,321,256,321,266,319,272,316,275,312,276,306,276,302,274,294,272,290,270,285,197,174,124,285,121,289,118,294,116,299,115,304,115,308,116,312,119,316,123,318,130,320,138,321,151,321,151,331,11,331,11,321,24,319,37,313,50,299,68,277,92,243,157,147,157,61,156,39,152,25,144,16,129,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,151,282,266,297,288,310,303,322,313,336,319,352,321,299,88,287,88,282,72,278,59,273,49,266,40,257,33,249,28,240,24,228,21,215,20,199,19,73,19,289,324,289,331,26,331,16,246,29,246,32,260,35,271,38,279,43,287,50,295,58,301,68,306,81,309,97,311,117,312,224,312,5,7,5,0,286,0,150,-77,150,-64,108,-64,99,-63,92,-61,86,-56,83,-48,82,-38,82,295,83,304,86,311,92,315,99,318,108,319,150,319,150,331,44,331,44,-77,143,-6,29,338,-3,338,109,-6,123,-77, +121,289,118,294,157,147,157,147,118,294,116,299,157,147,116,299,92,243,92,243,116,299,115,304,92,243,115,304,115,308,115,308,116,312,92,243,151,331,11,331,24,319,151,331,24,319,37,313,151,331,37,313,50,299,151,331,50,299,123,318,151,331,123,318,130,320,151,331,130,320,138,321,151,331,138,321,151,321,123,318,50,299,119,316,119,316,50,299,68,277,119,316,68,277,116,312,116,312,68,277,92,243,209,55,209,151,197,174,209,55,197,174,210,36,210,36,197,174,157,147,210,36,157,147,215,23,215,23,157,147,157,61,215,23,157,61,224,15,224,15,157,61,156,39,224,15,156,39,260,0,260,0,156,39,152,25,260,0,152,25,144,16,275,298,274,294,282,266,282,266,274,294,272,290,282,266,272,290,270,285,270,285,197,174,209,151,352,331,243,331,256,321,352,331,256,321,266,319,352,331,266,319,272,316,352,331,272,316,275,312,352,331,275,312,276,306,352,331,276,306,322,313,352,331,322,313,336,319,352,331,336,319,352,321,276,306,282,266,297,288,276,306,297,288,310,303,276,306,310,303,322,313,282,266,276,306,276,302,282,266,276,302,275,298,270,285,209,151,282,266,239,11,224,15,260,0,239,11,260,0,260,9,129,12,107,9,260,0,129,12,260,0,144,16,124,285,121,289,157,147,124,285,157,147,197,174,260,0,107,9,107,0,256,321,243,331,243,321,24,319,11,331,11,321, +299,88,287,88,282,72,278,59,273,49,266,40,257,33,249,28,240,24,228,21,215,20,199,19,73,19,289,324,289,331,26,331,16,246,29,246,32,260,35,271,38,279,43,287,50,295,58,301,68,306,81,309,97,311,117,312,224,312,5,7,5,0,286,0,150,-77,150,-64,108,-64,99,-63,92,-61,86,-56,83,-48,82,-38,82,295,83,304,86,311,92,315,99,318,108,319,150,319,150,331,44,331,44,-77,143,-6,29,338,-3,338,109,-6,123,-77,123,331,17,331,17,319,59,319,69,318,76,314,81,309,83,301,84,291, +35,271,38,279,26,331,26,331,38,279,43,287,26,331,43,287,50,295,50,295,58,301,26,331,26,331,58,301,68,306,26,331,68,306,81,309,73,19,289,324,224,312,224,312,289,324,289,331,224,312,289,331,117,312,97,311,117,312,289,331,97,311,289,331,26,331,26,331,16,246,29,246,26,331,29,246,32,260,26,331,32,260,35,271,224,312,5,7,73,19,73,19,5,7,286,0,73,19,286,0,199,19,199,19,286,0,215,20,278,59,273,49,286,0,286,0,273,49,266,40,286,0,266,40,257,33,257,33,249,28,286,0,286,0,249,28,240,24,286,0,240,24,228,21,286,0,299,88,287,88,286,0,287,88,282,72,286,0,282,72,278,59,286,0,5,7,5,0,215,20,286,0,228,21,26,331,81,309,97,311, +150,-77,150,-64,108,-64,99,-63,92,-61,86,-56,83,-48,82,-38,82,295,83,304,86,311,92,315,99,318,108,319,150,319,150,331,44,331,44,-77,143,-6,29,338,-3,338,109,-6,123,-77,123,331,17,331,17,319,59,319,69,318,76,314,81,309,83,301,84,291,84,-50,81,-56,77,-61,70,-63, +86,311,92,315,44,331,44,331,92,315,99,318,44,331,99,318,150,331,150,331,99,318,108,319,82,-38,82,295,44,331,82,-38,44,331,44,-77,82,-38,44,-77,83,-48,83,304,86,311,44,331,83,304,44,331,82,295,150,-64,108,-64,150,-77,150,-77,108,-64,99,-63,150,-77,99,-63,44,-77,44,-77,99,-63,92,-61,44,-77,92,-61,86,-56,83,-48,44,-77,86,-56,150,331,108,319,150,319, +143,-6,29,338,-3,338,109,-6,123,-77,123,331,17,331,17,319, +143,-6,29,338,-3,338,143,-6,-3,338,109,-6, +123,-77,123,331,17,331,17,319,59,319,69,318,76,314,81,309,83,301,84,291,84,-50,81,-56,77,-61,70,-63,61,-64,17,-64,17,-77,223,148,132,331,103,331,12,148,46,148,118,293,189,148,250,-62,250,-36,0,-36,0,-62,121,253,49,328,44,332,40,335,35,337,27,339, +123,-77,123,331,84,291,123,-77,84,291,84,-41,123,-77,84,-41,84,-50,123,-77,84,-50,81,-56,123,-77,81,-56,77,-61,123,-77,77,-61,70,-63,123,-77,70,-63,61,-64,123,-77,61,-64,17,-64,123,-77,17,-64,17,-77,76,314,81,309,123,331,123,331,81,309,83,301,123,331,83,301,84,291,123,331,17,331,59,319,123,331,59,319,69,318,123,331,69,318,76,314,59,319,17,331,17,319, +223,148,132,331,103,331,12,148,46,148,118,293,189,148,250,-62,250,-36,0,-36,0,-62,121,253,49,328,44,332, +12,148,46,148,103,331,103,331,46,148,118,293,103,331,118,293,132,331,132,331,118,293,189,148,132,331,189,148,223,148, +250,-62,250,-36,0,-36,0,-62,121,253,49,328,44,332,40,335, +250,-62,250,-36,0,-36,250,-62,0,-36,0,-62, +121,253,49,328,44,332,40,335,35,337,27,339,21,338,16,336,12,333,10,329,9,323,10,318,12,314,15,309,19,305,24,301,101,253,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226, +101,253,121,253,49,328,101,253,49,328,44,332,101,253,44,332,40,335,101,253,40,335,35,337,101,253,35,337,31,338,101,253,31,338,27,339,101,253,27,339,24,301,9,323,10,318,10,329,10,329,10,318,12,314,10,329,12,314,12,333,12,333,12,314,15,309,12,333,15,309,16,336,16,336,15,309,19,305,16,336,19,305,21,338,21,338,19,305,24,301,21,338,24,301,27,339, +221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,76,340,74,342,62,338,51,334,41,331,29,328,17,324,2,320,2,311,5,311,6,312,10,312,21,311,28,309,32,304,34,296,35,283,35,28,39,18,52,9,71,2,93,-2,117,-4,155,1,187,18,212,44,228,78,234,120,230,155,218,185,199,209,174,224,144,230,126,228,110,223,96,214,85,202,76,188,16383,16383,76,159,79,171,86,182,97,191,111,197,126,199,137,198,146,195,155,190,164,183,171,175,177,163,183,149,186,133,189,116,190,99,189,82,187,67,183,54,178,42,171,32,164,25,156,19,147,15,136,12,125,11,110,12,97,16,86,21,79,28,76,37,199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161,195,166,198,172,199,179,195,195,184,209,167,220,146,227,122,230,108,229,94,226,80,221,67,213,55,204, +37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,184,56,186,-3,185,44,29,167,29,183,28,175, +76,340,74,342,62,338,51,334,41,331,29,328,17,324,2,320,2,311,5,311,6,312,10,312,21,311,28,309,32,304,34,296,35,283,35,28,39,18,52,9,71,2,93,-2,117,-4,155,1,187,18,212,44,228,78,234,120,230,155,218,185,199,209,174,224,144,230,126,228,110,223,96,214,85,202,76,188,16383,16383,76,159,79,171,86,182,97,191,111,197,126,199,137,198,146,195,155,190,164,183,171,175,177,163,183,149,186,133,189,116,190,99,189,82,187,67,183,54,178,42,171,32,164,25,156,19,147,15,136,12,125,11,110,12,97,16,86,21,79,28,76,37,199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161,195,166,198,172,199,179,195,195,184,209,167,220,146,227,122,230,108,229,94,226,80,221,67,213,55,204,40,189,28,172,19,152,14,130,12,106,17,70,30,39,50,15,76,0,108,-4,120,-3,132,-1,144,3,155,9,165,16,174,24,181,32,189,43,197,57,206,74,246,21,246,29,239,29,237,28,234,28,225,29,218,32,215,37, +5,311,6,312,17,324,17,324,6,312,8,312,17,324,8,312,10,312,10,312,21,311,17,324,17,324,21,311,29,328,97,16,86,21,93,-2,93,-2,86,21,79,28,93,-2,79,28,71,2,71,2,79,28,76,37,71,2,76,37,74,342,74,342,76,37,76,188,74,342,76,188,76,340,62,338,51,334,52,9,52,9,51,334,41,331,52,9,41,331,39,18,39,18,41,331,35,283,39,18,35,283,35,28,3,311,5,311,17,324,3,311,17,324,2,320,3,311,2,320,2,311,156,19,147,15,155,1,155,1,147,15,136,12,155,1,136,12,125,11,125,11,110,12,117,-4,117,-4,110,12,97,16,117,-4,97,16,93,-2,62,338,52,9,71,2,62,338,71,2,74,342,21,311,28,309,29,328,29,328,28,309,32,304,29,328,32,304,41,331,41,331,32,304,34,296,41,331,34,296,35,283,126,228,126,199,137,198,126,228,137,198,144,230,144,230,137,198,146,195,144,230,146,195,174,224,174,224,146,195,155,190,174,224,155,190,164,183,76,159,79,171,85,202,85,202,79,171,86,182,85,202,86,182,96,214,96,214,86,182,97,191,96,214,97,191,110,223,110,223,97,191,111,197,110,223,111,197,126,228,126,228,111,197,126,199,76,159,85,202,76,188,76,159,76,188,76,37,174,224,171,175,177,163,174,224,177,163,199,209,199,209,177,163,183,149,199,209,183,149,186,133,187,67,183,54,187,18,187,18,183,54,178,42,187,18,178,42,171,32,171,32,164,25,187,18,187,18,164,25,156,19,187,18,156,19,155,1,234,120,230,155,228,78,228,78,230,155,218,185,228,78,218,185,212,44,212,44,218,185,199,209,212,44,199,209,190,99,190,99,199,209,189,116,187,67,187,18,189,82,189,82,187,18,212,44,189,82,212,44,190,99,125,11,117,-4,155,1,199,209,186,133,189,116,174,224,164,183,171,175, +199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161,195,166,198,172,199,179,195,195,184,209,167,220,146,227,122,230,108,229,94,226,80,221,67,213,55,204,40,189,28,172,19,152,14,130,12,106,17,70,30,39,50,15,76,0,108,-4,120,-3,132,-1,144,3,155,9,165,16,174,24,181,32,189,43,197,57,206,74,246,21,246,29,239,29,237,28,234,28,225,29,218,32,215,37,213,45,212,57,212,340,209,342,195,337,169,329,154,324,136,320,136,311,138,312,147,312,156,311,163,309,167,304,170,297,170,209,159,217,149,223,139,227,129,229,118,230,85,223,56,206,34,178,19,143,13,103,18,67,30,37,49,14,75,0,106,-4,122,-3,136,0,148,7,160,16,170,28,170,-2,172,-4,16383,16383,170,51,170,49,169,46,165,40,162,37,157,31,150,27,143,24,135,22,126,21,102,26,83,39,69,60,60,88,56,123, +81,49,65,69,76,0,76,0,65,69,54,96,76,0,54,96,50,15,50,15,54,96,51,128,55,204,51,128,54,157,55,204,54,157,63,181,128,31,108,-4,120,-3,128,31,120,-3,132,-1,128,31,103,36,108,-4,81,49,76,0,108,-4,81,49,108,-4,103,36,136,212,141,208,146,227,146,227,141,208,145,201,146,227,145,201,148,191,148,191,151,180,167,220,167,220,151,180,154,172,167,220,154,172,159,166,122,230,119,215,128,215,122,230,128,215,146,227,146,227,128,215,136,212,195,195,184,209,189,161,195,195,189,161,195,166,195,195,195,166,198,172,195,195,198,172,199,179,184,209,167,220,169,158,184,209,169,158,175,157,184,209,175,157,183,158,184,209,183,158,189,161,167,220,159,166,163,161,167,220,163,161,169,158,167,220,146,227,148,191,174,24,181,32,185,60,185,60,181,32,189,43,185,60,189,43,199,78,199,78,189,43,197,57,199,78,197,57,206,74,132,-1,144,3,144,33,144,33,144,3,155,9,144,33,155,9,159,38,159,38,155,9,165,16,159,38,165,16,172,46,172,46,165,16,174,24,172,46,174,24,185,60,144,33,128,31,132,-1,96,211,119,215,108,229,96,211,108,229,94,226,96,211,94,226,80,221,96,211,80,221,78,200,67,213,55,204,63,181,67,213,63,181,78,200,67,213,78,200,80,221,40,189,28,172,30,39,40,189,30,39,50,15,40,189,50,15,51,128,40,189,51,128,55,204,19,152,14,130,17,70,19,152,17,70,30,39,19,152,30,39,28,172,119,215,122,230,108,229,17,70,14,130,12,106, +246,21,246,29,239,29,237,28,234,28,225,29,218,32,215,37,213,45,212,57,212,340,209,342,195,337,169,329,154,324,136,320,136,311,138,312,147,312,156,311,163,309,167,304,170,297,170,209,159,217,149,223,139,227,129,229,118,230,85,223,56,206,34,178,19,143,13,103,18,67,30,37,49,14,75,0,106,-4,122,-3,136,0,148,7,160,16,170,28,170,-2,172,-4,16383,16383,170,51,170,49,169,46,165,40,162,37,157,31,150,27,143,24,135,22,126,21,102,26,83,39,69,60,60,88,56,123,59,154,67,180,80,199,98,212,119,216,135,213,149,206,160,195,167,181,170,166,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,11,225,11,209,51,209,51,52,50,34,47,21,40,13,28,9,10,7,10,0,140,0,140,7,119,9,106,13,98,21,95,33,94,52,94,209,155,209, +170,209,159,217,160,195,160,195,159,217,149,223,160,195,149,223,149,206,149,206,149,223,139,227,149,206,139,227,135,213,135,213,139,227,129,229,135,213,129,229,119,216,67,180,80,199,85,223,85,223,80,199,98,212,85,223,98,212,118,230,118,230,98,212,119,216,118,230,119,216,129,229,13,103,18,67,19,143,19,143,18,67,30,37,19,143,30,37,34,178,34,178,30,37,49,14,34,178,49,14,56,206,56,206,49,14,56,123,56,206,56,123,59,154,56,206,59,154,67,180,56,206,67,180,85,223,126,21,106,-4,122,-3,126,21,122,-3,136,0,126,21,102,26,106,-4,83,39,69,60,75,0,83,39,75,0,106,-4,83,39,106,-4,102,26,60,88,56,123,49,14,60,88,49,14,75,0,60,88,75,0,69,60,169,46,167,43,170,28,170,28,167,43,165,40,170,28,165,40,162,37,162,37,157,31,160,16,160,16,157,31,150,27,160,16,150,27,148,7,148,7,150,27,143,24,148,7,143,24,136,0,136,0,143,24,135,22,136,0,135,22,126,21,140,312,142,312,154,324,154,324,142,312,145,312,154,324,145,312,147,312,147,312,156,311,154,324,154,324,156,311,169,329,154,324,136,320,138,312,154,324,138,312,140,312,170,209,170,166,170,28,170,209,170,28,170,286,170,297,170,286,182,333,170,297,182,333,169,329,170,209,160,195,167,181,170,209,167,181,170,166,172,-4,246,21,225,29,172,-4,225,29,218,32,172,-4,218,32,215,37,172,-4,215,37,213,45,172,-4,213,45,182,333,172,-4,182,333,170,28,172,-4,170,28,170,-2,170,28,170,166,170,51,170,28,170,51,170,49,170,28,170,49,169,46,162,37,160,16,170,28,212,57,212,340,209,342,212,57,209,342,195,337,212,57,195,337,213,45,239,29,237,28,246,21,246,21,237,28,235,28,246,21,235,28,234,28,234,28,225,29,246,21,241,29,239,29,246,21,241,29,246,21,246,29,169,329,156,311,163,309,169,329,163,309,167,304,169,329,167,304,170,297,138,312,136,320,136,311,182,333,170,286,170,28,182,333,213,45,195,337, +204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,11,225,11,209,51,209,51,52,50,34,47,21,40,13,28,9,10,7,10,0,140,0,140,7,119,9,106,13,98,21,95,33,94,52,94,209,155,209,155,225,94,225,94,283,95,299,98,311,104,320,111,326,122,328,128,327,133,325,138,321,143,316,148,308,153,301,157,296,161,293,166,291,171,290,177,291,183,294,188,298,190,304,191,310,189,321,182,329,171,336,156,340,140,342,121,340,105,335,90,328,78,318,69,305,62,292, +52,100,50,118,49,15,49,15,50,118,49,138,49,15,49,138,31,182,49,15,31,182,29,39,29,39,31,182,17,148,29,39,17,148,17,70,17,70,17,148,12,108,133,228,116,230,120,210,120,210,116,230,103,212,87,210,103,212,116,230,87,210,116,230,81,224,190,62,176,48,181,26,181,26,176,48,162,37,181,26,162,37,160,9,160,9,162,37,146,31,160,9,146,31,136,-1,136,-1,146,31,127,30,203,138,201,153,198,166,203,138,198,166,195,177,203,138,195,177,190,186,203,138,190,186,185,195,203,138,185,195,175,207,203,138,175,207,163,217,203,138,163,217,151,155,203,138,151,155,50,155,203,138,50,155,49,138,141,192,147,176,149,224,149,224,147,176,151,155,149,224,151,155,163,217,198,49,212,79,204,82,198,49,204,82,190,62,198,49,190,62,181,26,114,31,101,34,108,-4,114,31,108,-4,136,-1,114,31,136,-1,127,30,101,34,90,39,108,-4,108,-4,90,39,80,47,108,-4,80,47,75,0,75,0,80,47,71,57,133,228,120,210,133,203,133,228,133,203,141,192,133,228,141,192,149,224,50,155,55,175,52,207,52,207,55,175,63,191,52,207,63,191,81,224,81,224,63,191,74,203,81,224,74,203,87,210,52,207,31,182,49,138,52,207,49,138,50,155,75,0,71,57,62,71,75,0,62,71,56,85,75,0,56,85,52,100,75,0,52,100,49,15, +11,225,11,209,51,209,51,52,50,34,47,21,40,13,28,9,10,7,10,0,140,0,140,7,119,9,106,13,98,21,95,33,94,52,94,209,155,209,155,225,94,225,94,283,95,299,98,311,104,320,111,326,122,328,128,327,133,325,138,321,143,316,148,308,153,301,157,296,161,293,166,291,171,290,177,291,183,294,188,298,190,304,191,310,189,321,182,329,171,336,156,340,140,342,121,340,105,335,90,328,78,318,69,305,62,292,57,279,54,264,52,247,51,225,235,194,235,214,185,214,180,215,175,217,169,219,158,223,134,229,126,230,118,230,91,226,68,214,51,197,39,174,35,148,36,131,41,116,50,103,63,92,81,81,77,77,72,73,60,61,51,53,44,46,40,39,37,33,36,27,37,21,40,16,44,11,52,6,63,1,44,-13,30,-26,21,-37,16,-48,14,-59,18,-75,31,-88,49,-98,73,-105,100,-108,122,-106,144,-102,165,-96,184,-87,200,-76,211,-66,220,-56,226,-46,229,-35,230,-24,228,-6,220,7,207,18,190,26, +57,279,54,264,95,33,95,33,54,264,52,247,95,33,52,247,51,209,51,209,52,247,51,225,51,209,51,225,11,225,78,318,95,33,94,52,94,225,94,209,155,209,94,225,155,209,155,225,133,325,140,342,128,327,128,327,140,342,122,328,111,326,122,328,121,340,111,326,121,340,105,335,94,283,95,299,90,328,90,328,95,299,98,311,90,328,98,311,105,335,105,335,98,311,104,320,105,335,104,320,111,326,90,328,78,318,94,52,90,328,94,52,94,283,189,321,182,329,183,294,189,321,183,294,188,298,189,321,188,298,190,304,189,321,190,304,191,310,166,291,171,290,171,336,171,336,171,290,177,291,171,336,177,291,182,329,182,329,177,291,183,294,148,308,153,301,156,340,156,340,153,301,157,296,156,340,157,296,171,336,171,336,157,296,161,293,171,336,161,293,166,291,143,316,148,308,156,340,143,316,156,340,140,342,143,316,140,342,138,321,140,342,121,340,122,328,140,0,140,7,119,9,140,0,119,9,106,13,140,0,106,13,50,34,140,0,50,34,47,21,140,0,47,21,40,13,140,0,40,13,28,9,140,0,28,9,10,7,140,0,10,7,10,0,95,33,78,318,69,305,95,33,69,305,62,292,95,33,62,292,57,279,51,52,50,34,106,13,51,52,106,13,98,21,51,52,98,21,95,33,51,52,95,33,51,209,51,209,11,225,11,209,140,342,133,325,138,321, +235,194,235,214,185,214,180,215,175,217,169,219,158,223,134,229,126,230,118,230,91,226,68,214,51,197,39,174,35,148,36,131,41,116,50,103,63,92,81,81,77,77,72,73,60,61,51,53,44,46,40,39,37,33,36,27,37,21,40,16,44,11,52,6,63,1,44,-13,30,-26,21,-37,16,-48,14,-59,18,-75,31,-88,49,-98,73,-105,100,-108,122,-106,144,-102,165,-96,184,-87,200,-76,211,-66,220,-56,226,-46,229,-35,230,-24,228,-6,220,7,207,18,190,26,170,29,105,32,91,33,80,35,72,38,68,41,66,46,68,52,73,60,80,67,88,73,97,77,106,76,111,75,125,75,136,76,146,78,157,82,167,87,177,94,186,103,194,113,199,124,202,137,203,152,203,160,202,168,200,176,194,194,16383,16383,76,169,78,185,82,198,90,208,100,214,113,216,122,215,130,212,137,207,144,201,150,193,155,181,159,169,162,157,164,145,165,132,163,117,158,104,150,95,140,89,127,87,110,91,96,102,85,118,78,141,76,167,16383,16383,217,-31,212,-47,200,-60,180,-71,153,-77,122,-79,97,-78,77,-73,62,-65,52,-55,49,-43,50,-36,52,-30,56,-22,63,-13,74,0,86,-2,102,-4,138,-6,155,-6,178,-7,196,-10,208,-14,214,-21,217,-31,243,0,243,7,230,10,221,15,216,22,214,34,214,151,211,179,204,201,191,217,174,227,152,230,135,228,120,224,106,216,92,204,79,188,79,340,76,342,66,338,46,332,34,328,18,324,5,320,5,311,6,312,11,312,22,311,29,309,34,305,36,297,36,33,33,22,28,15,19,10,4,7,4,0,113,0,113,7,98,10,88,14,82,22,79,34,79,171,90,184,101,193,112,199,123,202,134,203,148,201,158,195,165,184,170,169,171,150,171,34,168,22,162,14,152,10,137,7,137,0,90,316,89,324,85,331,80,337,73,340,65,342,56,340,49,336,44,331,40,324,39,316,40,308,44,301,49,295,56,292,64,291,73,292,80,295,85,301,89,308,90,316,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,88,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7,8,0,97,316,96,324,92,331,86,337,79,340,71,342,63,340,56,336,51,331,47,324,46,316,47,308,51,301,56,295,63,292,71,291,79,292,87,295,92,301,96,308,97,316,16383,16383,97,228,94,230,77,224,62,218,48,213,33,208,16,203,16,195,18,195,23,196,27,197,39,197, +85,118,81,81,88,73,88,73,81,81,80,67,80,67,81,81,77,77,80,67,77,77,73,60,73,60,77,77,72,73,73,60,72,73,68,52,68,52,72,73,68,69,68,52,68,69,66,46,66,46,64,65,63,-13,63,-13,64,65,63,1,116,75,127,87,111,75,111,75,127,87,110,91,111,75,110,91,106,76,106,76,110,91,97,77,88,73,97,77,96,102,88,73,96,102,85,118,118,230,113,216,122,215,118,230,122,215,126,230,126,230,122,215,130,212,126,230,130,212,134,229,134,229,130,212,137,207,134,229,137,207,142,227,142,227,137,207,144,201,142,227,144,201,150,225,150,225,144,201,150,193,127,87,116,75,120,75,127,87,120,75,123,75,127,87,123,75,125,75,127,87,125,75,136,76,110,91,96,102,97,77,169,219,158,223,159,169,169,219,159,169,162,157,169,219,162,157,164,145,169,219,164,145,165,132,169,219,165,132,167,87,169,219,167,87,177,94,169,219,177,94,175,217,167,87,165,132,163,117,167,87,163,117,158,104,167,87,158,104,157,82,127,87,136,76,140,89,140,89,136,76,146,78,140,89,146,78,150,95,150,95,146,78,157,82,150,95,157,82,158,104,82,198,90,208,91,226,91,226,90,208,100,214,91,226,100,214,118,230,118,230,100,214,113,216,76,167,76,169,68,214,68,214,76,169,78,185,68,214,78,185,91,226,91,226,78,185,82,198,81,81,85,118,78,141,81,81,78,141,76,167,81,81,76,167,68,214,81,81,68,214,63,92,51,197,39,174,41,116,51,197,41,116,50,103,51,197,50,103,63,92,51,197,63,92,68,214,39,174,35,148,36,131,39,174,36,131,41,116,51,53,44,46,44,11,51,53,44,11,52,6,51,53,52,6,60,61,36,27,37,21,37,33,37,33,37,21,40,16,37,33,40,16,40,39,40,39,40,16,44,11,40,39,44,11,44,46,30,-26,31,-88,44,-13,44,-13,31,-88,49,-98,44,-13,49,-98,49,-43,49,-43,50,-36,44,-13,44,-13,50,-36,52,-30,44,-13,52,-30,63,1,63,1,52,-30,56,-22,63,1,56,-22,63,-13,74,0,72,38,68,41,74,0,68,41,66,46,74,0,66,46,63,-13,74,0,80,35,72,38,60,61,52,6,63,1,60,61,63,1,64,65,62,-65,73,-105,77,-73,77,-73,73,-105,100,-108,77,-73,100,-108,97,-78,97,-78,100,-108,122,-79,153,-77,122,-79,122,-106,153,-77,122,-106,144,-102,52,-55,49,-43,49,-98,52,-55,49,-98,73,-105,52,-55,73,-105,62,-65,21,-37,16,-48,18,-75,21,-37,18,-75,31,-88,21,-37,31,-88,30,-26,196,214,191,214,194,194,196,214,194,194,235,194,196,214,235,194,235,214,202,137,203,152,203,160,202,137,203,160,202,168,202,137,202,168,200,176,202,137,200,176,199,124,197,185,194,194,194,113,197,185,194,113,199,124,197,185,199,124,200,176,191,214,185,214,186,103,191,214,186,103,194,113,191,214,194,113,194,194,180,215,175,217,177,94,180,215,177,94,186,103,180,215,186,103,185,214,155,181,159,169,158,223,155,181,158,223,150,225,155,181,150,225,150,193,208,-14,214,-21,220,7,220,7,214,-21,217,-31,220,-56,217,-31,212,-47,138,-6,155,-6,170,29,170,29,155,-6,178,-7,170,29,178,-7,190,26,190,26,178,-7,196,-10,190,26,196,-10,207,18,207,18,196,-10,208,-14,207,18,208,-14,220,7,228,-6,220,7,220,-56,228,-6,220,-56,226,-46,228,-6,226,-46,229,-35,228,-6,229,-35,230,-24,153,-77,165,-96,180,-71,180,-71,165,-96,184,-87,180,-71,184,-87,200,-60,200,-60,184,-87,200,-76,200,-60,200,-76,212,-47,212,-47,200,-76,211,-66,212,-47,211,-66,220,-56,138,-6,170,29,120,-5,120,-5,170,29,105,32,120,-5,105,32,102,-4,102,-4,105,32,91,33,102,-4,91,33,86,-2,86,-2,91,33,80,35,86,-2,80,35,74,0,122,-79,100,-108,122,-106,153,-77,144,-102,165,-96,217,-31,220,-56,220,7,18,-75,16,-48,14,-59,64,65,66,46,68,69, +243,0,243,7,230,10,221,15,216,22,214,34,214,151,211,179,204,201,191,217,174,227,152,230,135,228,120,224,106,216,92,204,79,188,79,340,76,342,66,338,46,332,34,328,18,324,5,320,5,311,6,312,11,312,22,311,29,309,34,305,36,297,36,33,33,22,28,15,19,10,4,7,4,0,113,0,113,7,98,10,88,14,82,22,79,34,79,171,90,184,101,193,112,199,123,202,134,203,148,201,158,195,165,184,170,169,171,150,171,34,168,22,162,14,152,10,137,7,137,0,90,316,89,324,85,331,80,337,73,340,65,342,56,340,49,336,44,331,40,324,39,316,40,308,44,301,49,295,56,292,64,291,73,292,80,295,85,301,89,308,90,316,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,88,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7,8,0,97,316,96,324,92,331,86,337,79,340,71,342,63,340,56,336,51,331,47,324,46,316,47,308,51,301,56,295,63,292, +33,22,28,15,113,0,113,0,28,15,19,10,113,0,19,10,4,7,7,312,9,312,18,324,18,324,9,312,10,312,18,324,10,312,11,312,11,312,22,311,18,324,18,324,22,311,34,328,18,324,5,320,6,312,18,324,6,312,7,312,88,14,82,22,36,51,36,51,82,22,79,34,36,51,79,34,36,286,36,297,36,286,46,332,36,297,46,332,34,328,34,328,22,311,29,309,34,328,29,309,34,305,34,328,34,305,36,297,79,188,79,340,76,342,79,188,76,342,79,51,79,51,76,342,66,338,79,51,66,338,79,34,79,34,66,338,56,335,79,34,56,335,46,332,135,228,134,203,148,201,135,228,148,201,152,230,152,230,148,201,158,195,152,230,158,195,174,227,174,227,158,195,165,184,174,227,165,184,170,169,79,171,90,184,92,204,92,204,90,184,101,193,92,204,101,193,106,216,106,216,101,193,112,199,106,216,112,199,120,224,120,224,112,199,123,202,120,224,123,202,135,228,135,228,123,202,134,203,79,51,79,171,79,188,79,188,79,171,92,204,168,22,162,14,243,0,243,0,162,14,152,10,243,0,152,10,137,7,174,227,170,169,171,150,216,22,171,150,171,51,216,22,171,51,221,15,221,15,171,51,171,34,221,15,171,34,243,0,243,0,171,34,168,22,214,51,214,151,211,179,214,51,211,179,204,201,214,51,204,201,214,34,230,10,221,15,243,0,230,10,243,0,243,7,171,150,216,22,174,227,174,227,216,22,214,34,174,227,214,34,191,217,191,217,214,34,204,201,113,0,113,7,98,10,113,0,98,10,88,14,113,0,88,14,36,33,113,0,36,33,33,22,113,0,4,7,4,0,36,33,88,14,36,51,36,286,79,34,46,332,243,0,137,7,137,0,6,312,5,320,5,311, +90,316,89,324,85,331,80,337,73,340,65,342,56,340,49,336,44,331,40,324,39,316,40,308,44,301,49,295,56,292,64,291,73,292,80,295,85,301,89,308,90,316,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,88,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7,8,0,97,316,96,324,92,331,86,337,79,340,71,342,63,340,56,336,51,331,47,324,46,316,47,308,51,301,56,295,63,292,71,291,79,292,87,295,92,301,96,308,97,316,16383,16383,97,228,94,230,77,224,62,218,48,213,33,208,16,203,16,195,18,195,23,196,27,197,39,197,45,196,49,193,52,187,54,178,55,167,55,-21,54,-41,54,-56,52,-67,50,-76,47,-82, +39,316,40,308,40,324,40,324,40,308,44,301,40,324,44,301,44,331,44,331,44,301,49,295,44,331,49,295,49,336,49,336,49,295,56,292,49,336,56,292,56,340,56,340,56,292,64,291,56,340,64,291,65,342,65,342,64,291,73,292,65,342,73,292,73,340,73,340,73,292,80,295,73,340,80,295,80,337,80,337,80,295,85,301,80,337,85,301,85,331,85,331,85,301,89,308,85,331,89,308,89,324,89,324,89,308,90,316,43,20,37,13,127,0,127,0,37,13,25,9,127,0,25,9,8,7,20,197,24,197,88,230,88,230,24,197,28,197,88,230,28,197,31,197,31,197,38,196,88,230,88,230,38,196,42,193,88,230,42,193,45,187,43,20,127,0,47,33,47,33,127,0,99,14,47,33,99,14,47,52,47,52,99,14,93,21,47,52,93,21,47,166,47,178,47,166,88,230,47,178,88,230,45,187,15,196,20,197,88,230,15,196,88,230,10,203,15,196,10,203,10,195,89,52,89,228,88,230,89,52,88,230,47,166,89,52,47,166,90,34,110,9,99,14,127,0,110,9,127,0,127,7,127,0,8,7,8,0,47,166,93,21,90,34, +97,316,96,324,92,331,86,337,79,340,71,342,63,340,56,336,51,331,47,324,46,316,47,308,51,301,56,295,63,292,71,291,79,292,87,295,92,301,96,308,97,316,16383,16383,97,228,94,230,77,224,62,218,48,213,33,208,16,203,16,195,18,195,23,196,27,197,39,197,45,196,49,193,52,187,54,178,55,167,55,-21,54,-41,54,-56,52,-67,50,-76,47,-82,45,-85,39,-89,35,-91,26,-91,18,-87,14,-83,4,-71,0,-66,-4,-63,-9,-61,-14,-61,-20,-62,-26,-65,-30,-69,-33,-74,-34,-80,-32,-90,-26,-97,-16,-103,-3,-107,12,-108,42,-103,65,-90,83,-68,93,-38,97,0,252,0,252,7,240,9,228,13,217,20,206,30,194,44,118,141,132,155,164,183,188,201,206,212,222,217,240,218,240,225,138,225,138,218,148,218,155,217,160,215,162,212,163,209,161,203,155,195,151,191,83,131,83,340,81,342,70,338,48,332,35,328,18,324,3,320,3,311,7,312,17,312,20,313,28,312,34,309,38,303,40,294,41,282,41,41,40,28,38,20,32,14,21,11,3,7,3,0,121,0,121,7,110,8,100,9,92,12,87,17,84,24,83,33,83,126,158,26,160,24,162,21,163,19,163,17,164,15,163,13,162,10,153,7,143,7,143,0,128,0,128,7, +86,337,87,295,92,331,92,331,87,295,92,301,92,331,92,301,96,324,96,324,92,301,96,308,96,324,96,308,97,316,46,316,47,308,47,324,47,324,47,308,51,301,47,324,51,301,51,331,51,331,51,301,56,295,51,331,56,295,56,336,56,336,56,295,63,292,56,336,63,292,63,340,63,340,63,292,71,291,63,340,71,291,71,342,71,342,71,291,79,292,71,342,79,292,79,340,79,340,79,292,87,295,79,340,87,295,86,337,18,195,23,196,33,208,18,195,33,208,16,203,18,195,16,203,16,195,42,-87,39,-89,42,-103,42,-103,39,-89,35,-91,42,-103,35,-91,31,-91,31,-91,26,-91,42,-103,42,-103,26,-91,22,-89,42,-103,22,-89,18,-87,52,187,62,218,49,193,49,193,62,218,48,213,49,193,48,213,45,196,45,196,48,213,39,197,35,197,39,197,48,213,35,197,48,213,33,208,54,-56,52,-67,65,-90,65,-90,52,-67,50,-76,65,-90,50,-76,47,-82,47,-82,45,-85,65,-90,65,-90,45,-85,42,-87,65,-90,42,-87,42,-103,93,-38,94,230,83,-68,83,-68,94,230,77,224,83,-68,77,224,65,-90,65,-90,77,224,62,218,65,-90,62,218,55,167,55,167,62,218,54,178,33,208,23,196,27,197,33,208,27,197,32,197,33,208,32,197,35,197,97,0,97,228,94,230,97,0,94,230,93,-38,65,-90,55,167,55,-21,65,-90,55,-21,54,-41,65,-90,54,-41,54,-56,12,-108,42,-103,18,-87,12,-108,18,-87,14,-83,12,-108,14,-83,9,-77,12,-108,9,-77,4,-71,12,-108,4,-71,0,-66,12,-108,0,-66,-3,-107,-3,-107,0,-66,-4,-63,-3,-107,-4,-63,-9,-61,-3,-107,-9,-61,-14,-61,-3,-107,-14,-61,-16,-103,-20,-62,-26,-65,-26,-97,-20,-62,-26,-97,-16,-103,-20,-62,-16,-103,-14,-61,-30,-69,-33,-74,-32,-90,-30,-69,-32,-90,-26,-97,-30,-69,-26,-97,-26,-65,-32,-90,-33,-74,-34,-80,62,218,52,187,54,178, +252,0,252,7,240,9,228,13,217,20,206,30,194,44,118,141,132,155,164,183,188,201,206,212,222,217,240,218,240,225,138,225,138,218,148,218,155,217,160,215,162,212,163,209,161,203,155,195,151,191,83,131,83,340,81,342,70,338,48,332,35,328,18,324,3,320,3,311,7,312,17,312,20,313,28,312,34,309,38,303,40,294,41,282,41,41,40,28,38,20,32,14,21,11,3,7,3,0,121,0,121,7,110,8,100,9,92,12,87,17,84,24,83,33,83,126,158,26,160,24,162,21,163,19,163,17,164,15,163,13,162,10,153,7,143,7,143,0,128,0,128,7,112,9,101,13,95,20,92,29,91,44,91,339,89,342,74,337,59,333,45,329,28,324,9,320,9,311,14,312,25,312,28,313,36,311,42,308,46,302,48,293,49,281,49,46,48,32,45,21,38,14,27,10,11,7,11,0,387,0,387,7,374,8,366,10,360,13,356,19,354,27,353,39,353,140,351,172,344,197,333,215,317,226,295,230,278,228,262,224,246,215,230,204,214,188,207,203,199,215,188,223,176,228,161,230,147,229,133,226,119,220,103,208,84,191,83,191,83,228,79,230,51,220,25,212,9,208,9,199,13,200,16,200,19,201, +38,20,32,14,121,0,121,0,32,14,21,11,121,0,21,11,3,7,10,312,14,312,18,324,18,324,14,312,17,312,18,324,17,312,20,313,20,313,28,312,35,328,35,328,28,312,34,309,35,328,34,309,38,303,7,312,10,312,18,324,7,312,18,324,3,320,7,312,3,320,3,311,194,44,118,141,158,26,158,26,118,141,83,131,158,26,83,131,83,126,84,24,83,33,48,332,84,24,48,332,41,282,41,282,48,332,40,294,48,332,35,328,38,303,48,332,38,303,40,294,35,328,18,324,20,313,83,33,83,340,81,342,83,33,81,342,70,338,83,33,70,338,59,335,83,33,59,335,48,332,151,191,118,141,132,155,151,191,132,155,164,183,151,191,83,131,118,141,161,203,158,199,164,183,164,183,158,199,155,195,164,183,155,195,151,191,240,225,138,225,148,218,240,225,148,218,155,217,240,225,155,217,160,215,240,225,160,215,162,212,240,225,162,212,163,209,240,225,163,209,206,212,240,225,206,212,222,217,240,225,222,217,240,218,163,209,164,183,188,201,163,209,188,201,206,212,164,183,163,209,162,206,164,183,162,206,161,203,162,10,159,9,252,0,252,0,159,9,156,8,252,0,156,8,153,7,164,15,252,0,228,13,164,15,228,13,217,20,164,15,217,20,206,30,164,15,206,30,194,44,164,15,194,44,163,17,194,44,158,26,160,24,194,44,160,24,162,21,194,44,162,21,163,19,194,44,163,19,163,17,240,9,228,13,252,0,240,9,252,0,252,7,163,13,162,10,252,0,163,13,252,0,164,15,143,7,143,0,252,0,143,7,252,0,153,7,121,0,121,7,110,8,121,0,110,8,100,9,121,0,100,9,92,12,121,0,92,12,40,28,121,0,40,28,38,20,92,12,87,17,41,41,41,41,87,17,84,24,41,41,84,24,41,282,121,0,3,7,3,0,40,28,92,12,41,41,148,218,138,225,138,218, +128,0,128,7,112,9,101,13,95,20,92,29,91,44,91,339,89,342,74,337,59,333,45,329,28,324,9,320,9,311,14,312,25,312,28,313,36,311,42,308,46,302,48,293,49,281,49,46,48,32,45,21,38,14,27,10,11,7,11,0,387,0,387,7,374,8,366,10,360,13,356,19,354,27,353,39,353,140,351,172,344,197,333,215,317,226,295,230,278,228,262,224,246,215,230,204,214,188,207,203,199,215,188,223,176,228,161,230,147,229,133,226,119,220,103,208,84,191,83,191, +45,21,38,14,128,0,128,0,38,14,27,10,128,0,27,10,11,7,18,312,22,312,28,324,28,324,22,312,25,312,28,324,25,312,28,313,28,313,36,311,28,324,28,324,36,311,45,329,28,324,9,320,14,312,28,324,14,312,18,312,36,311,42,308,45,329,45,329,42,308,46,302,45,329,46,302,59,333,59,333,46,302,48,293,59,333,48,293,49,281,92,29,49,281,49,46,92,29,49,46,95,20,95,20,49,46,101,13,91,44,91,339,89,342,91,44,89,342,74,337,91,44,74,337,59,333,91,44,59,333,92,29,128,0,128,7,112,9,128,0,112,9,101,13,128,0,101,13,48,32,128,0,48,32,45,21,14,312,9,320,9,311,128,0,11,7,11,0,48,32,101,13,49,46,49,281,92,29,59,333, +387,0,387,7,374,8,366,10,360,13,356,19,354,27,353,39,353,140,351,172,344,197,333,215,317,226,295,230,278,228,262,224,246,215,230,204,214,188,207,203,199,215,188,223,176,228,161,230,147,229,133,226,119,220,103,208,84,191,83,191,83,228,79,230,51,220,25,212,9,208,9,199,13,200,16,200,19,201,26,201,32,200,37,196,41,190,42,181,43,168,43,44,42,29,39,19,32,12,22,9,8,7,8,0,119,0,119,7,105,8,96,11,89,16,86,24,85,35,85,175,99,189,109,195,121,200,133,203,145,204,156,202,165,195,172,183,176,168,177,148,177,43,176,28,173,18,167,12,157,9,143,7,143,0,255,0,255,7,240,9,230,12,223,19,220,31,219,47,219,174,228,185,237,194,248,200,259,203,272,204,287,202,298,196,305,185,310,169,311,148,311,45,310,30,307,20,302,14,293,10,278,7,278,0,243,0,243,7,230,9,221,13,216,19,213,29,212,42,212,153,210,180,202,201,190,217,174,227,153,230,139,229,125,224,111,216,96,205,81,190,80,190,80,228,76,230,50,220,37,216,23,212,8,208,8,199,10,200,13,200,16,201,22,201,30,200,35,197,38,191,40,181,40,47,39,32,37,21,31,14,22,9,9,7,9,0,114,0,114,7,101,9,92,13,86,18,83,26,82,36,82,174,95,186,105,194,115,199,124,202,133,203,147,201,157,195,164,185,169,171,170,152,170,52,169,35,166,23,161,15,152,10,139,7,138,0,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91, +16,200,19,201,25,212,25,212,19,201,22,201,25,212,22,201,26,201,26,201,32,200,38,216,38,216,32,200,37,196,38,216,37,196,41,190,25,212,9,208,13,200,25,212,13,200,16,200,38,216,41,190,51,220,51,220,41,190,42,181,51,220,42,181,43,168,86,24,43,168,43,44,86,24,43,44,89,16,89,16,43,44,96,11,38,216,25,212,26,201,83,228,79,230,83,191,83,191,79,230,85,35,83,191,85,35,84,191,84,191,85,35,85,174,84,191,85,174,85,175,173,18,167,12,255,0,255,0,167,12,157,9,255,0,157,9,143,7,161,230,147,229,156,202,156,202,147,229,145,204,133,203,145,204,133,226,133,203,133,226,121,200,121,200,133,226,119,220,121,200,119,220,109,195,109,195,119,220,103,208,109,195,103,208,99,189,99,189,103,208,92,182,103,208,84,191,85,175,103,208,85,175,86,176,103,208,86,176,88,178,103,208,88,178,90,180,103,208,90,180,92,182,85,35,79,230,65,225,85,35,65,225,86,24,147,229,133,226,145,204,173,18,255,0,176,28,176,28,255,0,230,12,176,28,230,12,177,43,177,43,230,12,223,19,177,43,223,19,177,148,176,228,177,148,188,223,176,228,161,230,165,195,176,228,165,195,172,183,176,228,172,183,176,168,176,228,176,168,177,148,207,203,199,215,220,31,207,203,220,31,219,47,207,203,219,47,214,188,219,174,228,185,230,204,230,204,228,185,237,194,230,204,237,194,246,215,246,215,237,194,248,200,246,215,248,200,262,224,262,224,248,200,259,203,262,224,259,203,272,204,272,204,287,202,278,228,278,228,287,202,295,230,219,47,219,174,214,188,214,188,219,174,230,204,278,228,262,224,272,204,307,20,302,14,387,0,387,0,302,14,293,10,387,0,293,10,278,7,298,196,305,185,317,226,317,226,305,185,310,169,317,226,310,169,311,148,356,19,311,148,311,45,356,19,311,45,360,13,360,13,311,45,310,30,360,13,310,30,366,10,366,10,310,30,387,0,366,10,387,0,374,8,374,8,387,0,387,7,295,230,287,202,298,196,295,230,298,196,317,226,353,39,353,140,351,172,353,39,351,172,344,197,353,39,344,197,333,215,353,39,333,215,354,27,354,27,333,215,317,226,354,27,317,226,311,148,354,27,311,148,356,19,240,9,230,12,255,0,240,9,255,0,255,7,220,31,199,215,188,223,220,31,188,223,177,148,220,31,177,148,223,19,119,0,119,7,105,8,119,0,105,8,96,11,119,0,96,11,42,29,119,0,42,29,39,19,119,0,39,19,32,12,119,0,32,12,22,9,119,0,22,9,8,7,119,0,8,7,8,0,51,220,43,168,86,24,51,220,86,24,65,225,13,200,9,208,9,199,42,29,96,11,43,44,255,0,143,7,143,0,387,0,278,7,278,0,307,20,387,0,310,30,161,230,156,202,165,195, +243,0,243,7,230,9,221,13,216,19,213,29,212,42,212,153,210,180,202,201,190,217,174,227,153,230,139,229,125,224,111,216,96,205,81,190,80,190,80,228,76,230,50,220,37,216,23,212,8,208,8,199,10,200,13,200,16,201,22,201,30,200,35,197,38,191,40,181,40,47,39,32,37,21,31,14,22,9,9,7,9,0,114,0,114,7,101,9,92,13,86,18,83,26,82,36,82,174,95,186,105,194,115,199,124,202,133,203,147,201,157,195,164,185,169,171,170,152,170,52,169,35,166,23,161,15,152,10,139,7,138,0,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,79,229,76,230,62,224,20,209,4,204,4,196,7,197,17,197,26,196,31,194,35,189,37,180,37,-78, +37,21,31,14,114,0,114,0,31,14,22,9,114,0,22,9,9,7,13,200,16,201,23,212,23,212,16,201,19,201,23,212,19,201,22,201,22,201,30,200,23,212,23,212,30,200,37,216,23,212,8,208,10,200,23,212,10,200,13,200,30,200,35,197,37,216,37,216,35,197,38,191,37,216,38,191,50,220,50,220,38,191,40,181,50,220,40,181,40,169,83,26,40,169,40,47,83,26,40,47,86,18,86,18,40,47,92,13,80,228,76,230,80,190,80,190,76,230,82,36,80,190,82,36,81,190,81,190,82,36,82,174,81,190,82,174,96,205,96,205,82,174,95,186,96,205,95,186,105,194,96,205,105,194,111,216,111,216,105,194,115,199,111,216,115,199,125,224,125,224,115,199,124,202,125,224,124,202,133,203,133,203,147,201,139,229,139,229,147,201,153,230,82,36,76,230,63,225,82,36,63,225,83,26,139,229,125,224,133,203,166,23,161,15,243,0,243,0,161,15,152,10,243,0,152,10,139,7,157,195,164,185,174,227,174,227,164,185,169,171,174,227,169,171,170,152,216,19,170,152,170,52,216,19,170,52,221,13,221,13,170,52,169,35,221,13,169,35,243,0,243,0,169,35,166,23,153,230,147,201,157,195,153,230,157,195,174,227,212,42,212,153,210,180,212,42,210,180,202,201,212,42,202,201,213,29,230,9,221,13,243,0,230,9,243,0,243,7,213,29,202,201,190,217,213,29,190,217,174,227,213,29,174,227,170,152,213,29,170,152,216,19,114,0,114,7,101,9,114,0,101,9,92,13,114,0,92,13,39,32,114,0,39,32,37,21,50,220,40,169,83,26,50,220,83,26,63,225,10,200,8,208,8,199,114,0,9,7,9,0,39,32,92,13,40,47,243,0,139,7,138,0, +235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,79,229,76,230,62,224,20,209,4,204,4,196,7,197,17,197,26,196,31,194,35,189,37,180,37,-78,34,-87,27,-93,17,-97,2,-99,2,-107,123,-107,123,-98,104,-97,92,-94,84,-88,80,-77,79,-61,79,17,90,8,99,2,108,-1,118,-3,130,-4,164,1,193,19,215,47,230,82,235,123,231,158,219,188,202,210,179,225,151,230,135,228,120,224,106,216,93,205,79,190,16383,16383,79,167,82,176,91,185,103,193,116,198,131,200, +64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18, +79,229,76,230,62,224,20,209,4,204,4,196,7,197,17,197,26,196,31,194,35,189,37,180,37,-78,34,-87,27,-93,17,-97,2,-99,2,-107,123,-107,123,-98,104,-97,92,-94,84,-88,80,-77,79,-61,79,17,90,8,99,2,108,-1,118,-3,130,-4,164,1,193,19,215,47,230,82,235,123,231,158,219,188,202,210,179,225,151,230,135,228,120,224,106,216,93,205,79,190,16383,16383,79,167,82,176,91,185,103,193,116,198,131,200,151,195,168,183,181,163,189,136,192,103,189,73,181,47,168,28,152,15,132,11,117,13,103,18,91,26,82,35,79,44,244,-107,244,-99,231,-97,222,-93,216,-88,213,-80,213,228,207,228,180,213,167,220,155,224,144,228,122,230,87,224,57,206,33,179,18,144,12,103,16,67,27,38,44,15,66,0,92,-4,109,-2,126,1,142,8,157,19,171,32,171,-61,169,-75,165,-86,157,-93,144,-97,126,-99,126,-107,16383,16383,171,64,170,57,170,52,168,47,167,44,165,41,149,31,140,28,130,26,112,26,96,30,89,34,83,39,74,50,66,64,60,81,56,100,55,121,58,153,67,179,81,199,100,211,124,215,141,214,154,208,163,198,169,184,171,166,80,229,78,230,62,224,48,219, +34,-87,27,-93,123,-107,123,-107,27,-93,17,-97,123,-107,17,-97,2,-99,9,197,12,197,20,209,20,209,12,197,14,197,20,209,14,197,17,197,17,197,26,196,20,209,20,209,26,196,34,214,20,209,4,204,7,197,20,209,7,197,9,197,82,35,79,44,90,8,90,8,79,44,79,17,80,-77,79,-61,48,219,80,-77,48,219,37,169,37,169,48,219,37,180,26,196,31,194,34,214,34,214,31,194,35,189,34,214,35,189,48,219,48,219,35,189,37,180,79,190,79,229,76,230,79,190,76,230,79,-61,79,190,79,-61,79,167,79,190,79,167,82,176,79,190,82,176,93,205,235,123,231,158,230,82,230,82,231,158,219,188,230,82,219,188,215,47,215,47,219,188,202,210,215,47,202,210,193,19,193,19,202,210,192,103,193,19,192,103,189,73,193,19,189,73,181,47,202,210,179,225,181,163,202,210,181,163,189,136,202,210,189,136,192,103,135,228,131,200,151,195,135,228,151,195,151,230,151,230,151,195,168,183,151,230,168,183,179,225,179,225,168,183,181,163,108,-1,118,-3,117,13,117,13,118,-3,132,11,152,15,132,11,164,1,152,15,164,1,168,28,168,28,164,1,193,19,168,28,193,19,181,47,132,11,118,-3,130,-4,132,11,130,-4,164,1,123,-107,123,-98,104,-97,123,-107,104,-97,92,-94,123,-107,92,-94,37,-78,123,-107,37,-78,34,-87,62,224,48,219,79,-61,62,224,79,-61,76,230,92,-94,84,-88,37,-64,37,-64,84,-88,80,-77,37,-64,80,-77,37,169,82,176,91,185,93,205,93,205,91,185,103,193,93,205,103,193,106,216,106,216,103,193,116,198,106,216,116,198,120,224,120,224,116,198,131,200,120,224,131,200,135,228,82,35,90,8,91,26,91,26,90,8,99,2,91,26,99,2,103,18,103,18,99,2,108,-1,103,18,108,-1,117,13,7,197,4,204,4,196,123,-107,2,-99,2,-107,37,-78,92,-94,37,-64, +244,-107,244,-99,231,-97,222,-93,216,-88,213,-80,213,228,207,228,180,213,167,220,155,224,144,228,122,230,87,224,57,206,33,179,18,144,12,103,16,67,27,38,44,15,66,0,92,-4,109,-2,126,1,142,8,157,19,171,32,171,-61,169,-75,165,-86,157,-93,144,-97,126,-99,126,-107,16383,16383,171,64,170,57,170,52,168,47,167,44,165,41,149,31,140,28,130,26,112,26,96,30,89,34,83,39,74,50,66,64,60,81,56,100,55,121,58,153,67,179,81,199,100,211,124,215,141,214,154,208,163,198,169,184,171,166,80,229,78,230,62,224,48,219,35,214,20,209,3,203,3,195,7,196,11,196,14,197,21,197,28,196,32,193,36,187,37,179,38,167,38,42,37,29,35,21,29,15,18,11,2,7,2,0,123,0,123,7,105,9,93,13,85,20,81,30,80,45,80,157,82,168,88,179,97,189,106,196,115,199,119,197,122,196,125,194,128,191,133,187,137,184,141,182,144,181,148,181,155,182,160,185,164,190,167,196,167,204,166,213,163,220,157,225,149,229,140,230,128,228,117,224,106,215,94,202,80,183,78,151,71,156,64,163, +112,26,104,28,109,-2,109,-2,104,28,96,30,109,-2,96,30,92,-4,92,-4,96,30,89,34,92,-4,89,34,83,39,83,39,74,50,92,-4,92,-4,74,50,66,64,92,-4,66,64,66,0,66,0,66,64,60,81,66,0,60,81,56,100,109,-2,126,1,112,26,112,26,126,1,121,26,130,26,121,26,126,1,130,26,126,1,142,8,133,229,124,215,141,214,133,229,141,214,144,228,144,228,141,214,154,208,144,228,154,208,155,224,155,224,154,208,163,198,155,224,163,198,167,220,167,220,163,198,169,184,167,220,169,184,180,213,180,213,169,184,171,166,180,213,171,166,171,32,171,32,171,166,171,64,67,179,81,199,87,224,87,224,81,199,100,211,87,224,100,211,122,230,122,230,100,211,124,215,122,230,124,215,133,229,57,206,33,179,44,15,57,206,44,15,55,121,57,206,55,121,58,153,57,206,58,153,67,179,57,206,67,179,87,224,55,121,44,15,56,100,12,103,16,67,18,144,18,144,16,67,27,38,18,144,27,38,33,179,33,179,27,38,44,15,165,-86,157,-93,244,-107,244,-107,157,-93,144,-97,244,-107,144,-97,126,-99,170,52,168,47,171,32,171,32,168,47,167,44,171,32,167,44,165,41,165,41,157,36,171,32,171,32,157,36,157,19,170,57,170,52,171,32,170,57,171,32,171,64,149,31,140,28,142,8,149,31,142,8,157,19,149,31,157,19,157,36,213,-69,213,228,207,228,213,-69,207,228,180,213,213,-69,180,213,213,-80,244,-107,244,-99,231,-97,244,-107,231,-97,222,-93,244,-107,222,-93,169,-75,244,-107,169,-75,165,-86,171,32,216,-88,213,-80,171,32,213,-80,180,213,171,-61,169,-75,222,-93,171,-61,222,-93,216,-88,171,-61,216,-88,171,32,244,-107,126,-99,126,-107,56,100,44,15,66,0,130,26,142,8,140,28, +80,229,78,230,62,224,48,219,35,214,20,209,3,203,3,195,7,196,11,196,14,197,21,197,28,196,32,193,36,187,37,179,38,167,38,42,37,29,35,21,29,15,18,11,2,7,2,0,123,0,123,7,105,9,93,13,85,20,81,30,80,45,80,157,82,168,88,179,97,189,106,196,115,199,119,197,122,196,125,194,128,191,133,187,137,184,141,182,144,181,148,181,155,182,160,185,164,190,167,196,167,204,166,213,163,220,157,225,149,229,140,230,128,228,117,224,106,215,94,202,80,183,78,151,71,156,64,163,60,170,57,178,56,185,58,197,63,207,71,214,82,217,94,219,110,217,123,210,134,198,143,181,151,157,158,157,156,225,150,225,145,220,140,220,137,221,134,221,131,223,122,226,115,228,109,229,94,229,72,227,53,219,38,207,29,190,26,168,28,153,35,138,47,123,63,109,85,95,113,80,129,68,134,60,138,52,139,43,137,31,132,21,123,13,112,8,98,6,79,9,63,17,51,31,41,50,34,76,26,76,26,-1,32,-1,34,0,36,2,39,3,41,4,48,4, +11,196,14,197,20,209,20,209,14,197,18,197,20,209,18,197,21,197,21,197,28,196,35,214,35,214,28,196,32,193,35,214,32,193,36,187,20,209,3,203,7,196,20,209,7,196,11,196,80,183,80,229,78,230,80,183,78,230,80,45,80,45,78,230,62,224,80,45,62,224,81,30,81,30,62,224,48,219,81,30,48,219,38,167,38,167,48,219,37,179,48,219,35,214,36,187,48,219,36,187,37,179,35,214,20,209,21,197,122,196,128,228,119,197,119,197,128,228,117,224,119,197,117,224,117,198,117,198,117,224,115,199,106,196,115,199,117,224,106,196,117,224,106,215,137,184,140,230,133,187,133,187,140,230,128,228,133,187,128,228,128,191,128,191,128,228,125,194,144,181,148,181,149,229,149,229,148,181,155,182,149,229,155,182,157,225,157,225,155,182,160,185,157,225,160,185,163,220,163,220,160,185,164,190,163,220,164,190,166,213,166,213,164,190,167,196,166,213,167,196,167,204,141,182,144,181,149,229,141,182,149,229,140,230,141,182,140,230,137,184,82,168,88,179,94,202,94,202,88,179,97,189,94,202,97,189,106,215,106,215,97,189,106,196,80,45,80,157,80,183,80,183,80,157,82,168,80,183,82,168,94,202,123,0,123,7,105,9,123,0,105,9,93,13,123,0,93,13,37,29,123,0,37,29,35,21,123,0,35,21,29,15,123,0,29,15,18,11,123,0,18,11,2,7,123,0,2,7,2,0,93,13,85,20,38,42,38,42,85,20,81,30,38,42,81,30,38,167,7,196,3,203,3,195,37,29,93,13,38,42,128,228,122,196,125,194, +78,151,71,156,64,163,60,170,57,178,56,185,58,197,63,207,71,214,82,217,94,219,110,217,123,210,134,198,143,181,151,157,158,157,156,225,150,225,145,220,140,220,137,221,134,221,131,223,122,226,115,228,109,229,94,229,72,227,53,219,38,207,29,190,26,168,28,153,35,138,47,123,63,109,85,95,113,80,129,68,134,60,138,52,139,43,137,31,132,21,123,13,112,8,98,6,79,9,63,17,51,31,41,50,34,76,26,76,26,-1,32,-1,34,0,36,2,39,3,41,4,48,4,52,3,56,3,61,1,68,0,75,-2,82,-3,90,-4,104,-4,126,-1,145,7,160,21,170,38,174,57,173,73,168,86,159,97,147,108,130,119,133,39,127,32,121,27,115,24,109,22,103,21,93,23,86,28,81,36,78,49,77,66,77,209,127,209,127,225,77,225,77,286,76,287,76,289,75,289,74,290,72,287,69,284,65,278,64,276,53,260,42,247,32,236,23,228,15,222,12,220,8,216,7,214,7,210,8,210,8,209,35,209,35,59,37,36,42,18,51,5,64,-1,79,-4,93,-3,106,1,118,8,129,19,140,33,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216, +36,2,39,3,41,50,41,50,39,3,41,4,41,50,41,4,45,4,45,4,48,4,51,31,51,31,48,4,52,3,51,31,52,3,63,17,63,17,52,3,56,3,63,17,56,3,61,1,36,2,41,50,34,0,34,0,41,50,34,76,34,0,34,76,32,-1,32,-1,34,76,26,76,32,-1,26,76,26,-1,72,227,53,219,58,197,58,197,53,219,56,185,63,109,56,185,53,219,63,109,53,219,47,123,47,123,53,219,38,207,47,123,38,207,35,138,35,138,38,207,29,190,35,138,29,190,28,153,28,153,29,190,26,168,102,229,94,229,110,217,110,217,94,229,94,219,82,217,94,219,94,229,82,217,94,229,72,227,137,221,134,221,134,198,134,198,134,221,131,223,134,198,131,223,128,224,128,224,122,226,123,210,123,210,122,226,115,228,123,210,115,228,110,217,110,217,115,228,109,229,110,217,109,229,102,229,148,223,146,221,151,157,151,157,146,221,145,220,151,157,145,220,143,181,143,181,145,220,143,220,143,181,143,220,142,220,142,220,140,220,143,181,143,181,140,220,137,221,143,181,137,221,134,198,151,157,158,157,156,225,151,157,156,225,150,225,151,157,150,225,148,223,128,224,123,210,134,198,174,57,173,73,170,38,170,38,173,73,168,86,170,38,168,86,160,21,160,21,168,86,159,97,160,21,159,97,147,108,123,13,126,-1,132,21,132,21,126,-1,145,7,132,21,145,7,137,31,137,31,145,7,139,43,147,108,139,43,145,7,147,108,145,7,160,21,121,74,129,68,130,119,130,119,129,68,134,60,130,119,134,60,147,108,147,108,134,60,138,52,147,108,138,52,139,43,130,119,78,151,85,95,130,119,85,95,113,80,130,119,113,80,121,74,78,151,71,156,85,95,85,95,71,156,64,163,85,95,64,163,63,109,63,109,64,163,60,170,63,109,60,170,57,178,98,6,104,-4,112,8,112,8,104,-4,126,-1,112,8,126,-1,123,13,72,227,58,197,63,207,72,227,63,207,71,214,72,227,71,214,82,217,98,6,79,9,82,-3,98,6,82,-3,90,-4,98,6,90,-4,97,-4,98,6,97,-4,104,-4,79,9,63,17,68,0,79,9,68,0,75,-2,79,9,75,-2,82,-3,68,0,63,17,61,1,51,31,41,50,45,4,56,185,63,109,57,178, +133,39,127,32,121,27,115,24,109,22,103,21,93,23,86,28,81,36,78,49,77,66,77,209,127,209,127,225,77,225,77,286,76,287,76,289,75,289,74,290,72,287,69,284,65,278,64,276,53,260,42,247,32,236,23,228,15,222,12,220,8,216,7,214,7,210,8,210,8,209,35,209,35,59,37,36,42,18,51,5,64,-1,79,-4,93,-3,106,1,118,8,129,19,140,33,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38, +42,247,32,236,35,209,35,209,32,236,23,228,35,209,23,228,15,222,53,260,42,247,42,18,53,260,42,18,51,5,53,260,51,5,64,-1,53,260,64,-1,64,276,37,36,42,18,42,247,37,36,42,247,35,209,37,36,35,209,35,59,7,210,8,210,8,216,8,216,8,210,8,209,8,216,8,209,10,218,10,218,8,209,35,209,10,218,35,209,12,220,12,220,35,209,15,222,7,214,7,213,7,212,7,214,7,212,7,211,7,214,7,211,7,210,7,214,7,210,8,216,69,284,79,-4,77,66,77,225,77,209,127,209,77,225,127,209,127,225,77,66,77,283,77,286,77,66,77,286,76,287,77,66,76,287,76,289,77,66,76,289,75,289,77,66,75,289,74,290,77,66,74,290,72,287,77,66,72,287,69,284,86,28,93,-3,93,23,93,23,93,-3,103,21,109,22,103,21,106,1,109,22,106,1,118,8,81,36,78,49,79,-4,81,36,79,-4,93,-3,81,36,93,-3,86,28,79,-4,69,284,67,281,79,-4,67,281,65,278,79,-4,65,278,64,276,79,-4,64,276,64,-1,129,19,140,33,133,39,129,19,133,39,127,32,129,19,127,32,121,27,129,19,121,27,118,8,115,24,109,22,118,8,115,24,118,8,121,27,103,21,93,-3,106,1,77,66,79,-4,78,49, +240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,238,225,169,225,169,218,178,216,184,214,189,211,192,207,193,201,192,198,192,195,191,192,191,189,190,186,140,57,89,185,87,190,86,194,85,197,84,201,84,204,85,209,88,212,92,215,99,216,108,218,108,225,9,225,9,218,19,216,27,212,35,202,44,186,55,160,115,17,116,14,118,10,118,8,119,6,121,1,123,-1,125,-4,126,-6,128,-6,130,-5,132,-3,135,1,138,8,142,18,206,179,213,195,219,206,224,213,231,216,238,218, +78,225,4,225,17,216,78,225,17,216,26,213,78,225,26,213,32,207,78,225,32,207,35,197,78,225,35,197,36,185,78,225,36,185,38,38,78,225,38,38,46,20,78,225,46,20,58,6,78,225,58,6,75,-1,78,225,75,-1,78,64,164,53,162,48,168,38,168,38,162,48,159,43,168,38,159,43,155,40,155,40,147,34,153,21,153,21,147,34,139,29,153,21,139,29,138,8,138,8,139,29,130,26,138,8,130,26,123,0,123,0,130,26,121,25,123,0,121,25,113,24,113,24,102,26,109,-3,109,-3,102,26,97,-4,97,-4,102,26,92,31,97,-4,92,31,84,40,97,-4,84,40,79,51,97,-4,79,51,75,-1,78,64,75,-1,79,51,113,24,109,-3,123,0,166,184,168,38,209,225,209,225,168,38,169,38,209,225,169,38,171,-3,171,-3,169,38,169,-2,168,38,166,184,166,69,168,38,166,69,166,59,168,38,166,59,164,53,155,40,153,21,168,38,225,26,217,29,225,14,225,14,217,29,212,34,225,14,212,34,212,10,212,10,212,34,209,42,212,10,209,42,199,6,199,6,209,42,209,54,199,6,209,54,209,225,209,225,171,-3,186,1,209,225,186,1,199,6,209,225,129,225,145,215,209,225,145,215,155,212,209,225,155,212,162,206,209,225,162,206,165,197,209,225,165,197,166,184,237,25,225,26,225,14,237,25,225,14,240,18,237,25,240,18,240,25,38,38,36,185,36,59,145,215,129,225,129,217,17,216,4,225,4,218, +238,225,169,225,169,218,178,216,184,214,189,211,192,207,193,201,192,198,192,195,191,192,191,189,190,186,140,57,89,185,87,190,86,194,85,197,84,201,84,204,85,209,88,212,92,215,99,216,108,218,108,225,9,225,9,218,19,216,27,212,35,202,44,186,55,160,115,17,116,14,118,10,118,8,119,6,121,1,123,-1,125,-4,126,-6,128,-6,130,-5,132,-3,135,1,138,8,142,18,206,179,213,195,219,206,224,213,231,216,238,218,347,225,286,225,286,218,294,215,301,213,305,210,307,207,307,197,306,191,302,177,299,169,254,58,209,178,206,185,204,195,204,205,207,210,212,213,221,215,233,218,233,225,131,225,131,218,141,216,148,212,155,206,160,196,166,183,175,155,130,55,80,186,79,189,79,192,78,195,78,206,81,211,85,214,91,216,100,218,100,225,11,225,11,218,17,216,22,214,26,208,31,199,37,186,104,15,108,7,111,0,113,-3,116,-5,118,-6,121,-3, +87,190,86,194,115,17,115,17,86,194,85,197,115,17,85,197,55,160,55,160,85,197,84,201,55,160,84,201,84,204,84,204,85,209,55,160,108,225,9,225,19,216,108,225,19,216,27,212,108,225,27,212,35,202,108,225,35,202,44,186,108,225,44,186,88,212,108,225,88,212,92,215,108,225,92,215,99,216,108,225,99,216,108,218,85,209,88,212,44,186,85,209,44,186,55,160,140,57,89,185,115,17,140,57,115,17,116,14,140,57,116,14,117,12,140,57,117,12,118,10,140,57,118,10,118,8,140,57,118,8,119,6,140,57,119,6,121,1,140,57,121,1,123,-1,140,57,123,-1,125,-4,140,57,125,-4,126,-6,140,57,126,-6,128,-6,140,57,128,-6,130,-5,140,57,130,-5,132,-3,140,57,132,-3,135,1,140,57,135,1,138,8,140,57,138,8,142,18,140,57,142,18,190,186,206,179,190,186,142,18,238,225,169,225,178,216,238,225,178,216,184,214,238,225,184,214,189,211,238,225,189,211,192,207,238,225,192,207,193,201,238,225,193,201,224,213,238,225,224,213,231,216,238,225,231,216,238,218,206,179,213,195,193,201,206,179,193,201,192,198,206,179,192,198,192,195,206,179,192,195,191,192,206,179,191,192,191,189,206,179,191,189,190,186,219,206,224,213,193,201,219,206,193,201,213,195,178,216,169,225,169,218,87,190,115,17,89,185,19,216,9,225,9,218, +347,225,286,225,286,218,294,215,301,213,305,210,307,207,307,197,306,191,302,177,299,169,254,58,209,178,206,185,204,195,204,205,207,210,212,213,221,215,233,218,233,225,131,225,131,218,141,216,148,212,155,206,160,196,166,183,175,155,130,55,80,186,79,189,79,192,78,195,78,206,81,211,85,214,91,216,100,218,100,225,11,225,11,218,17,216,22,214,26,208,31,199,37,186,104,15,108,7,111,0,113,-3,116,-5,118,-6,121,-3,123,0,126,5,130,12,186,132,232,15,235,5,238,0,241,-6,246,-6,250,0,253,7,257,17,326,190,331,200,334,207,338,212,342,215,347,218,239,0,239,7,230,8,222,12,215,18,207,26,199,37,134,136,176,195,182,203,190,209,198,214,207,216,217,218,217,225,137,225,137,218,145,217,151,215,155,213,157,210,157,202,154,197,150,191,145,184,136,169,133,165,130,160,124,152,123,154,121,156,119,160,117,162,109,174,103,185,98,194,95,201,94,206,95,210,97,213,101,216,107,217,116,218,116,225,12,225,12,218,17,218,25,217,32,214,39,208,47,200,55,187,55,188,102,116,45,33,37,22,31,15,24,11,17,9,8,7,8,0,81,0,81,7,73,8,68,9,64,11,62,13,61,17,61,19,62,22,64,26,67,31, +22,214,26,208,100,225,100,225,26,208,31,199,100,225,31,199,37,186,37,186,104,15,78,195,78,195,104,15,79,192,37,186,78,198,78,201,78,201,78,206,37,186,37,186,78,206,81,211,37,186,81,211,85,214,100,225,37,186,85,214,100,225,85,214,91,216,100,225,91,216,100,218,17,216,22,214,100,225,17,216,100,225,11,225,17,216,11,225,11,218,186,132,204,200,204,205,186,132,204,205,175,155,175,155,204,205,166,183,160,196,166,183,207,210,160,196,207,210,212,213,233,225,131,225,141,216,233,225,141,216,148,212,233,225,148,212,155,206,233,225,155,206,160,196,233,225,160,196,212,213,233,225,212,213,221,215,233,225,221,215,233,218,207,210,166,183,204,205,254,58,212,170,232,15,254,58,232,15,235,5,254,58,235,5,238,0,254,58,238,0,240,-4,254,58,240,-4,241,-6,254,58,241,-6,243,-6,254,58,243,-6,246,-6,254,58,246,-6,248,-3,254,58,248,-3,250,0,254,58,250,0,253,7,254,58,253,7,257,17,254,58,257,17,299,169,232,15,212,170,209,178,232,15,209,178,206,185,232,15,206,185,205,190,232,15,205,190,204,195,232,15,204,195,186,132,326,190,299,169,257,17,347,225,286,225,294,215,347,225,294,215,301,213,347,225,301,213,305,210,347,225,305,210,307,207,347,225,307,207,307,203,347,225,307,203,334,207,347,225,334,207,338,212,347,225,338,212,342,215,347,225,342,215,347,218,326,190,331,200,307,203,326,190,307,203,307,197,326,190,307,197,306,191,326,190,306,191,304,184,326,190,304,184,302,177,326,190,302,177,299,169,123,0,126,5,130,55,130,55,126,5,130,12,130,55,130,12,175,155,175,155,130,12,186,132,130,55,80,186,104,15,130,55,104,15,108,7,130,55,108,7,111,0,130,55,111,0,113,-3,130,55,113,-3,116,-5,130,55,116,-5,118,-6,130,55,118,-6,119,-5,130,55,119,-5,121,-3,130,55,121,-3,123,0,79,189,79,192,104,15,79,189,104,15,80,186,37,186,78,195,78,198,294,215,286,225,286,218,334,207,307,203,331,200,186,132,204,195,204,200,141,216,131,225,131,218, +239,0,239,7,230,8,222,12,215,18,207,26,199,37,134,136,176,195,182,203,190,209,198,214,207,216,217,218,217,225,137,225,137,218,145,217,151,215,155,213,157,210,157,202,154,197,150,191,145,184,136,169,133,165,130,160,124,152,123,154,121,156,119,160,117,162,109,174,103,185,98,194,95,201,94,206,95,210,97,213,101,216,107,217,116,218,116,225,12,225,12,218,17,218,25,217,32,214,39,208,47,200,55,187,55,188,102,116,45,33,37,22,31,15,24,11,17,9,8,7,8,0,81,0,81,7,73,8,68,9,64,11,62,13,61,17,61,19,62,22,64,26,67,31,71,37,110,99,156,28,157,27,159,23,159,15,157,12,153,9,147,8,139,7,139,0,238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214,26,211,30,206,33,200,99,60,105,47,111,35,116,24,121,9,119,2,116,-8,112,-21,106,-34,100,-44,96,-51,85,-62,80,-65,75,-66,71,-66,69,-65,66,-64,62,-63,63,-63,57,-60,52,-58,42,-56,36,-56,30,-57,24,-60,19,-65,16,-72,15,-79,17,-88,21,-96,28,-102,38,-106,50,-108,71,-105,90,-94,106,-76,122,-49,137,-11,213,192,217,202,221,208,226,213,231,216,238,218,209,68,200,70,197,57,195,47,193,40,190,34,186,28,181,24,173,20, +31,15,24,11,81,0,81,0,24,11,17,9,81,0,17,9,8,7,32,214,39,208,116,225,116,225,39,208,47,200,116,225,47,200,55,188,55,187,55,188,102,116,55,187,102,116,94,206,94,206,95,210,55,187,55,187,95,210,97,213,55,187,97,213,116,225,116,225,97,213,101,216,116,225,101,216,107,217,31,15,81,0,37,22,37,22,81,0,64,11,37,22,64,11,45,33,45,33,64,11,62,13,45,33,62,13,61,17,61,17,61,19,45,33,45,33,61,19,62,22,45,33,62,22,102,116,102,116,62,22,64,26,102,116,64,26,67,31,102,116,67,31,71,37,71,37,110,99,102,116,102,116,110,99,103,185,102,116,103,185,98,194,107,217,116,218,116,225,116,225,12,225,17,218,116,225,17,218,25,217,116,225,25,217,32,214,95,201,94,206,102,116,95,201,102,116,98,194,121,156,120,158,156,28,156,28,120,158,119,160,156,28,119,160,117,162,117,162,109,174,110,99,110,99,109,174,103,185,222,12,215,18,159,20,159,20,215,18,207,26,159,20,207,26,199,37,199,37,134,136,156,28,156,28,134,136,127,156,156,28,127,156,124,152,124,152,123,154,156,28,156,28,123,154,121,156,217,225,137,225,145,217,217,225,145,217,151,215,217,225,151,215,155,213,217,225,155,213,157,210,217,225,157,210,157,206,217,225,157,206,190,209,217,225,190,209,198,214,217,225,198,214,207,216,217,225,207,216,217,218,176,195,182,203,157,206,176,195,157,206,157,202,176,195,157,202,154,197,176,195,154,197,150,191,176,195,150,191,145,184,176,195,145,184,139,174,176,195,139,174,136,169,176,195,136,169,134,136,134,136,136,169,133,165,134,136,133,165,130,160,134,136,130,160,127,156,157,12,153,9,239,0,239,0,153,9,147,8,239,0,147,8,139,7,158,25,159,23,199,37,199,37,159,23,159,21,199,37,159,21,159,20,159,20,159,15,239,0,239,0,159,15,157,12,199,37,156,28,157,27,199,37,157,27,158,25,117,162,110,99,156,28,239,0,239,7,230,8,239,0,230,8,222,12,239,0,222,12,159,20,81,0,81,7,73,8,81,0,73,8,68,9,81,0,68,9,64,11,81,0,8,7,8,0,239,0,139,7,139,0,145,217,137,225,137,218,190,209,157,206,182,203,17,218,12,225,12,218,116,225,55,188,55,187, +238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214,26,211,30,206,33,200,99,60,105,47,111,35,116,24,121,9,119,2,116,-8,112,-21,106,-34,100,-44,96,-51,85,-62,80,-65,75,-66,71,-66,69,-65,66,-64,62,-63,63,-63,57,-60,52,-58,42,-56,36,-56,30,-57,24,-60,19,-65,16,-72,15,-79,17,-88,21,-96,28,-102,38,-106,50,-108,71,-105,90,-94,106,-76,122,-49,137,-11,213,192,217,202,221,208,226,213,231,216,238,218,209,68,200,70,197,57,195,47,193,40,190,34,186,28,181,24,173,20,163,17,149,16,133,15,67,15,201,218,201,225,28,225,26,166,36,166,39,184,44,197,51,205,63,209,79,210,147,210,13,7,13,0,201,0,175,-84,157,-78,144,-69,136,-58,131,-42,129,-22,129,60,128,82,124,98,115,110,102,118,83,124,102,131,115,140,124,151,128,167,129,189,129,273,131,293,136,308,144,320,157,328,175,334,175,340,157,339,144,338,132,336,114,328,107,321,100,312,96,300,94,287,93,271,93,181,91,163,87,149,80,139,67,131,50,125,67,118,80,110,87,100,91,86,93,68,93,-20,94,-35,96,-49, +90,-57,85,-62,90,-94,90,-94,85,-62,80,-65,90,-94,80,-65,75,-66,75,-66,73,-66,90,-94,90,-94,73,-66,71,-105,90,-57,106,-76,96,-51,96,-51,106,-76,100,-44,106,-34,100,-44,106,-76,106,-34,106,-76,122,-49,143,59,88,184,99,60,143,59,99,60,105,47,143,59,105,47,111,35,143,59,111,35,116,24,143,59,116,24,119,15,143,59,119,15,121,9,143,59,121,9,122,-49,143,59,122,-49,137,-11,143,59,137,-11,213,192,143,59,213,192,192,196,122,-49,121,9,119,2,99,60,88,184,86,188,99,60,86,188,84,192,99,60,84,192,82,196,99,60,82,196,81,201,99,60,81,201,33,200,33,200,81,201,81,204,81,204,82,209,33,200,33,200,82,209,85,212,33,200,85,212,109,225,109,225,85,212,90,215,109,225,90,215,98,217,194,202,193,201,213,192,213,192,193,201,193,198,213,192,193,198,192,196,238,225,171,225,179,217,238,225,179,217,186,216,238,225,186,216,190,213,238,225,190,213,193,210,238,225,193,210,194,205,238,225,194,205,226,213,238,225,226,213,231,216,238,225,231,216,238,218,194,205,213,192,217,202,194,205,217,202,221,208,194,205,221,208,226,213,194,204,194,202,213,192,194,204,213,192,194,205,122,-49,119,2,116,-8,122,-49,116,-8,112,-21,122,-49,112,-21,106,-34,71,-105,73,-66,71,-66,71,-105,71,-66,69,-65,71,-105,69,-65,66,-64,71,-105,66,-64,63,-63,71,-105,63,-63,57,-60,71,-105,57,-60,52,-58,71,-105,52,-58,50,-108,52,-58,47,-57,50,-108,50,-108,47,-57,42,-56,50,-108,42,-56,38,-106,38,-106,42,-56,36,-56,38,-106,36,-56,30,-57,38,-106,30,-57,28,-102,28,-102,30,-57,24,-60,28,-102,24,-60,21,-96,21,-96,24,-60,19,-65,21,-96,19,-65,17,-88,17,-88,19,-65,16,-72,17,-88,16,-72,15,-79,98,217,109,218,109,225,109,225,7,225,14,217,109,225,14,217,21,214,109,225,21,214,26,211,109,225,26,211,30,206,109,225,30,206,33,200,66,-64,62,-63,63,-63,14,217,7,225,7,218,90,-57,90,-94,106,-76,179,217,171,225,171,218, +209,68,200,70,197,57,195,47,193,40,190,34,186,28,181,24,173,20,163,17,149,16,133,15,67,15,201,218,201,225,28,225,26,166,36,166,39,184,44,197,51,205,63,209,79,210,147,210,13,7,13,0,201,0,175,-84,157,-78,144,-69,136,-58,131,-42,129,-22,129,60,128,82,124,98,115,110,102,118,83,124,102,131,115,140,124,151,128,167,129,189,129,273,131,293,136,308,144,320,157,328,175,334,175,340,157,339,144,338,132,336, +67,15,201,218,147,210,147,210,201,218,201,225,147,210,201,225,79,210,63,209,79,210,201,225,63,209,201,225,28,225,28,225,26,166,36,166,28,225,36,166,39,184,28,225,39,184,44,197,28,225,44,197,51,205,28,225,51,205,63,209,147,210,13,7,67,15,67,15,13,7,201,0,67,15,201,0,133,15,133,15,201,0,149,16,195,47,193,40,201,0,201,0,193,40,190,34,201,0,190,34,186,28,186,28,181,24,201,0,201,0,181,24,173,20,201,0,173,20,163,17,201,0,209,68,200,70,201,0,200,70,197,57,201,0,197,57,195,47,201,0,13,7,13,0,149,16,201,0,163,17, +175,-84,157,-78,144,-69,136,-58,131,-42,129,-22,129,60,128,82,124,98,115,110,102,118,83,124,102,131,115,140,124,151,128,167,129,189,129,273,131,293,136,308,144,320,157,328,175,334,175,340,157,339,144,338,132,336,114,328,107,321,100,312,96,300,94,287,93,271,93,181,91,163,87,149,80,139,67,131,50,125,67,118,80,110,87,100,91,86,93,68,93,-20,94,-35,96,-49,101,-61,107,-70,114,-77,123,-82,132,-85,143,-87,157,-89,175,-89,66,-6,66,338,33,338,33,-6,147,270,146,286,144,300,139,312,133,321,126,328,108,336,97,338,83,339,65,340,65,334,83,328,96,320,104,308,109,293,110,273,110,189,112,167,116,151,125,139,138,131,157,125,138,118,125,110,116,98,112,82,110,60,110,-22,109,-42,104,-58,96,-69,83,-78,65,-84,65,-89,83,-89,96,-87,108,-85,117,-82,126,-77,133,-71,139,-61,144,-50,146,-36,147,-20,147,68,149,86,153,100,160,111,172,118,190,125,172,131, +107,-70,114,-77,115,110,115,110,114,-77,123,-82,115,110,123,-82,124,98,124,98,123,-82,132,-85,124,98,132,-85,129,-22,129,-22,129,60,128,82,129,-22,128,82,124,98,157,-89,175,-89,175,-84,157,-89,175,-84,157,-78,157,-89,157,-78,144,-69,157,-89,144,-69,143,-87,136,-58,131,-42,132,-85,136,-58,132,-85,143,-87,136,-58,143,-87,144,-69,102,118,83,124,87,100,102,118,87,100,91,86,102,118,91,86,93,68,102,118,93,68,94,-35,102,118,94,-35,96,-49,102,118,96,-49,101,-61,102,118,101,-61,107,-70,102,118,107,-70,115,110,93,68,93,-20,94,-35,80,110,87,100,83,124,80,110,83,124,87,149,80,110,87,149,80,139,80,110,80,139,67,118,157,339,144,338,144,320,157,339,144,320,157,328,157,339,157,328,175,334,157,339,175,334,175,340,129,273,131,293,132,336,132,336,131,293,136,308,132,336,136,308,144,338,144,338,136,308,144,320,114,328,115,140,123,332,123,332,115,140,124,151,123,332,124,151,129,273,129,273,124,151,128,167,129,273,128,167,129,189,107,321,100,312,102,131,107,321,102,131,115,140,107,321,115,140,114,328,102,131,100,312,96,300,102,131,96,300,94,287,102,131,94,287,93,271,102,131,93,271,93,181,102,131,93,181,91,163,102,131,91,163,87,149,102,131,87,149,83,124,67,131,50,125,67,118,67,131,67,118,80,139,123,332,129,273,132,336,129,-22,132,-85,131,-42, +66,-6,66,338,33,338,33,-6,147,270,146,286,144,300,139,312, +66,-6,66,338,33,338,66,-6,33,338,33,-6, +147,270,146,286,144,300,139,312,133,321,126,328,108,336,97,338,83,339,65,340,65,334,83,328,96,320,104,308,109,293,110,273,110,189,112,167,116,151,125,139,138,131,157,125,138,118,125,110,116,98,112,82,110,60,110,-22,109,-42,104,-58,96,-69,83,-78,65,-84,65,-89,83,-89,96,-87,108,-85,117,-82,126,-77,133,-71,139,-61,144,-50,146,-36,147,-20,147,68,149,86,153,100,160,111,172,118,190,125,172,131,160,139,153,149,149,163,147,181,233,162,227,151,219,141,211,133,201,128,189,126,179,127,157,135,148,140,141,143,124,150,111,155,100,158,92,160,83,160,69,159,56,154,43,146,31,134,20,117,38,92,44,104,51,114,60,122,70,126,80,128,92,127,103,125,114,122,122,119,128,116,143,107,155,101,166,97,176,95,189,94,202,95,214,100,226,108,238,120,251,137,101,209,100,217,96,224,90,229,83,233,75,234,66,233,59,229,53,224,49,217,48,209,49,200,53,192,58,186, +110,273,112,167,110,273,110,273,112,167,117,332,110,273,117,332,109,293,109,293,117,332,108,336,109,293,108,336,104,308,104,308,108,336,97,338,104,308,97,338,96,320,96,320,97,338,83,339,96,320,83,339,83,328,83,328,83,339,65,340,83,328,65,340,65,334,147,181,147,270,146,286,147,181,146,286,144,300,147,181,144,300,139,312,147,181,139,312,138,131,147,181,138,131,149,163,172,118,190,125,172,131,172,118,172,131,160,111,160,111,172,131,160,139,160,111,160,139,157,125,157,125,160,139,153,149,157,125,153,149,149,163,112,167,116,151,117,332,117,332,116,151,125,139,117,332,125,139,126,328,126,328,125,139,138,131,126,328,138,131,133,321,133,321,138,131,139,312,157,125,138,118,149,86,157,125,149,86,153,100,157,125,153,100,160,111,147,68,149,86,138,118,147,68,138,118,139,-61,147,68,139,-61,144,-50,147,68,144,-50,146,-36,147,68,146,-36,147,-20,116,98,117,-82,125,110,125,110,117,-82,126,-77,125,110,126,-77,138,118,138,118,126,-77,133,-71,138,118,133,-71,139,-61,117,-82,116,98,112,82,117,-82,112,82,110,60,117,-82,110,60,110,-22,117,-82,110,-22,109,-42,117,-82,109,-42,108,-85,104,-58,96,-69,96,-87,104,-58,96,-87,108,-85,104,-58,108,-85,109,-42,83,-78,65,-84,83,-89,83,-78,83,-89,96,-87,83,-78,96,-87,96,-69,83,-89,65,-84,65,-89,149,163,138,131,157,125,112,167,110,273,110,189, +233,162,227,151,219,141,211,133,201,128,189,126,179,127,157,135,148,140,141,143,124,150,111,155,100,158,92,160,83,160,69,159,56,154,43,146,31,134,20,117,38,92,44,104,51,114,60,122,70,126,80,128,92,127,103,125,114,122,122,119,128,116,143,107,155,101,166,97,176,95,189,94,202,95,214,100,226,108,238,120,251,137,101,209,100,217,96,224,90,229,83,233,75,234,66,233,59,229,53,224,49,217,48,209,49,200,53,192,58,186,66,182,74,181,83,182,90,186,96,192,100,200,101,209,16383,16383,78,141,71,141,49,-49,49,-53,48,-57,48,-69,49,-82,52,-93,58,-101,65,-106,75,-108,84,-106,91,-100,96,-92,100,-81,101,-68,101,-57,100,-53,100,-49, +92,160,83,160,92,127,92,127,83,160,80,128,70,126,80,128,83,160,70,126,83,160,69,159,141,143,128,116,143,107,141,143,143,107,148,140,148,140,143,107,155,101,148,140,155,101,157,135,157,135,155,101,166,97,157,135,166,97,168,131,168,131,166,97,176,95,168,131,176,95,179,127,179,127,176,95,189,94,179,127,189,94,189,126,189,126,189,94,202,95,189,126,202,95,201,128,92,160,92,127,100,158,100,158,92,127,103,125,100,158,103,125,111,155,111,155,103,125,114,122,111,155,114,122,124,150,124,150,114,122,122,119,124,150,122,119,128,116,201,128,202,95,211,133,211,133,202,95,214,100,211,133,214,100,219,141,219,141,214,100,226,108,219,141,226,108,227,151,227,151,226,108,238,120,227,151,238,120,233,162,233,162,238,120,251,137,44,104,51,114,56,154,56,154,51,114,60,122,56,154,60,122,69,159,69,159,60,122,70,126,43,146,31,134,38,92,43,146,38,92,44,104,43,146,44,104,56,154,38,92,31,134,20,117,128,116,141,143,124,150, +101,209,100,217,96,224,90,229,83,233,75,234,66,233,59,229,53,224,49,217,48,209,49,200,53,192,58,186,66,182,74,181,83,182,90,186,96,192,100,200,101,209,16383,16383,78,141,71,141,49,-49,49,-53,48,-57,48,-69,49,-82,52,-93,58,-101,65,-106,75,-108,84,-106,91,-100,96,-92,100,-81,101,-68,101,-57,100,-53,100,-49,218,82,203,62,189,48,175,39,160,33,144,32,138,32,133,33,127,34,121,36,114,38,165,184,170,173,176,166,181,161,187,158,194,157,201,158,207,161,211,166,214,173,215,180,214,190,209,200,202,208,191,216,178,222,201,290,184,290,162,228,155,229,150,229,145,230,137,230,101,224,71,207,47,181,32,148,26,109,27,94,30,79, +48,209,49,200,49,217,49,217,49,200,53,192,49,217,53,192,53,224,53,224,53,192,58,186,53,224,58,186,59,229,59,229,58,186,66,182,59,229,66,182,66,233,66,233,66,182,74,181,66,233,74,181,75,234,75,234,74,181,83,182,75,234,83,182,83,233,83,233,83,182,90,186,83,233,90,186,90,229,90,229,90,186,96,192,90,229,96,192,96,224,96,224,96,192,100,200,96,224,100,200,100,217,100,217,100,200,101,209,100,-49,78,141,84,-106,100,-49,84,-106,91,-100,100,-49,91,-100,96,-92,100,-49,96,-92,100,-81,100,-49,100,-81,101,-68,100,-49,101,-68,100,-53,58,-101,65,-106,71,141,71,141,65,-106,75,-108,71,141,75,-108,78,141,78,141,75,-108,84,-106,71,141,49,-49,49,-82,71,141,49,-82,52,-93,71,141,52,-93,58,-101,49,-82,49,-49,49,-53,49,-82,49,-53,48,-57,49,-82,48,-57,48,-61,49,-82,48,-61,48,-65,49,-82,48,-65,48,-69,101,-68,101,-64,101,-61,101,-68,101,-61,101,-57,101,-68,101,-57,100,-53, +218,82,203,62,189,48,175,39,160,33,144,32,138,32,133,33,127,34,121,36,114,38,165,184,170,173,176,166,181,161,187,158,194,157,201,158,207,161,211,166,214,173,215,180,214,190,209,200,202,208,191,216,178,222,201,290,184,290,162,228,155,229,150,229,145,230,137,230,101,224,71,207,47,181,32,148,26,109,27,94,30,79,34,64,40,50,47,38,53,30,59,24,66,18,74,12,84,6,59,-68,76,-68,100,0,107,-1,119,-3,140,-3,151,0,161,3,171,8,180,15,190,24,198,33,206,45,214,59,224,78,16383,16383,99,49,86,63,76,77,70,92,66,110,65,130,68,158,77,182,91,200,110,211,133,215,138,215,142,214,147,213,151,212,156,210,172,164,172,186,109,186,107,205,106,220,105,233,104,245,104,256,106,280,112,299,122,313,135,322,151,325,161,324,169,321,175,315,178,308,180,299,180,285,182,275,186,269,191,266,199,265,207,266,214,270,219,276,223,283,224,291,221,306,212,319,198,329,180,336,159,338,126,333,99,317,79,293,66,261,61,221,62,214,62,208,64,194,65,186,12,186,12,164,65,164,68,147,71,127,73,109,75,93,76,81,76,69,75,67,75,63,69,64,64,64,60,65,51,65,36,63,24,58,14,50,8,40,6,27,8,16,12,8,19,1,28,-2,40,-3,50,-2,59,0,68,6,78,14,89,27,107,15,123,6,136,1,149,-1,161,-2,175,-1,188,1,201,7,212,15, +156,210,99,49,100,0,100,0,99,49,86,63,100,0,86,63,84,6,84,6,86,63,76,77,84,6,76,77,74,12,74,12,76,77,70,92,74,12,70,92,66,110,53,30,59,24,65,130,65,130,66,18,66,110,66,110,66,18,74,12,113,-2,119,-3,114,38,114,38,119,-3,121,36,121,36,119,-3,124,-3,121,36,124,-3,127,34,127,34,124,-3,129,-3,127,34,129,-3,133,33,133,33,129,-3,140,-3,133,33,140,-3,138,32,138,32,140,-3,144,32,160,33,144,32,151,0,160,33,151,0,161,3,114,38,165,184,156,210,156,210,162,228,155,229,156,210,155,229,151,212,151,212,155,229,150,229,151,212,150,229,147,213,147,213,150,229,145,230,147,213,145,230,142,214,142,214,145,230,141,230,142,214,141,230,138,215,138,215,141,230,137,230,138,215,137,230,133,215,184,290,162,228,165,184,184,290,165,184,170,173,184,290,170,173,178,222,184,290,178,222,201,290,170,173,176,166,178,222,178,222,176,166,181,161,178,222,181,161,191,216,191,216,181,161,187,158,191,216,187,158,194,157,114,38,156,210,100,0,114,38,100,0,107,-1,114,38,107,-1,113,-2,76,-68,100,0,84,6,76,-68,84,6,59,-68,194,157,201,158,202,208,202,208,201,158,207,161,202,208,207,161,209,200,209,200,207,161,211,166,209,200,211,166,214,190,214,190,211,166,214,173,214,190,214,173,215,180,77,182,91,200,101,224,101,224,91,200,110,211,101,224,110,211,137,230,137,230,110,211,133,215,71,207,47,181,47,38,71,207,47,38,53,30,71,207,53,30,65,130,71,207,65,130,68,158,71,207,68,158,77,182,71,207,77,182,101,224,27,94,30,79,32,148,32,148,30,79,34,64,32,148,34,64,47,181,47,181,34,64,40,50,47,181,40,50,47,38,190,24,198,33,203,62,203,62,198,33,206,45,203,62,206,45,218,82,218,82,206,45,214,59,218,82,214,59,224,78,161,3,171,8,175,39,175,39,171,8,180,15,175,39,180,15,189,48,189,48,180,15,190,24,189,48,190,24,203,62,144,32,140,-3,151,0,160,33,161,3,175,39,27,94,32,148,26,109,191,216,194,157,202,208,156,210,165,184,162,228,66,18,65,130,59,24, +172,164,172,186,109,186,107,205,106,220,105,233,104,245,104,256,106,280,112,299,122,313,135,322,151,325,161,324,169,321,175,315,178,308,180,299,180,285,182,275,186,269,191,266,199,265,207,266,214,270,219,276,223,283,224,291,221,306,212,319,198,329,180,336,159,338,126,333,99,317,79,293,66,261,61,221,62,214,62,208,64,194,65,186,12,186,12,164,65,164,68,147,71,127,73,109,75,93,76,81,76,69,75,67,75,63,69,64,64,64,60,65,51,65,36,63,24,58,14,50,8,40,6,27,8,16,12,8,19,1,28,-2,40,-3,50,-2,59,0,68,6,78,14,89,27,107,15,123,6,136,1,149,-1,161,-2,175,-1,188,1,201,7,212,15,223,24,229,32,235,42,240,52,244,61,245,68,245,69,244,70,240,70,238,69,236,67,233,65,230,62,230,63,221,54,210,47,199,42,187,39,174,38,160,38,147,40,133,43,117,48,99,55,109,105,111,117,112,125,112,164,16383,16383,71,38,71,35,68,29,66,26,64,22,59,18,55,14,50,12,46,10,40,10,33,11,27,13,23,17,20,22,19,28,20,35,23,40,28,44,35,46,44,47,52,46,59,45,65,43,69,41,71,38,261,20,213,68,221,81,226,93,230,105,232,118,233,132,232,146,230,158,226,170,221,182,213,194,261,243,237,267,188,219,176,226,165,232,153,235,140,238,112,238,99,236,87,232,75,226,62,219,14,267,-10,243,38,194,30,182,24,170,20,158,18,145,17,131,18,117,20,105,24,92,30,80,38,68,-10,20,14,-4,62,44,74,36,87,31,99,27,112,24,126,23,139,24,152,27,164,31,176,37,188,44,237,-4,16383,16383,199,132,195,108,185,86,169,70,149,59,126,55,102,59,82,70,66,86,55,107,51,132,55,155,66,176,81,192,101,203,124,206,148,203,168,192,184,176,195,156,199,132,256,331,158,331,158,321,174,321,181,319,186,315,190,311,191,306,191,303,190,299,188,294,187,289,184,284,128,174,69,285,67,289,65,294,64,299,63,303,63,307,64,313,67,317,73,319,83,321,95,321,95,331,-25,331,-25,321,-13,319,-3,314,7,304,18,287,32,262,80,176,8,176,8,156,92,156,95,149,95,111,8,111,8,91,95,91,95,60,94,39,91,25,84,16,72,11,55,9,55,0,177,0,177,9,161,11,150,16,142,24,138,37,137,55,137,91,224,91,224,111,137,111,137,149,141,156, +59,18,55,14,59,0,59,0,55,14,50,12,59,0,50,12,50,-2,50,-2,50,12,46,10,50,-2,46,10,40,-3,40,-3,46,10,40,10,69,64,64,64,65,43,65,43,64,64,60,65,65,43,60,65,59,45,59,45,60,65,56,65,59,45,56,65,52,46,52,46,56,65,51,65,52,46,51,65,44,47,20,35,23,40,24,58,24,58,23,40,28,44,24,58,28,44,36,63,36,63,28,44,35,46,36,63,35,46,44,47,20,22,19,28,19,1,19,1,19,28,14,50,14,50,19,28,24,58,24,58,19,28,20,35,71,35,70,33,78,14,78,14,70,33,68,29,78,14,68,29,68,6,68,6,68,29,66,26,68,6,66,26,64,22,64,22,59,18,68,6,68,6,59,18,59,0,75,67,75,65,78,14,78,14,75,65,75,62,78,14,75,62,71,38,71,38,75,62,75,63,71,38,75,63,69,41,69,41,75,63,69,64,69,41,69,64,65,43,78,14,71,38,71,35,89,27,107,15,99,55,99,55,107,15,117,48,117,48,107,15,123,6,117,48,123,6,133,43,133,43,123,6,136,1,133,43,136,1,147,40,147,40,136,1,149,-1,147,40,149,-1,160,38,160,38,149,-1,161,-2,160,38,161,-2,174,38,174,38,161,-2,175,-1,174,38,175,-1,187,39,99,55,105,85,104,256,104,256,106,280,99,317,99,317,106,280,112,299,99,317,112,299,126,333,126,333,112,299,122,313,126,333,122,313,135,322,180,336,159,338,161,324,161,324,159,338,151,325,135,322,151,325,159,338,135,322,159,338,126,333,221,306,212,319,214,270,221,306,214,270,219,276,221,306,219,276,223,283,221,306,223,283,224,291,186,269,191,266,198,329,198,329,191,266,199,265,198,329,199,265,212,319,212,319,199,265,207,266,212,319,207,266,214,270,178,308,180,299,180,336,180,336,180,299,180,285,180,336,180,285,198,329,198,329,180,285,182,275,198,329,182,275,186,269,180,336,161,324,169,321,180,336,169,321,175,315,180,336,175,315,178,308,76,71,78,14,76,73,76,73,78,14,79,293,79,293,78,14,89,27,79,293,89,27,99,317,99,317,89,27,99,55,99,317,99,55,104,256,109,105,111,117,109,186,109,186,111,117,112,164,109,186,112,164,172,186,172,186,112,164,172,164,109,186,107,205,109,105,109,105,107,205,106,220,109,105,106,220,105,85,105,85,106,220,105,233,105,85,105,233,104,245,112,139,112,146,112,133,112,133,112,146,112,152,112,133,112,152,112,125,112,125,112,152,112,158,112,125,112,158,112,164,229,32,230,62,223,24,223,24,230,62,221,54,223,24,221,54,212,15,212,15,221,54,210,47,212,15,210,47,201,7,201,7,210,47,199,42,201,7,199,42,188,1,188,1,199,42,187,39,188,1,187,39,175,-1,245,69,244,70,245,68,245,68,244,70,244,61,244,61,244,70,243,70,244,61,243,70,242,70,240,52,244,61,242,70,240,52,242,70,240,70,240,52,240,70,238,69,240,52,238,69,236,67,240,52,236,67,235,42,235,42,236,67,233,65,235,42,233,65,230,62,235,42,230,62,229,32,79,293,66,261,68,147,79,293,68,147,71,127,79,293,71,127,73,109,79,293,73,109,75,93,79,293,75,93,76,81,79,293,76,81,76,73,66,261,61,221,62,214,66,261,62,214,62,208,66,261,62,208,63,201,66,261,63,201,64,194,66,261,64,194,65,186,66,261,65,186,65,164,66,261,65,164,68,147,76,69,75,67,78,14,76,69,78,14,76,71,65,164,65,186,12,186,65,164,12,186,12,164,33,11,27,13,28,-2,33,11,28,-2,40,-3,33,11,40,-3,40,10,28,-2,27,13,23,17,28,-2,23,17,20,22,28,-2,20,22,19,1,6,27,8,16,8,40,8,40,8,16,12,8,8,40,12,8,14,50,14,50,12,8,19,1,221,54,230,62,230,63,112,125,112,164,111,117,104,256,105,85,104,245,44,47,51,65,36,63, +261,20,213,68,221,81,226,93,230,105,232,118,233,132,232,146,230,158,226,170,221,182,213,194,261,243,237,267,188,219,176,226,165,232,153,235,140,238,112,238,99,236,87,232,75,226,62,219,14,267,-10,243,38,194,30,182,24,170,20,158,18,145,17,131,18,117,20,105,24,92,30,80,38,68,-10,20,14,-4,62,44,74,36,87,31,99,27,112,24,126,23,139,24,152,27,164,31,176,37,188,44,237,-4,16383,16383,199,132,195,108,185,86,169,70,149,59,126,55,102,59,82,70,66,86,55,107,51,132,55,155,66,176,81,192,101,203,124,206,148,203,168,192,184,176,195,156,199,132,256,331,158,331,158,321,174,321,181,319,186,315,190,311,191,306,191,303,190,299,188,294,187,289,184,284,128,174,69,285,67,289,65,294,64,299,63,303,63,307,64,313,67,317,73,319,83,321,95,321,95,331,-25,331,-25,321,-13,319,-3,314,7,304,18,287,32,262,80,176,8,176,8,156,92,156,95,149,95,111,8,111,8,91,95,91,95,60,94,39,91,25,84,16,72,11,55,9,55,0,177,0,177,9,161,11,150,16,142,24,138,37,137,55,137,91,224,91,224,111,137,111,137,149,141,156,224,156,224,176,151,176,197,268,207,286,218,300,229,310,242,317,256,321,66,200,66,338, +99,27,112,24,102,59,102,59,112,24,126,55,149,59,126,55,126,23,149,59,126,23,139,24,62,219,14,267,38,194,62,219,38,194,38,68,62,219,38,68,51,132,62,219,51,132,55,155,62,219,55,155,66,176,62,219,66,176,75,226,66,86,55,107,62,44,62,44,55,107,51,132,140,238,126,238,148,203,148,203,126,238,124,206,101,203,124,206,112,238,101,203,112,238,99,236,87,232,75,226,81,192,87,232,81,192,101,203,87,232,101,203,99,236,261,20,213,68,237,-4,237,-4,213,68,195,108,237,-4,195,108,188,44,188,44,195,108,185,86,188,44,185,86,176,37,176,37,185,86,169,70,176,37,169,70,164,31,164,31,169,70,152,27,149,59,139,24,152,27,149,59,152,27,169,70,195,156,199,132,213,194,195,156,213,194,237,267,237,267,213,194,261,243,165,232,168,192,176,226,176,226,168,192,184,176,176,226,184,176,188,219,188,219,184,176,195,156,188,219,195,156,237,267,153,235,140,238,148,203,153,235,148,203,168,192,153,235,168,192,165,232,213,194,213,68,221,182,221,182,213,68,221,81,221,182,221,81,226,170,226,170,221,81,226,93,226,170,226,93,230,158,230,158,226,93,230,105,230,158,230,105,232,146,232,146,230,105,232,118,232,146,232,118,233,132,213,68,213,194,199,132,213,68,199,132,195,108,126,55,112,24,126,23,126,238,112,238,124,206,99,27,102,59,87,31,87,31,102,59,82,70,87,31,82,70,74,36,74,36,82,70,66,86,74,36,66,86,62,44,38,68,14,-4,62,44,38,68,62,44,51,132,38,68,38,194,30,80,30,80,38,194,30,182,30,80,30,182,24,92,24,92,30,182,24,170,24,92,24,170,20,105,20,105,24,170,20,158,20,105,20,158,18,117,18,117,20,158,18,145,18,117,18,145,17,131,14,-4,38,68,-10,20,75,226,66,176,81,192,38,194,14,267,-10,243, +256,331,158,331,158,321,174,321,181,319,186,315,190,311,191,306,191,303,190,299,188,294,187,289,184,284,128,174,69,285,67,289,65,294,64,299,63,303,63,307,64,313,67,317,73,319,83,321,95,321,95,331,-25,331,-25,321,-13,319,-3,314,7,304,18,287,32,262,80,176,8,176,8,156,92,156,95,149,95,111,8,111,8,91,95,91,95,60,94,39,91,25,84,16,72,11,55,9,55,0,177,0,177,9,161,11,150,16,142,24,138,37,137,55,137,91,224,91,224,111,137,111,137,149,141,156,224,156,224,176,151,176,197,268,207,286,218,300,229,310,242,317,256,321,66,200,66,338,33,338,33,200,16383,16383,66,-6,66,131,33,131,33,-6,100,257,94,262,86,276,84,284,83,292,85,304,91,314,100,321,111,326,126,328,135,327,144,324,150,321,155,316,156,311,156,310,155,309,154,307,152,306,144,298,142,293,140,289,140,284,141,277,144,271,149,266,155,263,163,262,172,263,179,267,184,272,188,280,189,289,185,305,177,318,163,329,145,336,124,338,101,335,82,327,68,314,58,297,55,277,57,262,61,248,70,235,84,220,105,202,99,202,97,203,92,203,74,200,58,191,46,179,38,162,35,143,38,121,48,100,64,79,88,57,121,32,137,20, +32,262,80,176,32,262,32,262,80,176,63,303,32,262,63,303,63,307,63,307,64,313,32,262,91,25,84,16,177,0,177,0,84,16,72,11,177,0,72,11,55,9,95,331,-25,331,-13,319,95,331,-13,319,-3,314,95,331,-3,314,7,304,95,331,7,304,67,317,95,331,67,317,73,319,95,331,73,319,83,321,95,331,83,321,95,321,18,287,32,262,64,313,18,287,64,313,67,317,18,287,67,317,7,304,184,284,128,174,137,149,184,284,137,149,141,156,184,284,141,156,151,176,184,284,151,176,197,268,184,284,197,268,187,289,256,331,158,331,166,321,256,331,166,321,174,321,256,331,174,321,181,319,256,331,181,319,186,315,256,331,186,315,190,311,256,331,190,311,191,306,256,331,191,306,229,310,256,331,229,310,242,317,256,331,242,317,256,321,197,268,207,286,191,306,197,268,191,306,191,303,197,268,191,303,190,299,197,268,190,299,188,294,197,268,188,294,187,289,218,300,229,310,191,306,218,300,191,306,207,286,92,156,95,149,128,174,128,174,95,149,138,37,128,174,138,37,137,55,137,111,137,91,224,91,137,111,224,91,224,111,151,176,141,156,224,156,151,176,224,156,224,176,177,0,177,9,161,11,177,0,161,11,150,16,177,0,150,16,94,39,177,0,94,39,91,25,142,24,138,37,95,149,142,24,95,149,95,111,142,24,95,111,95,91,142,24,95,91,95,60,142,24,95,60,150,16,8,111,8,91,95,91,8,111,95,91,95,111,80,176,8,176,92,156,80,176,92,156,128,174,80,176,128,174,69,285,80,176,69,285,67,289,80,176,67,289,65,294,80,176,65,294,64,299,80,176,64,299,63,303,92,156,8,176,8,156,177,0,55,9,55,0,94,39,150,16,95,60,137,149,128,174,137,55,166,321,158,331,158,321,-13,319,-25,331,-25,321, +66,200,66,338,33,338,33,200,16383,16383,66,-6,66,131,33,131,33,-6,100,257,94,262,86,276,84,284,83,292,85,304,91,314,100,321,111,326, +33,338,33,200,66,200,33,338,66,200,66,338,33,131,33,-6,66,-6,33,131,66,-6,66,131, +100,257,94,262,86,276,84,284,83,292,85,304,91,314,100,321,111,326,126,328,135,327,144,324,150,321,155,316,156,311,156,310,155,309,154,307,152,306,144,298,142,293,140,289,140,284,141,277,144,271,149,266,155,263,163,262,172,263,179,267,184,272,188,280,189,289,185,305,177,318,163,329,145,336,124,338,101,335,82,327,68,314,58,297,55,277,57,262,61,248,70,235,84,220,105,202,99,202,97,203,92,203,74,200,58,191,46,179,38,162,35,143,38,121,48,100,64,79,88,57,121,32,137,20,150,8,159,-2,164,-13,165,-24,163,-37,157,-48,148,-56,136,-61,122,-63,111,-62,101,-59,93,-55,88,-50,86,-45,86,-44,87,-42,90,-39,92,-38,96,-33,99,-29,103,-21,103,-17,102,-10,99,-5,93,0,87,2,79,3,70,2,63,-1,57,-7,53,-14,52,-23,55,-39,65,-53,80,-64,99,-71,121,-73,145,-70,165,-62,180,-48,190,-31,193,-10,192,4,187,17,179,30,165,45,146,63,152,63,173,65,190,73,202,86,210,102,213,123,211,139,206,154,197,170,184,185,169,200,16383,16383,187,105,185,96,180,87,172,80,163,75,152,73,141,75,129,79,116,87,101,99,84,114,75,124,69,133,65,141,62,149,61,158,63,169,68,178,75,185,84,190,95,191,106,190,118,184,132,176,146,165,161,152,170,142,177,132,183,123,186,114,187,105,158,286,157,294,153,301,148,306,141,310,133,311,125,310,118,306,113,301,110,294,108,286,109,278,113,272,118,266,125,263,132,262,140,263,148,266,153,272,157,278,158,286,16383,16383,59,286,57,294,54,301,48,306,41,310,33,311,26,310,19,306,14,301,10,294,9,286,10,278,14,272,19,266,25,263,33,262,41,263,48,266,54,272,57,278,59,286,273,124,266,124,257,108,247,95,236,87,223,82,208,80,183,84,162,95,147,113,137,138,133,169,137,197,146,221,161,240,180,252,205,256,221,254,234,249,245,240,253,227,257,211,266,211,266,247,265,249,264,250,263,252,261,254,259,255,249,259,238,262,216,266,205,266,169,262,138,248,115,227,100,199,95,165,99,133,112,107,132,87,158,75,191,70,210,71,230,74,247,78,260,82,265,86,16383,16383,361,165,352,220,329,267,292,305,246,329,193,338,137,329,89,305,52,268,28,220,19,165,28,110,52,63,89,26,136,1,190,-6,245,1,292,26,329,63,353,110,361,165,16383,16383,334,167,326,119,306,77,275,44,235,22,190,14,145,22,106,43,74,76,54,118,46,166,54,213,74,254,106,287,144,309,189,317,234,309,274,288,305,255,326,214,334,167,135,221,129,217,127,216,124,215,118,215,116,217,115,220,115,225,114,233,114,290,112,307,106,321,96,330,81,336,62,338,44,337,29,332, +101,335,82,327,85,304,85,304,82,327,83,292,84,220,83,292,82,327,84,220,82,327,70,235,70,235,82,327,68,314,70,235,68,314,61,248,61,248,68,314,58,297,61,248,58,297,57,262,57,262,58,297,55,277,69,133,88,57,75,124,75,124,88,57,84,114,101,99,84,114,88,57,101,99,88,57,121,32,95,191,94,203,92,203,95,191,92,203,84,190,95,191,97,203,94,203,63,169,68,178,74,200,74,200,68,178,75,185,74,200,75,185,92,203,92,203,75,185,84,190,74,200,58,191,63,169,63,169,58,191,61,158,64,79,61,158,58,191,64,79,58,191,48,100,48,100,58,191,46,179,48,100,46,179,38,121,38,121,46,179,38,162,38,121,38,162,35,143,165,45,146,63,150,8,150,8,146,63,141,75,150,8,141,75,137,20,137,20,141,75,129,79,137,20,129,79,121,32,121,32,129,79,116,87,121,32,116,87,101,99,163,-37,157,-48,165,-62,165,-62,157,-48,148,-56,165,-62,148,-56,145,-70,145,-70,148,-56,136,-61,145,-70,136,-61,122,-63,122,-63,111,-62,121,-73,121,-73,111,-62,101,-59,121,-73,101,-59,99,-71,99,-71,101,-59,93,-55,99,-71,93,-55,88,-50,79,3,80,-64,87,2,87,2,80,-64,86,-45,88,-50,86,-45,80,-64,88,-50,80,-64,99,-71,144,324,145,336,135,327,135,327,145,336,126,328,111,326,126,328,124,338,111,326,124,338,101,335,101,335,85,304,91,314,101,335,91,314,100,321,101,335,100,321,111,326,152,73,146,63,152,63,152,73,152,63,173,65,152,73,141,75,146,63,180,87,172,80,173,65,173,65,172,80,163,75,173,65,163,75,152,73,118,184,132,176,169,200,169,200,132,176,146,165,169,200,146,165,161,152,161,152,170,142,169,200,169,200,170,142,184,185,213,123,211,139,210,102,210,102,211,139,206,154,210,102,206,154,202,86,202,86,206,154,197,170,202,86,197,170,190,73,190,73,197,170,187,105,190,73,187,105,185,96,190,73,185,96,180,87,177,132,183,123,184,185,184,185,183,123,186,114,184,185,186,114,197,170,197,170,186,114,187,105,106,190,118,184,169,200,106,190,169,200,105,202,106,190,105,202,102,202,106,190,102,202,99,202,106,190,99,202,97,203,106,190,97,203,95,191,100,257,94,262,105,202,100,257,105,202,169,200,94,262,90,269,105,202,105,202,90,269,86,276,105,202,86,276,84,220,84,220,86,276,84,284,84,220,84,284,83,292,193,-10,192,4,190,-31,190,-31,192,4,187,17,190,-31,187,17,180,-48,180,-48,187,17,179,30,180,-48,179,30,165,45,165,45,150,8,159,-2,165,45,159,-2,164,-13,165,45,164,-13,165,-24,165,45,165,-24,165,-62,165,45,165,-62,180,-48,163,-37,165,-62,165,-24,122,-63,121,-73,145,-70,156,311,156,310,163,262,163,262,156,310,155,309,163,262,155,309,155,263,155,263,155,309,154,307,155,263,154,307,152,306,163,329,156,311,163,262,155,316,156,311,163,329,155,316,163,329,150,321,150,321,163,329,145,336,150,321,145,336,144,324,145,336,124,338,126,328,185,305,177,318,179,267,185,305,179,267,184,272,185,305,184,272,188,280,185,305,188,280,189,289,177,318,163,329,163,262,177,318,163,262,172,263,177,318,172,263,179,267,149,266,155,263,152,306,149,266,152,306,148,302,149,266,148,302,144,298,149,266,144,298,144,271,142,293,140,289,141,277,142,293,141,277,144,271,142,293,144,271,144,298,102,-10,99,-5,99,-29,102,-10,99,-29,101,-25,102,-10,101,-25,103,-21,102,-10,103,-21,103,-17,99,-29,99,-5,96,-33,96,-33,99,-5,93,0,96,-33,93,0,92,-38,92,-38,93,0,90,-39,86,-45,86,-44,87,2,87,2,86,-44,87,-42,87,2,87,-42,93,0,93,0,87,-42,88,-41,93,0,88,-41,90,-39,70,2,63,-1,65,-53,70,2,65,-53,80,-64,70,2,80,-64,79,3,57,-7,53,-14,55,-39,57,-7,55,-39,65,-53,57,-7,65,-53,63,-1,65,141,62,149,64,79,65,141,64,79,88,57,65,141,88,57,69,133,61,158,64,79,62,149,55,-39,53,-14,52,-23,141,277,140,289,140,284,180,87,173,65,190,73,184,185,170,142,177,132, +158,286,157,294,153,301,148,306,141,310,133,311,125,310,118,306,113,301,110,294,108,286,109,278,113,272,118,266,125,263,132,262,140,263,148,266,153,272,157,278,158,286,16383,16383,59,286,57,294,54,301,48,306,41,310,33,311,26,310,19,306,14,301,10,294,9,286,10,278,14,272,19,266,25,263,33,262,41,263,48,266,54,272,57,278,59,286,273,124,266,124,257,108,247,95,236,87,223,82,208,80,183,84,162,95,147,113,137,138,133,169,137,197,146,221,161,240,180,252,205,256,221,254,234,249,245,240,253,227,257,211,266,211,266,247,265,249,264,250,263,252,261,254,259,255,249,259,238,262,216,266,205,266,169,262,138,248,115,227,100,199,95,165,99,133,112,107,132,87,158,75,191,70, +108,286,109,278,110,294,110,294,109,278,113,272,110,294,113,272,113,301,113,301,113,272,118,266,113,301,118,266,118,306,118,306,118,266,125,263,118,306,125,263,125,310,125,310,125,263,132,262,125,310,132,262,133,311,133,311,132,262,140,263,133,311,140,263,141,310,141,310,140,263,148,266,141,310,148,266,148,306,148,306,148,266,153,272,148,306,153,272,153,301,153,301,153,272,157,278,153,301,157,278,157,294,157,294,157,278,158,286,9,286,10,278,10,294,10,294,10,278,14,272,10,294,14,272,14,301,14,301,14,272,19,266,14,301,19,266,19,306,19,306,19,266,25,263,19,306,25,263,26,310,26,310,25,263,33,262,26,310,33,262,33,311,33,311,33,262,41,263,33,311,41,263,41,310,41,310,41,263,48,266,41,310,48,266,48,306,48,306,48,266,54,272,48,306,54,272,54,301,54,301,54,272,57,278,54,301,57,278,57,294,57,294,57,278,59,286, +273,124,266,124,257,108,247,95,236,87,223,82,208,80,183,84,162,95,147,113,137,138,133,169,137,197,146,221,161,240,180,252,205,256,221,254,234,249,245,240,253,227,257,211,266,211,266,247,265,249,264,250,263,252,261,254,259,255,249,259,238,262,216,266,205,266,169,262,138,248,115,227,100,199,95,165,99,133,112,107,132,87,158,75,191,70,210,71,230,74,247,78,260,82,265,86,16383,16383,361,165,352,220,329,267,292,305,246,329,193,338,137,329,89,305,52,268,28,220,19,165,28,110,52,63,89,26,136,1,190,-6,245,1,292,26,329,63,353,110,361,165,16383,16383,334,167,326,119,306,77,275,44,235,22,190,14,145,22,106,43,74,76,54,118,46,166,54,213,74,254,106,287,144,309,189,317,234,309,274,288,305,255,326,214,334,167,135,221,129,217,127,216,124,215,118,215,116,217,115,220,115,225,114,233,114,290,112,307,106,321,96,330,81,336,62,338,44,337,29,332,18,325,10,316,8,305,9,300,11,295,14,292,19,290,24,289,29,290,37,294,39,298,40,301,40,303,39,304,39,307,38,309,38,313,39,316,43,319,48,322,54,324,60,324,67,323,72,321,76,316,78,310,79,303,79,288,56,279,40,273,29,268,20,263,13,257,9,253,6,248,4,243,2,231,4,220,9,210,16,203,26,199,37,197,46,198,55,200,64,205,73,211,83,219,85,210,88,204,93,200,98,198,105,197,112,197,117,199,123,202,128,206,135,212,16383,16383,79,237,79,235,78,233,77,230,76,228,74,226,64,222,60,221,56,221,52,220,46,222,41,225,37,230,34,236,33,243,35,250,39,256, +162,95,147,113,158,75,158,75,147,113,137,138,158,75,137,138,132,87,132,87,137,138,133,169,138,248,133,169,137,197,138,248,137,197,146,221,216,266,205,266,221,254,221,254,205,266,205,256,180,252,205,256,205,266,180,252,205,266,169,262,263,252,261,254,266,211,266,211,261,254,259,255,266,211,259,255,257,211,257,211,259,255,253,227,169,262,138,248,146,221,169,262,146,221,161,240,169,262,161,240,180,252,115,227,100,199,112,107,115,227,112,107,132,87,115,227,132,87,133,169,115,227,133,169,138,248,100,199,95,165,99,133,100,199,99,133,112,107,266,124,257,108,260,82,260,82,257,108,247,95,260,82,247,95,247,78,247,78,247,95,236,87,247,78,236,87,230,74,230,74,236,87,223,82,230,74,223,82,210,71,210,71,223,82,208,80,191,70,210,71,208,80,191,70,208,80,183,84,191,70,183,84,162,95,191,70,162,95,158,75,266,211,266,247,265,249,266,211,265,249,264,250,266,211,264,250,263,252,216,266,221,254,227,264,227,264,221,254,234,249,227,264,234,249,238,262,238,262,234,249,245,240,238,262,245,240,249,259,249,259,245,240,253,227,249,259,253,227,259,255,266,124,260,82,265,86,266,124,265,86,273,124,193,338,189,317,234,309,193,338,234,309,246,329,246,329,234,309,274,288,246,329,274,288,292,305,292,305,274,288,305,255,292,305,305,255,329,267,329,267,305,255,326,214,329,267,326,214,334,167,334,167,352,220,329,267,334,167,353,110,352,220,329,63,353,110,334,167,329,63,334,167,326,119,329,63,326,119,306,77,329,63,306,77,292,26,190,14,190,-6,235,22,235,22,190,-6,245,1,235,22,245,1,275,44,275,44,245,1,292,26,275,44,292,26,306,77,54,213,74,254,89,305,89,305,74,254,106,287,89,305,106,287,137,329,137,329,106,287,144,309,137,329,144,309,193,338,193,338,144,309,189,317,28,110,52,63,28,220,28,220,52,63,46,166,52,268,46,166,54,213,52,268,54,213,89,305,145,22,106,43,136,1,145,22,136,1,190,-6,145,22,190,-6,190,14,89,26,136,1,106,43,89,26,106,43,74,76,89,26,74,76,54,118,89,26,54,118,52,63,46,166,52,63,54,118,28,110,28,220,19,165,28,220,46,166,52,268,352,220,353,110,361,165, +135,221,129,217,127,216,124,215,118,215,116,217,115,220,115,225,114,233,114,290,112,307,106,321,96,330,81,336,62,338,44,337,29,332,18,325,10,316,8,305,9,300,11,295,14,292,19,290,24,289,29,290,37,294,39,298,40,301,40,303,39,304,39,307,38,309,38,313,39,316,43,319,48,322,54,324,60,324,67,323,72,321,76,316,78,310,79,303,79,288,56,279,40,273,29,268,20,263,13,257,9,253,6,248,4,243,2,231,4,220,9,210,16,203,26,199,37,197,46,198,55,200,64,205,73,211,83,219,85,210,88,204,93,200,98,198,105,197,112,197,117,199,123,202,128,206,135,212,16383,16383,79,237,79,235,78,233,77,230,76,228,74,226,64,222,60,221,56,221,52,220,46,222,41,225,37,230,34,236,33,243,35,250,39,256,48,262,61,269,79,276,117,113,157,77,172,64,203,33,216,21,222,17,224,17,225,18,227,19,228,20,228,22,227,26,224,31,219,39,212,49,203,60,196,70,188,80,180,91,171,102,161,113,203,166,212,178,219,187,224,194,227,199,228,203,228,205,227,207,225,208,223,208,216,204,204,193,172,163,157,150,16383,16383,21,113,61,77,76,64,107,33,120,21,126,17,128,17,129,18,131,19,132,20,132,22,131,26,128,31,123,39,116,49,107,60,100,70,92,80,65,113,107,166,116,178,123,187,128,194,131,199,132,203,132,205,131,207,129,208,127,208,120,204,108,193,76,163,61,150,276,57,276,196,24,196,24,164,243,164,243,57,142,97,142,128,20,128,20,97,283,76,283,80,276,86,268,94,252,112,244,123,216,162,230,168,241,177,249,188,254,199,256,211,253,228,246,241,233,251,217,258, +38,309,38,310,39,298,39,298,38,310,38,311,39,298,38,311,37,294,37,294,38,311,38,313,44,337,38,313,39,316,44,337,39,316,43,319,39,305,39,307,39,298,39,305,39,298,40,301,40,301,40,302,40,303,40,301,40,303,39,304,40,301,39,304,39,305,46,198,55,200,46,222,46,222,55,200,52,220,56,221,52,220,55,200,56,221,55,200,64,205,81,336,62,338,67,323,67,323,62,338,60,324,54,324,60,324,62,338,54,324,62,338,48,322,48,322,62,338,44,337,48,322,44,337,43,319,78,233,77,230,83,219,83,219,77,230,76,228,83,219,76,228,74,226,74,226,69,224,73,211,73,211,69,224,64,222,73,211,64,222,64,205,64,205,64,222,60,221,64,205,60,221,56,221,24,289,29,290,29,332,29,332,29,290,33,292,29,332,33,292,38,313,38,313,33,292,37,294,11,295,14,292,18,325,18,325,14,292,19,290,18,325,19,290,29,332,29,332,19,290,24,289,10,316,8,305,9,300,10,316,9,300,11,295,10,316,11,295,18,325,81,336,79,276,83,219,81,336,83,219,96,330,96,330,83,219,85,210,96,330,85,210,88,204,81,336,67,323,72,321,81,336,72,321,76,316,81,336,76,316,78,310,81,336,78,310,79,303,81,336,79,303,79,276,98,198,105,197,106,321,106,321,105,197,112,197,106,321,112,197,112,307,112,307,112,197,115,225,112,307,115,225,114,233,117,199,123,202,118,215,118,215,123,202,121,215,124,215,121,215,123,202,124,215,123,202,128,206,135,221,132,219,135,212,135,212,132,219,129,217,135,212,129,217,128,206,128,206,129,217,127,216,128,206,127,216,124,215,117,199,118,215,116,217,117,199,116,217,115,220,117,199,115,220,115,225,117,199,115,225,112,197,96,330,88,204,93,200,96,330,93,200,98,198,96,330,98,198,106,321,83,219,79,276,79,237,83,219,79,237,79,235,83,219,79,235,78,233,74,226,73,211,83,219,35,250,39,256,40,273,40,273,39,256,48,262,40,273,48,262,56,279,56,279,48,262,61,269,56,279,61,269,79,288,79,288,61,269,79,276,79,288,79,276,79,303,40,273,29,268,35,250,35,250,29,268,33,243,37,197,33,243,29,268,37,197,29,268,26,199,26,199,29,268,20,263,26,199,20,263,16,203,16,203,20,263,13,257,16,203,13,257,9,253,41,225,37,230,37,197,41,225,37,197,46,198,41,225,46,198,46,222,34,236,33,243,37,197,34,236,37,197,37,230,9,210,16,203,9,253,9,210,9,253,6,248,9,210,6,248,4,243,9,210,4,243,4,220,3,237,2,231,4,220,3,237,4,220,4,243,114,233,114,290,112,307,29,332,38,313,44,337,38,309,39,298,39,307, +117,113,157,77,172,64,203,33,216,21,222,17,224,17,225,18,227,19,228,20,228,22,227,26,224,31,219,39,212,49,203,60,196,70,188,80,180,91,171,102,161,113,203,166,212,178,219,187,224,194,227,199,228,203,228,205,227,207,225,208,223,208,216,204,204,193,172,163,157,150,16383,16383,21,113,61,77,76,64,107,33,120,21,126,17,128,17,129,18,131,19,132,20,132,22,131,26,128,31,123,39,116,49,107,60,100,70,92,80,65,113,107,166,116,178,123,187,128,194,131,199,132,203,132,205,131,207,129,208,127,208,120,204,108,193,76,163,61,150,276,57,276,196,24,196,24,164,243,164,243,57,142,97,142,128,20,128,20,97,283,76,283,80,276,86,268,94,252,112,244,123,216,162,230,168,241,177,249,188,254,199,256,211,253,228,246,241,233,251,217,258,196,260,110,260,110,252,122,251,128,248,132,244,134,237,134,98,132,91,129,87,121,85,110,84,109,76,190,76,190,84,178,85,171,87,168,92,166,100,166,157,190,157,199,143,206,133,210,127,213,121,216,116,224,101,232,90,239,82,246,77,252,76,16383,16383,166,166,166,251,185,251,199,248,210,243,217,234,221,222,222,209,221,196,216,184,209,175, +203,60,196,70,203,60,203,60,196,70,203,33,203,60,203,33,212,49,212,49,203,33,216,21,212,49,216,21,219,39,219,39,216,21,222,17,219,39,222,17,224,31,224,31,222,17,224,17,224,31,224,17,225,18,227,26,224,31,225,18,227,26,225,18,227,19,227,26,227,19,228,20,227,26,228,20,228,22,171,102,172,64,180,91,180,91,172,64,188,48,180,91,188,48,188,80,188,80,188,48,203,33,188,80,203,33,196,70,161,113,172,163,157,150,161,113,157,150,157,77,161,113,157,77,172,64,161,113,172,64,171,102,228,205,227,207,227,199,228,205,227,199,228,203,228,205,228,203,228,204,188,178,203,166,204,193,204,193,203,166,212,178,204,193,212,178,216,204,216,204,212,178,219,187,216,204,219,187,223,208,223,208,219,187,224,194,223,208,224,194,225,208,225,208,224,194,227,199,225,208,227,199,227,207,172,163,161,113,203,166,172,163,203,166,188,178,107,60,100,70,107,33,107,60,107,33,116,49,116,49,107,33,120,21,116,49,120,21,123,39,123,39,120,21,126,17,123,39,126,17,128,31,128,31,126,17,128,17,128,31,128,17,129,18,131,26,128,31,129,18,131,26,129,18,131,19,131,26,131,19,132,20,131,26,132,20,132,22,74,102,76,64,83,91,83,91,76,64,92,48,83,91,92,48,92,80,92,80,92,48,107,33,92,80,107,33,100,70,65,113,76,163,61,150,65,113,61,150,61,77,65,113,61,77,76,64,65,113,76,64,74,102,132,205,131,207,131,199,132,205,131,199,132,203,132,205,132,203,132,204,92,178,107,166,108,193,108,193,107,166,116,178,108,193,116,178,120,204,120,204,116,178,123,187,120,204,123,187,127,208,127,208,123,187,128,194,127,208,128,194,129,208,129,208,128,194,131,199,129,208,131,199,131,207,76,163,65,113,107,166,76,163,107,166,92,178,61,77,61,150,21,113,157,77,157,150,117,113, +276,57,276,196,24,196,24,164,243,164,243,57,142,97,142,128,20,128,20,97,283,76,283,80, +243,164,243,57,276,57,243,164,276,57,276,196,243,164,276,196,24,196,243,164,24,196,24,164, +142,97,142,128,20,128,20,97,283,76,283,80,276,86,268,94, +142,97,142,128,20,128,142,97,20,128,20,97, +283,76,283,80,276,86,268,94,252,112,244,123,216,162,230,168,241,177,249,188,254,199,256,211,253,228,246,241,233,251,217,258,196,260,110,260,110,252,122,251,128,248,132,244,134,237,134,98,132,91,129,87,121,85,110,84,109,76,190,76,190,84,178,85,171,87,168,92,166,100,166,157,190,157,199,143,206,133,210,127,213,121,216,116,224,101,232,90,239,82,246,77,252,76,16383,16383,166,166,166,251,185,251,199,248,210,243,217,234,221,222,222,209,221,196,216,184,209,175,199,168,187,166,188,166,16383,16383,361,165,352,220,329,267,292,305,246,329,193,338,137,330,89,305,52,268,28,221,19,166,28,111,51,63,88,26,135,1,190,-6,245,1,292,26,329,63,353,110,361,165,16383,16383,334,165,326,118,306,77,275,44,235,22,190,14,145,22,106,43,74,76,54,118,46,166,54,213,74,254,106,287,145,309,189,317,235,309,275,288,306,255,326,213,334,165,161,273,161,300,6,300,6,273,171,267,168,289,158,309,143,324,123,334,101,338,78,335,58,325,42,309,32,290,28,267,32,244,42,224,57,209,77,198,100,195,123,198,142,209,158,224,168,244,171,267,16383,16383,152,267,149,250,142,235,130,223,116,215,100,212,84,215,69,223,58,234,51,249,48,267,51,284,58,298,69,310,83,318,99,321,115,318,130,310,141,299,149,284,152,267,319,121,319,154,188,154,188,251,155,251,155,154,24,154,24,121,155,121,155,17,188,17,188,121,16383,16383,319,-43,319,-10,24,-10,24,-43,148,177,139,181,134,175,124,169,110,167,54,167,95,208,112,226,125,241,133,255,137,269,138,283,136,301,127,316,114,328,97,335,75,338,53,336,35,329,21,317,10,301,1,278,13,271,20,284,28,295,37,302,46,307,57,308,68,306,78,301,86,292,91,282,93,270,91,260,86,247,78,233,67,217,54,201,3,147,3,135,128,135,102,256, +222,209,222,209,222,209,222,209,230,168,233,251,233,251,230,168,241,177,233,251,241,177,246,241,246,241,241,177,249,188,246,241,249,188,253,228,253,228,249,188,254,199,253,228,254,199,256,211,221,222,222,209,233,251,221,222,233,251,217,258,221,222,217,258,217,234,166,251,185,251,196,260,196,260,185,251,199,248,196,260,199,248,217,258,217,258,199,248,210,243,217,258,210,243,217,234,134,226,168,92,166,100,134,226,166,100,166,111,166,166,166,157,190,157,166,166,190,157,187,166,187,166,190,157,188,166,187,166,188,166,199,168,199,168,188,166,190,157,199,168,190,157,199,143,166,251,196,260,132,244,166,251,132,244,134,237,166,251,134,237,134,226,166,251,134,226,166,111,196,260,110,260,122,251,196,260,122,251,128,248,196,260,128,248,132,244,213,121,216,162,216,184,216,184,216,162,230,168,216,184,230,168,221,196,221,196,230,168,222,209,213,121,216,184,210,127,210,127,216,184,209,175,210,127,209,175,206,133,206,133,209,175,199,168,206,133,199,168,199,143,232,90,239,82,244,123,244,123,239,82,246,77,244,123,246,77,252,112,252,112,246,77,252,76,252,112,252,76,260,103,260,103,252,76,283,76,260,103,283,76,268,94,268,94,283,76,276,86,244,123,216,162,216,116,244,123,216,116,224,101,244,123,224,101,232,90,190,76,190,84,178,85,190,76,178,85,171,87,190,76,171,87,134,108,190,76,134,108,134,98,190,76,134,98,132,91,190,76,132,91,129,87,190,76,129,87,121,85,190,76,121,85,110,84,190,76,110,84,109,76,134,111,134,108,171,87,134,111,171,87,168,92,134,111,168,92,134,226,193,338,189,317,235,309,193,338,235,309,246,329,246,329,235,309,275,288,246,329,275,288,292,305,292,305,275,288,306,255,292,305,306,255,329,267,329,267,306,255,326,213,329,267,326,213,334,165,334,165,352,220,329,267,334,165,353,110,352,220,329,63,353,110,334,165,329,63,334,165,326,118,329,63,326,118,306,77,329,63,306,77,292,26,190,14,190,-6,235,22,235,22,190,-6,245,1,235,22,245,1,275,44,275,44,245,1,292,26,275,44,292,26,306,77,54,213,74,254,89,305,89,305,74,254,106,287,89,305,106,287,137,330,137,330,106,287,145,309,137,330,145,309,193,338,193,338,145,309,189,317,28,111,51,63,28,221,28,221,51,63,46,166,52,268,46,166,54,213,52,268,54,213,89,305,145,22,106,43,135,1,145,22,135,1,190,-6,145,22,190,-6,190,14,88,26,135,1,106,43,88,26,106,43,74,76,88,26,74,76,54,118,88,26,54,118,51,63,46,166,51,63,54,118,28,111,28,221,19,166,28,221,46,166,52,268,352,220,353,110,361,165,216,116,216,162,213,121,276,86,283,76,283,80,122,251,110,260,110,252, +161,273,161,300,6,300,6,273,171,267,168,289,158,309,143,324, +161,273,161,300,6,300,161,273,6,300,6,273, +171,267,168,289,158,309,143,324,123,334,101,338,78,335,58,325,42,309,32,290,28,267,32,244,42,224,57,209,77,198,100,195,123,198,142,209,158,224,168,244,171,267,16383,16383,152,267,149,250,142,235,130,223,116,215,100,212,84,215,69,223,58,234,51,249,48,267,51,284,58,298,69,310,83,318,99,321,115,318,130,310,141,299,149,284,152,267,319,121,319,154,188,154,188,251,155,251,155,154,24,154,24,121,155,121,155,17,188,17,188,121,16383,16383,319,-43,319,-10,24,-10,24,-43,148,177,139,181,134,175,124,169,110,167,54,167,95,208,112,226,125,241,133,255,137,269,138,283,136,301,127,316,114,328,97,335,75,338,53,336,35,329,21,317,10,301,1,278,13,271,20,284,28,295,37,302, +83,318,99,321,99,321,101,338,99,321,115,318,101,338,115,318,123,334,123,334,115,318,130,310,123,334,130,310,143,324,143,324,130,310,141,299,143,324,141,299,149,284,171,267,168,289,168,244,168,244,168,289,158,309,168,244,158,309,158,224,158,224,158,309,152,267,158,224,152,267,149,250,158,224,149,250,142,209,142,209,149,250,142,235,142,209,142,235,130,223,158,309,143,324,149,284,158,309,149,284,152,267,142,209,130,223,123,198,123,198,130,223,116,215,123,198,116,215,100,195,100,195,116,215,100,212,58,298,69,310,78,335,78,335,69,310,83,318,78,335,83,318,101,338,101,338,83,318,99,321,42,309,48,267,51,284,42,309,51,284,58,325,58,325,51,284,58,298,58,325,58,298,78,335,84,215,69,223,77,198,84,215,77,198,100,195,84,215,100,195,100,212,48,267,42,224,51,249,51,249,42,224,57,209,51,249,57,209,58,234,58,234,57,209,77,198,58,234,77,198,69,223,28,267,32,244,32,290,32,290,32,244,42,224,32,290,42,224,42,309,42,309,42,224,48,267, +319,121,319,154,188,154,188,251,155,251,155,154,24,154,24,121,155,121,155,17,188,17,188,121,16383,16383,319,-43,319,-10,24,-10,24,-43,148,177,139,181,134,175,124,169,110,167,54,167,95,208,112,226,125,241,133,255,137,269,138,283,136,301,127,316,114,328,97,335,75,338, +188,251,155,251,188,17,188,17,155,251,155,154,188,17,155,154,155,121,155,121,155,154,24,154,155,121,24,154,24,121,188,121,319,121,188,154,24,-10,24,-43,319,-43,24,-10,319,-43,319,-10,188,154,319,121,319,154,188,17,155,121,155,17, +148,177,139,181,134,175,124,169,110,167,54,167,95,208,112,226,125,241,133,255,137,269,138,283,136,301,127,316,114,328,97,335,75,338,53,336,35,329,21,317,10,301,1,278,13,271,20,284,28,295,37,302,46,307,57,308,68,306,78,301,86,292,91,282,93,270,91,260,86,247,78,233,67,217,54,201,3,147,3,135,128,135,102,256,114,263,123,271,129,279,131,288,132,296,130,310,122,321,110,330,95,336,78,338,61,336,46,331,33,322,22,309,11,291,23,281,31,293,39,301,47,306,56,309,66,310,76,309,83,306,89,301,93,295,94,286,92,276,87,267,78,259,65,252,46,244,46,230,52,231,59,231,60,232,76,230,88,225,97,216,103,205,105,190, +54,201,3,147,54,167,54,201,54,167,95,208,54,201,95,208,67,217,13,271,20,284,21,317,21,317,20,284,28,295,21,317,28,295,35,329,35,329,28,295,37,302,35,329,37,302,53,336,53,336,37,302,46,307,53,336,46,307,57,308,57,308,68,306,75,338,75,338,68,306,78,301,75,338,78,301,97,335,97,335,78,301,86,292,97,335,86,292,91,282,10,301,1,278,13,271,10,301,13,271,21,317,91,260,95,208,93,270,93,270,95,208,97,335,97,335,95,208,112,226,97,335,112,226,114,328,114,328,112,226,125,241,114,328,125,241,127,316,127,316,125,241,133,255,127,316,133,255,136,301,136,301,133,255,137,269,136,301,137,269,138,283,97,335,91,282,93,270,75,338,53,336,57,308,95,208,91,260,86,247,95,208,86,247,78,233,95,208,78,233,67,217,129,172,124,169,128,135,128,135,124,169,117,168,128,135,117,168,110,167,128,135,110,167,54,167,128,135,54,167,3,147,148,177,139,181,134,175,148,177,134,175,129,172,148,177,129,172,128,135,128,135,3,147,3,135, +102,256,114,263,123,271,129,279,131,288,132,296,130,310,122,321,110,330,95,336,78,338,61,336,46,331,33,322,22,309,11,291,23,281,31,293,39,301,47,306,56,309,66,310,76,309,83,306,89,301,93,295,94,286,92,276,87,267,78,259,65,252,46,244,46,230,52,231,59,231,60,232,76,230,88,225,97,216,103,205,105,190,103,179,99,169,92,162,82,157,71,155,66,155,61,156,57,158,52,161,40,169,32,173,28,174,25,175,19,174,14,172,10,169,8,165,7,159,9,150,15,142,25,136,37,132,52,131,83,134,109,144,129,159,141,177,146,200,144,214,139,227,130,239,118,248,102,254,46,253,66,253,143,302,149,306,153,310,156,314,158,318,158,329,155,333,152,336,147,338,141,339,133,337,129,335,125,332,120,328,215,225,171,225,171,57,164,46,155,38,144,31,131,27,116,26,102,28,90,34,81,45,76,59,74,78,74,225,30,225,30,27,29,14,26,-5,22,-28,19,-51,18,-69,19,-82,22,-93,26,-101,32,-106,40,-108,48,-106,55,-102,60,-94,63,-83,64,-69,62,-51,58,-29,52,-6,48,14,46,32,55,18,66,8,77,1,91,-3,107,-4,123,-2,137,2,150,11,162,24,172,40,174,40,176,24,182,11,191,2,201,-2,211,-4,222,-3,231,0,239,4,247,12,256,23,256,28, +66,155,61,156,83,134,83,134,61,156,57,158,83,134,57,158,52,131,52,131,57,158,52,161,52,131,52,161,46,165,56,231,59,231,65,252,65,252,59,231,60,232,60,232,76,230,65,252,65,252,76,230,78,259,65,252,46,244,52,231,65,252,52,231,56,231,23,281,31,293,33,322,33,322,31,293,39,301,33,322,39,301,46,331,46,331,39,301,47,306,46,331,47,306,61,336,61,336,47,306,56,309,61,336,56,309,66,310,66,310,76,309,78,338,78,338,76,309,83,306,78,338,83,306,95,336,95,336,83,306,89,301,95,336,89,301,93,295,22,309,11,291,23,281,22,309,23,281,33,322,103,179,99,169,109,144,109,144,99,169,92,162,109,144,92,162,83,134,83,134,92,162,82,157,83,134,82,157,71,155,71,155,66,155,83,134,95,336,94,286,97,216,95,336,97,216,110,330,110,330,97,216,102,256,110,330,102,256,114,263,78,338,61,336,66,310,130,310,122,321,123,271,130,310,123,271,129,279,130,310,129,279,131,288,130,310,131,288,132,296,122,321,110,330,114,263,122,321,114,263,123,271,102,254,102,256,97,216,102,254,97,216,103,205,102,254,103,205,118,248,92,276,87,267,88,225,92,276,88,225,97,216,92,276,97,216,94,286,78,259,76,230,88,225,78,259,88,225,87,267,141,177,146,200,144,214,141,177,144,214,139,227,141,177,139,227,130,239,141,177,130,239,129,159,103,179,109,144,105,190,105,190,109,144,118,248,118,248,109,144,129,159,118,248,129,159,130,239,105,190,118,248,103,205,40,169,36,171,37,132,40,169,37,132,52,131,40,169,52,131,46,165,37,132,36,171,32,173,37,132,32,173,28,174,37,132,28,174,25,175,37,132,25,175,25,136,19,174,14,172,15,142,19,174,15,142,25,136,19,174,25,136,25,175,10,169,8,165,9,150,10,169,9,150,15,142,10,169,15,142,14,172,52,231,46,244,46,230,9,150,8,165,7,159,95,336,93,295,94,286, +46,253,66,253,143,302,149,306,153,310,156,314,158,318,158,329,155,333,152,336,147,338,141,339,133,337,129,335,125,332,120,328,215,225,171,225,171,57,164,46,155,38,144,31,131,27,116,26,102,28,90,34,81,45,76,59,74,78,74,225,30,225,30,27, +141,339,143,302,147,338,147,338,143,302,149,306,147,338,149,306,152,336,152,336,149,306,153,310,152,336,153,310,155,333,155,333,153,310,156,314,155,333,156,314,158,329,158,329,156,314,158,318,158,329,158,318,158,323,143,302,141,339,137,338,143,302,137,338,133,337,143,302,133,337,129,335,143,302,129,335,125,332,143,302,125,332,120,328,143,302,120,328,66,253,66,253,120,328,46,253, +215,225,171,225,171,57,164,46,155,38,144,31,131,27,116,26,102,28,90,34,81,45,76,59,74,78,74,225,30,225,30,27,29,14,26,-5,22,-28,19,-51,18,-69,19,-82,22,-93,26,-101,32,-106,40,-108,48,-106,55,-102,60,-94,63,-83,64,-69,62,-51,58,-29,52,-6,48,14,46,32,55,18,66,8,77,1,91,-3,107,-4,123,-2,137,2,150,11,162,24,172,40,174,40,176,24,182,11,191,2,201,-2,211,-4,222,-3,231,0,239,4,247,12,256,23,256,28,249,22,244,18,239,15,235,14,230,13,224,15,220,19,217,26,215,36,215,48,266,-76,266,-65,247,-62,234,-58,227,-50,223,-38,222,-20,222,271,223,290,227,304,234,313,247,318,266,321,266,331,134,331,95,327,66,316,46,297,34,270,30,235,34,199,46,172,66,154,93,142,127,137,127,-14,126,-35,123,-49,115,-58,102,-63,83,-65,83,-76,160,-76,160,320,189,320,189,-76,16383,16383,127,147,105,153,88,164,77,182,70,206,68,237,70,266,75,289,86,305,103,315,127,320,90,127,89,135,85,143,79,149,71,154,63,155,54,154,46,150,40,144,37,136,35,127,37,118,40,111,46,105,54,101,63,99,71,101,79,105,85,111,89,118, +46,32,46,32,46,32,46,32,74,225,30,225,46,32,30,225,32,-106,46,32,32,-106,40,-108,46,32,40,-108,48,-106,76,59,74,78,77,1,77,1,74,78,66,8,66,8,74,78,74,225,66,8,74,225,55,18,55,18,74,225,46,32,30,225,30,27,32,-106,32,-106,30,27,29,14,32,-106,29,14,26,-101,26,-101,29,14,26,-5,26,-101,26,-5,22,-28,18,-69,19,-82,19,-51,19,-51,19,-82,22,-93,19,-51,22,-93,22,-28,22,-28,22,-93,26,-101,171,225,171,57,172,40,172,40,171,57,164,46,172,40,164,46,162,24,162,24,164,46,155,38,162,24,155,38,150,11,150,11,155,38,144,31,150,11,144,31,137,2,137,2,144,31,131,27,137,2,131,27,123,-2,123,-2,131,27,116,26,123,-2,116,26,107,-4,107,-4,116,26,102,28,107,-4,102,28,91,-3,91,-3,102,28,90,34,91,-3,90,34,81,45,81,45,76,59,77,1,81,45,77,1,91,-3,215,225,171,225,172,40,215,225,172,40,174,40,215,225,174,40,176,24,215,225,176,24,182,11,215,225,182,11,191,2,215,225,191,2,201,-2,215,225,201,-2,211,-4,215,225,211,-4,215,48,249,22,244,18,247,12,247,12,244,18,239,15,247,12,239,15,239,4,239,4,239,15,235,14,239,4,235,14,231,0,231,0,235,14,230,13,249,22,247,12,256,23,249,22,256,23,256,28,224,15,220,19,222,-3,224,15,222,-3,231,0,224,15,231,0,230,13,215,48,211,-4,215,36,215,36,211,-4,222,-3,215,36,222,-3,217,26,217,26,222,-3,220,19,48,14,48,-106,52,-6,52,-6,48,-106,55,-102,52,-6,55,-102,58,-29,58,-29,55,-102,60,-94,58,-29,60,-94,62,-51,62,-51,60,-94,63,-83,62,-51,63,-83,64,-69,46,32,48,-106,48,14, +266,-76,266,-65,247,-62,234,-58,227,-50,223,-38,222,-20,222,271,223,290,227,304,234,313,247,318,266,321,266,331,134,331,95,327,66,316,46,297,34,270,30,235,34,199,46,172,66,154,93,142,127,137,127,-14,126,-35,123,-49,115,-58,102,-63,83,-65,83,-76,160,-76,160,320,189,320,189,-76,16383,16383,127,147,105,153,88,164,77,182,70,206,68,237,70,266,75,289,86,305,103,315,127,320,90,127,89,135,85,143,79,149,71,154,63,155,54,154,46,150,40,144,37,136,35,127,37,118,40,111,46,105,54,101,63,99,71,101,79,105,85,111,89,118,90,127,87,0,70,0,49,-49,52,-51,55,-50,57,-50,60,-49,66,-49,76,-50,84,-52,89,-55,92,-60,93,-67,92,-74,88,-81,83,-85,75,-88,65,-89,59,-89,47,-87,40,-86,33,-83,26,-98,35,-102,51,-106,59,-106,68,-107, +123,-49,115,-58,160,-76,160,-76,115,-58,102,-63,160,-76,102,-63,83,-65,134,331,95,327,103,315,134,331,103,315,127,320,134,331,127,320,127,137,134,331,127,137,160,-76,134,331,160,-76,160,320,134,331,160,320,266,331,127,320,127,147,127,137,105,153,88,164,93,142,93,142,88,164,77,182,93,142,77,182,66,154,66,154,77,182,70,206,66,154,70,206,68,237,68,237,70,266,66,316,66,316,70,266,75,289,66,316,75,289,95,327,95,327,75,289,86,305,95,327,86,305,103,315,66,316,46,297,46,172,66,316,46,172,66,154,66,316,66,154,68,237,247,318,266,321,266,331,247,318,266,331,234,313,234,313,266,331,189,320,234,313,189,320,227,304,227,304,189,320,223,290,234,-58,227,-50,189,-76,189,-76,227,-50,223,-38,189,-76,223,-38,189,320,189,320,223,-38,222,-20,189,320,222,-20,222,271,160,-76,127,137,127,-14,160,-76,127,-14,126,-35,160,-76,126,-35,123,-49,266,-76,266,-65,247,-62,266,-76,247,-62,234,-58,266,-76,234,-58,189,-76,105,153,93,142,127,137,105,153,127,137,127,147,34,199,46,172,46,297,34,199,46,297,34,270,34,199,34,270,30,235,160,-76,83,-65,83,-76,266,331,160,320,189,320,223,290,189,320,222,271, +90,127,89,135,85,143,79,149,71,154,63,155,54,154,46,150,40,144,37,136,35,127,37,118,40,111,46,105,54,101,63,99,71,101,79,105,85,111,89,118,90,127,87,0,70,0,49,-49,52,-51,55,-50,57,-50,60,-49,66,-49,76,-50,84,-52,89,-55,92,-60,93,-67,92,-74,88,-81,83,-85,75,-88,65,-89,59,-89,47,-87,40,-86, +35,127,37,118,37,136,37,136,37,118,40,111,37,136,40,111,40,144,40,144,40,111,46,105,40,144,46,105,46,150,46,150,46,105,54,101,46,150,54,101,54,154,54,154,54,101,62,99,54,154,62,99,63,155,63,155,62,99,71,101,63,155,71,101,71,154,71,154,71,101,79,105,71,154,79,105,79,149,79,149,79,105,85,111,79,149,85,111,85,143,85,143,85,111,89,118,85,143,89,118,89,135,89,135,89,118,90,127, +87,0,70,0,49,-49,52,-51,55,-50,57,-50,60,-49,66,-49,76,-50,84,-52,89,-55,92,-60,93,-67,92,-74,88,-81,83,-85,75,-88,65,-89,59,-89,47,-87,40,-86,33,-83,26,-98,35,-102,51,-106,59,-106,68,-107,89,-105,107,-99,120,-91,128,-79,131,-64,129,-52,123,-43,114,-36,102,-32,88,-30,80,-30,77,-31,75,-31,124,135,124,147,113,148,105,150,99,154,96,159,95,166,95,336,89,338,30,310,30,299,36,302,41,304,45,305,52,305,54,301,55,297,55,157,52,153,47,150,40,148,28,147,28,135,152,271,148,293,139,312,123,326,103,335,79,338,54,335,33,325,17,310,6,291,3,267,6,244,16,225,32,210,52,200,75,197,100,201, +59,-106,68,-107,59,-89,59,-89,68,-107,65,-89,75,-88,65,-89,68,-107,75,-88,68,-107,89,-105,57,-50,60,-49,70,0,70,0,60,-49,63,-49,70,0,63,-49,66,-49,66,-49,76,-50,70,0,70,0,76,-50,75,-31,70,0,75,-31,87,0,70,0,49,-49,52,-51,70,0,52,-51,55,-50,70,0,55,-50,57,-50,131,-64,129,-52,128,-79,128,-79,129,-52,123,-43,128,-79,123,-43,120,-91,120,-91,123,-43,114,-36,120,-91,114,-36,107,-99,107,-99,114,-36,102,-32,107,-99,102,-32,93,-67,93,-67,102,-32,92,-60,89,-55,92,-60,102,-32,89,-55,102,-32,88,-30,89,-55,88,-30,85,-30,89,-55,85,-30,84,-52,84,-52,85,-30,82,-30,84,-52,82,-30,80,-30,84,-52,80,-30,77,-31,84,-52,77,-31,76,-50,107,-99,93,-67,92,-74,107,-99,92,-74,89,-105,89,-105,92,-74,88,-81,89,-105,88,-81,83,-85,33,-83,35,-102,40,-86,40,-86,35,-102,43,-104,40,-86,43,-104,47,-87,47,-87,43,-104,51,-106,47,-87,51,-106,53,-88,53,-88,51,-106,59,-106,53,-88,59,-106,59,-89,35,-102,33,-83,26,-98,75,-88,89,-105,83,-85,75,-31,76,-50,77,-31, +124,135,124,147,113,148,105,150,99,154,96,159,95,166,95,336,89,338,30,310,30,299,36,302,41,304,45,305,52,305,54,301,55,297,55,157,52,153,47,150,40,148,28,147,28,135,152,271,148,293,139,312,123,326,103,335,79,338,54,335,33,325,17,310,6,291,3,267,6,244,16,225,32,210,52,200,75,197,100,201,121,211,138,227,148,247,152,271,16383,16383,116,258, +52,153,47,150,124,135,124,135,47,150,40,148,124,135,40,148,28,147,41,304,45,305,89,338,89,338,45,305,48,305,89,338,48,305,50,305,50,305,52,305,89,338,89,338,52,305,53,303,89,338,53,303,54,301,113,148,105,150,124,135,124,135,105,150,99,154,124,135,99,154,55,164,55,164,99,154,96,159,55,164,96,159,55,291,55,297,55,291,89,338,55,297,89,338,54,301,36,302,41,304,89,338,36,302,89,338,30,310,36,302,30,310,30,299,95,166,95,336,89,338,95,166,89,338,55,291,95,166,55,291,96,159,55,157,52,153,124,135,55,157,124,135,55,164,124,135,28,147,28,135,113,148,124,135,124,147, +152,271,148,293,139,312,123,326,103,335,79,338,54,335,33,325,17,310,6,291,3,267,6,244,16,225,32,210,52,200,75,197,100,201,121,211,138,227,148,247,152,271,16383,16383,116,258,114,242,110,230,102,221,93,216,80,214,73,214,66,216,56,224,52,230,44,250,42,261,40,273,40,285,41,297,46,307,53,315,63,320,74,321,88,318,99,310,108,297,114,279,116,258,229,111,189,147,174,161,143,192,130,204,124,208,122,208,121,207,119,206,118,204,118,203,119,199,122,193,127,185,134,176,143,165,150,155,158,145,167,134,176,122,185,111,143,58,134,47,127,38,122,31,119,25,118,22,118,19,119,18,121,17,123,17,130,21,142,32,158,46,174,61,189,75,16383,16383,132,111,92,147,62,177,46,192,34,204,27,208,26,208,24,207,23,206, +44,250,52,200,48,240,48,240,52,200,52,230,56,224,52,230,52,200,56,224,52,200,75,197,42,261,40,273,33,325,42,261,33,325,32,210,42,261,32,210,52,200,42,261,52,200,44,250,33,325,40,285,41,297,33,325,41,297,54,335,54,335,41,297,46,307,54,335,46,307,53,315,3,267,6,244,6,291,6,291,6,244,16,225,6,291,16,225,17,310,17,310,16,225,32,210,17,310,32,210,33,325,103,335,79,338,88,318,88,318,79,338,74,321,63,320,74,321,79,338,63,320,79,338,54,335,114,242,110,230,121,211,121,211,110,230,102,221,121,211,102,221,100,201,100,201,102,221,93,216,100,201,93,216,80,214,80,214,73,214,75,197,75,197,73,214,66,216,75,197,66,216,61,220,152,271,148,293,148,247,148,247,148,293,139,312,148,247,139,312,138,227,138,227,139,312,123,326,138,227,123,326,121,211,121,211,123,326,116,258,88,318,99,310,103,335,103,335,99,310,108,297,103,335,108,297,123,326,123,326,108,297,114,279,123,326,114,279,116,258,80,214,75,197,100,201,54,335,53,315,63,320,114,242,121,211,116,258,56,224,75,197,61,220,33,325,40,273,40,285, +229,111,189,147,174,161,143,192,130,204,124,208,122,208,121,207,119,206,118,204,118,203,119,199,122,193,127,185,134,176,143,165,150,155,158,145,167,134,176,122,185,111,143,58,134,47,127,38,122,31,119,25,118,22,118,19,119,18,121,17,123,17,130,21,142,32,158,46,174,61,189,75,16383,16383,132,111,92,147,62,177,46,192,34,204,27,208,26,208,24,207,23,206,22,204,22,203,23,199,26,193,31,185,38,176,46,165,53,155,61,145,70,134,79,122,89,111,46,58,38,47,31,38,26,31,23,25,22,22,22,19,23,18,25,17,27,17,33,21,45,32,61,46,77,61,92,75,357,45,357,74,329,74,329,203,305,203,204,70,204,45,294,45,294,0,329,0,329,45,16383,16383,294,74,227,74,294,163,16383,16383,316,338,293,338,66,-6,91,-6,16383,16383,112,135,112,147,100,148,92,150,87,154,84,159,83,166,83,336,76,338,22,310,22,299,29,302,34,304,38,305,45,305,47,301,47,157,44,153,40,150,32,148,21,147,21,135,371,42,362,46,357,40,352,36,346,34,340,33,333,32,276,32,318,73,335,91,347,106,355,120,360,134,361,148,358,166,350,181,337,193,320,200,298,203,275,201,257,194,243,182,232,165,223,143,235,136,243,149,251,159,259,167,269,171,280,173, +92,75,132,111,92,147,92,75,92,147,89,111,92,75,89,111,77,61,53,155,61,145,62,177,62,177,61,145,70,134,62,177,70,134,78,161,78,161,70,134,79,122,78,161,79,122,92,147,92,147,79,122,89,111,53,155,62,177,46,165,46,165,62,177,46,192,46,165,46,192,38,176,38,176,46,192,34,204,38,176,34,204,31,185,31,185,34,204,27,208,31,185,27,208,26,193,26,193,27,208,26,208,26,193,26,208,24,207,23,206,22,204,23,199,23,206,23,199,26,193,23,206,26,193,24,207,189,75,229,111,189,147,189,75,189,147,185,111,189,75,185,111,174,61,150,155,158,145,158,177,158,177,158,145,167,134,158,177,167,134,174,161,174,161,167,134,176,122,174,161,176,122,189,147,189,147,176,122,185,111,150,155,158,177,143,165,143,165,158,177,143,192,143,165,143,192,134,176,134,176,143,192,130,204,134,176,130,204,127,185,127,185,130,204,124,208,127,185,124,208,122,208,122,193,127,185,122,208,122,193,122,208,121,207,122,193,121,207,119,206,122,193,119,206,119,199,118,204,118,203,119,199,118,204,119,199,119,206,119,18,121,17,122,31,122,31,121,17,123,17,122,31,123,17,127,38,127,38,123,17,130,21,127,38,130,21,134,47,134,47,130,21,142,32,134,47,142,32,143,58,143,58,142,32,158,46,143,58,158,46,185,111,185,111,158,46,174,61,119,25,118,22,118,20,119,25,118,20,118,19,119,25,118,19,119,18,119,25,119,18,122,31,23,18,25,17,26,31,26,31,25,17,27,17,26,31,27,17,31,38,31,38,27,17,33,21,31,38,33,21,38,47,38,47,33,21,45,32,38,47,45,32,46,58,46,58,45,32,61,46,46,58,61,46,89,111,89,111,61,46,77,61,23,25,22,22,22,20,23,25,22,20,22,19,23,25,22,19,23,18,23,25,23,18,26,31,23,199,22,204,22,203, +357,45,357,74,329,74,329,203,305,203,204,70,204,45,294,45,294,0,329,0,329,45,16383,16383,294,74,227,74,294,163,16383,16383,316,338,293,338,66,-6,91,-6,16383,16383,112,135,112,147,100,148,92,150,87,154,84,159,83,166,83,336,76,338,22,310,22,299,29,302,34,304,38,305,45,305,47,301,47,157,44,153,40,150,32,148,21,147,21,135,371,42,362,46,357,40,352,36,346,34,340,33,333,32,276,32,318,73,335,91,347,106,355,120,360,134,361,148,358,166,350,181,337,193,320,200,298,203,275,201,257,194,243,182,232,165,223,143,235,136,243,149,251,159,259,167,269,171,280,173,291,171,301,166,308,158,313,147,315,135,313,125,308,112,301,98,290,82,276,66,225,12,225,0,351,0, +204,45,294,45,204,70,204,70,294,45,227,74,204,70,227,74,305,203,305,203,227,74,294,163,305,203,294,163,329,0,329,0,294,163,294,74,329,0,294,74,294,45,294,45,294,74,227,74,305,203,329,0,329,203,329,74,329,45,357,45,329,74,357,45,357,74,293,338,66,-6,91,-6,293,338,91,-6,316,338,44,153,40,150,112,135,112,135,40,150,32,148,112,135,32,148,21,147,34,304,38,305,76,338,76,338,38,305,41,305,76,338,41,305,43,305,43,305,45,305,76,338,76,338,45,305,46,303,76,338,46,303,47,301,100,148,92,150,112,135,112,135,92,150,87,154,112,135,87,154,47,164,47,164,87,154,84,159,47,164,84,159,47,291,47,297,47,291,76,338,47,297,76,338,47,301,29,302,34,304,76,338,29,302,76,338,22,310,29,302,22,310,22,299,83,166,83,336,76,338,83,166,76,338,47,291,83,166,47,291,84,159,47,157,44,153,112,135,47,157,112,135,47,164,112,135,21,147,21,135,100,148,112,135,112,147,329,0,294,45,294,0, +371,42,362,46,357,40,352,36,346,34,340,33,333,32,276,32,318,73,335,91,347,106,355,120,360,134,361,148,358,166,350,181,337,193,320,200,298,203,275,201,257,194,243,182,232,165,223,143,235,136,243,149,251,159,259,167,269,171,280,173,291,171,301,166,308,158,313,147,315,135,313,125,308,112,301,98,290,82,276,66,225,12,225,0,351,0,16383,16383,297,338,275,338,48,-6,73,-6,16383,16383,108,135,108,147,97,148,89,150,84,154,81,159,80,166,80,336,73,338,19,310,19,299,26,302,31,304,35,305,42,305,44,301,44,297,45,291,45,164,44,157,41,153,37,150,29,148,18,147,18,135,359,45,359,74,331,74,331,203,308,203,206,70,206,45,296,45,296,0,331,0,331,45,16383,16383,296,74,229,74,296,163,16383,16383,319,338,296,338,69,-6,94,-6,16383,16383,102,256,114,263,123,271,129,279,131,288,132,296,130,310,122,321,110,330,95,336,78,338,61,336,46,331,33,322,22,309,11,291,23,281,31,293,39,301,47,306,56,309,66,310,76,309,83,306,89,301,93,295,94,286,92,276,87,267,78,259,65,252,46,244,46,230,52,231,59,231,60,232,76,230,88,225,97,216,103,205,105,190,103,179,99,169,92,162,82,157,71,155,66,155,61,156,57,158,52,161,40,169,32,173,28,174, +308,112,301,98,318,73,318,73,301,98,290,82,318,73,290,82,276,66,276,66,225,12,276,32,276,32,225,12,351,0,276,32,351,0,333,32,340,33,333,32,351,0,340,33,351,0,346,34,346,34,351,0,352,36,235,136,243,149,243,182,243,182,243,149,251,159,243,182,251,159,257,194,257,194,251,159,259,167,257,194,259,167,275,201,275,201,259,167,269,171,275,201,269,171,280,173,280,173,291,171,298,203,298,203,291,171,301,166,298,203,301,166,320,200,320,200,301,166,308,158,320,200,308,158,313,147,232,165,223,143,235,136,232,165,235,136,243,182,371,42,362,46,357,40,371,42,357,40,352,36,371,42,352,36,351,0,275,338,48,-6,73,-6,275,338,73,-6,297,338,41,153,37,150,108,135,108,135,37,150,29,148,108,135,29,148,18,147,31,304,35,305,73,338,73,338,35,305,38,305,73,338,38,305,40,305,40,305,42,305,73,338,73,338,42,305,43,303,73,338,43,303,44,301,97,148,89,150,108,135,108,135,89,150,84,154,108,135,84,154,45,164,45,164,84,154,81,159,45,164,81,159,45,291,44,297,45,291,73,338,44,297,73,338,44,301,26,302,31,304,73,338,26,302,73,338,19,310,26,302,19,310,19,299,80,166,80,336,73,338,80,166,73,338,45,291,80,166,45,291,81,159,313,125,318,73,315,135,315,135,318,73,320,200,320,200,318,73,335,91,320,200,335,91,337,193,337,193,335,91,347,106,337,193,347,106,350,181,350,181,347,106,355,120,350,181,355,120,358,166,358,166,355,120,360,134,358,166,360,134,361,148,320,200,313,147,315,135,298,203,275,201,280,173,276,66,276,32,318,73,44,157,41,153,108,135,44,157,108,135,45,164,108,135,18,147,18,135,97,148,108,135,108,147,308,112,318,73,313,125,351,0,225,12,225,0, +359,45,359,74,331,74,331,203,308,203,206,70,206,45,296,45,296,0,331,0,331,45,16383,16383,296,74,229,74,296,163,16383,16383,319,338,296,338,69,-6,94,-6,16383,16383,102,256,114,263,123,271,129,279,131,288,132,296,130,310,122,321,110,330,95,336,78,338,61,336,46,331,33,322,22,309,11,291,23,281,31,293,39,301,47,306,56,309,66,310,76,309,83,306,89,301,93,295,94,286,92,276,87,267,78,259,65,252,46,244,46,230,52,231,59,231,60,232,76,230,88,225,97,216,103,205,105,190,103,179,99,169,92,162,82,157,71,155,66,155,61,156,57,158,52,161,40,169,32,173,28,174,25,175,19,174,14,172,10,169,8,165,7,159,9,150,15,142,25,136,37,132,52,131,83,134,109,144,129,159,141,177,146,200,144,214,139,227,130,239,118,248,102,254,130,208,129,216,125,223,119,229,112,232,103,233,95,232,87,229,82,223,78,217,77,208,78,199,82,192,87,186,95,182,103,180,112,182,119,186,125,192,129,199,130,208,16383,16383,100,147,96,128,91,112,85,97,77,84,68,70,46,42,31,20,22,2,17,-13,15,-30,16,-42,18,-52,22,-62,27,-71,33,-79,45,-89,58,-97,74,-103,90,-107,107,-108,133,-104,155,-94,173,-79,184,-59,188,-35,187,-24,184,-16,179,-10,173,-6,164,-5,157,-5,151,-8,147,-12,144,-18,143,-25,145,-33,147,-37,150,-42,154,-46,160,-54,161,-57,162,-59,162,-62,160,-71,153,-80,142,-87,130,-91,116,-93,98,-90,83,-81,71,-69,64,-52,61,-34,62,-19,64,-4,67,11,72,27,79,44,93,75,101,99,106,118,108,133,108,147,225,378,153,453,148,457,144,460,140,462,132,464,125,463,120,461,117,458, +206,45,296,45,206,70,206,70,296,45,229,74,206,70,229,74,308,203,308,203,229,74,296,163,308,203,296,163,331,0,331,0,296,163,296,74,331,0,296,74,296,45,296,45,296,74,229,74,308,203,331,0,331,203,331,74,331,45,359,45,331,74,359,45,359,74,296,338,69,-6,94,-6,296,338,94,-6,319,338,66,155,61,156,83,134,83,134,61,156,57,158,83,134,57,158,52,131,52,131,57,158,52,161,52,131,52,161,46,165,56,231,59,231,65,252,65,252,59,231,60,232,60,232,76,230,65,252,65,252,76,230,78,259,65,252,46,244,52,231,65,252,52,231,56,231,23,281,31,293,33,322,33,322,31,293,39,301,33,322,39,301,46,331,46,331,39,301,47,306,46,331,47,306,61,336,61,336,47,306,56,309,61,336,56,309,66,310,66,310,76,309,78,338,78,338,76,309,83,306,78,338,83,306,95,336,95,336,83,306,89,301,95,336,89,301,93,295,22,309,11,291,23,281,22,309,23,281,33,322,103,179,99,169,109,144,109,144,99,169,92,162,109,144,92,162,83,134,83,134,92,162,82,157,83,134,82,157,71,155,71,155,66,155,83,134,95,336,94,286,97,216,95,336,97,216,110,330,110,330,97,216,102,256,110,330,102,256,114,263,78,338,61,336,66,310,130,310,122,321,123,271,130,310,123,271,129,279,130,310,129,279,131,288,130,310,131,288,132,296,122,321,110,330,114,263,122,321,114,263,123,271,102,254,102,256,97,216,102,254,97,216,103,205,102,254,103,205,118,248,92,276,87,267,88,225,92,276,88,225,97,216,92,276,97,216,94,286,78,259,76,230,88,225,78,259,88,225,87,267,141,177,146,200,144,214,141,177,144,214,139,227,141,177,139,227,130,239,141,177,130,239,129,159,103,179,109,144,105,190,105,190,109,144,118,248,118,248,109,144,129,159,118,248,129,159,130,239,105,190,118,248,103,205,40,169,36,171,37,132,40,169,37,132,52,131,40,169,52,131,46,165,37,132,36,171,32,173,37,132,32,173,28,174,37,132,28,174,25,175,37,132,25,175,25,136,19,174,14,172,15,142,19,174,15,142,25,136,19,174,25,136,25,175,10,169,8,165,9,150,10,169,9,150,15,142,10,169,15,142,14,172,52,231,46,244,46,230,9,150,8,165,7,159,95,336,93,295,94,286,331,0,296,45,296,0, +130,208,129,216,125,223,119,229,112,232,103,233,95,232,87,229,82,223,78,217,77,208,78,199,82,192,87,186,95,182,103,180,112,182,119,186,125,192,129,199,130,208,16383,16383,100,147,96,128,91,112,85,97,77,84,68,70,46,42,31,20,22,2,17,-13,15,-30,16,-42,18,-52,22,-62,27,-71,33,-79,45,-89,58,-97,74,-103,90,-107,107,-108,133,-104,155,-94,173,-79,184,-59,188,-35,187,-24,184,-16,179,-10,173,-6,164,-5,157,-5,151,-8,147,-12,144,-18,143,-25,145,-33,147,-37,150,-42,154,-46,160,-54,161,-57,162,-59,162,-62,160,-71,153,-80,142,-87,130,-91,116,-93,98,-90,83,-81,71,-69,64,-52,61,-34,62,-19,64,-4,67,11,72,27,79,44,93,75,101,99,106,118,108,133,108,147,225,378,153,453,148,457,144,460,140,462,132,464,125,463,120,461,117,458,114,454,113,448,114,443,116,439,119,434,123,430,128,426,205,378,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,138,378,158,378,235,427,245,435,248,439,249,443,250,448,249,454,247,458,243,461,239,463,233,464,228,463,224,462,221,460,216,457,211,453,16383,16383,353,0,353,9,340,12, +103,180,112,182,112,232,112,232,112,182,119,186,112,232,119,186,119,229,119,229,119,186,125,192,119,229,125,192,125,223,125,223,125,192,129,199,125,223,129,199,129,216,129,216,129,199,130,208,78,217,78,199,82,223,82,223,78,199,82,192,82,223,82,192,87,229,87,229,82,192,87,186,87,229,87,186,95,232,95,232,87,186,95,182,95,232,95,182,103,233,103,233,95,182,103,180,103,233,103,180,112,232,72,27,79,44,77,84,72,27,77,84,68,70,68,70,46,42,62,-19,62,-19,46,42,61,-34,64,-52,61,-34,58,-97,64,-52,58,-97,74,-103,68,70,62,-19,64,-4,68,70,64,-4,67,11,68,70,67,11,72,27,33,-79,45,-89,46,42,46,42,45,-89,58,-97,46,42,58,-97,61,-34,31,20,22,2,22,-62,31,20,22,-62,27,-71,31,20,27,-71,33,-79,31,20,33,-79,46,42,15,-30,16,-42,17,-13,17,-13,16,-42,18,-52,17,-13,18,-52,22,2,22,2,18,-52,22,-62,108,147,100,147,101,99,108,147,101,99,106,118,108,147,106,118,108,133,96,128,91,112,93,75,96,128,93,75,101,99,96,128,101,99,100,147,85,97,77,84,79,44,85,97,79,44,93,75,85,97,93,75,91,112,160,-71,153,-80,155,-94,155,-94,153,-80,142,-87,155,-94,142,-87,133,-104,133,-104,142,-87,130,-91,133,-104,130,-91,116,-93,116,-93,98,-90,107,-108,107,-108,98,-90,90,-107,83,-81,71,-69,74,-103,83,-81,74,-103,90,-107,83,-81,90,-107,98,-90,147,-37,150,-42,151,-8,151,-8,150,-42,154,-46,151,-8,154,-46,157,-5,157,-5,154,-46,157,-50,157,-5,157,-50,164,-5,164,-5,157,-50,160,-54,164,-5,160,-54,161,-57,143,-25,144,-29,144,-18,144,-18,144,-29,145,-33,144,-18,145,-33,147,-12,147,-12,145,-33,147,-37,147,-12,147,-37,151,-8,173,-6,173,-79,179,-10,179,-10,173,-79,184,-59,179,-10,184,-59,184,-16,184,-16,184,-59,188,-35,184,-16,188,-35,187,-24,155,-94,173,-79,160,-71,160,-71,173,-79,162,-62,164,-5,162,-62,173,-79,164,-5,173,-79,173,-6,116,-93,107,-108,133,-104,164,-5,161,-57,162,-59,164,-5,162,-59,162,-62,64,-52,74,-103,71,-69,78,199,78,217,77,208, +225,378,153,453,148,457,144,460,140,462,132,464,125,463,120,461,117,458,114,454,113,448,114,443,116,439,119,434,123,430,128,426,205,378,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,138,378,158,378,235,427,245,435,248,439,249,443,250,448,249,454,247,458,243,461,239,463,233,464,228,463,224,462,221,460,216,457,211,453,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266, +205,378,225,378,153,453,205,378,153,453,148,457,205,378,148,457,144,460,205,378,144,460,140,462,205,378,140,462,136,463,205,378,136,463,132,464,205,378,132,464,128,426,113,448,114,443,114,454,114,454,114,443,116,439,114,454,116,439,117,458,117,458,116,439,119,434,117,458,119,434,120,461,120,461,119,434,123,430,120,461,123,430,125,463,125,463,123,430,128,426,125,463,128,426,132,464,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0, +138,378,158,378,235,427,245,435,248,439,249,443,250,448,249,454,247,458,243,461,239,463,233,464,228,463,224,462,221,460,216,457,211,453,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,257,378,194,462,163,462,101,378,118,378,179,430,239,378,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,248,444,243,434,238,427,233,422,227,420,221,419,216,419,211,420,206,422,200,424, +233,464,235,427,239,463,239,463,235,427,240,431,239,463,240,431,243,461,243,461,240,431,245,435,243,461,245,435,247,458,247,458,245,435,248,439,247,458,248,439,249,454,249,454,248,439,249,443,249,454,249,443,250,448,235,427,233,464,228,463,235,427,228,463,224,462,235,427,224,462,221,460,235,427,221,460,216,457,235,427,216,457,211,453,235,427,211,453,158,378,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0,158,378,211,453,138,378, +257,378,194,462,163,462,101,378,118,378,179,430,239,378,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,248,444,243,434,238,427,233,422,227,420,221,419,216,419,211,420,206,422,200,424,195,426,182,432,175,436,161,440,154,441,147,441,133,439,121,433,111,423,103,409,97,391,112,391,115,399,120,406,125,410,131,413,137,414,141,414,149,412,157,408,169,403,180,398,189,394,196,392,202,391,209,391,224,393,237,399,247,409,255,424,262,444,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20, +101,378,118,378,163,462,163,462,118,378,179,430,163,462,179,430,194,462,194,462,179,430,239,378,194,462,239,378,257,378,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0, +248,444,243,434,238,427,233,422,227,420,221,419,216,419,211,420,206,422,200,424,195,426,182,432,175,436,161,440,154,441,147,441,133,439,121,433,111,423,103,409,97,391,112,391,115,399,120,406,125,410,131,413,137,414,141,414,149,412,157,408,169,403,180,398,189,394,196,392,202,391,209,391,224,393,237,399,247,409,255,424,262,444,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,254,411,253,419,249,426,244,431,237,435,229,436,221,435,214,431,209,426,206,419,204,411,205,403,209,397,214,391,221,388,228,387,236,388,244,391,249,397,253,403,254,411,16383,16383,155,411,153,419,150,426,144,431,137,435,129,436,122,435,115,431,110,426,106,419,105,411,106,403,110,397,115,391,121,388,129,387,137,388,144,391,150,397,153,403,155,411,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128, +115,399,120,406,121,433,121,433,120,406,125,410,121,433,125,410,133,439,133,439,125,410,131,413,133,439,131,413,137,414,137,414,141,414,147,441,147,441,141,414,145,413,147,441,145,413,149,412,112,391,115,399,121,433,112,391,121,433,111,423,112,391,111,423,103,409,112,391,103,409,97,391,147,441,149,412,154,441,154,441,149,412,153,410,154,441,153,410,157,408,157,408,169,403,161,440,161,440,169,403,168,438,147,441,133,439,137,414,161,440,154,441,157,408,168,438,169,403,175,436,175,436,169,403,180,398,175,436,180,398,182,432,182,432,180,398,189,394,182,432,189,394,195,426,195,426,189,394,196,392,195,426,196,392,200,424,200,424,196,392,202,391,200,424,202,391,206,422,206,422,202,391,209,391,206,422,209,391,211,420,211,420,209,391,224,393,211,420,224,393,216,419,216,419,224,393,221,419,227,420,221,419,224,393,227,420,224,393,237,399,248,444,243,434,247,409,248,444,247,409,255,424,248,444,255,424,262,444,238,427,233,422,237,399,238,427,237,399,247,409,238,427,247,409,243,434,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0,227,420,237,399,233,422, +254,411,253,419,249,426,244,431,237,435,229,436,221,435,214,431,209,426,206,419,204,411,205,403,209,397,214,391,221,388,228,387,236,388,244,391,249,397,253,403,254,411,16383,16383,155,411,153,419,150,426,144,431,137,435,129,436,122,435,115,431,110,426,106,419,105,411,106,403,110,397,115,391,121,388,129,387,137,388,144,391,150,397,153,403,155,411,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,229,430,227,446,220,460,209,471,196,478,180,480,164,478,151,471,140,460,133,447,130,431,132,415,139,401,150,391,163,384,179,381,195,384,209,391,220,401,227,415,229,430,16383,16383,213,431,211,420,206,411,199,404,190,400,179,398,169,400,160,404,153,411,148,420,147,431,148,441,153,450,160,457,169,462,179,464,190,462,199,457,206,450,211,441,213,431,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266, +204,411,205,403,206,419,206,419,205,403,209,397,206,419,209,397,209,426,209,426,209,397,214,391,209,426,214,391,214,431,214,431,214,391,221,388,214,431,221,388,221,435,221,435,221,388,228,387,221,435,228,387,229,436,229,436,228,387,236,388,229,436,236,388,237,435,237,435,236,388,244,391,237,435,244,391,244,431,244,431,244,391,249,397,244,431,249,397,249,426,249,426,249,397,253,403,249,426,253,403,253,419,253,419,253,403,254,411,105,411,106,403,106,419,106,419,106,403,110,397,106,419,110,397,110,426,110,426,110,397,115,391,110,426,115,391,115,431,115,431,115,391,121,388,115,431,121,388,122,435,122,435,121,388,129,387,122,435,129,387,129,436,129,436,129,387,137,388,129,436,137,388,137,435,137,435,137,388,144,391,137,435,144,391,144,431,144,431,144,391,150,397,144,431,150,397,150,426,150,426,150,397,153,403,150,426,153,403,153,419,153,419,153,403,155,411,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0, +229,430,227,446,220,460,209,471,196,478,180,480,164,478,151,471,140,460,133,447,130,431,132,415,139,401,150,391,163,384,179,381,195,384,209,391,220,401,227,415,229,430,16383,16383,213,431,211,420,206,411,199,404,190,400,179,398,169,400,160,404,153,411,148,420,147,431,148,441,153,450,160,457,169,462,179,464,190,462,199,457,206,450,211,441,213,431,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,431,84,420,84,404,56,389,37,372,26,349,20,320,19,268,19,257,22,252,26,249,34,248,47,248,165,319,165,337,163,350,158,360,149,366,135,370,114,381,114,381,232,370,232,367,211,359,197,346,189,326,184,300,183,248,183,248,295,249,301,251,306,253,310,257,312,262,313,305,313,341,312,367,308,382,299,392,283,397,261,408,261,408,331,126,331,126,321,143,320,155,318,164,315,169,310,171,305,171,302,170,300,168,294,166,291,44,49,36,33,28,23,21,16,11,12,0,9,0,0,99,0,99,9,87,11,77,13,70,16,66,20,65,24,66,33,71,48,80,68,93,95,111,130,199,130,199,56,198,39,195,27,189,18,179,13,164,11,155,9,155,0,410,0,16383,16383,199,150,120,150,199,309,307,65,285,47,264,32,242,23,220,17, +211,420,206,411,209,391,209,391,206,411,199,404,209,391,199,404,195,384,195,384,199,404,190,400,195,384,190,400,179,381,179,381,190,400,179,398,180,480,179,464,190,462,180,480,190,462,196,478,196,478,190,462,199,457,196,478,199,457,209,471,209,471,199,457,206,450,209,471,206,450,211,441,229,430,227,446,227,415,227,415,227,446,220,460,227,415,220,460,220,401,220,401,220,460,213,431,211,441,213,431,220,460,211,441,220,460,209,471,211,420,209,391,220,401,211,420,220,401,213,431,153,450,160,457,164,478,164,478,160,457,169,462,164,478,169,462,180,480,180,480,169,462,179,464,151,471,140,460,147,431,151,471,147,431,148,441,151,471,148,441,153,450,151,471,153,450,164,478,153,411,148,420,150,391,150,391,148,420,147,431,169,400,160,404,163,384,169,400,163,384,179,381,169,400,179,381,179,398,153,411,150,391,163,384,153,411,163,384,160,404,130,431,132,415,133,447,133,447,132,415,139,401,133,447,139,401,140,460,140,460,139,401,150,391,140,460,150,391,147,431,55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,246,11,242,10,353,0,353,0,242,10,235,10,353,0,235,10,226,9,259,21,258,18,353,0,353,0,258,18,256,16,353,0,256,16,253,14,253,14,250,12,353,0,353,0,250,12,246,11,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,23,259,21,353,0,260,23,353,0,261,26,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58,353,0,226,9,226,0, +431,84,420,84,404,56,389,37,372,26,349,20,320,19,268,19,257,22,252,26,249,34,248,47,248,165,319,165,337,163,350,158,360,149,366,135,370,114,381,114,381,232,370,232,367,211,359,197,346,189,326,184,300,183,248,183,248,295,249,301,251,306,253,310,257,312,262,313,305,313,341,312,367,308,382,299,392,283,397,261,408,261,408,331,126,331,126,321,143,320,155,318,164,315,169,310,171,305,171,302,170,300,168,294,166,291,44,49,36,33,28,23,21,16,11,12,0,9,0,0,99,0,99,9,87,11,77,13,70,16,66,20,65,24,66,33,71,48,80,68,93,95,111,130,199,130,199,56,198,39,195,27,189,18,179,13,164,11,155,9,155,0,410,0,16383,16383,199,150,120,150,199,309,307,65,285,47,264,32,242,23,220,17,196,15,175,17,155,21,137,29,120,40,105,54,93,72,84,94,77,118,73,145,72,173,77,222,93,262,118,292,151,311,191,318,221,313,249,300,272,280,289,255,299,225,310,225,305,338,295,338,293,332,285,324,280,322,275,321,271,322,268,322,263,323,259,325,254,326,240,330,225,334,210,336,196,338,181,338,160,337,140,333,120,327,101,319,84,308,59,287,40,262,25,233,17,200,14,165,16,135,21,107,30,82,43,60,58,41,73,27,90,15,109,6,129,0,151,-4,132,-49,136,-51,139,-50,141,-50,144,-49,150,-49,160,-50,168,-52,173,-55,175,-60,176,-67,175,-74,172,-81,166,-85,158,-88,149,-89,143,-89,131,-87,124,-86,117,-83,109,-98,118,-102,134,-106, +87,11,77,13,99,0,99,0,77,13,70,16,99,0,70,16,36,33,36,33,70,16,66,20,36,33,66,20,44,49,44,49,66,20,65,24,71,48,80,68,166,291,166,291,80,68,93,95,166,291,93,95,111,130,111,130,199,130,120,150,120,150,199,130,199,150,195,27,189,18,410,0,410,0,189,18,179,13,410,0,179,13,164,11,166,291,111,130,120,150,166,291,120,150,199,309,166,291,199,309,168,294,262,313,408,331,199,309,199,309,408,331,169,310,199,309,169,310,171,305,171,305,171,302,199,309,199,309,171,302,170,300,199,309,170,300,169,297,360,149,366,135,367,211,367,211,366,135,370,114,367,211,370,114,370,232,370,232,370,114,381,114,370,232,381,114,381,232,300,183,319,165,326,184,326,184,319,165,337,163,326,184,337,163,346,189,346,189,337,163,350,158,346,189,350,158,359,197,359,197,350,158,360,149,359,197,360,149,367,211,199,309,249,34,248,47,248,183,248,165,319,165,248,183,319,165,300,183,408,331,262,313,305,313,408,331,305,313,341,312,408,331,341,312,367,308,408,331,367,308,382,299,408,331,382,299,392,283,408,331,392,283,397,261,408,331,397,261,408,261,199,309,248,47,248,295,199,309,248,295,249,301,199,309,249,301,251,306,199,309,251,306,253,310,199,309,253,310,257,312,199,309,257,312,262,313,408,331,126,331,143,320,408,331,143,320,155,318,408,331,155,318,164,315,408,331,164,315,169,310,389,37,372,26,410,0,410,0,372,26,349,20,410,0,349,20,320,19,410,0,431,84,420,84,410,0,420,84,404,56,410,0,404,56,389,37,199,56,198,39,257,22,257,22,198,39,195,27,257,22,195,27,268,19,268,19,195,27,410,0,268,19,410,0,283,19,283,19,410,0,320,19,199,150,199,130,252,26,199,150,252,26,249,34,199,150,249,34,199,309,199,56,257,22,252,26,199,56,252,26,199,130,155,9,155,0,410,0,155,9,410,0,164,11,44,49,65,24,66,33,44,49,66,33,71,48,44,49,71,48,166,291,99,0,36,33,28,23,99,0,28,23,21,16,99,0,21,16,11,12,99,0,11,12,0,9,99,0,0,9,0,0,87,11,99,0,99,9,168,294,199,309,169,297,143,320,126,331,126,321, +307,65,285,47,264,32,242,23,220,17,196,15,175,17,155,21,137,29,120,40,105,54,93,72,84,94,77,118,73,145,72,173,77,222,93,262,118,292,151,311,191,318,221,313,249,300,272,280,289,255,299,225,310,225,305,338,295,338,293,332,285,324,280,322,275,321,271,322,268,322,263,323,259,325,254,326,240,330,225,334,210,336,196,338,181,338,160,337,140,333,120,327,101,319,84,308,59,287,40,262,25,233,17,200,14,165,16,135,21,107,30,82,43,60,58,41,73,27,90,15,109,6,129,0,151,-4,132,-49,136,-51,139,-50,141,-50,144,-49,150,-49,160,-50,168,-52,173,-55,175,-60,176,-67,175,-74,172,-81,166,-85,158,-88,149,-89,143,-89,131,-87,124,-86,117,-83,109,-98,118,-102,134,-106,142,-106,151,-107,173,-105,190,-99,203,-91,211,-79,214,-64,212,-52,206,-43,198,-36,186,-32,171,-30,163,-30,161,-31,158,-31,168,-6,180,-6,213,-4,244,3,272,16,297,34,316,56,201,378,128,453,124,457,119,460,115,462,107,464,101,463,96,461,92,458,90,454,89,448,89,443,91,439,94,434,104,426,181,378,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,123,378,142,378,219,427,225,431,229,435,232,439,234,443,234,454,231,458,228,461,223,463,217,464,209,462,205,460,201,457,196,453,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158, +84,94,77,118,90,15,90,15,77,118,73,145,90,15,73,145,73,27,73,27,73,145,72,173,59,287,72,173,84,308,158,-31,175,17,155,21,158,-31,155,21,151,-4,151,-4,155,21,137,29,151,-4,137,29,129,0,129,0,137,29,120,40,129,0,120,40,109,6,109,6,120,40,105,54,142,-106,151,-107,143,-89,143,-89,151,-107,149,-89,158,-88,149,-89,151,-107,158,-88,151,-107,173,-105,141,-50,144,-49,151,-4,151,-4,144,-49,147,-49,151,-4,147,-49,150,-49,150,-49,160,-50,151,-4,151,-4,132,-49,136,-51,151,-4,136,-51,139,-50,151,-4,139,-50,141,-50,196,15,178,-6,180,-6,196,15,180,-6,213,-4,196,15,175,17,175,-6,196,15,175,-6,178,-6,175,17,158,-31,168,-6,175,17,168,-6,171,-6,175,17,171,-6,173,-6,175,17,173,-6,175,-6,316,56,307,65,297,34,297,34,307,65,285,47,297,34,285,47,272,16,272,16,285,47,264,32,272,16,264,32,244,3,244,3,264,32,242,23,244,3,242,23,220,17,220,17,196,15,213,-4,220,17,213,-4,244,3,191,318,181,338,160,337,191,318,160,337,151,311,191,318,196,338,181,338,72,173,77,222,84,308,84,308,77,222,93,262,84,308,93,262,101,319,101,319,93,262,118,292,101,319,118,292,120,327,120,327,118,292,151,311,120,327,151,311,140,333,140,333,151,311,160,337,210,336,221,313,225,334,225,334,221,313,249,300,225,334,249,300,240,330,240,330,249,300,254,326,221,313,210,336,196,338,221,313,196,338,191,318,289,328,285,324,289,255,289,255,285,324,280,322,289,255,280,322,275,321,275,321,271,322,272,280,272,280,271,322,268,322,272,280,268,322,263,323,272,280,263,323,259,325,272,280,259,325,254,326,272,280,254,326,249,300,299,225,310,225,305,338,299,225,305,338,295,338,299,225,295,338,293,332,299,225,293,332,289,255,275,321,272,280,289,255,214,-64,212,-52,211,-79,211,-79,212,-52,206,-43,211,-79,206,-43,203,-91,203,-91,206,-43,198,-36,203,-91,198,-36,190,-99,190,-99,198,-36,186,-32,190,-99,186,-32,176,-67,176,-67,186,-32,175,-60,173,-55,175,-60,186,-32,173,-55,186,-32,171,-30,173,-55,171,-30,168,-30,173,-55,168,-30,168,-52,168,-52,168,-30,166,-30,168,-52,166,-30,163,-30,168,-52,163,-30,161,-31,168,-52,161,-31,160,-50,158,-31,151,-4,160,-50,158,-31,160,-50,161,-31,190,-99,176,-67,175,-74,190,-99,175,-74,173,-105,173,-105,175,-74,172,-81,173,-105,172,-81,166,-85,117,-83,118,-102,124,-86,124,-86,118,-102,126,-104,124,-86,126,-104,131,-87,131,-87,126,-104,134,-106,131,-87,134,-106,137,-88,137,-88,134,-106,142,-106,137,-88,142,-106,143,-89,93,72,84,94,90,15,93,72,90,15,109,6,93,72,109,6,105,54,59,287,40,262,43,60,59,287,43,60,58,41,59,287,58,41,73,27,59,287,73,27,72,173,14,165,16,135,17,200,17,200,16,135,21,107,17,200,21,107,25,233,25,233,21,107,30,82,25,233,30,82,40,262,40,262,30,82,43,60,118,-102,117,-83,109,-98,158,-88,173,-105,166,-85,289,328,289,255,293,332, +201,378,128,453,124,457,119,460,115,462,107,464,101,463,96,461,92,458,90,454,89,448,89,443,91,439,94,434,104,426,181,378,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,123,378,142,378,219,427,225,431,229,435,232,439,234,443,234,454,231,458,228,461,223,463,217,464,209,462,205,460,201,457,196,453,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0, +181,378,201,378,128,453,181,378,128,453,124,457,181,378,124,457,119,460,181,378,119,460,115,462,181,378,115,462,111,463,181,378,111,463,107,464,181,378,107,464,104,426,89,448,89,443,90,454,90,454,89,443,91,439,90,454,91,439,92,458,92,458,91,439,94,434,92,458,94,434,96,461,96,461,94,434,99,430,96,461,99,430,101,463,101,463,99,430,104,426,101,463,104,426,107,464,45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,49,294,50,275,106,310,49,294,106,310,45,307,45,307,106,310,111,312,45,307,111,312,271,331,271,331,111,312,118,312,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,271,331,118,312,184,312,271,331,184,312,213,311,271,331,213,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,271,331,6,331,25,320,271,331,25,320,38,315,271,331,38,315,45,307,255,38,234,26,276,0,276,0,234,26,206,20,276,0,206,20,169,18,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,255,38,276,0,169,18,151,18,276,0,151,18,132,19,276,0,132,19,117,21,276,0,117,21,45,24,276,0,6,9,6,0,25,320,6,331,6,321,176,184,176,164,198,162,233,232,244,115,244,232, +123,378,142,378,219,427,225,431,229,435,232,439,234,443,234,454,231,458,228,461,223,463,217,464,209,462,205,460,201,457,196,453,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,242,378,179,462,148,462,86,378,103,378,164,430,224,378,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,238,411,236,419,233,426,227,431,220,435,213,436,205,435,198,431,193,426, +217,464,219,427,223,463,223,463,219,427,225,431,223,463,225,431,228,461,228,461,225,431,229,435,228,461,229,435,231,458,231,458,229,435,232,439,231,458,232,439,234,454,234,454,232,439,234,443,234,454,234,443,234,448,219,427,217,464,213,463,219,427,213,463,209,462,219,427,209,462,205,460,219,427,205,460,201,457,219,427,201,457,196,453,219,427,196,453,142,378,45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,49,294,50,275,106,310,49,294,106,310,45,307,45,307,106,310,111,312,45,307,111,312,271,331,271,331,111,312,118,312,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,271,331,118,312,184,312,271,331,184,312,213,311,271,331,213,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,271,331,6,331,25,320,271,331,25,320,38,315,271,331,38,315,45,307,255,38,234,26,276,0,276,0,234,26,206,20,276,0,206,20,169,18,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,255,38,276,0,169,18,151,18,276,0,151,18,132,19,276,0,132,19,117,21,276,0,117,21,45,24,276,0,6,9,6,0,25,320,6,331,6,321,176,184,176,164,198,162,233,232,244,115,244,232,142,378,196,453,123,378, +242,378,179,462,148,462,86,378,103,378,164,430,224,378,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,238,411,236,419,233,426,227,431,220,435,213,436,205,435,198,431,193,426,189,419,188,411,189,403,193,397,198,391,204,388,212,387,220,388,227,391,233,397,236,403,238,411,16383,16383,138,411,137,419,133,426,128,431,121,435,113,436,105,435,98,431,93,426,90,419,89,411,90,403,93,397,98,391,105,388,113,387,121,388,128,391,133,397,137,403,138,411,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115, +86,378,103,378,148,462,148,462,103,378,164,430,148,462,164,430,179,462,179,462,164,430,224,378,179,462,224,378,242,378,45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,49,294,50,275,106,310,49,294,106,310,45,307,45,307,106,310,111,312,45,307,111,312,271,331,271,331,111,312,118,312,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,271,331,118,312,184,312,271,331,184,312,213,311,271,331,213,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,271,331,6,331,25,320,271,331,25,320,38,315,271,331,38,315,45,307,255,38,234,26,276,0,276,0,234,26,206,20,276,0,206,20,169,18,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,255,38,276,0,169,18,151,18,276,0,151,18,132,19,276,0,132,19,117,21,276,0,117,21,45,24,276,0,6,9,6,0,25,320,6,331,6,321,176,184,176,164,198,162,233,232,244,115,244,232, +238,411,236,419,233,426,227,431,220,435,213,436,205,435,198,431,193,426,189,419,188,411,189,403,193,397,198,391,204,388,212,387,220,388,227,391,233,397,236,403,238,411,16383,16383,138,411,137,419,133,426,128,431,121,435,113,436,105,435,98,431,93,426,90,419,89,411,90,403,93,397,98,391,105,388,113,387,121,388,128,391,133,397,137,403,138,411,16383,16383,299,84,285,84,271,57,255,38,234,26,206,20,169,18,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,184,312,213,311,234,306,247,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,134,378,62,453,57,457,53,460,49,462,41,464,35,463,29,461,26,458,23,454,22,448,23,443,25,439,28,434,32,430,37,426,114,378,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,32,378,52,378,129,427,139,435,142,439,143,443,144,448,143,454,141,458,137,461,133,463,127,464,122,463,118,462,115,460,110,457,105,453,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,161,378,98,462,67,462,5,378,22,378,83,430,143,378,16383,16383,153,0,153,9,133,11, +113,436,113,387,121,435,121,435,113,387,121,388,121,435,121,388,128,431,128,431,121,388,128,391,128,431,128,391,133,426,133,426,128,391,133,397,133,426,133,397,137,419,137,419,133,397,137,403,137,419,137,403,138,411,89,411,90,403,90,419,90,419,90,403,93,397,90,419,93,397,93,426,93,426,93,397,98,391,93,426,98,391,98,431,98,431,98,391,105,388,98,431,105,388,105,435,105,435,105,388,113,387,105,435,113,387,113,436,45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,49,294,50,275,106,310,49,294,106,310,45,307,45,307,106,310,111,312,45,307,111,312,271,331,271,331,111,312,118,312,188,411,189,403,189,419,189,419,189,403,193,397,189,419,193,397,193,426,193,426,193,397,198,391,193,426,198,391,198,431,198,431,198,391,204,388,198,431,204,388,205,435,205,435,204,388,212,387,205,435,212,387,213,436,213,436,212,387,220,388,213,436,220,388,220,435,220,435,220,388,227,391,220,435,227,391,227,431,227,431,227,391,233,397,227,431,233,397,233,426,233,426,233,397,236,403,233,426,236,403,236,419,236,419,236,403,238,411,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,271,331,118,312,184,312,271,331,184,312,213,311,271,331,213,311,234,306,271,331,234,306,247,297,271,331,247,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,271,331,6,331,25,320,271,331,25,320,38,315,271,331,38,315,45,307,255,38,234,26,276,0,276,0,234,26,206,20,276,0,206,20,169,18,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,255,38,276,0,169,18,151,18,276,0,151,18,132,19,276,0,132,19,117,21,276,0,117,21,45,24,276,0,6,9,6,0,25,320,6,331,6,321,176,184,176,164,198,162,233,232,244,115,244,232, +134,378,62,453,57,457,53,460,49,462,41,464,35,463,29,461,26,458,23,454,22,448,23,443,25,439,28,434,32,430,37,426,114,378,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,32,378,52,378,129,427,139,435,142,439,143,443,144,448,143,454,141,458,137,461,133,463,127,464,122,463,118,462,115,460,110,457,105,453,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0, +114,378,134,378,62,453,114,378,62,453,57,457,114,378,57,457,53,460,114,378,53,460,49,462,114,378,49,462,45,463,114,378,45,463,41,464,114,378,41,464,37,426,22,448,23,443,23,454,23,454,23,443,25,439,23,454,25,439,26,458,26,458,25,439,28,434,26,458,28,434,29,461,29,461,28,434,32,430,29,461,32,430,35,463,35,463,32,430,37,426,35,463,37,426,41,464,52,23,44,15,157,0,157,0,44,15,30,11,157,0,30,11,9,9,157,331,9,331,30,320,157,331,30,320,44,316,157,331,44,316,53,308,157,331,53,308,57,295,157,331,57,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,57,295,157,0,157,9,137,11,157,0,137,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,9,9,9,0,56,36,122,16,57,56,30,320,9,331,9,321, +32,378,52,378,129,427,139,435,142,439,143,443,144,448,143,454,141,458,137,461,133,463,127,464,122,463,118,462,115,460,110,457,105,453,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,161,378,98,462,67,462,5,378,22,378,83,430,143,378,16383,16383,153,0,153,9,133,11,119,16,110,24,106,37,104,56,104,276,105,295,110,308,118,316,132,320,153,321,153,331,5,331,5,321,26,320,40,316,49,308,53,295,54,276,54,56,53,36,49,23,40,15,26,11,5,9,5,0,157,411,156,419,153,426,147,431,140,435,132,436,125,435,118,431,113,426, +127,464,129,427,133,463,133,463,129,427,134,431,133,463,134,431,137,461,137,461,134,431,139,435,137,461,139,435,141,458,141,458,139,435,142,439,141,458,142,439,143,454,143,454,142,439,143,443,143,454,143,443,144,448,129,427,127,464,122,463,129,427,122,463,118,462,129,427,118,462,115,460,129,427,115,460,110,457,129,427,110,457,105,453,129,427,105,453,52,378,52,23,44,15,157,0,157,0,44,15,30,11,157,0,30,11,9,9,157,331,9,331,30,320,157,331,30,320,44,316,157,331,44,316,53,308,157,331,53,308,57,295,157,331,57,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,57,295,157,0,157,9,137,11,157,0,137,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,9,9,9,0,56,36,122,16,57,56,30,320,9,331,9,321,52,378,105,453,32,378, +161,378,98,462,67,462,5,378,22,378,83,430,143,378,16383,16383,153,0,153,9,133,11,119,16,110,24,106,37,104,56,104,276,105,295,110,308,118,316,132,320,153,321,153,331,5,331,5,321,26,320,40,316,49,308,53,295,54,276,54,56,53,36,49,23,40,15,26,11,5,9,5,0,157,411,156,419,153,426,147,431,140,435,132,436,125,435,118,431,113,426,109,419,108,411,109,403,113,397,118,391,124,388,132,387,140,388,147,391,153,397,156,403,157,411,16383,16383,58,411,57,419,53,426,48,431,41,435,33,436,25,435,18,431,13,426,10,419,8,411,10,403,13,397,18,391, +5,378,22,378,67,462,67,462,22,378,83,430,67,462,83,430,98,462,98,462,83,430,143,378,98,462,143,378,161,378,49,23,40,15,153,0,153,0,40,15,26,11,153,0,26,11,5,9,153,331,5,331,26,320,153,331,26,320,40,316,153,331,40,316,49,308,153,331,49,308,53,295,153,331,53,295,118,316,153,331,118,316,132,320,153,331,132,320,153,321,119,16,110,24,54,56,54,56,110,24,106,37,54,56,106,37,54,276,54,276,106,37,104,56,54,276,104,56,104,276,54,276,104,276,105,295,54,276,105,295,110,308,54,276,110,308,118,316,54,276,118,316,53,295,153,0,153,9,133,11,153,0,133,11,119,16,153,0,119,16,53,36,153,0,53,36,49,23,153,0,5,9,5,0,53,36,119,16,54,56,26,320,5,331,5,321, +157,411,156,419,153,426,147,431,140,435,132,436,125,435,118,431,113,426,109,419,108,411,109,403,113,397,118,391,124,388,132,387,140,388,147,391,153,397,156,403,157,411,16383,16383,58,411,57,419,53,426,48,431,41,435,33,436,25,435,18,431,13,426,10,419,8,411,10,403,13,397,18,391,25,388,32,387,40,388,47,391,53,397,57,403,58,411,16383,16383,157,0,157,9,136,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,8,331,8,321,30,320,44,316,52,308,56,295,57,276,57,56,56,36,52,23,44,15,29,11,8,9,8,0,8,331,8,321,28,319,40,315,48,307,51,295,52,276,52,180,11,180,11,157,52,157,52,55,51,36,47,24,40,16,27,12,8,9,8,0,150,0,183,2,213,7,242,16,267,27,287,41,307,60,322,83,333,109,340,137,343,167,334,224,308,269,267,303,212,324,143,331,16383,16383,103,157,176,157,176,180,103,180,103,293,104,301,106,307,111,310,117,312,127,313,152,312,175,309,194,304,212,297,227,289,249,271,266,249,278,224,285,195,288,164,285,130,278,101,266,76,249,55,227,39,211,31,194,26,175,22,153,19,128,18,118,19,111,21,106,25,104,31,103,39,244,444,240,434, +8,411,10,403,10,419,10,419,10,403,13,397,10,419,13,397,13,426,13,426,13,397,18,391,13,426,18,391,18,431,18,431,18,391,25,388,18,431,25,388,25,435,25,435,25,388,32,387,25,435,32,387,33,436,33,436,32,387,40,388,33,436,40,388,41,435,41,435,40,388,47,391,41,435,47,391,48,431,48,431,47,391,53,397,48,431,53,397,53,426,53,426,53,397,57,403,53,426,57,403,57,419,57,419,57,403,58,411,52,23,44,15,157,0,157,0,44,15,29,11,157,0,29,11,8,9,157,331,8,331,30,320,157,331,30,320,44,316,157,331,44,316,52,308,157,331,52,308,56,295,157,331,56,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,56,295,132,436,132,387,140,435,140,435,132,387,140,388,140,435,140,388,147,431,147,431,140,388,147,391,147,431,147,391,153,426,153,426,147,391,153,397,153,426,153,397,156,419,156,419,153,397,156,403,156,419,156,403,157,411,108,411,109,403,109,419,109,419,109,403,113,397,109,419,113,397,113,426,113,426,113,397,118,391,113,426,118,391,118,431,118,431,118,391,124,388,118,431,124,388,125,435,125,435,124,388,132,387,125,435,132,387,132,436,157,0,157,9,136,11,157,0,136,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,8,9,8,0,56,36,122,16,57,56,30,320,8,331,8,321, +8,331,8,321,28,319,40,315,48,307,51,295,52,276,52,180,11,180,11,157,52,157,52,55,51,36,47,24,40,16,27,12,8,9,8,0,150,0,183,2,213,7,242,16,267,27,287,41,307,60,322,83,333,109,340,137,343,167,334,224,308,269,267,303,212,324,143,331,16383,16383,103,157,176,157,176,180,103,180,103,293,104,301,106,307,111,310,117,312,127,313,152,312,175,309,194,304,212,297,227,289,249,271,266,249,278,224,285,195,288,164,285,130,278,101,266,76,249,55,227,39,211,31,194,26,175,22,153,19,128,18,118,19,111,21,106,25,104,31,103,39,244,444,240,434,235,427,230,422,224,420,218,419,213,419,208,420,203,422,191,426,180,432,172,436,158,440,151,441,145,441,130,439,118,433,108,423,100,409,94,391,108,391,112,399,116,406,122,410,128,413,134,414,138,414,146,412,150,410,155,408,177,398,185,394,193,392,200,391,206,391,221,393,234,399,244,409,252,424,259,444,16383,16383,353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9, +47,24,40,16,150,0,150,0,40,16,27,12,150,0,27,12,8,9,40,315,48,307,143,331,143,331,48,307,51,295,143,331,51,295,52,276,104,31,52,276,52,180,104,31,52,180,52,157,52,157,52,180,11,180,52,157,11,180,11,157,104,301,106,307,52,276,52,276,106,307,111,310,52,276,111,310,143,331,143,331,111,310,117,312,143,331,117,312,127,313,127,313,117,312,127,312,127,313,127,312,152,312,127,313,152,312,143,331,143,331,152,312,212,324,175,22,183,2,194,26,194,26,183,2,213,7,194,26,213,7,211,31,211,31,213,7,227,39,249,55,227,39,242,16,249,55,242,16,267,27,128,18,150,0,153,19,153,19,150,0,183,2,153,19,183,2,175,22,175,309,194,304,212,324,212,324,194,304,212,297,212,324,212,297,227,289,227,289,249,271,267,303,267,303,249,271,266,249,267,303,266,249,278,224,334,224,308,269,322,83,334,224,322,83,333,109,334,224,333,109,340,137,334,224,340,137,343,167,322,83,308,269,307,60,307,60,308,269,288,164,287,41,288,164,285,130,287,41,285,130,278,101,267,303,278,224,308,269,308,269,278,224,285,195,308,269,285,195,288,164,267,303,212,324,227,289,267,27,287,41,278,101,267,27,278,101,266,76,267,27,266,76,249,55,227,39,213,7,242,16,52,276,104,31,103,39,103,180,103,157,176,157,103,180,176,157,176,180,103,293,104,301,52,276,103,293,52,276,103,39,143,331,8,331,28,319,143,331,28,319,40,315,52,55,51,36,111,21,111,21,51,36,150,0,111,21,150,0,118,19,118,19,150,0,128,18,52,55,111,21,106,25,52,55,106,25,104,31,52,55,104,31,52,157,150,0,8,9,8,0,47,24,150,0,51,36,28,319,8,331,8,321,288,164,287,41,307,60,212,324,152,312,175,309, +244,444,240,434,235,427,230,422,224,420,218,419,213,419,208,420,203,422,191,426,180,432,172,436,158,440,151,441,145,441,130,439,118,433,108,423,100,409,94,391,108,391,112,399,116,406,122,410,128,413,134,414,138,414,146,412,150,410,155,408,177,398,185,394,193,392,200,391,206,391,221,393,234,399,244,409,252,424,259,444,16383,16383,353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9,103,13,90,20,82,31,78,49,76,75,76,269,297,-5,306,-5,306,274,308,289,311,299,315,307,320,313,324,315,329,318,335,319,343,320,353,321,225,378,152,453,148,457,143,460,139,462,131,464,125,463,120,461,116,458,114,454,113,448,113,443,115,439,118,434,128,426,205,378,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,129,378,150,378,227,427,232,431,236,435,239,439,241,443,242,448, +112,399,116,406,118,433,118,433,116,406,122,410,118,433,122,410,130,439,130,439,122,410,128,413,130,439,128,413,134,414,134,414,138,414,145,441,145,441,138,414,142,413,145,441,142,413,146,412,108,391,112,399,118,433,108,391,118,433,108,423,108,391,108,423,100,409,108,391,100,409,94,391,145,441,146,412,151,441,151,441,146,412,150,410,151,441,150,410,155,408,155,408,166,403,158,440,158,440,166,403,165,438,145,441,130,439,134,414,158,440,151,441,155,408,165,438,166,403,172,436,172,436,166,403,177,398,172,436,177,398,180,432,180,432,177,398,185,394,180,432,185,394,191,426,191,426,185,394,193,392,191,426,193,392,197,424,197,424,193,392,200,391,197,424,200,391,203,422,203,422,200,391,206,391,203,422,206,391,208,420,208,420,206,391,221,393,208,420,221,393,213,419,213,419,221,393,218,419,224,420,218,419,221,393,224,420,221,393,234,399,244,444,240,434,244,409,244,444,244,409,252,424,244,444,252,424,259,444,235,427,230,422,234,399,235,427,234,399,244,409,235,427,244,409,240,434,49,30,41,19,123,0,123,0,41,19,27,13,123,0,27,13,6,9,256,319,263,317,353,331,353,331,263,317,269,313,353,331,269,313,275,309,275,309,278,303,353,331,353,331,278,303,281,295,353,331,281,295,324,315,324,315,281,295,320,313,324,315,320,313,320,312,320,312,320,313,315,307,315,307,320,313,284,274,315,307,284,274,284,259,297,-5,284,259,284,89,297,-5,284,89,91,331,353,331,324,315,329,318,353,331,329,318,335,319,353,331,335,319,343,320,353,331,343,320,353,321,306,-5,306,253,297,-5,297,-5,306,253,306,274,297,-5,306,274,284,259,284,259,306,274,308,289,284,259,308,289,311,299,283,285,284,274,320,313,283,285,320,313,281,295,247,320,256,319,353,331,247,320,353,331,235,331,247,320,235,331,235,321,91,331,6,331,19,321,91,331,19,321,29,318,91,331,29,318,37,313,91,331,37,313,46,306,91,331,46,306,55,295,91,331,55,295,76,269,91,331,76,269,297,-5,55,295,78,49,76,75,54,48,49,30,90,20,90,20,49,30,123,0,90,20,123,0,103,13,103,13,123,0,123,9,55,75,54,48,82,31,55,75,82,31,78,49,55,75,78,49,55,295,123,0,6,9,6,0,54,48,90,20,82,31,19,321,6,331,6,321,76,269,55,295,76,75,315,307,284,259,311,299,224,420,234,399,230,422, +225,378,152,453,148,457,143,460,139,462,131,464,125,463,120,461,116,458,114,454,113,448,113,443,115,439,118,434,128,426,205,378,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,129,378,150,378,227,427,232,431,236,435,239,439,241,443,242,448,241,454,239,458,235,461,230,463,224,464,216,462,212,460,208,457,203,453,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201, +205,378,225,378,152,453,205,378,152,453,148,457,205,378,148,457,143,460,205,378,143,460,139,462,205,378,139,462,135,463,205,378,135,463,131,464,205,378,131,464,128,426,113,448,113,443,114,454,114,454,113,443,115,439,114,454,115,439,116,458,116,458,115,439,118,434,116,458,118,434,120,461,120,461,118,434,123,430,120,461,123,430,125,463,125,463,123,430,128,426,125,463,128,426,131,464,149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19, +129,378,150,378,227,427,232,431,236,435,239,439,241,443,242,448,241,454,239,458,235,461,230,463,224,464,216,462,212,460,208,457,203,453,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,255,378,193,462,161,462,99,378,117,378,177,430,238,378,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,244,444,240,434,235,427,230,422,224,420,218,419,213,419,208,420,203,422,191,426, +149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,224,464,227,427,230,463,230,463,227,427,232,431,230,463,232,431,235,461,235,461,232,431,236,435,235,461,236,435,239,458,239,458,236,435,239,439,239,458,239,439,241,454,241,454,239,439,241,443,241,454,241,443,242,448,227,427,224,464,220,463,227,427,220,463,216,462,227,427,216,462,212,460,227,427,212,460,208,457,227,427,208,457,203,453,227,427,203,453,150,378,81,24,74,166,46,61,150,378,203,453,129,378,223,19,234,1,235,26,130,25,180,-6,142,19, +255,378,193,462,161,462,99,378,117,378,177,430,238,378,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,244,444,240,434,235,427,230,422,224,420,218,419,213,419,208,420,203,422,191,426,180,432,172,436,158,440,151,441,145,441,130,439,118,433,108,423,100,409,94,391,108,391,112,399,116,406,122,410,128,413,134,414,138,414,146,412,150,410,155,408,177,398,185,394,193,392,200,391,206,391,221,393,234,399,244,409,252,424,259,444,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19, +99,378,117,378,161,462,161,462,117,378,177,430,161,462,177,430,193,462,193,462,177,430,238,378,193,462,238,378,255,378,149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19, +244,444,240,434,235,427,230,422,224,420,218,419,213,419,208,420,203,422,191,426,180,432,172,436,158,440,151,441,145,441,130,439,118,433,108,423,100,409,94,391,108,391,112,399,116,406,122,410,128,413,134,414,138,414,146,412,150,410,155,408,177,398,185,394,193,392,200,391,206,391,221,393,234,399,244,409,252,424,259,444,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,252,411,250,419,247,426,241,431,234,435,227,436,219,435,212,431,207,426,203,419,202,411,203,403,207,397,212,391,218,388,226,387,234,388,241,391,247,397,250,403,252,411,16383,16383,152,411,151,419,147,426,142,431,135,435,127,436,119,435,113,431,107,426,104,419,103,411,104,403,107,397,112,391,119,388,127,387,135,388,142,391,147,397,151,403,152,411,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257, +112,399,116,406,118,433,118,433,116,406,122,410,118,433,122,410,130,439,130,439,122,410,128,413,130,439,128,413,134,414,134,414,138,414,145,441,145,441,138,414,142,413,145,441,142,413,146,412,108,391,112,399,118,433,108,391,118,433,108,423,108,391,108,423,100,409,108,391,100,409,94,391,145,441,146,412,151,441,151,441,146,412,150,410,151,441,150,410,155,408,155,408,166,403,158,440,158,440,166,403,165,438,145,441,130,439,134,414,158,440,151,441,155,408,165,438,166,403,172,436,172,436,166,403,177,398,172,436,177,398,180,432,180,432,177,398,185,394,180,432,185,394,191,426,191,426,185,394,193,392,191,426,193,392,197,424,197,424,193,392,200,391,197,424,200,391,203,422,203,422,200,391,206,391,203,422,206,391,208,420,208,420,206,391,221,393,208,420,221,393,213,419,213,419,221,393,218,419,224,420,218,419,221,393,224,420,221,393,234,399,244,444,240,434,244,409,244,444,244,409,252,424,244,444,252,424,259,444,235,427,230,422,234,399,235,427,234,399,244,409,235,427,244,409,240,434,149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19,224,420,234,399,230,422, +252,411,250,419,247,426,241,431,234,435,227,436,219,435,212,431,207,426,203,419,202,411,203,403,207,397,212,391,218,388,226,387,234,388,241,391,247,397,250,403,252,411,16383,16383,152,411,151,419,147,426,142,431,135,435,127,436,119,435,113,431,107,426,104,419,103,411,104,403,107,397,112,391,119,388,127,387,135,388,142,391,147,397,151,403,152,411,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,299,11,184,126,299,242,276,265,160,150,45,265,22,242,137,126,22,11,45,-11,160,103,276,-11,329,367,305,367,268,314,250,323,233,330,217,335,200,337,181,338,127,330,81,307,47,270,25,222,17,165,18,147,20,129,24,111,30,94,36,79,48,59,55,50,75,30,28,-39,52,-39,92,18,110,8,127,1,143,-3,161,-5,180,-6,234,1,279,24,314,61,336,109,344,166,343,184,340,203,336,220,331,237,325,252,319,263,313,272,305,281,296,291,285,302,16383,16383,97,61,88,80,82,99,77,119,75,141,74,165,79,218,93,261,115,293,144,313,180,320,196,319,211,315,225,309,238,300,251,287,16383,16383,263,270,272,251,279,232,284,212,286,190,287,165,282,113,268,70,246,38,217,18,180,11,164,12,149,16,135,22,122,32,109,44,227,378,154,453,149,457,145,460,141,462,137,463,132,464,126,463,121,461,118,458,115,454,114,448,115,443,117,439,120,434,124,430,129,426, +103,411,104,403,104,419,104,419,104,403,107,397,104,419,107,397,107,426,107,426,107,397,112,391,107,426,112,391,113,431,113,431,112,391,119,388,113,431,119,388,119,435,119,435,119,388,127,387,119,435,127,387,127,436,127,436,127,387,135,388,127,436,135,388,135,435,135,435,135,388,142,391,135,435,142,391,142,431,142,431,142,391,147,397,142,431,147,397,147,426,147,426,147,397,151,403,147,426,151,403,151,419,151,419,151,403,152,411,149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,202,411,203,403,203,419,203,419,203,403,207,397,203,419,207,397,207,426,207,426,207,397,212,391,207,426,212,391,212,431,212,431,212,391,218,388,212,431,218,388,219,435,219,435,218,388,226,387,219,435,226,387,227,436,227,436,226,387,234,388,227,436,234,388,234,435,234,435,234,388,241,391,234,435,241,391,241,431,241,431,241,391,247,397,241,431,247,397,247,426,247,426,247,397,250,403,247,426,250,403,250,419,250,419,250,403,252,411,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19, +299,11,184,126,299,242,276,265,160,150,45,265,22,242,137,126,22,11,45,-11,160,103,276,-11,329,367,305,367,268,314,250,323,233,330,217,335,200,337,181,338,127,330,81,307,47,270,25,222, +184,126,299,242,276,265,184,126,276,265,160,150,184,126,160,150,276,-11,184,126,276,-11,299,11,22,11,45,-11,137,126,137,126,45,-11,160,103,137,126,160,103,160,150,160,150,160,103,276,-11,45,265,22,242,137,126,45,265,137,126,160,150, +329,367,305,367,268,314,250,323,233,330,217,335,200,337,181,338,127,330,81,307,47,270,25,222,17,165,18,147,20,129,24,111,30,94,36,79,48,59,55,50,75,30,28,-39,52,-39,92,18,110,8,127,1,143,-3,161,-5,180,-6,234,1,279,24,314,61,336,109,344,166,343,184,340,203,336,220,331,237,325,252,319,263,313,272,305,281,296,291,285,302,16383,16383,97,61,88,80,82,99,77,119,75,141,74,165,79,218,93,261,115,293,144,313,180,320,196,319,211,315,225,309,238,300,251,287,16383,16383,263,270,272,251,279,232,284,212,286,190,287,165,282,113,268,70,246,38,217,18,180,11,164,12,149,16,135,22,122,32,109,44,227,378,154,453,149,457,145,460,141,462,137,463,132,464,126,463,121,461,118,458,115,454,114,448,115,443,117,439,120,434,124,430,129,426,206,378,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45, +48,59,55,50,81,307,81,307,55,50,64,41,81,307,64,41,74,165,74,165,75,30,75,141,75,141,75,30,77,119,282,113,268,70,279,24,279,24,268,70,246,38,279,24,246,38,234,1,234,1,246,38,217,18,234,1,217,18,180,11,180,11,164,12,180,-6,180,-6,164,12,161,-5,88,80,92,18,97,61,97,61,92,18,110,8,97,61,110,8,109,44,109,44,110,8,122,32,122,32,110,8,127,1,122,32,127,1,135,22,135,22,127,1,143,-3,135,22,143,-3,149,16,149,16,143,-3,161,-5,149,16,161,-5,164,12,92,18,88,80,82,99,92,18,82,99,77,119,92,18,77,119,75,30,92,18,75,30,52,-39,75,30,28,-39,52,-39,109,44,263,270,251,287,251,287,268,314,250,323,251,287,250,323,238,300,238,300,250,323,233,330,238,300,233,330,225,309,225,309,233,330,217,335,225,309,217,335,211,315,211,315,217,335,200,337,211,315,200,337,196,319,196,319,200,337,181,338,196,319,181,338,180,320,343,184,340,203,344,166,344,166,340,203,336,220,344,166,336,220,336,109,336,109,336,220,331,237,336,109,331,237,325,252,319,263,313,272,314,61,319,263,314,61,336,109,319,263,336,109,325,252,279,24,314,61,282,113,282,113,314,61,287,165,296,291,287,165,314,61,296,291,314,61,305,281,305,281,314,61,313,272,180,11,180,-6,234,1,263,270,272,251,268,314,268,314,272,251,285,302,268,314,285,302,305,367,305,367,285,302,329,367,285,302,272,251,279,232,285,302,279,232,284,212,285,302,284,212,286,190,285,302,286,190,296,291,251,287,97,61,109,44,93,261,115,293,127,330,127,330,115,293,144,313,127,330,144,313,181,338,181,338,144,313,180,320,81,307,74,165,79,218,81,307,79,218,93,261,81,307,93,261,127,330,47,270,25,222,30,94,47,270,30,94,36,79,47,270,36,79,42,69,47,270,42,69,48,59,47,270,48,59,81,307,25,222,17,165,18,147,25,222,18,147,20,129,25,222,20,129,24,111,25,222,24,111,30,94,296,291,286,190,287,165,268,314,251,287,263,270,75,30,74,165,64,41, +227,378,154,453,149,457,145,460,141,462,137,463,132,464,126,463,121,461,118,458,115,454,114,448,115,443,117,439,120,434,124,430,129,426,206,378,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,132,378,152,378,229,427,234,431,238,435,241,439,243,443,244,448,243,454,241,458,237,461,233,463,227,464,222,463,218,462,214,460,210,457,205,453,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321, +206,378,227,378,154,453,206,378,154,453,149,457,206,378,149,457,145,460,206,378,145,460,141,462,206,378,141,462,137,463,206,378,137,463,132,464,206,378,132,464,129,426,114,448,115,443,115,454,115,454,115,443,117,439,115,454,117,439,118,458,118,458,117,439,120,434,118,458,120,434,121,461,121,461,120,434,124,430,121,461,124,430,126,463,126,463,124,430,129,426,126,463,129,426,132,464,105,79,106,8,109,63,109,63,106,8,121,1,109,63,121,1,115,50,115,50,121,1,125,37,135,30,125,37,138,-3,135,30,138,-3,146,24,146,24,138,-3,157,-5,146,24,157,-5,158,19,158,19,157,-5,177,-6,158,19,177,-6,173,16,173,16,177,-6,189,15,208,16,189,15,204,-5,208,16,204,-5,227,0,103,118,103,275,93,16,103,118,93,16,104,97,104,97,93,16,106,8,104,97,106,8,105,79,125,37,121,1,138,-3,283,103,282,85,290,45,290,45,282,85,279,70,290,45,279,70,278,30,278,30,279,70,273,57,278,30,273,57,265,45,265,45,254,34,264,17,264,17,254,34,247,6,241,26,225,20,227,0,241,26,227,0,247,6,241,26,247,6,254,34,353,331,237,331,257,319,353,331,257,319,270,312,353,331,270,312,279,301,353,331,279,301,318,311,353,331,318,311,331,318,353,331,331,318,353,321,305,258,306,282,297,62,305,258,297,62,302,81,305,258,302,81,305,104,305,258,305,104,305,131,290,45,297,62,306,282,290,45,306,282,283,257,290,45,283,257,283,125,290,45,283,125,283,103,310,300,318,311,282,283,310,300,282,283,283,257,310,300,283,257,306,282,265,45,264,17,278,30,189,15,177,-6,204,-5,128,319,148,321,148,331,128,319,148,331,115,314,115,314,148,331,51,297,115,314,51,297,52,280,53,95,52,280,52,124,58,69,66,48,104,293,104,293,66,48,78,30,104,293,78,30,103,275,103,275,78,30,93,16,104,293,108,306,52,280,104,293,52,280,53,95,104,293,53,95,58,69,148,331,7,331,27,319,148,331,27,319,40,315,148,331,40,315,47,308,148,331,47,308,51,297,27,319,7,331,7,321,115,314,52,280,108,306,257,319,237,331,237,321,318,311,279,301,282,283,208,16,227,0,225,20, +132,378,152,378,229,427,234,431,238,435,241,439,243,443,244,448,243,454,241,458,237,461,233,463,227,464,222,463,218,462,214,460,210,457,205,453,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,256,378,193,462,162,462,100,378,117,378,177,430,238,378,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,252,411,250,419,247,426,241,431,234,435,227,436,219,435,212,431,207,426,203,419,202,411, +105,79,106,8,109,63,109,63,106,8,121,1,109,63,121,1,115,50,115,50,121,1,125,37,135,30,125,37,138,-3,135,30,138,-3,146,24,146,24,138,-3,157,-5,146,24,157,-5,158,19,158,19,157,-5,177,-6,158,19,177,-6,173,16,173,16,177,-6,189,15,208,16,189,15,204,-5,208,16,204,-5,227,0,103,118,103,275,93,16,103,118,93,16,104,97,104,97,93,16,106,8,104,97,106,8,105,79,125,37,121,1,138,-3,227,464,229,427,233,463,233,463,229,427,234,431,233,463,234,431,237,461,237,461,234,431,238,435,237,461,238,435,241,458,241,458,238,435,241,439,241,458,241,439,243,454,243,454,241,439,243,443,243,454,243,443,244,448,229,427,227,464,222,463,229,427,222,463,218,462,229,427,218,462,214,460,229,427,214,460,210,457,229,427,210,457,205,453,229,427,205,453,152,378,283,103,282,85,290,45,290,45,282,85,279,70,290,45,279,70,278,30,278,30,279,70,273,57,278,30,273,57,265,45,265,45,254,34,264,17,264,17,254,34,247,6,241,26,225,20,227,0,241,26,227,0,247,6,241,26,247,6,254,34,353,331,237,331,257,319,353,331,257,319,270,312,353,331,270,312,279,301,353,331,279,301,318,311,353,331,318,311,331,318,353,331,331,318,353,321,305,258,306,282,297,62,305,258,297,62,302,81,305,258,302,81,305,104,305,258,305,104,305,131,290,45,297,62,306,282,290,45,306,282,283,257,290,45,283,257,283,125,290,45,283,125,283,103,310,300,318,311,282,283,310,300,282,283,283,257,310,300,283,257,306,282,265,45,264,17,278,30,189,15,177,-6,204,-5,128,319,148,321,148,331,128,319,148,331,115,314,115,314,148,331,51,297,115,314,51,297,52,280,53,95,52,280,52,124,58,69,66,48,104,293,104,293,66,48,78,30,104,293,78,30,103,275,103,275,78,30,93,16,104,293,108,306,52,280,104,293,52,280,53,95,104,293,53,95,58,69,148,331,7,331,27,319,148,331,27,319,40,315,148,331,40,315,47,308,148,331,47,308,51,297,27,319,7,331,7,321,115,314,52,280,108,306,257,319,237,331,237,321,318,311,279,301,282,283,208,16,227,0,225,20,152,378,205,453,132,378, +256,378,193,462,162,462,100,378,117,378,177,430,238,378,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,252,411,250,419,247,426,241,431,234,435,227,436,219,435,212,431,207,426,203,419,202,411,203,403,207,397,212,391,218,388,226,387,234,388,241,391,247,397,250,403,252,411,16383,16383,152,411,151,419,147,426,142,431,135,435,127,436,119,435,113,431,107,426,104,419,103,411,104,403,107,397,112,391,119,388,127,387,135,388,142,391,147,397,151,403,152,411,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314, +100,378,117,378,162,462,162,462,117,378,177,430,162,462,177,430,193,462,193,462,177,430,238,378,193,462,238,378,256,378,105,79,106,8,109,63,109,63,106,8,121,1,109,63,121,1,115,50,115,50,121,1,125,37,135,30,125,37,138,-3,135,30,138,-3,146,24,146,24,138,-3,157,-5,146,24,157,-5,158,19,158,19,157,-5,177,-6,158,19,177,-6,173,16,173,16,177,-6,189,15,208,16,189,15,204,-5,208,16,204,-5,227,0,103,118,103,275,93,16,103,118,93,16,104,97,104,97,93,16,106,8,104,97,106,8,105,79,125,37,121,1,138,-3,283,103,282,85,290,45,290,45,282,85,279,70,290,45,279,70,278,30,278,30,279,70,273,57,278,30,273,57,265,45,265,45,254,34,264,17,264,17,254,34,247,6,241,26,225,20,227,0,241,26,227,0,247,6,241,26,247,6,254,34,353,331,237,331,257,319,353,331,257,319,270,312,353,331,270,312,279,301,353,331,279,301,318,311,353,331,318,311,331,318,353,331,331,318,353,321,305,258,306,282,297,62,305,258,297,62,302,81,305,258,302,81,305,104,305,258,305,104,305,131,290,45,297,62,306,282,290,45,306,282,283,257,290,45,283,257,283,125,290,45,283,125,283,103,310,300,318,311,282,283,310,300,282,283,283,257,310,300,283,257,306,282,265,45,264,17,278,30,189,15,177,-6,204,-5,128,319,148,321,148,331,128,319,148,331,115,314,115,314,148,331,51,297,115,314,51,297,52,280,53,95,52,280,52,124,58,69,66,48,104,293,104,293,66,48,78,30,104,293,78,30,103,275,103,275,78,30,93,16,104,293,108,306,52,280,104,293,52,280,53,95,104,293,53,95,58,69,148,331,7,331,27,319,148,331,27,319,40,315,148,331,40,315,47,308,148,331,47,308,51,297,27,319,7,331,7,321,115,314,52,280,108,306,257,319,237,331,237,321,318,311,279,301,282,283,208,16,227,0,225,20, +252,411,250,419,247,426,241,431,234,435,227,436,219,435,212,431,207,426,203,419,202,411,203,403,207,397,212,391,218,388,226,387,234,388,241,391,247,397,250,403,252,411,16383,16383,152,411,151,419,147,426,142,431,135,435,127,436,119,435,113,431,107,426,104,419,103,411,104,403,107,397,112,391,119,388,127,387,135,388,142,391,147,397,151,403,152,411,16383,16383,353,331,237,331,237,321,257,319,270,312,279,301,282,283,283,257,283,103,282,85,279,70,273,57,265,45,254,34,241,26,225,20,208,16,189,15,173,16,158,19,146,24,135,30,125,37,115,50,109,63,105,79,104,97,103,118,103,275,104,293,108,306,115,314,128,319,148,321,148,331,7,331,7,321,27,319,40,315,47,308,51,297,52,280,52,124,53,95,58,69,66,48,78,30,93,16,106,8,121,1,138,-3,157,-5,177,-6,204,-5,227,0,247,6,264,17,278,30,290,45,297,62,302,81,305,104,305,258,306,282,310,300,318,311,331,318,353,321,133,378,153,378,230,427,240,435,243,439,244,443,245,448,244,454,242,458,238,461,234,463,228,464,223,463,219,462,216,460,211,457,206,453,16383,16383,352,331,243,331,243,321,256,321,266,319,272,316,275,312,276,306,276,302,274,294,272,290,270,285,197,174,124,285,121,289,118,294,116,299,115,304,115,308,116,312,119,316,123,318,130,320,138,321,151,321,151,331,11,331,11,321,24,319,37,313,50,299,68,277,92,243,157,147,157,61,156,39,152,25,144,16,129,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,151,282,266,297,288,310,303,322,313,336,319,352,321,101,266,101,268,100,269,100,271,101,292,105,306,113,314,127,319,147,321,147,331,8,331,8,321,27,319,39,314,46,307,49,294,50,276,50,60,49,39,46,25,39,17,27,12,8,9,8,0,148,0,148,9,128,11,114,16,106,23,102,36,101,55,101,80,109,80,115,79,136,79,158,80,177,82,194,85,210,90, +202,411,203,403,203,419,203,419,203,403,207,397,203,419,207,397,207,426,207,426,207,397,212,391,207,426,212,391,212,431,212,431,212,391,218,388,212,431,218,388,219,435,219,435,218,388,226,387,219,435,226,387,227,436,227,436,226,387,234,388,227,436,234,388,234,435,234,435,234,388,241,391,234,435,241,391,241,431,241,431,241,391,247,397,241,431,247,397,247,426,247,426,247,397,250,403,247,426,250,403,250,419,250,419,250,403,252,411,103,411,104,403,104,419,104,419,104,403,107,397,104,419,107,397,107,426,107,426,107,397,112,391,107,426,112,391,113,431,113,431,112,391,119,388,113,431,119,388,119,435,119,435,119,388,127,387,119,435,127,387,127,436,127,436,127,387,135,388,127,436,135,388,135,435,135,435,135,388,142,391,135,435,142,391,142,431,142,431,142,391,147,397,142,431,147,397,147,426,147,426,147,397,151,403,147,426,151,403,151,419,151,419,151,403,152,411,105,79,106,8,109,63,109,63,106,8,121,1,109,63,121,1,115,50,115,50,121,1,125,37,135,30,125,37,138,-3,135,30,138,-3,146,24,146,24,138,-3,157,-5,146,24,157,-5,158,19,158,19,157,-5,177,-6,158,19,177,-6,173,16,173,16,177,-6,189,15,208,16,189,15,204,-5,208,16,204,-5,227,0,103,118,103,275,93,16,103,118,93,16,104,97,104,97,93,16,106,8,104,97,106,8,105,79,125,37,121,1,138,-3,283,103,282,85,290,45,290,45,282,85,279,70,290,45,279,70,278,30,278,30,279,70,273,57,278,30,273,57,265,45,265,45,254,34,264,17,264,17,254,34,247,6,241,26,225,20,227,0,241,26,227,0,247,6,241,26,247,6,254,34,353,331,237,331,257,319,353,331,257,319,270,312,353,331,270,312,279,301,353,331,279,301,318,311,353,331,318,311,331,318,353,331,331,318,353,321,305,258,306,282,297,62,305,258,297,62,302,81,305,258,302,81,305,104,305,258,305,104,305,131,290,45,297,62,306,282,290,45,306,282,283,257,290,45,283,257,283,125,290,45,283,125,283,103,310,300,318,311,282,283,310,300,282,283,283,257,310,300,283,257,306,282,265,45,264,17,278,30,189,15,177,-6,204,-5,128,319,148,321,148,331,128,319,148,331,115,314,115,314,148,331,51,297,115,314,51,297,52,280,53,95,52,280,52,124,58,69,66,48,104,293,104,293,66,48,78,30,104,293,78,30,103,275,103,275,78,30,93,16,104,293,108,306,52,280,104,293,52,280,53,95,104,293,53,95,58,69,148,331,7,331,27,319,148,331,27,319,40,315,148,331,40,315,47,308,148,331,47,308,51,297,27,319,7,331,7,321,115,314,52,280,108,306,257,319,237,331,237,321,318,311,279,301,282,283,208,16,227,0,225,20, +133,378,153,378,230,427,240,435,243,439,244,443,245,448,244,454,242,458,238,461,234,463,228,464,223,463,219,462,216,460,211,457,206,453,16383,16383,352,331,243,331,243,321,256,321,266,319,272,316,275,312,276,306,276,302,274,294,272,290,270,285,197,174,124,285,121,289,118,294,116,299,115,304,115,308,116,312,119,316,123,318,130,320,138,321,151,321,151,331,11,331,11,321,24,319,37,313,50,299,68,277,92,243,157,147,157,61,156,39,152,25,144,16,129,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,151,282,266,297,288,310,303,322,313,336,319,352,321,101,266,101,268,100,269,100,271,101,292,105,306,113,314,127,319,147,321,147,331,8,331,8,321,27,319,39,314,46,307,49,294,50,276,50,60,49,39,46,25,39,17,27,12,8,9,8,0,148,0,148,9,128,11,114,16,106,23,102,36,101,55,101,80,109,80,115,79,136,79,158,80,177,82,194,85,210,90,223,96,239,107,253,121,263,138,269,156,271,175,265,206,248,231,221,250,185,262,141,266,16383,16383,101,230,101,237,103,242,106,245,110,247,117,247,154,244,182,236,201,221,213,200,217,172,213,146,202,126,185,111,161,102,129,99,113,99,107,100,101,100,36,42,36,28,33,19, +121,289,118,294,157,147,157,147,118,294,116,299,157,147,116,299,92,243,92,243,116,299,115,304,92,243,115,304,115,308,115,308,116,312,92,243,151,331,11,331,24,319,151,331,24,319,37,313,151,331,37,313,50,299,151,331,50,299,123,318,151,331,123,318,130,320,151,331,130,320,138,321,151,331,138,321,151,321,123,318,50,299,119,316,119,316,50,299,68,277,119,316,68,277,116,312,116,312,68,277,92,243,209,55,209,151,197,174,209,55,197,174,210,36,210,36,197,174,157,147,210,36,157,147,215,23,215,23,157,147,157,61,215,23,157,61,224,15,224,15,157,61,156,39,224,15,156,39,260,0,260,0,156,39,152,25,260,0,152,25,144,16,275,298,274,294,282,266,282,266,274,294,272,290,282,266,272,290,270,285,270,285,197,174,209,151,352,331,243,331,256,321,352,331,256,321,266,319,352,331,266,319,272,316,352,331,272,316,275,312,352,331,275,312,276,306,352,331,276,306,322,313,352,331,322,313,336,319,352,331,336,319,352,321,276,306,282,266,297,288,276,306,297,288,310,303,276,306,310,303,322,313,282,266,276,306,276,302,282,266,276,302,275,298,270,285,209,151,282,266,228,464,230,427,234,463,234,463,230,427,235,431,234,463,235,431,238,461,238,461,235,431,240,435,238,461,240,435,242,458,242,458,240,435,243,439,242,458,243,439,244,454,244,454,243,439,244,443,244,454,244,443,245,448,230,427,228,464,223,463,230,427,223,463,219,462,230,427,219,462,216,460,230,427,216,460,211,457,230,427,211,457,206,453,230,427,206,453,153,378,239,11,224,15,260,0,239,11,260,0,260,9,129,12,107,9,260,0,129,12,260,0,144,16,124,285,121,289,157,147,124,285,157,147,197,174,260,0,107,9,107,0,153,378,206,453,133,378,256,321,243,331,243,321,24,319,11,331,11,321, +101,266,101,268,100,269,100,271,101,292,105,306,113,314,127,319,147,321,147,331,8,331,8,321,27,319,39,314,46,307,49,294,50,276,50,60,49,39,46,25,39,17,27,12,8,9,8,0,148,0,148,9,128,11,114,16,106,23,102,36,101,55,101,80,109,80,115,79,136,79,158,80,177,82,194,85,210,90,223,96,239,107,253,121,263,138,269,156,271,175,265,206,248,231,221,250,185,262,141,266,16383,16383,101,230,101,237,103,242,106,245,110,247,117,247,154,244,182,236,201,221,213,200,217,172,213,146,202,126,185,111,161,102,129,99,113,99,107,100,101,100,36,42,36,28,33,19,28,13,19,9,6,7,6,0,79,0,79,275,81,293,86,308,95,319,107,326,122,328,137,325,150,316,159,302,165,282,167,258,165,237,159,220,150,207,137,199,119,195,114,194,110,193,107,191,105,189,105,184,107,182,110,180,115,179,121,179,145,173,163,161,176,140,184,111,187,75,186,61,185,48,182,36,179,26,175,19,172,15,164,11,160,10,155,10,150,11,146,12,143,15,142,19,141,25,140,36,138,42,135,48,130,52,125,55,118,56,111,55,105,51,100,46,97,40,96,32,98,20,105,10,115,2,129,-2,145,-3,173,0,198,14, +50,276,102,36,50,276,50,276,102,36,101,55,50,276,101,55,100,271,100,271,101,292,50,276,50,276,101,292,105,306,50,276,105,306,113,314,147,331,8,331,27,319,147,331,27,319,39,314,147,331,39,314,46,307,147,331,46,307,49,294,147,331,49,294,113,314,147,331,113,314,127,319,147,331,127,319,147,321,50,276,113,314,49,294,101,237,103,242,101,266,101,266,103,242,106,245,101,266,106,245,141,266,141,266,106,245,110,247,141,266,110,247,117,247,117,247,154,244,141,266,141,266,154,244,185,262,201,221,213,200,221,250,221,250,213,200,217,172,223,96,217,172,213,146,185,262,154,244,182,236,185,262,182,236,201,221,185,262,201,221,221,250,265,206,248,231,253,121,265,206,253,121,263,138,265,206,263,138,269,156,265,206,269,156,271,175,248,231,221,250,223,96,248,231,223,96,239,107,248,231,239,107,253,121,136,79,158,80,161,102,161,102,158,80,177,82,161,102,177,82,185,111,185,111,177,82,194,85,185,111,194,85,202,126,202,126,194,85,210,90,202,126,210,90,213,146,213,146,210,90,223,96,161,102,129,99,136,79,136,79,129,99,128,79,128,79,129,99,124,99,128,79,124,99,122,79,122,79,124,99,118,99,122,79,118,99,115,79,115,79,118,99,113,99,115,79,113,99,109,80,109,80,113,99,107,100,109,80,107,100,101,100,101,266,101,100,101,230,101,266,101,230,101,237,101,267,101,268,101,55,101,267,101,55,101,100,101,267,101,100,101,266,101,100,101,80,109,80,148,0,148,9,128,11,148,0,128,11,114,16,148,0,114,16,49,39,148,0,49,39,46,25,148,0,46,25,39,17,148,0,39,17,27,12,148,0,27,12,8,9,148,0,8,9,8,0,101,55,101,268,100,269,101,55,100,269,100,270,101,55,100,270,100,271,50,60,49,39,114,16,50,60,114,16,106,23,50,60,106,23,102,36,50,60,102,36,50,276,217,172,223,96,221,250,27,319,8,331,8,321, +36,42,36,28,33,19,28,13,19,9,6,7,6,0,79,0,79,275,81,293,86,308,95,319,107,326,122,328,137,325,150,316,159,302,165,282,167,258,165,237,159,220,150,207,137,199,119,195,114,194,110,193,107,191,105,189,105,184,107,182,110,180,115,179,121,179,145,173,163,161,176,140,184,111,187,75,186,61,185,48,182,36,179,26,175,19,172,15,164,11,160,10,155,10,150,11,146,12,143,15,142,19,141,25,140,36,138,42,135,48,130,52,125,55,118,56,111,55,105,51,100,46,97,40,96,32,98,20,105,10,115,2,129,-2,145,-3,173,0,198,14,217,35,229,62,234,93,233,110,229,125,223,139,214,152,203,163,193,170,183,176,172,181,158,185,142,189,169,203,189,216,202,230,208,246,210,266,207,291,195,312,178,328,154,338,126,342,93,337,68,324,50,301,40,269,36,227,158,253,86,328,81,332,77,335,73,337,65,339,59,338,53,336,50,333,47,329,46,323,47,318,49,314,52,309,56,305,61,301,138,253,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3, +33,19,28,13,79,0,79,0,28,13,19,9,79,0,19,9,6,7,158,185,142,189,145,173,145,173,142,189,137,199,145,173,137,199,121,179,121,179,137,199,119,195,121,179,119,195,115,179,115,179,119,195,114,194,115,179,114,194,110,180,110,180,114,194,110,193,110,180,110,193,107,182,107,182,110,193,107,191,107,182,107,191,105,184,105,184,107,191,105,189,105,184,105,189,105,187,81,293,86,308,93,337,93,337,86,308,95,319,93,337,95,319,126,342,126,342,95,319,107,326,126,342,107,326,122,328,122,328,137,325,126,342,126,342,137,325,154,338,165,237,169,203,167,258,167,258,169,203,178,328,178,328,169,203,189,216,178,328,189,216,195,312,195,312,189,216,202,230,195,312,202,230,207,291,207,291,202,230,208,246,207,291,208,246,210,266,137,325,150,316,154,338,154,338,150,316,159,302,154,338,159,302,178,328,178,328,159,302,165,282,178,328,165,282,167,258,150,207,142,189,169,203,150,207,169,203,159,220,159,220,169,203,165,237,229,62,234,93,233,110,229,62,233,110,229,125,229,62,229,125,223,139,229,62,223,139,217,35,223,139,214,152,217,35,217,35,214,152,203,163,217,35,203,163,198,14,198,14,203,163,193,170,198,14,193,170,187,75,187,75,193,170,184,111,198,14,187,75,186,61,198,14,186,61,185,48,198,14,185,48,182,36,198,14,182,36,179,26,198,14,179,26,175,19,198,14,175,19,173,0,141,25,140,36,138,42,141,25,138,42,145,-3,141,25,145,-3,142,19,68,324,50,301,79,0,68,324,79,0,79,275,68,324,79,275,81,293,68,324,81,293,93,337,79,0,50,301,40,269,79,0,40,269,36,227,79,0,36,227,36,42,79,0,36,42,36,28,79,0,36,28,33,19,168,13,164,11,173,0,173,0,164,11,160,10,173,0,160,10,155,10,155,10,150,11,173,0,173,0,150,11,146,12,173,0,146,12,145,-3,145,-3,146,12,143,15,145,-3,143,15,142,19,168,13,173,0,172,15,172,15,173,0,175,19,138,42,135,48,145,-3,145,-3,135,48,130,52,145,-3,130,52,129,-2,129,-2,130,52,125,55,129,-2,125,55,118,56,115,2,129,-2,118,56,115,2,118,56,111,55,115,2,111,55,105,51,115,2,105,51,105,10,100,46,97,40,98,20,100,46,98,20,105,10,100,46,105,10,105,51,158,185,163,161,172,181,172,181,163,161,176,140,172,181,176,140,183,176,183,176,176,140,184,111,183,176,184,111,193,170,158,185,145,173,163,161,98,20,97,40,96,32,79,0,6,7,6,0,142,189,150,207,137,199, +158,253,86,328,81,332,77,335,73,337,65,339,59,338,53,336,50,333,47,329,46,323,47,318,49,314,52,309,56,305,61,301,138,253,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,60,253,79,253,156,302,162,306,166,310,169,314,171,318,171,329,168,333,165,336,160,338,154,339,146,337,142,335,138,332,133,328,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,190,253, +138,253,158,253,86,328,138,253,86,328,81,332,138,253,81,332,77,335,138,253,77,335,73,337,138,253,73,337,69,338,138,253,69,338,65,339,138,253,65,339,61,301,46,323,47,318,47,329,47,329,47,318,49,314,47,329,49,314,50,333,50,333,49,314,52,309,50,333,52,309,53,336,53,336,52,309,56,305,53,336,56,305,59,338,59,338,56,305,61,301,59,338,61,301,65,339,37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,184,56,186,-3,185,44,29,167,29,183,28,175, +60,253,79,253,156,302,162,306,166,310,169,314,171,318,171,329,168,333,165,336,160,338,154,339,146,337,142,335,138,332,133,328,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,190,253,128,337,97,337,35,253,52,253,113,305,174,253,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,180,319,175,309,170,302,165,297,160,295,153,294,149,294,144,295,138,297, +37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,154,339,156,302,160,338,160,338,156,302,162,306,160,338,162,306,165,336,165,336,162,306,166,310,165,336,166,310,168,333,168,333,166,310,169,314,168,333,169,314,171,329,171,329,169,314,171,318,171,329,171,318,171,323,156,302,154,339,150,338,156,302,150,338,146,337,156,302,146,337,142,335,156,302,142,335,138,332,156,302,138,332,133,328,156,302,133,328,79,253,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,79,253,133,328,60,253,184,56,186,-3,185,44,29,167,29,183,28,175, +190,253,128,337,97,337,35,253,52,253,113,305,174,253,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,180,319,175,309,170,302,165,297,160,295,153,294,149,294,144,295,138,297,133,299,127,301,115,307,108,311,94,315,87,316,80,316,66,314,54,308,43,298,35,284,30,266,44,266,48,274,52,281,57,285,63,288,70,289,73,289,81,287,86,285,90,283,102,278,112,273,121,269,128,267,135,266,142,266,157,268,169,274,180,284,188,299,195,319,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17, +35,253,52,253,97,337,97,337,52,253,113,305,97,337,113,305,128,337,128,337,113,305,174,253,128,337,174,253,190,253,37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,184,56,186,-3,185,44,29,167,29,183,28,175, +180,319,175,309,170,302,165,297,160,295,153,294,149,294,144,295,138,297,133,299,127,301,115,307,108,311,94,315,87,316,80,316,66,314,54,308,43,298,35,284,30,266,44,266,48,274,52,281,57,285,63,288,70,289,73,289,81,287,86,285,90,283,102,278,112,273,121,269,128,267,135,266,142,266,157,268,169,274,180,284,188,299,195,319,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,186,286,185,294,182,301,176,306,169,310,161,311,154,310,147,306,142,301,138,294,137,286,138,278,142,272,147,266,153,263,161,262,169,263,176,266,182,272,185,278,186,286,16383,16383,87,286,86,294,82,301,77,306,70,310,62,311,54,310,48,306,42,301,39,294,37,286,39,278,42,272,47,266,54,263,61,262,69,263,76,266,82,272,86,278,87,286,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127, +48,274,52,281,54,308,54,308,52,281,57,285,54,308,57,285,66,314,66,314,57,285,63,288,66,314,63,288,70,289,70,289,73,289,80,316,80,316,73,289,77,288,80,316,77,288,81,287,44,266,48,274,54,308,44,266,54,308,43,298,44,266,43,298,35,284,44,266,35,284,30,266,37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,80,316,81,287,87,316,87,316,81,287,86,285,87,316,86,285,90,283,90,283,102,278,94,315,94,315,102,278,101,313,80,316,66,314,70,289,94,315,87,316,90,283,101,313,102,278,108,311,108,311,102,278,112,273,108,311,112,273,115,307,115,307,112,273,121,269,115,307,121,269,127,301,127,301,121,269,128,267,127,301,128,267,133,299,133,299,128,267,135,266,133,299,135,266,138,297,138,297,135,266,142,266,138,297,142,266,144,295,144,295,142,266,157,268,144,295,157,268,149,294,149,294,157,268,153,294,160,295,153,294,157,268,160,295,157,268,169,274,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,180,319,175,309,180,284,180,319,180,284,188,299,180,319,188,299,195,319,170,302,165,297,169,274,170,302,169,274,180,284,170,302,180,284,175,309,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,29,167,29,183,28,175,160,295,169,274,165,297,184,56,186,-3,185,44, +186,286,185,294,182,301,176,306,169,310,161,311,154,310,147,306,142,301,138,294,137,286,138,278,142,272,147,266,153,263,161,262,169,263,176,266,182,272,185,278,186,286,16383,16383,87,286,86,294,82,301,77,306,70,310,62,311,54,310,48,306,42,301,39,294,37,286,39,278,42,272,47,266,54,263,61,262,69,263,76,266,82,272,86,278,87,286,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,162,306,159,322,152,336,142,347,128,354,113,357,97,354,83,347,72,336,65,323,63,307,65,291,72,277,83,267,96,260,112,257,128,260,141,267,152,277,159,291,162,306,16383,16383,145,307,143,296,139,287,132,280,122,276,112,274,101,276,92,280,85,287,81,296,79,307,81,317,86,326,93,333,102,338,112,339,122,338,131,333,139,326,143,317,145,307,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134, +161,311,161,262,169,310,169,310,161,262,169,263,169,310,169,263,176,306,176,306,169,263,176,266,176,306,176,266,182,301,182,301,176,266,182,272,182,301,182,272,185,294,185,294,182,272,185,278,185,294,185,278,186,286,137,286,138,278,138,294,138,294,138,278,142,272,138,294,142,272,142,301,142,301,142,272,147,266,142,301,147,266,147,306,147,306,147,266,153,263,147,306,153,263,154,310,154,310,153,263,161,262,154,310,161,262,161,311,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,37,286,39,278,39,294,39,294,39,278,42,272,39,294,42,272,42,301,42,301,42,272,47,266,42,301,47,266,48,306,48,306,47,266,54,263,48,306,54,263,54,310,54,310,54,263,61,262,54,310,61,262,62,311,62,311,61,262,69,263,62,311,69,263,70,310,70,310,69,263,76,266,70,310,76,266,77,306,77,306,76,266,82,272,77,306,82,272,82,301,82,301,82,272,86,278,82,301,86,278,86,294,86,294,86,278,87,286,37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,29,167,29,183,28,175,184,56,186,-3,185,44, +162,306,159,322,152,336,142,347,128,354,113,357,97,354,83,347,72,336,65,323,63,307,65,291,72,277,83,267,96,260,112,257,128,260,141,267,152,277,159,291,162,306,16383,16383,145,307,143,296,139,287,132,280,122,276,112,274,101,276,92,280,85,287,81,296,79,307,81,317,86,326,93,333,102,338,112,339,122,338,131,333,139,326,143,317,145,307,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,98,0,113,6,128,16,143,31,144,31,147,17,151,7,157,0,166,-3,176,-4,186,-3,195,-1,204,2,212,9,221,19,16383,16383,143,64,143,56,142,49,138,43,133,38,126,32,121,29,109,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,79,68,87,73,94,79,101,88,108,99,114,111,121,126,127,143,134,310,77,296,58,283,44,269,35,254,30,238,28,226,30,215,33,205,38,197,45,190,54,185,65,181,78,179,93,178,112,177,138,308,138,302,173,292,199,277,216,255,227,228,230,215,229,203,227,192,222,181,216,169,206,157,216,147,222,136,227,123,229,109,230,84,227,62,220,45,208,34,193,30,176,31,168,34,161,38,156,44,153,52,152,59,153,66,156,70,161,73,167,74,175,74,185,73,188,73,196,74,203,79,208,86,213,96,216,107,217,119,215,127,210,133,202,136,189,137,172,137,141,73,123,48,112,32,99,24,84,20,68,19,50,22,32,30,17,42,6,58,0,77,-2,91,-1,105,1,119,7,134,17,153,31,164,18,175,8,188,1,202,-1,218,-2,230,-2,243,0,254,3,266,9,276,17,285,24,293,33,300,44,308,58,316,75,16383,16383,177,153,180,177,186,194,194,206,206,212,221,214,235,212,246,206,254,194,259,177,261,153,16383,16383,137,100,138,90,140,68,146,46,146,45,147,45,147,44,143,38,134,31,121,25,108,21,95,19,83,21,74,28,67,37,64,49,63,63,64,79,71,92,85,103,106,114,137,127,199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161, +143,296,139,287,141,267,141,267,139,287,132,280,141,267,132,280,128,260,128,260,132,280,122,276,128,260,122,276,112,257,112,257,122,276,112,274,63,307,65,291,65,323,65,323,65,291,72,277,65,323,72,277,72,336,72,336,72,277,83,267,72,336,83,267,79,307,79,307,83,347,72,336,37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,218,117,216,111,230,117,216,127,229,127,229,117,216,128,211,127,229,128,211,140,226,140,226,128,211,136,202,140,226,136,202,142,190,76,208,83,213,85,227,85,227,83,213,93,217,85,227,93,217,98,229,98,229,93,217,104,218,98,229,104,218,111,230,73,224,70,194,71,201,73,224,71,201,76,208,73,224,76,208,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,113,357,112,339,122,338,113,357,122,338,128,354,128,354,122,338,131,333,128,354,131,333,142,347,142,347,131,333,139,326,142,347,139,326,143,317,184,56,184,152,184,168,184,56,184,168,183,181,184,56,183,181,180,191,184,56,180,191,186,-3,190,28,195,-1,195,25,195,25,195,-1,200,23,204,24,200,23,204,2,204,24,204,2,212,9,187,35,185,44,186,-3,187,35,186,-3,195,-1,187,35,195,-1,190,28,147,17,151,7,152,222,152,222,151,7,157,0,152,222,157,0,162,215,162,215,157,0,166,-3,162,215,166,-3,170,208,170,208,166,-3,176,-4,170,208,176,-4,176,199,176,199,176,-4,186,-3,176,199,186,-3,180,191,152,222,140,226,142,190,152,222,142,190,143,173,152,222,143,173,143,134,152,222,143,134,144,31,152,222,144,31,147,17,143,31,144,31,143,134,143,146,143,134,143,173,216,29,212,27,212,9,216,29,212,9,221,19,216,29,221,19,221,33,208,25,204,24,212,9,208,25,212,9,212,27,200,23,195,-1,204,2,162,306,159,322,159,291,159,291,159,322,152,336,159,291,152,336,152,277,152,277,152,336,145,307,143,317,145,307,152,336,143,317,152,336,142,347,143,296,141,267,152,277,143,296,152,277,145,307,86,326,93,333,97,354,97,354,93,333,102,338,97,354,102,338,113,357,113,357,102,338,112,339,83,347,79,307,81,317,83,347,81,317,86,326,83,347,86,326,97,354,101,276,92,280,96,260,101,276,96,260,112,257,101,276,112,257,112,274,85,287,81,296,83,267,85,287,83,267,96,260,85,287,96,260,92,280,143,31,143,134,143,64,143,31,143,64,143,56,143,31,143,56,142,49,143,31,142,49,138,43,143,31,138,43,133,38,143,31,133,38,128,16,128,16,133,38,126,32,126,32,121,29,128,16,128,16,121,29,115,27,128,16,115,27,113,6,113,6,115,27,109,25,113,6,109,25,103,24,99,114,111,121,114,135,114,135,111,121,126,127,114,135,126,127,143,146,143,146,126,127,143,134,65,79,68,87,75,118,75,118,68,87,73,94,75,118,73,94,79,101,79,101,88,108,92,126,92,126,88,108,99,114,92,126,99,114,114,135,92,126,75,118,79,101,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,79,63,112,65,79,75,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,98,0,86,25,86,25,98,0,97,24,103,24,97,24,98,0,103,24,98,0,113,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,79,307,83,267,81,296,184,56,186,-3,185,44,29,167,29,183,28,175, +310,77,296,58,283,44,269,35,254,30,238,28,226,30,215,33,205,38,197,45,190,54,185,65,181,78,179,93,178,112,177,138,308,138,302,173,292,199,277,216,255,227,228,230,215,229,203,227,192,222,181,216,169,206,157,216,147,222,136,227,123,229,109,230,84,227,62,220,45,208,34,193,30,176,31,168,34,161,38,156,44,153,52,152,59,153,66,156,70,161,73,167,74,175,74,185,73,188,73,196,74,203,79,208,86,213,96,216,107,217,119,215,127,210,133,202,136,189,137,172,137,141,73,123,48,112,32,99,24,84,20,68,19,50,22,32,30,17,42,6,58,0,77,-2,91,-1,105,1,119,7,134,17,153,31,164,18,175,8,188,1,202,-1,218,-2,230,-2,243,0,254,3,266,9,276,17,285,24,293,33,300,44,308,58,316,75,16383,16383,177,153,180,177,186,194,194,206,206,212,221,214,235,212,246,206,254,194,259,177,261,153,16383,16383,137,100,138,90,140,68,146,46,146,45,147,45,147,44,143,38,134,31,121,25,108,21,95,19,83,21,74,28,67,37,64,49,63,63,64,79,71,92,85,103,106,114,137,127,199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161,195,166,198,172,199,179,195,195,184,209,167,220,146,227,122,230,108,229,94,226,80,220,67,213,55,204,40,189,28,172,19,152,14,130,12,106,16,72,27,43,45,20,68,4,96,-3,77,-49,80,-51,83,-50,85,-50,88,-49,94,-49,104,-50,112,-52,117,-55,120,-60,121,-67,120,-74,116,-81,111,-85,103,-88,94,-89,88,-89,82,-88,75,-87,69,-86,61,-83,54,-98,63,-102,79,-106,87,-106,96,-107,117,-105,135,-99,148,-91,156,-79,158,-64,157,-52,151,-43,142,-36,130,-32,116,-30,108,-30,105,-31,103,-31,113,-4,136,0,156,9,174,24,190,46,206,74,155,253,83,328,78,332,74,335,69,337,61,339,55,338,50,336,46,333,44,329,43,323,44,318,46,314,49,309,53,305,58,301,135,253,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71, +73,196,73,196,73,196,73,196,74,203,62,220,73,196,62,220,66,156,73,196,66,156,70,161,143,38,134,31,134,17,134,17,134,31,121,25,134,17,121,25,119,7,119,7,121,25,108,21,119,7,108,21,105,1,105,1,108,21,95,19,105,1,95,19,91,-1,91,-1,95,19,83,21,91,-1,83,21,77,-2,77,-2,83,21,74,28,77,-2,74,28,67,37,63,63,58,0,64,49,64,49,58,0,77,-2,64,49,77,-2,67,37,74,203,79,208,84,227,84,227,79,208,86,213,84,227,86,213,109,230,109,230,86,213,96,216,109,230,96,216,107,217,107,217,119,215,109,230,109,230,119,215,123,229,175,8,177,138,169,206,175,8,169,206,164,18,164,18,169,206,157,216,164,18,157,216,153,31,153,31,157,216,147,44,147,45,147,44,147,222,147,222,147,44,157,216,147,222,136,227,136,189,147,222,136,189,137,172,147,222,137,172,137,127,147,222,137,127,138,90,147,222,138,90,139,79,147,222,139,79,140,68,147,222,140,68,143,57,147,222,143,57,146,46,147,222,146,46,146,45,147,222,146,45,147,45,137,141,137,127,137,172,136,227,123,229,127,210,136,227,127,210,133,202,136,227,133,202,136,189,228,230,221,214,235,212,228,230,235,212,255,227,255,227,235,212,246,206,255,227,246,206,254,194,177,153,180,177,181,216,181,216,180,177,186,194,181,216,186,194,192,222,192,222,186,194,194,206,192,222,194,206,203,227,203,227,194,206,206,212,203,227,206,212,215,229,215,229,206,212,221,214,215,229,221,214,228,230,277,216,261,153,308,138,308,138,261,153,177,153,308,138,177,153,177,138,169,206,177,138,177,153,169,206,177,153,181,216,259,177,261,153,277,216,259,177,277,216,255,227,259,177,255,227,254,194,292,199,277,216,308,138,292,199,308,138,302,173,226,30,215,33,218,-2,218,-2,215,33,205,38,218,-2,205,38,202,-1,202,-1,205,38,197,45,202,-1,197,45,190,54,190,54,185,65,188,1,188,1,185,65,181,78,188,1,181,78,179,93,175,8,188,1,179,93,175,8,179,93,178,112,175,8,178,112,177,138,218,-2,230,-2,226,30,226,30,230,-2,238,28,254,30,238,28,243,0,254,30,243,0,254,3,190,54,188,1,202,-1,285,24,293,33,296,58,296,58,293,33,300,44,296,58,300,44,310,77,310,77,300,44,308,58,310,77,308,58,316,75,254,3,266,9,269,35,269,35,266,9,276,17,269,35,276,17,283,44,283,44,276,17,285,24,283,44,285,24,296,58,238,28,230,-2,243,0,143,38,134,17,153,31,143,38,153,31,147,44,64,79,71,92,73,123,73,123,71,92,85,103,73,123,85,103,137,141,137,141,85,103,106,114,137,141,106,114,137,127,42,6,58,0,48,112,48,112,58,0,63,63,48,112,63,63,64,79,20,68,22,32,24,84,24,84,22,32,30,17,24,84,30,17,32,99,32,99,30,17,42,6,32,99,42,6,48,112,38,156,44,153,45,208,45,208,44,153,52,152,45,208,52,152,62,220,62,220,52,152,59,153,62,220,59,153,66,156,34,193,30,176,31,168,34,193,31,168,34,161,34,193,34,161,38,156,34,193,38,156,45,208,74,185,73,188,73,167,74,185,73,167,74,175,74,185,74,175,74,180,73,167,73,188,73,192,73,167,73,192,73,196,73,167,73,196,70,161,62,220,74,203,84,227,22,32,20,68,19,50,48,112,64,79,73,123,138,90,137,127,137,100,254,30,254,3,269,35,123,229,119,215,127,210, +199,78,185,60,172,46,159,38,144,33,128,31,103,36,81,49,65,69,54,96,51,128,54,157,63,181,78,200,96,211,119,215,128,215,136,212,141,208,145,201,148,191,151,180,154,172,159,166,163,161,169,158,175,157,183,158,189,161,195,166,198,172,199,179,195,195,184,209,167,220,146,227,122,230,108,229,94,226,80,220,67,213,55,204,40,189,28,172,19,152,14,130,12,106,16,72,27,43,45,20,68,4,96,-3,77,-49,80,-51,83,-50,85,-50,88,-49,94,-49,104,-50,112,-52,117,-55,120,-60,121,-67,120,-74,116,-81,111,-85,103,-88,94,-89,88,-89,82,-88,75,-87,69,-86,61,-83,54,-98,63,-102,79,-106,87,-106,96,-107,117,-105,135,-99,148,-91,156,-79,158,-64,157,-52,151,-43,142,-36,130,-32,116,-30,108,-30,105,-31,103,-31,113,-4,136,0,156,9,174,24,190,46,206,74,155,253,83,328,78,332,74,335,69,337,61,339,55,338,50,336,46,333,44,329,43,323,44,318,46,314,49,309,53,305,58,301,135,253,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,58,253,78,253,155,302,161,306,165,310,168,314,170,318,170,323,169,329,167,333,163,336,158,338,152,339,148,338,145,337,141,335,137,332,132,328,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31, +81,49,65,69,68,4,68,4,65,69,54,96,68,4,54,96,45,20,45,20,54,96,51,128,55,204,51,128,54,157,55,204,54,157,63,181,87,-106,96,-107,88,-89,88,-89,96,-107,94,-89,103,-88,94,-89,96,-107,103,-88,96,-107,117,-105,96,-3,94,-49,104,-50,96,-3,104,-50,103,-31,96,-3,103,-31,103,36,103,36,103,-31,113,-4,96,-3,77,-49,80,-51,96,-3,80,-51,83,-50,96,-3,83,-50,85,-50,96,-3,85,-50,88,-49,96,-3,88,-49,91,-49,96,-3,91,-49,94,-49,185,60,172,46,174,24,174,24,172,46,159,38,174,24,159,38,156,9,156,9,159,38,144,33,156,9,144,33,136,0,136,0,144,33,128,31,113,-4,136,0,128,31,113,-4,128,31,103,36,81,49,68,4,96,-3,81,49,96,-3,103,36,136,212,141,208,146,227,146,227,141,208,145,201,146,227,145,201,148,191,148,191,151,180,167,220,167,220,151,180,154,172,167,220,154,172,159,166,122,230,119,215,128,215,122,230,128,215,146,227,146,227,128,215,136,212,195,195,184,209,189,161,195,195,189,161,195,166,195,195,195,166,198,172,195,195,198,172,199,179,184,209,167,220,169,158,184,209,169,158,175,157,184,209,175,157,183,158,184,209,183,158,189,161,167,220,159,166,163,161,167,220,163,161,169,158,167,220,146,227,148,191,190,46,206,74,199,78,190,46,199,78,185,60,190,46,185,60,174,24,96,211,119,215,108,229,96,211,108,229,94,226,96,211,94,226,80,220,96,211,80,220,78,200,67,213,55,204,63,181,67,213,63,181,78,200,67,213,78,200,80,220,45,20,51,128,55,204,45,20,55,204,40,189,45,20,40,189,28,172,45,20,28,172,27,43,19,152,14,130,16,72,19,152,16,72,27,43,19,152,27,43,28,172,158,-64,157,-52,156,-79,156,-79,157,-52,151,-43,156,-79,151,-43,148,-91,148,-91,151,-43,142,-36,148,-91,142,-36,135,-99,135,-99,142,-36,130,-32,135,-99,130,-32,121,-67,121,-67,130,-32,120,-60,117,-55,120,-60,130,-32,117,-55,130,-32,116,-30,117,-55,116,-30,113,-30,117,-55,113,-30,112,-52,112,-52,113,-30,110,-30,112,-52,110,-30,108,-30,112,-52,108,-30,105,-31,112,-52,105,-31,104,-50,135,-99,121,-67,120,-74,135,-99,120,-74,117,-105,117,-105,120,-74,116,-81,117,-105,116,-81,111,-85,61,-83,63,-102,69,-86,69,-86,63,-102,71,-104,69,-86,71,-104,75,-87,75,-87,71,-104,79,-106,75,-87,79,-106,82,-88,82,-88,79,-106,87,-106,82,-88,87,-106,88,-89,63,-102,61,-83,54,-98,103,-88,117,-105,111,-85,103,-31,104,-50,105,-31,119,215,122,230,108,229,16,72,14,130,12,106, +155,253,83,328,78,332,74,335,69,337,61,339,55,338,50,336,46,333,44,329,43,323,44,318,46,314,49,309,53,305,58,301,135,253,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,58,253,78,253,155,302,161,306,165,310,168,314,170,318,170,323,169,329,167,333,163,336,158,338,152,339,148,338,145,337,141,335,137,332,132,328,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176, +56,85,75,0,62,71,62,71,75,0,71,57,80,47,71,57,75,0,80,47,75,0,108,-4,52,100,50,118,49,15,52,100,49,15,75,0,52,100,75,0,56,85,12,108,17,70,17,148,17,148,17,70,29,39,17,148,29,39,31,182,31,182,29,39,49,15,31,182,49,15,49,138,49,138,49,15,50,118,135,253,155,253,83,328,135,253,83,328,78,332,135,253,78,332,74,335,135,253,74,335,69,337,135,253,69,337,65,338,135,253,65,338,61,339,135,253,61,339,58,301,43,323,44,318,44,329,44,329,44,318,46,314,44,329,46,314,46,333,46,333,46,314,49,309,46,333,49,309,50,336,50,336,49,309,53,305,50,336,53,305,55,338,55,338,53,305,58,301,55,338,58,301,61,339,133,228,116,230,120,210,120,210,116,230,103,212,87,210,103,212,116,230,87,210,116,230,81,224,190,62,176,48,181,26,181,26,176,48,162,37,181,26,162,37,160,9,160,9,162,37,146,31,160,9,146,31,136,-1,136,-1,146,31,127,30,203,138,201,153,198,166,203,138,198,166,195,177,203,138,195,177,190,186,203,138,190,186,185,195,203,138,185,195,175,207,203,138,175,207,163,217,203,138,163,217,151,155,203,138,151,155,50,155,203,138,50,155,49,138,141,192,147,176,149,224,149,224,147,176,151,155,149,224,151,155,163,217,198,49,212,79,204,82,198,49,204,82,190,62,198,49,190,62,181,26,114,31,101,34,108,-4,114,31,108,-4,136,-1,114,31,136,-1,127,30,90,39,80,47,108,-4,90,39,108,-4,101,34,133,228,120,210,133,203,133,228,133,203,141,192,133,228,141,192,149,224,50,155,55,175,52,207,52,207,55,175,63,191,52,207,63,191,81,224,81,224,63,191,74,203,81,224,74,203,87,210,52,207,31,182,49,138,52,207,49,138,50,155, +58,253,78,253,155,302,161,306,165,310,168,314,170,318,170,323,169,329,167,333,163,336,158,338,152,339,148,338,145,337,141,335,137,332,132,328,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,190,253,127,337,97,337,35,253,51,253,112,305,173,253,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,186,286,185,294,181,301,176,306,169,310,161,311,153,310,147,306,141,301,138,294,137,286, +203,138,201,153,198,166,203,138,198,166,195,177,203,138,195,177,190,186,203,138,190,186,185,195,203,138,185,195,175,207,203,138,175,207,163,217,203,138,163,217,151,155,203,138,151,155,50,155,203,138,50,155,49,138,141,192,147,176,149,224,149,224,147,176,151,155,149,224,151,155,163,217,152,339,155,302,158,338,158,338,155,302,161,306,158,338,161,306,163,336,163,336,161,306,165,310,163,336,165,310,167,333,167,333,165,310,168,314,167,333,168,314,169,329,169,329,168,314,170,318,169,329,170,318,170,323,155,302,152,339,148,338,155,302,148,338,145,337,155,302,145,337,141,335,155,302,141,335,137,332,155,302,137,332,132,328,155,302,132,328,78,253,52,100,50,118,49,15,49,15,50,118,49,138,49,15,49,138,31,182,49,15,31,182,29,39,29,39,31,182,17,148,29,39,17,148,17,70,17,70,17,148,12,108,133,228,116,230,120,210,120,210,116,230,103,212,87,210,103,212,116,230,87,210,116,230,81,224,190,62,176,48,181,26,181,26,176,48,162,37,181,26,162,37,160,9,160,9,162,37,146,31,160,9,146,31,136,-1,136,-1,146,31,127,30,198,49,212,79,204,82,198,49,204,82,190,62,198,49,190,62,181,26,114,31,101,34,108,-4,114,31,108,-4,136,-1,114,31,136,-1,127,30,101,34,90,39,108,-4,108,-4,90,39,80,47,108,-4,80,47,75,0,75,0,80,47,71,57,133,228,120,210,133,203,133,228,133,203,141,192,133,228,141,192,149,224,50,155,55,175,52,207,52,207,55,175,63,191,52,207,63,191,81,224,81,224,63,191,74,203,81,224,74,203,87,210,52,207,31,182,49,138,52,207,49,138,50,155,75,0,71,57,62,71,75,0,62,71,56,85,75,0,56,85,52,100,75,0,52,100,49,15,78,253,132,328,58,253, +190,253,127,337,97,337,35,253,51,253,112,305,173,253,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,186,286,185,294,181,301,176,306,169,310,161,311,153,310,147,306,141,301,138,294,137,286,138,278,141,272,146,266,153,263,161,262,169,263,176,266,181,272,185,278,186,286,16383,16383,86,286,85,294,82,301,76,306,69,310,61,311,54,310,47,306,42,301,38,294,37,286,38,278,41,272,47,266,53,263,61,262,69,263,76,266,81,272,85,278,86,286,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138, +35,253,51,253,97,337,97,337,51,253,112,305,97,337,112,305,127,337,127,337,112,305,173,253,127,337,173,253,190,253,52,100,50,118,49,15,49,15,50,118,49,138,49,15,49,138,31,182,49,15,31,182,29,39,29,39,31,182,17,148,29,39,17,148,17,70,17,70,17,148,12,108,133,228,116,230,120,210,120,210,116,230,103,212,87,210,103,212,116,230,87,210,116,230,81,224,190,62,176,48,181,26,181,26,176,48,162,37,181,26,162,37,160,9,160,9,162,37,146,31,160,9,146,31,136,-1,136,-1,146,31,127,30,203,138,201,153,198,166,203,138,198,166,195,177,203,138,195,177,190,186,203,138,190,186,185,195,203,138,185,195,175,207,203,138,175,207,163,217,203,138,163,217,151,155,203,138,151,155,50,155,203,138,50,155,49,138,141,192,147,176,149,224,149,224,147,176,151,155,149,224,151,155,163,217,198,49,212,79,204,82,198,49,204,82,190,62,198,49,190,62,181,26,114,31,101,34,108,-4,114,31,108,-4,136,-1,114,31,136,-1,127,30,101,34,90,39,108,-4,108,-4,90,39,80,47,108,-4,80,47,75,0,75,0,80,47,71,57,133,228,120,210,133,203,133,228,133,203,141,192,133,228,141,192,149,224,50,155,55,175,52,207,52,207,55,175,63,191,52,207,63,191,81,224,81,224,63,191,74,203,81,224,74,203,87,210,52,207,31,182,49,138,52,207,49,138,50,155,75,0,71,57,62,71,75,0,62,71,56,85,75,0,56,85,52,100,75,0,52,100,49,15, +186,286,185,294,181,301,176,306,169,310,161,311,153,310,147,306,141,301,138,294,137,286,138,278,141,272,146,266,153,263,161,262,169,263,176,266,181,272,185,278,186,286,16383,16383,86,286,85,294,82,301,76,306,69,310,61,311,54,310,47,306,42,301,38,294,37,286,38,278,41,272,47,266,53,263,61,262,69,263,76,266,81,272,85,278,86,286,16383,16383,204,82,190,62,176,48,162,37,146,31,127,30,114,31,101,34,90,39,80,47,71,57,62,71,56,85,52,100,50,118,49,138,203,138,201,153,198,166,195,177,185,195,175,207,163,217,149,224,133,228,116,230,81,224,52,207,31,182,17,148,12,108,17,70,29,39,49,15,75,0,108,-4,136,-1,160,9,181,26,198,49,212,79,16383,16383,50,155,55,175,63,191,74,203,87,210,103,212,120,210,133,203,141,192,147,176,151,155,115,253,42,328,38,332,33,335,29,337,21,339,15,338,10,336,6,333,4,329,3,323,3,318,5,314,8,309,18,301,95,253,16383,16383,122,0,122,7,105,9,94,14,88,21,85,34,84,52,84,228,82,230,5,203,5,195,15,197,26,197,33,196,37,193,40,187,42,178,42,33,38,20,32,13,20,9,3,7,3,0,25,253,45,253,122,302,127,306,131,310,134,314,136,318,137,323,136,329,134,333,130,336,125,338,119,339,111,337,107,335,103,332,98,328,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,87,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7,8,0,147,253,84,337,54,337,-7,253,8,253,69,305,130,253,16383,16383,110,0,110,7,93,9,83,14,77,21,74,34,73,52,73,228, +203,138,201,153,198,166,203,138,198,166,195,177,203,138,195,177,190,186,203,138,190,186,185,195,203,138,185,195,175,207,203,138,175,207,163,217,203,138,163,217,151,155,203,138,151,155,50,155,203,138,50,155,49,138,141,192,147,176,149,224,149,224,147,176,151,155,149,224,151,155,163,217,137,286,138,278,138,294,138,294,138,278,141,272,138,294,141,272,141,301,141,301,141,272,146,266,141,301,146,266,147,306,147,306,146,266,153,263,147,306,153,263,153,310,153,310,153,263,161,262,153,310,161,262,161,311,161,311,161,262,169,263,161,311,169,263,169,310,169,310,169,263,176,266,169,310,176,266,176,306,176,306,176,266,181,272,176,306,181,272,181,301,181,301,181,272,185,278,181,301,185,278,185,294,185,294,185,278,186,286,37,286,38,278,38,294,38,294,38,278,41,272,38,294,41,272,42,301,42,301,41,272,47,266,42,301,47,266,47,306,47,306,47,266,53,263,47,306,53,263,54,310,54,310,53,263,61,262,54,310,61,262,61,311,61,311,61,262,69,263,61,311,69,263,69,310,69,310,69,263,76,266,69,310,76,266,76,306,76,306,76,266,81,272,76,306,81,272,82,301,82,301,81,272,85,278,82,301,85,278,85,294,85,294,85,278,86,286,52,100,50,118,49,15,49,15,50,118,49,138,49,15,49,138,31,182,49,15,31,182,29,39,29,39,31,182,17,148,29,39,17,148,17,70,17,70,17,148,12,108,133,228,116,230,120,210,120,210,116,230,103,212,87,210,103,212,116,230,87,210,116,230,81,224,190,62,176,48,181,26,181,26,176,48,162,37,181,26,162,37,160,9,160,9,162,37,146,31,160,9,146,31,136,-1,136,-1,146,31,127,30,198,49,212,79,204,82,198,49,204,82,190,62,198,49,190,62,181,26,114,31,101,34,108,-4,114,31,108,-4,136,-1,114,31,136,-1,127,30,101,34,90,39,108,-4,108,-4,90,39,80,47,108,-4,80,47,75,0,75,0,80,47,71,57,133,228,120,210,133,203,133,228,133,203,141,192,133,228,141,192,149,224,50,155,55,175,52,207,52,207,55,175,63,191,52,207,63,191,81,224,81,224,63,191,74,203,81,224,74,203,87,210,52,207,31,182,49,138,52,207,49,138,50,155,75,0,71,57,62,71,75,0,62,71,56,85,75,0,56,85,52,100,75,0,52,100,49,15, +115,253,42,328,38,332,33,335,29,337,21,339,15,338,10,336,6,333,4,329,3,323,3,318,5,314,8,309,18,301,95,253,16383,16383,122,0,122,7,105,9,94,14,88,21,85,34,84,52,84,228,82,230,5,203,5,195,15,197,26,197,33,196,37,193,40,187,42,178,42,33,38,20,32,13,20,9,3,7,3,0,25,253,45,253,122,302,127,306,131,310,134,314,136,318,137,323,136,329,134,333,130,336,125,338,119,339,111,337,107,335,103,332,98,328,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,87,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7, +95,253,115,253,42,328,95,253,42,328,38,332,95,253,38,332,33,335,95,253,33,335,29,337,95,253,29,337,25,338,95,253,25,338,21,339,95,253,21,339,18,301,3,323,3,318,4,329,4,329,3,318,5,314,4,329,5,314,6,333,6,333,5,314,8,309,6,333,8,309,10,336,10,336,8,309,13,305,10,336,13,305,15,338,15,338,13,305,18,301,15,338,18,301,21,339,38,20,32,13,122,0,122,0,32,13,20,9,122,0,20,9,3,7,15,197,19,197,82,230,82,230,19,197,23,197,82,230,23,197,26,197,26,197,33,196,82,230,82,230,33,196,37,193,82,230,37,193,40,187,38,20,122,0,42,33,42,33,122,0,94,14,42,33,94,14,42,52,42,52,94,14,88,21,42,52,88,21,42,166,42,178,42,166,82,230,42,178,82,230,40,187,10,196,15,197,82,230,10,196,82,230,5,203,10,196,5,203,5,195,84,52,84,228,82,230,84,52,82,230,42,166,84,52,42,166,85,34,105,9,94,14,122,0,105,9,122,0,122,7,122,0,3,7,3,0,42,166,88,21,85,34, +25,253,45,253,122,302,127,306,131,310,134,314,136,318,137,323,136,329,134,333,130,336,125,338,119,339,111,337,107,335,103,332,98,328,16383,16383,127,0,127,7,110,9,99,14,93,21,90,34,89,52,89,228,87,230,10,203,10,195,20,197,31,197,38,196,42,193,45,187,47,178,47,33,43,20,37,13,25,9,8,7,8,0,147,253,84,337,54,337,-7,253,8,253,69,305,130,253,16383,16383,110,0,110,7,93,9,83,14,77,21,74,34,73,52,73,228,70,230,-6,203,-6,195,0,196,3,197,15,197,21,196,26,193,29,187,31,178,31,52,30,33,27,20,21,13,9,9,-7,7,-7,0,144,286,143,294,139,301,133,306,127,310,119,311,111,310,104,306, +119,339,122,302,125,338,125,338,122,302,127,306,125,338,127,306,130,336,130,336,127,306,131,310,130,336,131,310,134,333,134,333,131,310,134,314,134,333,134,314,136,329,136,329,134,314,136,318,136,329,136,318,137,323,122,302,119,339,115,338,122,302,115,338,111,337,122,302,111,337,107,335,122,302,107,335,103,332,122,302,103,332,98,328,122,302,98,328,45,253,43,20,37,13,127,0,127,0,37,13,25,9,127,0,25,9,8,7,20,197,24,197,87,230,87,230,24,197,28,197,87,230,28,197,31,197,31,197,38,196,87,230,87,230,38,196,42,193,87,230,42,193,45,187,43,20,127,0,47,33,47,33,127,0,99,14,47,33,99,14,47,52,47,52,99,14,93,21,47,52,93,21,47,166,47,178,47,166,87,230,47,178,87,230,45,187,15,196,20,197,87,230,15,196,87,230,10,203,15,196,10,203,10,195,89,52,89,228,87,230,89,52,87,230,47,166,89,52,47,166,90,34,110,9,99,14,127,0,110,9,127,0,127,7,127,0,8,7,8,0,47,166,93,21,90,34,45,253,98,328,25,253, +147,253,84,337,54,337,-7,253,8,253,69,305,130,253,16383,16383,110,0,110,7,93,9,83,14,77,21,74,34,73,52,73,228,70,230,-6,203,-6,195,0,196,3,197,15,197,21,196,26,193,29,187,31,178,31,52,30,33,27,20,21,13,9,9,-7,7,-7,0,144,286,143,294,139,301,133,306,127,310,119,311,111,310,104,306,99,301,96,294,94,286,96,278,99,272,104,266,111,263,118,262,126,263,133,266,139,272,143,278,144,286,16383,16383,45,286,43,294,40,301,34,306,27,310,20,311,12,310,5,306,0,301,-3,294,-4,286, +-7,253,8,253,54,337,54,337,8,253,69,305,54,337,69,305,84,337,84,337,69,305,130,253,84,337,130,253,147,253,27,20,21,13,110,0,110,0,21,13,9,9,110,0,9,9,-7,7,3,197,8,197,70,230,70,230,8,197,11,197,70,230,11,197,15,197,15,197,21,196,70,230,70,230,21,196,26,193,70,230,26,193,29,187,31,166,31,52,77,21,31,166,77,21,74,34,31,166,74,34,73,52,31,166,73,52,70,230,31,166,70,230,31,178,0,196,3,197,70,230,0,196,70,230,-6,203,0,196,-6,203,-6,195,73,52,73,228,70,230,110,0,110,7,93,9,110,0,93,9,83,14,110,0,83,14,30,33,110,0,30,33,27,20,31,52,30,33,83,14,31,52,83,14,77,21,110,0,-7,7,-7,0,70,230,29,187,31,178, +144,286,143,294,139,301,133,306,127,310,119,311,111,310,104,306,99,301,96,294,94,286,96,278,99,272,104,266,111,263,118,262,126,263,133,266,139,272,143,278,144,286,16383,16383,45,286,43,294,40,301,34,306,27,310,20,311,12,310,5,306,0,301,-3,294,-4,286,-3,278,0,272,5,266,11,263,19,262,27,263,34,266,40,272,43,278,45,286,16383,16383,113,0,113,7,97,9,86,14,80,21,77,34,76,52,76,228,74,230,-2,203,-2,195,2,196,7,197,18,197,25,196,29,193,32,187,34,178,35,166,35,52,34,33,31,20,24,13,12,9,-4,7,-4,0,212,328,195,343,148,318,135,326,122,332,107,337,90,340,71,342,50,329,66,326,80,323,93,318,105,311,118,302,57,270,74,255,135,287,151,272,163,256,172,239,179,220,184,200,170,212,159,221,148,226,136,229,123,230,89,224,59,208,35,182,20,148,15,108,20,70,35,38,58,15,88,0,123,-4,145,-2,165,3,182,13,196,26,209,44,218,60,225,79,231,99,234,120,235,142,233,179,225,215,211,248,192,278,166,304,16383,16383,190,101,187,69,179,44,167,25,151,13,132,9,104,18,83,41,70,73,62,108,60,141,62,165,70,185,83,201,99,212,118,216,142,211, +31,20,113,0,34,33,34,33,113,0,86,14,34,33,86,14,35,52,35,52,86,14,80,21,35,52,80,21,35,166,35,166,80,21,77,34,35,166,77,34,76,52,74,230,-2,203,2,196,74,230,2,196,7,197,74,230,7,197,11,197,74,230,11,197,15,197,74,230,15,197,18,197,74,230,18,197,25,196,74,230,25,196,29,193,74,230,29,193,32,187,74,230,32,187,34,178,74,230,34,178,35,166,74,230,35,166,76,52,74,230,76,52,76,228,94,286,96,278,96,294,96,294,96,278,99,272,96,294,99,272,99,301,99,301,99,272,104,266,99,301,104,266,104,306,104,306,104,266,111,263,104,306,111,263,111,310,111,310,111,263,118,262,111,310,118,262,119,311,119,311,118,262,126,263,119,311,126,263,127,310,127,310,126,263,133,266,127,310,133,266,133,306,133,306,133,266,139,272,133,306,139,272,139,301,139,301,139,272,143,278,139,301,143,278,143,294,143,294,143,278,144,286,97,9,86,14,113,0,97,9,113,0,113,7,113,0,31,20,24,13,113,0,24,13,12,9,113,0,12,9,-4,7,113,0,-4,7,-4,0,-4,286,-3,278,-3,294,-3,294,-3,278,0,272,-3,294,0,272,0,301,0,301,0,272,5,266,0,301,5,266,5,306,5,306,5,266,11,263,5,306,11,263,12,310,12,310,11,263,19,262,12,310,19,262,20,311,20,311,19,262,27,263,20,311,27,263,27,310,27,310,27,263,34,266,27,310,34,266,34,306,34,306,34,266,40,272,34,306,40,272,40,301,40,301,40,272,43,278,40,301,43,278,43,294,43,294,43,278,45,286,2,196,-2,203,-2,195, +212,328,195,343,148,318,135,326,122,332,107,337,90,340,71,342,50,329,66,326,80,323,93,318,105,311,118,302,57,270,74,255,135,287,151,272,163,256,172,239,179,220,184,200,170,212,159,221,148,226,136,229,123,230,89,224,59,208,35,182,20,148,15,108,20,70,35,38,58,15,88,0,123,-4,145,-2,165,3,182,13,196,26,209,44,218,60,225,79,231,99,234,120,235,142,233,179,225,215,211,248,192,278,166,304,16383,16383,190,101,187,69,179,44,167,25,151,13,132,9,104,18,83,41,70,73,62,108,60,141,62,165,70,185,83,201,99,212,118,216,142,211,162,195,177,171,187,139,190,101,196,319,191,309,186,302,181,297,176,295,170,294,165,294,160,295,154,297,149,299,143,301,131,307,124,311,110,315,103,316,96,316,82,314,70,308,59,298,51,284,46,266,60,266,64,274,68,281,73,285,79,288,85,289,89,289,97,287,102,285,106,283,118,278,128,273,137,269,144,267,151,266,158,266,173,268,185,274,195,284,203,299,210,319,16383,16383,243,0,243,7,230,9,221,13,216,19,213,29,212,42,212,153,210,180,202,201,190,217,174,227,153,230,139,229,125,224,111,216,96,205,81,190,80,190,80,228,76,230,50,220,37,216,23,212,8,208,8,199,10,200,13,200,16,201,22,201,30,200, +136,229,123,230,142,211,142,211,123,230,118,216,99,212,118,216,123,230,99,212,123,230,89,224,122,332,118,302,135,287,122,332,135,287,135,326,135,326,135,287,151,272,135,326,151,272,148,318,148,318,151,272,166,304,148,318,166,304,195,343,195,343,166,304,212,328,107,337,90,340,93,318,107,337,93,318,105,311,107,337,105,311,118,302,107,337,118,302,122,332,50,329,66,326,71,342,71,342,66,326,80,323,71,342,80,323,90,340,90,340,80,323,93,318,187,69,179,44,182,13,182,13,179,44,167,25,182,13,167,25,165,3,165,3,167,25,151,13,165,3,151,13,145,-2,145,-2,151,13,132,9,145,-2,132,9,123,-4,123,-4,132,9,104,18,123,-4,104,18,88,0,88,0,104,18,83,41,88,0,83,41,70,73,88,0,70,73,58,15,58,15,70,73,62,108,58,15,62,108,60,141,60,141,62,165,59,208,59,208,62,165,70,185,59,208,70,185,89,224,89,224,70,185,83,201,89,224,83,201,99,212,15,108,20,70,20,148,20,148,20,70,35,38,20,148,35,38,35,182,35,182,35,38,58,15,35,182,58,15,59,208,59,208,58,15,60,141,151,272,163,256,166,304,166,304,163,256,172,239,166,304,172,239,192,278,192,278,172,239,179,220,192,278,179,220,184,200,118,302,57,270,74,255,118,302,74,255,135,287,184,200,187,139,192,278,192,278,187,139,190,101,196,26,190,101,187,69,233,179,225,215,225,79,233,179,225,79,231,99,233,179,231,99,234,120,233,179,234,120,235,142,196,26,209,44,211,248,211,248,209,44,218,60,211,248,218,60,225,215,225,215,218,60,225,79,192,278,190,101,196,26,192,278,196,26,211,248,187,139,184,200,177,171,177,171,184,200,170,212,177,171,170,212,162,195,162,195,170,212,159,221,162,195,159,221,148,226,148,226,136,229,142,211,148,226,142,211,162,195,187,69,182,13,196,26, +196,319,191,309,186,302,181,297,176,295,170,294,165,294,160,295,154,297,149,299,143,301,131,307,124,311,110,315,103,316,96,316,82,314,70,308,59,298,51,284,46,266,60,266,64,274,68,281,73,285,79,288,85,289,89,289,97,287,102,285,106,283,118,278,128,273,137,269,144,267,151,266,158,266,173,268,185,274,195,284,203,299,210,319,16383,16383,243,0,243,7,230,9,221,13,216,19,213,29,212,42,212,153,210,180,202,201,190,217,174,227,153,230,139,229,125,224,111,216,96,205,81,190,80,190,80,228,76,230,50,220,37,216,23,212,8,208,8,199,10,200,13,200,16,201,22,201,30,200,35,197,38,191,40,181,40,47,39,32,37,21,31,14,22,9,9,7,9,0,114,0,114,7,101,9,92,13,86,18,83,26,82,36,82,174,95,186,105,194,115,199,124,202,133,203,147,201,157,195,164,185,169,171,170,152,170,52,169,35,166,23,161,15,152,10,139,7,138,0,166,253,94,328,89,332,84,335,80,337,72,339,66,338,61,336,57,333,55,329,54,323,55,318,57,314,60,309,64,305,69,301,146,253,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,77,253,97,253,174,302,180,306,184,310,187,314,189,318,189,323,188,329,186,333,182,336,177,338,171,339,163,337,160,335,156,332,151,328,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76, +37,21,31,14,114,0,114,0,31,14,22,9,114,0,22,9,9,7,13,200,16,201,23,212,23,212,16,201,19,201,23,212,19,201,22,201,22,201,30,200,23,212,23,212,30,200,37,216,23,212,8,208,10,200,23,212,10,200,13,200,30,200,35,197,37,216,37,216,35,197,38,191,37,216,38,191,50,220,50,220,38,191,40,181,50,220,40,181,40,169,83,26,40,169,40,47,83,26,40,47,86,18,86,18,40,47,92,13,80,228,76,230,80,190,80,190,76,230,82,36,80,190,82,36,81,190,81,190,82,36,82,174,81,190,82,174,96,205,96,205,82,174,95,186,96,205,95,186,105,194,64,274,68,281,70,308,70,308,68,281,73,285,70,308,73,285,82,314,82,314,73,285,79,288,82,314,79,288,85,289,85,289,89,289,96,316,96,316,89,289,93,288,96,316,93,288,97,287,60,266,64,274,70,308,60,266,70,308,59,298,60,266,59,298,51,284,60,266,51,284,46,266,96,316,97,287,103,316,103,316,97,287,102,285,103,316,102,285,106,283,106,283,118,278,110,315,110,315,118,278,117,313,96,316,82,314,85,289,110,315,103,316,106,283,117,313,118,278,124,311,124,311,118,278,128,273,124,311,128,273,131,307,131,307,128,273,137,269,131,307,137,269,143,301,143,301,137,269,144,267,143,301,144,267,149,299,149,299,144,267,151,266,149,299,151,266,154,297,154,297,151,266,158,266,154,297,158,266,160,295,160,295,158,266,173,268,160,295,173,268,165,294,165,294,173,268,170,294,176,295,170,294,173,268,176,295,173,268,185,274,96,205,105,194,111,216,111,216,105,194,115,199,111,216,115,199,125,224,125,224,115,199,124,202,125,224,124,202,133,203,133,203,147,201,139,229,139,229,147,201,153,230,82,36,76,230,63,225,82,36,63,225,83,26,139,229,125,224,133,203,166,23,161,15,243,0,243,0,161,15,152,10,243,0,152,10,139,7,157,195,164,185,174,227,174,227,164,185,169,171,174,227,169,171,170,152,216,19,170,152,170,52,216,19,170,52,221,13,221,13,170,52,169,35,221,13,169,35,243,0,243,0,169,35,166,23,153,230,147,201,157,195,153,230,157,195,174,227,212,42,212,153,210,180,212,42,210,180,202,201,212,42,202,201,213,29,230,9,221,13,243,0,230,9,243,0,243,7,213,29,202,201,190,217,213,29,190,217,174,227,213,29,174,227,170,152,213,29,170,152,216,19,196,319,191,309,195,284,196,319,195,284,203,299,196,319,203,299,210,319,186,302,181,297,185,274,186,302,185,274,195,284,186,302,195,284,191,309,114,0,114,7,101,9,114,0,101,9,92,13,114,0,92,13,39,32,114,0,39,32,37,21,50,220,40,169,83,26,50,220,83,26,63,225,10,200,8,208,8,199,114,0,9,7,9,0,39,32,92,13,40,47,176,295,185,274,181,297,243,0,139,7,138,0, +166,253,94,328,89,332,84,335,80,337,72,339,66,338,61,336,57,333,55,329,54,323,55,318,57,314,60,309,64,305,69,301,146,253,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,77,253,97,253,174,302,180,306,184,310,187,314,189,318,189,323,188,329,186,333,182,336,177,338,171,339,163,337,160,335,156,332,151,328,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102, +146,253,166,253,94,328,146,253,94,328,89,332,146,253,89,332,84,335,146,253,84,335,80,337,146,253,80,337,76,338,146,253,76,338,72,339,146,253,72,339,69,301,54,323,55,318,55,329,55,329,55,318,57,314,55,329,57,314,57,333,57,333,57,314,60,309,57,333,60,309,61,336,61,336,60,309,64,305,61,336,64,305,66,338,66,338,64,305,69,301,66,338,69,301,72,339,64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18, +77,253,97,253,174,302,180,306,184,310,187,314,189,318,189,323,188,329,186,333,182,336,177,338,171,339,163,337,160,335,156,332,151,328,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,200,253,138,337,107,337,45,253,62,253,123,305,184,253,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,190,319,185,309,181,302,176,297,170,295,164,294,159,294,154,295,149,297,137,301, +171,339,174,302,177,338,177,338,174,302,180,306,177,338,180,306,182,336,182,336,180,306,184,310,182,336,184,310,186,333,186,333,184,310,187,314,186,333,187,314,188,329,188,329,187,314,189,318,188,329,189,318,189,323,174,302,171,339,167,338,174,302,167,338,163,337,174,302,163,337,160,335,174,302,160,335,156,332,174,302,156,332,151,328,174,302,151,328,97,253,64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18,97,253,151,328,77,253, +200,253,138,337,107,337,45,253,62,253,123,305,184,253,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,190,319,185,309,181,302,176,297,170,295,164,294,159,294,154,295,149,297,137,301,126,307,118,311,104,315,97,316,90,316,76,314,64,308,54,298,46,284,40,266,55,266,58,274,63,281,68,285,73,288,80,289,84,289,92,287,100,283,112,278,123,273,131,269,139,267,145,266,152,266,168,268,180,274,190,284,198,299,205,319,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76, +45,253,62,253,107,337,107,337,62,253,123,305,107,337,123,305,138,337,138,337,123,305,184,253,138,337,184,253,200,253,64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18, +190,319,185,309,181,302,176,297,170,295,164,294,159,294,154,295,149,297,137,301,126,307,118,311,104,315,97,316,90,316,76,314,64,308,54,298,46,284,40,266,55,266,58,274,63,281,68,285,73,288,80,289,84,289,92,287,100,283,112,278,123,273,131,269,139,267,145,266,152,266,168,268,180,274,190,284,198,299,205,319,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,197,286,196,294,192,301,186,306,180,310,172,311,164,310,157,306,152,301,149,294,147,286,149,278,152,272,157,266,164,263,171,262,179,263,186,266,192,272,196,278,197,286,16383,16383,98,286,96,294,93,301,87,306,80,310,73,311,65,310,58,306,53,301,49,294,48,286,49,278,53,272,58,266,64,263,72,262,80,263,87,266,93,272,96,278,98,286,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161, +58,274,63,281,64,308,64,308,63,281,68,285,64,308,68,285,76,314,76,314,68,285,73,288,76,314,73,288,80,289,80,289,84,289,90,316,90,316,84,289,88,288,90,316,88,288,92,287,55,266,58,274,64,308,55,266,64,308,54,298,55,266,54,298,46,284,55,266,46,284,40,266,90,316,92,287,97,316,97,316,92,287,96,285,97,316,96,285,100,283,100,283,112,278,104,315,104,315,112,278,111,313,90,316,76,314,80,289,104,315,97,316,100,283,111,313,112,278,118,311,118,311,112,278,123,273,118,311,123,273,126,307,126,307,123,273,131,269,126,307,131,269,137,301,137,301,131,269,139,267,137,301,139,267,143,299,143,299,139,267,145,266,143,299,145,266,149,297,149,297,145,266,152,266,149,297,152,266,154,295,154,295,152,266,168,268,154,295,168,268,159,294,159,294,168,268,164,294,170,295,164,294,168,268,170,295,168,268,180,274,190,319,185,309,190,284,190,319,190,284,198,299,190,319,198,299,205,319,181,302,176,297,180,274,181,302,180,274,190,284,181,302,190,284,185,309,64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18,170,295,180,274,176,297, +197,286,196,294,192,301,186,306,180,310,172,311,164,310,157,306,152,301,149,294,147,286,149,278,152,272,157,266,164,263,171,262,179,263,186,266,192,272,196,278,197,286,16383,16383,98,286,96,294,93,301,87,306,80,310,73,311,65,310,58,306,53,301,49,294,48,286,49,278,53,272,58,266,64,263,72,262,80,263,87,266,93,272,96,278,98,286,16383,16383,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114,20,75,35,42,58,17,88,1,123,-4,160,1,191,17,215,43,230,76,235,116,16383,16383,190,102,187,70,180,44,168,25,151,13,131,9,120,10,110,13,101,18,93,25,86,34,76,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,98,212,118,216,130,215,140,211,149,206,158,199,165,191,174,177,181,161,186,142,189,122,190,102,169,229,168,238,164,246,158,252,150,256,142,258,133,256,125,252,119,246,115,239,113,230,115,221,119,214,125,208,132,204,141,203,150,204,158,208,164,214,168,221,169,229,16383,16383,267,110,267,143,15,143,15,110,16383,16383,169,22,168,31,164,38,158,45,150,49,142,50,133,49,125,45,119,39,115,31,113,22,115,14,119,6,125,0,132,-3,141,-4,150,-3,158,0,164,6,168,13,169,22,219,276,199,276,171,221,161,224,152,227,143,229,134,230,124,230,88,224,58,208,35,184,20,152,15,113,15,100,17,87,20,74,30,50,35,42,40,36,46,29,53,22,63,14,26,-55,45,-55,77,6,87,1,105,-3,114,-4,123,-4,159,1,190,18,214,44,229,78,235,117,233,141,227,162,218,181,204,198,186,213,16383,16383,79,46,72,63,66,81,63,99,60,118,60,138,62,164,70,186,82,202, +48,286,49,278,49,294,49,294,49,278,53,272,49,294,53,272,53,301,53,301,53,272,58,266,53,301,58,266,58,306,58,306,58,266,64,263,58,306,64,263,65,310,65,310,64,263,72,262,65,310,72,262,73,311,73,311,72,262,80,263,73,311,80,263,80,310,80,310,80,263,87,266,80,310,87,266,87,306,87,306,87,266,93,272,87,306,93,272,93,301,93,301,93,272,96,278,93,301,96,278,96,294,96,294,96,278,98,286,64,91,58,17,69,70,69,70,58,17,88,1,69,70,88,1,76,51,76,51,88,1,86,34,93,25,86,34,88,1,93,25,88,1,123,-4,162,225,127,230,130,215,130,215,127,230,118,216,98,212,118,216,127,230,98,212,127,230,90,225,147,286,149,278,149,294,149,294,149,278,152,272,149,294,152,272,152,301,152,301,152,272,157,266,152,301,157,266,157,306,157,306,157,266,164,263,157,306,164,263,164,310,164,310,164,263,171,262,164,310,171,262,172,311,172,311,171,262,179,263,172,311,179,263,180,310,180,310,179,263,186,266,180,310,186,266,186,306,186,306,186,266,192,272,186,306,192,272,192,301,192,301,192,272,196,278,192,301,196,278,196,294,196,294,196,278,197,286,187,70,180,44,191,17,191,17,180,44,168,25,191,17,168,25,160,1,160,1,168,25,151,13,160,1,151,13,131,9,131,9,120,10,123,-4,123,-4,120,10,110,13,123,-4,110,13,101,18,140,211,149,206,162,225,162,225,149,206,158,199,162,225,158,199,165,191,165,191,174,177,191,210,191,210,174,177,181,161,191,210,181,161,186,142,230,154,215,186,215,43,230,154,215,43,230,76,230,154,230,76,235,116,187,70,191,17,190,102,190,102,191,17,191,210,191,210,191,17,215,43,191,210,215,43,215,186,191,210,186,142,189,122,191,210,189,122,190,102,191,210,162,225,165,191,131,9,123,-4,160,1,58,17,61,113,60,137,60,137,62,164,58,209,58,209,62,164,70,186,58,209,70,186,90,225,90,225,70,186,82,202,90,225,82,202,98,212,58,17,60,137,58,209,58,17,58,209,35,42,35,42,58,209,35,185,35,42,35,185,20,75,20,75,35,185,20,153,20,75,20,153,15,114,61,113,58,17,64,91,162,225,130,215,140,211,93,25,123,-4,101,18, +169,229,168,238,164,246,158,252,150,256,142,258,133,256,125,252,119,246,115,239,113,230,115,221,119,214,125,208,132,204,141,203,150,204,158,208,164,214,168,221,169,229,16383,16383,267,110,267,143,15,143,15,110,16383,16383,169,22,168,31,164,38,158,45,150,49,142,50,133,49,125,45,119,39,115,31,113,22,115,14,119,6,125,0,132,-3,141,-4,150,-3,158,0,164,6,168,13,169,22,219,276,199,276,171,221,161,224,152,227,143,229,134,230,124,230,88,224,58,208,35,184,20,152,15,113,15,100,17,87,20,74,30,50,35,42,40,36,46,29,53,22,63,14,26,-55,45,-55,77,6,87,1,105,-3,114,-4,123,-4,159,1,190,18,214,44,229,78,235,117,233,141,227,162,218,181,204,198,186,213,16383,16383,79,46,72,63,66,81,63,99,60,118,60,138,62,164,70,186, +113,230,115,221,115,239,115,239,115,221,119,214,115,239,119,214,119,246,119,246,119,214,125,208,119,246,125,208,125,252,125,252,125,208,132,204,125,252,132,204,133,256,133,256,132,204,141,203,133,256,141,203,142,258,142,258,141,203,150,204,142,258,150,204,150,256,150,256,150,204,158,208,150,256,158,208,158,252,158,252,158,208,164,214,158,252,164,214,164,246,164,246,164,214,168,221,164,246,168,221,168,238,168,238,168,221,169,229,15,143,15,110,267,110,15,143,267,110,267,143,113,22,115,14,115,31,115,31,115,14,119,6,115,31,119,6,119,39,119,39,119,6,125,0,119,39,125,0,125,45,125,45,125,0,132,-3,125,45,132,-3,133,49,133,49,132,-3,141,-4,133,49,141,-4,142,50,142,50,141,-4,150,-3,142,50,150,-3,150,49,150,49,150,-3,158,0,150,49,158,0,158,45,158,45,158,0,164,6,158,45,164,6,164,38,164,38,164,6,168,13,164,38,168,13,168,31,168,31,168,13,169,22, +219,276,199,276,171,221,161,224,152,227,143,229,134,230,124,230,88,224,58,208,35,184,20,152,15,113,15,100,17,87,20,74,30,50,35,42,40,36,46,29,53,22,63,14,26,-55,45,-55,77,6,87,1,105,-3,114,-4,123,-4,159,1,190,18,214,44,229,78,235,117,233,141,227,162,218,181,204,198,186,213,16383,16383,79,46,72,63,66,81,63,99,60,118,60,138,62,164,70,186,82,202,99,212,118,216,127,215,135,213,143,210,151,205,158,198,16383,16383,170,183,178,167,183,152,187,136,189,120,190,102,187,69,180,44,168,25,151,13,131,9,121,10,112,12,104,16,97,22,89,30,170,253,97,328,92,332,88,335,84,337,80,338,75,339,69,338,64,336,61,333,58,329,57,323,58,318,60,314,63,309,67,305,73,301,150,253,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18, +63,14,63,14,45,-55,63,14,45,-55,77,6,63,14,77,6,63,99,63,14,63,99,60,118,63,14,60,118,60,138,63,14,60,138,58,208,63,14,58,208,53,22,58,208,35,184,35,42,58,208,35,42,40,36,58,208,40,36,46,29,58,208,46,29,53,22,35,184,20,152,20,74,35,184,20,74,25,62,35,184,25,62,30,50,35,184,30,50,35,42,20,152,15,113,15,100,20,152,15,100,17,87,20,152,17,87,20,74,124,230,118,216,127,215,124,230,127,215,134,230,134,230,127,215,135,213,134,230,135,213,143,229,143,229,135,213,143,210,143,229,143,210,152,227,152,227,143,210,151,205,152,227,151,205,158,198,187,69,180,44,190,18,190,18,180,44,168,25,190,18,168,25,159,1,159,1,168,25,151,13,159,1,151,13,131,9,131,9,121,10,123,-4,123,-4,121,10,114,-4,112,12,104,16,105,-3,112,12,105,-3,114,-4,112,12,114,-4,121,10,87,1,96,-1,89,30,89,30,96,-1,97,22,97,22,96,-1,105,-3,97,22,105,-3,104,16,161,224,158,198,170,183,161,224,170,183,171,221,171,221,170,183,178,167,171,221,178,167,186,213,186,213,178,167,183,152,186,213,183,152,187,136,199,276,171,221,186,213,199,276,186,213,219,276,158,198,79,46,89,30,158,198,89,30,170,183,79,46,72,63,77,6,79,46,77,6,87,1,79,46,87,1,89,30,66,81,63,99,77,6,66,81,77,6,72,63,229,78,235,117,233,141,229,78,233,141,227,162,229,78,227,162,218,181,229,78,218,181,214,44,187,69,190,18,190,102,190,102,190,18,204,198,204,198,190,18,214,44,204,198,214,44,218,181,186,213,187,136,204,198,204,198,187,136,189,120,204,198,189,120,190,102,131,9,123,-4,159,1,70,186,82,202,88,224,88,224,82,202,99,212,88,224,99,212,124,230,124,230,99,212,118,216,60,138,62,164,58,208,58,208,62,164,70,186,58,208,70,186,88,224,45,-55,63,14,26,-55,152,227,158,198,161,224, +170,253,97,328,92,332,88,335,84,337,80,338,75,339,69,338,64,336,61,333,58,329,57,323,58,318,60,314,63,309,67,305,73,301,150,253,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,78,253,98,253,175,302,181,306,185,310,188,314,189,318,190,323,189,329,187,333,183,336,179,338,172,339,168,338,165,337,161,335,156,332,151,328,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18, +150,253,170,253,97,328,150,253,97,328,92,332,150,253,92,332,88,335,150,253,88,335,84,337,150,253,84,337,80,338,150,253,80,338,75,339,150,253,75,339,73,301,57,323,58,318,58,329,58,329,58,318,60,314,58,329,60,314,61,333,61,333,60,314,63,309,61,333,63,309,64,336,64,336,63,309,67,305,64,336,67,305,69,338,69,338,67,305,73,301,69,338,73,301,75,339,78,225,4,225,17,216,78,225,17,216,26,213,78,225,26,213,32,207,78,225,32,207,35,197,78,225,35,197,36,185,78,225,36,185,38,38,78,225,38,38,46,20,78,225,46,20,58,6,78,225,58,6,75,-1,78,225,75,-1,78,64,164,53,162,48,168,38,168,38,162,48,159,43,168,38,159,43,155,40,155,40,147,34,153,21,153,21,147,34,139,29,153,21,139,29,138,8,138,8,139,29,130,26,138,8,130,26,123,0,123,0,130,26,121,25,123,0,121,25,113,24,113,24,102,26,109,-3,109,-3,102,26,97,-4,97,-4,102,26,92,31,97,-4,92,31,84,40,97,-4,84,40,79,51,97,-4,79,51,75,-1,78,64,75,-1,79,51,113,24,109,-3,123,0,166,184,168,38,209,225,209,225,168,38,169,38,209,225,169,38,171,-3,171,-3,169,38,169,-2,168,38,166,184,166,69,168,38,166,69,166,59,168,38,166,59,164,53,155,40,153,21,168,38,225,26,217,29,225,14,225,14,217,29,212,34,225,14,212,34,212,10,212,10,212,34,209,42,212,10,209,42,199,6,199,6,209,42,209,54,199,6,209,54,209,225,209,225,171,-3,186,1,209,225,186,1,199,6,209,225,129,225,145,215,209,225,145,215,155,212,209,225,155,212,162,206,209,225,162,206,165,197,209,225,165,197,166,184,237,25,225,26,225,14,237,25,225,14,240,18,237,25,240,18,240,25,38,38,36,185,36,59,145,215,129,225,129,217,17,216,4,225,4,218, +78,253,98,253,175,302,181,306,185,310,188,314,189,318,190,323,189,329,187,333,183,336,179,338,172,339,168,338,165,337,161,335,156,332,151,328,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,200,253,138,337,107,337,45,253,62,253,123,305,184,253,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,196,286,195,294,192,301,186,306,179,310,171,311,164,310,157,306,152,301,148,294,147,286, +209,225,129,225,145,215,209,225,145,215,155,212,209,225,155,212,162,206,209,225,162,206,165,197,209,225,165,197,166,184,209,225,166,184,168,38,209,225,168,38,169,38,209,225,169,38,171,-3,209,225,171,-3,186,1,209,225,186,1,199,6,209,225,199,6,209,54,166,184,166,69,168,38,237,25,225,26,225,14,237,25,225,14,240,18,237,25,240,18,240,25,209,54,199,6,209,42,209,42,199,6,212,10,209,42,212,10,212,34,212,34,212,10,225,14,212,34,225,14,217,29,217,29,225,14,225,26,172,339,175,302,179,338,179,338,175,302,181,306,179,338,181,306,183,336,183,336,181,306,185,310,183,336,185,310,187,333,187,333,185,310,188,314,187,333,188,314,189,329,189,329,188,314,189,318,189,329,189,318,190,323,175,302,172,339,168,338,175,302,168,338,165,337,175,302,165,337,161,335,175,302,161,335,156,332,175,302,156,332,151,328,175,302,151,328,98,253,78,225,4,225,17,216,78,225,17,216,26,213,78,225,26,213,32,207,78,225,32,207,35,197,78,225,35,197,36,185,78,225,36,185,38,38,78,225,38,38,46,20,78,225,46,20,58,6,78,225,58,6,75,-1,78,225,75,-1,78,64,164,53,162,48,168,38,168,38,162,48,159,43,168,38,159,43,155,40,155,40,147,34,153,21,153,21,147,34,139,29,153,21,139,29,138,8,138,8,139,29,130,26,138,8,130,26,123,0,123,0,130,26,121,25,123,0,121,25,113,24,113,24,102,26,109,-3,109,-3,102,26,97,-4,97,-4,102,26,92,31,97,-4,92,31,84,40,97,-4,84,40,79,51,97,-4,79,51,75,-1,78,64,75,-1,79,51,113,24,109,-3,123,0,166,59,164,53,168,38,166,59,168,38,166,69,155,40,153,21,168,38,38,38,36,185,36,59,171,-3,169,38,169,-2,17,216,4,225,4,218,98,253,151,328,78,253,145,215,129,225,129,217, +200,253,138,337,107,337,45,253,62,253,123,305,184,253,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,196,286,195,294,192,301,186,306,179,310,171,311,164,310,157,306,152,301,148,294,147,286,148,278,151,272,157,266,163,263,171,262,179,263,186,266,192,272,195,278,196,286,16383,16383,97,286,96,294,92,301,87,306,80,310,72,311,64,310,58,306,52,301,49,294,47,286,49,278,52,272,57,266,64,263,71,262,79,263,86,266,92,272,96,278,97,286,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43, +209,225,129,225,145,215,209,225,145,215,155,212,209,225,155,212,162,206,209,225,162,206,165,197,209,225,165,197,166,184,209,225,166,184,168,38,209,225,168,38,169,38,209,225,169,38,171,-3,209,225,171,-3,186,1,209,225,186,1,199,6,209,225,199,6,209,54,166,184,166,69,168,38,237,25,225,26,225,14,237,25,225,14,240,18,237,25,240,18,240,25,209,54,199,6,209,42,209,42,199,6,212,10,209,42,212,10,212,34,212,34,212,10,225,14,212,34,225,14,217,29,217,29,225,14,225,26,45,253,62,253,107,337,107,337,62,253,123,305,107,337,123,305,138,337,138,337,123,305,184,253,138,337,184,253,200,253,78,225,4,225,17,216,78,225,17,216,26,213,78,225,26,213,32,207,78,225,32,207,35,197,78,225,35,197,36,185,78,225,36,185,38,38,78,225,38,38,46,20,78,225,46,20,58,6,78,225,58,6,75,-1,78,225,75,-1,78,64,164,53,162,48,168,38,168,38,162,48,159,43,168,38,159,43,155,40,155,40,147,34,153,21,153,21,147,34,139,29,153,21,139,29,138,8,138,8,139,29,130,26,138,8,130,26,123,0,123,0,130,26,121,25,123,0,121,25,113,24,113,24,102,26,109,-3,109,-3,102,26,97,-4,97,-4,102,26,92,31,97,-4,92,31,84,40,97,-4,84,40,79,51,97,-4,79,51,75,-1,78,64,75,-1,79,51,113,24,109,-3,123,0,166,59,164,53,168,38,166,59,168,38,166,69,155,40,153,21,168,38,38,38,36,185,36,59,171,-3,169,38,169,-2,17,216,4,225,4,218,145,215,129,225,129,217, +196,286,195,294,192,301,186,306,179,310,171,311,164,310,157,306,152,301,148,294,147,286,148,278,151,272,157,266,163,263,171,262,179,263,186,266,192,272,195,278,196,286,16383,16383,97,286,96,294,92,301,87,306,80,310,72,311,64,310,58,306,52,301,49,294,47,286,49,278,52,272,57,266,64,263,71,262,79,263,86,266,92,272,96,278,97,286,16383,16383,240,25,237,25,225,26,217,29,212,34,209,42,209,225,129,225,129,217,145,215,155,212,162,206,165,197,166,184,166,59,164,53,162,48,159,43,147,34,139,29,130,26,121,25,113,24,102,26,92,31,84,40,79,51,78,64,78,225,4,225,4,218,17,216,26,213,32,207,35,197,36,185,36,59,38,38,46,20,58,6,75,-1,97,-4,109,-3,123,0,138,8,153,21,168,38,169,38,169,-2,171,-3,186,1,199,6,225,14,240,18,71,253,92,253,169,302,174,306,178,310,181,314,183,318,184,323,183,329,181,333,177,336,172,338,166,339,158,337,154,335,150,332,145,328,16383,16383,238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214,26,211,30,206,33,200,99,60,105,47,111,35,116,24,121,9,119,2,116,-8,112,-21,106,-34,100,-44,96,-51,85,-62,80,-65,75,-66,71,-66,69,-65,66,-64,62,-63,63,-63,57,-60,52,-58,42,-56,36,-56,30,-57,24,-60,19,-65,16,-72,15,-79,17,-88,21,-96,28,-102,38,-106,50,-108,71,-105,90,-94,106,-76,122,-49,137,-11,213,192,217,202,221,208,226,213,231,216,238,218,79,339,76,342,63,337,51,333,38,329,23,325, +209,225,129,225,145,215,209,225,145,215,155,212,209,225,155,212,162,206,209,225,162,206,165,197,209,225,165,197,166,184,209,225,166,184,168,38,209,225,168,38,169,38,209,225,169,38,171,-3,209,225,171,-3,186,1,209,225,186,1,199,6,209,225,199,6,209,54,166,184,166,69,168,38,237,25,225,26,225,14,237,25,225,14,240,18,237,25,240,18,240,25,209,54,199,6,209,42,209,42,199,6,212,10,209,42,212,10,212,34,212,34,212,10,225,14,212,34,225,14,217,29,217,29,225,14,225,26,147,286,148,278,148,294,148,294,148,278,151,272,148,294,151,272,152,301,152,301,151,272,157,266,152,301,157,266,157,306,157,306,157,266,163,263,157,306,163,263,164,310,164,310,163,263,171,262,164,310,171,262,171,311,171,311,171,262,179,263,171,311,179,263,179,310,179,310,179,263,186,266,179,310,186,266,186,306,186,306,186,266,192,272,186,306,192,272,192,301,192,301,192,272,195,278,192,301,195,278,195,294,195,294,195,278,196,286,47,286,49,278,49,294,49,294,49,278,52,272,49,294,52,272,52,301,52,301,52,272,57,266,52,301,57,266,58,306,58,306,57,266,64,263,58,306,64,263,64,310,64,310,64,263,71,262,64,310,71,262,72,311,72,311,71,262,79,263,72,311,79,263,80,310,80,310,79,263,86,266,80,310,86,266,87,306,87,306,86,266,92,272,87,306,92,272,92,301,92,301,92,272,96,278,92,301,96,278,96,294,96,294,96,278,97,286,78,225,4,225,17,216,78,225,17,216,26,213,78,225,26,213,32,207,78,225,32,207,35,197,78,225,35,197,36,185,78,225,36,185,38,38,78,225,38,38,46,20,78,225,46,20,58,6,78,225,58,6,75,-1,78,225,75,-1,78,64,164,53,162,48,168,38,168,38,162,48,159,43,168,38,159,43,155,40,155,40,147,34,153,21,153,21,147,34,139,29,153,21,139,29,138,8,138,8,139,29,130,26,138,8,130,26,123,0,123,0,130,26,121,25,123,0,121,25,113,24,113,24,102,26,109,-3,109,-3,102,26,97,-4,97,-4,102,26,92,31,97,-4,92,31,84,40,97,-4,84,40,79,51,97,-4,79,51,75,-1,78,64,75,-1,79,51,113,24,109,-3,123,0,166,59,164,53,168,38,166,59,168,38,166,69,155,40,153,21,168,38,38,38,36,185,36,59,171,-3,169,38,169,-2,17,216,4,225,4,218,145,215,129,225,129,217, +71,253,92,253,169,302,174,306,178,310,181,314,183,318,184,323,183,329,181,333,177,336,172,338,166,339,158,337,154,335,150,332,145,328,16383,16383,238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214,26,211,30,206,33,200,99,60,105,47,111,35,116,24,121,9,119,2,116,-8,112,-21,106,-34,100,-44,96,-51,85,-62,80,-65,75,-66,71,-66,69,-65,66,-64,62,-63,63,-63,57,-60,52,-58,42,-56,36,-56,30,-57,24,-60,19,-65,16,-72,15,-79,17,-88,21,-96,28,-102,38,-106,50,-108,71,-105,90,-94,106,-76,122,-49,137,-11,213,192,217,202,221,208,226,213,231,216,238,218,79,339,76,342,63,337,51,333,38,329,23,325,4,320,4,311,8,311,9,312,13,312,23,311,30,308,35,303,37,295,37,-76,34,-86,27,-92,17,-96,2,-98,2,-107,123,-107,123,-98,104,-97,91,-93,84,-87,80,-75,79,-59,79,17,90,8,99,2,108,-1,118,-3,130,-4,164,1,193,19,215,47,230,82,235,123,231,160,221,190,204,212,180,225,151,230,135,229,120,224,106,216,92,205,79,190,16383,16383,79,166,83,175,91,184,103,192,117,198,131,200,152,196,170,185,182,166,189,140,192,107,189,75,181,49,169,29,152,16,131,11,117,13,103,19,91,27,82,36,79,45,198,286,197,294,193,301,188,306,181,310,173,311,165,310,159,306,153,301,150,294,148,286,150,278,153,272,158,266,165,263,172,262,180,263,187,266,193,272,197,278,198,286, +166,339,169,302,172,338,172,338,169,302,174,306,172,338,174,306,177,336,177,336,174,306,178,310,177,336,178,310,181,333,181,333,178,310,181,314,181,333,181,314,183,329,183,329,181,314,183,318,183,329,183,318,184,323,169,302,166,339,162,338,169,302,162,338,158,337,169,302,158,337,154,335,169,302,154,335,150,332,169,302,150,332,145,328,169,302,145,328,92,253,90,-57,85,-62,90,-94,90,-94,85,-62,80,-65,90,-94,80,-65,75,-66,75,-66,73,-66,90,-94,90,-94,73,-66,71,-105,90,-57,106,-76,96,-51,96,-51,106,-76,100,-44,106,-34,100,-44,106,-76,106,-34,106,-76,122,-49,143,59,88,184,99,60,143,59,99,60,105,47,143,59,105,47,111,35,143,59,111,35,116,24,143,59,116,24,119,15,143,59,119,15,121,9,143,59,121,9,122,-49,143,59,122,-49,137,-11,143,59,137,-11,213,192,143,59,213,192,192,196,122,-49,121,9,119,2,99,60,88,184,86,188,99,60,86,188,84,192,99,60,84,192,82,196,99,60,82,196,81,201,99,60,81,201,33,200,33,200,81,201,81,204,81,204,82,209,33,200,33,200,82,209,85,212,33,200,85,212,109,225,109,225,85,212,90,215,109,225,90,215,98,217,194,202,193,201,213,192,213,192,193,201,193,198,213,192,193,198,192,196,238,225,171,225,179,217,238,225,179,217,186,216,238,225,186,216,190,213,238,225,190,213,193,210,238,225,193,210,194,205,238,225,194,205,226,213,238,225,226,213,231,216,238,225,231,216,238,218,194,205,213,192,217,202,194,205,217,202,221,208,194,205,221,208,226,213,194,204,194,202,213,192,194,204,213,192,194,205,122,-49,119,2,116,-8,122,-49,116,-8,112,-21,122,-49,112,-21,106,-34,71,-105,73,-66,71,-66,71,-105,71,-66,69,-65,71,-105,69,-65,66,-64,71,-105,66,-64,63,-63,71,-105,63,-63,57,-60,71,-105,57,-60,52,-58,71,-105,52,-58,50,-108,52,-58,47,-57,50,-108,50,-108,47,-57,42,-56,50,-108,42,-56,38,-106,38,-106,42,-56,36,-56,38,-106,36,-56,30,-57,38,-106,30,-57,28,-102,28,-102,30,-57,24,-60,28,-102,24,-60,21,-96,21,-96,24,-60,19,-65,21,-96,19,-65,17,-88,17,-88,19,-65,16,-72,17,-88,16,-72,15,-79,98,217,109,218,109,225,109,225,7,225,14,217,109,225,14,217,21,214,109,225,21,214,26,211,109,225,26,211,30,206,109,225,30,206,33,200,66,-64,62,-63,63,-63,14,217,7,225,7,218,90,-57,90,-94,106,-76,179,217,171,225,171,218,92,253,145,328,71,253, +79,339,76,342,63,337,51,333,38,329,23,325,4,320,4,311,8,311,9,312,13,312,23,311,30,308,35,303,37,295,37,-76,34,-86,27,-92,17,-96,2,-98,2,-107,123,-107,123,-98,104,-97,91,-93,84,-87,80,-75,79,-59,79,17,90,8,99,2,108,-1,118,-3,130,-4,164,1,193,19,215,47,230,82,235,123,231,160,221,190,204,212,180,225,151,230,135,229,120,224,106,216,92,205,79,190,16383,16383,79,166,83,175,91,184,103,192,117,198,131,200,152,196,170,185,182,166,189,140,192,107,189,75,181,49,169,29,152,16,131,11,117,13,103,19,91,27,82,36,79,45,198,286,197,294,193,301,188,306,181,310,173,311,165,310,159,306,153,301,150,294,148,286,150,278,153,272,158,266,165,263,172,262,180,263,187,266,193,272,197,278,198,286,16383,16383,99,286,97,294,94,301,88,306,81,310,74,311,66,310,59,306,54,301,50,294,49,286,50,278,54,272,59,266,65,263,73,262,81,263,88,266,94,272,97,278,99,286,16383,16383,238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214, +34,-86,27,-92,123,-107,123,-107,27,-92,17,-96,123,-107,17,-96,2,-98,8,311,9,312,23,325,23,325,9,312,11,312,23,325,11,312,13,312,13,312,23,311,23,325,23,325,23,311,38,329,23,325,4,320,6,311,23,325,6,311,8,311,30,308,35,303,38,329,38,329,35,303,37,295,38,329,37,295,37,284,80,-75,37,284,37,-63,80,-75,37,-63,84,-87,84,-87,37,-63,91,-93,79,190,79,339,76,342,79,190,76,342,79,-59,79,190,79,-59,79,166,79,190,79,166,92,205,235,123,231,160,230,82,230,82,231,160,221,190,230,82,221,190,215,47,215,47,221,190,204,212,215,47,204,212,193,19,193,19,204,212,192,107,193,19,192,107,189,75,193,19,189,75,181,49,152,196,170,185,180,225,180,225,170,185,182,166,180,225,182,166,204,212,204,212,182,166,189,140,204,212,189,140,192,107,135,229,131,200,152,196,135,229,152,196,151,230,151,230,152,196,180,225,108,-1,118,-3,117,13,117,13,118,-3,131,11,152,16,131,11,164,1,152,16,164,1,169,29,169,29,164,1,193,19,169,29,193,19,181,49,131,11,118,-3,130,-4,131,11,130,-4,164,1,123,-107,123,-98,104,-97,123,-107,104,-97,91,-93,123,-107,91,-93,37,-76,123,-107,37,-76,34,-86,82,36,79,45,90,8,90,8,79,45,79,17,80,-75,79,-59,51,333,80,-75,51,333,38,329,63,337,51,333,79,-59,63,337,79,-59,76,342,83,175,91,184,92,205,92,205,91,184,103,192,92,205,103,192,106,216,106,216,103,192,117,198,106,216,117,198,120,224,120,224,117,198,131,200,120,224,131,200,135,229,82,36,90,8,91,27,91,27,90,8,99,2,91,27,99,2,103,19,103,19,99,2,108,-1,103,19,108,-1,117,13,92,205,79,166,83,175,6,311,4,320,4,311,123,-107,2,-98,2,-107,37,-76,91,-93,37,-63,37,284,80,-75,38,329,38,329,23,311,30,308, +198,286,197,294,193,301,188,306,181,310,173,311,165,310,159,306,153,301,150,294,148,286,150,278,153,272,158,266,165,263,172,262,180,263,187,266,193,272,197,278,198,286,16383,16383,99,286,97,294,94,301,88,306,81,310,74,311,66,310,59,306,54,301,50,294,49,286,50,278,54,272,59,266,65,263,73,262,81,263,88,266,94,272,97,278,99,286,16383,16383,238,225,171,225,171,218,179,217,186,216,190,213,193,210,194,205,194,202,193,201,193,198,192,196,143,59,88,184,82,196,81,201,81,204,82,209,85,212,90,215,98,217,109,218,109,225,7,225,7,218,14,217,21,214,26,211,30,206,33,200,99,60,105,47,111,35,116,24,121,9,119,2,116,-8,112,-21,106,-34,100,-44,96,-51,85,-62,80,-65,75,-66,71,-66,69,-65,66,-64,62,-63,63,-63,57,-60,52,-58,42,-56,36,-56,30,-57,24,-60,19,-65,16,-72,15,-79,17,-88,21,-96,28,-102,38,-106,50,-108,71,-105,90,-94,106,-76,122,-49,137,-11,213,192,217,202,221,208,226,213,231,216,238,218,256,359,256,387,100,387,100,359,16383,16383,353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,23,259,21,258,18,256,16,250,12,242,10,235,10,226,9,226,0,16383,16383,224,128,108,128,166,266,190,253,190,281,35,281,35,253,16383,16383,221,33,216,29,208,25,200,23,195,25,190,28,187,35,185,44,184,56,184,168,183,181,180,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,208,83,213,93,217,104,218,117,216,128,211,136,202,142,190,143,173,143,146,114,135,92,126,75,118,63,112,54,105,42,97, +148,286,150,278,150,294,150,294,150,278,153,272,150,294,153,272,153,301,153,301,153,272,158,266,153,301,158,266,159,306,159,306,158,266,165,263,159,306,165,263,165,310,165,310,165,263,172,262,165,310,172,262,173,311,173,311,172,262,180,263,173,311,180,263,181,310,181,310,180,263,187,266,181,310,187,266,188,306,188,306,187,266,193,272,188,306,193,272,193,301,193,301,193,272,197,278,193,301,197,278,197,294,197,294,197,278,198,286,49,286,50,278,50,294,50,294,50,278,54,272,50,294,54,272,54,301,54,301,54,272,59,266,54,301,59,266,59,306,59,306,59,266,65,263,59,306,65,263,66,310,66,310,65,263,73,262,66,310,73,262,74,311,74,311,73,262,81,263,74,311,81,263,81,310,81,310,81,263,88,266,81,310,88,266,88,306,88,306,88,266,94,272,88,306,94,272,94,301,94,301,94,272,97,278,94,301,97,278,97,294,97,294,97,278,99,286,90,-57,85,-62,90,-94,90,-94,85,-62,80,-65,90,-94,80,-65,75,-66,75,-66,73,-66,90,-94,90,-94,73,-66,71,-105,90,-57,106,-76,96,-51,96,-51,106,-76,100,-44,106,-34,100,-44,106,-76,106,-34,106,-76,122,-49,143,59,88,184,99,60,143,59,99,60,105,47,143,59,105,47,111,35,143,59,111,35,116,24,143,59,116,24,119,15,143,59,119,15,121,9,143,59,121,9,122,-49,143,59,122,-49,137,-11,143,59,137,-11,213,192,143,59,213,192,192,196,122,-49,121,9,119,2,99,60,88,184,86,188,99,60,86,188,84,192,99,60,84,192,82,196,99,60,82,196,81,201,99,60,81,201,33,200,33,200,81,201,81,204,81,204,82,209,33,200,33,200,82,209,85,212,33,200,85,212,109,225,109,225,85,212,90,215,109,225,90,215,98,217,194,202,193,201,213,192,213,192,193,201,193,198,213,192,193,198,192,196,238,225,171,225,179,217,238,225,179,217,186,216,238,225,186,216,190,213,238,225,190,213,193,210,238,225,193,210,194,205,238,225,194,205,226,213,238,225,226,213,231,216,238,225,231,216,238,218,194,205,213,192,217,202,194,205,217,202,221,208,194,205,221,208,226,213,194,204,194,202,213,192,194,204,213,192,194,205,122,-49,119,2,116,-8,122,-49,116,-8,112,-21,122,-49,112,-21,106,-34,71,-105,73,-66,71,-66,71,-105,71,-66,69,-65,71,-105,69,-65,66,-64,71,-105,66,-64,63,-63,71,-105,63,-63,57,-60,71,-105,57,-60,52,-58,71,-105,52,-58,50,-108,52,-58,47,-57,50,-108,50,-108,47,-57,42,-56,50,-108,42,-56,38,-106,38,-106,42,-56,36,-56,38,-106,36,-56,30,-57,38,-106,30,-57,28,-102,28,-102,30,-57,24,-60,28,-102,24,-60,21,-96,21,-96,24,-60,19,-65,21,-96,19,-65,17,-88,17,-88,19,-65,16,-72,17,-88,16,-72,15,-79,98,217,109,218,109,225,109,225,7,225,14,217,109,225,14,217,21,214,109,225,21,214,26,211,109,225,26,211,30,206,109,225,30,206,33,200,66,-64,62,-63,63,-63,14,217,7,225,7,218,90,-57,90,-94,106,-76,179,217,171,225,171,218, +166,253,94,328,89,332,85,335,81,337,73,339,66,338,61,336,58,333,55,329,55,318,57,314,60,309,70,301,147,253,55,253,75,253,151,301,157,305,161,309,164,314,166,318,166,329,163,333,160,336,155,338,148,339,140,337,136,335,132,332, +147,253,166,253,94,328,147,253,94,328,89,332,147,253,89,332,85,335,147,253,85,335,81,337,147,253,81,337,77,338,147,253,77,338,73,339,147,253,73,339,70,301,55,323,55,318,55,329,55,329,55,318,57,314,55,329,57,314,58,333,58,333,57,314,60,309,58,333,60,309,61,336,61,336,60,309,65,305,61,336,65,305,66,338,66,338,65,305,70,301,66,338,70,301,73,339, +55,253,75,253,151,301,157,305,161,309,164,314,166,318,166,329,163,333,160,336,155,338,148,339,140,337,136,335,132,332,127,328,203,253,140,337,109,337,47,253,64,253,124,305,185,253,193,319,188,309,183,302,178,297,173,294,161,294,155,295,148,298,139,302, +148,339,151,301,155,338,155,338,151,301,157,305,155,338,157,305,160,336,160,336,157,305,161,309,160,336,161,309,163,333,163,333,161,309,164,314,163,333,164,314,166,329,166,329,164,314,166,318,166,329,166,318,166,323,151,301,148,339,144,338,151,301,144,338,140,337,151,301,140,337,136,335,151,301,136,335,132,332,151,301,132,332,127,328,151,301,127,328,75,253,127,328,55,253,75,253, +203,253,140,337,109,337,47,253,64,253,124,305,185,253,193,319,188,309,183,302,178,297,173,294,161,294,155,295, +47,253,64,253,109,337,109,337,64,253,124,305,109,337,124,305,140,337,140,337,124,305,185,253,140,337,185,253,203,253, +193,319,188,309,183,302,178,297,173,294,161,294,155,295,148,298,139,302,128,307,121,311,107,315,100,316,93,316,79,314,67,308,56,298,48,284,42,266,57,266,61,274,65,281,70,285,76,288,83,289,88,289,92,288,98,286,105,282,114,278,125,273,134,269,141,267,148,266,155,266,170,268,182,274,192,284,201,299,208,319,203,273,203,300,47,300,47,273,250,385,250,410,0,410,0,385,180,332,171,313,162,300,151,290,139,285,124,283,107,285,93,291,82,301,73,315,68,332,54,332,56,305,64,283,78,267,98,257,123,253,145,256,164,266,178,281,188,303,194,332,150,286,148,294,145,301,140,306,133,310,124,311,116,310,109,306,104,301,101,294, +61,274,65,281,67,308,67,308,65,281,70,285,67,308,70,285,79,314,79,314,70,285,76,288,79,314,76,288,83,289,83,289,88,289,93,316,93,316,88,289,92,288,93,316,92,288,98,286,57,266,61,274,67,308,57,266,67,308,56,298,57,266,56,298,48,284,57,266,48,284,42,266,155,266,170,268,161,294,161,294,170,268,166,294,173,294,166,294,170,268,173,294,170,268,182,274,193,319,188,309,192,284,193,319,192,284,201,299,193,319,201,299,208,319,183,302,178,297,182,274,183,302,182,274,192,284,183,302,192,284,188,309,114,313,114,278,121,311,121,311,114,278,125,273,121,311,125,273,128,307,128,307,125,273,134,269,128,307,134,269,139,302,139,302,134,269,141,267,139,302,141,267,148,298,148,298,141,267,148,266,148,298,148,266,155,295,155,295,148,266,155,266,155,295,155,266,161,294,93,316,98,286,100,316,100,316,98,286,105,282,100,316,105,282,107,315,107,315,105,282,114,278,107,315,114,278,114,313,93,316,79,314,83,289,173,294,182,274,178,297, +203,273,203,300,47,300,47,273,250,385,250,410,0,410,0,385, +203,273,203,300,47,300,203,273,47,300,47,273, +250,385,250,410,0,410,0,385,180,332,171,313,162,300,151,290, +250,385,250,410,0,410,250,385,0,410,0,385, +180,332,171,313,162,300,151,290,139,285,124,283,107,285,93,291,82,301,73,315,68,332,54,332,56,305,64,283,78,267,98,257,123,253,145,256,164,266,178,281,188,303,194,332,150,286,148,294,145,301,140,306,133,310,124,311,116,310,109,306,104,301,101,294,100,286,101,278,105,272,110,266,117,263,124,262,132,263,139,266,145,271,148,278,150,286,200,286, +107,285,93,291,98,257,98,257,93,291,82,301,98,257,82,301,78,267,78,267,82,301,73,315,78,267,73,315,68,332,171,313,162,300,164,266,164,266,162,300,151,290,164,266,151,290,145,256,145,256,151,290,139,285,145,256,139,285,124,283,124,283,107,285,123,253,123,253,107,285,98,257,68,332,54,332,56,305,68,332,56,305,64,283,68,332,64,283,78,267,180,332,171,313,178,281,180,332,178,281,188,303,180,332,188,303,194,332,124,283,123,253,145,256,171,313,164,266,178,281, +150,286,148,294,145,301,140,306,133,310,124,311,116,310,109,306,104,301,101,294,100,286,101,278,105,272,110,266,117,263,124,262,132,263,139,266,145,271,148,278,150,286,200,286,198,294,195,301,189,306,182,310,175,311,167,310,160,306,155,301,151,294,150,286,151,278,155,272,160,266,166,263,174,262,182,263,189,266,195,272,198,278,200,286, +124,262,132,263,133,310,133,310,132,263,139,266,133,310,139,266,140,306,140,306,139,266,145,271,140,306,145,271,145,301,145,301,145,271,148,278,145,301,148,278,148,294,148,294,148,278,150,286,101,294,101,278,104,301,104,301,101,278,105,272,104,301,105,272,109,306,109,306,105,272,110,266,109,306,110,266,116,310,116,310,110,266,117,263,116,310,117,263,124,311,124,311,117,263,124,262,124,311,124,262,133,310,101,278,101,294,100,286, +200,286,198,294,195,301,189,306,182,310,175,311,167,310,160,306,155,301,151,294,150,286,151,278,155,272,160,266,166,263,174,262,182,263,189,266,195,272,198,278,200,286,16383,16383,100,286,99,294,95,301,90,306,83,310,75,311,67,310,60,306,55,301,51,294,50,286,51,278,55,272,60,266,67,263,75,262,83,263,90,266,95,272,99,278,100,286,109,291,109,246,126,246,127,263,131,263,147,266,160,274,171,287,178,303,181,321,179,337,175,352,165,364,150,373,129,376,122,375,116,374,109,372,104,370,99,367,94,363,91,359,88,354,86,346,87,342,89,338,92,335,96,333,100,332,109,335,113,343,116,353,121,361,131,364,139,362,146,356,150,347,153,336,153,325,152,314,146,304,138,297,128,292, +75,311,75,262,83,310,83,310,75,262,83,263,83,310,83,263,90,306,90,306,83,263,90,266,90,306,90,266,95,301,95,301,90,266,95,272,95,301,95,272,99,294,99,294,95,272,99,278,99,294,99,278,100,286,50,286,51,278,51,294,51,294,51,278,55,272,51,294,55,272,55,301,55,301,55,272,60,266,55,301,60,266,60,306,60,306,60,266,67,263,60,306,67,263,67,310,67,310,67,263,75,262,67,310,75,262,75,311,150,286,151,278,151,294,151,294,151,278,155,272,151,294,155,272,155,301,155,301,155,272,160,266,155,301,160,266,160,306,160,306,160,266,166,263,160,306,166,263,167,310,167,310,166,263,174,262,167,310,174,262,175,311,175,311,174,262,182,263,175,311,182,263,182,310,182,310,182,263,189,266,182,310,189,266,189,306,189,306,189,266,195,272,189,306,195,272,195,301,195,301,195,272,198,278,195,301,198,278,198,294,198,294,198,278,200,286, +109,291,109,246,126,246,127,263,131,263,147,266,160,274,171,287,178,303,181,321,179,337,175,352,165,364,150,373,129,376,122,375,116,374,109,372,104,370,99,367,94,363,91,359,88,354,86,346,87,342,89,338,92,335,96,333,100,332,109,335,113,343,116,353,121,361,131,364,139,362,146,356,150,347,153,336,153,325,152,314,146,304,138,297,128,292,116,291,175,305,173,321,165,335,155,346,141,353,126,355,110,353,96,346,85,335,78,322,75,306,78,290,85,276,95,266,109,259,124,256,140,259,154,266,165,276,173,290,175,305,16383,16383,158,306,156,295,152,286,144,279,135,275,124,273,114,275,106,279,99,286,94,295,93,306,94,316,99,325,106,332,115,337,124,339,135,337,144,332,151,325,156,316,158,306,118,253, +131,364,129,376,122,375,131,364,122,375,121,361,131,364,150,373,129,376,121,361,122,375,116,353,116,353,122,375,116,374,116,353,116,374,113,343,113,343,116,374,109,372,113,343,109,372,109,335,109,335,109,372,104,370,109,335,104,370,100,332,100,332,104,370,99,367,100,332,99,367,96,333,96,333,99,367,94,363,96,333,94,363,92,335,92,335,94,363,91,359,92,335,91,359,89,338,89,338,91,359,88,354,89,338,88,354,87,342,87,342,88,354,87,350,87,342,87,350,86,346,181,321,179,337,178,303,178,303,179,337,175,352,178,303,175,352,171,287,171,287,175,352,165,364,171,287,165,364,160,274,160,274,165,364,153,325,153,336,153,325,165,364,153,336,165,364,150,373,153,336,150,373,150,347,150,373,131,364,139,362,150,373,139,362,146,356,150,373,146,356,150,347,152,314,146,304,147,266,152,314,147,266,160,274,152,314,160,274,153,325,126,246,127,263,128,292,128,292,127,263,131,263,128,292,131,263,138,297,138,297,131,263,147,266,138,297,147,266,146,304,126,246,128,292,116,291,126,246,116,291,109,291,126,246,109,291,109,246, +175,305,173,321,165,335,155,346,141,353,126,355,110,353,96,346,85,335,78,322,75,306,78,290,85,276,95,266,109,259,124,256,140,259,154,266,165,276,173,290,175,305,16383,16383,158,306,156,295,152,286,144,279,135,275,124,273,114,275,106,279,99,286,94,295,93,306,94,316,99,325,106,332,115,337,124,339,135,337,144,332,151,325,156,316,158,306,118,253,137,253,214,301,220,305,224,310,227,314,229,324,228,329,226,333,222,336,218,338,212,339,208,339,204,338,200,336,196,333,190,328,16383,16383,40,253,60,253,137,301,142,305,146,310,149,314,151,319,151,324,150,329,148,333,144,336,140,338,134,339,130,339,126,338,123,336,118,333,113,328,203,337,185,337,125,286,65,337,47,337,109,253,141,253, +156,295,152,286,154,266,154,266,152,286,144,279,154,266,144,279,140,259,140,259,144,279,135,275,140,259,135,275,124,256,124,256,135,275,124,273,126,355,124,339,135,337,126,355,135,337,141,353,141,353,135,337,144,332,141,353,144,332,155,346,155,346,144,332,151,325,155,346,151,325,156,316,175,305,173,321,173,290,173,290,173,321,165,335,173,290,165,335,165,276,165,276,165,335,158,306,156,316,158,306,165,335,156,316,165,335,155,346,156,295,154,266,165,276,156,295,165,276,158,306,99,325,106,332,110,353,110,353,106,332,115,337,110,353,115,337,126,355,126,355,115,337,124,339,96,346,85,335,93,306,96,346,93,306,94,316,96,346,94,316,99,325,96,346,99,325,110,353,99,286,94,295,95,266,95,266,94,295,93,306,114,275,106,279,109,259,114,275,109,259,124,256,114,275,124,256,124,273,99,286,95,266,109,259,99,286,109,259,106,279,75,306,78,290,78,322,78,322,78,290,85,276,78,322,85,276,85,335,85,335,85,276,95,266,85,335,95,266,93,306, +118,253,137,253,214,301,220,305,224,310,227,314,229,324,228,329,226,333,222,336,218,338,212,339,208,339,204,338,200,336,196,333,190,328,16383,16383,40,253,60,253,137,301,142,305,146,310,149,314,151,319,151,324,150,329,148,333,144,336,140,338,134,339,130,339,126,338,123,336,118,333,113,328,203,337,185,337,125,286,65,337,47,337,109,253,141,253,142,250,142,350,115,350,115,250,174,250,174,350,146,350,146,250,16383,16383,104,250,104,350,77,350,77,250,229,253,156,328,151,333,146,336,142,338,138,339,134,339,129,338,124,336,121,333,119,329,118,324,118,319,120,314,123,310,127,305, +212,339,214,301,218,338,218,338,214,301,220,305,218,338,220,305,222,336,222,336,220,305,224,310,222,336,224,310,226,333,226,333,224,310,227,314,226,333,227,314,228,329,228,329,227,314,228,319,228,329,228,319,229,324,214,301,212,339,208,339,214,301,208,339,204,338,214,301,204,338,200,336,214,301,200,336,196,333,214,301,196,333,190,328,214,301,190,328,137,253,134,339,137,301,140,338,140,338,137,301,142,305,140,338,142,305,144,336,144,336,142,305,146,310,144,336,146,310,148,333,148,333,146,310,149,314,148,333,149,314,150,329,150,329,149,314,151,319,150,329,151,319,151,324,137,301,134,339,130,339,137,301,130,339,126,338,137,301,126,338,123,336,137,301,123,336,118,333,137,301,118,333,113,328,137,301,113,328,60,253,60,253,113,328,40,253,137,253,190,328,118,253, +203,337,185,337,125,286,65,337,47,337,109,253,141,253,142,250,142,350,115,350,115,250,174,250,174,350,146,350, +203,337,185,337,141,253,141,253,185,337,125,286,141,253,125,286,109,253,109,253,125,286,65,337,109,253,65,337,47,337, +142,250,142,350,115,350,115,250,174,250,174,350,146,350,146,250, +142,250,142,350,115,350,142,250,115,350,115,250, +174,250,174,350,146,350,146,250,16383,16383,104,250,104,350,77,350,77,250,229,253,156,328,151,333,146,336,142,338,138,339,134,339,129,338,124,336, +146,350,146,250,174,250,146,350,174,250,174,350,77,350,77,250,104,250,77,350,104,250,104,350, +229,253,156,328,151,333,146,336,142,338,138,339,134,339,129,338,124,336,121,333,119,329,118,324,118,319,120,314,123,310,127,305,132,301,209,253,16383,16383,151,253,78,328,73,333,68,336,64,338,60,339,56,339,51,338,46,336,43,333,40,329,40,319,42,314,44,310,49,305,54,301,131,253,150,358,148,366,145,373,140,379,133,382,124,383,116,382,109,379,104,373,101,366,100,358,101,351,105,344,110,339,117,335,124,334,132,335,139,339,145,344,148,350,150,358,16383,16383,180,332,171,313,162,300,151,290,139,285,124,283,107,285,93,291,82,301,73,315,68,332,54,332,56,305,64,283, +209,253,229,253,156,328,209,253,156,328,151,333,209,253,151,333,146,336,209,253,146,336,142,338,209,253,142,338,138,339,209,253,138,339,134,339,209,253,134,339,132,301,118,324,118,319,119,329,119,329,118,319,120,314,119,329,120,314,121,333,121,333,120,314,123,310,121,333,123,310,124,336,124,336,123,310,127,305,124,336,127,305,129,338,129,338,127,305,132,301,129,338,132,301,134,339,131,253,151,253,78,328,131,253,78,328,73,333,131,253,73,333,68,336,131,253,68,336,64,338,131,253,64,338,60,339,131,253,60,339,56,339,131,253,56,339,54,301,40,324,40,319,40,329,40,329,40,319,42,314,40,329,42,314,43,333,43,333,42,314,44,310,43,333,44,310,46,336,46,336,44,310,49,305,46,336,49,305,51,338,51,338,49,305,54,301,51,338,54,301,56,339, +353,0,353,9,340,12,330,17,321,26,314,38,306,55,184,337,174,337,70,93,55,58,44,34,33,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,99,108,230,108,251,61,257,45,259,38,260,31,261,26,260,22,258,18,256,15,252,13,248,12,226,9,226,0,16383,16383,224,128,108,128,166,266,211,175,235,181,254,191,268,205,277,224,280,248,274,277,258,300,232,317,195,327,148,331,8,331,8,321,29,320,43,316,51,308,55,295,56,275,56,56,55,37,51,24,42,16,29,11,8,9,8,0,177,0,217,4,250,15,275,34,291,58,296,89,292,116,281,138,263,155,239,167,211,174,16383,16383,108,183,108,303,109,307,112,310,115,312,119,313,162,310,192,302, +55,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,174,337,76,51,99,108,174,337,99,108,108,128,108,128,99,108,230,108,108,128,230,108,224,128,224,128,230,108,306,55,224,128,306,55,184,337,258,18,256,15,353,0,353,0,256,15,252,13,353,0,252,13,248,12,261,26,353,0,330,17,261,26,330,17,321,26,261,26,321,26,314,38,261,26,314,38,306,55,261,26,306,55,260,31,306,55,230,108,251,61,306,55,251,61,254,53,306,55,254,53,257,45,306,55,257,45,259,38,306,55,259,38,260,31,174,337,108,128,166,266,174,337,166,266,224,128,174,337,224,128,184,337,70,93,55,58,72,30,70,93,74,43,75,47,70,93,75,47,76,51,70,93,76,51,174,337,340,12,330,17,353,0,340,12,353,0,353,9,260,22,258,18,353,0,260,22,353,0,261,26,226,9,226,0,353,0,226,9,353,0,248,12,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,44,34,107,0,44,34,33,20,107,0,33,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,55,58, +211,175,235,181,254,191,268,205,277,224,280,248,274,277,258,300,232,317,195,327,148,331,8,331,8,321,29,320,43,316,51,308,55,295,56,275,56,56,55,37,51,24,42,16,29,11,8,9,8,0,177,0,217,4,250,15,275,34,291,58,296,89,292,116,281,138,263,155,239,167,211,174,16383,16383,108,183,108,303,109,307,112,310,115,312,119,313,162,310,192,302,213,289,225,270,228,245,225,223,214,205,197,193,172,186,139,183,16383,16383,108,163,140,163,171,161,198,155,220,142,234,121,239,89,234,59,220,39,198,26,170,20,138,18,126,19,118,21,112,26,109,32,108,41,289,247,286,331,6,331,6,321,25,319,38,315,45,307,49,294,50,276,50,62,49,40,45,25,37,16,25,12,6,9,6,0,146,0,146,9,126,11,113,16,105,24,101,37,100,56,100,292,101,300,103,306,106,310,111,311,118,312,206,312,232,310,251,303,264,291,272,273,276,247,338,0,184,337,174,337,24,0,16383,16383,262,46,68,46,166,266,299,84,285,84,271,57,254,38,230,26,197,20,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184, +51,24,42,16,177,0,177,0,42,16,29,11,177,0,29,11,8,9,55,295,56,275,112,310,55,295,112,310,148,331,148,331,112,310,115,312,148,331,115,312,119,313,119,313,162,310,148,331,148,331,162,310,195,327,239,89,234,59,250,15,250,15,234,59,220,39,250,15,220,39,217,4,217,4,220,39,198,26,217,4,198,26,177,0,177,0,198,26,170,20,177,0,170,20,138,18,138,18,126,19,177,0,177,0,126,19,118,21,177,0,118,21,55,37,55,37,118,21,56,56,213,289,225,270,232,317,232,317,225,270,228,245,235,181,228,245,225,223,195,327,162,310,192,302,195,327,192,302,213,289,195,327,213,289,232,317,235,181,254,191,258,300,258,300,254,191,268,205,258,300,268,205,274,277,274,277,268,205,277,224,274,277,277,224,280,248,232,317,228,245,235,181,232,317,235,181,258,300,234,121,239,167,220,142,220,142,239,167,211,174,220,142,211,174,198,155,198,155,211,174,211,175,198,155,211,175,214,205,214,205,211,175,235,181,214,205,235,181,225,223,140,163,171,161,172,186,172,186,171,161,198,155,172,186,198,155,197,193,197,193,198,155,214,205,140,163,172,186,139,183,140,163,139,183,108,183,140,163,108,183,108,163,109,32,108,41,56,275,109,32,56,275,56,56,296,89,292,116,291,58,291,58,292,116,281,138,291,58,281,138,275,34,275,34,281,138,263,155,275,34,263,155,250,15,250,15,263,155,239,167,250,15,239,167,239,89,56,56,118,21,112,26,56,56,112,26,109,32,56,275,108,41,108,296,56,275,108,296,108,303,56,275,108,303,109,307,56,275,109,307,112,310,148,331,8,331,29,320,148,331,29,320,43,316,148,331,43,316,51,308,148,331,51,308,55,295,29,320,8,331,8,321,177,0,8,9,8,0,51,24,177,0,55,37,239,167,234,121,239,89, +289,247,286,331,6,331,6,321,25,319,38,315,45,307,49,294,50,276,50,62,49,40,45,25,37,16,25,12,6,9,6,0,146,0,146,9,126,11,113,16,105,24,101,37,100,56,100,292,101,300,103,306,106,310,111,311,118,312,206,312,232,310,251,303,264,291,272,273,276,247,338,0,184,337,174,337,24,0,16383,16383,262,46,68,46,166,266,299,84,285,84,271,57,254,38,230,26,197,20,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184, +38,315,45,307,286,331,286,331,45,307,111,311,286,331,111,311,118,312,286,331,118,312,206,312,286,331,206,312,232,310,286,331,232,310,251,303,286,331,251,303,264,291,286,331,264,291,272,273,286,331,272,273,276,247,286,331,276,247,289,247,100,56,100,292,50,276,50,276,100,292,101,300,50,276,101,300,103,306,50,276,103,306,106,310,50,276,106,310,49,294,50,276,101,37,100,56,111,311,45,307,49,294,111,311,49,294,106,310,25,319,38,315,286,331,25,319,286,331,6,331,25,319,6,331,6,321,146,0,146,9,126,11,146,0,126,11,113,16,146,0,113,16,49,40,146,0,49,40,45,25,146,0,45,25,37,16,146,0,37,16,25,12,146,0,25,12,6,9,146,0,6,9,6,0,50,62,49,40,113,16,50,62,113,16,105,24,50,62,105,24,101,37,50,62,101,37,50,276, +338,0,184,337,174,337,24,0,16383,16383,262,46,68,46,166,266,299,84,285,84,271,57,254,38,230,26,197,20,151,18,132,19, +174,337,24,0,68,46,68,46,24,0,338,0,68,46,338,0,262,46,262,46,338,0,184,337,262,46,184,337,174,337,174,337,68,46,166,266,174,337,166,266,262,46, +299,84,285,84,271,57,254,38,230,26,197,20,151,18,132,19,117,21,108,25,102,31,100,42,100,164,176,164,198,162,213,158,222,150,229,136,233,115,244,115,244,232,233,232,229,212,222,198,213,190,198,185,176,184,100,184,100,294,101,302,103,307,106,310,111,312,118,312,179,311,219,306,243,297,255,282,261,259,273,259,271,331,6,331,6,321,25,320,38,315,45,307,49,294,50,275,50,57,49,37,45,24,38,16,25,12,6,9,6,0,276,0,299,88,287,88,282,72,278,59,273,49,266,40,257,33,249,28,240,24,228,21,215,20,199,19,73,19,289,324,289,331,26,331,16,246,29,246,32,260,35,271,38,279,43,287,50,295,58,301,68,306,81,309,97,311,117,312,224,312,5,7,5,0,286,0,352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,211,331,211,321,231,319,244,315,251,307,255,294,256,274,256,180,104,180,104,274, +45,24,38,16,276,0,276,0,38,16,25,12,276,0,25,12,6,9,38,315,45,307,271,331,271,331,45,307,111,312,271,331,111,312,118,312,118,312,179,311,271,331,271,331,179,311,219,306,271,331,219,306,243,297,271,331,243,297,255,282,271,331,255,282,261,259,271,331,261,259,273,259,45,24,117,21,49,37,49,37,117,21,108,25,49,37,108,25,50,57,50,57,108,25,102,31,50,57,102,31,50,275,50,275,102,31,100,42,50,275,100,42,100,294,100,184,100,164,176,164,100,184,176,164,176,184,198,185,176,184,198,162,198,185,198,162,213,190,213,190,198,162,213,158,213,190,213,158,222,198,222,198,213,158,222,150,222,198,222,150,229,212,229,212,222,150,229,136,229,212,229,136,233,232,233,232,229,136,233,115,233,232,233,115,244,115,50,275,100,294,101,302,50,275,101,302,103,307,50,275,103,307,106,310,50,275,106,310,49,294,106,310,111,312,45,307,106,310,45,307,49,294,25,320,38,315,271,331,25,320,271,331,6,331,25,320,6,331,6,321,254,38,230,26,276,0,276,0,230,26,197,20,276,0,197,20,151,18,151,18,132,19,276,0,276,0,132,19,117,21,276,0,117,21,45,24,276,0,299,84,285,84,276,0,285,84,271,57,276,0,271,57,254,38,176,184,176,164,198,162,233,232,244,115,244,232,276,0,6,9,6,0, +299,88,287,88,282,72,278,59,273,49,266,40,257,33,249,28,240,24,228,21,215,20,199,19,73,19,289,324,289,331,26,331,16,246,29,246,32,260,35,271,38,279,43,287,50,295,58,301,68,306,81,309,97,311,117,312,224,312,5,7,5,0,286,0,352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,211,331,211,321,231,319,244,315,251,307,255,294,256,274,256,180,104,180,104,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321, +35,271,38,279,26,331,26,331,38,279,43,287,26,331,43,287,50,295,50,295,58,301,26,331,26,331,58,301,68,306,26,331,68,306,81,309,73,19,289,324,224,312,224,312,289,324,289,331,224,312,289,331,117,312,97,311,117,312,289,331,97,311,289,331,26,331,26,331,16,246,29,246,26,331,29,246,32,260,26,331,32,260,35,271,224,312,5,7,73,19,73,19,5,7,286,0,73,19,286,0,199,19,199,19,286,0,215,20,278,59,273,49,286,0,286,0,273,49,266,40,286,0,266,40,257,33,257,33,249,28,286,0,286,0,249,28,240,24,286,0,240,24,228,21,286,0,299,88,287,88,286,0,287,88,282,72,286,0,282,72,278,59,286,0,5,7,5,0,215,20,286,0,228,21,26,331,81,309,97,311, +352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,211,331,211,321,231,319,244,315,251,307,255,294,256,274,256,180,104,180,104,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,28,319,41,315,49,307,53,294,54,274,54,61,53,39,49,25,42,16,29,12,9,9,9,0,148,0,148,9,129,12,117,17,109,25,105,38,104,56,104,157,256,157,256,62,255,41,252,26,244,17,232,12,212,9,212,0,251,118,249,129,247,142,245,170,245,189,246,197,247,204,251,220,238,220,235,211,231,203,226,197,218,193,209,191,156,191,146,192,139,196,133,201,129,209,124,220,112,220,114,210,116,197,117,184,117,172,118,161,118,153,115,126,113,118,125,118,129,129,134,138,139,144,146,148,156,149,209,149,219,148,226,144,231,137,235,128,238,118,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24, +49,25,42,16,148,0,148,0,42,16,29,12,148,0,29,12,9,9,149,331,9,331,28,319,149,331,28,319,41,315,149,331,41,315,49,307,149,331,49,307,53,294,149,331,53,294,118,315,149,331,118,315,130,319,149,331,130,319,149,321,54,274,105,38,104,56,104,180,104,157,256,157,104,180,256,157,256,180,256,180,256,157,312,25,256,180,312,25,308,37,54,274,104,56,104,274,54,274,104,274,106,294,54,274,106,294,110,307,54,274,110,307,118,315,54,274,118,315,53,294,252,26,244,17,352,0,352,0,244,17,232,12,352,0,232,12,212,9,333,319,352,321,352,331,333,319,352,331,320,315,320,315,352,331,255,294,320,315,255,294,256,274,308,37,256,274,256,180,307,55,307,274,256,274,256,274,307,274,308,293,256,274,308,293,312,307,352,331,211,331,231,319,352,331,231,319,244,315,352,331,244,315,251,307,352,331,251,307,255,294,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,255,41,352,0,255,41,252,26,256,62,255,41,320,17,256,62,320,17,312,25,256,62,312,25,256,157,148,0,148,9,129,12,148,0,129,12,117,17,148,0,117,17,53,39,148,0,53,39,49,25,54,61,53,39,117,17,54,61,117,17,109,25,54,61,109,25,105,38,54,61,105,38,54,274,148,0,9,9,9,0,352,0,212,9,212,0,256,274,308,37,307,55,231,319,211,331,211,321,320,315,256,274,312,307,28,319,9,331,9,321, +251,118,249,129,247,142,245,170,245,189,246,197,247,204,251,220,238,220,235,211,231,203,226,197,218,193,209,191,156,191,146,192,139,196,133,201,129,209,124,220,112,220,114,210,116,197,117,184,117,172,118,161,118,153,115,126,113,118,125,118,129,129,134,138,139,144,146,148,156,149,209,149,219,148,226,144,231,137,235,128,238,118,16383,16383,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,362,0,362,9,349,11,336,16,322,25,305,41,283,64,166,192,259,281,278,298,292,309,305,316,320,320,338,321,338,331,208,331,208,321,220,321,229,320,235,318,238,315,240,311,241,305,239,298,234,289,226,280,202,256,113,174,113,293,117,307,124,315,137,319,158,321,158,331,17,331,17,321,37,319,50,315,57,306,61,293,62,275,62,63,61,40,57,26,50,17,36,12,17,9,17,0,157,0,157,9,139,12,126,16,118,23,114,36,113,55,113,148,126,158,176,107,198,84,217,63,232,46,241,32,244,22,244,18,241,15,237,12,231,11,224,10,210,9,210,0,344,0,344,9,330,12,320,17,311,26,304,38,296,55,179,337, +207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,134,308,149,314,180,338,180,338,149,314,164,318,180,338,164,318,180,320,180,320,194,319,235,330,235,330,194,319,207,316,235,330,180,338,180,320,247,142,246,156,238,220,238,220,246,156,245,170,238,220,245,170,245,180,245,180,245,189,238,220,238,220,245,189,246,197,238,220,246,197,247,204,249,212,251,220,238,220,249,212,238,220,247,204,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,234,1,235,26,223,19,234,1,223,19,209,15,234,1,209,15,196,12,234,1,196,12,181,11,234,1,181,11,180,-6,226,144,231,137,231,203,231,203,231,137,235,128,231,203,235,128,235,211,235,211,235,128,238,118,235,211,238,118,238,220,238,220,238,118,249,129,238,220,249,129,247,142,156,149,209,149,209,191,218,193,209,191,219,148,218,193,219,148,226,197,226,197,219,148,226,144,226,197,226,144,231,203,209,191,156,191,156,149,146,148,156,149,156,191,146,148,156,191,146,192,146,148,146,192,139,144,139,144,146,192,139,196,139,144,139,196,134,138,134,138,139,196,133,201,134,138,133,201,129,129,129,129,133,201,129,209,129,129,129,209,125,118,125,118,129,209,124,220,125,118,124,220,118,161,118,161,124,220,117,172,124,220,112,220,114,210,124,220,114,210,116,197,124,220,116,197,117,184,124,220,117,184,117,172,125,118,118,161,118,153,125,118,118,153,117,144,125,118,117,144,116,135,125,118,116,135,115,126,125,118,115,126,113,118,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,154,15,180,-6,167,12,167,12,180,-6,181,11,142,19,130,25,180,-6,142,19,180,-6,154,15,81,24,74,166,46,61,126,330,134,308,180,338,209,191,209,149,219,148,249,129,238,118,251,118, +157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,362,0,362,9,349,11,336,16,322,25,305,41,283,64,166,192,259,281,278,298,292,309,305,316,320,320,338,321,338,331,208,331,208,321,220,321,229,320,235,318,238,315,240,311,241,305,239,298,234,289,226,280,202,256, +52,23,44,15,157,0,157,0,44,15,30,11,157,0,30,11,9,9,157,331,9,331,30,320,157,331,30,320,44,316,157,331,44,316,53,308,157,331,53,308,57,295,157,331,57,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,57,295,157,0,157,9,137,11,157,0,137,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,9,9,9,0,56,36,122,16,57,56,30,320,9,331,9,321, +362,0,362,9,349,11,336,16,322,25,305,41,283,64,166,192,259,281,278,298,292,309,305,316,320,320,338,321,338,331,208,331,208,321,220,321,229,320,235,318,238,315,240,311,241,305,239,298,234,289,226,280,202,256,113,174,113,293,117,307,124,315,137,319,158,321,158,331,17,331,17,321,37,319,50,315,57,306,61,293,62,275,62,63,61,40,57,26,50,17,36,12,17,9,17,0,157,0,157,9,139,12,126,16,118,23,114,36,113,55,113,148,126,158,176,107,198,84,217,63,232,46,241,32,244,22,244,18,241,15,237,12,231,11,224,10,210,9,210,0,344,0,344,9,330,12,320,17,311,26,304,38,296,55,179,337,169,337,70,93,56,58,44,34,34,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,160,267,161,267,241,61,244,51,247,44,249,37,250,31,251,26,249,18,244,13,236,11,227,10,216,9,216,0,432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12, +158,321,158,321,137,319,137,319,158,321,158,331,137,319,158,331,124,315,124,315,158,331,61,293,124,315,61,293,62,275,114,36,62,275,62,63,114,36,62,63,118,23,118,23,62,63,126,16,62,275,114,36,113,55,113,174,113,148,126,158,113,174,126,158,202,256,202,256,126,158,166,192,202,256,166,192,259,281,62,275,113,55,113,274,62,275,113,274,113,293,62,275,113,293,117,307,62,275,117,307,124,315,158,331,17,331,37,319,158,331,37,319,50,315,158,331,50,315,57,306,158,331,57,306,61,293,234,289,226,280,259,281,259,281,226,280,215,269,259,281,215,269,202,256,338,331,208,331,220,321,338,331,220,321,229,320,338,331,229,320,235,318,338,331,235,318,238,315,338,331,238,315,240,311,338,331,240,311,241,305,338,331,241,305,305,316,338,331,305,316,320,320,338,331,320,320,338,321,241,305,259,281,278,298,241,305,278,298,292,309,241,305,292,309,305,316,239,298,234,289,259,281,239,298,259,281,241,305,241,15,237,12,362,0,362,0,237,12,231,11,362,0,231,11,224,10,244,22,362,0,336,16,244,22,336,16,322,25,244,22,322,25,305,41,244,22,305,41,283,64,244,22,283,64,241,32,283,64,166,192,176,107,283,64,176,107,198,84,283,64,198,84,217,63,283,64,217,63,232,46,283,64,232,46,241,32,349,11,336,16,362,0,349,11,362,0,362,9,244,18,241,15,362,0,244,18,362,0,244,22,210,9,210,0,362,0,210,9,362,0,224,10,157,0,157,9,139,12,157,0,139,12,126,16,157,0,126,16,61,40,157,0,61,40,57,26,157,0,57,26,50,17,157,0,50,17,36,12,157,0,36,12,17,9,157,0,17,9,17,0,61,40,126,16,62,63,176,107,166,192,126,158,220,321,208,331,208,321,37,319,17,331,17,321, +344,0,344,9,330,12,320,17,311,26,304,38,296,55,179,337,169,337,70,93,56,58,44,34,34,20,22,13,7,9,7,0,107,0,107,9,94,10,84,12,77,16,73,22,72,30,72,34,73,38,74,43,76,51,160,267,161,267,241,61,244,51,247,44,249,37,250,31,251,26,249,18,244,13,236,11,227,10,216,9,216,0,432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12,6,9,6,0,123,0,123,9,103,12,90,18,82,29,78,48,76,75,76,275,203,0,209,0, +56,58,73,22,72,30,72,30,72,34,70,93,70,93,72,34,73,38,70,93,73,38,74,43,161,267,169,337,160,267,160,267,169,337,76,51,75,47,76,51,169,337,75,47,169,337,70,93,251,26,344,0,320,17,251,26,320,17,311,26,251,26,311,26,304,38,251,26,304,38,296,55,251,26,296,55,250,31,296,55,179,337,241,61,296,55,241,61,244,51,296,55,244,51,247,44,296,55,247,44,249,37,296,55,249,37,250,31,169,337,161,267,241,61,169,337,241,61,179,337,70,93,56,58,72,30,330,12,320,17,344,0,330,12,344,0,344,9,249,18,244,13,344,0,249,18,344,0,251,26,344,0,244,13,236,11,344,0,236,11,227,10,344,0,227,10,216,9,344,0,216,9,216,0,107,0,107,9,94,10,107,0,94,10,84,12,107,0,84,12,34,20,107,0,34,20,22,13,107,0,22,13,7,9,107,0,7,9,7,0,44,34,34,20,84,12,44,34,84,12,77,16,44,34,77,16,73,22,44,34,73,22,56,58,75,47,70,93,74,43, +432,0,432,9,413,12,401,17,393,25,389,38,388,56,388,275,389,294,393,307,401,316,413,320,431,321,431,331,332,331,222,80,106,331,7,331,7,321,28,319,42,315,50,307,54,294,55,275,55,75,54,47,49,29,41,18,27,12,6,9,6,0,123,0,123,9,103,12,90,18,82,29,78,48,76,75,76,275,203,0,209,0,337,286,337,61,336,40,333,26,325,17,312,12,292,9,292,0,353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9,103,13,90,20,82,31,78,49,76,75,76,269,297,-5,306,-5,306,274,308,289,311,299,315,307,320,313,324,315,329,318,335,319,343,320,353,321,295,247,295,331, +49,29,41,18,123,0,123,0,41,18,27,12,123,0,27,12,6,9,333,26,325,17,432,0,432,0,325,17,312,12,432,0,312,12,292,9,413,320,431,321,431,331,413,320,431,331,401,316,401,316,431,331,337,286,401,316,337,286,393,307,393,307,337,286,389,294,401,17,393,25,337,61,337,61,393,25,389,38,337,61,389,38,337,286,337,286,389,38,388,56,337,286,388,56,388,275,203,0,209,0,222,80,222,80,209,0,337,286,222,80,337,286,332,331,332,331,337,286,431,331,106,331,7,331,28,319,106,331,28,319,42,315,106,331,42,315,50,307,106,331,50,307,54,294,106,331,54,294,55,275,106,331,55,275,76,275,106,331,76,275,203,0,106,331,203,0,222,80,76,75,76,275,55,275,76,75,55,275,78,48,78,48,55,275,55,75,78,48,55,75,82,29,82,29,55,75,54,47,82,29,54,47,90,18,90,18,54,47,49,29,90,18,49,29,123,0,432,0,432,9,413,12,432,0,413,12,401,17,432,0,401,17,336,40,432,0,336,40,333,26,103,12,90,18,123,0,103,12,123,0,123,9,123,0,6,9,6,0,432,0,292,9,292,0,336,40,401,17,337,61,28,319,7,331,7,321,389,294,337,286,388,275, +353,331,235,331,235,321,247,320,256,319,263,317,275,309,278,303,281,295,283,285,284,274,284,89,91,331,6,331,6,321,19,321,29,318,37,313,46,306,55,295,55,75,54,48,49,30,41,19,27,13,6,9,6,0,123,0,123,9,103,13,90,20,82,31,78,49,76,75,76,269,297,-5,306,-5,306,274,308,289,311,299,315,307,320,313,324,315,329,318,335,319,343,320,353,321,295,247,295,331,26,331,26,246,39,246,43,263,48,276,55,284,66,289,79,290,242,290,256,289,266,284,274,276,279,263,282,247,16383,16383,252,109,252,225,240,225,239,211,235,200,229,193,219,189,207,188,114,188,102,189,93,193,87,200,83,211,81,225,70,225,70,109,81,109,84,122,87,132,93,140,101,146,113,147,205,147,218,146,227,141,234,133,239,123,240,109,16383,16383,307,0, +49,30,41,19,123,0,123,0,41,19,27,13,123,0,27,13,6,9,256,319,263,317,353,331,353,331,263,317,269,313,353,331,269,313,275,309,275,309,278,303,353,331,353,331,278,303,281,295,353,331,281,295,324,315,324,315,281,295,320,313,324,315,320,313,320,312,320,312,320,313,315,307,315,307,320,313,284,274,315,307,284,274,284,259,297,-5,284,259,284,89,297,-5,284,89,91,331,353,331,324,315,329,318,353,331,329,318,335,319,353,331,335,319,343,320,353,331,343,320,353,321,306,-5,306,253,297,-5,297,-5,306,253,306,274,297,-5,306,274,284,259,284,259,306,274,308,289,284,259,308,289,311,299,283,285,284,274,320,313,283,285,320,313,281,295,247,320,256,319,353,331,247,320,353,331,235,331,247,320,235,331,235,321,91,331,6,331,19,321,91,331,19,321,29,318,91,331,29,318,37,313,91,331,37,313,46,306,91,331,46,306,55,295,91,331,55,295,76,269,91,331,76,269,297,-5,55,295,78,49,76,75,54,48,49,30,90,20,90,20,49,30,123,0,90,20,123,0,103,13,103,13,123,0,123,9,55,75,54,48,82,31,55,75,82,31,78,49,55,75,78,49,55,295,123,0,6,9,6,0,54,48,90,20,82,31,19,321,6,331,6,321,76,269,55,295,76,75,315,307,284,259,311,299, +295,247,295,331,26,331,26,246,39,246,43,263,48,276,55,284,66,289,79,290,242,290,256,289,266,284,274,276,279,263,282,247,16383,16383,252,109,252,225,240,225,239,211,235,200,229,193,219,189,207,188,114,188,102,189,93,193,87,200,83,211,81,225,70,225,70,109,81,109,84,122,87,132,93,140,101,146,113,147,205,147,218,146,227,141,234,133,239,123,240,109,16383,16383,307,0,307,85,295,85,293,70,287,57,278,49,265,44,248,42,70,42,56,44,44,49,35,57,29,69,27,85,15,85,15,0,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201, +295,331,26,331,66,289,295,331,66,289,79,290,295,331,79,290,242,290,295,331,242,290,256,289,295,331,256,289,266,284,295,331,266,284,274,276,295,331,274,276,279,263,295,331,279,263,282,247,295,331,282,247,295,247,26,331,26,246,39,246,26,331,39,246,43,263,26,331,43,263,48,276,26,331,48,276,55,284,26,331,55,284,66,289,219,189,207,188,218,146,218,146,207,188,205,147,205,147,207,188,114,188,205,147,114,188,113,147,101,146,113,147,102,189,101,146,102,189,93,193,83,211,84,122,87,200,87,200,84,122,87,132,87,200,87,132,93,193,93,193,87,132,93,140,93,193,93,140,101,146,83,211,81,225,84,122,84,122,81,225,81,109,81,109,81,225,70,225,81,109,70,225,70,109,240,225,239,211,240,109,240,225,240,109,252,109,240,225,252,109,252,225,240,109,239,211,239,123,239,123,239,211,235,200,239,123,235,200,234,133,234,133,235,200,229,193,234,133,229,193,227,141,227,141,229,193,219,189,227,141,219,189,218,146,287,57,278,49,307,0,307,0,278,49,265,44,307,0,265,44,248,42,307,0,307,85,295,85,307,0,295,85,293,70,307,0,293,70,287,57,248,42,70,42,307,0,307,0,70,42,56,44,307,0,56,44,15,0,15,0,56,44,44,49,15,0,44,49,35,57,15,0,35,57,15,85,15,85,35,57,29,69,15,85,29,69,27,85,113,147,114,188,102,189, +344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,9,331,9,321,28,319,41,315,49,307,53,294,54,274,54,61,53,39,49,25,42,16,29,12,9,9,9,0,148,0,148,9,129,12,117,17,109,25,105,38,104,56,104,296,105,303,107,307,111,310,116,312,238,312,245,311,251,310,254,306,256,301,256,62,255,41,252,26,244,17,232,12,212,9,212,0,8,331,8,321,27,319,39,315,46,307,49,294,50,276,50,39,47,25,40,16,27,12, +149,314,180,338,134,308,134,308,180,338,126,330,134,308,126,330,121,298,121,298,126,330,108,286,97,269,108,286,126,330,97,269,126,330,81,307,81,102,81,24,90,75,90,75,81,24,126,1,90,75,126,1,103,52,103,52,126,1,119,33,130,25,119,33,126,1,130,25,126,1,180,-6,207,316,235,330,194,319,194,319,235,330,180,320,164,318,180,320,180,338,164,318,180,338,149,314,81,307,46,271,46,61,81,307,46,61,74,166,81,307,74,166,76,194,81,307,76,194,80,222,81,307,80,222,87,247,81,307,87,247,97,269,81,102,76,132,81,24,81,24,76,132,74,166,24,109,46,61,46,271,24,109,46,271,24,224,24,109,24,224,17,167,223,19,209,15,234,1,234,1,209,15,196,12,234,1,196,12,181,11,181,11,167,12,180,-6,180,-6,167,12,154,15,180,-6,154,15,142,19,207,316,219,311,235,330,235,330,219,311,231,305,235,330,231,305,242,296,242,296,257,279,280,306,280,306,257,279,270,257,280,306,270,257,279,231,235,330,180,338,180,320,280,103,272,76,279,24,279,24,272,76,260,53,279,24,260,53,246,35,246,35,235,26,279,24,279,24,235,26,234,1,344,166,336,222,336,108,336,108,336,222,314,269,336,108,314,269,314,60,314,60,314,269,287,169,285,201,287,169,314,269,285,201,314,269,280,306,285,201,280,306,279,231,280,306,235,330,242,296,314,60,287,169,285,134,314,60,285,134,280,103,314,60,280,103,279,24,181,11,180,-6,234,1,81,24,74,166,46,61,223,19,234,1,235,26,130,25,180,-6,142,19, +352,0,352,9,333,12,320,17,312,25,308,37,307,55,307,274,308,293,312,307,320,315,333,319,352,321,352,331,9,331,9,321,28,319,41,315,49,307,53,294,54,274,54,61,53,39,49,25,42,16,29,12,9,9,9,0,148,0,148,9,129,12,117,17,109,25,105,38,104,56,104,296,105,303,107,307,111,310,116,312,238,312,245,311,251,310,254,306,256,301,256,62,255,41,252,26,244,17,232,12,212,9,212,0,8,331,8,321,27,319,39,315,46,307,49,294,50,276,50,39,47,25,40,16,27,12,8,9,8,0,148,0,148,9,128,12,114,16,106,24,102,37,101,56,101,146,109,145,115,145,122,144,136,144,164,145,188,147,208,153,225,161,243,175,253,185,260,197,266,210,270,225,271,240,270,254,267,268,262,280,255,291,246,300,231,310,213,319,191,325,166,329,137,331,16383,16383,101,295,101,302,103,307,106,310,111,312,118,313, +49,25,42,16,148,0,148,0,42,16,29,12,148,0,29,12,9,9,53,294,54,274,111,310,53,294,111,310,49,307,49,307,111,310,116,312,49,307,116,312,352,331,352,331,116,312,123,312,252,26,244,17,352,0,352,0,244,17,232,12,352,0,232,12,212,9,352,331,123,312,238,312,352,331,238,312,245,311,352,331,245,311,251,310,352,331,251,310,254,306,352,331,254,306,256,301,352,331,256,301,256,294,352,331,256,294,320,315,352,331,320,315,333,319,352,331,333,319,352,321,307,55,307,274,256,294,256,294,307,274,308,293,256,294,308,293,312,307,320,17,312,25,256,62,256,62,312,25,308,37,256,62,308,37,256,294,117,17,109,25,54,61,54,61,109,25,105,38,54,61,105,38,54,274,54,274,105,38,104,56,54,274,104,56,104,296,54,274,104,296,105,303,54,274,105,303,107,307,54,274,107,307,111,310,352,331,9,331,28,319,352,331,28,319,41,315,352,331,41,315,49,307,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,255,41,352,0,255,41,252,26,148,0,148,9,129,12,148,0,129,12,117,17,148,0,117,17,53,39,148,0,53,39,49,25,148,0,9,9,9,0,53,39,117,17,54,61,352,0,212,9,212,0,255,41,320,17,256,62,256,294,308,37,307,55,28,319,9,331,9,321,320,315,256,294,312,307, +8,331,8,321,27,319,39,315,46,307,49,294,50,276,50,39,47,25,40,16,27,12,8,9,8,0,148,0,148,9,128,12,114,16,106,24,102,37,101,56,101,146,109,145,115,145,122,144,136,144,164,145,188,147,208,153,225,161,243,175,253,185,260,197,266,210,270,225,271,240,270,254,267,268,262,280,255,291,246,300,231,310,213,319,191,325,166,329,137,331,16383,16383,101,295,101,302,103,307,106,310,111,312,118,313,155,310,182,302,202,288,213,266,217,238,213,213,202,192,185,177,162,167,132,164,120,164,114,165,108,165,101,166,300,102,289,102,283,82,275,66,264,56,249,49,229,47,74,47,193,184,86,312,190,312,214,310,234,305,248,294,259,276,266,251,278,251,278,331,15,331,15,324,148,162,15,7,15,0,286,0,296,246,293,331,12,331,8,246,21,246,28,274,37,292,50,303,70,309,97,310,127,310,127,61,126,39,123,25,115,16,101,12,80,9,80,0,226,0,226,9,205,11,192,16,183,23,179,36,178,55,178,310,208,310,235,309,254,303,268,292,277,274,284,246,352,329,345,332,338,334,332,335,320,335,289,330,259,315,232,290,211,258,198,218, +111,312,118,312,118,313,137,331,118,313,155,310,137,331,155,310,166,329,166,329,155,310,182,302,166,329,182,302,191,325,191,325,182,302,202,288,191,325,202,288,213,319,213,319,202,288,213,266,213,319,213,266,231,310,231,310,213,266,217,238,231,310,217,238,225,161,225,161,213,213,208,153,208,153,213,213,202,192,208,153,202,192,188,147,188,147,202,192,185,177,188,147,185,177,164,145,164,145,185,177,162,167,164,145,162,167,136,144,136,144,162,167,132,164,136,144,132,164,128,144,128,144,132,164,126,164,128,144,126,164,122,144,122,144,126,164,120,164,122,144,120,164,115,145,115,145,120,164,114,165,115,145,114,165,109,145,109,145,114,165,108,165,109,145,108,165,101,166,101,56,101,166,50,276,101,56,50,276,102,37,102,37,50,276,50,61,101,166,101,146,109,145,271,240,270,254,270,225,270,225,270,254,267,268,270,225,267,268,266,210,266,210,267,268,262,280,266,210,262,280,260,197,260,197,262,280,255,291,260,197,255,291,253,185,253,185,255,291,246,300,253,185,246,300,243,175,243,175,246,300,231,310,243,175,231,310,225,161,137,331,8,331,27,319,137,331,27,319,39,315,137,331,39,315,46,307,137,331,46,307,49,294,137,331,49,294,50,276,137,331,50,276,106,310,137,331,106,310,111,312,137,331,111,312,118,313,101,295,101,302,50,276,101,295,50,276,101,166,103,307,106,310,50,276,103,307,50,276,101,302,148,0,148,9,128,12,148,0,128,12,114,16,148,0,114,16,50,39,148,0,50,39,47,25,148,0,47,25,40,16,148,0,40,16,27,12,148,0,27,12,8,9,148,0,8,9,8,0,50,61,50,39,114,16,50,61,114,16,106,24,50,61,106,24,102,37,27,319,8,331,8,321,213,213,225,161,217,238,155,310,118,313,118,312, + + +300,102,289,102,283,82,275,66,264,56,249,49,229,47,74,47,193,184,86,312,190,312,214,310,234,305,248,294,259,276,266,251,278,251,278,331,15,331,15,324,148,162,15,7,15,0,286,0,296,246,293,331,12,331,8,246,21,246,28,274,37,292,50,303,70,309,97,310,127,310,127,61,126,39,123,25,115,16,101,12,80,9,80,0,226,0,226,9,205,11,192,16,183,23,179,36, +278,331,15,331,86,312,278,331,86,312,190,312,278,331,190,312,214,310,278,331,214,310,234,305,278,331,234,305,248,294,278,331,248,294,259,276,278,331,259,276,266,251,278,331,266,251,278,251,148,162,15,7,74,47,148,162,74,47,193,184,148,162,193,184,86,312,148,162,86,312,15,331,148,162,15,331,15,324,275,66,264,56,286,0,286,0,264,56,249,49,286,0,249,49,229,47,286,0,300,102,289,102,286,0,289,102,283,82,286,0,283,82,275,66,286,0,229,47,74,47,286,0,74,47,15,7,286,0,15,7,15,0, +296,246,293,331,12,331,8,246,21,246,28,274,37,292,50,303,70,309,97,310,127,310,127,61,126,39,123,25,115,16,101,12,80,9,80,0,226,0,226,9,205,11,192,16,183,23,179,36,178,55,178,310,208,310,235,309,254,303,268,292,277,274,284,246,352,329,345,332,338,334,332,335,320,335,289,330,259,315,232,290,211,258,198,218,196,218,186,260,169,293,146,318,117,332,81,337,67,336,53,332,39,327,26,319,15,311,18,303,25,305,33,308,41,310,49,311,55,312,84,306,109,289,130,257,146,211,157,147, +293,331,12,331,70,309,293,331,70,309,97,310,293,331,97,310,127,310,293,331,127,310,178,310,293,331,178,310,208,310,293,331,208,310,235,309,293,331,235,309,254,303,293,331,254,303,268,292,293,331,268,292,277,274,293,331,277,274,284,246,293,331,284,246,296,246,192,16,183,23,127,61,127,61,183,23,179,36,127,61,179,36,127,310,127,310,179,36,178,55,127,310,178,55,178,310,12,331,8,246,21,246,12,331,21,246,28,274,12,331,28,274,37,292,12,331,37,292,50,303,12,331,50,303,70,309,226,0,226,9,205,11,226,0,205,11,192,16,226,0,192,16,126,39,226,0,126,39,123,25,226,0,123,25,115,16,226,0,115,16,101,12,226,0,101,12,80,9,226,0,80,9,80,0,126,39,192,16,127,61, +352,329,345,332,338,334,332,335,320,335,289,330,259,315,232,290,211,258,198,218,196,218,186,260,169,293,146,318,117,332,81,337,67,336,53,332,39,327,26,319,15,311,18,303,25,305,33,308,41,310,49,311,55,312,84,306,109,289,130,257,146,211,157,147,157,61,156,39,153,25,144,16,130,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,152,215,204,233,251,261,288,296,313,335,322,342,322,348,320,352,320,216,290,217,301,221,310,230,316,245,320,267,321,267,331,114,331,114,321,136,320,151,317,160,311,164,302,165,290,165,280,122,276,82,263,49,241,26,209,17,165,23,128,39,97,67,72,106,57,156,51,165,51,165,42,163,29,157,20,146,14,132,10,114,9,114,0,267,0,267,9,248,11,234,15,224,20,218,29,216,43,216,51,228,51,264,56,300,69,332,91,355,123,364,165,355,209,332,241,298,263,258,276,216,280,16383,16383,215,262,250,256, +18,303,25,305,26,319,26,319,25,305,33,308,26,319,33,308,39,327,39,327,33,308,41,310,39,327,41,310,53,332,53,332,41,310,49,311,53,332,49,311,55,312,55,312,84,306,67,336,67,336,84,306,81,337,67,336,53,332,55,312,198,218,196,218,210,36,198,218,210,36,209,55,198,218,209,55,209,152,198,218,209,152,211,258,332,335,326,335,335,322,335,322,326,335,320,335,335,322,320,335,296,313,296,313,320,335,289,330,296,313,289,330,261,288,261,288,289,330,259,315,261,288,259,315,233,251,233,251,259,315,232,290,233,251,232,290,215,204,215,204,232,290,211,258,215,204,211,258,209,152,338,334,335,322,339,322,338,334,339,322,345,332,345,332,339,322,342,322,345,332,342,322,345,321,348,320,352,320,352,329,348,320,352,329,345,321,345,321,352,329,345,332,260,0,260,9,239,11,260,0,239,11,224,15,260,0,224,15,156,39,260,0,156,39,153,25,260,0,153,25,144,16,260,0,144,16,130,12,260,0,130,12,107,9,260,0,107,9,107,0,169,293,157,147,210,36,169,293,210,36,186,260,186,260,210,36,196,218,156,39,224,15,157,61,157,61,224,15,215,23,157,61,215,23,157,147,157,147,215,23,210,36,84,306,109,289,117,332,117,332,109,289,130,257,117,332,130,257,146,318,146,318,130,257,146,211,146,318,146,211,169,293,169,293,146,211,157,147,81,337,84,306,117,332,335,322,338,334,332,335,18,303,26,319,15,311, +216,290,217,301,221,310,230,316,245,320,267,321,267,331,114,331,114,321,136,320,151,317,160,311,164,302,165,290,165,280,122,276,82,263,49,241,26,209,17,165,23,128,39,97,67,72,106,57,156,51,165,51,165,42,163,29,157,20,146,14,132,10,114,9,114,0,267,0,267,9,248,11,234,15,224,20,218,29,216,43,216,51,228,51,264,56,300,69,332,91,355,123,364,165,355,209,332,241,298,263,258,276,216,280,16383,16383,215,262,250,256,276,240,295,216,306,188,310,159,304,128,290,103,268,85,243,74,215,70,16383,16383,166,70,133,75,107,88,88,107,76,132,72,159,76,189,89,216,109,240,135,256,166,262,352,0,352,9,338,12,327,16,317,22,307,32,296,46,200,184,272,272,289,292,303,305,316,314,331,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,263,301,260,296,257,290,251,282,243,272,188,202,166,234,151,255,139,272,131,286,126,297,124,306,125,312,128,316,133,319,139,320,147,321,161,321,161,331,11,331,11,321,29,319,44,312,59,299,78,276,103,242,156,164,78,66,58,42,43,26,31,17,19,12,5,9,5,0,121,0,121,9,106,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,100,57,109,70,169,145,217,74,226,60,233,48,238,38,241,31,242,25,241,20, +267,321,267,321,245,320,245,320,267,321,267,331,245,320,267,331,230,316,230,316,267,331,164,302,230,316,164,302,165,290,166,262,165,290,165,280,166,262,165,280,135,256,135,256,165,280,122,276,135,256,122,276,109,240,109,240,122,276,89,216,216,43,215,70,166,262,166,262,215,70,215,262,166,262,215,262,216,290,216,290,215,262,216,280,166,262,216,290,217,301,166,262,217,301,221,310,166,262,218,29,216,43,165,290,166,262,221,310,165,290,221,310,230,316,267,331,114,331,136,320,267,331,136,320,151,317,267,331,151,317,160,311,267,331,160,311,164,302,82,263,49,241,72,159,82,263,72,159,76,189,82,263,76,189,89,216,82,263,89,216,122,276,17,165,23,128,26,209,26,209,23,128,39,97,26,209,39,97,49,241,49,241,39,97,67,72,49,241,67,72,72,159,332,91,310,159,304,128,332,91,304,128,300,69,300,69,304,128,290,103,300,69,290,103,268,85,306,188,310,159,332,241,332,241,310,159,332,91,332,241,332,91,355,209,355,209,332,91,355,123,355,209,355,123,364,165,298,263,258,276,276,240,298,263,276,240,295,216,298,263,295,216,306,188,298,263,306,188,332,241,250,256,276,240,258,276,250,256,258,276,216,280,250,256,216,280,215,262,216,51,228,51,243,74,243,74,228,51,264,56,243,74,264,56,268,85,268,85,264,56,300,69,216,43,216,51,215,70,215,70,216,51,243,74,267,0,267,9,248,11,267,0,248,11,234,15,267,0,234,15,165,42,267,0,165,42,163,29,267,0,163,29,157,20,267,0,157,20,146,14,267,0,146,14,132,10,267,0,132,10,114,9,267,0,114,9,114,0,166,70,133,75,156,51,166,70,156,51,165,51,166,70,165,51,224,20,166,70,224,20,218,29,166,70,218,29,166,262,165,51,165,42,234,15,165,51,234,15,224,20,107,88,88,107,106,57,107,88,106,57,156,51,107,88,156,51,133,75,76,132,72,159,67,72,76,132,67,72,106,57,76,132,106,57,88,107,136,320,114,331,114,321, +352,0,352,9,338,12,327,16,317,22,307,32,296,46,200,184,272,272,289,292,303,305,316,314,331,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,263,301,260,296,257,290,251,282,243,272,188,202,166,234,151,255,139,272,131,286,126,297,124,306,125,312,128,316,133,319,139,320,147,321,161,321,161,331,11,331,11,321,29,319,44,312,59,299,78,276,103,242,156,164,78,66,58,42,43,26,31,17,19,12,5,9,5,0,121,0,121,9,106,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,100,57,109,70,169,145,217,74,226,60,233,48,238,38,241,31,242,25,241,20,238,16,233,14,226,12,217,11,204,9,204,0,362,345,332,341,310,328,295,309,287,284,285,254,283,226,278,198,267,175,248,159,218,153,212,153,212,281,214,299,221,311,232,318,246,321,263,321,263,331,110,331,110,321,128,321,142,317,152,310,159,299,161,281,161,153,156,153,125,159,106,175,95,198,90,226,89,254,86,284,78,309,64,328,42,341,11,345,11,335,21,330,28,320,32,308,34,295,35,283,34,274,34,265,33,256,33,247,32,238,39,199,59,170,87,150,122,139,161,135,161,62,160,40,156,25,147,16,132,12,110,9,110,0,263,0,263,9,244,11,229,14,220,22,214,35,212,55,212,135,251,139,286,150,314,170,333,199,340,238,340,256,339,265,339,295,341,308,345,320,352,330,362,335,358,0, +31,17,121,0,43,26,43,26,121,0,88,17,43,26,88,17,58,42,58,42,88,17,84,21,58,42,84,21,83,26,83,26,84,31,78,66,78,66,84,31,87,38,78,66,87,38,156,164,156,164,87,38,92,46,156,164,92,46,100,57,103,242,156,164,126,297,103,242,126,297,124,306,124,306,125,312,103,242,156,164,100,57,109,70,109,70,169,145,156,164,156,164,169,145,166,234,156,164,166,234,151,255,78,66,58,42,83,26,103,242,125,312,78,276,78,276,125,312,128,316,78,276,128,316,59,299,59,299,128,316,133,319,59,299,133,319,161,331,161,331,133,319,139,320,161,331,139,320,147,321,147,321,161,321,161,331,161,331,11,331,29,319,161,331,29,319,44,312,161,331,44,312,59,299,260,296,257,290,272,272,272,272,257,290,251,282,272,272,251,282,243,272,243,272,188,202,200,184,200,184,188,202,217,74,200,184,217,74,296,46,296,46,217,74,226,60,296,46,226,60,233,48,348,331,229,331,243,320,348,331,243,320,253,319,348,331,253,319,259,316,348,331,259,316,262,311,348,331,262,311,263,305,348,331,263,305,316,314,348,331,316,314,331,319,348,331,331,319,348,321,263,305,272,272,289,292,263,305,289,292,303,305,263,305,303,305,316,314,263,301,260,296,272,272,263,301,272,272,263,305,243,272,200,184,272,272,238,16,233,14,352,0,352,0,233,14,226,12,352,0,226,12,217,11,242,25,352,0,327,16,242,25,327,16,317,22,242,25,317,22,307,32,242,25,307,32,296,46,242,25,296,46,241,31,296,46,233,48,238,38,296,46,238,38,241,31,188,202,166,234,169,145,188,202,169,145,217,74,338,12,327,16,352,0,338,12,352,0,352,9,241,20,238,16,352,0,241,20,352,0,242,25,204,9,204,0,352,0,204,9,352,0,217,11,156,164,151,255,139,272,156,164,139,272,131,286,156,164,131,286,126,297,121,0,121,9,106,11,121,0,106,11,95,13,121,0,95,13,88,17,19,12,5,9,121,0,19,12,121,0,31,17,121,0,5,9,5,0,243,320,229,331,229,321,29,319,11,331,11,321, +362,345,332,341,310,328,295,309,287,284,285,254,283,226,278,198,267,175,248,159,218,153,212,153,212,281,214,299,221,311,232,318,246,321,263,321,263,331,110,331,110,321,128,321,142,317,152,310,159,299,161,281,161,153,156,153,125,159,106,175,95,198,90,226,89,254,86,284,78,309,64,328,42,341,11,345,11,335,21,330,28,320,32,308,34,295,35,283,34,274,34,265,33,256,33,247,32,238,39,199,59,170,87,150,122,139,161,135,161,62,160,40,156,25,147,16,132,12,110,9,110,0,263,0,263,9,244,11,229,14,220,22,214,35,212,55,212,135,251,139,286,150,314,170,333,199,340,238,340,256,339,265,339,295,341,308,345,320,352,330,362,335,358,0,358,84,345,84,343,71,339,61,333,53,325,49,314,47,237,47,238,66,275,80,305,100,327,126,341,159,345,199,338,242,318,280,285,310,241,331,186,338,130,330,86,309,53,277,33,239,26,199,31,159,44,126,65,100,95,80,132,66,133,47,58,47,46,48,38,52,32,59,28,70,27,85,15,85,15,0,158,0,153,80,129,93,110,114,96,140,87,170,84,200,88,235,100,268,120,295,149,313,186,320,222,314,250,298,271,273,284,239,289,200,285,168,276,138,261,112,242,92,218,80,214,0,158,411,157,419,153,426,148,432,141,435,133,436,125,435,118,432,113,426,110,420,108,412,109,404,113,397,118,392,125,388,132,387,140,388,148,392,153,397, +263,321,263,321,246,321,246,321,263,321,263,331,246,321,263,331,232,318,232,318,263,331,159,299,232,318,159,299,161,281,161,135,161,281,161,153,161,135,161,153,156,153,161,135,220,22,214,35,161,135,214,35,212,55,212,153,212,135,251,139,212,153,251,139,218,153,218,153,251,139,248,159,212,55,212,281,161,135,161,135,212,281,214,299,161,135,214,299,161,281,161,281,214,299,221,311,161,281,221,311,232,318,263,331,110,331,128,321,263,331,128,321,142,317,263,331,142,317,152,310,263,331,152,310,159,299,310,328,295,309,314,170,314,170,295,309,287,284,314,170,287,284,286,150,286,150,287,284,285,254,286,150,285,254,283,226,310,328,314,170,332,341,332,341,314,170,333,199,332,341,333,199,339,295,339,295,333,199,339,283,339,274,339,283,333,199,339,274,333,199,340,238,352,330,362,335,362,345,352,330,362,345,345,320,345,320,362,345,332,341,345,320,332,341,341,308,341,308,332,341,339,295,248,159,251,139,267,175,267,175,251,139,286,150,267,175,286,150,278,198,278,198,286,150,283,226,340,238,340,247,340,256,340,238,340,256,339,265,340,238,339,265,339,274,263,0,263,9,244,11,263,0,244,11,229,14,263,0,229,14,160,40,263,0,160,40,156,25,263,0,156,25,147,16,263,0,147,16,132,12,263,0,132,12,110,9,263,0,110,9,110,0,161,62,160,40,229,14,161,62,229,14,220,22,161,62,220,22,161,135,125,159,106,175,122,139,125,159,122,139,161,135,125,159,161,135,156,153,90,226,89,254,87,150,90,226,87,150,95,198,95,198,87,150,122,139,95,198,122,139,106,175,87,150,89,254,86,284,87,150,86,284,78,309,87,150,78,309,64,328,87,150,64,328,59,170,42,341,11,345,21,330,42,341,21,330,28,320,42,341,28,320,32,308,42,341,32,308,34,295,42,341,34,295,35,283,42,341,35,283,39,199,42,341,39,199,59,170,42,341,59,170,64,328,39,199,35,283,34,274,39,199,34,274,34,265,39,199,34,265,33,256,39,199,33,256,33,247,39,199,33,247,32,238,21,330,11,345,11,335,128,321,110,331,110,321, +358,0,358,84,345,84,343,71,339,61,333,53,325,49,314,47,237,47,238,66,275,80,305,100,327,126,341,159,345,199,338,242,318,280,285,310,241,331,186,338,130,330,86,309,53,277,33,239,26,199,31,159,44,126,65,100,95,80,132,66,133,47,58,47,46,48,38,52,32,59,28,70,27,85,15,85,15,0,158,0,153,80,129,93,110,114,96,140,87,170,84,200,88,235,100,268,120,295,149,313,186,320,222,314,250,298,271,273,284,239,289,200,285,168,276,138,261,112,242,92,218,80,214,0,158,411,157,419,153,426,148,432,141,435,133,436,125,435,118,432,113,426,110,420,108,412,109,404,113,397,118,392,125,388,132,387,140,388,148,392,153,397,157,404,158,411,16383,16383,59,411,57,419,54,426,48,432,41,435,33,436,26,435,19,432,14,426,10,420,9,412,10,404,14,397,19,392,25,388,33,387,41,388,48,392,54,397,57,404,59,411,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316, +58,47,46,48,158,0,158,0,46,48,38,52,158,0,38,52,15,0,15,0,38,52,32,59,15,0,32,59,15,85,15,85,32,59,28,70,15,85,28,70,27,85,26,199,31,159,33,239,33,239,31,159,44,126,33,239,44,126,53,277,53,277,44,126,65,100,53,277,65,100,86,309,86,309,65,100,84,200,95,80,84,200,65,100,186,338,149,313,186,320,186,320,222,314,241,331,241,331,222,314,250,298,241,331,250,298,285,310,285,310,250,298,271,273,285,310,271,273,284,239,289,200,305,100,318,280,318,280,305,100,327,126,318,280,327,126,338,242,338,242,327,126,341,159,338,242,341,159,345,199,285,310,284,239,289,200,285,310,289,200,318,280,241,331,186,338,186,320,261,112,275,80,276,138,276,138,275,80,305,100,276,138,305,100,285,168,285,168,305,100,289,200,214,0,237,47,218,80,218,80,237,47,238,66,218,80,238,66,242,92,242,92,238,66,275,80,242,92,275,80,261,112,339,61,333,53,358,0,358,0,333,53,325,49,358,0,325,49,314,47,358,0,358,84,345,84,358,0,345,84,343,71,358,0,343,71,339,61,237,47,214,0,358,0,237,47,358,0,314,47,130,330,86,309,100,268,130,330,100,268,120,295,130,330,120,295,149,313,130,330,149,313,186,338,86,309,84,200,88,235,86,309,88,235,100,268,132,66,133,47,153,80,132,66,153,80,129,93,132,66,129,93,110,114,132,66,110,114,96,140,132,66,96,140,95,80,87,170,84,200,95,80,87,170,95,80,96,140,133,47,58,47,158,0,133,47,158,0,153,80, +158,411,157,419,153,426,148,432,141,435,133,436,125,435,118,432,113,426,110,420,108,412,109,404,113,397,118,392,125,388,132,387,140,388,148,392,153,397,157,404,158,411,16383,16383,59,411,57,419,54,426,48,432,41,435,33,436,26,435,19,432,14,426,10,420,9,412,10,404,14,397,19,392,25,388,33,387,41,388,48,392,54,397,57,404,59,411,16383,16383,157,0,157,9,137,11,122,16,114,24,109,37,108,56,108,276,109,295,113,308,122,316,136,320,157,321,157,331,9,331,9,321,30,320,44,316,53,308,57,295,57,56,56,36,52,23,44,15,30,11,9,9,9,0,257,411,256,419,252,426,247,432,240,435,233,436,225,435,218,432,213,426,209,420,208,412,209,404,213,397,218,392,225,388,232,387,240,388,247,392,252,397,256,404,257,411,16383,16383,158,411,157,419,153,426,148,432,141,435,133,436,125,435,118,432,113,426,110,420,108,412,109,404,113,397,118,392,125,388,132,387,140,388,148,392,153,397,157,404,158,411,16383,16383,352,329,345,332,338,334,332,335,320,335,289,330,259,315,232,290,211,258,198,218,196,218,186,260,169,293,146,318,117,332,81,337,67,336,53,332,39,327,26,319,15,311,18,303,25,305,33,308,41,310,49,311,55,312, +9,412,10,404,10,420,10,420,10,404,14,397,10,420,14,397,14,426,14,426,14,397,19,392,14,426,19,392,19,432,19,432,19,392,25,388,19,432,25,388,26,435,26,435,25,388,33,387,26,435,33,387,33,436,33,436,33,387,41,388,33,436,41,388,41,435,41,435,41,388,48,392,41,435,48,392,48,432,48,432,48,392,54,397,48,432,54,397,54,426,54,426,54,397,57,404,54,426,57,404,57,419,57,419,57,404,59,411,52,23,44,15,157,0,157,0,44,15,30,11,157,0,30,11,9,9,157,331,9,331,30,320,157,331,30,320,44,316,157,331,44,316,53,308,157,331,53,308,57,295,157,331,57,295,122,316,157,331,122,316,136,320,157,331,136,320,157,321,122,16,114,24,57,56,57,56,114,24,109,37,57,56,109,37,57,276,57,276,109,37,108,56,57,276,108,56,108,276,57,276,108,276,109,295,57,276,109,295,113,308,57,276,113,308,122,316,57,276,122,316,57,295,108,412,109,404,110,420,110,420,109,404,113,397,110,420,113,397,113,426,113,426,113,397,118,392,113,426,118,392,118,432,118,432,118,392,125,388,118,432,125,388,125,435,125,435,125,388,132,387,125,435,132,387,133,436,133,436,132,387,140,388,133,436,140,388,141,435,141,435,140,388,148,392,141,435,148,392,148,432,148,432,148,392,153,397,148,432,153,397,153,426,153,426,153,397,157,404,153,426,157,404,157,419,157,419,157,404,158,411,157,0,157,9,137,11,157,0,137,11,122,16,157,0,122,16,56,36,157,0,56,36,52,23,157,0,9,9,9,0,56,36,122,16,57,56,30,320,9,331,9,321, +257,411,256,419,252,426,247,432,240,435,233,436,225,435,218,432,213,426,209,420,208,412,209,404,213,397,218,392,225,388,232,387,240,388,247,392,252,397,256,404,257,411,16383,16383,158,411,157,419,153,426,148,432,141,435,133,436,125,435,118,432,113,426,110,420,108,412,109,404,113,397,118,392,125,388,132,387,140,388,148,392,153,397,157,404,158,411,16383,16383,352,329,345,332,338,334,332,335,320,335,289,330,259,315,232,290,211,258,198,218,196,218,186,260,169,293,146,318,117,332,81,337,67,336,53,332,39,327,26,319,15,311,18,303,25,305,33,308,41,310,49,311,55,312,84,306,109,289,130,257,146,211,157,147,157,61,156,39,153,25,144,16,130,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,152,215,204,233,251,261,288,296,313,335,322,342,322,348,320,352,320,108,253,126,253,158,294,163,299,167,304,169,309,171,313,172,316,171,322,168,326,165,329,157,331,151,330,147,329,143,327,140,324,138,320,16383,16383,257,65,255,50,252,39,248,32,245,27,241,26,232,31,223,43,216,60,210,78,206,94,261,225,212,225,190,157,182,178,171,198,156,215,137,226,113,230,79,224,52,207,31,181,19,148,15,112,19,73,32,41,52,16,78,1,108,-4,129,-1,147,5,162,17,174,32,185,50,190,32,196,17,204,5,213,-1,225,-4,239,0,250,8,258,24,263,43,265,65,16383,16383,166,104,162,84,155,59,145,35,131,16,113,9,90,19,75,43,66,76,61,109,60,137,63,167,70,189,81,204,95,213,110,216,129,208,144,187,154,159,161,130,166,104,76,253,94,253,127,294,135,304,138,309,139,313,140,316,139,322,137,326,133,329,125,331,119,330,115,329,111,327,108,324, +18,303,25,305,26,319,26,319,25,305,33,308,26,319,33,308,39,327,39,327,33,308,41,310,39,327,41,310,53,332,53,332,41,310,49,311,53,332,49,311,55,312,55,312,84,306,67,336,67,336,84,306,81,337,67,336,53,332,55,312,198,218,196,218,210,36,198,218,210,36,209,55,198,218,209,55,209,152,198,218,209,152,211,258,260,0,260,9,239,11,260,0,239,11,224,15,260,0,224,15,156,39,260,0,156,39,153,25,260,0,153,25,144,16,260,0,144,16,130,12,260,0,130,12,107,9,260,0,107,9,107,0,169,293,157,147,210,36,169,293,210,36,186,260,186,260,210,36,196,218,156,39,224,15,157,61,157,61,224,15,215,23,157,61,215,23,157,147,157,147,215,23,210,36,332,335,326,335,335,322,335,322,326,335,320,335,335,322,320,335,296,313,296,313,320,335,289,330,296,313,289,330,261,288,261,288,289,330,259,315,261,288,259,315,233,251,233,251,259,315,232,290,233,251,232,290,215,204,215,204,232,290,211,258,215,204,211,258,209,152,338,334,335,322,339,322,338,334,339,322,345,332,345,332,339,322,342,322,345,332,342,322,345,321,348,320,352,320,352,329,348,320,352,329,345,321,345,321,352,329,345,332,208,412,209,404,209,420,209,420,209,404,213,397,209,420,213,397,213,426,213,426,213,397,218,392,213,426,218,392,218,432,218,432,218,392,225,388,218,432,225,388,225,435,225,435,225,388,232,387,225,435,232,387,233,436,233,436,232,387,240,388,233,436,240,388,240,435,240,435,240,388,247,392,240,435,247,392,247,432,247,432,247,392,252,397,247,432,252,397,252,426,252,426,252,397,256,404,252,426,256,404,256,419,256,419,256,404,257,411,108,412,109,404,110,420,110,420,109,404,113,397,110,420,113,397,113,426,113,426,113,397,118,392,113,426,118,392,118,432,118,432,118,392,125,388,118,432,125,388,125,435,125,435,125,388,132,387,125,435,132,387,133,436,133,436,132,387,140,388,133,436,140,388,141,435,141,435,140,388,148,392,141,435,148,392,148,432,148,432,148,392,153,397,148,432,153,397,153,426,153,426,153,397,157,404,153,426,157,404,157,419,157,419,157,404,158,411,84,306,109,289,117,332,117,332,109,289,130,257,117,332,130,257,146,318,146,318,130,257,146,211,146,318,146,211,169,293,169,293,146,211,157,147,81,337,84,306,117,332,335,322,338,334,332,335,18,303,26,319,15,311, +108,253,126,253,158,294,163,299,167,304,169,309,171,313,172,316,171,322,168,326,165,329,157,331,151,330,147,329,143,327,140,324,138,320,16383,16383,257,65,255,50,252,39,248,32,245,27,241,26,232,31,223,43,216,60,210,78,206,94,261,225,212,225,190,157,182,178,171,198,156,215,137,226,113,230,79,224,52,207,31,181,19,148,15,112,19,73,32,41,52,16,78,1,108,-4,129,-1,147,5,162,17,174,32,185,50,190,32,196,17,204,5,213,-1,225,-4,239,0,250,8,258,24,263,43,265,65,16383,16383,166,104,162,84,155,59,145,35,131,16,113,9,90,19,75,43,66,76,61,109,60,137,63,167,70,189,81,204,95,213,110,216,129,208,144,187,154,159,161,130,166,104,76,253,94,253,127,294,135,304,138,309,139,313,140,316,139,322,137,326,133,329,125,331,119,330,115,329,111,327,108,324,106,320,16383,16383,196,73,182,54,166,39,149,29,131,22,110,20,95,22,80,27,69,36,60,49,57,65,61,81,70,94,83,102,97,107,111,108,117,108,125,106,128,106,133,105,142,106,148,108,153,111,156,115,157,118,156,122,154,124,150,127,145,128,138,129,131,128,121,126,115,125,108,124,92,127,80,133,72,142,67,154,65,167,67,182,74,195,83,206,96,213,112,215,127,215,140,212,148,208,154,203,156,195,155,193,155,190,154,187,154,183,153,179,155,171,158,166,163,161,168,158,175,157,182,158,188,161,194,165,198,171,199,179,194,199,181,214,163,223, +63,167,70,189,79,224,79,224,70,189,81,204,79,224,81,204,113,230,113,230,81,204,95,213,113,230,95,213,110,216,110,216,129,208,113,230,113,230,129,208,137,226,157,331,158,294,161,330,161,330,158,294,163,299,161,330,163,299,165,329,165,329,163,299,167,304,165,329,167,304,168,326,168,326,167,304,169,309,168,326,169,309,171,322,171,322,169,309,171,313,171,322,171,313,172,316,158,294,157,331,151,330,158,294,151,330,147,329,158,294,147,329,143,327,158,294,143,327,140,324,158,294,140,324,138,320,158,294,138,320,126,253,144,187,154,159,156,215,156,215,154,159,161,130,156,215,161,130,171,198,171,198,161,130,166,104,171,198,166,104,174,32,171,198,174,32,182,178,182,178,174,32,185,50,182,178,185,50,190,157,190,157,185,50,190,32,190,157,190,32,212,225,212,225,190,32,196,17,212,225,196,17,206,94,206,94,196,17,204,5,206,94,204,5,213,-1,137,226,129,208,144,187,137,226,144,187,156,215,174,32,166,104,162,84,174,32,162,84,162,17,162,17,162,84,155,59,162,17,155,59,147,5,147,5,155,59,145,35,147,5,145,35,131,16,78,1,108,-4,90,19,90,19,108,-4,113,9,131,16,113,9,129,-1,131,16,129,-1,147,5,210,78,206,94,213,-1,212,225,206,94,261,225,252,39,248,32,250,8,250,8,248,32,245,27,250,8,245,27,241,26,241,26,232,31,239,0,239,0,232,31,225,-4,210,78,213,-1,216,60,216,60,213,-1,225,-4,216,60,225,-4,223,43,223,43,225,-4,232,31,258,24,263,43,265,65,258,24,265,65,257,65,258,24,257,65,255,50,258,24,255,50,252,39,258,24,252,39,250,8,241,26,239,0,250,8,113,9,108,-4,129,-1,90,19,75,43,78,1,78,1,75,43,66,76,78,1,66,76,52,16,52,16,66,76,61,109,52,16,61,109,60,137,60,137,63,167,52,207,52,207,63,167,79,224,52,16,60,137,52,207,52,16,52,207,32,41,32,41,52,207,31,181,32,41,31,181,19,73,19,73,31,181,19,148,19,73,19,148,15,112,126,253,138,320,108,253, +76,253,94,253,127,294,135,304,138,309,139,313,140,316,139,322,137,326,133,329,125,331,119,330,115,329,111,327,108,324,106,320,16383,16383,196,73,182,54,166,39,149,29,131,22,110,20,95,22,80,27,69,36,60,49,57,65,61,81,70,94,83,102,97,107,111,108,117,108,125,106,128,106,133,105,142,106,148,108,153,111,156,115,157,118,156,122,154,124,150,127,145,128,138,129,131,128,121,126,115,125,108,124,92,127,80,133,72,142,67,154,65,167,67,182,74,195,83,206,96,213,112,215,127,215,140,212,148,208,154,203,156,195,155,193,155,190,154,187,154,183,153,179,155,171,158,166,163,161,168,158,175,157,182,158,188,161,194,165,198,171,199,179,194,199,181,214,163,223,142,228,121,230,87,226,60,217,40,202,28,184,24,165,26,152,31,141,39,131,49,123,63,118,47,113,33,103,22,91,15,77,12,61,14,46,21,29,37,13,65,0,108,-4,130,-1,151,6,171,20,189,40,204,68,84,253,101,253,134,294,142,304,145,309,147,313,147,316,146,322,144,326,140,329,132,331,122,329,119,327,116,324,113,320,16383,16383,226,-107,223,-101,221,-94,219,-86,218,-76,218,160,216,182,208,202,196,217,180,226,159,230,145,229,131,224,117,216,102,205,87,190,86,190,84,205,81,215,76,223,68,226,56,228,44,225,33,216,22,203,13,188,5,172,12,170,15,176,25,188,30,193,36,194,39,193,41,190,44,184,45,173,46,156,46,0,88,0,88,174,100,185,111,194,120,199,130,202,140,203,153,201,163,195,170,185,174,172,176,154,176,-79,177,-89,179,-97,181,-103,184,-107,40,253,57,253,90,294,98,304,101,309,103,313,103,316,102,322,100,326,96,329,93,330,89,331,83,330,78,329,75,327,72,324,70,320,16383,16383,126,54,120,43,115,36,110,31,105,29,99,28,95,29,91,33,90,36,89,40,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,37,196,42,193,45,188, +37,13,65,0,47,113,47,113,65,0,57,65,63,118,57,65,61,81,63,118,61,81,70,94,72,142,67,154,70,94,70,94,67,154,65,167,63,118,65,167,60,217,63,118,60,217,49,123,49,123,60,217,40,202,49,123,40,202,39,131,39,131,40,202,31,141,142,228,121,230,127,215,127,215,121,230,112,215,96,213,112,215,121,230,96,213,121,230,87,226,125,331,127,294,129,330,129,330,127,294,131,299,129,330,131,299,133,329,133,329,131,299,135,304,133,329,135,304,137,326,137,326,135,304,138,309,137,326,138,309,139,322,139,322,138,309,139,313,139,322,139,313,140,316,127,294,125,331,119,330,127,294,119,330,115,329,127,294,115,329,111,327,127,294,111,327,108,324,127,294,108,324,106,320,127,294,106,320,94,253,194,199,181,214,182,158,194,199,182,158,188,161,194,199,188,161,194,165,194,199,194,165,198,171,194,199,198,171,199,179,158,166,163,161,163,223,163,223,163,161,168,158,163,223,168,158,181,214,181,214,168,158,175,157,181,214,175,157,182,158,127,215,140,212,142,228,142,228,140,212,148,208,142,228,148,208,163,223,163,223,148,208,154,203,163,223,154,203,156,195,156,195,158,166,163,223,156,195,155,193,158,166,158,166,155,193,155,190,158,166,155,190,155,171,155,171,155,190,154,187,155,171,154,187,154,183,87,226,60,217,67,182,87,226,67,182,74,195,87,226,74,195,83,206,87,226,83,206,96,213,67,182,60,217,65,167,28,184,24,165,26,152,28,184,26,152,31,141,28,184,31,141,40,202,83,102,97,107,92,127,92,127,97,107,108,124,115,125,108,124,111,108,83,102,92,127,80,133,83,102,80,133,72,142,83,102,72,142,70,94,63,118,70,94,65,167,111,108,108,124,97,107,117,108,121,107,121,126,121,126,121,107,125,106,121,126,125,106,126,127,126,127,125,106,128,106,126,127,128,106,131,128,131,128,128,106,133,105,131,128,133,105,138,129,138,129,133,105,142,106,138,129,142,106,145,128,145,128,142,106,148,108,145,128,148,108,150,127,150,127,148,108,153,111,150,127,153,111,154,124,154,124,153,111,156,115,154,124,156,115,156,122,156,122,156,115,157,118,115,125,111,108,117,108,115,125,117,108,121,126,80,27,108,-4,95,22,95,22,108,-4,110,20,131,22,110,20,130,-1,131,22,130,-1,151,6,69,36,60,49,65,0,69,36,65,0,108,-4,69,36,108,-4,80,27,57,65,65,0,60,49,12,61,14,46,15,77,15,77,14,46,21,29,15,77,21,29,22,91,22,91,21,29,37,13,22,91,37,13,33,103,33,103,37,13,47,113,204,68,196,73,189,40,189,40,196,73,182,54,189,40,182,54,171,20,171,20,182,54,166,39,171,20,166,39,151,6,151,6,166,39,149,29,151,6,149,29,131,22,110,20,108,-4,130,-1,47,113,57,65,63,118,155,171,154,183,153,179,94,253,106,320,76,253, +84,253,101,253,134,294,142,304,145,309,147,313,147,316,146,322,144,326,140,329,132,331,122,329,119,327,116,324,113,320,16383,16383,226,-107,223,-101,221,-94,219,-86,218,-76,218,160,216,182,208,202,196,217,180,226,159,230,145,229,131,224,117,216,102,205,87,190,86,190,84,205,81,215,76,223,68,226,56,228,44,225,33,216,22,203,13,188,5,172,12,170,15,176,25,188,30,193,36,194,39,193,41,190,44,184,45,173,46,156,46,0,88,0,88,174,100,185,111,194,120,199,130,202,140,203,153,201,163,195,170,185,174,172,176,154,176,-79,177,-89,179,-97,181,-103,184,-107,40,253,57,253,90,294,98,304,101,309,103,313,103,316,102,322,100,326,96,329,93,330,89,331,83,330,78,329,75,327,72,324,70,320,16383,16383,126,54,120,43,115,36,110,31,105,29,99,28,95,29,91,33,90,36,89,40,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,37,196,42,193,45,188,47,181,47,39,48,26,51,14,57,4,65,-2,77,-4,92,-1,105,7,116,20,126,35,133,50,202,278,201,286,197,293,192,298,185,302,177,303,169,302,163,298,157,293,154,286,152,278,154,271,157,264,163,258,169,255,177,253,185,255,192,258,197,264, +15,176,20,182,22,203,22,203,20,182,25,188,22,203,25,188,33,216,33,216,25,188,30,193,33,216,30,193,36,194,36,194,39,193,44,225,44,225,39,193,41,190,44,225,41,190,44,184,13,188,5,172,12,170,13,188,12,170,15,176,13,188,15,176,22,203,87,190,86,190,88,0,87,190,88,0,88,174,87,190,88,174,102,205,88,174,100,185,102,205,102,205,100,185,111,194,102,205,111,194,117,216,117,216,111,194,120,199,117,216,120,199,131,224,131,224,120,199,130,202,131,224,130,202,140,203,140,203,153,201,145,229,145,229,153,201,159,230,88,0,86,190,84,205,88,0,84,205,81,215,88,0,81,215,76,223,88,0,76,223,68,226,88,0,68,226,56,228,88,0,56,228,46,156,88,0,46,156,46,0,145,229,131,224,140,203,218,-65,218,160,216,182,218,-65,216,182,208,202,218,-65,208,202,218,-76,196,217,180,226,181,-103,196,217,181,-103,184,-107,196,217,184,-107,218,-76,196,217,218,-76,208,202,184,-107,226,-107,223,-101,184,-107,223,-101,221,-94,184,-107,221,-94,219,-86,184,-107,219,-86,218,-76,180,226,159,230,163,195,180,226,163,195,170,185,180,226,170,185,174,172,180,226,174,172,176,154,180,226,176,154,176,-79,180,226,176,-79,177,-89,180,226,177,-89,179,-97,180,226,179,-97,181,-103,176,154,176,-64,176,-79,132,331,134,294,136,330,136,330,134,294,138,299,136,330,138,299,140,329,140,329,138,299,142,304,140,329,142,304,144,326,144,326,142,304,145,309,144,326,145,309,146,322,146,322,145,309,147,313,146,322,147,313,147,316,134,294,132,331,127,330,134,294,127,330,122,329,134,294,122,329,119,327,134,294,119,327,116,324,134,294,116,324,113,320,134,294,113,320,101,253,45,173,46,156,56,228,45,173,56,228,44,225,45,173,44,225,44,184,44,225,33,216,36,194,101,253,113,320,84,253,159,230,153,201,163,195, +40,253,57,253,90,294,98,304,101,309,103,313,103,316,102,322,100,326,96,329,93,330,89,331,83,330,78,329,75,327,72,324,70,320,16383,16383,126,54,120,43,115,36,110,31,105,29,99,28,95,29,91,33,90,36,89,40,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,37,196,42,193,45,188,47,181,47,39,48,26,51,14,57,4,65,-2,77,-4,92,-1,105,7,116,20,126,35,133,50,202,278,201,286,197,293,192,298,185,302,177,303,169,302,163,298,157,293,154,286,152,278,154,271,157,264,163,258,169,255,177,253,185,255,192,258,197,264,201,271,202,278,16383,16383,100,253,118,253,151,294,159,304,162,309,163,313,164,316,163,322,161,326,157,329,149,331,143,330,139,329,135,327,132,324,130,320,16383,16383,103,278,101,286,98,293,92,298,85,302,78,303,70,302,63,298,58,293,54,286,53,278,54,271,58,264, +89,331,90,294,93,330,93,330,90,294,94,299,93,330,94,299,96,329,96,329,94,299,98,304,96,329,98,304,100,326,100,326,98,304,101,309,100,326,101,309,102,322,102,322,101,309,103,313,102,322,103,313,103,316,90,294,89,331,83,330,90,294,83,330,78,329,90,294,78,329,75,327,90,294,75,327,72,324,90,294,72,324,70,320,90,294,70,320,57,253,45,188,57,219,42,193,42,193,57,219,41,214,42,193,41,214,37,196,37,196,41,214,31,196,28,196,31,196,41,214,28,196,41,214,26,208,57,4,65,-2,72,224,72,224,65,-2,77,-4,72,224,77,-4,88,230,88,230,77,-4,89,40,88,230,89,40,89,228,91,33,92,-1,93,31,93,31,92,-1,105,7,93,31,105,7,95,29,95,29,105,7,99,28,105,29,99,28,105,7,105,29,105,7,116,20,133,50,126,54,126,35,126,35,126,54,120,43,126,35,120,43,116,20,116,20,120,43,115,36,116,20,115,36,110,31,92,-1,91,33,90,36,92,-1,90,36,89,40,92,-1,89,40,77,-4,57,219,45,188,47,181,57,219,47,181,47,172,57,219,47,172,48,26,57,219,48,26,51,14,57,219,51,14,57,4,57,219,57,4,72,224,47,172,47,39,48,26,26,208,10,204,15,196,26,208,15,196,20,196,26,208,20,196,24,196,26,208,24,196,28,196,15,196,10,204,10,195,105,29,116,20,110,31,57,253,70,320,40,253, +202,278,201,286,197,293,192,298,185,302,177,303,169,302,163,298,157,293,154,286,152,278,154,271,157,264,163,258,169,255,177,253,185,255,192,258,197,264,201,271,202,278,16383,16383,100,253,118,253,151,294,159,304,162,309,163,313,164,316,163,322,161,326,157,329,149,331,143,330,139,329,135,327,132,324,130,320,16383,16383,103,278,101,286,98,293,92,298,85,302,78,303,70,302,63,298,58,293,54,286,53,278,54,271,58,264,63,258,70,255,78,253,85,255,92,258,98,264,101,271,103,278,16383,16383,127,230,127,220,139,218,149,214,159,209,168,201,177,191,186,176,193,159,198,141,201,122,202,104,200,75,193,49,182,28,165,14,142,9,121,14,106,28,97,47,92,68,91,87,91,193,90,205,86,215,80,222,71,226,60,228,47,225,36,216,26,203,16,188,8,172,15,170,18,176,28,188,33,193,39,194,43,192,46,187,48,180,49,170,49,99,51,66,60,38,76,15,102,0,139,-4,174,1,204,18,227,43,242,75,247,113,241,155,226,188,202,211,173,225,141,230,257,65,255,50,252,39,248,32,245,27,241,26,232,31,223,43,216,60,210,78,206,94,261,225,212,225,190,157,182,178,171,198,156,215,137,226,113,230,79,224,52,207,31,181,19,148,15,112,19,73,32,41,52,16,78,1,108,-4,129,-1,147,5,162,17,174,32,185,50,190,32,196,17,204,5,213,-1,225,-4,239,0,250,8,258,24,263,43,265,65,16383,16383,166,104,162,84,155,59,145,35,131,16,113,9,90,19,75,43,66,76,61,109,60,137,63,167,70,189,81,204,95,213,110,216,129,208,144,187,154,159,161,130,166,104,172,200,181,204,190,209,196,215,202,222,206,229,209,236,211,244,213,251,213,257,214,264,209,289,197,311,179,327,157,338,133,342,102,337,76,322,54,293,41,249,36,186,36,-67,34,-85,30,-101,27,-107,70,-107,72,-102,74,-95,76,-87,78,-67,78,16,88,7,98,1,108,-2,119,-3,131,-4,164,2,192,19,214,46,228,78,233,114,231,137,223,158,211,176,194,190,173,199,16383,16383,78,243,78,250,79,276,85,297,95,314,108,324, +18,176,23,182,26,203,26,203,23,182,28,188,26,203,28,188,36,216,36,216,28,188,33,193,36,216,33,193,39,194,39,194,43,192,47,225,47,225,43,192,46,187,47,225,46,187,48,180,16,188,8,172,15,170,16,188,15,170,18,176,16,188,18,176,26,203,49,99,51,66,49,159,49,170,49,159,60,228,49,170,60,228,48,180,48,180,60,228,47,225,54,286,54,271,58,293,58,293,54,271,58,264,58,293,58,264,63,298,63,298,58,264,63,258,63,298,63,258,70,302,70,302,63,258,70,255,70,302,70,255,78,303,78,303,70,255,78,253,78,303,78,253,85,302,85,302,78,253,85,255,85,302,85,255,92,298,92,298,85,255,92,258,92,298,92,258,98,293,98,293,92,258,98,264,98,293,98,264,101,286,101,286,98,264,101,271,101,286,101,271,103,278,91,87,91,193,90,205,91,87,90,205,86,215,91,87,86,215,80,222,91,87,80,222,92,68,141,230,127,230,139,218,141,230,139,218,149,214,141,230,149,214,173,225,200,75,193,49,204,18,204,18,193,49,182,28,204,18,182,28,174,1,174,1,182,28,165,14,174,1,165,14,142,9,142,9,121,14,139,-4,139,-4,121,14,106,28,139,-4,106,28,102,0,102,0,106,28,97,47,102,0,97,47,92,68,76,15,102,0,92,68,76,15,92,68,80,222,76,15,80,222,71,226,76,15,71,226,60,228,76,15,60,228,60,38,60,228,49,159,51,66,60,228,51,66,60,38,47,225,36,216,39,194,149,214,159,209,173,225,173,225,159,209,168,201,173,225,168,201,177,191,177,191,186,176,202,211,202,211,186,176,193,159,202,211,193,159,198,141,202,211,202,104,204,18,202,211,204,18,226,188,226,188,204,18,227,43,226,188,227,43,241,155,241,155,227,43,242,75,241,155,242,75,247,113,202,211,198,141,201,122,202,211,201,122,202,104,202,211,173,225,177,191,142,9,139,-4,174,1,154,286,154,271,157,293,157,293,154,271,157,264,157,293,157,264,163,298,163,298,157,264,163,258,163,298,163,258,169,302,169,302,163,258,169,255,169,302,169,255,177,303,177,303,169,255,177,253,177,303,177,253,185,302,185,302,177,253,185,255,185,302,185,255,192,298,192,298,185,255,192,258,192,298,192,258,197,293,197,293,192,258,197,264,197,293,197,264,201,286,201,286,197,264,201,271,201,286,201,271,202,278,149,331,151,294,153,330,153,330,151,294,155,299,153,330,155,299,157,329,157,329,155,299,159,304,157,329,159,304,161,326,161,326,159,304,162,309,161,326,162,309,163,322,163,322,162,309,163,313,163,322,163,313,164,316,151,294,149,331,143,330,151,294,143,330,139,329,151,294,139,329,135,327,151,294,135,327,132,324,151,294,132,324,130,320,151,294,130,320,118,253,118,253,130,320,100,253,154,271,154,286,152,278,200,75,204,18,202,104,139,218,127,230,127,220,54,271,54,286,53,278, +257,65,255,50,252,39,248,32,245,27,241,26,232,31,223,43,216,60,210,78,206,94,261,225,212,225,190,157,182,178,171,198,156,215,137,226,113,230,79,224,52,207,31,181,19,148,15,112,19,73,32,41,52,16,78,1,108,-4,129,-1,147,5,162,17,174,32,185,50,190,32,196,17,204,5,213,-1,225,-4,239,0,250,8,258,24,263,43,265,65,16383,16383,166,104,162,84,155,59,145,35,131,16,113,9,90,19,75,43,66,76,61,109,60,137,63,167,70,189,81,204,95,213,110,216,129,208,144,187,154,159,161,130,166,104,172,200,181,204,190,209,196,215,202,222,206,229,209,236,211,244,213,251,213,257,214,264,209,289,197,311,179,327,157,338,133,342,102,337,76,322,54,293,41,249,36,186,36,-67,34,-85,30,-101,27,-107,70,-107,72,-102,74,-95,76,-87,78,-67,78,16,88,7,98,1,108,-2,119,-3,131,-4,164,2,192,19,214,46,228,78,233,114,231,137,223,158,211,176,194,190,173,199,16383,16383,78,243,78,250,79,276,85,297,95,314,108,324,124,328,144,322,158,309,167,290,172,268,173,247,172,235,170,225,166,215,160,209,152,206,147,207,141,208, +63,167,70,189,79,224,79,224,70,189,81,204,79,224,81,204,113,230,113,230,81,204,95,213,113,230,95,213,110,216,110,216,129,208,113,230,113,230,129,208,137,226,144,187,154,159,156,215,156,215,154,159,161,130,156,215,161,130,171,198,171,198,161,130,166,104,171,198,166,104,174,32,171,198,174,32,182,178,182,178,174,32,185,50,182,178,185,50,190,157,190,157,185,50,190,32,190,157,190,32,212,225,212,225,190,32,196,17,212,225,196,17,206,94,206,94,196,17,204,5,206,94,204,5,213,-1,137,226,129,208,144,187,137,226,144,187,156,215,174,32,166,104,162,84,174,32,162,84,162,17,162,17,162,84,155,59,162,17,155,59,147,5,147,5,155,59,145,35,147,5,145,35,131,16,78,1,108,-4,90,19,90,19,108,-4,113,9,131,16,113,9,129,-1,131,16,129,-1,147,5,210,78,206,94,213,-1,212,225,206,94,261,225,252,39,248,32,250,8,250,8,248,32,245,27,250,8,245,27,241,26,241,26,232,31,239,0,239,0,232,31,225,-4,210,78,213,-1,216,60,216,60,213,-1,225,-4,216,60,225,-4,223,43,223,43,225,-4,232,31,258,24,263,43,265,65,258,24,265,65,257,65,258,24,257,65,255,50,258,24,255,50,252,39,258,24,252,39,250,8,241,26,239,0,250,8,113,9,108,-4,129,-1,90,19,75,43,78,1,78,1,75,43,66,76,78,1,66,76,52,16,52,16,66,76,61,109,52,16,61,109,60,137,60,137,63,167,52,207,52,207,63,167,79,224,52,16,60,137,52,207,52,16,52,207,32,41,32,41,52,207,31,181,32,41,31,181,19,73,19,73,31,181,19,148,19,73,19,148,15,112, +172,200,181,204,190,209,196,215,202,222,206,229,209,236,211,244,213,251,213,257,214,264,209,289,197,311,179,327,157,338,133,342,102,337,76,322,54,293,41,249,36,186,36,-67,34,-85,30,-101,27,-107,70,-107,72,-102,74,-95,76,-87,78,-67,78,16,88,7,98,1,108,-2,119,-3,131,-4,164,2,192,19,214,46,228,78,233,114,231,137,223,158,211,176,194,190,173,199,16383,16383,78,243,78,250,79,276,85,297,95,314,108,324,124,328,144,322,158,309,167,290,172,268,173,247,172,235,170,225,166,215,160,209,152,206,147,207,141,208,136,209,130,210,118,210,112,208,108,206,106,203,105,200,106,195,109,192,113,189,118,188,125,187,130,187,142,190,148,190,158,187,169,178,179,162,187,136,190,101,187,72,179,47,167,28,150,16,129,11,114,13,100,19,88,26,80,35,78,45,222,225,172,225,120,49,115,84,108,130,97,177,78,214,49,228,32,224,20,212,12,195,7,173,5,150,12,150,16,166,21,178,28,187,35,192,41,194,66,179,84,143,96,96,103,50,107,18,103,9,100,0,96,-7,90,-25,84,-47,82,-57,81,-66,81,-74,82,-85,85,-94,90,-101,96,-106,105,-108,118,-105,127,-98,133,-87,135,-73,136,-58,136,-45,135,-32,133,-19,131,-8,129,0,110,213,77,203,50,187,31,164,19,137,15,108,20,74,34,44,56,18,86,1,123,-4,161,1,192,17,215,43,230,76,235,116,232,141,225,164,213,184,197,202,176,217,145,233,114,248,87,261,68,274,61,290,64,302,72,310,83,316,95,319,106,320,137,316,154,307,165,296,176,286,191,282,198,284,203,288,206,293,208,299,209,304,203,318,188,328,168,336,145,340,124,342,102,340,81,334,61,324, +108,324,124,328,124,328,133,342,124,328,144,322,133,342,144,322,157,338,157,338,144,322,158,309,157,338,158,309,179,327,179,327,158,309,167,290,179,327,167,290,172,268,172,200,181,204,172,235,172,200,172,235,170,225,172,200,170,225,169,178,172,200,169,178,179,162,172,200,179,162,173,199,233,114,231,137,228,78,228,78,231,137,223,158,228,78,223,158,214,46,214,46,223,158,211,176,214,46,211,176,194,190,192,19,214,46,194,190,192,19,194,190,190,101,192,19,190,101,187,72,192,19,187,72,179,47,192,19,179,47,167,28,192,19,167,28,164,2,194,190,173,199,179,162,194,190,179,162,187,136,194,190,187,136,190,101,170,225,166,215,169,178,169,178,166,215,160,209,169,178,160,209,158,187,158,187,160,209,152,206,129,11,131,-4,150,16,150,16,131,-4,164,2,150,16,164,2,167,28,85,297,95,314,102,337,102,337,95,314,108,324,102,337,108,324,133,342,133,342,108,324,124,328,78,250,79,276,76,322,78,250,76,322,76,-87,78,250,76,-87,77,-77,78,250,77,-77,78,-67,76,322,79,276,85,297,76,322,85,297,102,337,76,322,54,293,70,-107,76,322,70,-107,72,-102,76,322,72,-102,74,-95,76,322,74,-95,76,-87,70,-107,54,293,41,249,70,-107,41,249,36,186,70,-107,36,186,36,-67,70,-107,36,-67,35,-76,70,-107,35,-76,34,-85,70,-107,34,-85,32,-93,70,-107,32,-93,30,-101,70,-107,30,-101,27,-107,114,13,100,19,108,-2,114,13,108,-2,119,-3,114,13,119,-3,129,11,108,-2,100,19,98,1,98,1,100,19,88,26,98,1,88,26,88,7,88,7,88,26,80,35,88,7,80,35,78,45,78,45,78,16,88,7,148,190,152,206,147,207,148,190,147,207,142,190,118,188,125,187,127,210,127,210,125,187,130,187,127,210,130,187,130,210,130,210,130,187,134,188,130,210,134,188,136,209,136,209,134,188,138,189,136,209,138,189,141,208,141,208,138,189,142,190,141,208,142,190,147,207,106,203,106,195,108,206,108,206,106,195,109,192,108,206,109,192,112,208,112,208,109,192,113,189,112,208,113,189,118,210,118,210,113,189,118,188,118,210,118,188,127,210,173,247,181,204,179,327,173,247,179,327,172,268,206,229,209,236,209,289,209,289,209,236,211,244,209,289,211,244,214,264,214,264,211,244,213,251,214,264,213,251,213,257,190,209,196,215,197,311,197,311,196,215,202,222,197,311,202,222,209,289,209,289,202,222,206,229,197,311,179,327,181,204,197,311,181,204,190,209,172,235,181,204,173,247,148,190,158,187,152,206,131,-4,129,11,119,-3,106,195,106,203,105,200, +222,225,172,225,120,49,115,84,108,130,97,177,78,214,49,228,32,224,20,212,12,195,7,173,5,150,12,150,16,166,21,178,28,187,35,192,41,194,66,179,84,143,96,96,103,50,107,18,103,9,100,0,96,-7,90,-25,84,-47,82,-57,81,-66,81,-74,82,-85,85,-94,90,-101,96,-106,105,-108,118,-105,127,-98,133,-87,135,-73,136,-58,136,-45,135,-32,133,-19,131,-8,129,0,110,213,77,203,50,187,31,164,19,137,15,108,20,74,34,44,56,18,86,1,123,-4,161,1,192,17,215,43,230,76,235,116,232,141,225,164,213,184,197,202,176,217,145,233,114,248,87,261,68,274,61,290,64,302,72,310,83,316,95,319,106,320,137,316,154,307,165,296,176,286,191,282,198,284,203,288,206,293,208,299,209,304,203,318,188,328,168,336,145,340,124,342,102,340, +35,192,41,194,41,194,49,228,41,194,66,179,49,228,66,179,78,214,78,214,66,179,84,143,78,214,84,143,97,177,97,177,84,143,96,96,97,177,96,96,103,50,120,49,115,84,118,-105,118,-105,115,84,108,130,118,-105,108,130,107,18,107,18,108,130,103,50,103,50,108,130,97,177,118,-105,127,-98,120,49,120,49,127,-98,129,0,120,49,129,0,172,225,172,225,129,0,222,225,107,18,103,9,105,-108,107,18,105,-108,118,-105,100,0,96,-7,96,-106,100,0,96,-106,105,-108,100,0,105,-108,103,9,96,-7,93,-16,96,-106,96,-106,93,-16,90,-25,96,-106,90,-25,90,-101,90,-101,90,-25,87,-36,90,-101,87,-36,85,-94,85,-94,87,-36,84,-47,85,-94,84,-47,82,-57,82,-85,85,-94,82,-57,82,-85,82,-57,81,-66,82,-85,81,-66,81,-74,135,-73,136,-58,136,-45,135,-73,136,-45,135,-32,135,-73,135,-32,133,-19,135,-73,133,-19,133,-87,133,-87,133,-19,131,-8,133,-87,131,-8,129,0,133,-87,129,0,127,-98,21,178,28,187,32,224,32,224,28,187,35,192,32,224,35,192,49,228,49,228,35,192,41,194,20,212,12,195,12,150,20,212,12,150,16,166,20,212,16,166,21,178,20,212,21,178,32,224,7,173,5,150,12,150,7,173,12,150,12,195, +110,213,77,203,50,187,31,164,19,137,15,108,20,74,34,44,56,18,86,1,123,-4,161,1,192,17,215,43,230,76,235,116,232,141,225,164,213,184,197,202,176,217,145,233,114,248,87,261,68,274,61,290,64,302,72,310,83,316,95,319,106,320,137,316,154,307,165,296,176,286,191,282,198,284,203,288,206,293,208,299,209,304,203,318,188,328,168,336,145,340,124,342,102,340,81,334,61,324,47,309,42,289,45,269,54,251,68,237,87,224,110,213,16383,16383,190,104,187,71,180,45,168,25,151,13,130,9,121,10,111,13,101,19,93,26,85,35,76,52,69,70,64,88,61,106,60,121,62,144,70,165,84,183,103,195,127,200,149,190,167,172,179,149,187,126,190,104,196,73,182,54,166,39,149,29,131,22,110,20,95,22,80,27,69,36,60,49,57,65,61,81,70,94,83,102,97,107,111,108,117,108,125,106,128,106,133,105,142,106,148,108,153,111,156,115,157,118,156,122,154,124,150,127,145,128,138,129,131,128,121,126,115,125,108,124,92,127,80,133,72,142,67,154,65,167,67,182,74,195,83,206,96,213,112,215,127,215,140,212,148,208,154,203,156,195,155,193,155,190,154,187,154,183,153,179,155,171,158,166,163,161,168,158,175,157,182,158,188,161,194,165,198,171,199,179,194,199,181,214,163,223,142,228,121,230,87,226,60,217,40,202,28,184,24,165,26,152,31,141,39,131,49,123,63,118,47,113,33,103,22,91,15,77, +42,289,45,269,47,309,47,309,45,269,54,251,47,309,54,251,61,324,61,324,54,251,61,290,68,237,61,290,54,251,64,302,72,310,81,334,81,334,72,310,83,316,81,334,83,316,102,340,102,340,83,316,95,319,102,340,95,319,106,320,106,320,137,316,124,342,124,342,137,316,145,340,61,324,61,290,64,302,61,324,64,302,81,334,198,284,203,288,203,318,203,318,203,288,206,293,203,318,206,293,209,304,209,304,206,293,208,299,154,307,165,296,168,336,168,336,165,296,176,286,168,336,176,286,188,328,188,328,176,286,191,282,188,328,191,282,203,318,203,318,191,282,198,284,145,340,137,316,154,307,145,340,154,307,168,336,235,116,232,141,230,76,230,76,232,141,225,164,230,76,225,164,215,43,215,43,225,164,213,184,215,43,213,184,197,202,192,17,215,43,197,202,192,17,197,202,190,104,192,17,190,104,187,71,192,17,187,71,180,45,192,17,180,45,168,25,192,17,168,25,161,1,197,202,176,217,179,149,197,202,179,149,187,126,197,202,187,126,190,104,145,233,127,200,149,190,145,233,149,190,176,217,176,217,149,190,167,172,176,217,167,172,179,149,111,13,123,-4,121,10,121,10,123,-4,130,9,151,13,130,9,161,1,151,13,161,1,168,25,130,9,123,-4,161,1,124,342,102,340,106,320,69,70,86,1,76,52,76,52,86,1,85,35,93,26,85,35,86,1,93,26,86,1,123,-4,68,274,68,237,87,261,87,261,68,237,87,224,87,261,87,224,114,248,114,248,87,224,110,213,114,248,110,213,127,200,62,144,70,165,77,203,77,203,70,165,84,183,77,203,84,183,110,213,110,213,84,183,103,195,110,213,103,195,127,200,77,203,50,187,62,144,62,144,50,187,60,121,61,106,60,121,56,18,61,106,56,18,64,88,64,88,56,18,86,1,64,88,86,1,69,70,56,18,60,121,50,187,56,18,50,187,34,44,34,44,50,187,31,164,34,44,31,164,20,74,20,74,31,164,19,137,20,74,19,137,15,108,101,19,93,26,123,-4,101,19,123,-4,111,13,61,290,68,237,68,274,127,200,145,233,114,248, +196,73,182,54,166,39,149,29,131,22,110,20,95,22,80,27,69,36,60,49,57,65,61,81,70,94,83,102,97,107,111,108,117,108,125,106,128,106,133,105,142,106,148,108,153,111,156,115,157,118,156,122,154,124,150,127,145,128,138,129,131,128,121,126,115,125,108,124,92,127,80,133,72,142,67,154,65,167,67,182,74,195,83,206,96,213,112,215,127,215,140,212,148,208,154,203,156,195,155,193,155,190,154,187,154,183,153,179,155,171,158,166,163,161,168,158,175,157,182,158,188,161,194,165,198,171,199,179,194,199,181,214,163,223,142,228,121,230,87,226,60,217,40,202,28,184,24,165,26,152,31,141,39,131,49,123,63,118,47,113,33,103,22,91,15,77,12,61,14,46,21,29,37,13,65,0,108,-4,130,-1,151,6,171,20,189,40,204,68,76,342,59,335,45,327,35,318,29,308,27,296,30,283,38,272,48,265,60,260,71,259,72,257,52,225,36,196,25,166,19,135,17,100,21,58,33,28,49,9,71,-1,95,-4,105,-4,117,-2,128,-1,137,0,143,0,158,-1,170,-5,180,-12,186,-22,188,-34,186,-47,180,-58,170,-67,159,-72,147,-74,140,-72,134,-69,128,-64,123,-61,117,-59,110,-60,104,-63,99,-68,97,-73,96,-80,98,-90,103,-98,111,-103,121,-107,132,-108,151,-104,170,-93,187,-76,199,-55,204,-29,201,-3,192,16,177,30,156,38,128,41,117,41,113,40,103,40,78,44,61,55,49,72,43,93,41,117,44,151,53,184,65,213,80,238,94,257,119,262,142,271,161,283,174,297,179,311,178,316,175,321,171,325,166,327,159,328,142,325,125,315,108,302,94,287,84,273,74,274,65,277,57,281,52,288, +37,13,65,0,47,113,47,113,65,0,57,65,63,118,57,65,61,81,63,118,61,81,70,94,72,142,67,154,70,94,70,94,67,154,65,167,63,118,65,167,60,217,63,118,60,217,49,123,49,123,60,217,40,202,49,123,40,202,39,131,39,131,40,202,31,141,142,228,121,230,127,215,127,215,121,230,112,215,96,213,112,215,121,230,96,213,121,230,87,226,194,199,181,214,182,158,194,199,182,158,188,161,194,199,188,161,194,165,194,199,194,165,198,171,194,199,198,171,199,179,158,166,163,161,163,223,163,223,163,161,168,158,163,223,168,158,181,214,181,214,168,158,175,157,181,214,175,157,182,158,127,215,140,212,142,228,142,228,140,212,148,208,142,228,148,208,163,223,163,223,148,208,154,203,163,223,154,203,156,195,156,195,158,166,163,223,156,195,155,193,158,166,158,166,155,193,155,190,158,166,155,190,155,171,155,171,155,190,154,187,155,171,154,187,154,183,87,226,60,217,67,182,87,226,67,182,74,195,87,226,74,195,83,206,87,226,83,206,96,213,67,182,60,217,65,167,28,184,24,165,26,152,28,184,26,152,31,141,28,184,31,141,40,202,83,102,97,107,92,127,92,127,97,107,108,124,115,125,108,124,111,108,83,102,92,127,80,133,83,102,80,133,72,142,83,102,72,142,70,94,63,118,70,94,65,167,111,108,108,124,97,107,117,108,121,107,121,126,121,126,121,107,125,106,121,126,125,106,126,127,126,127,125,106,128,106,126,127,128,106,131,128,131,128,128,106,133,105,131,128,133,105,138,129,138,129,133,105,142,106,138,129,142,106,145,128,145,128,142,106,148,108,145,128,148,108,150,127,150,127,148,108,153,111,150,127,153,111,154,124,154,124,153,111,156,115,154,124,156,115,156,122,156,122,156,115,157,118,115,125,111,108,117,108,115,125,117,108,121,126,80,27,108,-4,95,22,95,22,108,-4,110,20,131,22,110,20,130,-1,131,22,130,-1,151,6,69,36,60,49,65,0,69,36,65,0,108,-4,69,36,108,-4,80,27,57,65,65,0,60,49,12,61,14,46,15,77,15,77,14,46,21,29,15,77,21,29,22,91,22,91,21,29,37,13,22,91,37,13,33,103,33,103,37,13,47,113,204,68,196,73,189,40,189,40,196,73,182,54,189,40,182,54,171,20,171,20,182,54,166,39,171,20,166,39,151,6,151,6,166,39,149,29,151,6,149,29,131,22,110,20,108,-4,130,-1,47,113,57,65,63,118,155,171,154,183,153,179, +76,342,59,335,45,327,35,318,29,308,27,296,30,283,38,272,48,265,60,260,71,259,72,257,52,225,36,196,25,166,19,135,17,100,21,58,33,28,49,9,71,-1,95,-4,105,-4,117,-2,128,-1,137,0,143,0,158,-1,170,-5,180,-12,186,-22,188,-34,186,-47,180,-58,170,-67,159,-72,147,-74,140,-72,134,-69,128,-64,123,-61,117,-59,110,-60,104,-63,99,-68,97,-73,96,-80,98,-90,103,-98,111,-103,121,-107,132,-108,151,-104,170,-93,187,-76,199,-55,204,-29,201,-3,192,16,177,30,156,38,128,41,117,41,113,40,103,40,78,44,61,55,49,72,43,93,41,117,44,151,53,184,65,213,80,238,94,257,119,262,142,271,161,283,174,297,179,311,178,316,175,321,171,325,166,327,159,328,142,325,125,315,108,302,94,287,84,273,74,274,65,277,57,281,52,288,50,298,51,305,55,312,61,320,70,328,81,334,226,-107,223,-101,221,-94,219,-86,218,-76,218,160,216,182,208,202,196,217,180,226,159,230,145,229,131,224,117,216,102,205,87,190,86,190,84,205,81,215,76,223,68,226,56,228,44,225,33,216,22,203,13,188,5,172,12,170,15,176,25,188,30,193,36,194,39,193,41,190,44,184,45,173,46,156,46,0,88,0,88,174,100,185,111,194,120,199,130,202,140,203,153,201,163,195,170,185,174,172,176,154,176,-79,177,-89,179,-97,181,-103,184,-107,234,166,233,198,230,228,226,254,220,277,211,296,199,313,185,325,169,334,150,340,126,342,87,333,55,310,32,273,18,226,13,170,14,144,15,120,18,100,23,81,28,64,40,41,55,21,74,7,96,-1,122,-4,161,3,192,27,215,63,229,110,234,166,16383,16383,59,177,59,193,62,247,70,285,83,310,99,324,119,328,150,318,171,292,182,256,188,216,189,177,16383,16383, +43,93,41,117,41,117,36,196,41,117,44,151,36,196,44,151,52,225,52,225,44,151,53,184,52,225,53,184,72,257,72,257,53,184,65,213,72,257,65,213,80,238,48,265,50,298,45,327,48,265,45,327,38,272,38,272,45,327,35,318,38,272,35,318,30,283,30,283,35,318,29,308,30,283,29,308,27,296,51,305,55,312,59,335,59,335,55,312,61,320,59,335,61,320,76,342,76,342,61,320,70,328,76,342,70,328,81,334,51,305,59,335,45,327,51,305,45,327,50,298,108,302,94,287,94,257,94,257,94,287,84,273,94,257,84,273,80,238,80,238,84,273,74,274,80,238,74,274,72,257,72,257,74,274,71,259,166,327,159,328,161,283,161,283,159,328,142,325,161,283,142,325,142,271,142,271,142,325,125,315,142,271,125,315,119,262,119,262,125,315,108,302,119,262,108,302,94,257,65,277,57,281,60,260,65,277,60,260,71,259,65,277,71,259,74,274,52,288,50,298,48,265,52,288,48,265,60,260,52,288,60,260,57,281,71,-1,95,-4,78,44,78,44,95,-4,103,40,108,40,103,40,105,-4,108,40,105,-4,117,-2,61,55,49,72,49,9,61,55,49,9,71,-1,61,55,71,-1,78,44,43,93,41,117,33,28,43,93,33,28,49,9,43,93,49,9,49,72,41,117,36,196,33,28,33,28,36,196,25,166,33,28,25,166,21,58,21,58,25,166,19,135,21,58,19,135,17,100,177,30,156,38,158,-1,158,-1,156,38,143,0,137,0,143,0,156,38,137,0,156,38,128,41,128,-1,137,0,128,41,128,-1,128,41,123,41,128,-1,123,41,117,41,128,-1,117,41,117,-2,113,40,108,40,117,-2,113,40,117,-2,117,41,128,-64,132,-108,134,-69,134,-69,132,-108,151,-104,134,-69,151,-104,140,-72,140,-72,151,-104,147,-74,159,-72,147,-74,151,-104,159,-72,151,-104,170,-93,204,-29,201,-3,199,-55,199,-55,201,-3,192,16,199,-55,192,16,188,-34,188,-34,187,-76,199,-55,158,-1,170,-5,177,30,177,30,170,-5,180,-12,177,30,180,-12,192,16,192,16,180,-12,186,-22,192,16,186,-22,188,-34,187,-76,188,-34,186,-47,187,-76,186,-47,180,-58,187,-76,180,-58,170,-67,187,-76,170,-67,170,-93,110,-60,111,-103,117,-59,117,-59,111,-103,121,-107,117,-59,121,-107,123,-61,123,-61,121,-107,132,-108,123,-61,132,-108,128,-64,97,-73,98,-90,99,-68,99,-68,98,-90,103,-98,99,-68,103,-98,104,-63,104,-63,103,-98,111,-103,104,-63,111,-103,110,-60,175,321,171,325,174,297,175,321,174,297,179,311,175,321,179,311,178,316,166,327,161,283,174,297,166,327,174,297,171,325,103,40,95,-4,105,-4,98,-90,97,-73,96,-80,159,-72,170,-93,170,-67, +226,-107,223,-101,221,-94,219,-86,218,-76,218,160,216,182,208,202,196,217,180,226,159,230,145,229,131,224,117,216,102,205,87,190,86,190,84,205,81,215,76,223,68,226,56,228,44,225,33,216,22,203,13,188,5,172,12,170,15,176,25,188,30,193,36,194,39,193,41,190,44,184,45,173,46,156,46,0,88,0,88,174,100,185,111,194,120,199,130,202,140,203,153,201,163,195,170,185,174,172,176,154,176,-79,177,-89,179,-97,181,-103,184,-107,234,166,233,198,230,228,226,254,220,277,211,296,199,313,185,325,169,334,150,340,126,342,87,333,55,310,32,273,18,226,13,170,14,144,15,120,18,100,23,81,28,64,40,41,55,21,74,7,96,-1,122,-4,161,3,192,27,215,63,229,110,234,166,16383,16383,59,177,59,193,62,247,70,285,83,310,99,324,119,328,150,318,171,292,182,256,188,216,189,177,16383,16383,189,158,187,109,180,67,168,36,151,16,128,9,98,18,78,42,67,77,61,118, +15,176,20,182,22,203,22,203,20,182,25,188,22,203,25,188,33,216,33,216,25,188,30,193,33,216,30,193,36,194,36,194,39,193,44,225,44,225,39,193,41,190,44,225,41,190,44,184,13,188,5,172,12,170,13,188,12,170,15,176,13,188,15,176,22,203,87,190,86,190,88,0,87,190,88,0,88,174,87,190,88,174,102,205,88,174,100,185,102,205,102,205,100,185,111,194,102,205,111,194,117,216,117,216,111,194,120,199,117,216,120,199,131,224,131,224,120,199,130,202,131,224,130,202,140,203,140,203,153,201,145,229,145,229,153,201,159,230,88,0,86,190,84,205,88,0,84,205,81,215,88,0,81,215,76,223,88,0,76,223,68,226,88,0,68,226,56,228,88,0,56,228,46,156,88,0,46,156,46,0,145,229,131,224,140,203,218,-65,218,160,216,182,218,-65,216,182,208,202,218,-65,208,202,218,-76,196,217,180,226,181,-103,196,217,181,-103,184,-107,196,217,184,-107,218,-76,196,217,218,-76,208,202,184,-107,226,-107,223,-101,184,-107,223,-101,221,-94,184,-107,221,-94,219,-86,184,-107,219,-86,218,-76,180,226,159,230,163,195,180,226,163,195,170,185,180,226,170,185,174,172,180,226,174,172,176,154,180,226,176,154,176,-79,180,226,176,-79,177,-89,180,226,177,-89,179,-97,180,226,179,-97,181,-103,176,154,176,-64,176,-79,45,173,46,156,56,228,45,173,56,228,44,225,45,173,44,225,44,184,44,225,33,216,36,194,159,230,153,201,163,195, +234,166,233,198,230,228,226,254,220,277,211,296,199,313,185,325,169,334,150,340,126,342,87,333,55,310,32,273,18,226,13,170,14,144,15,120,18,100,23,81,28,64,40,41,55,21,74,7,96,-1,122,-4,161,3,192,27,215,63,229,110,234,166,16383,16383,59,177,59,193,62,247,70,285,83,310,99,324,119,328,150,318,171,292,182,256,188,216,189,177,16383,16383,189,158,187,109,180,67,168,36,151,16,128,9,98,18,78,42,67,77,61,118,59,161,189,161,126,54,120,43,115,36,110,31,105,29,99,28,95,29,91,33,90,36,89,40,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,37,196,42,193,45,188,47,181,47,39,48,26,51,14,57,4,65,-2,77,-4,92,-1,105,7,116,20,126,35,133,50,252,0,252,7,239,10,228,13,219,19,209,27,199,39,113,140,131,158,147,172,161,181,174,185,188,187,194,186,201,185,207,183,213,182,220,181,227,182,233,185,239,189,243,196,245,206, +150,340,126,342,150,318,150,318,126,342,119,328,99,324,119,328,126,342,99,324,126,342,87,333,230,228,226,254,229,110,230,228,229,110,234,166,230,228,234,166,233,198,220,277,211,296,215,63,220,277,215,63,229,110,220,277,229,110,226,254,23,81,28,64,32,273,32,273,28,64,40,41,32,273,40,41,55,310,55,310,40,41,55,21,55,310,55,21,59,193,59,193,55,21,59,161,59,193,59,161,59,177,59,177,59,161,189,177,189,177,59,161,189,161,189,177,189,161,192,27,189,177,192,27,199,313,199,313,192,27,215,63,199,313,215,63,211,296,171,292,182,256,185,325,185,325,182,256,188,216,185,325,188,216,199,313,199,313,188,216,189,177,169,334,150,340,150,318,169,334,150,318,171,292,169,334,171,292,185,325,187,109,180,67,192,27,192,27,180,67,168,36,192,27,168,36,161,3,161,3,168,36,151,16,161,3,151,16,128,9,128,9,98,18,122,-4,122,-4,98,18,96,-1,78,42,67,77,74,7,78,42,74,7,96,-1,78,42,96,-1,98,18,59,161,55,21,61,118,61,118,55,21,74,7,61,118,74,7,67,77,189,158,187,109,192,27,189,158,192,27,189,161,128,9,122,-4,161,3,59,193,62,247,55,310,55,310,62,247,70,285,55,310,70,285,87,333,87,333,70,285,83,310,87,333,83,310,99,324,14,144,15,120,18,226,18,226,15,120,18,100,18,226,18,100,32,273,32,273,18,100,23,81,14,144,18,226,13,170, +126,54,120,43,115,36,110,31,105,29,99,28,95,29,91,33,90,36,89,40,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,37,196,42,193,45,188,47,181,47,39,48,26,51,14,57,4,65,-2,77,-4,92,-1,105,7,116,20,126,35,133,50,252,0,252,7,239,10,228,13,219,19,209,27,199,39,113,140,131,158,147,172,161,181,174,185,188,187,194,186,201,185,207,183,213,182,220,181,227,182,233,185,239,189,243,196,245,206,244,214,240,220,234,225,226,229,215,230,202,228,184,222,160,205,127,176,83,129,83,229, +45,188,57,219,42,193,42,193,57,219,41,214,42,193,41,214,37,196,37,196,41,214,31,196,28,196,31,196,41,214,28,196,41,214,26,208,57,4,65,-2,72,224,72,224,65,-2,77,-4,72,224,77,-4,88,230,88,230,77,-4,89,40,88,230,89,40,89,228,91,33,92,-1,93,31,93,31,92,-1,105,7,93,31,105,7,95,29,95,29,105,7,99,28,105,29,99,28,105,7,105,29,105,7,116,20,133,50,126,54,126,35,126,35,126,54,120,43,126,35,120,43,116,20,116,20,120,43,115,36,116,20,115,36,110,31,92,-1,91,33,90,36,92,-1,90,36,89,40,92,-1,89,40,77,-4,57,219,45,188,47,181,57,219,47,181,47,172,57,219,47,172,48,26,57,219,48,26,51,14,57,219,51,14,57,4,57,219,57,4,72,224,47,172,47,39,48,26,26,208,10,204,15,196,26,208,15,196,20,196,26,208,20,196,24,196,26,208,24,196,28,196,15,196,10,204,10,195,105,29,116,20,110,31, +252,0,252,7,239,10,228,13,219,19,209,27,199,39,113,140,131,158,147,172,161,181,174,185,188,187,194,186,201,185,207,183,213,182,220,181,227,182,233,185,239,189,243,196,245,206,244,214,240,220,234,225,226,229,215,230,202,228,184,222,160,205,127,176,83,129,83,229,81,230,70,226,48,220,35,216,18,212,3,208,3,200,10,200,14,201,20,201,28,200,34,197,38,192,40,183,41,171,41,0,83,0,83,113,148,34,151,30,155,24,156,22,156,20,155,15,153,12,149,9,144,8,137,7,133,7,133,0,238,69,235,53,229,42,222,35,215,31,209,30,200,32,193,38,186,47,181,58,176,71,121,266,113,292,104,313,95,329,83,338,68,342,51,337,39,325,32,308,28,288,26,268,34,268,38,284,43,295,49,302,56,305,64,306,74,304,83,296,92,283,100,267,107,248,113,225,6,0,56,0,128,177,164,45,169,29,176,15,184,4,193,-2,204,-5,219,-1,230,8,239,24,244,45,246,69,251,53,244,42,239,35,234,31,230,29,224,28,221,29,218,31,216,36,215,45,214,56,214,225,172,225,172,59,171,53,169,48, +10,200,14,201,18,212,18,212,14,201,17,201,18,212,17,201,20,201,20,201,28,200,35,216,35,216,28,200,34,197,35,216,34,197,38,192,7,200,10,200,18,212,7,200,18,212,3,208,7,200,3,208,3,200,35,216,38,192,48,220,48,220,38,192,40,183,48,220,40,183,41,171,83,0,41,171,41,0,35,216,18,212,20,201,83,129,83,229,81,230,83,129,81,230,83,0,83,129,83,0,83,113,83,129,83,113,127,176,131,158,147,172,160,205,160,205,147,172,161,181,160,205,161,181,184,222,184,222,161,181,174,185,184,222,174,185,188,187,188,187,194,186,202,228,202,228,194,186,201,185,202,228,201,185,207,183,127,176,83,113,113,140,127,176,113,140,131,158,127,176,131,158,160,205,83,0,81,230,70,226,83,0,70,226,59,223,83,0,59,223,48,220,83,0,48,220,41,171,227,182,233,185,234,225,234,225,233,185,239,189,234,225,239,189,240,220,240,220,239,189,243,196,240,220,243,196,244,214,244,214,243,196,245,206,207,183,213,182,215,230,215,230,213,182,220,181,215,230,220,181,226,229,226,229,220,181,227,182,226,229,227,182,234,225,202,228,184,222,188,187,153,12,149,9,252,0,252,0,149,9,144,8,252,0,144,8,137,7,156,20,252,0,228,13,156,20,228,13,219,19,156,20,219,19,209,27,156,20,209,27,199,39,156,20,199,39,156,22,199,39,113,140,148,34,199,39,148,34,151,30,199,39,151,30,153,27,199,39,153,27,155,24,199,39,155,24,156,22,239,10,228,13,252,0,239,10,252,0,252,7,155,15,153,12,252,0,155,15,252,0,156,20,133,7,133,0,252,0,133,7,252,0,137,7,148,34,113,140,83,113,202,228,207,183,215,230, +238,69,235,53,229,42,222,35,215,31,209,30,200,32,193,38,186,47,181,58,176,71,121,266,113,292,104,313,95,329,83,338,68,342,51,337,39,325,32,308,28,288,26,268,34,268,38,284,43,295,49,302,56,305,64,306,74,304,83,296,92,283,100,267,107,248,113,225,6,0,56,0,128,177,164,45,169,29,176,15,184,4,193,-2,204,-5,219,-1,230,8,239,24,244,45,246,69,251,53,244,42,239,35,234,31,230,29,224,28,221,29,218,31,216,36,215,45,214,56,214,225,172,225,172,59,171,53,169,48,166,44,161,40,153,33,144,29,136,26,128,24,121,24,108,26,96,32,87,41,80,53,78,69,78,225,36,225,36,-65,35,-75,34,-84,32,-93,30,-101,27,-107,69,-107,71,-102,73,-94,75,-85,76,-75,76,9,78,9,81,4,87,0,93,-2,101,-4,109,-4, +56,305,64,306,64,306,68,342,64,306,74,304,68,342,74,304,83,338,83,338,74,304,83,296,83,338,83,296,95,329,95,329,83,296,92,283,95,329,92,283,100,267,113,292,107,248,113,225,113,292,113,225,121,266,121,266,113,225,128,177,121,266,128,177,176,71,176,71,128,177,164,45,176,71,164,45,169,29,104,313,95,329,100,267,104,313,100,267,107,248,104,313,107,248,113,292,176,71,169,29,176,15,176,71,176,15,184,4,113,225,6,0,56,0,113,225,56,0,128,177,200,32,193,38,193,-2,193,-2,193,38,186,47,193,-2,186,47,184,4,184,4,186,47,181,58,184,4,181,58,176,71,235,53,229,42,230,8,230,8,229,42,222,35,230,8,222,35,219,-1,219,-1,222,35,215,31,219,-1,215,31,209,30,209,30,200,32,204,-5,204,-5,200,32,193,-2,239,24,244,45,246,69,239,24,246,69,238,69,239,24,238,69,235,53,239,24,235,53,230,8,209,30,204,-5,219,-1,43,295,49,302,51,337,51,337,49,302,56,305,51,337,56,305,68,342,68,342,56,305,64,306,39,325,32,308,34,268,39,325,34,268,38,284,39,325,38,284,43,295,39,325,43,295,51,337,28,288,26,268,34,268,28,288,34,268,32,308, +251,53,244,42,239,35,234,31,230,29,224,28,221,29,218,31,216,36,215,45,214,56,214,225,172,225,172,59,171,53,169,48,166,44,161,40,153,33,144,29,136,26,128,24,121,24,108,26,96,32,87,41,80,53,78,69,78,225,36,225,36,-65,35,-75,34,-84,32,-93,30,-101,27,-107,69,-107,71,-102,73,-94,75,-85,76,-75,76,9,78,9,81,4,87,0,93,-2,101,-4,109,-4,119,-3,131,0,144,7,158,19,171,36,172,36,173,23,177,12,182,3,191,-2,203,-4,217,-1,230,7,241,20,250,35,258,50,212,230,206,188,189,141,163,97,129,63,90,45,89,45,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,31,196,37,195,42,192,45,188,47,181,47,-6,59,-6,100,7,134,28,163,55,186,84,203,116,212,141,217,166,220,189,221,211,222,230,89,342,71,335,57,328,48,319,43,309,41,297,42,286,47,278,53,272,61,268,69,266,63,259,58,251,54,242,52,233,51,224,52,215,55,206,59,198,65,190,73,184,54,168,39,150,27,129,20,106,17,81,20,53,29,29,44,11,67,0,98,-4, +78,225,36,225,69,-107,78,225,69,-107,71,-102,78,225,71,-102,73,-94,78,225,73,-94,75,-85,78,225,75,-85,76,-75,78,225,76,-75,76,9,78,225,76,9,78,9,69,-107,36,225,36,-65,69,-107,36,-65,35,-75,69,-107,35,-75,34,-84,69,-107,34,-84,32,-93,69,-107,32,-93,30,-101,69,-107,30,-101,27,-107,87,0,93,-2,96,32,96,32,93,-2,101,-4,96,32,101,-4,108,26,108,26,101,-4,109,-4,108,26,109,-4,121,24,121,24,109,-4,119,-3,121,24,119,-3,131,0,171,53,169,48,171,36,171,36,169,48,166,44,171,36,166,44,161,40,161,40,153,33,158,19,158,19,153,33,144,29,158,19,144,29,144,7,144,7,144,29,136,26,144,7,136,26,131,0,131,0,136,26,128,24,131,0,128,24,121,24,87,41,80,53,81,4,87,41,81,4,87,0,87,41,87,0,96,32,81,4,80,53,78,69,81,4,78,69,78,9,214,225,172,225,173,23,173,23,172,225,172,68,173,23,172,68,172,36,172,36,172,68,172,59,172,36,172,59,171,36,171,36,172,59,171,53,161,40,158,19,171,36,214,225,173,23,177,12,214,225,177,12,182,3,214,225,182,3,191,-2,214,225,191,-2,203,-4,214,225,203,-4,214,56,244,42,239,35,241,20,241,20,239,35,234,31,241,20,234,31,230,7,230,7,234,31,230,29,230,7,230,29,224,28,224,28,221,29,230,7,230,7,221,29,218,31,230,7,218,31,217,-1,217,-1,218,31,216,36,217,-1,216,36,215,45,250,35,258,50,251,53,250,35,251,53,244,42,250,35,244,42,241,20,215,45,214,56,203,-4,215,45,203,-4,217,-1,76,9,76,-75,76,-64, +212,230,206,188,189,141,163,97,129,63,90,45,89,45,89,228,88,230,72,224,57,219,41,214,26,208,10,204,10,195,15,196,31,196,37,195,42,192,45,188,47,181,47,-6,59,-6,100,7,134,28,163,55,186,84,203,116,212,141,217,166,220,189,221,211,222,230,89,342,71,335,57,328,48,319,43,309,41,297,42,286,47,278,53,272,61,268,69,266,63,259,58,251,54,242,52,233,51,224,52,215,55,206,59,198,65,190,73,184,54,168,39,150,27,129,20,106,17,81,20,53,29,29,44,11,67,0,98,-4,107,-4,117,-2, +45,188,57,219,42,192,42,192,57,219,41,214,42,192,41,214,37,195,37,195,41,214,31,196,28,196,31,196,41,214,28,196,41,214,26,208,89,228,88,230,89,45,89,45,88,230,72,224,89,45,72,224,59,-6,59,-6,72,224,57,219,59,-6,57,219,47,172,47,172,57,219,47,181,26,208,10,204,15,196,26,208,15,196,20,196,26,208,20,196,25,196,26,208,25,196,28,196,186,84,189,141,163,55,163,55,189,141,163,97,163,55,163,97,134,28,134,28,163,97,129,63,134,28,129,63,100,7,100,7,129,63,90,45,189,141,203,116,206,188,206,188,203,116,212,141,206,188,212,141,212,230,212,230,212,141,217,166,212,230,217,166,222,230,222,230,217,166,220,189,222,230,220,189,221,211,89,45,59,-6,100,7,89,45,100,7,90,45,47,172,47,-6,59,-6,15,196,10,204,10,195,189,141,186,84,203,116,57,219,45,188,47,181, +89,342,71,335,57,328,48,319,43,309,41,297,42,286,47,278,53,272,61,268,69,266,63,259,58,251,54,242,52,233,51,224,52,215,55,206,59,198,65,190,73,184,54,168,39,150,27,129,20,106,17,81,20,53,29,29,44,11,67,0,98,-4,107,-4,117,-2,128,-1,137,0,143,0,158,-1,170,-5,180,-12,186,-22,188,-34,186,-47,180,-59,170,-67,159,-72,147,-74,140,-72,134,-69,128,-64,123,-61,117,-59,110,-60,104,-63,99,-68,97,-73,96,-80,98,-90,103,-98,111,-103,121,-107,132,-108,151,-104,170,-93,187,-76,199,-53,204,-26,201,-3,192,15,177,29,156,38,128,41,118,41,111,40,98,40,79,42,63,48,51,59,43,75,40,98,43,118,50,136,62,152,77,164,94,174,102,172,110,171,117,170,142,170,157,173,171,178,181,186,185,197,184,204,179,210,172,214,164,216,153,217,140,216,127,213,113,208,101,202,89,194,83,199,78,204,74,211,72,218,71,225,73,235,77,243,83,251,93,256,106,258,126,260,144,264,160,271,171,280,175,291,174,297,171,301,166,305,160,307,151,307,139,306,125,303,111,297,96,290,83,281,76,283,70,286,66,291,64,297,63,305,64,310,66,316,72,322,80,328,93,334,237,114,232,151,218,183,197,208,167,224,129,230,91,223,60,203,37,174,22,139,17,101,23,67,38,38,62,15,92,0,126,-4,161,2,191,20,215,47,231,79,237,114,16383,16383,192,95,190,74,183,52,172,31,156,17,134,11,107,19,87,38,73,65,65,95,62,122,64,145,70,169,80,191,97,207,119,214,148,205,168,184,182,155,190,124,192,95,233,69,229,55,223,45,216,40,209,37,203,36,194,38,188,41,184,47,180,54,178,61,177,69,176,78,175,88,175,109,176,127,176,144,178,160,179,173,180,183,239,183,239,225,97,225,68,222,46,214,29,200,16,180,4,155,12,155,23,167,35,176,47,180,62,183,78,183,72,119,64,77,54,54,42,42,30,36,26,35,20,31,18,25,20,15,23,6,30,0,39,-5,52,-6,77,9,91,48,98,99,100,148,100,183,147,183,145,160,143,136,139,82,139,56,141,37,147,20,156,7,169,-1,185,-4,205,0,220,12,232,29,239,49,241,69,36,-65,35,-75,34,-84,32,-93,30,-101,27,-107,70,-107,72,-102,74,-95,76,-85,77,-75,78,-64,78,15,88,7,98,1,108,-2,118,-4,130,-4,164,1,192,19,214,47,228,82,233,123,228,158,214,188,191,210,163,225, +51,59,43,75,44,11,44,11,43,75,40,98,39,150,40,98,43,118,39,150,43,118,54,168,54,168,43,118,50,136,54,168,50,136,62,152,61,268,63,305,57,328,61,268,57,328,53,272,53,272,57,328,48,319,53,272,48,319,47,278,47,278,48,319,43,309,47,278,43,309,42,286,42,286,43,309,41,297,64,310,66,316,71,335,71,335,66,316,72,322,71,335,72,322,89,342,89,342,72,322,80,328,89,342,80,328,93,334,64,310,71,335,57,328,64,310,57,328,63,305,73,235,76,283,71,225,71,225,70,286,69,266,69,266,70,286,66,291,69,266,66,291,64,297,83,281,76,283,77,243,83,281,77,243,83,251,83,281,83,251,96,290,72,218,73,184,74,211,74,211,73,184,77,164,74,211,77,164,78,204,78,204,77,164,94,174,78,204,94,174,83,199,83,199,94,174,89,194,101,202,94,174,102,172,101,202,102,172,113,208,113,208,102,172,110,171,113,208,110,171,117,170,73,184,54,168,62,152,73,184,62,152,77,164,73,184,72,218,71,225,73,184,71,225,69,266,73,184,69,266,65,190,52,233,52,215,54,242,54,242,52,215,55,206,54,242,55,206,58,251,58,251,55,206,59,198,58,251,59,198,63,259,63,259,59,198,65,190,63,259,65,190,69,266,64,297,63,305,61,268,64,297,61,268,69,266,128,41,124,41,128,-1,128,-1,124,41,118,41,128,-1,118,41,117,-2,117,-2,118,41,111,40,117,-2,111,40,107,-4,107,-4,111,40,104,40,107,-4,104,40,98,-4,98,-4,104,40,98,40,177,29,156,38,158,-1,158,-1,156,38,143,0,137,0,143,0,156,38,137,0,156,38,128,41,128,-64,132,-108,134,-69,134,-69,132,-108,151,-104,134,-69,151,-104,140,-72,140,-72,151,-104,147,-74,159,-72,147,-74,151,-104,159,-72,151,-104,170,-93,204,-26,201,-3,199,-53,199,-53,201,-3,192,15,199,-53,192,15,188,-34,188,-34,187,-76,199,-53,158,-1,170,-5,177,29,177,29,170,-5,180,-12,177,29,180,-12,192,15,192,15,180,-12,186,-22,192,15,186,-22,188,-34,188,-34,186,-47,187,-76,187,-76,186,-47,180,-59,187,-76,180,-59,170,-93,170,-93,180,-59,170,-67,170,-93,170,-67,159,-72,110,-60,111,-103,117,-59,117,-59,111,-103,121,-107,117,-59,121,-107,123,-61,123,-61,121,-107,132,-108,123,-61,132,-108,128,-64,97,-73,98,-90,99,-68,99,-68,98,-90,103,-98,99,-68,103,-98,104,-63,104,-63,103,-98,111,-103,104,-63,111,-103,110,-60,181,186,185,197,184,204,181,186,184,204,179,210,181,186,179,210,172,214,181,186,172,214,171,178,117,170,124,170,127,213,127,213,124,170,131,170,127,213,131,170,140,216,140,216,131,170,142,170,140,216,142,170,153,217,153,217,142,170,157,173,153,217,157,173,164,216,164,216,157,173,171,178,164,216,171,178,172,214,160,307,160,271,166,305,166,305,160,271,171,280,166,305,171,280,171,301,171,301,171,280,175,291,171,301,175,291,174,297,125,303,126,260,139,306,139,306,126,260,144,264,139,306,144,264,151,307,151,307,144,264,160,271,151,307,160,271,160,307,83,251,93,256,96,290,96,290,93,256,106,258,96,290,106,258,111,297,111,297,106,258,126,260,111,297,126,260,125,303,79,42,63,48,67,0,79,42,67,0,98,-4,79,42,98,-4,98,40,51,59,44,11,67,0,51,59,67,0,63,48,29,29,44,11,40,98,29,29,40,98,39,150,29,29,39,150,27,129,29,29,27,129,20,53,20,106,17,81,20,53,20,106,20,53,27,129,113,208,117,170,127,213,98,-90,97,-73,96,-80,128,41,128,-1,137,0,52,215,52,233,51,224,94,174,101,202,89,194,70,286,71,225,76,283,76,283,73,235,77,243, +237,114,232,151,218,183,197,208,167,224,129,230,91,223,60,203,37,174,22,139,17,101,23,67,38,38,62,15,92,0,126,-4,161,2,191,20,215,47,231,79,237,114,16383,16383,192,95,190,74,183,52,172,31,156,17,134,11,107,19,87,38,73,65,65,95,62,122,64,145,70,169,80,191,97,207,119,214,148,205,168,184,182,155,190,124,192,95,233,69,229,55,223,45,216,40,209,37,203,36,194,38,188,41,184,47,180,54,178,61,177,69,176,78,175,88,175,109,176,127,176,144,178,160,179,173,180,183,239,183,239,225,97,225,68,222,46,214,29,200,16,180,4,155,12,155,23,167,35,176,47,180,62,183,78,183,72,119,64,77,54,54,42,42,30,36,26,35,20,31,18,25,20,15, +97,207,119,214,119,214,129,230,119,214,148,205,129,230,148,205,167,224,167,224,148,205,168,184,167,224,168,184,197,208,197,208,168,184,182,155,197,208,182,155,190,124,190,74,183,52,191,20,191,20,183,52,172,31,191,20,172,31,161,2,161,2,172,31,156,17,161,2,156,17,134,11,134,11,107,19,126,-4,126,-4,107,19,92,0,107,19,87,38,92,0,92,0,87,38,73,65,92,0,73,65,62,15,62,15,73,65,65,95,62,15,65,95,62,122,80,191,91,223,70,169,70,169,91,223,60,203,70,169,60,203,64,145,64,145,60,203,62,122,62,15,62,122,60,203,62,15,60,203,38,38,38,38,60,203,37,174,38,38,37,174,23,67,23,67,37,174,22,139,23,67,22,139,17,101,237,114,232,151,231,79,231,79,232,151,218,183,231,79,218,183,215,47,215,47,218,183,197,208,215,47,197,208,192,95,192,95,191,20,215,47,134,11,126,-4,161,2,97,207,119,214,129,230,97,207,129,230,91,223,97,207,91,223,80,191,190,74,191,20,192,95,197,208,190,124,192,95, +233,69,229,55,223,45,216,40,209,37,203,36,194,38,188,41,184,47,180,54,178,61,177,69,176,78,175,88,175,109,176,127,176,144,178,160,179,173,180,183,239,183,239,225,97,225,68,222,46,214,29,200,16,180,4,155,12,155,23,167,35,176,47,180,62,183,78,183,72,119,64,77,54,54,42,42,30,36,26,35,20,31,18,25,20,15,23,6,30,0,39,-5,52,-6,77,9,91,48,98,99,100,148,100,183,147,183,145,160,143,136,139,82,139,56,141,37,147,20,156,7,169,-1,185,-4,205,0,220,12,232,29,239,49,241,69,36,-65,35,-75,34,-84,32,-93,30,-101,27,-107,70,-107,72,-102,74,-95,76,-85,77,-75,78,-64,78,15,88,7,98,1,108,-2,118,-4,130,-4,164,1,192,19,214,47,228,82,233,123,228,158,214,188,191,210,163,225,129,230,101,225,75,210,54,182,41,138,36,76,16383,16383,78,137,79,163,85,185,94,202,107,212,123,216,145,211,163,197,177,175,186,144,190,106,187,75,179,49,166,29,150,16,129,11,115,13,101,18,89,26,81,35,78,44,216,176,213,191,205,206,190,218,169,227,142,230,107,223,73,202,45,171,25,130,17,83,21,45, +72,119,64,77,77,9,77,9,64,77,54,54,77,9,54,54,52,-6,52,-6,54,54,42,42,52,-6,42,42,39,-5,39,-5,42,42,30,36,39,-5,30,36,30,0,30,0,30,36,26,35,30,0,26,35,23,6,23,6,26,35,23,33,23,6,23,33,20,31,20,15,23,6,20,31,20,15,20,31,19,28,20,15,19,28,18,25,97,225,68,222,78,183,78,183,91,48,97,225,97,225,91,48,98,99,97,225,98,99,100,183,100,183,98,99,100,148,180,183,239,183,239,225,180,183,239,225,147,183,147,183,239,225,100,183,176,78,175,88,169,-1,169,-1,175,88,175,99,169,-1,175,99,175,109,175,109,176,127,169,-1,169,-1,176,127,176,144,169,-1,176,144,156,7,156,7,176,144,178,160,156,7,178,160,179,173,147,20,180,183,147,183,147,20,147,183,145,160,179,173,180,183,147,20,179,173,147,20,156,7,97,225,100,183,239,225,4,155,12,155,16,180,16,180,12,155,23,167,16,180,23,167,29,200,29,200,23,167,35,176,29,200,35,176,46,214,46,214,35,176,47,180,46,214,47,180,68,222,68,222,47,180,62,183,68,222,62,183,78,183,188,41,184,47,185,-4,185,-4,184,47,180,54,185,-4,180,54,178,61,178,61,177,69,185,-4,185,-4,177,69,169,-1,188,41,205,0,194,38,194,38,205,0,203,36,209,37,203,36,205,0,209,37,205,0,220,12,233,69,229,55,232,29,233,69,232,29,239,49,233,69,239,49,241,69,223,45,216,40,220,12,223,45,220,12,232,29,223,45,232,29,229,55,143,136,141,109,141,37,143,136,141,37,147,20,143,136,147,20,145,160,139,82,139,56,141,37,139,82,141,37,141,109,78,183,72,119,77,9,78,183,77,9,91,48,176,78,169,-1,177,69,188,41,185,-4,205,0,209,37,220,12,216,40, +36,-65,35,-75,34,-84,32,-93,30,-101,27,-107,70,-107,72,-102,74,-95,76,-85,77,-75,78,-64,78,15,88,7,98,1,108,-2,118,-4,130,-4,164,1,192,19,214,47,228,82,233,123,228,158,214,188,191,210,163,225,129,230,101,225,75,210,54,182,41,138,36,76,16383,16383,78,137,79,163,85,185,94,202,107,212,123,216,145,211,163,197,177,175,186,144,190,106,187,75,179,49,166,29,150,16,129,11,115,13,101,18,89,26,81,35,78,44,216,176,213,191,205,206,190,218,169,227,142,230,107,223,73,202,45,171,25,130,17,83,21,45,33,20,50,5,71,-2,95,-4,105,-4,117,-2,128,-1,137,0,143,0,158,-1,170,-5,180,-12,186,-22,188,-34,186,-47,180,-58,170,-67,159,-72,147,-74,140,-72,134,-69,128,-64,123,-61,117,-59,110,-60,104,-63,99,-68,97,-73,96,-80,98,-90,103,-98,111,-103,121,-107,132,-108,151,-104,170,-93,187,-76,199,-55,204,-29,201,-3,192,16,177,30,156,38, +107,212,123,216,123,216,129,230,123,216,145,211,129,230,145,211,163,225,163,225,145,211,163,197,163,225,163,197,191,210,191,210,163,197,177,175,191,210,177,175,186,144,191,210,190,106,192,19,191,210,192,19,214,188,214,188,192,19,214,47,214,188,214,47,228,158,228,158,214,47,228,82,228,158,228,82,233,123,192,19,190,106,187,75,192,19,187,75,179,49,192,19,179,49,166,29,192,19,166,29,164,1,129,11,130,-4,150,16,150,16,130,-4,164,1,150,16,164,1,166,29,130,-4,129,11,118,-4,118,-4,129,11,115,13,118,-4,115,13,108,-2,108,-2,115,13,101,18,108,-2,101,18,98,1,98,1,101,18,89,26,98,1,89,26,88,7,88,7,89,26,81,35,88,7,81,35,78,44,85,185,94,202,101,225,101,225,94,202,107,212,101,225,107,212,129,230,129,230,107,212,123,216,78,137,79,163,75,210,78,137,75,210,76,-85,78,137,76,-85,77,-75,78,137,77,-75,78,-64,75,210,79,163,85,185,75,210,85,185,101,225,75,210,54,182,70,-107,75,210,70,-107,72,-102,75,210,72,-102,74,-95,75,210,74,-95,76,-85,70,-107,54,182,41,138,70,-107,41,138,36,76,70,-107,36,76,36,-65,70,-107,36,-65,35,-75,70,-107,35,-75,34,-84,70,-107,34,-84,32,-93,70,-107,32,-93,30,-101,70,-107,30,-101,27,-107,78,44,78,15,88,7,191,210,186,144,190,106, +216,176,213,191,205,206,190,218,169,227,142,230,107,223,73,202,45,171,25,130,17,83,21,45,33,20,50,5,71,-2,95,-4,105,-4,117,-2,128,-1,137,0,143,0,158,-1,170,-5,180,-12,186,-22,188,-34,186,-47,180,-58,170,-67,159,-72,147,-74,140,-72,134,-69,128,-64,123,-61,117,-59,110,-60,104,-63,99,-68,97,-73,96,-80,98,-90,103,-98,111,-103,121,-107,132,-108,151,-104,170,-93,187,-76,199,-55,204,-29,201,-3,192,16,177,30,156,38,128,41,119,41,115,40,103,40,78,45,60,54,48,68,42,85,41,105,45,135,58,158,76,174,97,183,118,186,141,182,158,174,170,163,181,155,192,151,201,153,208,157,212,163,215,169,216,176,259,183,259,225,119,225,87,220,58,207,35,184,20,151,15,108,20,73,35,42,58,18,87,1,119,-4,156,1,187,16,212,38,228,65,233,94,229,121,218,138,203,152,186,165,171,183,16383,16383,189,85,186,63,180,42,168,25,152,13,131,9,110,15,90,30,75,54,64,84,60,117,65,145,78,164,97,176,118,182,137,183,153,172,167,155,178,134,186,110,189,85,221,183,221,225,81,225,55,219,34,204,18,183,7,160,2,138,9,138,16,153,25,166,37,175,50,181,66,183,107,183,102,164,96,142,92,119,88,95,87,71,89,49,94,28,103,11,118,0,138,-4,157,0,172,10,183,27,191,48,193,71,185,71,182,59,176,49,169,42, +60,54,48,68,50,5,50,5,48,68,42,85,50,5,42,85,33,20,33,20,42,85,41,105,45,171,41,105,45,135,45,171,45,135,73,202,73,202,45,135,58,158,73,202,58,158,76,174,73,202,76,174,107,223,107,223,76,174,97,183,107,223,97,183,118,186,118,186,141,182,142,230,142,230,141,182,158,174,142,230,158,174,169,227,169,227,158,174,170,163,169,227,170,163,190,218,190,218,170,163,181,155,190,218,181,155,192,151,17,83,21,45,25,130,25,130,21,45,33,20,25,130,33,20,45,171,45,171,33,20,41,105,177,30,156,38,158,-1,158,-1,156,38,143,0,137,0,143,0,156,38,137,0,156,38,128,41,128,-1,137,0,128,41,128,-1,128,41,123,41,128,-1,123,41,119,41,128,-1,119,41,117,-2,105,-4,117,-2,107,40,111,40,107,40,117,-2,111,40,117,-2,115,40,115,40,117,-2,119,41,60,54,71,-2,78,45,78,45,71,-2,95,-4,78,45,95,-4,103,40,103,40,95,-4,105,-4,103,40,105,-4,107,40,128,-64,132,-108,134,-69,134,-69,132,-108,151,-104,134,-69,151,-104,140,-72,140,-72,151,-104,147,-74,159,-72,147,-74,151,-104,159,-72,151,-104,170,-93,204,-29,201,-3,199,-55,199,-55,201,-3,192,16,199,-55,192,16,188,-34,188,-34,187,-76,199,-55,158,-1,170,-5,177,30,177,30,170,-5,180,-12,177,30,180,-12,192,16,192,16,180,-12,186,-22,192,16,186,-22,188,-34,187,-76,188,-34,186,-47,187,-76,186,-47,180,-58,187,-76,180,-58,170,-67,187,-76,170,-67,170,-93,110,-60,111,-103,117,-59,117,-59,111,-103,121,-107,117,-59,121,-107,123,-61,123,-61,121,-107,132,-108,123,-61,132,-108,128,-64,97,-73,98,-90,99,-68,99,-68,98,-90,103,-98,99,-68,103,-98,104,-63,104,-63,103,-98,111,-103,104,-63,111,-103,110,-60,213,191,205,206,208,157,213,191,208,157,212,163,213,191,212,163,215,169,213,191,215,169,216,176,205,206,190,218,192,151,205,206,192,151,201,153,205,206,201,153,208,157,142,230,107,223,118,186,98,-90,97,-73,96,-80,159,-72,170,-93,170,-67,60,54,50,5,71,-2, +259,183,259,225,119,225,87,220,58,207,35,184,20,151,15,108,20,73,35,42,58,18,87,1,119,-4,156,1,187,16,212,38,228,65,233,94,229,121,218,138,203,152,186,165,171,183,16383,16383,189,85,186,63,180,42,168,25,152,13,131,9,110,15,90,30,75,54,64,84,60,117,65,145,78,164,97,176,118,182,137,183,153,172,167,155,178,134,186,110,189,85,221,183,221,225,81,225,55,219,34,204,18,183,7,160,2,138,9,138,16,153,25,166,37,175,50,181,66,183,107,183,102,164,96,142,92,119,88,95,87,71,89,49,94,28,103,11,118,0,138,-4,157,0,172,10,183,27,191,48,193,71,185,71,182,59,176,49,169,42,161,38,151,36,141,39,133,47,128,59,125,74,124,91,125,113,128,135,131,155,134,172, +186,63,180,42,187,16,187,16,180,42,168,25,187,16,168,25,156,1,156,1,168,25,152,13,156,1,152,13,131,9,131,9,110,15,119,-4,119,-4,110,15,90,30,119,-4,90,30,87,1,87,1,90,30,75,54,87,1,75,54,64,84,58,207,60,117,65,145,58,207,65,145,87,220,87,220,65,145,78,164,87,220,78,164,97,176,58,18,87,1,64,84,58,18,64,84,60,117,58,18,60,117,58,207,58,18,58,207,35,184,58,18,35,184,35,42,20,151,15,108,20,73,20,151,20,73,35,42,20,151,35,42,35,184,153,172,167,155,171,183,171,183,167,155,178,134,171,183,259,225,137,183,119,225,87,220,97,176,119,225,97,176,118,182,119,225,118,182,137,183,119,225,137,183,259,225,137,183,153,172,171,183,233,94,229,121,228,65,228,65,229,121,218,138,228,65,218,138,212,38,212,38,218,138,203,152,212,38,203,152,189,85,189,85,203,152,186,165,189,85,186,165,186,110,186,165,171,183,178,134,186,165,178,134,186,110,189,85,187,16,212,38,131,9,119,-4,156,1,186,63,187,16,189,85,259,225,171,183,259,183, +221,183,221,225,81,225,55,219,34,204,18,183,7,160,2,138,9,138,16,153,25,166,37,175,50,181,66,183,107,183,102,164,96,142,92,119,88,95,87,71,89,49,94,28,103,11,118,0,138,-4,157,0,172,10,183,27,191,48,193,71,185,71,182,59,176,49,169,42,161,38,151,36,141,39,133,47,128,59,125,74,124,91,125,113,128,135,131,155,134,172,136,183,127,230,127,220,139,218,149,214,159,209,168,201,177,191,186,176,193,159,198,141,201,122,202,104,200,75,193,49,182,28,165,14,142,9,121,14,106,28,97,47,92,68,91,87,91,193,90,205,86,215,80,222,71,226,60,228,47,225,36,216,26,203,16,188,8,172,15,170,18,176,28,188,33,193,39,194,43,192,46,187,48,180,49,170,49,99,51,66,60,38,76,15, +9,138,16,153,18,183,18,183,16,153,25,166,18,183,25,166,34,204,34,204,25,166,37,175,34,204,37,175,55,219,55,219,37,175,50,181,55,219,50,181,66,183,81,225,66,183,107,183,81,225,107,183,221,225,221,225,107,183,136,183,221,225,136,183,221,183,7,160,2,138,9,138,7,160,9,138,18,183,118,0,125,74,124,91,124,91,125,113,118,0,118,0,125,113,107,183,118,0,107,183,103,11,103,11,107,183,102,164,103,11,102,164,96,142,128,135,131,155,107,183,107,183,131,155,134,172,107,183,134,172,136,183,138,-4,157,0,141,39,141,39,157,0,151,36,161,38,151,36,157,0,161,38,157,0,172,10,185,71,182,59,183,27,185,71,183,27,191,48,185,71,191,48,193,71,176,49,169,42,172,10,176,49,172,10,183,27,176,49,183,27,182,59,138,-4,141,39,133,47,138,-4,133,47,128,59,138,-4,128,59,125,74,138,-4,125,74,118,0,103,11,96,142,94,28,94,28,96,142,92,119,94,28,92,119,89,49,89,49,92,119,88,95,89,49,88,95,87,71,161,38,172,10,169,42,66,183,81,225,55,219,128,135,107,183,125,113, +127,230,127,220,139,218,149,214,159,209,168,201,177,191,186,176,193,159,198,141,201,122,202,104,200,75,193,49,182,28,165,14,142,9,121,14,106,28,97,47,92,68,91,87,91,193,90,205,86,215,80,222,71,226,60,228,47,225,36,216,26,203,16,188,8,172,15,170,18,176,28,188,33,193,39,194,43,192,46,187,48,180,49,170,49,99,51,66,60,38,76,15,102,0,139,-4,174,1,204,18,227,43,242,75,247,113,241,155,226,188,202,211,173,225,141,230,134,9,124,10,114,13,104,18,94,25,86,34,76,52,68,72,63,94,61,116,60,137,63,166,73,189,88,206,109,216,134,221,134,228,132,229,129,229,126,230,121,230,84,224,54,207,33,181,19,150,15,114,19,78,33,46,55,20,85,3,123,-3,134,-4,134,-107,176,-107,176,-4,220,1,254,18,277,43,292,75,296,111,291,151,278,184,258,209,233,224,207,230,195,229,184,226,175,221,167,215,160,208,148,187,141,162,137,134,135,105,134,76,16383,16383,176,9,176,129, +18,176,23,182,26,203,26,203,23,182,28,188,26,203,28,188,36,216,36,216,28,188,33,193,36,216,33,193,39,194,39,194,43,192,47,225,47,225,43,192,46,187,47,225,46,187,48,180,16,188,8,172,15,170,16,188,15,170,18,176,16,188,18,176,26,203,49,99,51,66,49,159,49,170,49,159,60,228,49,170,60,228,48,180,48,180,60,228,47,225,91,87,91,193,90,205,91,87,90,205,86,215,91,87,86,215,80,222,91,87,80,222,92,68,141,230,127,230,139,218,141,230,139,218,149,214,141,230,149,214,173,225,200,75,193,49,204,18,204,18,193,49,182,28,204,18,182,28,174,1,174,1,182,28,165,14,174,1,165,14,142,9,142,9,121,14,139,-4,139,-4,121,14,106,28,139,-4,106,28,102,0,102,0,106,28,97,47,102,0,97,47,92,68,76,15,102,0,92,68,76,15,92,68,80,222,76,15,80,222,71,226,76,15,71,226,60,228,76,15,60,228,60,38,60,228,49,159,51,66,60,228,51,66,60,38,47,225,36,216,39,194,149,214,159,209,173,225,173,225,159,209,168,201,173,225,168,201,177,191,177,191,186,176,202,211,202,211,186,176,193,159,202,211,193,159,198,141,202,211,202,104,204,18,202,211,204,18,226,188,226,188,204,18,227,43,226,188,227,43,241,155,241,155,227,43,242,75,241,155,242,75,247,113,202,211,198,141,201,122,202,211,201,122,202,104,202,211,173,225,177,191,142,9,139,-4,174,1,200,75,204,18,202,104,139,218,127,230,127,220, +134,9,124,10,114,13,104,18,94,25,86,34,76,52,68,72,63,94,61,116,60,137,63,166,73,189,88,206,109,216,134,221,134,228,132,229,129,229,126,230,121,230,84,224,54,207,33,181,19,150,15,114,19,78,33,46,55,20,85,3,123,-3,134,-4,134,-107,176,-107,176,-4,220,1,254,18,277,43,292,75,296,111,291,151,278,184,258,209,233,224,207,230,195,229,184,226,175,221,167,215,160,208,148,187,141,162,137,134,135,105,134,76,16383,16383,176,9,176,129,177,155,178,179,182,198,189,211,201,216,218,209,232,190,243,164,249,134,252,103,250,74,243,49,231,28,214,14,191,9,243,225,194,225,123,93,113,139,103,177,92,206,79,224,63,230,49,227,38,217,31,202,27,182,26,156,34,156,37,171,41,182,46,190,51,194,56,195,67,192,77,183,85,168,93,147,101,119,110,78,6,-104,55,-104,126,26,136,-34,141,-57,148,-78,157,-94,168,-105,182,-109,198,-104,209,-90,216,-71,219,-52,220,-34,213,-34,210,-49,206,-61,201,-68,195,-72,187,-74,188,-74,177,-71,168,-63,160,-48,153,-27,147,1,138,41,342,228,332,230,316,230,290,224,273,209,262,187,256,162,254,136,253,103,249,69,239,39,223,17,197,9,197,225,155,225,155,9,129,17,112,39,103,69,99,104,98,137, +61,116,60,137,60,137,55,20,60,137,54,207,55,20,54,207,33,46,33,46,54,207,33,181,33,46,33,181,19,78,19,78,33,181,19,150,19,78,19,150,15,114,63,94,55,20,68,72,68,72,55,20,85,3,68,72,85,3,76,52,76,52,85,3,86,34,94,25,86,34,85,3,94,25,85,3,123,-3,61,116,60,137,55,20,61,116,55,20,63,94,135,105,134,76,176,-107,176,-107,134,76,134,9,176,-107,134,9,134,-4,134,-4,134,9,124,10,134,-4,124,10,123,-3,123,-3,124,10,114,13,123,-3,114,13,104,18,134,221,134,228,132,229,134,221,132,229,129,229,134,221,129,229,126,230,134,221,126,230,124,230,134,221,124,230,121,230,134,221,121,230,109,216,175,221,176,-107,176,129,176,9,176,-4,220,1,176,9,220,1,191,9,191,9,220,1,214,14,207,230,201,216,218,209,207,230,218,209,233,224,233,224,218,209,232,190,233,224,232,190,243,164,178,179,182,198,184,226,184,226,182,198,189,211,184,226,189,211,195,229,195,229,189,211,201,216,195,229,201,216,207,230,175,221,176,129,177,155,175,221,177,155,178,179,175,221,178,179,184,226,176,-107,175,221,167,215,176,-107,167,215,160,208,176,-107,160,208,148,187,176,-107,148,187,141,162,176,-107,141,162,137,134,176,-107,137,134,135,105,296,111,291,151,292,75,292,75,291,151,278,184,292,75,278,184,277,43,277,43,278,184,258,209,277,43,258,209,254,18,254,18,258,209,252,103,254,18,252,103,250,74,254,18,250,74,243,49,258,209,233,224,243,164,258,209,243,164,249,134,258,209,249,134,252,103,231,28,214,14,220,1,231,28,220,1,254,18,231,28,254,18,243,49,63,166,73,189,84,224,84,224,73,189,88,206,84,224,88,206,121,230,121,230,88,206,109,216,63,166,84,224,54,207,63,166,54,207,60,137,176,-107,134,-4,134,-107,94,25,123,-3,104,18, +243,225,194,225,123,93,113,139,103,177,92,206,79,224,63,230,49,227,38,217,31,202,27,182,26,156,34,156,37,171,41,182,46,190,51,194,56,195,67,192,77,183,85,168,93,147,101,119,110,78,6,-104,55,-104,126,26,136,-34,141,-57,148,-78,157,-94,168,-105,182,-109,198,-104,209,-90,216,-71,219,-52,220,-34,213,-34,210,-49,206,-61,201,-68,195,-72,187,-74,188,-74,177,-71,168,-63,160,-48,153,-27,147,1,138,41,342,228,332,230,316,230,290,224,273,209,262,187,256,162,254,136,253,103,249,69,239,39,223,17,197,9,197,225,155,225,155,9,129,17,112,39,103,69,99,104,98,137,96,163,90,188,78,210,61,224,36,230,31,230,25,229,14,229,10,228,10,220,30,210,42,190,49,164,52,137,52,114,55,72,65,39,84,15,114,0,155,-4,155,-107,197,-107,197,-4,236,0,265,16,285,41,296,74,300,114,300,137,303,164,310,190, +79,224,63,230,67,192,67,192,63,230,56,195,51,194,56,195,63,230,51,194,63,230,49,227,194,225,123,93,126,26,126,26,123,93,113,139,126,26,113,139,110,78,110,78,113,139,103,177,110,78,103,177,101,119,67,192,77,183,79,224,79,224,77,183,85,168,79,224,85,168,92,206,92,206,85,168,93,147,92,206,93,147,103,177,103,177,93,147,101,119,138,41,243,225,194,225,138,41,194,225,126,26,138,41,126,26,136,-34,138,41,136,-34,141,-57,138,41,141,-57,147,1,110,78,6,-104,55,-104,110,78,55,-104,126,26,210,-49,206,-61,209,-90,209,-90,206,-61,201,-68,209,-90,201,-68,198,-104,198,-104,201,-68,195,-72,198,-104,195,-72,188,-74,187,-74,188,-74,177,-71,187,-74,177,-71,182,-109,182,-109,177,-71,168,-105,177,-71,168,-63,168,-105,168,-105,168,-63,160,-48,168,-105,160,-48,157,-94,157,-94,160,-48,153,-27,157,-94,153,-27,148,-78,148,-78,153,-27,147,1,148,-78,147,1,141,-57,216,-71,219,-52,220,-34,216,-71,220,-34,213,-34,216,-71,213,-34,210,-49,216,-71,210,-49,209,-90,187,-74,182,-109,198,-104,187,-74,198,-104,188,-74,34,156,37,171,38,217,38,217,37,171,41,182,38,217,41,182,49,227,49,227,41,182,46,190,49,227,46,190,51,194,34,156,38,217,31,202,34,156,31,202,27,182,34,156,27,182,26,156, +342,228,332,230,316,230,290,224,273,209,262,187,256,162,254,136,253,103,249,69,239,39,223,17,197,9,197,225,155,225,155,9,129,17,112,39,103,69,99,104,98,137,96,163,90,188,78,210,61,224,36,230,31,230,25,229,14,229,10,228,10,220,30,210,42,190,49,164,52,137,52,114,55,72,65,39,84,15,114,0,155,-4,155,-107,197,-107,197,-4,236,0,265,16,285,41,296,74,300,114,300,137,303,164,310,190,322,211,342,221,180,223,206,218,226,203,240,179,249,146,252,104,252,76,248,51,242,29,229,14,210,9,200,12,190,20,181,33,174,51,170,73,173,85,177,105,178,115,179,127,177,145,174,158,169,168,163,173,156,175,149,173,143,168,138,159,135,145,133,126,134,114,135,103,137,94,139,84,142,73,138,51,132,33,123,20,113,12,100,9,82,15,71,31,64,54,61,81,60,109,63,149,73,180,88,204,108,218,132,223,132,230,94,225,62,211,37,186, +239,39,223,17,236,0,236,0,223,17,197,9,197,-107,197,9,155,-4,197,225,155,225,155,-4,197,225,155,-4,197,9,155,225,155,9,155,-4,155,-4,155,9,129,17,155,-4,129,17,114,0,114,0,129,17,112,39,114,0,112,39,103,69,99,104,98,137,96,163,99,104,96,163,90,188,99,104,90,188,84,15,99,104,84,15,103,69,52,114,55,72,61,224,61,224,55,72,65,39,61,224,65,39,78,210,78,210,65,39,84,15,78,210,84,15,90,188,42,190,49,164,61,224,61,224,49,164,52,137,61,224,52,137,52,114,61,224,36,230,42,190,42,190,36,230,31,230,42,190,31,230,30,210,30,210,31,230,25,229,30,210,25,229,19,229,14,229,10,228,30,210,14,229,30,210,19,229,262,187,256,162,265,16,265,16,256,162,254,136,265,16,254,136,253,103,342,221,342,228,337,229,342,221,337,229,332,230,342,221,332,230,327,230,342,221,327,230,322,211,303,164,310,190,316,230,316,230,310,190,322,211,316,230,322,211,321,230,321,230,322,211,327,230,262,187,265,16,273,209,273,209,265,16,285,41,273,209,285,41,290,224,290,224,285,41,296,74,290,224,296,74,300,137,300,137,296,74,300,114,290,224,300,137,303,164,290,224,303,164,316,230,265,16,253,103,249,69,265,16,249,69,239,39,265,16,239,39,236,0,197,9,197,-4,236,0,197,-107,155,-4,155,-107,30,210,10,228,10,220,103,69,84,15,114,0, +180,223,206,218,226,203,240,179,249,146,252,104,252,76,248,51,242,29,229,14,210,9,200,12,190,20,181,33,174,51,170,73,173,85,177,105,178,115,179,127,177,145,174,158,169,168,163,173,156,175,149,173,143,168,138,159,135,145,133,126,134,114,135,103,137,94,139,84,142,73,138,51,132,33,123,20,113,12,100,9,82,15,71,31,64,54,61,81,60,109,63,149,73,180,88,204,108,218,132,223,132,230,94,225,62,211,37,186,20,151,15,104,15,84,18,66,23,50,30,35,39,23,49,13,59,5,70,0,81,-3,93,-4,109,-2,123,3,136,12,147,26,156,43,164,26,175,12,187,3,202,-2,218,-4,230,-3,242,0,253,5,263,13,273,23,282,35,289,49,294,66,296,85,297,105,292,152,275,187,250,211,218,225,180,230,158,286,157,294,153,301,148,306,141,310,133,311,125,310,118,306,113,301,110,294,108,286,109,278,113,272,118,266,125,263,132,262,140,263,148,266,153,272,157,278,158,286,16383,16383,59,286,57,294,54,301,48,306,41,310,33,311,26,310,19,306,14,301,10,294,9,286,10,278,14,272,19,266,25,263,33,262,41,263,48,266,54,272,57,278,59,286,16383,16383,138,54,132,43,127,36,122,31,118,29,112,28,108,29,105,31,103,33,102,36,102,228,99,230,84,224,68,219,53,214,37,208,22,204,22,195,27,196,49,196,54,193,57,188,59,181,60,172,60,39,61,26,63,14,69,4,77,-2,89,-4,104,-1,117,7,128,20,138,35,146,50,202,286,201,294,197,301,192,306,185,310,177,311,169,310,162,306,157,301,154,294,152,286,154,278, +71,31,64,54,70,0,70,0,64,54,61,81,70,0,61,81,59,5,59,5,61,81,60,109,62,211,60,109,63,149,62,211,63,149,73,180,108,218,132,223,132,230,108,218,132,230,94,225,108,218,94,225,88,204,94,225,62,211,73,180,94,225,73,180,88,204,23,50,30,35,37,186,37,186,30,35,39,23,37,186,39,23,62,211,62,211,39,23,49,13,62,211,49,13,60,109,60,109,49,13,59,5,20,151,15,104,15,84,20,151,15,84,18,66,20,151,18,66,23,50,20,151,23,50,37,186,81,-3,93,-4,82,15,82,15,93,-4,100,9,113,12,100,9,109,-2,113,12,109,-2,123,3,71,31,70,0,81,-3,71,31,81,-3,82,15,174,51,170,73,175,12,174,158,170,73,173,85,174,158,173,85,175,95,177,145,174,158,175,95,177,145,175,95,177,105,177,145,177,105,178,115,177,145,178,115,179,127,156,175,156,43,163,173,163,173,156,43,164,26,163,173,164,26,169,168,169,168,164,26,170,73,169,168,170,73,174,158,174,51,175,12,181,33,181,33,175,12,187,3,181,33,187,3,190,20,190,20,187,3,202,-2,190,20,202,-2,200,12,200,12,202,-2,210,9,229,14,210,9,218,-4,229,14,218,-4,230,-3,282,35,289,49,292,152,292,152,289,49,294,66,292,152,294,66,297,105,297,105,294,66,296,85,275,187,250,211,252,104,275,187,252,104,253,5,275,187,253,5,263,13,275,187,263,13,273,23,275,187,273,23,282,35,275,187,282,35,292,152,240,179,249,146,250,211,250,211,249,146,252,104,253,5,252,104,252,76,240,179,250,211,226,203,226,203,250,211,218,225,226,203,218,225,206,218,206,218,218,225,180,230,206,218,180,230,180,223,229,14,230,-3,242,29,242,29,230,-3,242,0,242,29,242,0,248,51,248,51,242,0,253,5,248,51,253,5,252,76,210,9,202,-2,218,-4,139,84,142,73,143,168,143,168,142,73,147,26,143,168,147,26,149,173,149,173,147,26,156,43,149,173,156,43,156,175,147,26,142,73,138,51,147,26,138,51,136,12,136,12,138,51,132,33,136,12,132,33,123,3,123,3,132,33,123,20,123,3,123,20,113,12,138,159,135,145,135,103,138,159,135,103,137,94,138,159,137,94,139,84,138,159,139,84,143,168,135,145,133,126,134,114,135,145,134,114,135,103,100,9,93,-4,109,-2,170,73,164,26,175,12, +272,145,263,146,255,146,246,147,238,148,230,150,229,176,225,203,220,230,212,257,201,281,191,300,179,316,163,329,144,338,121,342,100,339,80,331,63,316,50,294,46,264,53,226,74,194,104,168,142,149,185,137,186,133,186,116,185,85,180,56,171,32,157,15,137,9,115,14,101,28,91,46,87,66,85,84,85,110,84,131,81,145,76,154,67,159,55,160,43,158,31,151,20,140,9,125,0,105,7,100,15,114,20,123,25,128,29,131,33,132,37,131,39,128,42,123,43,115,44,104,44,93,46,61,55,34,72,13,97,0,133,-4,172,3,200,26,217,58,227,95,230,134,247,134,256,135,272,137,16383,16383,185,161,141,182,112,208,95,235,86,260,84,280,86,295,91,307,99,316,109,321,119,323,135,320,149,310,162,289,173,253,181,200,181,198,182,193,183,184,184,174,185,161,198,208,186,255,169,291,146,317,117,332,81,337,67,336,53,332,39,327,26,319,15,311,18,303,25,305,33,308,41,310,49,311,55,312,84,306,109,289,130,257,146,211,157,147,157,61,156,39,153,25,144,16,130,12,107,9,107,0,260,0,260,9,239,11,224,15,215,23,210,36,209,55,209,126,211,167,220,219,236,270,261,309,296,325,299,325,305,323,308,321,309,319,307,315,296,304,291,295,289,285,290,276,294,268,301,262,308,259,318,257,329,259,338,265,344,273,348,284,349,295,346,309,339,320,329,330,317,336,303,338,268,330,241,308,221,277,207,242,199,208,176,342,134,342,134,230,126,230,86,224,55,206,32,180,19,149,15,114,19,79,33,47,55,20,85,2,123,-4,134,-4,134,-107,176,-107,176,-4,223,2,257,21,280,48,292,81,296,116,294,143,286,168,272,190, +20,123,25,128,31,151,31,151,25,128,29,131,31,151,29,131,33,132,33,132,37,131,43,158,43,158,37,131,39,128,43,158,39,128,42,123,0,105,7,100,9,125,9,125,7,100,15,114,9,125,15,114,20,140,20,140,15,114,20,123,20,140,20,123,31,151,44,104,46,61,55,160,55,160,46,61,55,34,55,160,55,34,67,159,67,159,55,34,72,13,67,159,72,13,76,154,76,154,72,13,87,66,76,154,87,66,85,84,85,84,85,110,84,131,85,84,84,131,81,145,85,84,81,145,76,154,121,342,119,323,135,320,121,342,135,320,144,338,144,338,135,320,149,310,144,338,149,310,163,329,163,329,149,310,162,289,163,329,162,289,173,253,180,56,171,32,172,3,172,3,171,32,157,15,172,3,157,15,137,9,137,9,115,14,133,-4,133,-4,115,14,101,28,133,-4,101,28,97,0,97,0,101,28,91,46,97,0,91,46,87,66,43,115,44,104,55,160,43,115,55,160,43,158,43,115,43,158,42,123,43,158,31,151,33,132,272,137,272,145,264,136,264,136,272,145,263,146,264,136,263,146,256,135,256,135,263,146,255,146,256,135,255,146,247,134,247,134,255,146,246,147,247,134,246,147,238,134,238,134,246,147,238,148,238,134,238,148,230,150,230,150,229,176,230,134,230,134,229,176,227,95,229,176,225,203,227,95,227,95,225,203,220,230,227,95,220,230,217,58,217,58,220,230,212,257,217,58,212,257,201,281,217,58,201,281,200,26,200,26,201,281,191,300,200,26,191,300,186,116,186,116,185,85,200,26,200,26,185,85,180,56,200,26,180,56,172,3,137,9,133,-4,172,3,238,134,230,150,230,134,91,307,99,316,100,339,100,339,99,316,109,321,100,339,109,321,121,342,121,342,109,321,119,323,80,331,84,280,86,295,80,331,86,295,100,339,100,339,86,295,91,307,191,300,179,316,181,200,191,300,181,200,181,198,191,300,181,198,182,193,191,300,182,193,183,184,191,300,183,184,184,174,191,300,184,174,185,161,191,300,185,161,185,137,191,300,185,137,186,133,191,300,186,133,186,129,191,300,186,129,186,124,191,300,186,124,186,120,191,300,186,120,186,116,185,161,141,182,142,149,185,161,142,149,185,137,112,208,95,235,104,168,112,208,104,168,142,149,112,208,142,149,141,182,86,260,84,280,74,194,86,260,74,194,104,168,86,260,104,168,95,235,84,280,80,331,74,194,74,194,80,331,63,316,74,194,63,316,53,226,53,226,63,316,50,294,53,226,50,294,46,264,173,253,181,200,179,316,173,253,179,316,163,329,46,61,44,104,44,93,87,66,72,13,97,0, +176,342,134,342,134,230,126,230,86,224,55,206,32,180,19,149,15,114,19,79,33,47,55,20,85,2,123,-4,134,-4,134,-107,176,-107,176,-4,223,2,257,21,280,48,292,81,296,116,294,143,286,168,272,190,254,208,230,222,221,225,211,228,189,230,176,230,16383,16383,176,9,176,216,203,210,225,193,240,168,249,137,252,102,249,73,243,48,231,27,214,14,191,9,16383,16383,135,9,125,10,114,13,104,18,95,25,86,34,77,51,69,70,64,91,61,113,60,137,62,164,70,186,82,202,99,212,120,216,135,216,363,183,363,225,77,225,53,219,33,204,18,183,8,160,3,137,11,137,18,152,27,164,36,174,48,181,61,183,84,183,76,169,69,153,64,137,61,120,60,103,64,64,76,34,92,12,112,0,134,-4,153,-2,169,3,182,12,193,26,201,43,210,25,221,12,233,2,247,-2,261,-4,286,0,309,12,327,33,339,63,343,102,342,119,340,136,336,153,329,169,320,183,16383,16383,279,183,285,171,291,155,295,138,297,120,298,103,297,76,293,51,286,29,275,15,258,9,246,12,236,20,226,33,219,51,215,74,218,82, +296,116,294,143,292,81,292,81,294,143,286,168,292,81,286,168,280,48,280,48,286,168,272,190,280,48,272,190,257,21,257,21,272,190,254,208,257,21,254,208,252,102,221,225,225,193,230,222,230,222,225,193,240,168,230,222,240,168,254,208,254,208,240,168,249,137,254,208,249,137,252,102,211,228,200,229,203,210,211,228,203,210,225,193,211,228,225,193,221,225,200,229,189,230,203,210,203,210,189,230,176,230,203,210,176,230,176,216,176,216,176,230,176,342,176,216,176,342,135,216,135,216,176,342,134,342,135,216,134,342,134,230,257,21,252,102,249,73,257,21,249,73,243,48,257,21,243,48,231,27,257,21,231,27,223,2,231,27,214,14,223,2,223,2,214,14,191,9,223,2,191,9,176,-4,176,-4,191,9,176,9,176,-4,176,9,176,-107,176,-107,176,9,135,216,176,-107,135,216,135,9,134,-4,134,-107,176,-107,134,-4,176,-107,135,9,134,-4,135,9,125,10,134,-4,125,10,123,-4,69,70,85,2,77,51,77,51,85,2,86,34,95,25,86,34,85,2,95,25,85,2,123,-4,82,202,86,224,70,186,70,186,86,224,55,206,70,186,55,206,62,164,62,164,55,206,60,137,61,113,60,137,55,20,61,113,55,20,64,91,64,91,55,20,85,2,64,91,85,2,69,70,123,-4,125,10,114,13,123,-4,114,13,104,18,123,-4,104,18,95,25,126,230,86,224,99,212,126,230,99,212,120,216,126,230,120,216,135,216,126,230,135,216,134,230,55,20,60,137,55,206,55,20,55,206,33,47,33,47,55,206,32,180,33,47,32,180,19,79,19,79,32,180,19,149,19,79,19,149,15,114,86,224,82,202,99,212,176,216,135,216,176,9, +363,183,363,225,77,225,53,219,33,204,18,183,8,160,3,137,11,137,18,152,27,164,36,174,48,181,61,183,84,183,76,169,69,153,64,137,61,120,60,103,64,64,76,34,92,12,112,0,134,-4,153,-2,169,3,182,12,193,26,201,43,210,25,221,12,233,2,247,-2,261,-4,286,0,309,12,327,33,339,63,343,102,342,119,340,136,336,153,329,169,320,183,16383,16383,279,183,285,171,291,155,295,138,297,120,298,103,297,76,293,51,286,29,275,15,258,9,246,12,236,20,226,33,219,51,215,74,218,82,220,90,222,99,224,115,223,126,221,138,217,149,211,156,202,159,193,156,186,149,182,139,180,127,179,116,180,107,181,99,185,81,188,74,183,51,176,33,167,19,156,12,143,9,126,15,115,30,108,52,106,76,105,99,106,118,108,137,112,153,118,169,125,183,155,-46,154,-68,151,-83,143,-91,129,-96,108,-98,108,-107,254,-107,254,-98,233,-96,219,-92,211,-84,207,-71,206,-52,206,-4,252,8,290,33,319,68,337,113,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,23,114,42,69,71,33,109,8,155,-4,16383,16383,287,169,285,134,280,103,272,76,260,53,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,52,90,75,81,102,76,132,74,166,76,194,80,222,87,247,97,269,108,286,121,298,134,308,149,314,164,318,180,320,194,319,207,316,219,311,231,305,242,296,257,279,270,257,279,231,285,201,287,169,103,-107,146,-107,146,-2,176,7,200,26,219,50,231,81,235,116,230,154,215,186,191,210,162,225,127,230,90,225,58,209,35,185,20,153,15,114, +11,137,18,152,18,183,18,183,18,152,27,164,18,183,27,164,33,204,33,204,27,164,36,174,33,204,36,174,53,219,53,219,36,174,48,181,53,219,48,181,61,183,77,225,61,183,84,183,77,225,84,183,363,225,363,225,84,183,125,183,363,225,125,183,279,183,8,160,3,137,11,137,8,160,11,137,18,183,108,137,112,153,84,183,84,183,112,153,118,169,84,183,118,169,125,183,108,52,112,0,115,30,115,30,112,0,134,-4,115,30,134,-4,126,15,126,15,134,-4,143,9,156,12,143,9,153,-2,156,12,153,-2,169,3,105,99,92,12,106,76,106,76,92,12,112,0,106,76,112,0,108,52,219,51,215,74,221,12,217,149,215,74,218,82,217,149,218,82,221,138,221,138,218,82,220,90,221,138,220,90,222,99,223,126,221,138,222,99,223,126,222,99,223,107,223,126,223,107,224,115,188,74,193,26,193,156,193,156,193,26,201,43,193,156,201,43,202,159,202,159,201,43,210,25,202,159,210,25,211,156,211,156,210,25,215,74,211,156,215,74,217,149,219,51,221,12,226,33,226,33,221,12,233,2,226,33,233,2,236,20,236,20,233,2,247,-2,236,20,247,-2,246,12,246,12,247,-2,258,9,275,15,258,9,261,-4,275,15,261,-4,286,0,363,225,279,183,285,171,363,225,285,171,291,155,363,225,291,155,320,183,363,225,320,183,363,183,340,136,336,153,339,63,339,63,336,153,329,169,339,63,329,169,327,33,327,33,329,169,320,183,327,33,320,183,309,12,309,12,320,183,298,103,291,155,295,138,320,183,320,183,295,138,297,120,320,183,297,120,298,103,106,118,108,137,84,183,106,118,84,183,92,12,106,118,92,12,105,99,340,136,339,63,343,102,340,136,343,102,342,119,309,12,298,103,297,76,309,12,297,76,293,51,309,12,293,51,286,29,309,12,286,29,286,0,258,9,247,-2,261,-4,186,149,182,139,183,90,186,149,183,90,185,81,186,149,185,81,188,74,186,149,188,74,193,156,179,116,180,107,180,127,180,127,180,107,181,99,180,127,181,99,182,139,182,139,181,99,183,90,193,26,188,74,183,51,193,26,183,51,182,12,182,12,183,51,176,33,182,12,176,33,169,3,169,3,176,33,167,19,169,3,167,19,156,12,143,9,134,-4,153,-2,76,169,69,153,76,34,76,169,76,34,92,12,76,169,92,12,84,183,64,137,61,120,64,64,64,137,64,64,76,34,64,137,76,34,69,153,64,64,61,120,60,103,275,15,286,0,286,29,61,183,77,225,53,219,215,74,210,25,221,12, +257,225,206,225,111,104,110,104,112,114,114,125,115,138,117,150,117,160,115,183,108,202,97,217,82,226,64,230,53,229,43,225,35,219,29,210,27,198,28,193,31,188,35,184,40,181,46,180,54,181,60,184,63,188,67,191,71,192,81,190,89,184,95,174,99,162,100,148,99,136,98,121,96,107,94,94,91,85,21,0,73,0,170,121,171,121,168,111,166,100,164,88,163,76,162,65,164,46,170,27,180,11,194,0,214,-4,225,-3,236,0,244,5,250,14,252,26,251,32,248,37,244,41,239,43,233,44,225,43,219,40,213,34,209,33,199,35,191,40,185,50,181,64,180,85,180,98,181,111,183,122,186,132,189,141,213,-107,214,-103,216,-93,217,-89,217,-86,202,-54,166,-40,119,-30,75,-8,44,40,45,40,55,24,69,11,86,2,106,-2,131,-4,166,1,195,18,217,44,230,75,235,110,230,150,217,183,195,208,166,224,129,230,83,221,50,197,29,163,18,126,15,89,15,69,16,49,18,29,22,10,28,-6,65,-50,110,-71,154,-79,189,-88,205,-107,16383,16383,190,108,188,82,183,55,173,32,157,15,133,9,105,17,85,37,70,66,62,101,60,137,63,166,71,188,83,203,100,213,120,216,141,210,160,195,175,171,186,142,190,108,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24, +95,174,97,217,89,184,89,184,97,217,82,226,89,184,82,226,81,190,81,190,82,226,71,192,67,191,71,192,82,226,67,191,82,226,64,230,206,225,111,104,170,121,170,121,111,104,94,94,170,121,94,94,91,85,91,85,21,0,73,0,112,114,114,125,115,183,115,183,114,125,115,138,115,183,115,138,117,160,117,160,115,138,117,150,110,104,112,114,115,183,110,104,115,183,108,202,110,104,108,202,100,148,110,104,100,148,99,136,110,104,99,136,98,121,110,104,98,121,96,107,110,104,96,107,94,94,110,104,94,94,111,104,191,40,185,50,194,0,194,0,185,50,181,64,194,0,181,64,180,11,180,11,181,64,180,85,171,121,180,85,180,98,171,121,180,98,181,111,186,132,189,141,206,225,186,132,206,225,183,122,183,122,206,225,171,121,183,122,171,121,181,111,206,225,189,141,257,225,99,162,100,148,108,202,99,162,108,202,97,217,91,85,73,0,170,121,225,43,219,40,225,-3,225,-3,219,40,216,37,225,-3,216,37,214,-4,214,-4,216,37,213,34,214,-4,213,34,209,33,209,33,199,35,214,-4,214,-4,199,35,194,0,252,26,251,32,250,14,250,14,251,32,248,37,250,14,248,37,244,5,244,5,248,37,244,41,244,5,244,41,239,43,225,43,225,-3,233,44,233,44,225,-3,236,0,233,44,236,0,239,43,239,43,236,0,244,5,171,121,168,111,170,27,171,121,170,27,180,11,171,121,180,11,180,85,166,100,164,88,164,46,166,100,164,46,170,27,166,100,170,27,168,111,163,76,162,65,164,46,163,76,164,46,164,88,64,230,53,229,54,181,64,230,54,181,60,184,64,230,60,184,63,188,64,230,63,188,67,191,35,184,40,181,43,225,43,225,40,181,46,180,43,225,46,180,53,229,53,229,46,180,54,181,27,198,28,193,29,210,29,210,28,193,31,188,29,210,31,188,35,219,35,219,31,188,35,184,35,219,35,184,43,225,97,217,95,174,99,162,191,40,194,0,199,35,206,225,170,121,171,121, +213,-107,214,-103,216,-93,217,-89,217,-86,202,-54,166,-40,119,-30,75,-8,44,40,45,40,55,24,69,11,86,2,106,-2,131,-4,166,1,195,18,217,44,230,75,235,110,230,150,217,183,195,208,166,224,129,230,83,221,50,197,29,163,18,126,15,89,15,69,16,49,18,29,22,10,28,-6,65,-50,110,-71,154,-79,189,-88,205,-107,16383,16383,190,108,188,82,183,55,173,32,157,15,133,9,105,17,85,37,70,66,62,101,60,137,63,166,71,188,83,203,100,213,120,216,141,210,160,195,175,171,186,142,190,108,344,166,336,222,314,269,280,306,235,330,180,338,126,330,81,307,46,271,24,224,17,167,24,109,46,61,81,24,126,1,180,-6,234,1,279,24,314,60,336,108,344,166,16383,16383,74,180,77,205,82,229,88,251,97,271,108,286,121,299,134,308,149,315,164,318,180,320,194,319,207,316,219,311,231,305,242,296,256,281,268,261,277,237,284,210,286,180,16383,16383,287,157,285,126,279,98,271,73,260,52,246,35,235,26,223,19,209,15,196,12,181,11,167,12,154,15,142,19,130,25,119,33,103,51,91,73,82,98, +28,-6,65,-50,44,40,44,40,65,-50,75,-8,75,-8,65,-50,110,-71,75,-8,110,-71,119,-30,119,-30,110,-71,154,-79,119,-30,154,-79,166,-40,166,-40,154,-79,189,-88,166,-40,189,-88,202,-54,202,-54,189,-88,205,-107,202,-54,205,-107,217,-86,217,-86,205,-107,213,-107,217,-86,213,-107,214,-103,55,24,69,11,60,137,60,137,63,166,50,197,50,197,63,166,71,188,50,197,71,188,83,221,83,221,71,188,83,203,83,221,83,203,129,230,129,230,83,203,100,213,129,230,100,213,120,216,120,216,141,210,129,230,129,230,141,210,166,224,133,9,106,-2,131,-4,133,9,131,-4,166,1,133,9,105,17,106,-2,86,2,106,-2,105,17,86,2,105,17,85,37,86,2,85,37,70,66,86,2,70,66,69,11,62,101,60,137,69,11,62,101,69,11,70,66,188,82,183,55,195,18,195,18,183,55,173,32,195,18,173,32,166,1,166,1,173,32,157,15,166,1,157,15,133,9,175,171,186,142,195,208,195,208,186,142,190,108,195,18,190,108,188,82,166,224,141,210,160,195,166,224,160,195,175,171,166,224,175,171,195,208,195,18,217,44,217,183,217,183,217,44,230,75,217,183,230,75,230,150,230,150,230,75,235,110,195,208,190,108,195,18,195,208,195,18,217,183,217,-86,214,-103,215,-98,217,-86,215,-98,216,-93,217,-86,216,-93,217,-89,16,49,18,29,18,126,18,126,18,29,22,10,18,126,22,10,29,163,29,163,22,10,28,-6,29,163,28,-6,44,40,18,126,15,89,15,69,18,126,15,69,16,49,44,40,45,40,50,197,50,197,45,40,55,24,50,197,55,24,60,137,50,197,29,163,44,40, +196,56,183,41,169,29,155,22,139,17,123,16,100,21,82,35,68,56,60,82,57,112,155,112,155,127,57,127,61,151,69,175,82,196,99,210,119,215,142,212,158,203,169,191,177,177,183,162,191,162,184,230,176,230,174,224,173,222,171,220,167,220,160,221,152,223,144,226,133,229,118,230,82,223,53,205,31,178,17,145,12,108,17,74,30,44,50,18,78,1,112,-4,136,-1,157,5,176,17,191,33,204,52,23,169,37,184,50,195,65,203,80,208,97,209,119,204,138,190,151,169,159,143,162,113,65,113,65,98,162,98,159,73,150,50,137,29,120,15,100,9,77,13,61,21,50,34,42,48,36,63,28,63,36,-4,44,-4,44,-1,46,3,52,5,60,4,67,1,76,0,87,-3,101,-4,137,2,167,20,189,47,202,80,207,117,203,150,190,181,169,207,142,224,108,230,84,227,62,220,44,208,28,192,16,172,243,411, +155,112,155,127,57,112,57,112,57,127,53,205,53,205,57,127,61,151,53,205,61,151,82,223,82,223,61,151,69,175,82,223,69,175,82,196,68,56,78,1,82,35,82,35,78,1,112,-4,82,35,112,-4,100,21,100,21,112,-4,123,16,139,17,123,16,136,-1,139,17,136,-1,157,5,60,82,57,112,50,18,60,82,50,18,78,1,60,82,78,1,68,56,12,108,17,74,17,145,17,145,17,74,30,44,17,145,30,44,31,178,31,178,30,44,50,18,31,178,50,18,53,205,53,205,50,18,57,112,158,203,169,191,160,221,160,221,169,191,167,220,171,220,167,220,169,191,171,220,169,191,177,177,184,230,176,230,177,177,184,230,177,177,183,162,184,230,183,162,191,162,177,177,176,230,175,227,177,177,175,227,174,224,177,177,174,224,173,222,177,177,173,222,171,220,133,229,119,215,142,212,133,229,142,212,144,226,144,226,142,212,158,203,144,226,158,203,152,223,152,223,158,203,160,221,204,52,196,56,191,33,191,33,196,56,183,41,191,33,183,41,176,17,176,17,183,41,169,29,176,17,169,29,157,5,157,5,169,29,155,22,157,5,155,22,139,17,123,16,112,-4,136,-1,118,230,82,223,82,196,118,230,82,196,99,210,118,230,99,210,119,215,118,230,119,215,133,229,57,127,57,112,155,127, +350,0,350,9,337,12,327,17,319,26,311,38,304,55,180,337,171,337,68,93,52,58,41,34,31,20,19,13,4,9,4,0,104,0,104,9,91,10,81,12,74,16,70,22,69,30,69,34,70,38,71,43,72,47,74,51,97,108,228,108,248,61,254,45,256,38,257,31,257,23,256,21,255,18,251,14,247,12,239,10,232,10,223,9,223,0,16383,16383,220,128,105,128,162,266,108,183,108,294,109,301,111,306,114,310,119,311,126,312,188,312,202,311,217,307,230,300,242,287,251,267,252,263,253,258,255,254,256,250,256,247,268,247,266,331,9,331,9,321,30,320,44,315,52,308,56,295,57,275,57,56,56,37,52,24,43,16,29,11,9,9,9,0,169,0,209,4,242,16,267,35,283,60,289,91,280,132,256,159,223,174,185,181,146,183,16383,16383,108,163, +52,58,70,22,69,30,69,30,69,34,68,93,68,93,69,34,70,38,68,93,70,38,71,43,243,11,239,10,350,0,350,0,239,10,232,10,350,0,232,10,223,9,72,47,74,51,171,337,171,337,74,51,97,108,171,337,97,108,105,128,105,128,97,108,228,108,105,128,228,108,220,128,220,128,228,108,304,55,220,128,304,55,180,337,256,21,255,18,350,0,350,0,255,18,253,16,350,0,253,16,251,14,251,14,247,12,350,0,350,0,247,12,243,11,257,26,350,0,327,17,257,26,327,17,319,26,257,26,319,26,311,38,257,26,311,38,304,55,257,26,304,55,257,31,304,55,228,108,248,61,304,55,248,61,251,53,304,55,251,53,254,45,304,55,254,45,256,38,304,55,256,38,257,31,171,337,105,128,162,266,171,337,162,266,220,128,171,337,220,128,180,337,68,93,52,58,69,30,72,47,171,337,68,93,72,47,68,93,71,43,337,12,327,17,350,0,337,12,350,0,350,9,257,23,256,21,350,0,257,23,350,0,257,26,104,0,104,9,91,10,104,0,91,10,81,12,104,0,81,12,41,34,104,0,41,34,31,20,104,0,31,20,19,13,104,0,19,13,4,9,104,0,4,9,4,0,41,34,81,12,74,16,41,34,74,16,70,22,41,34,70,22,52,58,350,0,223,9,223,0, +108,183,108,294,109,301,111,306,114,310,119,311,126,312,188,312,202,311,217,307,230,300,242,287,251,267,252,263,253,258,255,254,256,250,256,247,268,247,266,331,9,331,9,321,30,320,44,315,52,308,56,295,57,275,57,56,56,37,52,24,43,16,29,11,9,9,9,0,169,0,209,4,242,16,267,35,283,60,289,91,280,132,256,159,223,174,185,181,146,183,16383,16383,108,163,138,163,166,161,191,154,212,141,226,120,231,89,226,59,212,39,190,27,162,21,131,19,120,20,113,22,110,26,108,33,108,41,212,180,226,183,237,187,245,190,253,195,260,200,267,208,273,218,277,229,280,240,281,252,275,281,259,303,233,318,196,328,150,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,178,0,218,4,251,17,276,37,292,63,297,94,296,107,293,120,289,131,282,142,273,151,264,159,255,165,244,171,230,175,212,179,16383,16383,108,188,108,296,109,302,110,307,113,310,116,311,121,312,141,312,173,310,198,302,215,290,226,273,229,250,226,228,217,210,203,198, +52,24,43,16,169,0,169,0,43,16,29,11,169,0,29,11,9,9,44,315,52,308,266,331,266,331,52,308,119,311,266,331,119,311,126,312,266,331,126,312,188,312,266,331,188,312,202,311,217,307,230,300,266,331,266,331,230,300,242,287,266,331,242,287,251,267,251,267,252,263,266,331,266,331,252,263,253,258,266,331,253,258,255,254,266,331,255,254,256,250,266,331,256,250,256,247,266,331,256,247,268,247,57,275,108,33,108,41,108,183,108,163,138,163,108,183,138,163,146,183,146,183,138,163,166,161,146,183,166,161,185,181,185,181,166,161,191,154,185,181,191,154,223,174,223,174,191,154,212,141,223,174,212,141,226,120,57,275,108,41,108,294,57,275,108,294,109,301,57,275,109,301,111,306,57,275,111,306,114,310,57,275,114,310,56,295,119,311,52,308,56,295,119,311,56,295,114,310,30,320,44,315,266,331,30,320,266,331,9,331,30,320,9,331,9,321,231,89,226,59,242,16,242,16,226,59,212,39,242,16,212,39,209,4,209,4,212,39,190,27,209,4,190,27,169,0,169,0,190,27,162,21,169,0,162,21,131,19,131,19,120,20,169,0,169,0,120,20,113,22,169,0,113,22,56,37,56,37,113,22,57,56,231,89,242,16,256,159,256,159,242,16,267,35,256,159,267,35,280,132,280,132,267,35,283,60,280,132,283,60,289,91,226,120,231,89,256,159,226,120,256,159,223,174,57,56,113,22,110,26,57,56,110,26,108,33,57,56,108,33,57,275,169,0,9,9,9,0,52,24,169,0,56,37,266,331,202,311,217,307, +212,180,226,183,237,187,245,190,253,195,260,200,267,208,273,218,277,229,280,240,281,252,275,281,259,303,233,318,196,328,150,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,178,0,218,4,251,17,276,37,292,63,297,94,296,107,293,120,289,131,282,142,273,151,264,159,255,165,244,171,230,175,212,179,16383,16383,108,188,108,296,109,302,110,307,113,310,116,311,121,312,141,312,173,310,198,302,215,290,226,273,229,250,226,228,217,210,203,198,182,191,155,188,16383,16383,108,168,139,168,163,167,182,164,199,158,217,148,225,141,232,131,237,120,239,108,240,94,239,82,237,69,233,58,228,48,221,41,208,31,195,25,180,21,162,19,140,19,127,20,119,22,113,26,109,33,108,41,272,242,270,331,9,331,9,321,28,320,41,315,48,307,52,294,53,275,53,57,52,37,48,24,41,16,28,12,9,9,9,0,150,0,150,9,130,12,117,16,109,24,105,37,104,56,104,302,106,307,109,310,114,312,192,312,206,311,221,307,234,300,246,286,255,267,256,262,258,256,259,250,260,245,260,242,323,-75,323,9,303,11,291,17,283,27,279,40,278,57,278,274,280,293,283,307,291,315,304,319,323,321,323,331,47,331,47,321,62,320,75,316,83,308,88,295,90,275,87,172,79,97,65,46,45,18,17,9,7,9,7,-75,19,-75,19,-72,20,-67,21,-60,23,-54,24,-49,32,-29,43,-15,56,-5,71,0,259,0,274,-5,287,-15,298,-29,306,-49,307,-54,308,-60,309,-67,310,-72,311,-75,16383,16383,228,41,227,33,225,27,222,22,217,20, +52,24,43,16,178,0,178,0,43,16,30,11,178,0,30,11,9,9,56,295,57,275,113,310,56,295,113,310,150,331,150,331,113,310,116,311,150,331,116,311,121,312,150,331,121,312,141,312,150,331,141,312,173,310,208,31,195,25,218,4,218,4,195,25,180,21,218,4,180,21,178,0,178,0,180,21,162,19,178,0,162,19,140,19,140,19,127,20,178,0,178,0,127,20,119,22,178,0,119,22,56,37,56,37,119,22,57,56,259,303,233,318,237,187,237,187,233,318,229,250,237,187,229,250,226,228,237,187,226,228,226,183,226,183,226,228,217,210,226,183,217,210,212,180,212,180,217,210,203,198,212,180,203,198,212,179,212,179,203,198,217,148,212,179,217,148,230,175,230,175,217,148,225,141,155,188,163,167,182,191,182,191,163,167,182,164,182,191,182,164,203,198,203,198,182,164,199,158,203,198,199,158,217,148,237,69,233,58,251,17,251,17,233,58,228,48,251,17,228,48,221,41,221,41,208,31,218,4,163,167,155,188,139,168,139,168,155,188,108,188,139,168,108,188,108,168,109,33,108,41,57,275,109,33,57,275,57,56,57,56,119,22,113,26,57,56,113,26,109,33,273,151,264,159,276,37,276,37,264,159,255,165,276,37,255,165,251,17,251,17,255,165,244,171,251,17,244,171,240,94,240,94,239,82,251,17,251,17,239,82,237,69,244,171,230,175,232,131,244,171,232,131,237,120,244,171,237,120,239,108,244,171,239,108,240,94,233,318,196,328,198,302,233,318,198,302,215,290,233,318,215,290,226,273,233,318,226,273,229,250,196,328,150,331,173,310,196,328,173,310,198,302,57,275,108,41,108,296,57,275,108,296,109,302,57,275,109,302,110,307,57,275,110,307,113,310,150,331,9,331,30,320,150,331,30,320,44,316,150,331,44,316,52,308,150,331,52,308,56,295,267,208,273,218,275,281,275,281,273,218,277,229,275,281,277,229,281,252,281,252,277,229,280,240,245,190,253,195,259,303,259,303,253,195,260,200,259,303,260,200,275,281,275,281,260,200,267,208,293,120,289,131,292,63,293,120,292,63,297,94,293,120,297,94,296,107,282,142,273,151,276,37,282,142,276,37,292,63,282,142,292,63,289,131,221,41,218,4,251,17,259,303,237,187,245,190,30,320,9,331,9,321,230,175,225,141,232,131,178,0,9,9,9,0,52,24,178,0,56,37, +272,242,270,331,9,331,9,321,28,320,41,315,48,307,52,294,53,275,53,57,52,37,48,24,41,16,28,12,9,9,9,0,150,0,150,9,130,12,117,16,109,24,105,37,104,56,104,302,106,307,109,310,114,312,192,312,206,311,221,307,234,300,246,286,255,267,256,262,258,256,259,250,260,245,260,242,323,-75,323,9,303,11,291,17,283,27,279,40,278,57,278,274,280,293,283,307,291,315,304,319,323,321,323,331,47,331,47,321,62,320,75,316,83,308,88,295,90,275,87,172,79,97,65,46,45,18,17,9,7,9,7,-75,19,-75,19,-72,20,-67,21,-60,23,-54,24,-49,32,-29,43,-15,56,-5,71,0, +48,24,41,16,150,0,150,0,41,16,28,12,150,0,28,12,9,9,52,294,53,275,109,310,52,294,109,310,48,307,48,307,109,310,114,312,48,307,114,312,270,331,270,331,114,312,122,312,221,307,234,300,270,331,270,331,234,300,246,286,270,331,246,286,255,267,255,267,256,262,270,331,270,331,256,262,258,256,270,331,258,256,259,250,270,331,259,250,260,245,270,331,260,245,260,242,270,331,260,242,272,242,270,331,122,312,192,312,270,331,192,312,206,311,270,331,206,311,221,307,117,16,109,24,53,57,53,57,109,24,105,37,53,57,105,37,53,275,53,275,105,37,104,56,53,275,104,56,104,294,53,275,104,294,104,302,53,275,104,302,106,307,53,275,106,307,109,310,270,331,9,331,28,320,270,331,28,320,41,315,270,331,41,315,48,307,150,0,150,9,130,12,150,0,130,12,117,16,150,0,117,16,52,37,150,0,52,37,48,24,150,0,9,9,9,0,52,37,117,16,53,57,28,320,9,331,9,321, +323,-75,323,9,303,11,291,17,283,27,279,40,278,57,278,274,280,293,283,307,291,315,304,319,323,321,323,331,47,331,47,321,62,320,75,316,83,308,88,295,90,275,87,172,79,97,65,46,45,18,17,9,7,9,7,-75,19,-75,19,-72,20,-67,21,-60,23,-54,24,-49,32,-29,43,-15,56,-5,71,0,259,0,274,-5,287,-15,298,-29,306,-49,307,-54,308,-60,309,-67,310,-72,311,-75,16383,16383,228,41,227,33,225,27,222,22,217,20,209,19,76,19,91,48,101,88,108,141,112,209,113,294,113,303,115,308,119,311,124,312,210,312,217,311,222,310,225,306,227,301,228,294,304,84,290,84,276,57,260,38,239,27,211,21,174,19,137,19,122,21,113,25,107,32,105,42,105,164,181,164,203,162,218,158,227,150,234,136,238,115,249,115,249,232,238,232,234,211,227,198,218,189,203,185,181,184,105,184,105,294,106,302,108,307,111,310,116,312,189,312,218,311,239,306,252,297,261,282,266,259,278,259,276,331,11,331,11,321,30,320,43,315,50,307,54,294,55,275,55,57,54,37,50,24,43,16,30,12,11,9,11,0,281,0,507,0,507,9,476,18,453,32,435,52,417,79,394,113,382,130,370,144,359,155,345,164,330,172,329,173,342,181,354,193, +20,-67,21,-60,17,9,17,9,21,-60,23,-54,17,9,23,-54,24,-49,24,-49,32,-29,45,18,45,18,32,-29,43,-15,45,18,43,-15,56,-5,62,320,75,316,323,331,323,331,75,316,124,312,323,331,124,312,131,312,323,331,131,312,210,312,323,331,210,312,217,311,87,172,91,48,90,275,90,275,91,48,113,303,113,303,91,48,113,294,71,0,87,0,76,19,71,0,76,19,79,97,79,97,76,19,91,48,79,97,91,48,87,172,65,46,45,18,56,-5,65,46,56,-5,71,0,65,46,71,0,79,97,45,18,17,9,24,-49,17,9,7,9,19,-75,17,9,19,-75,19,-72,17,9,19,-72,20,-67,323,331,217,311,222,310,323,331,222,310,225,306,323,331,225,306,227,301,323,331,227,301,228,294,323,331,228,294,291,315,323,331,291,315,304,319,323,331,304,319,323,321,291,17,283,27,287,-15,287,-15,283,27,279,40,287,-15,279,40,274,-5,274,-5,279,40,278,57,274,-5,278,57,278,274,228,294,243,0,280,293,280,293,243,0,259,0,280,293,259,0,278,274,278,274,259,0,274,-5,283,307,291,315,228,294,283,307,228,294,280,293,113,294,91,48,101,88,113,294,101,88,108,141,113,294,108,141,112,209,124,312,83,308,119,311,119,311,83,308,88,295,119,311,88,295,115,308,115,308,88,295,90,275,115,308,90,275,113,303,47,331,47,321,62,320,47,331,62,320,323,331,308,-60,323,9,307,-54,307,-54,323,9,306,-49,298,-29,306,-49,303,11,298,-29,303,11,291,17,323,9,308,-60,309,-67,323,9,309,-67,310,-72,323,9,310,-72,311,-75,323,9,311,-75,323,-75,323,9,303,11,306,-49,209,19,76,19,87,0,209,19,87,0,243,0,209,19,243,0,217,20,243,0,228,294,228,41,243,0,228,41,227,33,243,0,227,33,225,27,243,0,225,27,222,22,243,0,222,22,217,20,19,-75,7,9,7,-75,291,17,287,-15,298,-29,124,312,75,316,83,308, +304,84,290,84,276,57,260,38,239,27,211,21,174,19,137,19,122,21,113,25,107,32,105,42,105,164,181,164,203,162,218,158,227,150,234,136,238,115,249,115,249,232,238,232,234,211,227,198,218,189,203,185,181,184,105,184,105,294,106,302,108,307,111,310,116,312,189,312,218,311,239,306,252,297,261,282,266,259,278,259,276,331,11,331,11,321,30,320,43,315,50,307,54,294,55,275,55,57,54,37,50,24,43,16,30,12,11,9,11,0,281,0,507,0,507,9,476,18,453,32,435,52,417,79,394,113,382,130,370,144,359,155,345,164,330,172,329,173,342,181,354,193,364,209,373,228,382,251,388,266,394,280,401,293,410,301,419,305,425,302,430,295,435,286,443,279,457,276,466,278,473,283,478,289,481,297,482,305,480,315,475,324,467,331,456,336,442,338,419,335,401,325,388,309,376,290,367,267,356,239,345,216,331,197,310,185,280,181,280,293,283,307,291,315,304,319,325,321,325,331,186,331,186,321, +50,24,43,16,281,0,281,0,43,16,30,12,281,0,30,12,11,9,54,294,55,275,111,310,54,294,111,310,50,307,50,307,111,310,116,312,50,307,116,312,276,331,276,331,116,312,123,312,50,24,122,21,54,37,54,37,122,21,113,25,54,37,113,25,55,57,55,57,113,25,107,32,55,57,107,32,55,275,55,275,107,32,105,42,55,275,105,42,105,294,105,184,105,164,181,164,105,184,181,164,181,184,203,185,181,184,203,162,203,185,203,162,218,189,218,189,203,162,218,158,218,189,218,158,227,198,227,198,218,158,227,150,227,198,227,150,234,211,234,211,227,150,234,136,234,211,234,136,238,232,238,232,234,136,238,115,238,232,238,115,249,115,276,331,123,312,189,312,276,331,189,312,218,311,276,331,218,311,239,306,276,331,239,306,252,297,276,331,252,297,261,282,276,331,261,282,266,259,276,331,266,259,278,259,55,275,105,294,106,302,55,275,106,302,108,307,55,275,108,307,111,310,276,331,11,331,30,320,276,331,30,320,43,315,276,331,43,315,50,307,260,38,239,27,281,0,281,0,239,27,211,21,281,0,211,21,174,19,281,0,304,84,290,84,281,0,290,84,276,57,281,0,276,57,260,38,281,0,174,19,156,19,281,0,156,19,137,19,281,0,137,19,122,21,281,0,122,21,50,24,281,0,11,9,11,0,30,320,11,331,11,321,181,184,181,164,203,162,238,232,249,115,249,232, +507,0,507,9,476,18,453,32,435,52,417,79,394,113,382,130,370,144,359,155,345,164,330,172,329,173,342,181,354,193,364,209,373,228,382,251,388,266,394,280,401,293,410,301,419,305,425,302,430,295,435,286,443,279,457,276,466,278,473,283,478,289,481,297,482,305,480,315,475,324,467,331,456,336,442,338,419,335,401,325,388,309,376,290,367,267,356,239,345,216,331,197,310,185,280,181,280,293,283,307,291,315,304,319,325,321,325,331,186,331,186,321,206,320,220,315,227,307,230,294,231,275,231,181,203,185,182,197,167,216,154,239,143,267,134,290,123,309,109,325,91,335,68,338,54,336,43,331,35,324,30,315,28,305,29,297,32,289,37,283,44,278,53,276,67,279,75,286,80,295,85,302,91,305,100,301,109,293,115,280,122,266,128,251,137,228,146,209,156,193,168,181,181,173,180,172,165,164,152,155,140,144,129,130,117,113,94,79,75,52,57,32,35,18,4,9,4,0,99,0,109,10,120,23,131,40,144,60,158,84,177,116,190,138,201,152,213,159,231,161,231,55,230,36,228,23,222,16,210,11,193,9,193,0,323,0,323,9,305,12,292,16,284,23,281,36,280,55,280,161,297,159,309,152,320,138,333,116,352,84,367,60,380,40,391,23,401,10,411,0,177,175,201,180,222,192,240,208,251,229,256,253,252,281,239,304,217,322,185,334,142,338,131,338,121,337,111,335,100,333,89,330,83,328,67,324,60,322,54,321,49,322,44,324,40,328,37,332,35,338,25,338,23,220,35,220,43,253,56,280,76,301,101,314,131,319,156,316,176,308,191,294,201,277,204,257,204,245,201,232,196,219,188,207,175,196,165,191,155,187,143,185,127,183,104,183,104,163,128,163,146,161,160,158,172,153,184,146,194,138,202,129,209,118,213,105,215,91,211,64,201,43,183,28,159,18,128,15,105,17,85,23,65,33,44,47,23,65,14,57,32,35,54,17,80,4,109,-3,141,-6,160,-6,177,-3,193,0,208,5,223,13,239,25,253,39,264,55,270,74,272,95,267,121,252,142,230,158,204,169,177,174,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,212,331,212,321,230,319,242,315,251,309,255,299,257,285,105,82,105,274,106,294,110,307,118,315,131,319,150,321,150,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,148,9,131,11,118,16,110,23,106,33,105,48,257,252,257,62,256,41,252,26,245,17, +75,52,57,32,99,0,99,0,57,32,35,18,99,0,35,18,4,9,75,286,80,295,91,335,91,335,80,295,85,302,91,335,85,302,91,305,91,305,100,301,109,325,109,325,100,301,109,293,109,325,109,293,115,280,44,278,53,276,54,336,54,336,53,276,67,279,54,336,67,279,68,338,68,338,67,279,75,286,68,338,75,286,91,335,28,305,29,297,30,315,30,315,29,297,32,289,30,315,32,289,35,324,35,324,32,289,37,283,35,324,37,283,43,331,43,331,37,283,44,278,43,331,44,278,54,336,115,280,122,266,123,309,123,309,122,266,128,251,123,309,128,251,134,290,134,290,128,251,137,228,134,290,137,228,143,267,143,267,137,228,146,209,143,267,146,209,154,239,154,239,146,209,156,193,154,239,156,193,167,216,167,216,156,193,168,181,167,216,168,181,182,197,182,197,168,181,181,173,182,197,181,173,190,138,190,138,181,173,180,172,228,23,222,16,323,0,323,0,222,16,210,11,323,0,210,11,193,9,304,319,325,321,325,331,304,319,325,331,291,315,291,315,325,331,230,294,291,315,230,294,231,275,231,161,231,275,231,181,231,161,284,23,281,36,323,0,323,9,305,12,323,0,305,12,292,16,323,0,292,16,230,36,323,0,230,36,228,23,280,55,280,181,231,161,280,55,231,161,281,36,231,55,230,36,292,16,231,55,292,16,284,23,231,55,284,23,231,161,280,161,297,159,280,181,280,181,280,274,231,161,231,161,280,274,280,293,231,161,280,293,283,307,283,307,291,315,231,275,283,307,231,275,231,161,325,331,186,331,206,320,325,331,206,320,220,315,325,331,220,315,227,307,325,331,227,307,230,294,453,32,435,52,411,0,411,0,435,52,417,79,411,0,417,79,401,10,401,10,417,79,394,113,401,10,394,113,391,23,391,23,394,113,382,130,391,23,382,130,380,40,380,40,382,130,370,144,380,40,370,144,367,60,367,60,370,144,359,155,367,60,359,155,352,84,352,84,359,155,345,164,352,84,345,164,333,116,333,116,345,164,330,172,333,116,330,172,329,173,476,18,453,32,411,0,476,18,411,0,507,0,476,18,507,0,507,9,320,138,329,173,331,197,331,197,329,173,342,181,331,197,342,181,345,216,345,216,342,181,354,193,345,216,354,193,356,239,356,239,354,193,364,209,356,239,364,209,367,267,367,267,364,209,373,228,367,267,373,228,376,290,376,290,373,228,382,251,376,290,382,251,388,309,388,309,382,251,388,266,388,309,388,266,401,325,401,325,388,266,394,280,401,325,394,280,401,293,310,185,280,181,297,159,310,185,297,159,309,152,310,185,309,152,320,138,310,185,320,138,331,197,442,338,419,335,425,302,425,302,419,335,419,305,410,301,419,305,419,335,410,301,419,335,401,325,457,276,466,278,467,331,467,331,466,278,473,283,467,331,473,283,475,324,475,324,473,283,478,289,475,324,478,289,480,315,480,315,478,289,481,297,480,315,481,297,482,305,430,295,435,286,442,338,442,338,435,286,443,279,442,338,443,279,456,336,456,336,443,279,457,276,456,336,457,276,467,331,190,138,201,152,203,185,203,185,201,152,213,159,203,185,213,159,231,181,231,181,213,159,231,161,99,0,109,10,117,113,117,113,109,10,120,23,117,113,120,23,129,130,129,130,120,23,131,40,129,130,131,40,140,144,140,144,131,40,144,60,140,144,144,60,152,155,152,155,144,60,158,84,152,155,158,84,165,164,165,164,158,84,177,116,165,164,177,116,180,172,180,172,177,116,190,138,94,79,75,52,99,0,94,79,99,0,117,113,109,325,91,335,91,305,109,325,115,280,123,309,99,0,4,9,4,0,182,197,190,138,203,185,333,116,329,173,320,138,442,338,425,302,430,295,401,325,401,293,410,301,206,320,186,331,186,321,323,0,193,9,193,0, +177,175,201,180,222,192,240,208,251,229,256,253,252,281,239,304,217,322,185,334,142,338,131,338,121,337,111,335,100,333,89,330,83,328,67,324,60,322,54,321,49,322,44,324,40,328,37,332,35,338,25,338,23,220,35,220,43,253,56,280,76,301,101,314,131,319,156,316,176,308,191,294,201,277,204,257,204,245,201,232,196,219,188,207,175,196,165,191,155,187,143,185,127,183,104,183,104,163,128,163,146,161,160,158,172,153,184,146,194,138,202,129,209,118,213,105,215,91,211,64,201,43,183,28,159,18,128,15,105,17,85,23,65,33,44,47,23,65,14,57,32,35,54,17,80,4,109,-3,141,-6,160,-6,177,-3,193,0,208,5,223,13,239,25,253,39,264,55,270,74,272,95,267,121,252,142,230,158,204,169,177,174,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,212,331,212,321,230,319,242,315,251,309,255,299,257,285,105,82,105,274,106,294,110,307,118,315,131,319,150,321,150,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,148,9,131,11,118,16,110,23,106,33,105,48,257,252,257,62,256,41,252,26,245,17,232,12,213,9,213,0,248,424,246,436,242,445,235,452,227,456,219,458,211,456,208,453,206,450,205,445,207,438,213,434,225,430,227,425,226,418,221,413,212,408,199,406,180,405,162,406,149,408,140,413,135,418,134,425,136,430,148,434,154,438,156,445,156,450,154,453,151,456,148,457, +40,328,43,253,44,324,44,324,43,253,56,280,44,324,56,280,49,322,49,322,56,280,54,321,60,322,54,321,56,280,60,322,56,280,76,301,201,232,196,219,201,180,201,180,196,219,188,207,201,180,188,207,177,175,177,175,188,207,175,196,177,175,175,196,177,174,177,174,175,196,172,153,172,153,175,196,165,191,172,153,165,191,160,158,160,158,165,191,155,187,160,158,155,187,146,161,146,161,155,187,143,185,146,161,143,185,128,163,128,163,143,185,127,183,128,163,127,183,104,183,23,65,32,35,44,47,44,47,32,35,54,17,44,47,54,17,65,33,65,33,54,17,80,4,65,33,80,4,85,23,85,23,80,4,109,-3,85,23,109,-3,105,17,105,17,109,-3,128,15,159,18,128,15,141,-6,159,18,141,-6,160,-6,131,319,121,337,111,335,131,319,111,335,101,314,131,319,131,338,121,337,101,314,111,335,100,333,101,314,100,333,89,330,101,314,89,330,83,328,101,314,83,328,76,301,76,301,83,328,75,326,76,301,75,326,67,324,76,301,67,324,60,322,156,316,176,308,185,334,185,334,176,308,191,294,185,334,191,294,217,322,217,322,191,294,201,277,217,322,201,277,204,257,204,257,204,245,222,192,222,192,204,245,201,232,222,192,201,232,201,180,156,316,185,334,142,338,156,316,142,338,131,338,156,316,131,338,131,319,217,322,222,192,239,304,239,304,222,192,240,208,239,304,240,208,252,281,252,281,240,208,251,229,252,281,251,229,256,253,204,257,222,192,217,322,177,174,172,153,184,146,184,146,194,138,204,169,204,169,194,138,202,129,204,169,202,129,209,118,267,121,252,142,253,39,267,121,253,39,264,55,267,121,264,55,270,74,267,121,270,74,272,95,160,-6,177,-3,183,28,183,28,177,-3,193,0,183,28,193,0,201,43,201,43,193,0,208,5,201,43,208,5,211,64,211,64,208,5,223,13,211,64,223,13,215,91,215,91,223,13,230,158,230,158,223,13,239,25,230,158,239,25,252,142,252,142,239,25,253,39,204,169,209,118,230,158,230,158,209,118,213,105,230,158,213,105,215,91,204,169,177,174,184,146,128,15,109,-3,141,-6,40,328,37,332,43,253,43,253,37,332,35,338,43,253,35,338,35,220,35,220,35,338,25,338,35,220,25,338,23,220,32,35,23,65,14,57,159,18,160,-6,183,28,128,163,104,183,104,163, +352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,212,331,212,321,230,319,242,315,251,309,255,299,257,285,105,82,105,274,106,294,110,307,118,315,131,319,150,321,150,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,148,9,131,11,118,16,110,23,106,33,105,48,257,252,257,62,256,41,252,26,245,17,232,12,213,9,213,0,248,424,246,436,242,445,235,452,227,456,219,458,211,456,208,453,206,450,205,445,207,438,213,434,225,430,227,425,226,418,221,413,212,408,199,406,180,405,162,406,149,408,140,413,135,418,134,425,136,430,148,434,154,438,156,445,156,450,154,453,151,456,148,457,144,458,135,456,127,452,120,445,115,436,113,424,117,408,129,395,145,386,163,380,180,378,198,380,216,385,232,395,243,407,248,424,16383,16383,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293, +50,25,42,16,149,0,149,0,42,16,29,12,149,0,29,12,9,9,257,285,105,82,105,48,105,48,105,274,54,274,54,274,105,274,106,294,54,274,106,294,110,307,150,331,9,331,29,319,150,331,29,319,42,315,150,331,42,315,50,307,150,331,50,307,53,294,150,331,53,294,118,315,150,331,118,315,131,319,150,331,131,319,150,321,54,274,110,307,118,315,54,274,118,315,53,294,252,26,245,17,352,0,352,0,245,17,232,12,352,0,232,12,213,9,242,315,251,309,352,331,352,331,251,309,255,299,352,331,255,299,257,285,257,285,257,252,309,37,309,37,257,252,257,62,309,37,257,62,312,25,312,25,257,62,320,17,333,319,352,321,352,331,333,319,352,331,320,315,320,315,352,331,257,285,320,315,257,285,312,307,312,307,257,285,309,293,307,55,307,274,257,285,307,55,257,285,309,37,230,319,242,315,352,331,230,319,352,331,212,331,230,319,212,331,212,321,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,256,41,352,0,256,41,252,26,149,0,148,9,131,11,149,0,131,11,118,16,149,0,118,16,53,39,149,0,53,39,50,25,106,33,105,48,54,274,106,33,54,274,54,61,106,33,54,61,110,23,54,61,53,39,118,16,54,61,118,16,110,23,149,0,9,9,9,0,352,0,213,9,213,0,256,41,320,17,257,62,309,293,257,285,307,274,257,285,105,48,257,252,29,319,9,331,9,321, +248,424,246,436,242,445,235,452,227,456,219,458,211,456,208,453,206,450,205,445,207,438,213,434,225,430,227,425,226,418,221,413,212,408,199,406,180,405,162,406,149,408,140,413,135,418,134,425,136,430,148,434,154,438,156,445,156,450,154,453,151,456,148,457,144,458,135,456,127,452,120,445,115,436,113,424,117,408,129,395,145,386,163,380,180,378,198,380,216,385,232,395,243,407,248,424,16383,16383,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,212,331,212,321,230,319,242,316,250,310,254,300,256,285,105,82,105,274,106,294,110,307,118,315,131,319,150,321,150,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,148,9,131,11,119,15,111,22,107,33,105,48,257,252,257,62,256,41,252,26,245,17,232,12,213,9,213,0,343,0,343,9,321,13,312,17,302,23,292,30,282,40,271,54,259,71,246,92,230,114,218,131,206,145,193,155,180,164,164,171,164,172,178,181,190,193,201,208,211,227,220,251,225,266,232,281,239,294,247,303,257,306,263,303,267,296,272,287,281,280,294,277,303,279,310,284,315,291,318,299,319,306,317,317,313,325,305,332,295,337,281,338,257,335,239,325,224,309,213,290,204,267,196,245,187,226,176,209,162,195,142,185,137,183,131,182,124,181,106,181,106,274,107,293,110,307,117,315,130,319,151,321,151,331,10,331,10,321,30,319,43,315,51,306,54,293,55,275,55,65,54,42,51,27,43,17,29,12,9,9,9,0,151,0,151,9,132,12,119,16,111,23,107,36,106,55,106,161,113,161,119,160,125,158,130,156,134,154,140,149,149,140,160,126,174,108,189,85,203,61,216,40,227,24,238,10,248,0,332,0,332,9,313,12,300,17,292,25,288,37,287,55, +149,408,140,413,145,386,145,386,140,413,135,418,145,386,135,418,129,395,129,395,135,418,134,425,135,456,134,425,136,430,135,456,136,430,144,458,144,458,136,430,142,432,144,458,142,432,148,434,148,457,148,434,151,456,151,456,148,434,154,438,151,456,154,438,154,453,154,453,154,438,156,445,154,453,156,445,156,450,129,395,134,425,135,456,129,395,135,456,127,452,129,395,127,452,120,445,129,395,120,445,117,408,115,436,113,424,117,408,115,436,117,408,120,445,149,408,163,380,162,406,162,406,163,380,180,405,199,406,180,405,180,378,199,406,180,378,198,380,246,436,242,445,243,407,243,407,242,445,235,452,243,407,235,452,232,395,232,395,235,452,227,456,232,395,227,456,227,425,227,456,219,458,219,432,227,456,219,432,225,430,227,456,225,430,227,425,215,457,211,456,213,434,215,457,213,434,219,432,215,457,219,432,219,458,208,453,206,450,207,438,208,453,207,438,213,434,208,453,213,434,211,456,227,425,226,418,232,395,232,395,226,418,221,413,232,395,221,413,216,385,216,385,221,413,212,408,216,385,212,408,199,406,180,405,163,380,180,378,50,25,42,16,149,0,149,0,42,16,29,12,149,0,29,12,9,9,119,15,111,22,54,61,54,61,111,22,107,33,54,61,107,33,54,274,54,274,107,33,105,48,105,82,105,48,256,285,150,331,9,331,29,319,150,331,29,319,42,315,150,331,42,315,50,307,150,331,50,307,53,294,150,331,53,294,118,315,150,331,118,315,131,319,150,331,131,319,150,321,105,274,106,294,54,274,105,274,54,274,105,48,105,274,105,48,105,82,54,274,106,294,110,307,54,274,110,307,118,315,54,274,118,315,53,294,252,26,245,17,352,0,352,0,245,17,232,12,352,0,232,12,213,9,352,331,212,331,230,319,352,331,230,319,242,316,352,331,242,316,250,310,352,331,250,310,254,300,352,331,254,300,256,285,352,331,256,285,320,315,352,331,320,315,333,319,352,331,333,319,352,321,320,17,312,25,257,62,257,62,312,25,309,37,257,62,309,37,257,252,257,252,309,37,307,55,257,252,307,55,307,274,257,252,307,274,309,293,257,252,309,293,312,307,257,252,312,307,320,315,257,252,320,315,256,285,257,252,256,285,105,48,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,256,41,352,0,256,41,252,26,149,0,148,9,131,11,149,0,131,11,119,15,149,0,119,15,53,39,149,0,53,39,50,25,149,0,9,9,9,0,53,39,119,15,54,61,352,0,213,9,213,0,256,41,320,17,257,62,230,319,212,331,212,321,29,319,9,331,9,321,199,406,198,380,216,385,246,436,243,407,248,424,207,438,206,450,205,445,149,408,145,386,163,380,144,458,148,434,148,457, +343,0,343,9,321,13,312,17,302,23,292,30,282,40,271,54,259,71,246,92,230,114,218,131,206,145,193,155,180,164,164,171,164,172,178,181,190,193,201,208,211,227,220,251,225,266,232,281,239,294,247,303,257,306,263,303,267,296,272,287,281,280,294,277,303,279,310,284,315,291,318,299,319,306,317,317,313,325,305,332,295,337,281,338,257,335,239,325,224,309,213,290,204,267,196,245,187,226,176,209,162,195,142,185,137,183,131,182,124,181,106,181,106,274,107,293,110,307,117,315,130,319,151,321,151,331,10,331,10,321,30,319,43,315,51,306,54,293,55,275,55,65,54,42,51,27,43,17,29,12,9,9,9,0,151,0,151,9,132,12,119,16,111,23,107,36,106,55,106,161,113,161,119,160,125,158,130,156,134,154,140,149,149,140,160,126,174,108,189,85,203,61,216,40,227,24,238,10,248,0,332,0,332,9,313,12,300,17,292,25,288,37,287,55,287,274,288,293,292,307,300,315,313,319,332,321,332,331,65,331,65,321,80,320,93,316,101,308,107,295,108,275,108,112,105,78,100,47,89,26,73,17,65,21,54,43,46,53,32,57,25,56,18,53,11,48,6,40,4,30,7,14,14,4,25,-2,39,-5,55,-6,92,2,114,27,126,60,130,97,131,131,131,292,132,300,133,305,136,309,141,311,148,312,219,312,226,311,231,309,234,305,236,300,237,292,237,63,236,41,232,26,225,17,212,12,193,9,193,0,435,0,435,9,417,12,404,17,397,25,393,38,392,56,392,275,393,294,397,307,404,316,417,320,435,321,435,331,335,331,225,80,109,331,11,331,11,321,31,319,45,315,53,307,57,294,58,275,58,75,57,47,53,29,44,18,30,12,9,9,9,0,127,0,127,9,107,12,94,18,85,29, +151,0,151,9,132,12,151,0,132,12,119,16,151,0,119,16,54,42,151,0,54,42,51,27,151,0,51,27,43,17,151,0,43,17,29,12,151,0,29,12,9,9,151,0,9,9,9,0,55,275,107,36,106,55,106,181,106,161,113,161,55,275,106,55,106,181,106,181,113,161,116,181,116,181,113,161,119,160,116,181,119,160,124,181,124,181,119,160,125,158,124,181,125,158,131,182,131,182,125,158,130,156,131,182,130,156,134,154,134,154,140,149,137,183,137,183,140,149,142,185,162,195,142,185,149,140,162,195,149,140,160,126,55,65,54,42,119,16,55,65,119,16,111,23,55,65,111,23,107,36,55,65,107,36,55,275,151,331,10,331,30,319,151,331,30,319,43,315,151,331,43,315,51,306,151,331,51,306,54,293,151,331,54,293,117,315,151,331,117,315,130,319,151,331,130,319,151,321,106,274,107,293,55,275,106,274,55,275,106,181,55,275,107,293,110,307,55,275,110,307,117,315,55,275,117,315,54,293,137,183,131,182,134,154,196,245,187,226,190,193,196,245,190,193,201,208,196,245,201,208,204,267,190,193,187,226,178,181,178,181,187,226,176,209,178,181,176,209,164,172,164,172,176,209,162,195,164,172,162,195,164,171,164,171,162,195,160,126,164,171,160,126,174,108,225,266,232,281,239,325,239,325,232,281,239,294,239,325,239,294,257,335,257,335,239,294,247,303,257,335,247,303,257,306,257,306,263,303,257,335,257,335,263,303,281,338,204,267,211,227,213,290,213,290,211,227,220,251,213,290,220,251,224,309,224,309,220,251,225,266,224,309,225,266,239,325,332,11,321,13,343,0,343,0,321,13,312,17,343,0,312,17,248,0,248,0,312,17,302,23,248,0,302,23,292,30,292,30,282,40,248,0,248,0,282,40,271,54,248,0,271,54,259,71,193,155,189,85,203,61,193,155,203,61,206,145,206,145,203,61,216,40,206,145,216,40,218,131,218,131,216,40,227,24,218,131,227,24,230,114,230,114,227,24,238,10,230,114,238,10,246,92,246,92,238,10,248,0,246,92,248,0,259,71,272,287,281,280,281,338,281,338,281,280,294,277,281,338,294,277,295,337,295,337,294,277,303,279,295,337,303,279,305,332,305,332,303,279,310,284,305,332,310,284,313,325,313,325,310,284,315,291,313,325,315,291,317,317,317,317,315,291,318,299,317,317,318,299,319,306,281,338,263,303,267,296,281,338,267,296,272,287,180,164,164,171,174,108,180,164,174,108,189,85,180,164,189,85,193,155,142,185,140,149,149,140,332,11,343,0,343,9,211,227,204,267,201,208,30,319,10,331,10,321, +332,0,332,9,313,12,300,17,292,25,288,37,287,55,287,274,288,293,292,307,300,315,313,319,332,321,332,331,65,331,65,321,80,320,93,316,101,308,107,295,108,275,108,112,105,78,100,47,89,26,73,17,65,21,54,43,46,53,32,57,25,56,18,53,11,48,6,40,4,30,7,14,14,4,25,-2,39,-5,55,-6,92,2,114,27,126,60,130,97,131,131,131,292,132,300,133,305,136,309,141,311,148,312,219,312,226,311,231,309,234,305,236,300,237,292,237,63,236,41,232,26,225,17,212,12,193,9,193,0,435,0,435,9,417,12,404,17,397,25,393,38,392,56,392,275,393,294,397,307,404,316,417,320,435,321,435,331,335,331,225,80,109,331,11,331,11,321,31,319,45,315,53,307,57,294,58,275,58,75,57,47,53,29,44,18,30,12,9,9,9,0,127,0,127,9,107,12,94,18,85,29,81,48,80,75,80,275,206,0,213,0,340,286,340,40,336,26,328,17,315,12,296,9,296,0,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,213,331,213,321, +108,112,105,78,114,27,114,27,105,78,100,47,114,27,100,47,92,2,92,2,100,47,89,26,92,2,89,26,73,17,73,17,65,21,92,2,92,2,65,21,55,-6,107,295,108,275,136,309,107,295,136,309,101,308,101,308,136,309,141,311,101,308,141,311,332,331,332,331,141,311,148,312,232,26,225,17,332,0,332,0,225,17,212,12,332,0,212,12,193,9,332,331,148,312,219,312,332,331,219,312,226,311,332,331,226,311,231,309,332,331,231,309,234,305,332,331,234,305,236,300,332,331,236,300,237,292,332,331,237,292,300,315,332,331,300,315,313,319,332,331,313,319,332,321,287,55,287,274,237,292,237,292,287,274,288,293,237,292,288,293,292,307,300,17,292,25,237,63,237,63,292,25,288,37,237,63,288,37,237,292,131,292,132,300,114,27,131,292,114,27,126,60,131,292,126,60,130,97,131,292,130,97,131,131,108,275,108,145,114,27,108,275,114,27,132,300,108,275,132,300,133,305,108,275,133,305,136,309,332,331,65,331,80,320,332,331,80,320,93,316,332,331,93,316,101,308,332,0,332,9,313,12,332,0,313,12,300,17,332,0,300,17,236,41,332,0,236,41,232,26,55,-6,65,21,60,31,55,-6,60,31,54,43,55,-6,54,43,46,53,55,-6,46,53,39,-5,46,53,32,57,39,-5,39,-5,32,57,25,56,39,-5,25,56,25,-2,25,-2,25,56,18,53,25,-2,18,53,14,4,14,4,18,53,11,48,14,4,11,48,7,14,7,14,11,48,6,40,7,14,6,40,4,30,108,112,114,27,108,145,332,0,193,9,193,0,236,41,300,17,237,63,237,292,288,37,287,55,80,320,65,331,65,321,300,315,237,292,292,307, +435,0,435,9,417,12,404,17,397,25,393,38,392,56,392,275,393,294,397,307,404,316,417,320,435,321,435,331,335,331,225,80,109,331,11,331,11,321,31,319,45,315,53,307,57,294,58,275,58,75,57,47,53,29,44,18,30,12,9,9,9,0,127,0,127,9,107,12,94,18,85,29,81,48,80,75,80,275,206,0,213,0,340,286,340,40,336,26,328,17,315,12,296,9,296,0,352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,213,331,213,321,232,319,245,315,252,307,256,294,257,274,257,180,105,180,105,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17, +53,29,44,18,127,0,127,0,44,18,30,12,127,0,30,12,9,9,336,26,328,17,435,0,435,0,328,17,315,12,435,0,315,12,296,9,417,320,435,321,435,331,417,320,435,331,404,316,404,316,435,331,340,286,404,316,340,286,397,307,397,307,340,286,393,294,404,17,397,25,340,61,340,61,397,25,393,38,340,61,393,38,340,286,340,286,393,38,392,56,340,286,392,56,392,275,206,0,213,0,225,80,225,80,213,0,340,286,225,80,340,286,335,331,335,331,340,286,435,331,109,331,11,331,31,319,109,331,31,319,45,315,109,331,45,315,53,307,109,331,53,307,57,294,109,331,57,294,58,275,109,331,58,275,80,275,109,331,80,275,206,0,109,331,206,0,225,80,80,75,80,275,58,275,80,75,58,275,81,48,81,48,58,275,58,75,81,48,58,75,85,29,85,29,58,75,57,47,85,29,57,47,94,18,94,18,57,47,53,29,94,18,53,29,127,0,435,0,435,9,417,12,435,0,417,12,404,17,435,0,404,17,340,40,435,0,340,40,336,26,107,12,94,18,127,0,107,12,127,0,127,9,127,0,9,9,9,0,435,0,296,9,296,0,340,40,404,17,340,61,31,319,11,331,11,321,393,294,340,286,392,275, +352,0,352,9,333,12,320,17,312,25,309,37,307,55,307,274,309,293,312,307,320,315,333,319,352,321,352,331,213,331,213,321,232,319,245,315,252,307,256,294,257,274,257,180,105,180,105,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17,110,25,106,38,105,56,105,157,257,157,257,62,256,41,252,26,245,17,232,12,213,9,213,0,345,166,337,222,316,269,281,306,236,330,181,338,127,330,82,307,47,271,26,224,18,167,26,109,47,61,82,24,127,1,181,-6,235,1,280,24,315,60,337,108,345,166,16383,16383,288,169,286,134,281,103,273,76,261,53,247,35,235,26,223,19,210,15,197,12,182,11,168,12,155,15,143,19,131,25,120,33,103,52,91,75,82,102,77,132,75,166,76,194,81,222,88,247,98,269,109,286,122,298,135,308,150,314,165,318,181,320,194,319,207,316,220,311,231,305,243,296,258,279,271,257, +50,25,42,16,149,0,149,0,42,16,29,12,149,0,29,12,9,9,149,331,9,331,29,319,149,331,29,319,42,315,149,331,42,315,50,307,149,331,50,307,53,294,149,331,53,294,118,315,149,331,118,315,130,319,149,331,130,319,149,321,54,274,106,38,105,56,105,180,105,157,257,157,105,180,257,157,257,180,257,180,257,157,312,25,257,180,312,25,309,37,54,274,105,56,105,274,54,274,105,274,106,294,54,274,106,294,110,307,54,274,110,307,118,315,54,274,118,315,53,294,252,26,245,17,352,0,352,0,245,17,232,12,352,0,232,12,213,9,333,319,352,321,352,331,333,319,352,331,320,315,320,315,352,331,256,294,320,315,256,294,257,274,309,37,257,274,257,180,307,55,307,274,257,274,257,274,307,274,309,293,257,274,309,293,312,307,352,331,213,331,232,319,352,331,232,319,245,315,352,331,245,315,252,307,352,331,252,307,256,294,352,0,352,9,333,12,352,0,333,12,320,17,352,0,320,17,256,41,352,0,256,41,252,26,257,62,256,41,320,17,257,62,320,17,312,25,257,62,312,25,257,157,149,0,149,9,130,12,149,0,130,12,118,17,149,0,118,17,53,39,149,0,53,39,50,25,54,61,53,39,118,17,54,61,118,17,110,25,54,61,110,25,106,38,54,61,106,38,54,274,149,0,9,9,9,0,352,0,213,9,213,0,257,274,309,37,307,55,232,319,213,331,213,321,320,315,257,274,312,307,29,319,9,331,9,321, +345,166,337,222,316,269,281,306,236,330,181,338,127,330,82,307,47,271,26,224,18,167,26,109,47,61,82,24,127,1,181,-6,235,1,280,24,315,60,337,108,345,166,16383,16383,288,169,286,134,281,103,273,76,261,53,247,35,235,26,223,19,210,15,197,12,182,11,168,12,155,15,143,19,131,25,120,33,103,52,91,75,82,102,77,132,75,166,76,194,81,222,88,247,98,269,109,286,122,298,135,308,150,314,165,318,181,320,194,319,207,316,220,311,231,305,243,296,258,279,271,257,280,231,286,201,288,169,353,0,353,9,333,12,321,17,313,25,309,37,308,55,308,274,309,293,313,307,321,315,334,319,353,321,353,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17,110,25,106,38,105,56,105,300,107,306,111,309,116,311,124,312,238,312,246,311,251,309,255,306,257,300,257,62,256,41,253,26,246,17,233,12,213,9,213,0,9,331,9,321,28,319,40,315,47,307,51,294,51,39,48,25,41,16,29,12,9,9, +150,314,181,338,135,308,135,308,181,338,127,330,135,308,127,330,122,298,122,298,127,330,109,286,98,269,109,286,127,330,98,269,127,330,82,307,82,102,82,24,91,75,91,75,82,24,127,1,91,75,127,1,103,52,103,52,127,1,120,33,131,25,120,33,127,1,131,25,127,1,181,-6,236,330,181,338,194,319,194,319,181,338,181,320,165,318,181,320,181,338,165,318,181,338,150,314,223,19,210,15,235,1,235,1,210,15,197,12,235,1,197,12,182,11,182,11,168,12,181,-6,181,-6,168,12,155,15,181,-6,155,15,143,19,207,316,220,311,236,330,236,330,220,311,231,305,236,330,231,305,243,296,243,296,258,279,281,306,281,306,258,279,271,257,281,306,271,257,280,231,281,103,273,76,280,24,280,24,273,76,261,53,280,24,261,53,247,35,247,35,235,26,280,24,280,24,235,26,235,1,345,166,337,222,337,108,337,108,337,222,316,269,337,108,316,269,315,60,315,60,316,269,288,169,286,201,288,169,316,269,286,201,316,269,281,306,286,201,281,306,280,231,281,306,236,330,243,296,315,60,288,169,286,134,315,60,286,134,281,103,315,60,281,103,280,24,182,11,181,-6,235,1,82,307,47,271,47,61,82,307,47,61,75,166,82,307,75,166,76,194,82,307,76,194,81,222,82,307,81,222,88,247,82,307,88,247,98,269,82,102,77,132,82,24,82,24,77,132,75,166,26,109,47,61,47,271,26,109,47,271,26,224,26,109,26,224,18,167,82,24,75,166,47,61,223,19,235,1,235,26,236,330,194,319,207,316,131,25,181,-6,143,19, +353,0,353,9,333,12,321,17,313,25,309,37,308,55,308,274,309,293,313,307,321,315,334,319,353,321,353,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17,110,25,106,38,105,56,105,300,107,306,111,309,116,311,124,312,238,312,246,311,251,309,255,306,257,300,257,62,256,41,253,26,246,17,233,12,213,9,213,0,9,331,9,321,28,319,40,315,47,307,51,294,51,39,48,25,41,16,29,12,9,9,9,0,150,0,150,9,129,12,115,16,107,24,104,37,103,56,103,146,110,145,115,145,120,144,132,144,161,145,184,147,204,153,221,161,239,175,249,185,257,197,263,210,266,225,267,240,266,254,263,268,258,280,252,291,243,300,227,310,209,319,187,325,162,329,134,331,16383,16383,103,294,103,301,105,306,108,310,113,311,120,312,156,309, +50,25,42,16,149,0,149,0,42,16,29,12,149,0,29,12,9,9,42,315,50,307,353,331,353,331,50,307,116,311,353,331,116,311,124,312,353,331,124,312,238,312,353,331,238,312,246,311,253,26,246,17,353,0,353,0,246,17,233,12,353,0,233,12,213,9,353,331,246,311,251,309,353,331,251,309,255,306,353,331,255,306,257,300,353,331,257,300,257,292,353,331,257,292,321,315,353,331,321,315,334,319,353,331,334,319,353,321,308,55,308,274,257,292,257,292,308,274,309,293,257,292,309,293,313,307,321,17,313,25,257,62,257,62,313,25,309,37,257,62,309,37,257,292,118,17,110,25,54,61,54,61,110,25,106,38,54,61,106,38,54,274,54,274,106,38,105,56,54,274,105,56,105,291,54,274,105,291,105,300,54,274,105,300,107,306,54,274,107,306,111,309,54,274,111,309,53,294,116,311,50,307,53,294,116,311,53,294,111,309,29,319,42,315,353,331,29,319,353,331,9,331,29,319,9,331,9,321,353,0,353,9,333,12,353,0,333,12,321,17,353,0,321,17,256,41,353,0,256,41,253,26,149,0,149,9,130,12,149,0,130,12,118,17,149,0,118,17,53,39,149,0,53,39,50,25,149,0,9,9,9,0,53,39,118,17,54,61,353,0,213,9,213,0,256,41,321,17,257,62,257,292,309,37,308,55,321,315,257,292,313,307, +9,331,9,321,28,319,40,315,47,307,51,294,51,39,48,25,41,16,29,12,9,9,9,0,150,0,150,9,129,12,115,16,107,24,104,37,103,56,103,146,110,145,115,145,120,144,132,144,161,145,184,147,204,153,221,161,239,175,249,185,257,197,263,210,266,225,267,240,266,254,263,268,258,280,252,291,243,300,227,310,209,319,187,325,162,329,134,331,16383,16383,103,294,103,301,105,306,108,310,113,311,120,312,156,309,182,302,200,287,210,266,213,238,210,213,199,192,182,177,158,167,128,164,118,164,113,165,109,165,103,166,311,65,289,47,269,32,248,23,226,17,201,15,180,17,161,21,143,28,126,38,112,51,99,68,89,88,82,112,77,140,76,171,81,219,96,260,121,291,154,311,196,318,215,316,232,311,248,304,263,293,276,280,283,272,289,263,294,252,299,240,302,224,314,224,310,338,300,338,297,332,289,324,284,322,278,321,273,322,266,324,258,326,244,330,232,333,208,337,196,338,185,338,157,336,131,330,106,320,83,305,63,286,47,266,35,243,26,218,20,191,18,162,20,133,26,106,36,80,49,57,66,37,85,22,107,9,131,0,157,-4, +113,311,120,312,120,312,134,331,120,312,156,309,134,331,156,309,162,329,162,329,156,309,182,302,162,329,182,302,187,325,187,325,182,302,200,287,187,325,200,287,209,319,209,319,200,287,210,266,209,319,210,266,227,310,227,310,210,266,213,238,227,310,213,238,221,161,221,161,210,213,204,153,204,153,210,213,199,192,204,153,199,192,184,147,184,147,199,192,182,177,184,147,182,177,161,145,161,145,182,177,158,167,161,145,158,167,132,144,132,144,158,167,128,164,132,144,128,164,125,144,125,144,128,164,122,164,125,144,122,164,120,144,120,144,122,164,118,164,120,144,118,164,115,145,115,145,118,164,113,165,115,145,113,165,110,145,110,145,113,165,109,165,110,145,109,165,103,146,103,146,109,165,103,166,103,146,103,166,103,56,103,56,103,166,51,276,103,56,51,276,104,37,104,37,51,276,51,61,267,240,266,254,266,225,266,225,266,254,263,268,266,225,263,268,263,210,263,210,263,268,258,280,263,210,258,280,257,197,257,197,258,280,252,291,257,197,252,291,249,185,249,185,252,291,243,300,249,185,243,300,239,175,239,175,243,300,227,310,239,175,227,310,221,161,134,331,9,331,28,319,134,331,28,319,40,315,134,331,40,315,47,307,134,331,47,307,51,294,134,331,51,294,51,276,134,331,51,276,108,310,134,331,108,310,113,311,134,331,113,311,120,312,103,294,103,301,51,276,103,294,51,276,103,166,105,306,108,310,51,276,105,306,51,276,103,301,150,0,150,9,129,12,150,0,129,12,115,16,150,0,115,16,51,39,150,0,51,39,48,25,150,0,48,25,41,16,150,0,41,16,29,12,150,0,29,12,9,9,150,0,9,9,9,0,51,61,51,39,115,16,51,61,115,16,107,24,51,61,107,24,104,37,28,319,9,331,9,321,210,213,221,161,213,238, +311,65,289,47,269,32,248,23,226,17,201,15,180,17,161,21,143,28,126,38,112,51,99,68,89,88,82,112,77,140,76,171,81,219,96,260,121,291,154,311,196,318,215,316,232,311,248,304,263,293,276,280,283,272,289,263,294,252,299,240,302,224,314,224,310,338,300,338,297,332,289,324,284,322,278,321,273,322,266,324,258,326,244,330,232,333,208,337,196,338,185,338,157,336,131,330,106,320,83,305,63,286,47,266,35,243,26,218,20,191,18,162,20,133,26,106,36,80,49,57,66,37,85,22,107,9,131,0,157,-4,184,-6,218,-4,249,3,277,16,301,34,320,56,296,246,292,331,18,331,15,246,27,246,33,274,42,292,54,303,73,309,100,310,130,310,130,61,129,39,125,25,117,16,104,12,83,9,83,0,229,0,229,9,208,11,194,16,186,23,182,36,181,55,181,310,210,310,237,309,256,303,269,292,277,274,284,246,347,331,243,331,243,322,254,320,263,316,269,312,273,306,274,299,273,292,271,284,268,273,263,260,257,245,204,118,132,245,123,262,110,288,107,297,106,303,107,309,112,314,119,318,129,321,142,322,142,331,7,331,7,322,15,320,27,316,37,310,42,305,46,300,51,294,61,278,181,67,172,53,163,41,154,33,146,28, +66,37,77,140,76,171,76,171,83,305,66,37,66,37,83,305,63,286,66,37,63,286,49,57,49,57,63,286,47,266,49,57,47,266,36,80,36,80,47,266,35,243,36,80,35,243,26,106,26,106,35,243,26,218,26,106,26,218,20,133,20,133,26,218,20,191,20,133,20,191,18,162,82,112,85,22,89,88,89,88,85,22,107,9,89,88,107,9,99,68,99,68,107,9,112,51,126,38,112,51,131,0,126,38,131,0,143,28,143,28,131,0,157,-4,143,28,157,-4,161,21,161,21,157,-4,184,-6,161,21,184,-6,180,17,180,17,184,-6,201,15,226,17,201,15,218,-4,226,17,218,-4,249,3,77,140,66,37,85,22,77,140,85,22,82,112,112,51,107,9,131,0,258,326,263,293,266,324,266,324,263,293,276,280,266,324,276,280,273,322,273,322,276,280,278,321,284,322,278,321,283,272,284,322,283,272,289,263,278,321,276,280,283,272,232,333,232,311,244,330,244,330,232,311,248,304,244,330,248,304,251,328,251,328,248,304,263,293,251,328,263,293,258,326,220,335,208,337,215,316,220,335,215,316,232,311,220,335,232,311,232,333,208,337,196,338,215,316,215,316,196,338,196,318,154,311,196,318,157,336,154,311,157,336,131,330,314,224,310,338,302,224,302,224,310,338,300,338,302,224,300,338,299,240,299,240,300,338,297,332,299,240,297,332,294,252,294,252,297,332,293,328,294,252,293,328,289,263,289,263,293,328,289,324,289,263,289,324,284,322,320,56,311,65,301,34,301,34,311,65,289,47,301,34,289,47,277,16,277,16,289,47,269,32,277,16,269,32,249,3,249,3,269,32,248,23,249,3,248,23,226,17,201,15,184,-6,218,-4,196,318,196,338,185,338,196,318,185,338,157,336,76,171,81,219,83,305,83,305,81,219,96,260,83,305,96,260,106,320,106,320,96,260,121,291,106,320,121,291,131,330,131,330,121,291,154,311, +296,246,292,331,18,331,15,246,27,246,33,274,42,292,54,303,73,309,100,310,130,310,130,61,129,39,125,25,117,16,104,12,83,9,83,0,229,0,229,9,208,11,194,16,186,23,182,36,181,55,181,310,210,310,237,309,256,303,269,292,277,274,284,246,347,331,243,331,243,322,254,320,263,316,269,312,273,306,274,299,273,292,271,284,268,273,263,260,257,245,204,118,132,245,123,262,110,288,107,297,106,303,107,309,112,314,119,318,129,321,142,322,142,331,7,331,7,322,15,320,27,316,37,310,42,305,46,300, +292,331,18,331,73,309,292,331,73,309,100,310,292,331,100,310,130,310,292,331,130,310,181,310,292,331,181,310,210,310,292,331,210,310,237,309,292,331,237,309,256,303,292,331,256,303,269,292,292,331,269,292,277,274,292,331,277,274,284,246,292,331,284,246,296,246,194,16,186,23,130,61,130,61,186,23,182,36,130,61,182,36,130,310,130,310,182,36,181,55,130,310,181,55,181,310,18,331,15,246,27,246,18,331,27,246,33,274,18,331,33,274,42,292,18,331,42,292,54,303,18,331,54,303,73,309,229,0,229,9,208,11,229,0,208,11,194,16,229,0,194,16,129,39,229,0,129,39,125,25,229,0,125,25,117,16,229,0,117,16,104,12,229,0,104,12,83,9,229,0,83,9,83,0,129,39,194,16,130,61, +347,331,243,331,243,322,254,320,263,316,269,312,273,306,274,299,273,292,271,284,268,273,263,260,257,245,204,118,132,245,123,262,110,288,107,297,106,303,107,309,112,314,119,318,129,321,142,322,142,331,7,331,7,322,15,320,27,316,37,310,42,305,46,300,51,294,61,278,181,67,172,53,163,41,154,33,146,28,138,27,136,27,133,28,131,29,127,30,124,32,118,35,108,39,104,40,99,41,92,40,85,37,80,32,77,26,76,20,78,10,84,3,93,-2,104,-5,117,-6,132,-4,147,0,161,9,175,22,188,40,194,51,202,65,210,81,219,100,228,122,291,272,300,289,310,302,321,312,333,319,347,322,218,290,219,301,223,310,232,316,247,320,269,321,269,331,116,331,116,321,138,320,152,317,161,311,165,302,166,290,166,280,124,276,84,263,50,241,27,209,19,165,24,128,41,97,69,72,107,57,158,51,166,51,166,37,164,27,158,19,148,14,134,10,116,9,116,0,269,0,269,9,248,11,233,14,224,19,219,27,218,38,218,51,230,51,265,56,302,69,334,91,357,123,366,165,357,209,333,241,300,263,260,276,218,280,16383,16383,217,262,251,256,278,240,296,216,307,188,311,159,305,128,291,103,270,85,244,74,217,70,16383,16383,167,70,135,75,108,88,89,107,78,132,74,159,78,189,91,216,111,240,136,256, +21,318,27,316,142,331,142,331,27,316,32,313,142,331,32,313,37,310,37,310,42,305,142,331,142,331,42,305,46,300,142,331,46,300,51,294,61,278,181,67,107,297,61,278,107,297,106,303,106,303,107,309,61,278,61,278,107,309,112,314,61,278,112,314,56,286,142,331,51,294,56,286,142,331,56,286,112,314,142,331,112,314,119,318,142,331,119,318,129,321,142,331,129,321,142,322,15,320,21,318,142,331,15,320,142,331,7,331,15,320,7,331,7,322,133,28,131,29,132,-4,132,-4,131,29,127,30,132,-4,127,30,124,32,124,32,118,35,132,-4,132,-4,118,35,117,-6,181,67,172,53,175,22,175,22,172,53,163,41,175,22,163,41,161,9,161,9,163,41,154,33,161,9,154,33,147,0,147,0,154,33,146,28,147,0,146,28,138,27,138,27,136,27,147,0,147,0,136,27,133,28,147,0,133,28,132,-4,257,245,204,118,210,81,257,245,210,81,219,100,257,245,219,100,228,122,257,245,228,122,291,272,347,331,243,331,254,320,347,331,254,320,263,316,347,331,263,316,269,312,347,331,269,312,273,306,347,331,273,306,274,299,347,331,274,299,321,312,347,331,321,312,333,319,347,331,333,319,347,322,291,272,300,289,274,299,291,272,274,299,273,292,291,272,273,292,271,284,291,272,271,284,268,273,291,272,268,273,263,260,291,272,263,260,257,245,310,302,321,312,274,299,310,302,274,299,300,289,204,118,132,245,181,67,204,118,181,67,188,40,204,118,188,40,194,51,204,118,194,51,202,65,204,118,202,65,210,81,181,67,132,245,123,262,181,67,123,262,116,276,181,67,116,276,110,288,181,67,110,288,107,297,118,35,113,37,117,-6,117,-6,113,37,108,39,117,-6,108,39,104,-5,104,-5,108,39,104,40,104,-5,104,40,99,41,93,-2,104,-5,99,41,93,-2,99,41,92,40,93,-2,92,40,85,37,93,-2,85,37,84,3,80,32,77,26,78,10,80,32,78,10,84,3,80,32,84,3,85,37,78,10,77,26,76,20,181,67,175,22,188,40,254,320,243,331,243,322, +218,290,219,301,223,310,232,316,247,320,269,321,269,331,116,331,116,321,138,320,152,317,161,311,165,302,166,290,166,280,124,276,84,263,50,241,27,209,19,165,24,128,41,97,69,72,107,57,158,51,166,51,166,37,164,27,158,19,148,14,134,10,116,9,116,0,269,0,269,9,248,11,233,14,224,19,219,27,218,38,218,51,230,51,265,56,302,69,334,91,357,123,366,165,357,209,333,241,300,263,260,276,218,280,16383,16383,217,262,251,256,278,240,296,216,307,188,311,159,305,128,291,103,270,85,244,74,217,70,16383,16383,167,70,135,75,108,88,89,107,78,132,74,159,78,189,91,216,111,240,136,256,167,262,352,0,352,9,337,12,326,16,316,22,306,32,296,46,200,184,272,272,289,292,303,305,316,314,330,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,262,301,260,296,256,290,250,282,243,272,187,202,165,234,151,255,139,272,130,286,125,297,123,306,124,312,127,316,132,319,139,320,147,320,161,321,161,331,11,331,11,321,28,319,43,312,58,299,77,276,102,242,155,164,77,66,57,42,42,26,30,17,18,12,4,9,4,0,121,0,121,9,105,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,99,57,109,70,169,145,216,74,225,60,232,48,238,38,241,31,242,25,241,20, +269,321,269,321,247,320,247,320,269,321,269,331,247,320,269,331,232,316,232,316,269,331,166,290,232,316,166,290,223,310,223,310,166,290,167,262,219,27,167,262,167,70,219,27,167,70,224,19,224,19,167,70,166,51,224,19,166,51,166,37,218,38,217,70,167,262,167,262,217,70,217,262,167,262,217,262,218,290,218,290,217,262,218,280,219,301,223,310,167,262,219,301,167,262,218,290,166,290,269,331,165,302,269,331,116,331,138,320,269,331,138,320,152,317,269,331,152,317,161,311,269,331,161,311,165,302,91,216,111,240,124,276,124,276,111,240,136,256,124,276,136,256,166,280,166,280,136,256,167,262,166,280,167,262,166,290,84,263,50,241,74,159,84,263,74,159,78,189,84,263,78,189,91,216,84,263,91,216,124,276,19,165,24,128,27,209,27,209,24,128,41,97,27,209,41,97,50,241,50,241,41,97,69,72,50,241,69,72,74,159,334,91,311,159,305,128,334,91,305,128,302,69,302,69,305,128,291,103,302,69,291,103,270,85,307,188,311,159,333,241,333,241,311,159,334,91,333,241,334,91,357,209,357,209,334,91,357,123,357,209,357,123,366,165,300,263,260,276,278,240,300,263,278,240,296,216,300,263,296,216,307,188,300,263,307,188,333,241,251,256,278,240,260,276,251,256,260,276,218,280,251,256,218,280,217,262,218,51,230,51,244,74,244,74,230,51,265,56,244,74,265,56,270,85,270,85,265,56,302,69,218,38,167,262,219,27,218,38,218,51,217,70,269,0,269,9,248,11,269,0,248,11,233,14,269,0,233,14,166,37,269,0,166,37,164,27,269,0,164,27,158,19,269,0,158,19,148,14,269,0,148,14,134,10,269,0,134,10,116,9,269,0,116,9,116,0,158,51,166,51,167,70,158,51,167,70,135,75,158,51,135,75,108,88,158,51,108,88,107,57,74,159,69,72,78,132,78,132,69,72,107,57,78,132,107,57,89,107,89,107,107,57,108,88,166,37,233,14,224,19,217,70,218,51,244,74,138,320,116,331,116,321, +352,0,352,9,337,12,326,16,316,22,306,32,296,46,200,184,272,272,289,292,303,305,316,314,330,319,348,321,348,331,229,331,229,321,243,320,253,319,259,316,262,311,263,305,262,301,260,296,256,290,250,282,243,272,187,202,165,234,151,255,139,272,130,286,125,297,123,306,124,312,127,316,132,319,139,320,147,320,161,321,161,331,11,331,11,321,28,319,43,312,58,299,77,276,102,242,155,164,77,66,57,42,42,26,30,17,18,12,4,9,4,0,121,0,121,9,105,11,95,13,88,17,84,21,83,26,84,31,87,38,92,46,99,57,109,70,169,145,216,74,225,60,232,48,238,38,241,31,242,25,241,20,237,16,232,14,225,12,217,11,204,9,204,0,348,-75,348,9,329,12,316,16,308,24,305,37,304,57,304,292,308,306,316,315,329,319,348,321,348,331,209,331,209,321,228,319,240,315,248,306,251,293,252,275,252,28,250,23,247,21,242,19,115,19,110,21,107,23,105,28,105,269,106,290,109,305,117,314,129,319,149,321,149,331,9,331,9,321,28,319,41,314,49,306,53,294,54,276,54,57,53,37,49,24,41,16,28,12,9,9,9,0,284,0,299,-5,312,-15,323,-29,331,-49,332,-54,333,-60,335,-67,335,-72,336,-75,320,0,320,9,301,12,288,16,280,24,276,37,275,57,275,269,276,291,280,306,288,315,301,319,320,321,320,331,186,331,186,321,204,319,214,316,221,309,223,299,224,283,224,174,216,170, +30,17,121,0,42,26,42,26,121,0,88,17,42,26,88,17,57,42,57,42,88,17,84,21,57,42,84,21,83,26,83,26,84,31,77,66,77,66,84,31,87,38,77,66,87,38,155,164,155,164,87,38,92,46,155,164,92,46,99,57,102,242,155,164,125,297,102,242,125,297,123,306,123,306,124,312,102,242,155,164,99,57,109,70,109,70,169,145,155,164,155,164,169,145,165,234,155,164,165,234,151,255,77,66,57,42,83,26,161,331,11,331,28,319,161,331,28,319,43,312,161,331,43,312,58,299,161,331,58,299,132,319,161,331,132,319,139,320,161,331,139,320,147,320,161,331,147,320,161,321,132,319,58,299,127,316,127,316,58,299,77,276,127,316,77,276,124,312,124,312,77,276,102,242,260,296,256,290,272,272,272,272,256,290,250,282,272,272,250,282,243,272,243,272,187,202,200,184,200,184,187,202,216,74,200,184,216,74,296,46,296,46,216,74,225,60,296,46,225,60,232,48,348,331,229,331,243,320,348,331,243,320,253,319,348,331,253,319,259,316,348,331,259,316,262,311,348,331,262,311,263,305,348,331,263,305,316,314,348,331,316,314,330,319,348,331,330,319,348,321,263,305,272,272,289,292,263,305,289,292,303,305,263,305,303,305,316,314,262,301,260,296,272,272,262,301,272,272,263,305,243,272,200,184,272,272,237,16,232,14,352,0,352,0,232,14,225,12,352,0,225,12,217,11,242,25,352,0,326,16,242,25,326,16,316,22,242,25,316,22,306,32,242,25,306,32,296,46,242,25,296,46,241,31,296,46,232,48,238,38,296,46,238,38,241,31,187,202,165,234,169,145,187,202,169,145,216,74,337,12,326,16,352,0,337,12,352,0,352,9,241,20,237,16,352,0,241,20,352,0,242,25,204,9,204,0,352,0,204,9,352,0,217,11,155,164,151,255,139,272,155,164,139,272,130,286,155,164,130,286,125,297,121,0,121,9,105,11,121,0,105,11,95,13,121,0,95,13,88,17,18,12,4,9,121,0,18,12,121,0,30,17,121,0,4,9,4,0,243,320,229,331,229,321,28,319,11,331,11,321, +348,-75,348,9,329,12,316,16,308,24,305,37,304,57,304,292,308,306,316,315,329,319,348,321,348,331,209,331,209,321,228,319,240,315,248,306,251,293,252,275,252,28,250,23,247,21,242,19,115,19,110,21,107,23,105,28,105,269,106,290,109,305,117,314,129,319,149,321,149,331,9,331,9,321,28,319,41,314,49,306,53,294,54,276,54,57,53,37,49,24,41,16,28,12,9,9,9,0,284,0,299,-5,312,-15,323,-29,331,-49,332,-54,333,-60,335,-67,335,-72,336,-75,320,0,320,9,301,12,288,16,280,24,276,37,275,57,275,269,276,291,280,306,288,315,301,319,320,321,320,331,186,331,186,321,204,319,214,316,221,309,223,299,224,283,224,174,216,170,204,166,190,161,173,158,155,156,132,158,116,165,105,176,99,193,97,216,97,273,98,294,101,307,109,315,121,319,139,321,139,331,2,331,2,321,21,319,34,315,41,307,45,293,46,273,46,211,50,178,62,155,80,142,104,136,133,134,157,136,178,140,197,145,212,152,224,157,224,57,223,37, +49,24,41,16,268,0,268,0,41,16,28,12,268,0,28,12,9,9,149,331,9,331,28,319,149,331,28,319,41,314,149,331,41,314,49,306,149,331,49,306,53,294,149,331,53,294,117,314,149,331,117,314,129,319,149,331,129,319,149,321,110,21,107,23,54,57,54,57,107,23,105,28,54,57,105,28,54,276,54,276,105,28,105,34,54,276,105,34,105,269,54,276,105,269,106,290,54,276,106,290,109,305,54,276,109,305,117,314,54,276,117,314,53,294,329,319,348,321,348,331,329,319,348,331,316,315,316,315,348,331,251,293,316,315,251,293,252,275,268,0,252,275,252,35,268,0,252,35,252,28,316,16,308,24,312,-15,312,-15,308,24,305,37,312,-15,305,37,299,-5,299,-5,305,37,304,57,299,-5,304,57,304,270,252,275,268,0,304,292,304,292,268,0,284,0,304,292,284,0,304,270,304,270,284,0,299,-5,308,306,316,315,252,275,308,306,252,275,304,292,348,331,209,331,228,319,348,331,228,319,240,315,348,331,240,315,248,306,348,331,248,306,251,293,333,-60,348,9,332,-54,332,-54,348,9,331,-49,323,-29,331,-49,329,12,323,-29,329,12,316,16,348,9,333,-60,335,-67,348,9,335,-67,335,-72,348,9,335,-72,336,-75,348,9,336,-75,348,-75,348,9,329,12,331,-49,268,0,252,28,250,23,268,0,250,23,247,21,268,0,247,21,242,19,268,0,242,19,235,19,268,0,235,19,123,19,268,0,123,19,115,19,268,0,115,19,49,24,110,21,54,57,53,37,110,21,53,37,49,24,110,21,49,24,115,19,268,0,9,9,9,0,316,16,312,-15,323,-29,228,319,209,331,209,321,28,319,9,331,9,321, +320,0,320,9,301,12,288,16,280,24,276,37,275,57,275,269,276,291,280,306,288,315,301,319,320,321,320,331,186,331,186,321,204,319,214,316,221,309,223,299,224,283,224,174,216,170,204,166,190,161,173,158,155,156,132,158,116,165,105,176,99,193,97,216,97,273,98,294,101,307,109,315,121,319,139,321,139,331,2,331,2,321,21,319,34,315,41,307,45,293,46,273,46,211,50,178,62,155,80,142,104,136,133,134,157,136,178,140,197,145,212,152,224,157,224,57,223,37,219,24,211,16,199,12,180,9,180,0,483,0,483,9,463,12,450,16,443,24,439,37,438,57,438,270,439,292,443,306,450,315,463,319,483,321,483,331,343,331,344,321,362,319,375,315,383,306,386,293,387,275,387,28,385,23,382,21,377,19,282,19,277,21,274,23,272,27,272,269,273,290,276,305,283,314,296,319,315,321,315,331,183,331,183,321,200,319,210,314,217,306,220,294,220,28,218,23,215,21,210,19,120,19,115,21,112,23,110,28,110,269,111,291,114,306,120,315,131,320,147,321,147,331,15,331,15,321,34,319,46,314,54,306,58,294,59,276, +139,321,139,321,121,319,121,319,139,321,139,331,121,319,139,331,109,315,109,315,139,331,45,293,109,315,45,293,46,273,50,178,46,273,46,211,132,158,116,165,133,134,133,134,116,165,105,176,133,134,105,176,104,136,104,136,105,176,99,193,104,136,99,193,80,142,80,142,99,193,97,216,80,142,97,216,97,273,46,273,50,178,101,307,101,307,50,178,62,155,101,307,62,155,98,294,98,294,62,155,80,142,98,294,80,142,97,273,139,331,2,331,21,319,139,331,21,319,34,315,139,331,34,315,41,307,139,331,41,307,45,293,224,283,224,174,224,157,224,157,224,174,216,170,224,157,216,170,212,152,212,152,216,170,204,166,212,152,204,166,197,145,197,145,204,166,190,161,197,145,190,161,178,140,178,140,190,161,173,158,178,140,173,158,157,136,157,136,173,158,155,156,133,134,157,136,155,156,133,134,155,156,132,158,320,331,186,331,204,319,320,331,204,319,214,316,320,331,214,316,221,309,320,331,221,309,223,299,320,331,223,299,224,283,320,331,224,283,288,315,320,331,288,315,301,319,320,331,301,319,320,321,275,57,275,269,224,157,224,157,275,269,276,291,224,157,276,291,280,306,224,283,224,157,280,306,224,283,280,306,288,315,320,0,320,9,301,12,320,0,301,12,288,16,320,0,288,16,223,37,320,0,223,37,219,24,320,0,219,24,211,16,320,0,211,16,199,12,320,0,199,12,180,9,320,0,180,9,180,0,224,157,280,24,276,37,224,157,276,37,275,57,224,57,223,37,288,16,224,57,288,16,280,24,224,57,280,24,224,157,204,319,186,331,186,321,21,319,2,331,2,321,109,315,46,273,101,307, +483,0,483,9,463,12,450,16,443,24,439,37,438,57,438,270,439,292,443,306,450,315,463,319,483,321,483,331,343,331,344,321,362,319,375,315,383,306,386,293,387,275,387,28,385,23,382,21,377,19,282,19,277,21,274,23,272,27,272,269,273,290,276,305,283,314,296,319,315,321,315,331,183,331,183,321,200,319,210,314,217,306,220,294,220,28,218,23,215,21,210,19,120,19,115,21,112,23,110,28,110,269,111,291,114,306,120,315,131,320,147,321,147,331,15,331,15,321,34,319,46,314,54,306,58,294,59,276,59,57,58,37,54,24,46,16,33,12,15,9,15,0,483,-75,483,9,463,12,450,16,443,24,439,37,438,57,438,270,439,292,443,306,450,315,463,319,483,321,483,331,343,331,344,321,362,319,375,315,383,306,386,293,387,275,387,28,385,23,382,21,377,19,282,19,277,21,274,23,272,27,272,269,273,290,276,305,283,314,296,319,315,321,315,331,183,331,183,321,200,319,210,314,217,306,220,294,220,28,218,23,215,21,210,19,120,19,115,21,112,23,110,28,110,269,111,291,114,306,120,315,131,320,147,321,147,331,15,331,15,321,34,319,46,314,54,306,58,294,59,276,59,57,58,37,54,24,46,16,33,12,15,9,15,0, +59,57,58,37,115,21,115,21,58,37,54,24,115,21,54,24,120,19,120,19,54,24,46,16,120,19,46,16,483,0,483,0,46,16,33,12,483,0,33,12,15,9,147,331,15,331,34,319,147,331,34,319,46,314,147,331,46,314,54,306,147,331,54,306,58,294,147,331,58,294,120,315,147,331,120,315,131,320,147,331,131,320,147,321,115,21,112,23,59,57,59,57,112,23,110,28,59,57,110,28,59,276,59,276,110,28,110,34,59,276,110,34,110,269,59,276,110,269,111,291,59,276,111,291,114,306,59,276,114,306,120,315,59,276,120,315,58,294,296,319,315,321,315,331,296,319,315,331,283,314,283,314,315,331,220,294,283,314,220,294,220,276,272,27,220,276,220,35,272,27,220,35,274,23,274,23,220,35,277,21,272,33,272,269,220,276,220,276,272,269,273,290,220,276,273,290,276,305,315,331,183,331,200,319,315,331,200,319,210,314,315,331,210,314,217,306,315,331,217,306,220,294,463,319,483,321,483,331,463,319,483,331,450,315,450,315,483,331,386,293,450,315,386,293,387,275,439,37,387,275,387,35,439,37,387,35,443,24,443,24,387,35,450,16,438,57,438,270,387,275,387,275,438,270,439,292,387,275,439,292,443,306,483,331,343,331,344,321,483,331,344,321,362,319,483,331,362,319,375,315,483,331,375,315,383,306,483,331,383,306,386,293,483,0,483,9,463,12,483,0,463,12,450,16,483,0,450,16,387,35,483,0,387,35,387,28,483,0,387,28,385,23,483,0,385,23,382,21,483,0,382,21,377,19,483,0,377,19,371,19,483,0,371,19,289,19,483,0,289,19,282,19,483,0,282,19,218,23,483,0,218,23,215,21,483,0,215,21,210,19,483,0,210,19,203,19,483,0,203,19,127,19,483,0,127,19,120,19,282,19,277,21,220,35,282,19,220,35,220,28,282,19,220,28,218,23,483,0,15,9,15,0,220,276,272,27,272,33,387,275,439,37,438,57,450,315,387,275,443,306,200,319,183,331,183,321,283,314,220,276,276,305,34,319,15,331,15,321, +483,-75,483,9,463,12,450,16,443,24,439,37,438,57,438,270,439,292,443,306,450,315,463,319,483,321,483,331,343,331,344,321,362,319,375,315,383,306,386,293,387,275,387,28,385,23,382,21,377,19,282,19,277,21,274,23,272,27,272,269,273,290,276,305,283,314,296,319,315,321,315,331,183,331,183,321,200,319,210,314,217,306,220,294,220,28,218,23,215,21,210,19,120,19,115,21,112,23,110,28,110,269,111,291,114,306,120,315,131,320,147,321,147,331,15,331,15,321,34,319,46,314,54,306,58,294,59,276,59,57,58,37,54,24,46,16,33,12,15,9,15,0,419,0,433,-5,446,-15,457,-29,465,-49,467,-55,468,-61,469,-68,470,-73,470,-75,171,183,171,274,172,293,177,307,186,315,200,319,219,321,219,331,10,331,7,246,18,246,25,274,33,293,45,304,63,309,90,310,120,310,120,56,119,37,114,24,106,16,92,11,72,9,72,0,231,0,271,4,305,15,330,34,346,59,352,91,345,126,327,153,299,170,262,180,219,183,16383,16383,171,163,204,163,231,161,256,154,276,141,289,120,294,89,289,59,275,39,253,27,226,21,195,19,185,20,178,22,174,26,171,33,171,41,432,0,432,9,414,12,401,17,393,25,389,38,388,57,388,274,389,294,393,307,401,315,414,319,432,321,432,331,292,331,292,321,312,319,325,315,332,307,336,294,337,274,337,61,336,39,333,25,325,16,312,12,292,9,292,0, +59,57,58,37,115,21,115,21,58,37,54,24,115,21,54,24,120,19,120,19,54,24,46,16,120,19,46,16,402,0,402,0,46,16,33,12,402,0,33,12,15,9,147,331,15,331,34,319,147,331,34,319,46,314,147,331,46,314,54,306,147,331,54,306,58,294,147,331,58,294,120,315,147,331,120,315,131,320,147,331,131,320,147,321,115,21,112,23,59,57,59,57,112,23,110,28,59,57,110,28,59,276,59,276,110,28,110,34,59,276,110,34,110,269,59,276,110,269,111,291,59,276,111,291,114,306,59,276,114,306,120,315,59,276,120,315,58,294,296,319,315,321,315,331,296,319,315,331,283,314,283,314,315,331,220,294,283,314,220,294,220,276,272,27,220,276,220,35,272,27,220,35,274,23,274,23,220,35,277,21,272,33,272,269,220,276,220,276,272,269,273,290,220,276,273,290,276,305,315,331,183,331,200,319,315,331,200,319,210,314,315,331,210,314,217,306,315,331,217,306,220,294,463,319,483,321,483,331,463,319,483,331,450,315,450,315,483,331,386,293,450,315,386,293,387,275,402,0,387,275,387,35,402,0,387,35,387,28,450,16,443,24,446,-15,446,-15,443,24,439,37,446,-15,439,37,433,-5,433,-5,439,37,438,57,433,-5,438,57,438,270,387,275,402,0,439,292,439,292,402,0,419,0,439,292,419,0,438,270,438,270,419,0,433,-5,443,306,450,315,387,275,443,306,387,275,439,292,483,331,343,331,344,321,483,331,344,321,362,319,483,331,362,319,375,315,483,331,375,315,383,306,483,331,383,306,386,293,468,-61,483,9,467,-55,467,-55,483,9,465,-49,457,-29,465,-49,463,12,457,-29,463,12,450,16,483,9,468,-61,469,-68,483,9,469,-68,470,-73,483,9,470,-73,470,-75,483,9,470,-75,483,-75,483,9,463,12,465,-49,402,0,387,28,385,23,402,0,385,23,382,21,402,0,382,21,377,19,402,0,377,19,371,19,402,0,371,19,289,19,402,0,289,19,282,19,402,0,282,19,220,28,402,0,220,28,218,23,402,0,218,23,215,21,402,0,215,21,210,19,402,0,210,19,203,19,402,0,203,19,127,19,402,0,127,19,120,19,220,35,220,28,282,19,220,35,282,19,277,21,402,0,15,9,15,0,220,276,272,27,272,33,450,16,446,-15,457,-29,200,319,183,331,183,321,283,314,220,276,276,305,34,319,15,331,15,321, +171,183,171,274,172,293,177,307,186,315,200,319,219,321,219,331,10,331,7,246,18,246,25,274,33,293,45,304,63,309,90,310,120,310,120,56,119,37,114,24,106,16,92,11,72,9,72,0,231,0,271,4,305,15,330,34,346,59,352,91,345,126,327,153,299,170,262,180,219,183,16383,16383,171,163,204,163,231,161,256,154,276,141,289,120,294,89,289,59,275,39,253,27,226,21,195,19,185,20,178,22,174,26,171,33,171,41,432,0,432,9,414,12,401,17,393,25,389,38,388,57,388,274,389,294,393,307,401,315,414,319,432,321,432,331,292,331,292,321,312,319,325,315,332,307,336,294,337,274,337,61,336,39,333,25,325,16,312,12,292,9,292,0,16383,16383,108,183,108,274,110,293,115,307,123,315,137,319,156,321,156,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,170,0,210,4, +114,24,106,16,231,0,231,0,106,16,92,11,231,0,92,11,72,9,177,307,186,315,120,310,120,310,186,315,219,331,120,310,219,331,90,310,63,309,90,310,219,331,63,309,219,331,10,331,200,319,219,321,219,331,200,319,219,331,186,315,120,310,171,33,171,41,171,183,171,163,204,163,171,183,204,163,219,183,219,183,204,163,231,161,219,183,231,161,262,180,262,180,231,161,256,154,262,180,256,154,276,141,120,310,171,41,171,274,120,310,171,274,172,293,120,310,172,293,177,307,10,331,7,246,18,246,10,331,18,246,25,274,10,331,25,274,33,293,10,331,33,293,45,304,10,331,45,304,63,309,294,89,289,59,305,15,305,15,289,59,275,39,305,15,275,39,271,4,271,4,275,39,253,27,271,4,253,27,231,0,231,0,253,27,226,21,231,0,226,21,195,19,195,19,185,20,231,0,231,0,185,20,178,22,231,0,178,22,119,37,119,37,178,22,120,56,299,170,294,89,305,15,299,170,305,15,327,153,327,153,305,15,330,34,327,153,330,34,345,126,345,126,330,34,346,59,345,126,346,59,352,91,299,170,262,180,276,141,299,170,276,141,289,120,299,170,289,120,294,89,120,56,178,22,174,26,120,56,174,26,171,33,120,56,171,33,120,310,231,0,72,9,72,0,114,24,231,0,119,37, +432,0,432,9,414,12,401,17,393,25,389,38,388,57,388,274,389,294,393,307,401,315,414,319,432,321,432,331,292,331,292,321,312,319,325,315,332,307,336,294,337,274,337,61,336,39,333,25,325,16,312,12,292,9,292,0,16383,16383,108,183,108,274,110,293,115,307,123,315,137,319,156,321,156,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,170,0,210,4,244,15,268,34,284,59,290,91,283,126,265,153,238,170,201,180,158,183,16383,16383,108,163,142,163,170,161,194,154,214,141,227,120,232,89,227,59,214,39,193,27,166,21,134,19,123,20,115,22,111,26,109,33,108,41,108,183,108,274,110,293,115,307,123,315,137,319,156,321,156,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,170,0,210,4,243,15,268,34,284,59,289,91,283,126,265,153,237,170,201,180,158,183,16383,16383,108,163,142,163,170,161,194,154,214,141,227,120,232,89,227,59,213,39,193,27,166,21,134,19,123,20,115,22,111,26,109,33,108,41,26,338,23,224,36,224,39,239,42,252,46,263,51,272,57,280,71,293,85,304,101,311,118,316,136,318,173,312,203,293,226,265,241,228,248,184,103,184,103,161,248,161,248,142,246,124,242,108,237,92,231,78,218,57,201,39,181,26, +432,321,432,321,414,319,414,319,432,321,432,331,414,319,432,331,401,315,401,315,432,331,336,294,401,315,336,294,337,274,389,38,337,274,337,61,389,38,337,61,393,25,393,25,337,61,401,17,388,57,388,274,337,274,337,274,388,274,389,294,337,274,389,294,393,307,432,331,292,331,312,319,432,331,312,319,325,315,432,331,325,315,332,307,432,331,332,307,336,294,432,0,432,9,414,12,432,0,414,12,401,17,432,0,401,17,336,39,432,0,336,39,333,25,432,0,333,25,325,16,432,0,325,16,312,12,432,0,312,12,292,9,432,0,292,9,292,0,52,24,43,16,170,0,170,0,43,16,30,11,170,0,30,11,9,9,156,331,9,331,30,320,156,331,30,320,44,316,156,331,44,316,52,308,156,331,52,308,56,295,156,331,56,295,123,315,156,331,123,315,137,319,156,331,137,319,156,321,57,275,109,33,108,41,108,183,108,163,142,163,108,183,142,163,158,183,158,183,142,163,170,161,158,183,170,161,201,180,201,180,170,161,194,154,201,180,194,154,214,141,57,275,108,41,108,274,57,275,108,274,110,293,57,275,110,293,115,307,57,275,115,307,123,315,57,275,123,315,56,295,232,89,227,59,244,15,244,15,227,59,214,39,244,15,214,39,210,4,210,4,214,39,193,27,210,4,193,27,170,0,170,0,193,27,166,21,170,0,166,21,134,19,134,19,123,20,170,0,170,0,123,20,115,22,170,0,115,22,56,37,56,37,115,22,57,56,238,170,232,89,244,15,238,170,244,15,265,153,265,153,244,15,268,34,265,153,268,34,283,126,283,126,268,34,284,59,283,126,284,59,290,91,238,170,201,180,214,141,238,170,214,141,227,120,238,170,227,120,232,89,57,56,115,22,111,26,57,56,111,26,109,33,57,56,109,33,57,275,170,0,9,9,9,0,52,24,170,0,56,37,30,320,9,331,9,321,336,39,401,17,337,61,337,274,389,38,388,57,312,319,292,331,292,321,401,315,337,274,393,307, +108,183,108,274,110,293,115,307,123,315,137,319,156,321,156,331,9,331,9,321,30,320,44,316,52,308,56,295,57,275,57,56,56,37,52,24,43,16,30,11,9,9,9,0,170,0,210,4,243,15,268,34,284,59,289,91,283,126,265,153,237,170,201,180,158,183,16383,16383,108,163,142,163,170,161,194,154,214,141,227,120,232,89,227,59,213,39,193,27,166,21,134,19,123,20,115,22,111,26,109,33,108,41,26,338,23,224,36,224,39,239,42,252,46,263,51,272,57,280,71,293,85,304,101,311,118,316,136,318,173,312,203,293,226,265,241,228,248,184,103,184,103,161,248,161,248,142,246,124,242,108,237,92,231,78,218,57,201,39,181,26,158,18,131,15,107,17,86,23,65,32,45,46,25,65,15,55,33,33,55,16,80,3,109,-4,141,-6,168,-4,194,0,218,9,240,22,258,37,275,57,288,79,298,104,304,131, +52,24,43,16,170,0,170,0,43,16,30,11,170,0,30,11,9,9,156,331,9,331,30,320,156,331,30,320,44,316,156,331,44,316,52,308,156,331,52,308,56,295,156,331,56,295,123,315,156,331,123,315,137,319,156,331,137,319,156,321,57,275,109,33,108,41,108,183,108,163,142,163,108,183,142,163,158,183,158,183,142,163,170,161,158,183,170,161,201,180,201,180,170,161,194,154,201,180,194,154,214,141,57,275,108,41,108,274,57,275,108,274,110,293,57,275,110,293,115,307,57,275,115,307,123,315,57,275,123,315,56,295,57,56,56,37,115,22,115,22,56,37,170,0,115,22,170,0,123,20,123,20,170,0,134,19,166,21,134,19,170,0,166,21,170,0,193,27,193,27,170,0,210,4,193,27,210,4,213,39,213,39,210,4,243,15,213,39,243,15,227,59,227,59,243,15,232,89,237,170,232,89,243,15,237,170,243,15,265,153,265,153,243,15,268,34,265,153,268,34,283,126,283,126,268,34,284,59,283,126,284,59,289,91,237,170,201,180,214,141,237,170,214,141,227,120,237,170,227,120,232,89,57,56,115,22,111,26,57,56,111,26,109,33,57,56,109,33,57,275,170,0,9,9,9,0,52,24,170,0,56,37,30,320,9,331,9,321, +26,338,23,224,36,224,39,239,42,252,46,263,51,272,57,280,71,293,85,304,101,311,118,316,136,318,173,312,203,293,226,265,241,228,248,184,103,184,103,161,248,161,248,142,246,124,242,108,237,92,231,78,218,57,201,39,181,26,158,18,131,15,107,17,86,23,65,32,45,46,25,65,15,55,33,33,55,16,80,3,109,-4,141,-6,168,-4,194,0,218,9,240,22,258,37,275,57,288,79,298,104,304,131,306,160,305,188,299,215,290,240,278,263,263,284,244,304,222,319,198,330,173,336,147,338,136,338,124,337,113,336,101,333,90,330,83,328,75,326,61,322,55,321,50,322,45,324,41,328,38,332,36,338,105,180,105,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17,110,25,106,38,105,56,105,157,149,157,157,102,177,57,207,22,245,0,291,-6,337,1,376,24,405,60,425,108,431,166,425,222,406,269,377,306,338,330,291,338,245,331,207,310,178,276,158,232,149,180,16383,16383,377,169,376,134,373,103,367,76,359,53,347,35,337,26,327,19,315,15,303,12,291,11,279,12,268,15,257,19,247,25,237,33,224,52,214,75,208,102,204,132,203,166,204,194,207,222,211,247, +36,338,36,338,38,332,38,332,36,338,39,239,38,332,39,239,41,328,41,328,39,239,42,252,41,328,42,252,45,324,45,324,42,252,46,263,45,324,46,263,50,322,50,322,46,263,51,272,50,322,51,272,55,321,55,321,51,272,57,280,55,321,57,280,61,322,36,224,39,239,36,338,36,224,36,338,26,338,36,224,26,338,23,224,75,326,68,324,71,293,71,293,68,324,61,322,71,293,61,322,57,280,90,330,83,328,85,304,90,330,85,304,101,311,90,330,101,311,101,333,75,326,71,293,85,304,75,326,85,304,83,328,248,142,246,124,258,37,258,37,246,124,242,108,258,37,242,108,240,22,240,22,242,108,237,92,240,22,237,92,231,78,231,78,218,57,218,9,218,9,218,57,201,39,218,9,201,39,194,0,194,0,201,39,181,26,194,0,181,26,168,-4,168,-4,181,26,158,18,168,-4,158,18,141,-6,141,-6,158,18,131,15,131,15,107,17,109,-4,109,-4,107,17,86,23,109,-4,86,23,80,3,80,3,86,23,65,32,80,3,65,32,55,16,55,16,65,32,45,46,55,16,45,46,33,33,33,33,45,46,25,65,33,33,25,65,15,55,136,318,136,338,124,337,136,318,124,337,118,316,136,318,147,338,136,338,118,316,124,337,113,336,118,316,113,336,101,333,118,316,101,333,101,311,306,160,305,188,304,131,304,131,305,188,299,215,304,131,299,215,298,104,298,104,299,215,290,240,298,104,290,240,288,79,288,79,290,240,278,263,288,79,278,263,275,57,275,57,278,263,263,284,275,57,263,284,258,37,258,37,263,284,248,161,258,37,248,161,248,142,263,284,248,184,248,161,248,161,248,184,103,184,244,304,222,319,226,265,244,304,226,265,241,228,244,304,241,228,248,184,244,304,248,184,263,284,203,293,226,265,222,319,203,293,222,319,198,330,203,293,198,330,173,336,203,293,173,336,173,312,173,312,173,336,147,338,173,312,147,338,136,318,231,78,218,9,240,22,141,-6,131,15,109,-4,248,161,103,184,103,161, +105,180,105,274,106,294,110,307,118,315,130,319,149,321,149,331,9,331,9,321,29,319,42,315,50,307,53,294,54,274,54,61,53,39,50,25,42,16,29,12,9,9,9,0,149,0,149,9,130,12,118,17,110,25,106,38,105,56,105,157,149,157,157,102,177,57,207,22,245,0,291,-6,337,1,376,24,405,60,425,108,431,166,425,222,406,269,377,306,338,330,291,338,245,331,207,310,178,276,158,232,149,180,16383,16383,377,169,376,134,373,103,367,76,359,53,347,35,337,26,327,19,315,15,303,12,291,11,279,12,268,15,257,19,247,25,237,33,224,52,214,75,208,102,204,132,203,166,204,194,207,222,211,247,219,269,228,286,239,299,251,308,263,315,276,318,290,320,302,319,313,316,324,311,334,305,343,296,356,279,366,257,372,231,376,201,377,169,309,0,309,9,290,12,277,16,270,25,267,39,267,276,268,294,271,307,278,315,290,319,309,321,309,331,180,331,136,329,98,321,69,306,49,282,42,246,47,216,60,193,81,176,108,164,141,157,49,35,41,26,31,19,22,14,12,11,2,9,2,0,83,0,198,155,216,155,216,56,215,37,211,24,203,16,189,12,169,9,169,0,16383,16383,216,174,186,174,156,177,131,186,113,200,101,219,97,244,99,261,103,276,111,288,121,298,133,305,143,308,153,310,164,311,177,312,190,312,200,311,207,309,212,304,215,296,216,286,223,33,218,29,210,25,206,24,201,23,196,25,192,28,189,35,187,44,186,56,186,152,185,168,184,181,181,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192, +50,25,42,16,149,0,149,0,42,16,29,12,149,0,29,12,9,9,149,331,9,331,29,319,149,331,29,319,42,315,149,331,42,315,50,307,149,331,50,307,53,294,149,331,53,294,118,315,149,331,118,315,130,319,149,331,130,319,149,321,158,232,149,180,149,157,149,157,149,180,105,180,149,157,105,180,105,157,106,38,105,56,54,274,106,38,54,274,54,61,54,274,105,56,105,274,54,274,105,274,106,294,54,274,106,294,110,307,54,274,110,307,118,315,54,274,118,315,53,294,149,0,149,9,130,12,149,0,130,12,118,17,149,0,118,17,53,39,149,0,53,39,50,25,54,61,53,39,118,17,54,61,118,17,110,25,54,61,110,25,106,38,263,315,291,338,251,308,251,308,291,338,245,331,251,308,245,331,239,299,239,299,245,331,228,286,219,269,228,286,245,331,219,269,245,331,207,310,208,102,207,22,214,75,214,75,207,22,245,0,214,75,245,0,224,52,224,52,245,0,237,33,247,25,237,33,245,0,247,25,245,0,291,-6,338,330,291,338,302,319,302,319,291,338,290,320,276,318,290,320,291,338,276,318,291,338,263,315,207,310,178,276,203,166,207,310,203,166,204,194,207,310,204,194,207,222,207,310,207,222,211,247,207,310,211,247,219,269,208,102,204,132,207,22,207,22,204,132,203,166,268,15,291,-6,279,12,279,12,291,-6,291,11,303,12,291,11,291,-6,303,12,291,-6,337,1,313,316,324,311,338,330,338,330,324,311,334,305,338,330,334,305,343,296,343,296,356,279,377,306,377,306,356,279,366,257,377,306,366,257,372,231,373,103,367,76,376,24,376,24,367,76,359,53,376,24,359,53,347,35,347,35,337,26,376,24,376,24,337,26,337,1,431,166,425,222,425,108,425,108,425,222,406,269,425,108,406,269,405,60,405,60,406,269,377,169,377,306,372,231,376,201,377,306,376,201,377,169,377,306,377,169,406,269,377,306,338,330,343,296,376,134,373,103,376,24,376,134,376,24,405,60,376,134,405,60,377,169,337,1,337,26,327,19,337,1,327,19,315,15,337,1,315,15,303,12,257,19,247,25,291,-6,257,19,291,-6,268,15,149,157,157,102,158,232,158,232,157,102,177,57,158,232,177,57,178,276,178,276,177,57,207,22,178,276,207,22,203,166,338,330,302,319,313,316,149,0,9,9,9,0,29,319,9,331,9,321, +309,0,309,9,290,12,277,16,270,25,267,39,267,276,268,294,271,307,278,315,290,319,309,321,309,331,180,331,136,329,98,321,69,306,49,282,42,246,47,216,60,193,81,176,108,164,141,157,49,35,41,26,31,19,22,14,12,11,2,9,2,0,83,0,198,155,216,155,216,56,215,37,211,24,203,16,189,12,169,9,169,0,16383,16383,216,174,186,174,156,177,131,186,113,200,101,219,97,244,99,261,103,276,111,288,121,298,133,305,143,308,153,310,164,311,177,312,190,312,200,311,207,309,212,304,215,296,216,286,223,33,218,29,210,25,206,24,201,23,196,25,192,28,189,35,187,44,186,56,186,152,185,168,184,181,181,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,207,83,212,93,215,104,217,117,215,129,210,138,202,144,190,146,173,146,146,116,135,93,126,76,118,63,112,54,105,42,97,33,87, +31,19,22,14,83,0,83,0,22,14,12,11,83,0,12,11,2,9,99,261,103,276,98,321,98,321,103,276,111,288,98,321,111,288,136,329,136,329,111,288,121,298,136,329,121,298,133,305,133,305,143,308,136,329,136,329,143,308,180,331,101,219,97,244,108,164,108,164,97,244,81,176,81,176,97,244,98,321,98,321,97,244,99,261,42,246,47,216,49,282,49,282,47,216,60,193,49,282,60,193,69,306,69,306,60,193,81,176,69,306,81,176,98,321,141,157,83,0,198,155,141,157,198,155,156,177,141,157,156,177,131,186,141,157,131,186,113,200,141,157,113,200,108,164,211,24,203,16,309,0,309,0,203,16,189,12,309,0,189,12,169,9,153,310,164,311,180,331,180,331,164,311,177,312,180,331,177,312,190,312,190,312,200,311,309,331,309,331,200,311,207,309,309,331,207,309,212,304,211,24,309,0,215,37,215,37,309,0,277,16,215,37,277,16,216,56,216,56,277,16,270,25,216,56,270,25,216,155,216,155,270,25,216,174,216,155,216,174,198,155,198,155,216,174,186,174,198,155,186,174,156,177,83,0,141,157,49,35,83,0,49,35,41,26,83,0,41,26,31,19,290,319,309,321,309,331,290,319,309,331,278,315,278,315,309,331,216,286,278,315,216,286,271,307,271,307,216,286,268,294,216,286,267,39,267,61,267,276,268,294,216,286,267,276,216,286,267,61,309,331,212,304,215,296,309,331,215,296,216,286,309,331,180,331,190,312,290,12,277,16,309,0,290,12,309,0,309,9,216,174,270,25,267,39,216,174,267,39,216,286,309,0,169,9,169,0,83,0,2,9,2,0,180,331,143,308,153,310,101,219,108,164,113,200, +223,33,218,29,210,25,206,24,201,23,196,25,192,28,189,35,187,44,186,56,186,152,185,168,184,181,181,191,176,199,170,208,162,215,152,222,140,226,127,229,111,230,98,229,85,227,73,224,63,220,54,215,44,208,37,200,32,192,29,183,28,175,29,167,33,161,37,156,43,153,50,152,57,153,63,156,68,161,71,167,73,172,72,178,72,182,71,185,70,189,70,194,71,201,76,207,83,212,93,215,104,217,117,215,129,210,138,202,144,190,146,173,146,146,116,135,93,126,76,118,63,112,54,105,42,97,33,87,25,75,20,62,18,47,21,29,28,14,39,4,54,-2,71,-4,84,-3,99,0,114,6,130,16,146,31,149,17,153,7,160,0,168,-3,178,-4,188,-3,197,-1,206,2,214,9,223,19,16383,16383,146,65,145,57,144,50,140,44,135,38,128,32,122,29,110,25,103,24,97,24,86,25,76,30,69,38,64,48,63,63,63,71,65,78,68,84,73,91,79,97,88,104,99,111,112,118,128,125,146,132,42,174,47,203,59,230,77,253,100,270,129,278,142,279,169,279,182,280,194,283,210,293,220,306,226,320,229,333,230,343,220,343,217,332,212,325,205,320,195,318,183,317,150,317,94,304,57,269,34,223,23,172,20,127,24,87,36,52,57,22,87,2,127,-4,164,1,195,17,219,43,234,76,239,116,233,154,218,186,195,210,166,225,131,230,111,228,92,223,74,213,57,196,43,173,16383,16383,194,102,192,70,184,44,172,25,155,13,135,9,125,10,115,13,106,18,98,25,91,34,81,51,74,70,69,91,66,113,65,137,67,164,75,186,87,202,102,212,122,216,134,215,144,211,153,206,161,199,169,191,178,177,185,161,190,142,193,122,194,102,153,118,169,121,183,128,194,137,202,151,205,168,201,188,191,204,174,215,149,222,118,225,12,225,12,218,26,216,35,214,40,209,42,200,43,187,43,39,42,25,40,16,35,11,26,8,12,7,12,0,149,0,161,2,171,4,181,8,190,12,200,19,208,28,214,39,218,51, +37,156,43,153,44,208,44,208,43,153,50,152,44,208,50,152,54,215,54,215,50,152,57,153,54,215,57,153,63,220,63,220,57,153,63,156,63,220,63,156,73,224,73,224,63,156,70,194,71,167,70,194,68,161,111,230,104,217,117,215,111,230,117,215,127,229,127,229,117,215,129,210,127,229,129,210,140,226,140,226,129,210,138,202,140,226,138,202,144,190,76,207,83,212,85,227,85,227,83,212,93,215,85,227,93,215,98,229,98,229,93,215,104,217,98,229,104,217,111,230,73,224,70,194,71,201,73,224,71,201,76,207,73,224,76,207,85,227,70,194,63,156,68,161,29,183,29,167,32,192,32,192,29,167,33,161,32,192,33,161,37,200,37,200,33,161,37,156,37,200,37,156,44,208,186,56,186,152,185,168,186,56,185,168,184,181,186,56,184,181,181,191,186,56,181,191,188,-3,192,28,197,-1,196,25,196,25,197,-1,201,23,206,24,201,23,206,2,206,24,206,2,214,9,189,35,187,44,188,-3,189,35,188,-3,197,-1,189,35,197,-1,192,28,178,-4,188,-3,181,191,178,-4,181,191,176,199,178,-4,176,199,170,208,178,-4,170,208,168,-3,162,215,152,222,153,7,162,215,153,7,160,0,162,215,160,0,168,-3,162,215,168,-3,170,208,152,222,140,226,144,190,152,222,144,190,146,173,152,222,146,173,146,132,152,222,146,132,146,31,152,222,146,31,149,17,152,222,149,17,153,7,146,146,146,132,146,173,218,29,214,27,214,9,218,29,214,9,223,19,218,29,223,19,223,33,210,25,206,24,214,9,210,25,214,9,214,27,201,23,197,-1,206,2,146,31,146,132,146,65,146,31,146,65,145,57,146,31,145,57,144,50,146,31,144,50,140,44,146,31,140,44,135,38,146,31,135,38,130,16,130,16,135,38,128,32,128,32,122,29,130,16,130,16,122,29,116,27,130,16,116,27,114,6,114,6,116,27,110,25,114,6,110,25,103,24,99,111,112,118,116,135,116,135,112,118,128,125,116,135,128,125,146,146,146,146,128,125,146,132,65,78,68,84,76,118,76,118,68,84,73,91,76,118,73,91,79,97,79,97,88,104,93,126,93,126,88,104,99,111,93,126,99,111,116,135,93,126,76,118,79,97,72,182,71,185,71,167,72,182,71,167,73,172,72,182,73,172,72,178,70,189,70,194,71,167,70,189,71,167,71,185,63,112,54,105,54,-2,63,112,54,-2,63,63,63,112,63,63,63,71,63,112,63,71,65,78,63,112,65,78,76,118,63,63,54,-2,64,48,64,48,54,-2,71,-4,64,48,71,-4,69,38,69,38,71,-4,76,30,20,62,21,29,25,75,25,75,21,29,28,14,25,75,28,14,33,87,33,87,28,14,39,4,33,87,39,4,42,97,42,97,39,4,54,-2,42,97,54,-2,54,105,84,-3,99,0,86,25,86,25,99,0,97,24,103,24,97,24,99,0,103,24,99,0,114,6,76,30,71,-4,84,-3,76,30,84,-3,86,25,21,29,20,62,18,47,186,56,188,-3,187,44,29,167,29,183,28,175, +42,174,47,203,59,230,77,253,100,270,129,278,142,279,169,279,182,280,194,283,210,293,220,306,226,320,229,333,230,343,220,343,217,332,212,325,205,320,195,318,183,317,150,317,94,304,57,269,34,223,23,172,20,127,24,87,36,52,57,22,87,2,127,-4,164,1,195,17,219,43,234,76,239,116,233,154,218,186,195,210,166,225,131,230,111,228,92,223,74,213,57,196,43,173,16383,16383,194,102,192,70,184,44,172,25,155,13,135,9,125,10,115,13,106,18,98,25,91,34,81,51,74,70,69,91,66,113,65,137,67,164,75,186,87,202,102,212,122,216,134,215,144,211,153,206,161,199,169,191,178,177,185,161,190,142,193,122,194,102,153,118,169,121,183,128,194,137,202,151,205,168,201,188,191,204,174,215,149,222,118,225,12,225,12,218,26,216,35,214,40,209,42,200,43,187,43,39,42,25,40,16,35,11,26,8,12,7,12,0,149,0,161,2,171,4,181,8,190,12,200,19,208,28,214,39,218,51,219,63,215,82,206,96,191,107,174,114,153,118,16383,16383,85,195,86,202,88,207,92,209,97,211,103,211,127,209,145,203,156,194,162,182,164,166,161,151,154,139,143,130,128,125,110,123,99,124,92,125,87,128,85,132,85,139,16383,16383,85,97,85,102,87,105,91,108,98,109,127,109,144,105,159,98,170,84,174,62,174,63,170,42,160,28,146,19,127,15,106,14, +169,279,183,317,156,279,156,279,183,317,150,317,156,279,150,317,142,279,142,279,150,317,129,278,100,270,129,278,150,317,100,270,150,317,94,304,229,333,230,343,226,320,226,320,230,343,220,343,226,320,220,343,220,306,220,306,220,343,217,332,220,306,217,332,212,325,210,293,220,306,212,325,210,293,212,325,205,320,210,293,205,320,195,318,210,293,195,318,194,283,169,279,182,280,183,317,183,317,182,280,194,283,183,317,194,283,195,318,42,174,47,203,57,269,57,269,47,203,59,230,57,269,59,230,94,304,94,304,59,230,77,253,94,304,77,253,100,270,42,174,57,269,34,223,42,174,34,223,36,52,42,174,36,52,57,22,42,174,57,22,43,173,24,87,36,52,34,223,24,87,34,223,23,172,24,87,23,172,20,127,74,70,87,2,81,51,81,51,87,2,91,34,98,25,91,34,87,2,98,25,87,2,127,-4,65,137,57,196,66,113,66,113,57,196,57,22,66,113,57,22,69,91,69,91,57,22,87,2,69,91,87,2,74,70,131,230,122,216,134,215,131,230,134,215,166,225,166,225,134,215,144,211,166,225,144,211,153,206,75,186,87,202,92,223,92,223,87,202,102,212,92,223,102,212,111,228,111,228,102,212,122,216,111,228,122,216,131,230,74,213,57,196,67,164,74,213,67,164,75,186,74,213,75,186,92,223,67,164,57,196,65,137,192,70,184,44,195,17,195,17,184,44,172,25,195,17,172,25,164,1,164,1,172,25,155,13,164,1,155,13,135,9,135,9,125,10,127,-4,127,-4,125,10,115,13,127,-4,115,13,106,18,185,161,195,210,178,177,178,177,195,210,169,191,161,199,169,191,166,225,161,199,166,225,153,206,195,210,194,102,195,17,195,210,195,17,218,186,218,186,195,17,219,43,218,186,219,43,233,154,233,154,219,43,234,76,233,154,234,76,239,116,195,210,185,161,190,142,195,210,190,142,193,122,195,210,193,122,194,102,195,210,166,225,169,191,135,9,127,-4,164,1,192,70,195,17,194,102,98,25,127,-4,106,18,43,173,57,22,57,196, +153,118,169,121,183,128,194,137,202,151,205,168,201,188,191,204,174,215,149,222,118,225,12,225,12,218,26,216,35,214,40,209,42,200,43,187,43,39,42,25,40,16,35,11,26,8,12,7,12,0,149,0,161,2,171,4,181,8,190,12,200,19,208,28,214,39,218,51,219,63,215,82,206,96,191,107,174,114,153,118,16383,16383,85,195,86,202,88,207,92,209,97,211,103,211,127,209,145,203,156,194,162,182,164,166,161,151,154,139,143,130,128,125,110,123,99,124,92,125,87,128,85,132,85,139,16383,16383,85,97,85,102,87,105,91,108,98,109,127,109,144,105,159,98,170,84,174,62,174,63,170,42,160,28,146,19,127,15,106,14,98,15,92,17,88,20,85,26,85,34,194,155,191,225,8,225,8,218,22,217,31,215,36,211,39,204,40,194,40,40,39,25,36,16,30,11,21,9,8,7,8,0,113,0,113,7,100,9,91,13,85,18,82,26,81,36,81,194,82,200,83,205,86,208,91,209,98,210,130,208,154,201,170,190,180,175,185,155,219,225,21,225,21,218,34,216,44,212,51,206,55,197,56,183,56,99,55,66,51,40,42,22,28,11,7,7,7,-68,16,-68,26,-37,37,-17,47,-5,58,0,172,0,182,-5,191,-17,200,-37,210,-68,219,-68,219,7,206,9,197,11,192,16,189,25,189,198,192,207,198,213,206,216,219,218,16383,16383,147,41,146,30,143,23,139,18,133,15,126,14,58,14,64,28,68,43,71,59,73,75,73,190,74,199, +40,16,35,11,137,0,137,0,35,11,26,8,137,0,26,8,12,7,86,202,88,207,43,187,43,187,88,207,92,209,43,187,92,209,118,225,118,225,92,209,97,211,118,225,97,211,103,211,103,211,127,209,118,225,118,225,127,209,149,222,159,98,170,84,174,114,174,114,170,84,174,62,174,114,174,62,174,63,174,63,174,62,181,8,181,8,174,62,171,4,171,4,174,62,170,42,171,4,170,42,161,2,161,2,170,42,160,28,161,2,160,28,149,0,149,0,160,28,146,19,149,0,146,19,137,0,137,0,146,19,127,15,137,0,127,15,106,14,106,14,98,15,137,0,137,0,98,15,92,17,137,0,92,17,42,25,42,25,92,17,43,39,127,109,110,123,109,109,98,109,109,109,99,124,98,109,99,124,92,125,85,139,85,102,85,132,85,132,85,102,87,105,85,132,87,105,87,128,87,128,87,105,91,108,87,128,91,108,92,125,92,125,91,108,98,109,110,123,99,124,109,109,161,151,169,121,164,166,164,166,169,121,174,215,174,215,169,121,183,128,174,215,183,128,191,204,191,204,183,128,194,137,191,204,194,137,201,188,201,188,194,137,202,151,201,188,202,151,205,168,127,209,145,203,149,222,149,222,145,203,156,194,149,222,156,194,174,215,174,215,156,194,162,182,174,215,162,182,164,166,159,98,153,118,144,105,144,105,153,118,154,139,154,139,153,118,169,121,154,139,169,121,161,151,110,123,127,109,128,125,128,125,127,109,144,105,128,125,144,105,143,130,143,130,144,105,154,139,215,82,206,96,208,28,215,82,208,28,214,39,215,82,214,39,218,51,215,82,218,51,219,63,181,8,190,12,191,107,191,107,190,12,200,19,191,107,200,19,206,96,206,96,200,19,208,28,191,107,174,114,174,63,191,107,174,63,181,8,85,26,85,34,43,187,85,26,43,187,43,39,85,26,43,39,88,20,85,195,86,202,43,187,85,195,43,187,85,34,35,214,40,209,118,225,118,225,40,209,42,200,118,225,42,200,43,187,26,216,35,214,118,225,26,216,118,225,12,225,26,216,12,225,12,218,137,0,12,7,12,0,40,16,137,0,42,25,43,39,92,17,88,20,153,118,159,98,174,114,85,102,85,139,85,97, +194,155,191,225,8,225,8,218,22,217,31,215,36,211,39,204,40,194,40,40,39,25,36,16,30,11,21,9,8,7,8,0,113,0,113,7,100,9,91,13,85,18,82,26,81,36,81,194,82,200,83,205,86,208,91,209,98,210,130,208,154,201,170,190,180,175,185,155,219,225,21,225,21,218,34,216,44,212,51,206,55,197,56,183,56,99,55,66,51,40,42,22,28,11,7,7,7,-68,16,-68,26,-37,37,-17,47,-5,58,0,172,0,182,-5,191,-17,200,-37,210,-68,219,-68,219,7,206,9,197,11,192,16,189,25,189,198,192,207,198,213, +36,211,39,204,191,225,191,225,39,204,91,209,191,225,91,209,98,210,98,210,130,208,191,225,191,225,130,208,154,201,191,225,154,201,170,190,191,225,170,190,180,175,191,225,180,175,185,155,191,225,185,155,194,155,81,36,81,194,40,194,40,194,81,194,82,200,40,194,82,200,83,205,40,194,83,205,86,208,40,194,86,208,91,209,40,194,91,209,39,204,40,194,82,26,81,36,191,225,8,225,22,217,191,225,22,217,31,215,191,225,31,215,36,211,113,0,113,7,100,9,113,0,100,9,91,13,113,0,91,13,40,40,113,0,40,40,39,25,113,0,39,25,36,16,113,0,36,16,30,11,113,0,30,11,21,9,113,0,21,9,8,7,113,0,8,7,8,0,40,40,91,13,85,18,40,40,85,18,82,26,40,40,82,26,40,194,22,217,8,225,8,218, +219,225,21,225,21,218,34,216,44,212,51,206,55,197,56,183,56,99,55,66,51,40,42,22,28,11,7,7,7,-68,16,-68,26,-37,37,-17,47,-5,58,0,172,0,182,-5,191,-17,200,-37,210,-68,219,-68,219,7,206,9,197,11,192,16,189,25,189,198,192,207,198,213,206,216,219,218,16383,16383,147,41,146,30,143,23,139,18,133,15,126,14,58,14,64,28,68,43,71,59,73,75,73,190,74,199,76,205,80,209,85,210,92,211,135,211,141,209,145,205,146,199,147,190,210,82,196,63,182,48,167,39,150,33,132,31,102,37,80,53,66,77,58,106,55,137,209,137,208,152,205,165,202,176,197,186,192,195,181,207,169,217,156,224,140,228,123,230,88,224,59,207,37,182,24,148,19,108,23,70,35,39,55,15,81,0,114,-4,142,-1,167,9,188,26,205,49,219,79,16383,16383,56,151,61,172,69,190,80,203,93,211,109,214,126,211,139,203,148,191,154,173,158,151,353,0,353,7,347,8,341,10,331,14,327,17,323,21,317,28,311,37,304,47, +34,216,44,212,219,225,219,225,44,212,85,210,219,225,85,210,92,211,219,225,92,211,127,211,219,225,127,211,135,211,126,14,58,14,68,0,126,14,68,0,161,0,126,14,161,0,133,15,147,190,161,0,189,198,189,198,161,0,172,0,189,198,172,0,189,183,189,183,172,0,182,-5,189,183,182,-5,189,41,189,41,182,-5,191,-17,189,41,191,-17,189,25,161,0,147,190,147,41,161,0,147,41,146,30,161,0,146,30,143,23,161,0,143,23,139,18,161,0,139,18,133,15,219,225,135,211,141,209,219,225,141,209,145,205,219,225,145,205,146,199,219,225,146,199,147,190,219,225,147,190,198,213,219,225,198,213,206,216,219,225,206,216,219,218,192,207,198,213,147,190,192,207,147,190,189,198,73,190,74,199,58,14,73,190,58,14,64,28,73,190,64,28,68,43,73,190,68,43,71,59,73,190,71,59,73,75,73,190,73,75,73,89,58,0,68,0,58,14,58,0,58,14,56,183,58,0,56,183,56,99,58,0,56,99,55,66,58,0,55,66,51,40,58,0,51,40,47,-5,58,14,74,199,56,183,56,183,74,199,76,205,56,183,76,205,55,197,55,197,76,205,80,209,55,197,80,209,51,206,51,206,80,209,85,210,51,206,85,210,44,212,21,225,21,218,34,216,21,225,34,216,219,225,219,-68,219,7,210,-68,210,-68,219,7,206,9,210,-68,206,9,200,-37,200,-37,206,9,197,11,200,-37,197,11,192,16,192,16,189,25,191,-17,192,16,191,-17,200,-37,16,-68,26,-37,28,11,28,11,26,-37,37,-17,28,11,37,-17,42,22,42,22,37,-17,47,-5,42,22,47,-5,51,40,7,7,7,-68,16,-68,7,7,16,-68,28,11, +210,82,196,63,182,48,167,39,150,33,132,31,102,37,80,53,66,77,58,106,55,137,209,137,208,152,205,165,202,176,197,186,192,195,181,207,169,217,156,224,140,228,123,230,88,224,59,207,37,182,24,148,19,108,23,70,35,39,55,15,81,0,114,-4,142,-1,167,9,188,26,205,49,219,79,16383,16383,56,151,61,172,69,190,80,203,93,211,109,214,126,211,139,203,148,191,154,173,158,151,353,0,353,7,347,8,341,10,331,14,327,17,323,21,317,28,311,37,304,47,298,58,286,79,275,94,264,105,253,113,240,120,240,121,258,137,269,156,278,172,286,185,297,190,301,189,306,187,318,183,324,182,332,183,338,186,343,191,346,197,347,204,346,211,342,218,336,223,327,227,316,228,306,227,297,224,289,218,282,211,275,201,267,187,259,171,251,156,242,143,233,135,228,132,222,130,215,128, +80,53,66,77,81,0,81,0,66,77,58,106,81,0,58,106,55,15,55,15,58,106,55,137,56,151,55,137,209,137,56,151,209,137,158,151,158,151,209,137,169,217,140,228,123,230,126,211,126,211,123,230,109,214,93,211,109,214,123,230,93,211,123,230,88,224,156,224,140,228,148,191,156,224,148,191,154,173,156,224,154,173,158,151,156,224,158,151,169,217,140,228,126,211,139,203,140,228,139,203,148,191,56,151,61,172,59,207,59,207,61,172,69,190,59,207,69,190,88,224,88,224,69,190,80,203,88,224,80,203,93,211,37,182,24,148,35,39,37,182,35,39,55,15,37,182,55,15,55,137,37,182,55,137,56,151,37,182,56,151,59,207,24,148,19,108,23,70,24,148,23,70,35,39,81,0,114,-4,102,37,102,37,114,-4,132,31,150,33,132,31,142,-1,150,33,142,-1,167,9,209,137,208,152,205,165,209,137,205,165,202,176,209,137,202,176,197,186,209,137,197,186,192,195,209,137,192,195,181,207,209,137,181,207,169,217,219,79,210,82,205,49,205,49,210,82,196,63,205,49,196,63,188,26,188,26,196,63,182,48,188,26,182,48,167,9,167,9,182,48,167,39,167,9,167,39,150,33,132,31,114,-4,142,-1,80,53,81,0,102,37, +353,0,353,7,347,8,341,10,331,14,327,17,323,21,317,28,311,37,304,47,298,58,286,79,275,94,264,105,253,113,240,120,240,121,258,137,269,156,278,172,286,185,297,190,301,189,306,187,318,183,324,182,332,183,338,186,343,191,346,197,347,204,346,211,342,218,336,223,327,227,316,228,306,227,297,224,289,218,282,211,275,201,267,187,259,171,251,156,242,143,233,135,228,132,222,130,215,128,208,127,200,127,200,190,201,199,204,207,210,212,219,216,232,218,232,225,128,225,128,218,140,216,149,214,154,209,158,201,158,127,151,127,144,128,138,129,132,132,127,135,117,145,108,157,101,170,88,196,82,207,75,216,67,223,56,227,44,228,34,227,26,224,20,219,15,212,14,204,15,197,18,191,23,186,29,183,36,182,43,183,50,185,60,189,65,190,74,185,80,172,87,155,100,137,121,121,121,120,107,114,95,107,85,95,74,79,62,57,63,57,56,46,50,36,44,28,38,21,33,17,29,14,25,12,19,10,14,8,7,7,7,0,73,0,124,83,133,96,139,104,145,109,151,112,158,113,158,25,155,18,151,13,145,10,137,8,126,7,126,0,234,0,234,7,214,9,207,12,203,17,201,24,200,33,200,113,209,111,216,108,222,104,228,95,237,82,287,0,114,121,130,126,146,134,158,146,167,160,170,177,168,188,164,198,158,207,149,215,139,221,121,227,111,229,99,230,80,230,75,229,69,228,64,226,57,224,49,222,46,220,42,219,35,219,29,223,27,226,26,230,20,230,16,150,25,150,30,172,38,190,50,204,65,213,85,216,98,214,110,209,119,200,125,188,127,172,126,163,123,155,118,147,112,140,104,135,97,132,89,129,81,128,72,127,60,127,60,113,86,111,106,106,120,96,129,82,132,62,130,47,124,34,114,23,99,15,79,13,65,14,52,18,40,24,28,33,14,46,7,39,19,23,32,11,46,2,64,-2,85,-4,113,-2,125,1,137,5,147,12,157,20,166,29,173,40,177,52,179,65,175,84,165,99,151,110,133,117,114,121,251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,84,60,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,178,165,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9,229,12,224,17,221,26,220,40,220,183,221,198,223,207,229,213,238,216,251,218,201,319,199,330,195,340, +25,12,19,10,73,0,73,0,19,10,14,8,73,0,14,8,7,7,50,36,44,28,73,0,73,0,44,28,38,21,73,0,38,21,33,17,33,17,29,14,73,0,73,0,29,14,25,12,95,107,85,95,124,83,124,83,85,95,74,79,124,83,74,79,73,0,73,0,74,79,62,57,73,0,62,57,56,46,56,46,62,57,63,57,67,223,65,190,74,185,67,223,74,185,75,216,75,216,74,185,80,172,75,216,80,172,82,207,82,207,80,172,87,155,82,207,87,155,88,196,88,196,87,155,100,137,88,196,100,137,94,184,94,184,100,137,101,170,50,185,55,187,56,227,56,227,55,187,60,189,56,227,60,189,67,223,67,223,60,189,65,190,44,228,34,227,36,182,44,228,36,182,43,183,44,228,43,183,50,185,44,228,50,185,56,227,14,204,15,197,15,212,15,212,15,197,18,191,15,212,18,191,20,219,20,219,18,191,23,186,20,219,23,186,26,224,26,224,23,186,29,183,26,224,29,183,34,227,34,227,29,183,36,182,127,135,121,121,124,83,127,135,124,83,133,96,127,135,117,145,121,121,121,121,117,145,108,157,121,121,108,157,101,170,121,121,101,170,100,137,155,18,151,13,234,0,234,0,151,13,145,10,234,0,145,10,137,8,137,8,126,7,234,0,234,0,126,7,126,0,234,0,234,7,224,8,234,0,224,8,214,9,234,0,214,9,207,12,234,0,207,12,158,33,234,0,158,33,158,25,234,0,158,25,155,18,201,24,200,33,158,113,201,24,158,113,203,17,203,17,158,113,158,33,158,113,200,33,200,127,158,113,200,127,200,190,158,113,200,190,201,199,158,113,201,199,204,207,158,113,204,207,158,189,158,113,158,189,158,127,215,128,208,127,209,111,209,111,208,127,200,127,232,225,128,225,140,216,232,225,140,216,149,214,232,225,149,214,154,209,232,225,154,209,158,201,232,225,158,201,158,189,232,225,158,189,210,212,232,225,210,212,219,216,232,225,219,216,232,218,264,105,253,113,287,0,287,0,253,113,240,120,287,0,240,120,237,82,237,82,240,120,240,121,237,82,240,121,233,135,237,82,233,135,228,95,228,95,233,135,228,132,228,95,228,132,222,104,222,104,228,132,222,130,222,104,222,130,216,108,216,108,222,130,215,128,216,108,215,128,209,111,317,28,311,37,287,0,287,0,311,37,304,47,287,0,304,47,298,58,297,224,297,190,301,189,297,224,301,189,306,227,306,227,301,189,306,187,306,227,306,187,316,228,316,228,306,187,312,185,316,228,312,185,318,183,297,190,289,218,286,185,286,185,289,218,282,211,286,185,282,211,278,172,278,172,282,211,275,201,278,172,275,201,269,156,269,156,275,201,267,187,269,156,267,187,259,171,258,137,269,156,259,171,258,137,259,171,251,156,258,137,251,156,242,143,258,137,242,143,240,121,242,143,233,135,240,121,318,183,324,182,327,227,327,227,324,182,332,183,327,227,332,183,336,223,336,223,332,183,338,186,336,223,338,186,342,218,342,218,338,186,343,191,342,218,343,191,346,211,346,211,343,191,346,197,346,211,346,197,347,204,317,28,287,0,323,21,323,21,287,0,327,17,331,14,327,17,287,0,331,14,287,0,353,0,353,0,353,7,347,8,353,0,347,8,341,10,353,0,341,10,336,12,353,0,336,12,331,14,287,0,298,58,286,79,287,0,286,79,275,94,287,0,275,94,264,105,145,109,151,112,151,127,151,127,151,112,158,113,151,127,158,113,158,127,132,132,127,135,133,96,132,132,133,96,138,129,138,129,133,96,139,104,138,129,139,104,144,128,144,128,139,104,145,109,144,128,145,109,151,127,124,83,121,121,121,120,124,83,121,120,107,114,124,83,107,114,95,107,73,0,7,7,7,0,50,36,73,0,56,46,316,228,318,183,327,227,297,190,297,224,289,218,200,127,200,113,209,111,140,216,128,225,128,218,210,212,158,189,204,207,158,33,207,12,203,17, +114,121,130,126,146,134,158,146,167,160,170,177,168,188,164,198,158,207,149,215,139,221,121,227,111,229,99,230,80,230,75,229,69,228,64,226,57,224,49,222,46,220,42,219,35,219,29,223,27,226,26,230,20,230,16,150,25,150,30,172,38,190,50,204,65,213,85,216,98,214,110,209,119,200,125,188,127,172,126,163,123,155,118,147,112,140,104,135,97,132,89,129,81,128,72,127,60,127,60,113,86,111,106,106,120,96,129,82,132,62,130,47,124,34,114,23,99,15,79,13,65,14,52,18,40,24,28,33,14,46,7,39,19,23,32,11,46,2,64,-2,85,-4,113,-2,125,1,137,5,147,12,157,20,166,29,173,40,177,52,179,65,175,84,165,99,151,110,133,117,114,121,251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,84,60,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,178,165,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9,229,12,224,17,221,26,220,40,220,183,221,198,223,207,229,213,238,216,251,218,201,319,199,330,195,340,188,347,180,351,171,352,167,352,161,348,159,344,158,339,160,332,166,329,172,327,178,324,180,319,179,313,174,307,166,303,152,300,133,299,115,300,102,303,93,307,88,313,87,319,89,324,95,327,101,329,107,332, +26,230,20,230,25,150,26,230,25,150,30,172,26,230,30,172,27,226,49,222,46,220,50,204,50,204,46,220,42,219,50,204,42,219,39,219,39,219,35,219,38,190,38,190,35,219,32,221,38,190,32,221,30,172,30,172,32,221,29,223,30,172,29,223,27,226,64,-2,85,-4,65,14,65,14,85,-4,79,13,99,15,79,13,85,-4,99,15,85,-4,99,-3,85,216,80,230,75,229,85,216,75,229,69,228,85,216,69,228,65,213,85,216,86,230,80,230,65,213,69,228,64,226,65,213,64,226,57,224,65,213,57,224,53,223,65,213,53,223,50,204,39,219,38,190,50,204,81,128,86,111,89,129,89,129,86,111,106,106,89,129,106,106,97,132,97,132,106,106,104,135,112,140,104,135,106,106,112,140,106,106,114,121,114,121,106,106,120,96,114,121,120,96,133,117,133,117,120,96,129,82,133,117,129,82,132,62,86,230,98,214,99,230,99,230,98,214,110,209,99,230,110,209,111,229,111,229,110,209,119,200,111,229,119,200,121,227,121,227,119,200,125,188,121,227,125,188,130,224,130,224,125,188,127,172,130,126,127,172,126,163,126,163,123,155,130,126,130,126,123,155,118,147,130,126,118,147,114,121,114,121,118,147,112,140,170,177,168,188,167,160,167,160,168,188,164,198,167,160,164,198,158,146,158,146,164,198,158,207,158,146,158,207,149,215,146,134,158,146,149,215,146,134,149,215,139,221,146,134,139,221,130,224,146,134,130,224,130,126,85,216,98,214,86,230,133,117,132,62,137,5,133,117,137,5,151,110,151,110,137,5,147,12,151,110,147,12,157,20,175,84,165,99,166,29,175,84,166,29,173,40,175,84,173,40,177,52,175,84,177,52,179,65,165,99,151,110,157,20,165,99,157,20,166,29,130,47,124,34,125,1,130,47,125,1,137,5,130,47,137,5,132,62,114,23,99,15,99,-3,114,23,99,-3,113,-2,114,23,113,-2,125,1,114,23,125,1,124,34,72,127,60,127,86,111,72,127,86,111,81,128,14,46,19,23,28,33,28,33,19,23,32,11,28,33,32,11,40,24,40,24,32,11,46,2,40,24,46,2,52,18,52,18,46,2,64,-2,52,18,64,-2,65,14,19,23,14,46,7,39,86,111,60,127,60,113,130,224,127,172,130,126,49,222,50,204,53,223,25,150,20,230,16,150, +251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,84,60,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,178,165,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9,229,12,224,17,221,26,220,40,220,183,221,198,223,207,229,213,238,216,251,218,201,319,199,330,195,340,188,347,180,351,171,352,167,352,161,348,159,344,158,339,160,332,166,329,172,327,178,324,180,319,179,313,174,307,166,303,152,300,133,299,115,300,102,303,93,307,88,313,87,319,89,324,95,327,101,329,107,332,109,339,108,344,107,348,101,352,97,352,88,351,80,347,73,340,68,330,66,319,70,302,82,289,98,280,116,275,133,273,151,275,169,280,185,289,196,302,201,319,16383,16383,251,225,147,225,147,218,160,216,169,213,174,207, +39,16,33,11,116,0,116,0,33,11,25,9,116,0,25,9,12,7,178,189,84,60,84,36,84,36,84,189,42,183,42,183,84,189,85,199,42,183,85,199,88,207,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,42,183,88,207,93,212,42,183,93,212,42,197,174,18,169,12,251,0,251,0,169,12,160,9,251,0,160,9,147,7,169,213,174,207,251,225,251,225,174,207,177,200,251,225,177,200,178,189,178,189,178,165,221,26,221,26,178,165,178,37,221,26,178,37,224,17,224,17,178,37,229,12,238,216,251,218,251,225,238,216,251,225,229,213,229,213,251,225,178,189,229,213,178,189,223,207,223,207,178,189,221,198,220,40,220,183,178,189,220,40,178,189,221,26,160,216,169,213,251,225,160,216,251,225,147,225,160,216,147,225,147,218,251,0,251,7,238,9,251,0,238,9,229,12,251,0,229,12,178,37,251,0,178,37,177,26,251,0,177,26,174,18,116,0,116,7,102,9,116,0,102,9,93,13,116,0,93,13,42,40,116,0,42,40,42,25,116,0,42,25,39,16,85,26,84,36,42,183,85,26,42,183,42,40,85,26,42,40,88,18,116,0,12,7,12,0,42,40,93,13,88,18,251,0,147,7,147,0,221,198,178,189,220,183,178,189,84,36,178,165,25,216,12,225,12,218, +201,319,199,330,195,340,188,347,180,351,171,352,167,352,161,348,159,344,158,339,160,332,166,329,172,327,178,324,180,319,179,313,174,307,166,303,152,300,133,299,115,300,102,303,93,307,88,313,87,319,89,324,95,327,101,329,107,332,109,339,108,344,107,348,101,352,97,352,88,351,80,347,73,340,68,330,66,319,70,302,82,289,98,280,116,275,133,273,151,275,169,280,185,289,196,302,201,319,16383,16383,251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,84,60,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,178,165,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9,229,12,224,17,221,26,220,40,220,183,221,198,223,207,229,213,238,216,251,218,248,0,248,7,241,8,235,10,225,14,221,17,217,21,211,28,205,37,198,47,192,58,180,79,168,94,156,105,144,113,131,120,131,121,148,137,160,156,168,172,176,185,188,190,192,189,202,185,208,183,214,182,222,183,228,186,233,191,237,197,238,204,236,211,233,218,226,223,218,227,207,228,196,227,185,223,176,216,168,207,161,196,140,154,132,143,124,135,118,132,112,130,105,128,98,127,91,127,91,190,92,199,95,207,100,212,109,216,122,218,122,225,18,225,18,218,31,216,39,214,45,209,48,201,49,189,49,25,46,18,42,13,36,10,26,8,12,7,12,0,128,0,128,7,117,8,107,9,99,12,94,17,92,24,91,33,91,113,99,111,106,108,112,103,118,95,127,82,181,0,238,225,45,225,45,218,57,216,66,212,71,206,74,197,75,183,75,99,74,77,73,53,69,33,62,18,50,12,46,15,42,22,38,30,32,36,23,39,18,38,13,36, +102,303,93,307,98,280,98,280,93,307,88,313,98,280,88,313,82,289,82,289,88,313,87,319,88,351,87,319,89,324,88,351,89,324,97,352,97,352,89,324,95,327,97,352,95,327,101,329,101,352,101,329,104,350,104,350,101,329,107,332,104,350,107,332,107,348,107,348,107,332,109,339,107,348,109,339,108,344,82,289,87,319,88,351,82,289,88,351,80,347,82,289,80,347,73,340,82,289,73,340,70,302,68,330,66,319,70,302,68,330,70,302,73,340,102,303,116,275,115,300,115,300,116,275,133,299,152,300,133,299,133,273,152,300,133,273,151,275,196,302,201,319,199,330,196,302,199,330,195,340,196,302,195,340,188,347,196,302,188,347,185,289,185,289,188,347,180,319,185,289,180,319,179,313,185,289,179,313,174,307,185,289,174,307,169,280,180,351,171,352,172,327,180,351,172,327,178,324,180,351,178,324,180,319,180,351,180,319,188,347,167,352,164,350,166,329,167,352,166,329,172,327,167,352,172,327,171,352,161,348,159,344,160,332,161,348,160,332,166,329,161,348,166,329,164,350,169,280,174,307,166,303,169,280,166,303,152,300,169,280,152,300,151,275,133,299,116,275,133,273,39,16,33,11,116,0,116,0,33,11,25,9,116,0,25,9,12,7,178,189,84,60,84,36,84,36,84,189,42,183,42,183,84,189,85,199,42,183,85,199,88,207,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,42,183,88,207,93,212,42,183,93,212,42,197,174,18,169,12,251,0,251,0,169,12,160,9,251,0,160,9,147,7,169,213,174,207,251,225,251,225,174,207,177,200,251,225,177,200,178,189,178,189,178,165,221,26,221,26,178,165,178,37,221,26,178,37,224,17,224,17,178,37,229,12,238,216,251,218,251,225,238,216,251,225,229,213,229,213,251,225,178,189,229,213,178,189,223,207,223,207,178,189,221,198,220,40,220,183,178,189,220,40,178,189,221,26,160,216,169,213,251,225,160,216,251,225,147,225,160,216,147,225,147,218,251,0,251,7,238,9,251,0,238,9,229,12,251,0,229,12,178,37,251,0,178,37,177,26,251,0,177,26,174,18,116,0,116,7,102,9,116,0,102,9,93,13,116,0,93,13,42,40,116,0,42,40,42,25,116,0,42,25,39,16,85,26,84,36,42,183,85,26,42,183,42,40,85,26,42,40,88,18,116,0,12,7,12,0,42,40,93,13,88,18,251,0,147,7,147,0,221,198,178,189,220,183,178,189,84,36,178,165,25,216,12,225,12,218,160,332,159,344,158,339,102,303,98,280,116,275,97,352,101,329,101,352, +248,0,248,7,241,8,235,10,225,14,221,17,217,21,211,28,205,37,198,47,192,58,180,79,168,94,156,105,144,113,131,120,131,121,148,137,160,156,168,172,176,185,188,190,192,189,202,185,208,183,214,182,222,183,228,186,233,191,237,197,238,204,236,211,233,218,226,223,218,227,207,228,196,227,185,223,176,216,168,207,161,196,140,154,132,143,124,135,118,132,112,130,105,128,98,127,91,127,91,190,92,199,95,207,100,212,109,216,122,218,122,225,18,225,18,218,31,216,39,214,45,209,48,201,49,189,49,25,46,18,42,13,36,10,26,8,12,7,12,0,128,0,128,7,117,8,107,9,99,12,94,17,92,24,91,33,91,113,99,111,106,108,112,103,118,95,127,82,181,0,238,225,45,225,45,218,57,216,66,212,71,206,74,197,75,183,75,99,74,77,73,53,69,33,62,18,50,12,46,15,42,22,38,30,32,36,23,39,18,38,13,36,8,33,5,27,4,20,6,10,10,3,18,-1,28,-3,39,-4,64,2,79,18,88,41,91,66,92,89,92,198,94,204,98,208,103,210,110,211,154,211,159,209,163,205,165,199,165,37,164,26,161,18,156,12,147,9,134,7,134,0,238,0,238,7,225,9,216,12,211,17,208,26,207,40,207,183,208,198,211,207,216,213,225,216,238,218,297,225,229,225,157,62,79,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,92,0,92,7,78,9,69,12,63,18,60,26, +46,18,42,13,128,0,128,0,42,13,36,10,128,0,36,10,26,8,26,8,12,7,128,0,128,0,12,7,12,0,128,0,128,7,117,8,128,0,117,8,107,9,128,0,107,9,99,12,128,0,99,12,49,33,128,0,49,33,49,25,128,0,49,25,46,18,91,33,91,127,49,189,91,33,49,189,92,24,49,33,99,12,94,17,49,33,94,17,92,24,49,33,92,24,49,189,91,113,99,111,91,127,91,127,91,190,49,189,49,189,91,190,92,199,49,189,92,199,95,207,122,225,18,225,31,216,122,225,31,216,39,214,122,225,39,214,45,209,122,225,45,209,48,201,122,225,48,201,49,189,122,225,49,189,100,212,122,225,100,212,109,216,122,225,109,216,122,218,106,108,112,103,112,130,112,130,112,103,118,95,112,130,118,95,118,132,118,132,118,95,124,135,132,143,124,135,127,82,105,128,98,127,99,111,105,128,99,111,106,108,105,128,106,108,112,130,127,82,124,135,118,95,202,185,207,228,197,187,197,187,207,228,196,227,197,187,196,227,192,189,192,189,196,227,188,190,176,185,188,190,185,223,176,185,185,223,176,216,147,168,148,137,154,182,154,182,148,137,160,156,154,182,160,156,161,196,161,196,160,156,168,172,161,196,168,172,168,207,168,207,168,172,176,185,168,207,176,185,176,216,156,105,144,113,181,0,181,0,144,113,131,120,181,0,131,120,127,82,127,82,131,120,131,121,127,82,131,121,132,143,132,143,131,121,148,137,132,143,148,137,140,154,140,154,148,137,147,168,208,183,214,182,218,227,218,227,214,182,222,183,218,227,222,183,226,223,226,223,222,183,228,186,226,223,228,186,233,218,233,218,228,186,233,191,233,218,233,191,236,211,236,211,233,191,237,197,236,211,237,197,238,204,207,228,202,185,208,183,207,228,208,183,218,227,196,227,185,223,188,190,211,28,181,0,217,21,217,21,181,0,221,17,225,14,221,17,181,0,225,14,181,0,248,0,248,0,248,7,241,8,248,0,241,8,235,10,248,0,235,10,230,12,248,0,230,12,225,14,181,0,211,28,205,37,181,0,205,37,198,47,181,0,198,47,192,58,181,0,192,58,180,79,181,0,180,79,168,94,181,0,168,94,156,105,91,127,99,111,98,127,31,216,18,225,18,218,100,212,49,189,95,207, +238,225,45,225,45,218,57,216,66,212,71,206,74,197,75,183,75,99,74,77,73,53,69,33,62,18,50,12,46,15,42,22,38,30,32,36,23,39,18,38,13,36,8,33,5,27,4,20,6,10,10,3,18,-1,28,-3,39,-4,64,2,79,18,88,41,91,66,92,89,92,198,94,204,98,208,103,210,110,211,154,211,159,209,163,205,165,199,165,37,164,26,161,18,156,12,147,9,134,7,134,0,238,0,238,7,225,9,216,12,211,17,208,26,207,40,207,183,208,198,211,207,216,213,225,216,238,218,297,225,229,225,157,62,79,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,92,0,92,7,78,9,69,12,63,18,60,26,59,36,59,172,60,172,143,0,147,0,224,174,224,37,223,26,220,18,214,12,204,9,190,7,190,0,296,0,296,7,284,9,275,12,270,17,267,26,266,40,266,183,267,198,270,207,275,213,284,216,297,218,251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,178,124,84,124,84,189,85,199,88,207,93,212,102,216, +74,77,73,53,79,18,79,18,73,53,69,33,79,18,69,33,64,2,64,2,69,33,62,18,64,2,62,18,50,12,50,12,46,15,64,2,64,2,46,15,39,-4,57,216,66,212,238,225,238,225,66,212,103,210,238,225,103,210,110,211,238,225,110,211,145,211,238,225,145,211,154,211,161,18,156,12,238,0,238,0,156,12,147,9,238,0,147,9,134,7,238,225,154,211,159,209,238,225,159,209,163,205,238,225,163,205,165,199,238,225,165,199,165,190,238,225,165,190,216,213,238,225,216,213,225,216,238,225,225,216,238,218,207,40,207,183,165,190,165,190,207,183,208,198,165,190,208,198,211,207,216,12,211,17,165,37,165,37,211,17,208,26,165,37,208,26,165,190,92,189,92,198,75,183,92,189,75,183,79,18,92,189,79,18,88,41,92,189,88,41,91,66,92,189,91,66,92,89,75,183,92,198,94,204,75,183,94,204,98,208,75,183,98,208,74,197,71,206,74,197,98,208,71,206,98,208,103,210,71,206,103,210,66,212,45,225,45,218,57,216,45,225,57,216,238,225,238,0,238,7,225,9,238,0,225,9,216,12,238,0,216,12,165,37,238,0,165,37,164,26,238,0,164,26,161,18,75,99,74,77,79,18,75,99,79,18,75,183,39,-4,46,15,42,22,39,-4,42,22,38,30,39,-4,38,30,32,36,39,-4,32,36,28,-3,32,36,23,39,28,-3,28,-3,23,39,18,38,28,-3,18,38,18,-1,18,-1,18,38,13,36,18,-1,13,36,10,3,10,3,13,36,8,33,10,3,8,33,6,10,6,10,8,33,5,27,6,10,5,27,4,20,238,0,134,7,134,0,165,190,208,26,207,40,216,213,165,190,211,207, +297,225,229,225,157,62,79,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,92,0,92,7,78,9,69,12,63,18,60,26,59,36,59,172,60,172,143,0,147,0,224,174,224,37,223,26,220,18,214,12,204,9,190,7,190,0,296,0,296,7,284,9,275,12,270,17,267,26,266,40,266,183,267,198,270,207,275,213,284,216,297,218,251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,178,124,84,124,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,108,178,108,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9, +39,16,33,11,92,0,92,0,33,11,25,9,92,0,25,9,12,7,220,18,214,12,296,0,296,0,214,12,204,9,296,0,204,9,190,7,229,225,157,62,224,174,229,225,224,174,267,26,229,225,267,26,266,40,229,225,266,40,266,183,229,225,266,183,267,198,229,225,267,198,270,207,229,225,270,207,275,213,229,225,275,213,297,225,59,172,60,172,79,225,79,225,60,172,143,0,79,225,143,0,157,62,157,62,143,0,147,0,157,62,147,0,224,174,92,7,78,9,92,0,92,0,78,9,69,12,92,0,69,12,42,25,42,25,69,12,63,18,42,25,63,18,42,40,42,40,63,18,60,26,42,40,60,26,42,183,42,183,60,26,59,36,42,183,59,36,59,172,79,225,12,225,25,216,79,225,25,216,33,212,79,225,33,212,39,206,79,225,39,206,42,197,79,225,42,197,42,183,79,225,42,183,59,172,284,216,297,218,297,225,284,216,297,225,275,213,296,0,296,7,284,9,296,0,284,9,275,12,296,0,275,12,224,37,296,0,224,37,223,26,296,0,223,26,220,18,224,37,275,12,270,17,224,37,270,17,267,26,224,37,267,26,224,174,92,0,12,7,12,0,39,16,92,0,42,25,296,0,190,7,190,0,25,216,12,225,12,218, +251,225,147,225,147,218,160,216,169,213,174,207,177,200,178,189,178,124,84,124,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,108,178,108,178,37,177,26,174,18,169,12,160,9,147,7,147,0,251,0,251,7,238,9,229,12,224,17,221,26,220,40,220,183,221,198,223,207,229,213,238,216,251,218,238,116,232,154,217,186,194,210,165,225,130,230,92,225,61,209,38,185,23,153,17,114,23,75,38,42,61,17,91,1,126,-4,163,1,194,17,218,43,233,76,238,116,16383,16383,193,102,190,70,183,44,171,25,154,13,134,9,123,10,114,13,104,18,96,25,89,34,79,51,72,70,66,91,63,113,63,137,65,164,73,186,85,202,101,212,121,216,132,215,143,211,152,206,161,199,168,191,177,177,184,161,189,142,192,122,193,102,251,225,12,225,12,218,25,217,33,214, +39,16,33,11,116,0,116,0,33,11,25,9,116,0,25,9,12,7,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,42,183,85,26,84,36,84,124,84,108,178,108,84,124,178,108,178,124,178,124,178,108,224,17,178,124,224,17,221,26,42,183,84,36,84,189,42,183,84,189,85,199,42,183,85,199,88,207,42,183,88,207,93,212,42,183,93,212,42,197,174,18,169,12,251,0,251,0,169,12,160,9,251,0,160,9,147,7,251,225,147,225,160,216,251,225,160,216,169,213,251,225,169,213,174,207,251,225,174,207,177,200,251,225,177,200,178,189,251,225,178,189,229,213,251,225,229,213,238,216,251,225,238,216,251,218,220,40,220,183,178,189,178,189,220,183,221,198,178,189,221,198,223,207,178,189,221,26,220,40,251,0,251,7,238,9,251,0,238,9,229,12,251,0,229,12,178,37,251,0,178,37,177,26,251,0,177,26,174,18,178,37,229,12,224,17,178,37,224,17,178,108,116,0,116,7,102,9,116,0,102,9,93,13,116,0,93,13,42,40,116,0,42,40,42,25,116,0,42,25,39,16,42,40,93,13,88,18,42,40,88,18,85,26,42,40,85,26,42,183,116,0,12,7,12,0,251,0,147,7,147,0,178,124,221,26,178,189,160,216,147,225,147,218,229,213,178,189,223,207,25,216,12,225,12,218, +238,116,232,154,217,186,194,210,165,225,130,230,92,225,61,209,38,185,23,153,17,114,23,75,38,42,61,17,91,1,126,-4,163,1,194,17,218,43,233,76,238,116,16383,16383,193,102,190,70,183,44,171,25,154,13,134,9,123,10,114,13,104,18,96,25,89,34,79,51,72,70,66,91,63,113,63,137,65,164,73,186,85,202,101,212,121,216,132,215,143,211,152,206,161,199,168,191,177,177,184,161,189,142,192,122,193,102,251,225,12,225,12,218,25,217,33,214,39,209,42,200,42,26,39,17,33,12,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,186,85,196,88,203,92,208,98,210,105,211,156,211,163,210,169,208,174,203,177,196,178,186,178,37,177,26,175,18,170,12,161,9,148,7,148,0,251,0,251,7,238,9,229,11,224,16,221,24,220,37,220,184,221,199,224,209,230,214,238,217,251,218,76,229, +66,91,61,17,72,70,72,70,61,17,91,1,72,70,91,1,79,51,79,51,91,1,89,34,96,25,89,34,91,1,96,25,91,1,126,-4,165,225,130,230,132,215,132,215,130,230,121,216,101,212,121,216,130,230,101,212,130,230,92,225,190,70,183,44,194,17,194,17,183,44,171,25,194,17,171,25,163,1,163,1,171,25,154,13,163,1,154,13,134,9,134,9,123,10,126,-4,126,-4,123,10,114,13,126,-4,114,13,104,18,143,211,152,206,165,225,165,225,152,206,161,199,165,225,161,199,168,191,168,191,177,177,194,210,194,210,177,177,184,161,194,210,184,161,189,142,194,210,193,102,194,17,194,210,194,17,217,186,217,186,194,17,218,43,217,186,218,43,232,154,232,154,218,43,233,76,232,154,233,76,238,116,194,210,189,142,192,122,194,210,192,122,193,102,194,210,165,225,168,191,134,9,126,-4,163,1,61,17,63,113,63,137,63,137,65,164,61,209,61,209,65,164,73,186,61,209,73,186,92,225,92,225,73,186,85,202,92,225,85,202,101,212,61,17,63,137,61,209,61,17,61,209,38,42,38,42,61,209,38,185,38,42,38,185,23,75,23,75,38,185,23,153,23,75,23,153,17,114,63,113,61,17,66,91,190,70,194,17,193,102,165,225,132,215,143,211,96,25,126,-4,104,18, +251,225,12,225,12,218,25,217,33,214,39,209,42,200,42,26,39,17,33,12,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,186,85,196,88,203,92,208,98,210,105,211,156,211,163,210,169,208,174,203,177,196,178,186,178,37,177,26,175,18,170,12,161,9,148,7,148,0,251,0,251,7,238,9,229,11,224,16,221,24,220,37,220,184,221,199,224,209,230,214,238,217,251,218,76,229,73,230,58,224,44,219,31,214,17,209,1,204,1,196,4,197,13,197,22,196,28,194,32,189,34,180,34,-65,33,-79,30,-88,24,-94,14,-98,0,-100,0,-107,120,-107,120,-100,101,-99,88,-95,81,-89,77,-78,76,-62,76,17,86,8,96,2,107,-1,117,-3,129,-4,163,1,191,19,213,47,227,82,232,123,228,158,216,188,198,210,175,225,148,230,132,228,117,224,103,216,89,205,76,190,16383,16383,76,167,79,176, +39,17,33,12,116,0,116,0,33,12,25,9,116,0,25,9,12,7,156,211,251,225,105,211,98,210,105,211,39,209,98,210,39,209,42,200,175,18,170,12,251,0,251,0,170,12,161,9,251,0,161,9,148,7,238,217,251,218,251,225,238,217,251,225,230,214,230,214,251,225,177,196,230,214,177,196,178,186,221,24,178,186,178,37,221,24,178,37,224,16,224,16,178,37,229,11,220,37,220,184,178,186,178,186,220,184,221,199,178,186,221,199,224,209,251,225,156,211,163,210,251,225,163,210,169,208,251,225,169,208,174,203,251,225,174,203,177,196,93,13,88,18,42,39,42,39,88,18,85,26,42,39,85,26,42,185,42,185,85,26,84,36,42,185,84,36,84,186,42,185,84,186,85,196,42,185,85,196,88,203,42,185,88,203,92,208,42,185,92,208,42,200,251,225,12,225,25,217,251,225,25,217,33,214,251,225,33,214,39,209,251,225,39,209,105,211,251,0,251,7,238,9,251,0,238,9,229,11,251,0,229,11,178,37,251,0,178,37,177,26,251,0,177,26,175,18,116,0,116,7,102,9,116,0,102,9,93,13,116,0,93,13,42,39,116,0,42,39,42,26,116,0,42,26,39,17,116,0,12,7,12,0,251,0,148,7,148,0,178,186,221,24,220,37,25,217,12,225,12,218,98,210,42,200,92,208,230,214,178,186,224,209, +76,229,73,230,58,224,44,219,31,214,17,209,1,204,1,196,4,197,13,197,22,196,28,194,32,189,34,180,34,-65,33,-79,30,-88,24,-94,14,-98,0,-100,0,-107,120,-107,120,-100,101,-99,88,-95,81,-89,77,-78,76,-62,76,17,86,8,96,2,107,-1,117,-3,129,-4,163,1,191,19,213,47,227,82,232,123,228,158,216,188,198,210,175,225,148,230,132,228,117,224,103,216,89,205,76,190,16383,16383,76,167,79,176,87,185,99,193,113,198,127,200,148,195,165,183,178,163,186,136,189,103,186,73,178,47,165,27,148,14,128,10,113,12,99,18,87,26,79,35,76,44,207,78,193,60,180,46,167,38,153,33,137,31,111,36,89,49,73,69,63,96,59,128,62,157,71,182,86,200,105,212,127,216,137,215,144,212,149,208,153,201,156,191,160,180,163,172,167,166,171,161,177,158,184,157,191,158,197,161,202,166,206,172,207,179,203,195,192,209,175,220,154,227,130,230,116,229,102,226,88,221,75,213,62,204,63,204,48,189,36,172,28,152,22,130,21,106,25,70,38,39,58,15,84,0,116,-4,128,-3,140,-1,152,3,163,9,173,16,182,24,189,32,197,43,205,57,214,74,213,155,210,225,7,225,4,155,12,155,17,175,24,191,35,202, +30,-88,24,-94,120,-107,120,-107,24,-94,14,-98,120,-107,14,-98,0,-100,6,197,8,197,17,209,17,209,8,197,11,197,17,209,11,197,13,197,13,197,22,196,17,209,17,209,22,196,31,214,17,209,1,204,4,197,17,209,4,197,6,197,79,35,76,44,86,8,86,8,76,44,76,17,77,-78,76,-62,44,219,77,-78,44,219,34,169,34,169,44,219,34,180,22,196,28,194,31,214,31,214,28,194,32,189,31,214,32,189,44,219,44,219,32,189,34,180,76,190,76,229,73,230,76,190,73,230,76,-62,76,190,76,-62,76,167,76,190,76,167,79,176,76,190,79,176,89,205,232,123,228,158,227,82,227,82,228,158,216,188,227,82,216,188,213,47,213,47,216,188,198,210,213,47,198,210,191,19,191,19,198,210,189,103,191,19,189,103,186,73,191,19,186,73,178,47,198,210,175,225,178,163,198,210,178,163,186,136,198,210,186,136,189,103,132,228,127,200,148,195,132,228,148,195,148,230,148,230,148,195,165,183,148,230,165,183,175,225,175,225,165,183,178,163,128,10,129,-4,148,14,148,14,129,-4,163,1,148,14,163,1,165,27,165,27,163,1,191,19,165,27,191,19,178,47,120,-107,120,-100,101,-99,120,-107,101,-99,88,-95,120,-107,88,-95,33,-79,120,-107,33,-79,30,-88,58,224,44,219,76,-62,58,224,76,-62,73,230,34,-65,33,-79,88,-95,34,-65,88,-95,81,-89,34,-65,81,-89,77,-78,34,-65,77,-78,34,169,79,176,87,185,89,205,89,205,87,185,99,193,89,205,99,193,103,216,103,216,99,193,113,198,103,216,113,198,117,224,117,224,113,198,127,200,117,224,127,200,132,228,113,12,99,18,107,-1,113,12,107,-1,117,-3,113,12,117,-3,128,10,79,35,86,8,87,26,87,26,86,8,96,2,87,26,96,2,99,18,99,18,96,2,107,-1,129,-4,128,10,117,-3,4,197,1,204,1,196,120,-107,0,-100,0,-107, +207,78,193,60,180,46,167,38,153,33,137,31,111,36,89,49,73,69,63,96,59,128,62,157,71,182,86,200,105,212,127,216,137,215,144,212,149,208,153,201,156,191,160,180,163,172,167,166,171,161,177,158,184,157,191,158,197,161,202,166,206,172,207,179,203,195,192,209,175,220,154,227,130,230,116,229,102,226,88,221,75,213,62,204,63,204,48,189,36,172,28,152,22,130,21,106,25,70,38,39,58,15,84,0,116,-4,128,-3,140,-1,152,3,163,9,173,16,182,24,189,32,197,43,205,57,214,74,213,155,210,225,7,225,4,155,12,155,17,175,24,191,35,202,50,209,70,211,77,211,82,209,85,207,87,202,88,195,88,40,87,25,84,16,78,11,69,9,56,7,56,0,161,0,161,7,148,9,139,13,133,18,130,26,129,36,129,195,130,201,131,206,134,209,139,210,146,211,166,209,182,202,192,191,200,175,204,155,242,225,175,225,175,218,184,217,190,216,195,213,198,210,199,205,199,201,198,198,198,195,197,193,145,55,84,184,83,188,79,196,78,201,78,204,79,209,82,212,87,215,95,217,107,218, +89,49,73,69,84,0,84,0,73,69,63,96,84,0,63,96,58,15,58,15,63,96,59,128,63,204,59,128,62,157,63,204,62,157,71,182,137,31,116,-4,128,-3,137,31,128,-3,140,-1,137,31,111,36,116,-4,89,49,84,0,116,-4,89,49,116,-4,111,36,203,195,192,209,197,161,203,195,197,161,202,166,203,195,202,166,206,172,203,195,206,172,207,179,192,209,175,220,177,158,192,209,177,158,184,157,192,209,184,157,191,158,192,209,191,158,197,161,175,220,154,227,156,191,175,220,156,191,160,180,175,220,160,180,163,172,175,220,163,172,167,166,175,220,167,166,171,161,175,220,171,161,177,158,144,212,149,208,154,227,154,227,149,208,153,201,154,227,153,201,156,191,130,230,127,216,137,215,130,230,137,215,154,227,154,227,137,215,144,212,182,24,189,32,193,60,193,60,189,32,197,43,193,60,197,43,207,78,207,78,197,43,205,57,207,78,205,57,214,74,140,-1,152,3,153,33,153,33,152,3,163,9,153,33,163,9,167,38,167,38,163,9,173,16,167,38,173,16,180,46,180,46,173,16,182,24,180,46,182,24,193,60,153,33,137,31,140,-1,105,212,127,216,116,229,105,212,116,229,102,226,105,212,102,226,88,221,105,212,88,221,86,200,75,213,63,204,71,182,75,213,71,182,86,200,75,213,86,200,88,221,48,189,36,172,38,39,48,189,38,39,58,15,48,189,58,15,59,128,48,189,59,128,63,204,28,152,22,130,25,70,28,152,25,70,38,39,28,152,38,39,36,172,127,216,130,230,116,229,25,70,22,130,21,106, +213,155,210,225,7,225,4,155,12,155,17,175,24,191,35,202,50,209,70,211,77,211,82,209,85,207,87,202,88,195,88,40,87,25,84,16,78,11,69,9,56,7,56,0,161,0,161,7,148,9,139,13,133,18,130,26,129,36,129,195,130,201,131,206,134,209,139,210,146,211,166,209,182,202,192,191,200,175,204,155,242,225,175,225,175,218,184,217,190,216,195,213,198,210,199,205,199,201,198,198,198,195,197,193,145,55,84,184,83,188,79,196,78,201,78,204,79,209,82,212,87,215,95,217,107,218,107,225,4,225,4,218,11,217,23,211,27,206,31,200,99,59,105,47,111,34,116,22,120,13,122,6,119,-5,111,-24,100,-44,88,-60, +84,16,78,11,161,0,161,0,78,11,69,9,161,0,69,9,56,7,24,191,35,202,7,225,7,225,35,202,50,209,7,225,50,209,70,211,70,211,77,211,210,225,210,225,77,211,82,209,210,225,82,209,85,207,85,207,87,202,210,225,210,225,87,202,139,210,210,225,139,210,146,211,146,211,166,209,210,225,210,225,166,209,182,202,210,225,182,202,192,191,210,225,192,191,200,175,210,225,200,175,204,155,210,225,204,155,213,155,129,36,129,195,88,195,88,195,129,195,130,201,88,195,130,201,131,206,88,195,131,206,134,209,88,195,134,209,139,210,88,195,139,210,87,202,88,195,130,26,129,36,210,225,7,225,70,211,7,225,4,155,12,155,7,225,12,155,17,175,7,225,17,175,24,191,161,0,161,7,148,9,161,0,148,9,139,13,161,0,139,13,88,40,161,0,88,40,87,25,161,0,87,25,84,16,88,40,139,13,133,18,88,40,133,18,130,26,88,40,130,26,88,195,161,0,56,7,56,0, +242,225,175,225,175,218,184,217,190,216,195,213,198,210,199,205,199,201,198,198,198,195,197,193,145,55,84,184,83,188,79,196,78,201,78,204,79,209,82,212,87,215,95,217,107,218,107,225,4,225,4,218,11,217,23,211,27,206,31,200,99,59,105,47,111,34,116,22,120,13,122,6,119,-5,111,-24,100,-44,88,-60,75,-66,70,-66,64,-64,60,-63,55,-60,49,-58,39,-56,33,-56,27,-57,21,-60,16,-65,13,-72,12,-79,14,-88,18,-96,26,-102,35,-106,47,-108,68,-105,86,-94,102,-76,118,-48,134,-11,217,192,221,202,225,208,230,213,235,216,242,218,190,330,186,331,172,325,146,315,132,310,117,305,117,297,119,298,129,298,138,297,144,295,147,290,149,281,150,270,150,204,144,212,136,219,127,225,116,229,104,230,76,225,53,209,36,185,25,153,22,113,23,89,27,66,32,46,41,29,51,15,60,8,69,2,79,-1,91,-3,103,-4,115,-3,126,0,136,6,144,13,150,22,150,-65,149,-79,146,-88,140,-94,129,-98,114,-100,114,-107,233,-107,233,-100,214,-99,202,-95,194,-89,191,-78,190,-62,190,22,195,13,203,6,213,0,224,-3,236,-4,249,-3,260,-1,270,2,279,8,287,15,298,29,306,46,313,66,316,89, +67,-65,68,-105,70,-66,70,-66,68,-105,86,-94,70,-66,86,-94,73,-66,73,-66,86,-94,75,-66,88,-60,75,-66,86,-94,88,-60,86,-94,102,-76,31,200,78,201,78,204,78,204,79,209,31,200,31,200,79,209,82,212,31,200,82,212,107,225,107,225,82,212,87,215,107,225,87,215,95,217,95,217,107,218,107,225,107,225,4,225,11,217,107,225,11,217,17,214,107,225,17,214,23,211,107,225,23,211,27,206,107,225,27,206,31,200,122,6,134,-11,145,55,145,55,134,-11,217,192,145,55,217,192,197,193,197,193,217,192,198,195,242,225,175,225,184,217,242,225,184,217,190,216,242,225,190,216,195,213,242,225,195,213,198,210,242,225,198,210,199,205,242,225,199,205,230,213,242,225,230,213,235,216,242,225,235,216,242,218,199,205,217,192,221,202,199,205,221,202,225,208,199,205,225,208,230,213,199,204,199,201,217,192,199,204,217,192,199,205,198,198,198,195,217,192,198,198,217,192,199,201,111,34,116,22,145,55,145,55,116,22,120,13,145,55,120,13,122,6,145,55,84,184,99,59,145,55,99,59,105,47,145,55,105,47,111,34,99,59,84,184,83,188,99,59,83,188,81,192,99,59,81,192,79,196,99,59,79,196,78,201,99,59,78,201,31,200,119,-5,111,-24,118,-48,119,-5,118,-48,134,-11,119,-5,134,-11,122,6,102,-76,118,-48,111,-24,102,-76,111,-24,100,-44,102,-76,100,-44,88,-60,68,-105,67,-65,64,-64,68,-105,64,-64,60,-63,68,-105,60,-63,55,-60,68,-105,55,-60,49,-58,68,-105,49,-58,47,-108,49,-58,44,-57,47,-108,47,-108,44,-57,39,-56,47,-108,39,-56,35,-106,35,-106,39,-56,33,-56,35,-106,33,-56,27,-57,35,-106,27,-57,26,-102,26,-102,27,-57,21,-60,26,-102,21,-60,18,-96,18,-96,21,-60,16,-65,18,-96,16,-65,14,-88,14,-88,16,-65,13,-72,14,-88,13,-72,12,-79,184,217,175,225,175,218,11,217,4,225,4,218, +190,330,186,331,172,325,146,315,132,310,117,305,117,297,119,298,129,298,138,297,144,295,147,290,149,281,150,270,150,204,144,212,136,219,127,225,116,229,104,230,76,225,53,209,36,185,25,153,22,113,23,89,27,66,32,46,41,29,51,15,60,8,69,2,79,-1,91,-3,103,-4,115,-3,126,0,136,6,144,13,150,22,150,-65,149,-79,146,-88,140,-94,129,-98,114,-100,114,-107,233,-107,233,-100,214,-99,202,-95,194,-89,191,-78,190,-62,190,22,195,13,203,6,213,0,224,-3,236,-4,249,-3,260,-1,270,2,279,8,287,15,298,29,306,46,313,66,316,89,318,113,314,153,303,185,286,209,263,225,235,230,223,229,212,225,203,219,195,212,190,204,16383,16383,190,179,192,188,198,197,207,206,219,212,233,215,248,209,260,194,268,172,273,146,275,117,274,99,273,82,271,66,267,51,263,38,258,29,253,21,247,15,240,11,233,10,219,13,207,19,198,28,192,38,190,47,16383,16383,150,47,147,38,141,28,132,19,120,13,105,10,99,11,92,15,86,21,81,29,76,38,72,51,68,66,66,82,65,99,65,117,66,146,71,172,80,194,91,209,105,215,120,212,132,206,141,197,147,187,150,177,238,0,238,7,229,8,221,12,213,18,205,26,197,37,133,136,175,195,181,203,188,209,197,214,215,218,215,225,136,225,136,218,144,217,150,215,154,213,156,210,156,201,154,195,150,187,145,178,138,169,124,149,116,162,108,174,101,185,97,194,94,201,93,206,93,210,96,213,100,216,106,217,114,218,114,225,11,225,11,218,15,218,23,217,31,214,38,208,45,200,54,187,54,188,100,115,45,32,37,22,30,15,23,11,16,9,7,7,7,0,79,0,79,7,72,8,66,9,62,11,60,13,60,19,61,23,63,27,65,33,69,39,108,100,155,28,156,27,156,25,157,23,157,15,155,12,152,9,146,8,137,7,137,0,251,225,146,225,146,218,159,216,168,212,174,207,177,199,178,189,178,39,177,29,174,22,170,17,164,15,157,14,104,14,97,15,92,17,88,22,85,29,84,39,84,188,85,199,88,207,94,213,103,216,116,218,116,225,12,225,12,218,25,216,33,214,39,209,42,201,42,26,39,16,33,11,24,8,12,7,12,0,199,0,210,-3,221,-14,232,-34,243,-68,251,-68,251,7,238,8,229,11,224,16,221,25,220,40,220,186,221,199,223,208,229,213,238,216,251,218, +69,2,79,-1,72,51,72,51,79,-1,76,38,81,29,76,38,79,-1,81,29,79,-1,91,-3,150,177,150,47,150,22,150,22,150,47,147,38,150,22,147,38,144,13,144,13,147,38,141,28,144,13,141,28,136,6,136,6,141,28,132,19,136,6,132,19,126,0,126,0,132,19,120,13,126,0,120,13,115,-3,115,-3,120,13,105,10,105,10,99,11,103,-4,103,-4,99,11,92,15,103,-4,92,15,91,-3,91,-3,92,15,86,21,91,-3,86,21,81,29,150,270,150,204,150,22,150,22,150,204,150,177,150,177,150,204,147,187,147,187,150,204,144,212,147,187,144,212,141,197,141,197,144,212,136,219,141,197,136,219,132,206,132,206,136,219,127,225,132,206,127,225,120,212,120,212,127,225,116,229,120,212,116,229,105,215,66,146,71,172,76,225,76,225,71,172,80,194,76,225,80,194,104,230,104,230,80,194,91,209,104,230,91,209,105,215,76,225,53,209,66,146,66,146,53,209,65,117,65,99,65,117,60,8,65,99,60,8,69,2,41,29,51,15,53,209,53,209,51,15,60,8,53,209,60,8,65,117,36,185,25,153,27,66,36,185,27,66,32,46,36,185,32,46,41,29,36,185,41,29,53,209,25,153,22,113,23,89,25,153,23,89,27,66,146,-88,140,-94,233,-107,233,-107,140,-94,129,-98,233,-107,129,-98,114,-100,122,298,124,298,132,310,132,310,124,298,126,298,132,310,126,298,129,298,129,298,138,297,132,310,132,310,138,297,146,315,132,310,117,305,119,298,132,310,119,298,122,298,192,38,190,47,195,13,195,13,190,47,190,22,191,-78,190,-62,159,320,191,-78,159,320,150,22,150,22,159,320,150,270,138,297,144,295,146,315,146,315,144,295,147,290,146,315,147,290,159,320,159,320,147,290,149,281,159,320,149,281,150,270,190,204,190,330,186,331,190,204,186,331,190,-62,190,204,190,-62,190,179,190,204,190,179,195,212,274,99,273,82,279,8,279,8,273,82,271,66,279,8,271,66,270,2,270,2,271,66,267,51,270,2,267,51,263,38,263,38,258,29,260,-1,260,-1,258,29,253,21,260,-1,253,21,249,-3,249,-3,253,21,247,15,249,-3,247,15,240,11,213,0,224,-3,219,13,219,13,224,-3,233,10,240,11,233,10,236,-4,240,11,236,-4,249,-3,314,153,303,185,306,46,314,153,306,46,313,66,314,153,313,66,316,89,314,153,316,89,318,113,274,99,279,8,275,117,275,117,279,8,286,209,286,209,279,8,287,15,286,209,287,15,303,185,303,185,287,15,298,29,303,185,298,29,306,46,248,209,260,194,263,225,263,225,260,194,268,172,263,225,268,172,286,209,286,209,268,172,273,146,286,209,273,146,275,117,263,225,235,230,248,209,248,209,235,230,233,215,219,212,233,215,223,229,219,212,223,229,212,225,263,38,260,-1,270,2,233,-107,233,-100,214,-99,233,-107,214,-99,202,-95,233,-107,202,-95,149,-79,233,-107,149,-79,146,-88,172,325,159,320,190,-62,172,325,190,-62,186,331,194,-89,191,-78,150,22,194,-89,150,22,150,-65,194,-89,150,-65,202,-95,69,2,72,51,68,66,69,2,68,66,66,82,69,2,66,82,65,99,192,38,195,13,198,28,198,28,195,13,203,6,198,28,203,6,207,19,207,19,203,6,213,0,207,19,213,0,219,13,190,179,192,188,195,212,195,212,192,188,198,197,195,212,198,197,203,219,203,219,198,197,207,206,203,219,207,206,212,225,212,225,207,206,219,212,235,230,223,229,233,215,233,10,224,-3,236,-4,115,-3,105,10,103,-4,119,298,117,305,117,297,233,-107,114,-100,114,-107,149,-79,202,-95,150,-65,105,215,116,229,104,230, +238,0,238,7,229,8,221,12,213,18,205,26,197,37,133,136,175,195,181,203,188,209,197,214,215,218,215,225,136,225,136,218,144,217,150,215,154,213,156,210,156,201,154,195,150,187,145,178,138,169,124,149,116,162,108,174,101,185,97,194,94,201,93,206,93,210,96,213,100,216,106,217,114,218,114,225,11,225,11,218,15,218,23,217,31,214,38,208,45,200,54,187,54,188,100,115,45,32,37,22,30,15,23,11,16,9,7,7,7,0,79,0,79,7,72,8,66,9,62,11,60,13,60,19,61,23,63,27,65,33,69,39,108,100,155,28,156,27,156,25,157,23,157,15,155,12,152,9,146,8,137,7,137,0,251,225,146,225,146,218,159,216,168,212,174,207,177,199,178,189,178,39,177,29,174,22,170,17,164,15,157,14,104,14,97,15,92,17,88,22,85,29,84,39,84,188,85,199,88,207,94,213,103,216,116,218,116,225,12,225,12,218,25,216,33,214,39,209,42,201,42,26,39,16,33,11,24,8,12,7,12,0,199,0,210,-3,221,-14,232,-34,243,-68,251,-68,251,7,238,8,229,11,224,16,221,25,220,40,220,186,221,199,223,208,229,213,238,216,251,218,244,225,139,225,139,218,152,216,161,212,167,207,170,200,171,190,171,118,166,116,158,113,148,110,136,108,123,107,106,108,94,112,87,120,83,131,81,147,81,186, +30,15,23,11,79,0,79,0,23,11,16,9,79,0,16,9,7,7,31,214,38,208,114,225,114,225,38,208,45,200,114,225,45,200,54,188,54,188,45,200,54,187,54,187,100,115,93,206,93,206,93,210,54,187,54,187,93,210,96,213,54,187,96,213,114,225,114,225,96,213,100,216,114,225,100,216,106,217,30,15,79,0,37,22,37,22,79,0,62,11,37,22,62,11,45,32,45,32,62,11,60,13,45,32,60,13,60,17,60,17,60,19,45,32,45,32,60,19,61,23,45,32,61,23,63,27,106,217,114,218,114,225,114,225,11,225,15,218,114,225,15,218,23,217,114,225,23,217,31,214,138,169,124,149,133,136,138,169,133,136,175,195,138,169,175,195,145,178,215,225,136,225,144,217,215,225,144,217,150,215,215,225,150,215,154,213,215,225,154,213,156,210,215,225,156,210,156,206,215,225,156,206,188,209,215,225,188,209,197,214,215,225,197,214,206,216,215,225,206,216,215,218,175,195,181,203,156,206,175,195,156,206,156,201,175,195,156,201,154,195,175,195,154,195,150,187,175,195,150,187,145,178,155,12,152,9,238,0,238,0,152,9,146,8,238,0,146,8,137,7,157,20,238,0,221,12,157,20,221,12,213,18,157,20,213,18,205,26,157,20,205,26,197,37,157,20,197,37,157,21,197,37,133,136,155,28,197,37,155,28,156,27,197,37,156,27,156,25,197,37,156,25,157,23,197,37,157,23,157,21,133,136,124,149,155,28,155,28,124,149,116,162,155,28,116,162,108,100,108,100,116,162,108,174,108,100,108,174,101,185,100,115,45,32,63,27,100,115,63,27,65,33,100,115,65,33,69,39,100,115,69,39,108,100,100,115,108,100,101,185,100,115,101,185,97,194,100,115,97,194,94,201,100,115,94,201,93,206,229,8,221,12,238,0,229,8,238,0,238,7,157,15,155,12,238,0,157,15,238,0,157,20,79,0,79,7,72,8,79,0,72,8,66,9,79,0,66,9,62,11,79,0,7,7,7,0,238,0,137,7,137,0,144,217,136,225,136,218,188,209,156,206,181,203,15,218,11,225,11,218,114,225,54,188,54,187, +251,225,146,225,146,218,159,216,168,212,174,207,177,199,178,189,178,39,177,29,174,22,170,17,164,15,157,14,104,14,97,15,92,17,88,22,85,29,84,39,84,188,85,199,88,207,94,213,103,216,116,218,116,225,12,225,12,218,25,216,33,214,39,209,42,201,42,26,39,16,33,11,24,8,12,7,12,0,199,0,210,-3,221,-14,232,-34,243,-68,251,-68,251,7,238,8,229,11,224,16,221,25,220,40,220,186,221,199,223,208,229,213,238,216,251,218,244,225,139,225,139,218,152,216,161,212,167,207,170,200,171,190,171,118,166,116,158,113,148,110,136,108,123,107,106,108,94,112,87,120,83,131,81,147,81,186,82,199,86,208,91,213,100,216,113,218,113,225,9,225,9,218,22,216,30,213,36,209,39,200,40,186,40,144,43,121,52,105,66,97,85,93,107,92,124,93,139,96,152,100,162,104,171,108,171,27,168,18,162,13,153,9,141,7,141,0,244,0,244,7,231,9,223,12,217,17,215,25,214,39, +39,16,33,11,187,0,187,0,33,11,24,8,187,0,24,8,12,7,116,225,12,225,25,216,116,225,25,216,33,214,116,225,33,214,39,209,116,225,39,209,42,201,116,225,42,201,42,188,116,225,42,188,94,213,116,225,94,213,103,216,116,225,103,216,116,218,92,17,88,22,42,41,42,41,88,22,85,29,42,41,85,29,42,188,42,188,85,29,84,39,42,188,84,39,84,188,42,188,84,188,85,199,42,188,85,199,88,207,42,188,88,207,94,213,251,225,146,225,159,216,251,225,159,216,168,212,251,225,168,212,174,207,251,225,174,207,177,199,251,225,177,199,178,189,251,225,178,189,229,213,251,225,229,213,238,216,251,225,238,216,251,218,224,16,221,25,221,-14,221,-14,221,25,220,40,220,40,220,186,210,-3,210,-3,220,186,199,0,178,189,187,0,221,199,221,199,187,0,199,0,221,199,199,0,220,186,223,208,229,213,178,189,223,208,178,189,221,199,251,-68,251,7,243,-68,243,-68,251,7,238,8,243,-68,238,8,232,-34,232,-34,238,8,229,11,232,-34,229,11,224,16,174,22,170,17,187,0,187,0,170,17,164,15,187,0,164,15,157,14,187,0,178,189,178,39,187,0,178,39,177,29,187,0,177,29,174,22,42,26,39,16,97,15,97,15,39,16,187,0,97,15,187,0,104,14,104,14,187,0,157,14,42,26,97,15,92,17,42,26,92,17,42,41,187,0,12,7,12,0,221,-14,220,40,210,-3,224,16,221,-14,232,-34,159,216,146,225,146,218,25,216,12,225,12,218,42,188,42,201,42,187, +244,225,139,225,139,218,152,216,161,212,167,207,170,200,171,190,171,118,166,116,158,113,148,110,136,108,123,107,106,108,94,112,87,120,83,131,81,147,81,186,82,199,86,208,91,213,100,216,113,218,113,225,9,225,9,218,22,216,30,213,36,209,39,200,40,186,40,144,43,121,52,105,66,97,85,93,107,92,124,93,139,96,152,100,162,104,171,108,171,27,168,18,162,13,153,9,141,7,141,0,244,0,244,7,231,9,223,12,217,17,215,25,214,39,214,199,217,208,223,213,231,216,244,218,373,225,270,225,270,218,282,216,291,213,296,207,299,200,300,189,300,39,299,29,297,22,293,17,287,15,278,14,235,14,228,15,221,17,217,22,214,29,213,39,213,189,214,199,218,207,224,213,232,216,243,218,243,225,141,225,141,218,152,216,160,213,166,207,170,199,171,189,171,39,170,29,168,22,164,17,158,15,150,14,107,14,99,15,93,17,88,22,85,29,84,39,84,189,85,199,88,207,93,212,102,216,114,218,114,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11, +113,218,113,218,100,216,100,216,113,218,113,225,100,216,113,225,91,213,91,213,113,225,40,186,91,213,40,186,86,208,86,208,40,186,43,121,86,208,43,121,82,199,82,199,43,121,52,105,82,199,52,105,66,97,87,120,83,131,85,93,85,93,83,131,81,147,81,147,81,186,66,97,66,97,81,186,82,199,30,213,36,209,113,225,113,225,36,209,39,200,113,225,39,200,40,186,22,216,30,213,113,225,22,216,113,225,9,225,22,216,9,225,9,218,244,7,231,9,244,0,244,0,231,9,223,12,244,0,223,12,171,39,171,39,223,12,217,17,171,39,217,17,171,108,171,108,171,118,166,116,171,108,166,116,162,104,162,104,166,116,158,113,162,104,158,113,152,100,152,100,158,113,148,110,152,100,148,110,139,96,139,96,148,110,136,108,139,96,136,108,124,93,124,93,136,108,123,107,107,92,124,93,123,107,107,92,123,107,106,108,107,92,106,108,94,112,107,92,94,112,87,120,107,92,87,120,85,93,244,225,139,225,152,216,244,225,152,216,161,212,244,225,161,212,167,207,244,225,167,207,170,200,244,225,170,200,171,190,244,225,171,190,223,213,244,225,223,213,231,216,244,225,231,216,244,218,214,39,214,186,171,108,171,108,214,186,214,199,171,108,214,199,217,208,171,190,171,108,217,208,171,190,217,208,223,213,171,108,217,17,215,25,171,108,215,25,214,39,244,0,171,39,171,27,244,0,171,27,168,18,244,0,168,18,162,13,244,0,162,13,153,9,244,0,153,9,141,7,244,0,141,7,141,0,43,121,40,186,40,144,171,118,171,108,171,190,152,216,139,225,139,218,85,93,81,147,66,97, +373,225,270,225,270,218,282,216,291,213,296,207,299,200,300,189,300,39,299,29,297,22,293,17,287,15,278,14,235,14,228,15,221,17,217,22,214,29,213,39,213,189,214,199,218,207,224,213,232,216,243,218,243,225,141,225,141,218,152,216,160,213,166,207,170,199,171,189,171,39,170,29,168,22,164,17,158,15,150,14,107,14,99,15,93,17,88,22,85,29,84,39,84,189,85,199,88,207,93,212,102,216,114,218,114,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,372,0,372,7,360,8,351,11,345,16,342,25,342,198,345,207,351,213,360,216,373,218,373,225,270,225,270,218,282,216,291,213,296,207,299,200,300,189,300,39,299,29,297,22,293,17,287,15,278,14,235,14,228,15,221,17,217,22,214,29,213,39,213,189,214,199,218,207,224,212,232,216,243,218,243,225,141,225,141,218,142,218,152,216,160,212,166,207,170,199,171,189,171,39,170,29,168,22,164,17,158,15,150,14,107,14,99,15,93,17,88,22,85,29,84,39,84,189,85,199,87,207,93,212,101,216,114,218,114,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,325,0,335,-5,345,-17,354,-37,364,-68,372,-68,372,7,360,8,351,11,345,15, +39,16,33,11,372,0,372,0,33,11,25,9,372,0,25,9,12,7,114,225,12,225,25,216,114,225,25,216,33,212,114,225,33,212,39,206,114,225,39,206,42,197,114,225,42,197,42,183,114,225,42,183,93,212,114,225,93,212,102,216,114,225,102,216,114,218,93,17,88,22,42,40,42,40,88,22,85,29,42,40,85,29,42,183,42,183,85,29,84,39,42,183,84,39,84,189,42,183,84,189,85,199,42,183,85,199,88,207,42,183,88,207,93,212,93,17,42,25,99,15,99,15,42,25,39,16,99,15,39,16,107,14,107,14,39,16,372,0,107,14,372,0,150,14,150,14,372,0,158,15,243,225,141,225,152,216,243,225,152,216,160,213,243,225,160,213,166,207,243,225,166,207,170,199,243,225,170,199,171,189,243,225,171,189,224,213,243,225,224,213,232,216,243,225,232,216,243,218,213,39,213,189,171,189,171,189,213,189,214,199,171,189,214,199,218,207,221,17,217,22,171,39,171,39,217,22,214,29,171,39,214,29,171,189,297,22,293,17,372,0,372,0,293,17,287,15,372,0,287,15,278,14,373,225,270,225,282,216,373,225,282,216,291,213,373,225,291,213,296,207,373,225,296,207,299,200,373,225,299,200,300,189,373,225,300,189,351,213,373,225,351,213,360,216,373,225,360,216,373,218,342,40,342,183,300,189,300,189,342,183,342,198,300,189,342,198,345,207,351,11,345,16,300,39,300,39,345,16,342,25,300,39,342,25,300,189,372,0,372,7,360,8,372,0,360,8,351,11,372,0,351,11,299,29,372,0,299,29,297,22,372,0,278,14,235,14,372,0,235,14,228,15,372,0,228,15,164,17,372,0,164,17,158,15,170,29,168,22,228,15,170,29,228,15,221,17,170,29,221,17,171,39,372,0,12,7,12,0,42,25,93,17,42,40,164,17,228,15,168,22,171,189,214,29,213,39,299,29,351,11,300,39,300,189,342,25,342,40,282,216,270,225,270,218,351,213,300,189,345,207,152,216,141,225,141,218,224,213,171,189,218,207,25,216,12,225,12,218, +373,225,270,225,270,218,282,216,291,213,296,207,299,200,300,189,300,39,299,29,297,22,293,17,287,15,278,14,235,14,228,15,221,17,217,22,214,29,213,39,213,189,214,199,218,207,224,212,232,216,243,218,243,225,141,225,141,218,142,218,152,216,160,212,166,207,170,199,171,189,171,39,170,29,168,22,164,17,158,15,150,14,107,14,99,15,93,17,88,22,85,29,84,39,84,189,85,199,87,207,93,212,101,216,114,218,114,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,325,0,335,-5,345,-17,354,-37,364,-68,372,-68,372,7,360,8,351,11,345,15,342,25,342,198,345,207,351,213,360,216,373,218,126,126,126,199,129,207,134,212,143,216,156,218,156,225,8,225,4,161,12,161,18,181,25,195,35,205,46,209,61,211,68,211,74,209,79,207,83,202,84,195,84,40,83,25,80,16,75,11,66,9,52,7,52,0,169,0,196,3,220,10,238,23,249,40,253,62,249,86,235,105,215,117,188,124,158,126,16383,16383,126,112,148,112,167,111,183,107,196,98,205,84,208,64,205,43,196,29,182,20,164,15,142,14,135,14,130,16,127,19,126,23,126,30,323,0,323,8,310,10,301,13,295,18,293,26,292,36,292,199,295,207,300,212,309,216,323,218,323,225,219,225,219,218,232,216,241,212,246,206,249,197,250,183,250,40,249,25,246,16,241,11,232,9,219,7, +39,16,33,11,315,0,315,0,33,11,25,9,315,0,25,9,12,7,114,225,12,225,25,216,114,225,25,216,33,212,114,225,33,212,39,206,114,225,39,206,42,197,114,225,42,197,42,183,114,225,42,183,93,212,114,225,93,212,101,216,114,225,101,216,114,218,93,17,88,22,42,40,42,40,88,22,85,29,42,40,85,29,42,183,42,183,85,29,84,39,42,183,84,39,84,189,42,183,84,189,85,199,42,183,85,199,87,207,42,183,87,207,93,212,93,17,42,25,99,15,99,15,42,25,39,16,99,15,39,16,107,14,107,14,39,16,315,0,107,14,315,0,150,14,150,14,315,0,158,15,243,225,141,225,142,218,243,225,142,218,152,216,243,225,152,216,160,212,243,225,160,212,166,207,243,225,166,207,170,199,243,225,170,199,171,189,243,225,171,189,224,212,243,225,224,212,232,216,243,225,232,216,243,218,213,39,213,189,171,189,171,189,213,189,214,199,171,189,214,199,218,207,221,17,217,22,171,39,171,39,217,22,214,29,171,39,214,29,171,189,373,225,270,225,282,216,373,225,282,216,291,213,373,225,291,213,296,207,373,225,296,207,299,200,373,225,299,200,300,189,373,225,300,189,351,213,373,225,351,213,360,216,373,225,360,216,373,218,345,15,342,25,345,-17,345,-17,342,25,342,40,342,40,342,183,335,-5,335,-5,342,183,325,0,300,189,315,0,342,198,342,198,315,0,325,0,342,198,325,0,342,183,345,207,351,213,300,189,345,207,300,189,342,198,372,-68,372,7,364,-68,364,-68,372,7,360,8,364,-68,360,8,354,-37,354,-37,360,8,351,11,354,-37,351,11,345,15,297,22,293,17,315,0,315,0,293,17,287,15,315,0,287,15,278,14,315,0,300,189,300,39,315,0,300,39,299,29,315,0,299,29,297,22,315,0,278,14,235,14,315,0,235,14,228,15,315,0,228,15,168,22,315,0,168,22,164,17,315,0,164,17,158,15,170,29,168,22,228,15,170,29,228,15,221,17,170,29,221,17,171,39,315,0,12,7,12,0,42,25,93,17,42,40,171,189,214,29,213,39,345,-17,342,40,335,-5,345,15,345,-17,354,-37,282,216,270,225,270,218,142,218,141,225,141,218,224,212,171,189,218,207,25,216,12,225,12,218, +126,126,126,199,129,207,134,212,143,216,156,218,156,225,8,225,4,161,12,161,18,181,25,195,35,205,46,209,61,211,68,211,74,209,79,207,83,202,84,195,84,40,83,25,80,16,75,11,66,9,52,7,52,0,169,0,196,3,220,10,238,23,249,40,253,62,249,86,235,105,215,117,188,124,158,126,16383,16383,126,112,148,112,167,111,183,107,196,98,205,84,208,64,205,43,196,29,182,20,164,15,142,14,135,14,130,16,127,19,126,23,126,30,323,0,323,8,310,10,301,13,295,18,293,26,292,36,292,199,295,207,300,212,309,216,323,218,323,225,219,225,219,218,232,216,241,212,246,206,249,197,250,183,250,40,249,25,246,16,241,11,232,9,219,7,219,0,16383,16383,84,126,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,127,0,155,3,179,10,197,23,209,40,213,62,208,86,194,105, +80,16,75,11,169,0,169,0,75,11,66,9,169,0,66,9,52,7,74,209,156,225,68,211,68,211,156,225,61,211,46,209,61,211,156,225,46,209,156,225,8,225,156,225,74,209,79,207,156,225,79,207,83,202,156,225,83,202,84,195,156,225,84,195,134,212,156,225,134,212,143,216,156,225,143,216,156,218,84,195,126,23,126,30,126,126,126,112,148,112,126,126,148,112,158,126,158,126,148,112,167,111,158,126,167,111,188,124,188,124,167,111,183,107,188,124,183,107,196,98,84,195,126,30,126,189,84,195,126,189,126,199,84,195,126,199,129,207,84,195,129,207,134,212,8,225,4,161,12,161,8,225,12,161,18,181,8,225,18,181,25,195,8,225,25,195,35,205,8,225,35,205,46,209,205,43,196,29,196,3,196,3,196,29,182,20,196,3,182,20,169,0,169,0,182,20,164,15,169,0,164,15,142,14,142,14,135,14,169,0,169,0,135,14,130,16,169,0,130,16,83,25,83,25,130,16,84,40,196,3,220,10,205,43,205,43,220,10,208,64,215,117,208,64,220,10,215,117,220,10,235,105,235,105,220,10,238,23,235,105,238,23,249,86,249,86,238,23,249,40,249,86,249,40,253,62,215,117,188,124,196,98,215,117,196,98,205,84,215,117,205,84,208,64,84,40,130,16,127,19,84,40,127,19,126,23,84,40,126,23,84,195,169,0,52,7,52,0,80,16,169,0,83,25, +323,0,323,8,310,10,301,13,295,18,293,26,292,36,292,199,295,207,300,212,309,216,323,218,323,225,219,225,219,218,232,216,241,212,246,206,249,197,250,183,250,40,249,25,246,16,241,11,232,9,219,7,219,0,16383,16383,84,126,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,127,0,155,3,179,10,197,23,209,40,213,62,208,86,194,105,174,117,148,124,118,126,16383,16383,84,112,107,112,126,111,142,107,155,98,164,84,167,64,164,43,155,29,141,20,123,15,102,14,94,14,89,16,86,19,85,23,84,30,84,126,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,127,0,155,3,179,10,197,23,209,40,213,62,208,86,194,105,174,117,148,124,118,126,16383,16383,84,112,107,112,126,111,142,107,155,98,164,84,167,64,164,43,155,29,141,20,123,15,102,14,94,14,89,16,86,19,85,23,84,30,30,228,23,157,32,157,38,173,46,189,58,203,75,212,99,216,122,212,140,200,154,182,162,157,165,128,75,128,75,112,165,112,160,87,150,64,135,47,114,35,88,31,71,33,56,37,42,46,28,59,15,78,7,74,18,53, +323,218,323,218,309,216,309,216,323,218,323,225,309,216,323,225,300,212,300,212,323,225,249,197,300,212,249,197,250,183,293,26,250,183,250,40,293,26,250,40,295,18,295,18,250,40,301,13,292,36,292,189,250,183,250,183,292,189,292,199,250,183,292,199,295,207,323,225,219,225,232,216,323,225,232,216,241,212,323,225,241,212,246,206,323,225,246,206,249,197,323,0,323,8,310,10,323,0,310,10,301,13,323,0,301,13,250,40,323,0,250,40,249,25,323,0,249,25,246,16,323,0,246,16,241,11,323,0,241,11,232,9,323,0,232,9,219,7,323,0,219,7,219,0,39,16,33,11,127,0,127,0,33,11,25,9,127,0,25,9,12,7,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,42,183,85,23,84,30,84,126,84,112,107,112,84,126,107,112,118,126,118,126,107,112,126,111,118,126,126,111,148,124,148,124,126,111,142,107,148,124,142,107,155,98,42,183,84,30,84,189,42,183,84,189,85,199,42,183,85,199,88,207,42,183,88,207,93,212,42,183,93,212,42,197,164,43,155,29,155,3,155,3,155,29,141,20,155,3,141,20,127,0,127,0,141,20,123,15,127,0,123,15,102,14,102,14,94,14,127,0,127,0,94,14,89,16,127,0,89,16,42,25,42,25,89,16,42,40,155,3,179,10,164,43,164,43,179,10,167,64,174,117,167,64,179,10,174,117,179,10,194,105,194,105,179,10,197,23,194,105,197,23,208,86,208,86,197,23,209,40,208,86,209,40,213,62,174,117,148,124,155,98,174,117,155,98,164,84,174,117,164,84,167,64,42,40,89,16,86,19,42,40,86,19,85,23,42,40,85,23,42,183,127,0,12,7,12,0,39,16,127,0,42,25,25,216,12,225,12,218,250,183,293,26,292,36,232,216,219,225,219,218,300,212,250,183,295,207, +84,126,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,127,0,155,3,179,10,197,23,209,40,213,62,208,86,194,105,174,117,148,124,118,126,16383,16383,84,112,107,112,126,111,142,107,155,98,164,84,167,64,164,43,155,29,141,20,123,15,102,14,94,14,89,16,86,19,85,23,84,30,30,228,23,157,32,157,38,173,46,189,58,203,75,212,99,216,122,212,140,200,154,182,162,157,165,128,75,128,75,112,165,112,160,87,150,64,135,47,114,35,88,31,71,33,56,37,42,46,28,59,15,78,7,74,18,53,32,32,49,14,72,0,101,-4,136,1,165,16,187,41,200,73,205,110,201,147,189,179,169,206,140,223,102,230,92,230,84,229,63,222,59,220,56,218,52,217,48,217, +39,16,33,11,127,0,127,0,33,11,25,9,127,0,25,9,12,7,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,42,183,85,23,84,30,84,126,84,112,107,112,84,126,107,112,118,126,118,126,107,112,126,111,118,126,126,111,148,124,148,124,126,111,142,107,148,124,142,107,155,98,42,183,84,30,84,189,42,183,84,189,85,199,42,183,85,199,88,207,42,183,88,207,93,212,42,183,93,212,42,197,164,43,155,29,155,3,155,3,155,29,141,20,155,3,141,20,127,0,127,0,141,20,123,15,127,0,123,15,102,14,102,14,94,14,127,0,127,0,94,14,89,16,127,0,89,16,42,25,42,25,89,16,42,40,155,3,179,10,164,43,164,43,179,10,167,64,174,117,167,64,179,10,174,117,179,10,194,105,194,105,179,10,197,23,194,105,197,23,208,86,208,86,197,23,209,40,208,86,209,40,213,62,174,117,148,124,155,98,174,117,155,98,164,84,174,117,164,84,167,64,42,40,89,16,86,19,42,40,86,19,85,23,42,40,85,23,42,183,127,0,12,7,12,0,39,16,127,0,42,25,25,216,12,225,12,218, +30,228,23,157,32,157,38,173,46,189,58,203,75,212,99,216,122,212,140,200,154,182,162,157,165,128,75,128,75,112,165,112,160,87,150,64,135,47,114,35,88,31,71,33,56,37,42,46,28,59,15,78,7,74,18,53,32,32,49,14,72,0,101,-4,136,1,165,16,187,41,200,73,205,110,201,147,189,179,169,206,140,223,102,230,92,230,84,229,63,222,59,220,56,218,52,217,48,217,44,218,42,219,40,221,38,224,37,228,84,124,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,108,131,108,138,70,153,39,176,16,205,0,239,-4,276,1,308,17,331,43,346,76,352,116,346,154,331,186,308,210,278,225,243,230,207,225,177,211,154,189,138,160,131,124,16383,16383,306,102,304,70,296,44,284,25, +59,220,56,218,58,203,58,203,56,218,52,217,58,203,52,217,48,217,48,217,44,218,46,189,46,189,44,218,42,219,46,189,42,219,40,221,30,228,32,157,37,228,37,228,32,157,38,173,37,228,38,173,38,224,38,224,38,173,46,189,38,224,46,189,40,221,15,78,18,53,28,59,28,59,18,53,32,32,28,59,32,32,42,46,42,46,32,32,49,14,42,46,49,14,56,37,56,37,49,14,72,0,56,37,72,0,71,33,71,33,72,0,88,31,114,35,88,31,101,-4,114,35,101,-4,136,1,99,216,92,230,84,229,99,216,84,229,78,227,99,216,78,227,75,212,99,216,102,230,92,230,75,212,78,227,72,225,75,212,72,225,66,223,75,212,66,223,63,222,75,212,63,222,59,220,75,212,59,220,58,203,48,217,46,189,58,203,75,128,165,112,165,128,165,128,165,112,165,16,165,128,165,16,169,206,205,110,201,147,200,73,200,73,201,147,189,179,200,73,189,179,187,41,187,41,189,179,169,206,187,41,169,206,165,16,169,206,140,223,140,200,169,206,140,200,154,182,169,206,154,182,162,157,169,206,162,157,165,128,122,212,140,200,140,223,122,212,140,223,102,230,122,212,102,230,99,216,165,112,160,87,165,16,165,16,160,87,150,64,165,16,150,64,136,1,136,1,150,64,135,47,136,1,135,47,114,35,88,31,72,0,101,-4,18,53,15,78,7,74,32,157,30,228,23,157,165,112,75,128,75,112, +84,124,84,189,85,199,88,207,93,212,102,216,116,218,116,225,12,225,12,218,25,216,33,212,39,206,42,197,42,25,39,16,33,11,25,9,12,7,12,0,116,0,116,7,102,9,93,13,88,18,85,26,84,36,84,108,131,108,138,70,153,39,176,16,205,0,239,-4,276,1,308,17,331,43,346,76,352,116,346,154,331,186,308,210,278,225,243,230,207,225,177,211,154,189,138,160,131,124,16383,16383,306,102,304,70,296,44,284,25,268,13,248,9,237,10,227,13,218,18,210,25,203,34,193,51,185,70,180,91,177,113,176,137,179,164,186,186,199,202,215,212,234,216,246,215,257,211,266,206,274,199,281,191,290,177,297,161,302,142,305,122,306,102,224,225,121,225,91,224,65,219,45,210,31,193,26,167,30,148,40,131,55,118,74,109,97,104,37,31,32,25,26,19,19,14,11,9,2,7,2,0,64,0,142,103,151,103,151,25,148,16,143,11,135,8,123,7,123,0,224,0,224,8,211,10,202,13,197,18,194,26,193,40,193,183,194,198,197,207,202,213,211,216,224,218,16383,16383,151,117,131,117,111,119,94,125,82,135,74,148,71,165,75,185,85,198,99,206,117,210,136,211,142,211,147,209,149,206,151,202,151,195,193,286,191,294,188,301,182,306,175,310,167,311,160,310,153,306,148,301,144,294,143,286,144,278,147,272,153,266,159,263,167,262,175,263,182,266,188,272,191,278,193,286,16383,16383, +39,16,33,11,116,0,116,0,33,11,25,9,116,0,25,9,12,7,116,225,12,225,25,216,116,225,25,216,33,212,116,225,33,212,39,206,116,225,39,206,42,197,116,225,42,197,93,212,116,225,93,212,102,216,116,225,102,216,116,218,138,160,131,124,131,108,131,108,131,124,84,124,131,108,84,124,84,108,85,26,84,36,42,183,85,26,42,183,42,40,42,183,84,36,84,189,42,183,84,189,85,199,42,183,85,199,88,207,42,183,88,207,93,212,42,183,93,212,42,197,116,0,116,7,102,9,116,0,102,9,93,13,116,0,93,13,42,40,116,0,42,40,42,25,116,0,42,25,39,16,42,40,93,13,88,18,42,40,88,18,85,26,180,91,176,16,185,70,185,70,176,16,205,0,185,70,205,0,193,51,193,51,205,0,203,34,210,25,203,34,205,0,210,25,205,0,239,-4,278,225,243,230,246,215,246,215,243,230,234,216,215,212,234,216,243,230,215,212,243,230,207,225,304,70,296,44,308,17,308,17,296,44,284,25,308,17,284,25,276,1,276,1,284,25,268,13,276,1,268,13,248,9,248,9,237,10,239,-4,239,-4,237,10,227,13,239,-4,227,13,218,18,257,211,266,206,278,225,278,225,266,206,274,199,278,225,274,199,281,191,281,191,290,177,308,210,308,210,290,177,297,161,308,210,297,161,302,142,346,154,331,186,331,43,346,154,331,43,346,76,346,154,346,76,352,116,304,70,308,17,306,102,306,102,308,17,308,210,308,210,308,17,331,43,308,210,331,43,331,186,308,210,302,142,305,122,308,210,305,122,306,102,308,210,278,225,281,191,248,9,239,-4,276,1,176,137,179,164,177,211,177,211,179,164,186,186,177,211,186,186,207,225,207,225,186,186,199,202,207,225,199,202,215,212,131,108,138,70,138,160,138,160,138,70,153,39,138,160,153,39,154,189,154,189,153,39,176,16,154,189,176,16,176,137,176,137,177,211,154,189,177,113,176,137,176,16,177,113,176,16,180,91,278,225,246,215,257,211,210,25,239,-4,218,18,116,0,12,7,12,0,25,216,12,225,12,218, +224,225,121,225,91,224,65,219,45,210,31,193,26,167,30,148,40,131,55,118,74,109,97,104,37,31,32,25,26,19,19,14,11,9,2,7,2,0,64,0,142,103,151,103,151,25,148,16,143,11,135,8,123,7,123,0,224,0,224,8,211,10,202,13,197,18,194,26,193,40,193,183,194,198,197,207,202,213,211,216,224,218,16383,16383,151,117,131,117,111,119,94,125,82,135,74,148,71,165,75,185,85,198,99,206,117,210,136,211,142,211,147,209,149,206,151,202,151,195,193,286,191,294,188,301,182,306,175,310,167,311,160,310,153,306,148,301,144,294,143,286,144,278,147,272,153,266,159,263,167,262,175,263,182,266,188,272,191,278,193,286,16383,16383,93,286,92,294,88,301,83,306,76,310,68,311,60,310,54,306,48,301,45,294,44,286,45,278,48,272,53,266,60,263,68,262,76,263,83,266,88,272,92,278,93,286,16383,16383,210,82,196,63,182,48,167,39,150,33,132,31,102,37,80,53,66,77,58,106,55,137,209,137,208,152,205,165,202,176, +26,19,19,14,64,0,64,0,19,14,11,9,64,0,11,9,2,7,97,104,64,0,142,103,97,104,142,103,111,119,97,104,111,119,94,125,97,104,94,125,82,135,97,104,82,135,74,148,97,104,74,148,74,109,85,198,91,224,75,185,75,185,91,224,65,219,75,185,65,219,71,165,71,165,74,109,74,148,26,167,30,148,31,193,31,193,30,148,40,131,31,193,40,131,45,210,45,210,40,131,55,118,45,210,55,118,65,219,65,219,55,118,74,109,65,219,74,109,71,165,148,16,143,11,224,0,224,0,143,11,135,8,224,0,135,8,123,7,147,209,224,225,142,211,142,211,224,225,136,211,117,210,136,211,121,225,117,210,121,225,99,206,99,206,121,225,91,224,99,206,91,224,85,198,224,8,211,10,224,0,224,0,211,10,202,13,224,0,202,13,151,38,151,38,202,13,197,18,151,38,197,18,151,103,151,103,197,18,151,117,151,103,151,117,142,103,142,103,151,117,131,117,142,103,131,117,111,119,64,0,97,104,37,31,64,0,37,31,32,25,64,0,32,25,26,19,224,225,147,209,149,206,224,225,149,206,151,202,224,225,151,202,151,195,224,225,151,195,202,213,224,225,202,213,211,216,224,225,211,216,224,218,193,40,193,183,151,195,151,195,193,183,194,198,151,195,194,198,197,207,151,195,194,26,193,40,224,225,121,225,136,211,151,117,197,18,194,26,151,117,194,26,151,195,151,25,148,16,224,0,151,25,224,0,151,38,224,0,123,7,123,0,202,213,151,195,197,207,64,0,2,7,2,0, +266,59,253,44,242,34,234,29,228,26,222,25,216,28,216,31,215,33,216,38,217,44,218,49,220,55,221,61,247,151,249,159,252,180,252,186,250,202,245,214,236,223,224,228,208,230,189,227,169,216,147,196,123,165,99,123,98,123,133,252,205,278,211,300,139,273,146,296,148,306,151,315,153,324,156,332,158,340,155,342,143,337,131,333,116,329,98,325,76,320,76,312,85,312,92,311,99,309,103,306,104,301,104,293,103,290,103,286,93,257,45,239,40,218,87,234,23,0,65,0,78,41,88,72,98,97,109,117,121,137,137,159,152,177,167,191,180,200,190,203,198,202,203,199,207,194,209,188,209,175,207,161,206,155,204,150,185,78,182,66,178,54,175,41,173,31,172,23,174,13,177,5,183,0,190,-3,199,-4,211,-2,225,3,240,14,256,30,273,54,344,337,341,331,335,324,327,316,316,310,302,308,271,312,246,322,222,334,193,344,154,348,118,342,88,327,65,305,51,278,46,248,49,224,60,204,77,189,100,179,128,176,136,176,144,177,151,179,159,182,167,186,163,197,157,195,150,193,144,191,137,190,131,190,116,192,102,198,90,208,82,222,79,241,83,262,93,278,106,289,122,295,138,297,168,293,193,283,216,272,242,262,273,258,303,263,325,276,340,294,349,314,355,334,16383,16383,352,209,344,217,335,225,325,231,312,235,295,237,275,234,257,225,241,212,231,195,227,174,232,145,243,121,257,99,269,76,273,49,271,34,264,22,253,11,238,5,219,2,204,4,191,8,181,16,172,28,165,44,158,63,149,82,136,98,118,110,94,114,72,109,53,97,38,82,28,65,22,51,34,49,39,57,45,64,53,69,61,73, +99,123,98,123,99,123,99,123,98,123,109,117,99,123,109,117,123,165,123,165,109,117,121,137,104,296,104,293,133,252,133,252,104,293,103,290,133,252,103,290,103,286,103,286,93,257,98,123,98,123,93,257,98,97,98,123,98,97,109,117,203,199,208,230,198,202,198,202,208,230,190,203,180,200,190,203,189,227,180,200,189,227,169,216,123,165,137,159,147,196,147,196,137,159,152,177,147,196,152,177,169,216,169,216,152,177,167,191,169,216,167,191,180,200,204,150,185,78,190,-3,204,150,190,-3,199,-4,204,150,199,-4,211,-2,204,150,211,-2,206,155,211,-2,216,31,215,33,215,33,224,228,211,-2,211,-2,224,228,209,181,211,-2,209,181,209,175,211,-2,209,175,208,168,224,228,215,33,216,38,224,228,216,38,217,44,224,228,217,44,218,49,224,228,218,49,220,55,224,228,220,55,221,61,224,228,221,61,247,151,224,228,247,151,236,223,209,188,209,181,224,228,209,188,224,228,208,230,209,188,208,230,207,194,208,230,189,227,190,203,249,159,250,166,250,202,250,202,250,166,251,173,250,202,251,173,252,186,252,186,251,173,252,180,247,151,249,159,250,202,247,151,250,202,245,214,247,151,245,214,236,223,218,27,225,3,220,26,220,26,225,3,222,25,228,26,222,25,225,3,228,26,225,3,240,14,256,30,273,54,266,59,256,30,266,59,253,44,256,30,253,44,242,34,256,30,242,34,240,14,234,29,228,26,240,14,234,29,240,14,242,34,225,3,218,27,216,28,225,3,216,28,216,31,225,3,216,31,211,-2,207,161,206,155,211,-2,207,161,211,-2,208,168,183,0,190,-3,185,78,183,0,185,78,182,66,183,0,182,66,178,54,183,0,178,54,177,5,175,41,173,31,174,13,175,41,174,13,177,5,175,41,177,5,178,54,65,0,78,41,87,234,87,234,78,41,88,72,87,234,88,72,93,257,93,257,88,72,98,97,45,239,40,218,87,234,45,239,87,234,93,257,85,312,92,311,98,325,98,325,92,311,99,309,98,325,99,309,116,329,116,329,99,309,103,306,116,329,103,306,104,301,104,301,104,299,133,252,133,252,104,299,104,296,76,320,76,312,85,312,76,320,85,312,98,325,151,315,153,324,155,342,155,342,153,324,156,332,155,342,156,332,158,340,133,252,139,273,143,337,143,337,139,273,146,296,143,337,146,296,155,342,155,342,146,296,148,306,155,342,148,306,151,315,133,252,143,337,131,333,133,252,131,333,116,329,133,252,116,329,104,301,103,286,98,123,133,252,139,273,133,252,205,278,139,273,205,278,211,300,65,0,87,234,23,0,174,13,173,31,172,23,208,230,203,199,207,194,121,137,137,159,123,165, +344,337,341,331,335,324,327,316,316,310,302,308,271,312,246,322,222,334,193,344,154,348,118,342,88,327,65,305,51,278,46,248,49,224,60,204,77,189,100,179,128,176,136,176,144,177,151,179,159,182,167,186,163,197,157,195,150,193,144,191,137,190,131,190,116,192,102,198,90,208,82,222,79,241,83,262,93,278,106,289,122,295,138,297,168,293,193,283,216,272,242,262,273,258,303,263,325,276,340,294,349,314,355,334,16383,16383,352,209,344,217,335,225,325,231,312,235,295,237,275,234,257,225,241,212,231,195,227,174,232,145,243,121,257,99,269,76,273,49,271,34,264,22,253,11,238,5,219,2,204,4,191,8,181,16,172,28,165,44,158,63,149,82,136,98,118,110,94,114,72,109,53,97,38,82,28,65,22,51,34,49,39,57,45,64,53,69,61,73,69,74,75,73,81,70,87,65,92,58,97,49,102,39,108,29,114,20,122,11,132,3,144,-3,157,-9,172,-13,192,-15,215,-16,253,-11,285,1,311,22,329,47,335,76,329,103,316,127,300,149,287,169,281,186,283,197,287,205,294,211,302,214,310,215,316,215,322,214,328,211,335,207,343,200,314,0,314,331,292,331,292,78,291,78,118,309,103,331,35,331,35,0,57,0,57,252,58,252,247,0,16383,16383,292,22,257,22,57,289,57,309,91,309,292,41,483,153,480,178,471,200,456,217,437,229,414,233,389,229,370,217,356,199,347,177,344,152,347,128,355,107,370,89,389,78,414,74,437,78,457,89,471,106,480,128,483,153,16383,16383,444,152,443,127,439,108,433,95,424,87,413,84,402,87,393,95,387,108,384,127,383,152,384,178,388,197,394,211,402,219,412,222,424,219,433,211,439,197,443,178,444,152,16383,16383,481,0,481,44,346,44,346,0,16383,16383,278,107,135,331,45,331,45,321,53,321,71,318,75,316,80,313,86,308,92,301,99,291,107,280,107,112,104,78,98,47,88,26,71,17,64,21,53,43,45,53,31,57,24,56,17,53,10,48,5,40,3,30,6,14,13,4,24,-2,38,-5,55,-6,91,2,113,27,124,60,128,97,129,131,129,246,291,-5,300,-5,300,186,301,219,303,253,309,284,319,305,335,314,343,309,348,300,354,288,362,278,376,274,383,275,390,278,397,283,402,291,403,301,401,317,394,327,383,334,369,337,353,338,316,329, +102,198,90,208,100,179,100,179,90,208,82,222,100,179,82,222,77,189,77,189,82,222,79,241,88,327,79,241,83,262,88,327,83,262,93,278,154,348,138,297,168,293,154,348,168,293,193,344,193,344,168,293,193,283,193,344,193,283,222,334,222,334,193,283,216,272,222,334,216,272,242,262,222,334,242,262,246,322,246,322,242,262,273,258,246,322,273,258,271,312,271,312,273,258,302,308,316,310,302,308,303,263,316,310,303,263,325,276,355,334,344,337,349,314,349,314,344,337,341,331,349,314,341,331,340,294,340,294,341,331,335,324,340,294,335,324,327,316,327,316,316,310,325,276,327,316,325,276,340,294,302,308,273,258,303,263,295,237,275,234,283,197,283,197,275,234,281,186,285,1,281,186,275,234,285,1,275,234,273,49,273,49,271,34,285,1,285,1,271,34,264,22,285,1,264,22,253,-11,253,-11,264,22,253,11,253,-11,253,11,238,5,325,231,312,235,316,215,316,215,312,235,310,215,302,214,310,215,312,235,302,214,312,235,295,237,295,237,283,197,287,205,295,237,287,205,294,211,295,237,294,211,302,214,343,200,352,209,344,217,343,200,344,217,335,225,343,200,335,225,335,207,316,215,322,214,325,231,325,231,322,214,328,211,325,231,328,211,335,225,335,225,328,211,335,207,335,76,329,103,329,47,329,47,329,103,316,127,329,47,316,127,311,22,311,22,316,127,300,149,311,22,300,149,287,169,287,169,281,186,285,1,287,169,285,1,311,22,238,5,219,2,253,-11,253,-11,219,2,215,-16,215,-16,219,2,204,4,215,-16,204,4,192,-15,192,-15,204,4,191,8,192,-15,191,8,181,16,93,278,106,289,118,342,118,342,106,289,122,295,118,342,122,295,154,348,154,348,122,295,138,297,65,305,51,278,60,204,65,305,60,204,77,189,65,305,77,189,79,241,65,305,79,241,88,327,51,278,46,248,49,224,51,278,49,224,60,204,157,195,150,193,151,179,151,179,150,193,144,191,151,179,144,191,144,177,144,177,144,191,137,190,144,177,137,190,136,176,136,176,137,190,131,190,128,176,136,176,131,190,128,176,131,190,116,192,128,176,116,192,102,198,128,176,102,198,100,179,159,182,167,186,163,197,159,182,163,197,157,195,159,182,157,195,151,179,94,114,72,109,75,73,75,73,72,109,69,74,61,73,69,74,72,109,61,73,72,109,53,97,53,97,38,82,39,57,53,97,39,57,45,64,53,97,45,64,53,69,53,97,53,69,61,73,34,49,39,57,38,82,34,49,38,82,28,65,34,49,28,65,22,51,81,70,87,65,94,114,94,114,87,65,92,58,94,114,92,58,97,49,97,49,102,39,118,110,118,110,102,39,108,29,118,110,108,29,114,20,122,11,132,3,136,98,136,98,132,3,144,-3,136,98,144,-3,149,82,149,82,144,-3,157,-9,149,82,157,-9,158,63,158,63,157,-9,172,-13,158,63,172,-13,165,44,165,44,172,-13,172,28,181,16,172,28,172,-13,181,16,172,-13,192,-15,118,110,114,20,122,11,118,110,122,11,136,98,118,110,94,114,97,49,231,195,232,145,241,212,241,212,232,145,243,121,241,212,243,121,257,225,257,225,243,121,257,99,257,225,257,99,275,234,275,234,257,99,269,76,275,234,269,76,273,49,232,145,231,195,227,174,94,114,75,73,81,70,88,327,93,278,118,342, + + +406,57,402,52,396,46,384,36,379,35,361,47,353,78,347,119,335,159,309,190,309,191,331,203,348,218,361,236,368,256,371,277,367,300,355,321,335,337,308,348,272,352,206,304,193,317,178,329,160,339,140,345,118,348,89,344,63,335,43,319,30,297,25,270,31,247,45,229,62,214,76,197,82,175,79,163,73,153,64,144,54,138,45,134,49,123,74,132,97,145,115,161,128,180,132,200,126,227,112,245,95,259,81,275,75,299,76,308,80,318,87,325,97,330,108,332,133,322,149,297,157,265,161,231,162,203,162,165,160,123,156,84,149,56,137,45,129,47,116,54,100,62,86,70,76,75,30,2,41,-3,51,9,56,14,60,17,63,20,70,17,83,11,97,3,111,-4,122,-10,149,19,173,53,193,88,209,125,220,161,257,170,269,162,276,149,280,132,282,113,283,94,284,70,289,44,298,21,313,1,333,-10,339,-10,355,0,372,11,388,24,403,36,415,47,16383,16383,222,179,223,189,223,200,224,212,224,233,223,242,222,253,220,265,217,276,214,286,225,297,235,304,245,310,255,313,266,314,283,310,296,302,305,291,310,278,312,266,310,246,303,226,289,208,268,192,238,182,356,0,248,142,271,153,290,167,303,186,311,208,314,233,308,271,291,298,265,317,232,328,195,331,35,331,35,0,118,0,118,136,155,136,252,0,16383,16383,246,302,262,293,275,281,284,268,290,251,292,232,290,214,284,197,274,182,261,170,246,161,16383,16383,224,160,218,159,212,159,207,158,201,158,196,157,118,157,118,309,203,309,208,308,214,307,224,305,16383,16383,313,22,264,22,181,136,184,136,186,135,206,135,213,136,219,136,225,137,16383,16383,96,22,57,22,57,309,96,309,382,0,382,11,365,13,350,18,337,26,326,36,314,47,382,113,368,127,300,61,284,80,254,120,224,158,250,166,274,178,295,196,309,217,315,244,306,281,282,306,250,323,213,331,177,334,35,334,35,321,57,320,73,315,85,307,92,292,94,269,94,65,92,42,85,27,73,18,57,14,35,12,35,0,197,0,197,12,175,14,158,18,147,27,140,42,138,65,138,152,145,152,149,151,162,151,165,152,172,152,270,31,200,-35,213,-49,282,17,295,0,16383,16383,138,283,140,298,146,308,156,314,168,317,182,318,212,315,235,307,251,293,261,271,264,240,259,207,244,186,222,174,194,168,163,166,158,166,153,167, +82,175,79,163,82,175,82,175,79,163,97,145,82,175,97,145,95,259,82,175,95,259,81,275,82,175,81,275,76,197,76,197,81,275,75,299,63,335,75,299,76,308,63,335,76,308,89,344,89,344,76,308,80,318,89,344,80,318,87,325,118,348,108,332,133,322,118,348,133,322,140,345,140,345,133,322,149,297,140,345,149,297,160,339,160,339,149,297,157,265,160,339,157,265,161,231,162,165,160,123,173,53,173,53,160,123,156,84,173,53,156,84,149,19,149,19,156,84,149,56,149,19,149,56,137,45,137,45,129,47,149,19,149,19,129,47,122,-10,220,161,257,170,222,179,220,161,222,179,222,253,220,161,222,253,220,265,220,161,220,265,217,276,220,161,217,276,214,286,220,161,214,286,209,125,222,179,223,189,223,242,223,242,223,189,223,200,223,242,223,200,224,233,224,233,223,200,224,212,224,233,224,212,224,223,206,304,193,317,193,88,193,88,193,317,178,329,193,88,178,329,173,53,173,53,178,329,162,203,63,20,70,17,76,75,76,75,70,17,83,11,76,75,83,11,86,70,86,70,83,11,97,3,86,70,97,3,100,62,100,62,97,3,111,-4,100,62,111,-4,116,54,116,54,111,-4,122,-10,116,54,122,-10,129,47,76,75,30,2,41,-3,76,75,41,-3,46,3,76,75,46,3,51,9,76,75,51,9,56,14,76,75,56,14,60,17,76,75,60,17,63,20,97,330,108,332,118,348,97,330,118,348,89,344,97,330,89,344,87,325,63,335,43,319,45,229,63,335,45,229,62,214,63,335,62,214,76,197,63,335,76,197,75,299,31,247,45,229,43,319,31,247,43,319,30,297,31,247,30,297,25,270,95,259,97,145,112,245,112,245,97,145,115,161,112,245,115,161,126,227,126,227,115,161,128,180,126,227,128,180,132,200,74,132,97,145,79,163,74,132,79,163,73,153,74,132,73,153,64,144,74,132,64,144,54,138,74,132,54,138,49,123,54,138,45,134,49,123,276,149,289,208,269,162,269,162,289,208,268,192,269,162,268,192,257,170,257,170,268,192,238,182,235,304,245,310,272,352,272,352,245,310,255,313,272,352,255,313,266,314,266,314,283,310,272,352,272,352,283,310,308,348,312,266,331,203,335,337,335,337,331,203,348,218,335,337,348,218,355,321,355,321,348,218,361,236,355,321,361,236,367,300,367,300,361,236,368,256,367,300,368,256,371,277,310,278,312,266,335,337,310,278,335,337,308,348,310,278,308,348,305,291,308,348,283,310,296,302,308,348,296,302,305,291,310,246,303,226,309,191,310,246,309,191,331,203,310,246,331,203,312,266,309,190,309,191,303,226,309,190,303,226,313,1,309,190,313,1,335,159,402,52,396,46,403,36,403,36,396,46,390,41,403,36,390,41,388,24,388,24,390,41,384,36,388,24,384,36,379,35,379,35,361,47,372,11,372,11,361,47,355,0,313,1,333,-10,335,159,335,159,333,-10,339,-10,335,159,339,-10,347,119,347,119,339,-10,355,0,347,119,355,0,353,78,353,78,355,0,361,47,283,94,284,70,289,208,289,208,284,70,289,44,289,208,289,44,303,226,303,226,289,44,298,21,303,226,298,21,313,1,276,149,280,132,289,208,289,208,280,132,282,113,289,208,282,113,283,94,406,57,402,52,403,36,406,57,403,36,415,47,379,35,372,11,388,24,272,352,206,304,214,286,272,352,214,286,225,297,272,352,225,297,235,304,206,304,193,88,209,125,206,304,209,125,214,286,161,231,162,203,178,329,161,231,178,329,160,339,222,179,257,170,238,182,162,165,173,53,162,203,222,179,223,242,222,253, +429,110,429,143,125,143,121,145,119,147,117,150,117,155,119,161,123,167,132,176,141,186,149,195,165,215,155,224,134,202,112,180,89,160,63,143,36,129,36,124,63,110,89,93,112,73,134,51,154,29,164,39,157,49,149,59,140,68,132,78,123,86,120,89,118,92,116,96,116,99,117,102,119,105,122,107,126,109,129,110,225,212,203,232,181,254,162,278,144,303,130,331,125,331,111,303,94,278,74,254,52,233,30,213,40,203,49,210,69,226,79,235,88,243,90,246,93,248,97,250,100,251,103,250,109,244,111,238,111,-77,144,-77,144,237,145,242,146,246,148,248,151,250,157,250,159,249,168,243,177,234,187,226,197,217,206,209,216,202,428,129, +121,145,119,147,119,105,119,105,119,147,117,150,119,105,117,150,117,102,117,102,117,150,117,153,116,99,112,180,112,73,112,73,112,180,89,160,112,73,89,160,89,93,89,93,89,160,63,143,89,93,63,143,63,110,63,110,63,143,36,129,63,110,36,129,36,124,155,224,134,202,141,186,155,224,141,186,149,195,155,224,149,195,157,205,155,224,157,205,165,215,134,202,112,180,118,158,134,202,118,158,119,161,134,202,119,161,121,164,134,202,121,164,123,167,134,202,123,167,132,176,134,202,132,176,141,186,117,155,118,158,112,180,117,155,112,180,117,153,140,68,132,78,134,51,134,51,132,78,123,86,134,51,123,86,120,89,129,143,125,143,126,109,129,143,126,109,129,110,129,143,129,110,429,110,129,143,429,110,429,143,122,107,126,109,125,143,122,107,125,143,121,145,122,107,121,145,119,105,154,29,164,39,157,49,154,29,157,49,149,59,154,29,149,59,140,68,154,29,140,68,134,51,116,96,116,99,112,73,116,96,112,73,117,94,117,94,112,73,134,51,117,94,134,51,118,92,118,92,134,51,120,89,117,102,117,153,116,99,117,153,112,180,116,99, +225,212,203,232,181,254,162,278,144,303,130,331,125,331,111,303,94,278,74,254,52,233,30,213,40,203,49,210,69,226,79,235,88,243,90,246,93,248,97,250,100,251,103,250,109,244,111,238,111,-77,144,-77,144,237,145,242,146,246,148,248,151,250,157,250,159,249,168,243,177,234,187,226,197,217,206,209,216,202,428,129,400,143,375,160,352,180,330,201,310,224,300,214,314,194,323,185,332,175,340,166,343,164,345,161,347,159,347,157,348,154,347,151,341,145,338,144,334,143,35,143,35,110,334,110,339,109,343,108,345,106,347,103,347,97,346,95,340,86,331,77,322,67,314,58,306,48,299,38,309,28,330,51,351,72,375,92, +90,246,93,248,94,278,94,278,93,248,95,249,94,278,95,249,111,303,111,303,95,249,97,250,111,303,97,250,100,251,100,251,103,250,111,303,111,303,103,250,106,247,111,303,106,247,109,244,110,241,111,238,111,303,111,303,111,238,125,331,125,331,111,238,144,-77,125,331,144,-77,130,331,130,331,144,-77,144,237,130,331,144,237,144,303,144,303,144,237,145,242,144,303,145,242,146,246,88,243,90,246,94,278,88,243,94,278,79,235,79,235,94,278,74,254,79,235,74,254,69,226,69,226,74,254,59,218,52,233,30,213,40,203,52,233,40,203,49,210,52,233,49,210,59,218,52,233,59,218,74,254,146,246,148,248,162,278,162,278,148,248,151,250,162,278,151,250,154,250,154,250,157,250,162,278,162,278,157,250,159,249,162,278,159,249,162,247,187,226,197,217,203,232,203,232,197,217,206,209,203,232,206,209,225,212,225,212,206,209,216,202,181,254,162,278,162,247,181,254,162,247,165,245,181,254,165,245,168,243,181,254,168,243,177,234,181,254,177,234,187,226,181,254,187,226,203,232,111,238,111,-77,144,-77,144,303,146,246,162,278,111,303,109,244,110,241, +428,129,400,143,375,160,352,180,330,201,310,224,300,214,314,194,323,185,332,175,340,166,343,164,345,161,347,159,347,157,348,154,347,151,341,145,338,144,334,143,35,143,35,110,334,110,339,109,343,108,345,106,347,103,347,97,346,95,340,86,331,77,322,67,314,58,306,48,299,38,309,28,330,51,351,72,375,92,400,110,428,124,216,50,206,43,186,27,168,9,165,7,163,5,160,3,158,3,156,2,153,3,147,9,145,12,145,331,112,331,112,16,111,11,110,8,105,3,99,3,96,4,90,8,88,10,78,19,69,28,49,44,40,51,30,41,53,20,74,-1,94,-24,111,-49,126,-77,131,-77,145,-49,162,-24,182,-1,203,20,225,41,444,129,417,143,391,160, +347,97,351,72,347,100,347,100,351,72,348,154,348,154,351,72,352,180,352,180,351,72,375,92,352,180,375,92,375,160,375,160,375,92,400,110,375,160,400,110,400,143,400,143,400,110,428,124,400,143,428,124,428,129,352,180,330,201,332,175,352,180,332,175,340,166,352,180,340,166,343,164,352,180,343,164,345,161,352,180,345,161,347,159,352,180,347,159,347,157,352,180,347,157,348,154,300,214,307,204,310,224,310,224,307,204,314,194,310,224,314,194,330,201,330,201,314,194,323,185,330,201,323,185,332,175,35,143,334,110,334,143,338,144,334,143,339,109,338,144,339,109,341,145,341,145,339,109,343,108,341,145,343,108,344,148,344,148,343,108,345,106,344,148,345,106,347,151,347,151,345,106,347,103,347,151,347,103,347,100,322,67,330,51,331,77,331,77,330,51,351,72,331,77,351,72,340,86,340,86,351,72,342,89,351,72,347,97,346,95,351,72,346,95,344,92,351,72,344,92,342,89,314,58,306,48,309,28,314,58,309,28,330,51,314,58,330,51,322,67,348,154,347,151,347,100,334,110,35,143,35,110,334,143,334,110,339,109,309,28,306,48,299,38, +216,50,206,43,186,27,168,9,165,7,163,5,160,3,158,3,156,2,153,3,147,9,145,12,145,331,112,331,112,16,111,11,110,8,105,3,99,3,96,4,90,8,88,10,78,19,69,28,49,44,40,51,30,41,53,20,74,-1,94,-24,111,-49,126,-77,131,-77,145,-49,162,-24,182,-1,203,20,225,41,444,129,417,143,391,160,368,180,346,201,325,224,315,214,322,204,330,194,339,185,348,175,359,164,361,161,363,157,363,154,362,151,360,148,357,145,354,144,350,143,108,143,104,145,102,147,100,150,100,155,101,158,107,167,116,176,125,186,133,195,141,205,148,215,138,224,96,180,72,160,47,143,19,129,19,124, +110,8,107,5,111,-49,111,-49,107,5,105,3,111,-49,105,3,102,3,102,3,99,3,111,-49,111,-49,99,3,96,4,111,-49,96,4,94,-24,94,-24,96,4,93,6,94,-24,93,6,90,8,150,6,147,9,162,-24,162,-24,147,9,145,12,162,-24,145,12,145,-49,145,-49,145,12,145,16,145,16,145,331,131,-77,131,-77,145,331,126,-77,145,331,112,331,126,-77,126,-77,112,331,112,16,126,-77,112,16,111,-49,111,-49,112,16,111,11,111,-49,111,11,110,8,163,5,160,3,162,-24,162,-24,160,3,158,3,162,-24,158,3,156,2,156,2,153,3,162,-24,162,-24,153,3,150,6,186,27,177,18,182,-1,182,-1,177,18,168,9,182,-1,168,9,165,7,206,43,196,35,203,20,206,43,203,20,225,41,206,43,225,41,216,50,186,27,182,-1,203,20,186,27,203,20,196,35,163,5,162,-24,182,-1,163,5,182,-1,165,7,90,8,88,10,94,-24,94,-24,88,10,78,19,94,-24,78,19,74,-1,74,-1,78,19,69,28,74,-1,69,28,59,36,53,20,74,-1,59,36,53,20,59,36,49,44,53,20,49,44,40,51,53,20,40,51,30,41,145,-49,145,16,131,-77, +444,129,417,143,391,160,368,180,346,201,325,224,315,214,322,204,330,194,339,185,348,175,359,164,361,161,363,157,363,154,362,151,360,148,357,145,354,144,350,143,108,143,104,145,102,147,100,150,100,155,101,158,107,167,116,176,125,186,133,195,141,205,148,215,138,224,96,180,72,160,47,143,19,129,19,124,47,110,72,93,95,73,117,51,137,29,147,39,133,59,124,68,115,78,104,89,102,92,100,94,100,96,99,99,100,102,103,105,109,109,113,110,350,110,355,109,358,108,361,106,363,100,362,97,362,95,356,86,347,77,338,67,330,58,322,48,315,38,325,28,345,51,367,72,391,92,417,110,444,124,225,246,203,266,182,288,162,312,145,337,131,365,126,365,112,337,94,312,74,288,53,267,31,247,40,237,50,244,70,260,79,269,88,277,93,282,96,283,100,285,104,284,107,281,111,275,112,272,112,-16,111,-21,110,-25,107,-28,105,-29,102,-30,93,-27,90,-25,88,-22,78,-13,69,-5,59,2,49,10,40,17,30,7,53,-12,74,-34,94,-58,111,-83,126,-111,131,-111,145,-83,162,-58,181,-34,203,-12,225,7,215,17,206,10,196,2,186,-5,163,-28,160,-29,158,-30,156,-30,153,-29,150,-27,147,-24,145,-20,145,276,147,280,149,282,152,284,157,284,160,283,169,277,178,268,187,260,197,251,206,243,216,236,428,-54, +104,145,102,147,103,105,103,105,102,147,100,150,103,105,100,150,100,102,100,102,100,150,100,153,99,99,96,180,95,73,95,73,96,180,72,160,95,73,72,160,72,93,72,93,72,160,47,143,72,93,47,143,47,110,47,110,47,143,19,129,47,110,19,129,19,124,138,224,117,202,125,186,138,224,125,186,133,195,138,224,133,195,141,205,138,224,141,205,148,215,117,202,96,180,101,158,117,202,101,158,103,161,117,202,103,161,105,164,117,202,105,164,107,167,117,202,107,167,116,176,117,202,116,176,125,186,100,155,101,158,96,180,100,155,96,180,100,153,124,68,115,78,117,51,117,51,115,78,107,86,117,51,107,86,104,89,137,29,147,39,140,49,137,29,140,49,133,59,137,29,133,59,124,68,137,29,124,68,117,51,363,100,367,72,363,154,363,154,367,72,368,180,368,180,367,72,391,92,368,180,391,92,391,160,391,160,391,92,417,110,391,160,417,110,417,143,417,143,417,110,444,124,417,143,444,124,444,129,368,180,346,201,348,175,368,180,348,175,357,166,368,180,357,166,359,164,368,180,359,164,361,161,368,180,361,161,362,159,368,180,362,159,363,157,368,180,363,157,363,154,315,214,322,204,325,224,325,224,322,204,330,194,325,224,330,194,346,201,346,201,330,194,339,185,346,201,339,185,348,175,350,110,355,109,350,143,354,144,350,143,355,109,354,144,355,109,357,145,357,145,355,109,358,108,357,145,358,108,360,148,360,148,358,108,361,106,360,148,361,106,362,151,362,151,361,106,362,103,362,151,362,103,363,100,338,67,345,51,347,77,347,77,345,51,367,72,347,77,367,72,356,86,356,86,367,72,358,89,362,97,362,95,367,72,362,97,367,72,363,100,360,92,358,89,367,72,360,92,367,72,362,95,330,58,322,48,325,28,330,58,325,28,345,51,330,58,345,51,338,67,363,154,362,151,363,100,350,110,350,143,113,110,113,110,350,143,113,143,113,110,113,143,109,109,108,143,104,145,106,107,108,143,106,107,109,109,108,143,109,109,113,143,100,96,99,99,95,73,100,96,95,73,100,94,100,94,95,73,117,51,100,94,117,51,102,92,102,92,117,51,104,89,100,102,100,153,99,99,104,145,103,105,106,107,325,28,322,48,315,38,100,153,96,180,99,99, +225,246,203,266,182,288,162,312,145,337,131,365,126,365,112,337,94,312,74,288,53,267,31,247,40,237,50,244,70,260,79,269,88,277,93,282,96,283,100,285,104,284,107,281,111,275,112,272,112,-16,111,-21,110,-25,107,-28,105,-29,102,-30,93,-27,90,-25,88,-22,78,-13,69,-5,59,2,49,10,40,17,30,7,53,-12,74,-34,94,-58,111,-83,126,-111,131,-111,145,-83,162,-58,181,-34,203,-12,225,7,215,17,206,10,196,2,186,-5,163,-28,160,-29,158,-30,156,-30,153,-29,150,-27,147,-24,145,-20,145,276,147,280,149,282,152,284,157,284,160,283,169,277,178,268,187,260,197,251,206,243,216,236,428,-54,118,271,115,274,111,280,110,282,110,285,111,287,111,288,112,290,113,291,115,292,117,294,121,295,124,296,153,296,166,297,178,298,190,300,190,315,182,314,173,313,125,313,103,315,81,318,60,324,39,331,35,328,43,306,48,285,51,263,53,241,54,219,53,210,53,193,52,184,51,176,65,176,68,188,70,214,70,243,72,249,73,251,76,254,77,254,78,255,83,255,85,254,88,254,92,252,404,-77,425,331,403,324,382,318,360,315,338,313,289,313,281,314,272,315,272,300,284,298,297,297,309,296,339,296,342,295,346,294,348,292,350,291,351,290,352,288,353,287,353,282,352,280,348,274,345,271, +69,-5,74,-34,78,-13,78,-13,74,-34,94,-58,78,-13,94,-58,88,-22,88,-22,94,-58,90,-25,91,280,93,282,94,312,94,312,93,282,96,283,94,312,96,283,112,337,112,337,96,283,98,284,112,337,98,284,100,285,100,285,104,284,112,337,112,337,104,284,107,281,112,337,107,281,109,278,110,-25,107,-28,111,-83,111,-83,107,-28,105,-29,111,-83,105,-29,102,-30,102,-30,99,-29,111,-83,111,-83,99,-29,96,-28,111,-83,96,-28,94,-58,94,-58,96,-28,93,-27,94,-58,93,-27,90,-25,109,278,111,275,112,337,112,337,111,275,112,272,112,272,126,-111,126,365,126,365,126,-111,131,-111,126,365,131,-111,131,365,131,365,131,-111,145,-83,131,365,145,-83,145,271,145,271,145,-83,145,-17,88,277,91,280,94,312,88,277,94,312,79,269,79,269,94,312,74,288,79,269,74,288,70,260,70,260,74,288,60,252,53,267,31,247,40,237,53,267,40,237,50,244,53,267,50,244,60,252,53,267,60,252,74,288,147,280,149,282,162,312,162,312,149,282,152,284,162,312,152,284,155,284,155,284,157,284,162,312,162,312,157,284,160,283,162,312,160,283,163,281,187,260,197,251,203,266,203,266,197,251,206,243,203,266,206,243,225,246,225,246,206,243,216,236,182,288,162,312,163,281,182,288,163,281,166,279,182,288,166,279,169,277,182,288,169,277,178,268,182,288,178,268,187,260,182,288,187,260,203,266,145,337,131,365,145,271,145,337,145,271,145,276,145,337,145,276,147,280,145,337,147,280,162,312,163,-28,160,-29,162,-58,162,-58,160,-29,158,-30,162,-58,158,-30,156,-30,156,-30,153,-29,162,-58,162,-58,153,-29,150,-27,162,-58,150,-27,147,-24,186,-5,177,-14,181,-34,181,-34,177,-14,168,-23,181,-34,168,-23,165,-26,206,10,196,2,203,-12,206,10,203,-12,225,7,206,10,225,7,215,17,186,-5,181,-34,203,-12,186,-5,203,-12,196,2,163,-28,162,-58,181,-34,163,-28,181,-34,165,-26,145,-20,145,-17,145,-83,145,-20,145,-83,162,-58,145,-20,162,-58,147,-24,112,-16,111,-21,111,-83,112,-16,111,-83,126,-111,112,-16,126,-111,112,272,59,2,49,10,53,-12,59,2,53,-12,74,-34,59,2,74,-34,69,-5,40,17,30,7,53,-12,40,17,53,-12,49,10,110,-25,111,-83,111,-21,112,337,112,272,126,365, +428,-54,118,271,115,274,111,280,110,282,110,285,111,287,111,288,112,290,113,291,115,292,117,294,121,295,124,296,153,296,166,297,178,298,190,300,190,315,182,314,173,313,125,313,103,315,81,318,60,324,39,331,35,328,43,306,48,285,51,263,53,241,54,219,53,210,53,193,52,184,51,176,65,176,68,188,70,214,70,243,72,249,73,251,76,254,77,254,78,255,83,255,85,254,88,254,92,252,404,-77,425,331,403,324,382,318,360,315,338,313,289,313,281,314,272,315,272,300,284,298,297,297,309,296,339,296,342,295,346,294,348,292,350,291,351,290,352,288,353,287,353,282,352,280,348,274,345,271,35,-54,59,-77,372,252,373,253,375,254,377,254,380,255,385,255,387,254,388,254,388,253,390,251,391,249,392,246,392,226,393,214,395,188,397,176,411,176,411,185,410,193,410,241,412,263,415,285,421,307,428,328, +48,285,51,263,60,324,60,324,51,263,53,241,60,324,53,241,54,219,54,219,53,210,65,176,65,176,53,210,53,201,65,176,53,201,53,193,60,324,39,331,43,306,60,324,43,306,48,285,77,254,78,255,81,318,81,318,78,255,79,255,81,318,79,255,80,255,80,255,83,255,81,318,81,318,83,255,103,315,81,318,60,324,71,246,81,318,71,246,72,249,81,318,72,249,73,251,81,318,73,251,75,253,81,318,75,253,76,254,81,318,76,254,77,254,65,176,68,188,70,243,70,243,68,188,69,201,70,243,69,201,70,239,70,239,69,201,70,214,70,239,70,214,70,226,60,324,54,219,65,176,60,324,65,176,70,243,60,324,70,243,71,246,52,184,51,176,65,176,52,184,65,176,53,193,103,315,92,252,110,282,103,315,110,282,110,284,110,284,110,285,103,315,103,315,110,285,111,287,103,315,111,287,111,288,103,315,83,255,85,254,103,315,85,254,88,254,103,315,88,254,90,253,103,315,90,253,92,252,103,315,111,288,125,313,125,313,111,288,112,290,125,313,112,290,113,291,113,291,115,292,125,313,125,313,115,292,117,294,125,313,117,294,121,295,147,313,127,296,140,296,147,313,140,296,153,296,147,313,147,312,125,313,147,313,125,313,127,296,165,313,166,297,173,313,173,313,166,297,178,298,173,313,178,298,182,314,182,314,178,298,190,300,182,314,190,300,190,315,156,313,147,312,147,313,156,313,147,313,153,296,156,313,153,296,166,297,156,313,166,297,165,313,124,296,127,296,125,313,124,296,125,313,121,295,428,-54,118,271,404,-77,404,-77,118,271,115,274,404,-77,115,274,92,252,92,252,115,274,113,277,92,252,113,277,111,280,43,306,39,331,35,328,92,252,111,280,110,282, +425,331,403,324,382,318,360,315,338,313,289,313,281,314,272,315,272,300,284,298,297,297,309,296,339,296,342,295,346,294,348,292,350,291,351,290,352,288,353,287,353,282,352,280,348,274,345,271,35,-54,59,-77,372,252,373,253,375,254,377,254,380,255,385,255,387,254,388,254,388,253,390,251,391,249,392,246,392,226,393,214,395,188,397,176,411,176,411,185,410,193,410,241,412,263,415,285,421,307,428,328,428,-74,421,-53,415,-31,412,-9,410,12,410,60,411,68,411,76,397,77,395,65,392,26,392,7,391,4,390,2,387,-1,380,-1,377,0,373,0,372,2,59,331,35,307,345,-17,348,-20,352,-26,353,-28,353,-33,352,-34,351,-36,350,-36,346,-40,342,-41,335,-41,322,-42,309,-42,297,-43,284,-45,272,-46,272,-60,281,-60,289,-59,338,-59,360,-61,382,-65,403,-70,425,-77,428,307,404,331,92,2,90,0,88,0, +272,315,272,315,281,314,281,314,272,315,284,298,281,314,284,298,289,313,289,313,284,298,297,297,289,313,297,297,298,313,298,313,297,297,309,296,298,313,309,296,307,313,307,313,309,296,315,313,338,313,315,313,322,296,338,313,322,296,335,296,375,254,377,254,382,318,382,318,377,254,380,255,382,318,380,255,382,255,382,255,384,255,403,324,403,324,384,255,385,255,403,324,385,255,387,254,353,285,353,284,360,315,360,315,353,284,372,252,360,315,372,252,382,318,382,318,372,252,373,253,382,318,373,253,375,254,372,252,353,284,353,282,372,252,353,282,352,280,372,252,352,280,350,277,372,252,350,277,348,274,372,252,348,274,345,271,372,252,345,271,59,-77,410,193,410,201,403,324,403,324,410,201,410,210,403,324,410,210,410,219,410,219,410,241,403,324,403,324,410,241,412,263,403,324,412,263,415,285,403,324,415,285,425,331,425,331,415,285,421,307,425,331,421,307,428,328,395,188,397,176,403,324,403,324,397,176,411,176,403,324,411,176,410,193,410,193,411,176,411,185,403,324,387,254,388,254,403,324,388,254,388,253,403,324,388,253,390,251,403,324,390,251,391,249,403,324,391,249,392,246,403,324,392,246,392,243,403,324,392,243,392,239,403,324,392,239,392,226,403,324,392,226,393,214,403,324,393,214,394,201,403,324,394,201,395,188,403,324,382,318,382,255,360,315,338,313,339,296,360,315,339,296,342,295,360,315,342,295,346,294,360,315,346,294,348,292,360,315,348,292,350,291,360,315,350,291,351,290,360,315,351,290,352,288,360,315,352,288,353,287,360,315,353,287,353,285,335,296,339,296,338,313,315,313,309,296,322,296,59,-77,345,271,35,-54,284,298,272,315,272,300, +428,-74,421,-53,415,-31,412,-9,410,12,410,60,411,68,411,76,397,77,395,65,392,26,392,7,391,4,390,2,387,-1,380,-1,377,0,373,0,372,2,59,331,35,307,345,-17,348,-20,352,-26,353,-28,353,-33,352,-34,351,-36,350,-36,346,-40,342,-41,335,-41,322,-42,309,-42,297,-43,284,-45,272,-46,272,-60,281,-60,289,-59,338,-59,360,-61,382,-65,403,-70,425,-77,428,307,404,331,92,2,90,0,88,0,85,-1,77,-1,76,0,75,0,73,2,72,4,70,10,70,39,68,65,65,77,51,76,53,60,53,43,54,35,53,12,51,-9,48,-31,43,-53,35,-74,39,-77,60,-70,81,-65,103,-61,125,-59,173,-59,182,-60,190,-60,190,-46,178,-45,166,-43,153,-42,140,-42,127,-41,121,-41,117,-40,113,-36,112,-36,111,-34,111,-33,110,-32, +335,-41,322,-42,338,-59,338,-59,322,-42,315,-59,307,-59,315,-59,309,-42,307,-59,309,-42,298,-59,298,-59,309,-42,297,-43,298,-59,297,-43,289,-59,289,-59,297,-43,284,-45,289,-59,284,-45,281,-60,281,-60,284,-45,272,-46,281,-60,272,-46,272,-60,322,-42,309,-42,315,-59,353,-33,352,-34,360,-61,360,-61,352,-34,351,-36,360,-61,351,-36,350,-36,372,2,59,331,345,-17,372,2,345,-17,348,-20,372,2,348,-20,350,-23,372,2,350,-23,352,-26,372,2,352,-26,353,-28,372,2,353,-28,353,-30,372,2,353,-30,360,-61,372,2,360,-61,382,-65,372,2,382,-65,373,0,387,-1,385,-1,403,-70,403,-70,385,-1,384,-1,403,-70,384,-1,382,-1,382,-1,380,-1,382,-65,382,-65,380,-1,377,0,382,-65,377,0,375,0,360,-61,353,-30,353,-32,360,-61,353,-32,353,-33,393,39,392,26,403,-70,403,-70,392,26,392,14,403,-70,392,14,392,10,415,-31,412,-9,403,-70,403,-70,412,-9,410,12,403,-70,410,12,410,35,410,35,410,43,403,-70,403,-70,410,43,410,52,403,-70,410,52,410,60,411,76,397,77,403,-70,411,76,403,-70,410,60,411,76,410,60,411,68,403,-70,397,77,395,65,403,-70,395,65,394,52,403,-70,394,52,393,39,403,-70,392,10,392,7,403,-70,392,7,391,4,403,-70,391,4,390,2,403,-70,390,2,388,0,403,-70,388,0,387,-1,382,-1,382,-65,403,-70,425,-77,428,-74,421,-53,425,-77,421,-53,415,-31,425,-77,415,-31,403,-70,360,-61,350,-36,348,-38,360,-61,348,-38,346,-40,360,-61,346,-40,342,-41,360,-61,342,-41,339,-41,360,-61,339,-41,338,-59,339,-41,335,-41,338,-59,345,-17,59,331,35,307,373,0,382,-65,375,0, +428,307,404,331,92,2,90,0,88,0,85,-1,77,-1,76,0,75,0,73,2,72,4,70,10,70,39,68,65,65,77,51,76,53,60,53,43,54,35,53,12,51,-9,48,-31,43,-53,35,-74,39,-77,60,-70,81,-65,103,-61,125,-59,173,-59,182,-60,190,-60,190,-46,178,-45,166,-43,153,-42,140,-42,127,-41,121,-41,117,-40,113,-36,112,-36,111,-34,111,-33,110,-32,110,-28,111,-26,115,-20,118,-17,433,110,433,143,300,143,349,225,320,225,272,143,119,143,113,147,111,153,111,155,113,161,115,164,127,176,135,186,144,196,152,206,159,215,149,225,129,202,107,181,83,161,58,143,30,129,30,124,58,110,83,93,107,73,128,51,148,29,158,39,151,49,143,59,135,68,126,78,115,89,113,92,111,96,110,99,111,102,114,105,120,109,123,110,252,110,204,29,233,29,281,110,433,129,405,143,380,161, +78,-1,81,-65,79,-1,79,-1,81,-65,80,-1,83,-1,80,-1,81,-65,83,-1,81,-65,103,-61,111,-34,111,-33,103,-61,103,-61,111,-33,110,-32,103,-61,110,-32,110,-30,110,-30,110,-28,103,-61,103,-61,110,-28,92,2,103,-61,92,2,90,0,115,-20,118,-17,404,331,115,-20,404,331,92,2,404,331,118,-17,428,307,92,2,110,-28,111,-26,92,2,111,-26,113,-23,92,2,113,-23,115,-20,103,-61,90,0,88,0,103,-61,88,0,85,-1,103,-61,85,-1,83,-1,147,-59,140,-42,127,-41,147,-59,127,-41,125,-59,147,-59,153,-42,140,-42,156,-59,165,-59,166,-43,166,-43,165,-59,173,-59,166,-43,173,-59,178,-45,178,-45,173,-59,182,-60,178,-45,182,-60,190,-46,190,-46,182,-60,190,-60,156,-59,166,-43,153,-42,156,-59,153,-42,147,-59,121,-41,117,-40,125,-59,125,-59,117,-40,115,-38,125,-59,115,-38,113,-36,124,-41,121,-41,125,-59,124,-41,125,-59,127,-41,125,-59,113,-36,112,-36,125,-59,112,-36,111,-34,125,-59,111,-34,103,-61,81,-65,78,-1,77,-1,81,-65,77,-1,76,0,81,-65,76,0,75,0,81,-65,75,0,73,2,81,-65,73,2,72,4,81,-65,72,4,71,7,81,-65,71,7,60,-70,70,10,70,14,69,52,70,10,69,52,68,65,70,10,68,65,65,77,70,10,65,77,60,-70,70,10,60,-70,71,7,70,39,69,52,70,14,70,39,70,14,70,26,60,-70,65,77,54,35,60,-70,54,35,53,12,60,-70,53,12,51,-9,60,-70,51,-9,48,-31,60,-70,48,-31,43,-53,60,-70,43,-53,39,-77,53,60,53,51,65,77,65,77,53,51,53,43,65,77,53,43,54,35,65,77,51,76,52,68,65,77,52,68,53,60,43,-53,35,-74,39,-77, +279,331,243,331,206,232,74,232,36,331,1,331,123,0,156,0,16383,16383,195,201,140,51,84,201,202,110,169,110,169,65,165,48,155,37,141,30,128,27,117,26,107,26,92,29,78,36,67,47, +156,0,279,331,195,201,195,201,279,331,206,232,195,201,206,232,84,201,84,201,206,232,74,232,84,201,74,232,123,0,123,0,74,232,36,331,123,0,36,331,1,331,140,51,84,201,123,0,140,51,123,0,156,0,140,51,156,0,195,201,206,232,279,331,243,331, +202,110,169,110,169,65,165,48,155,37,141,30,128,27,117,26,107,26,92,29,78,36,67,47,63,65,63,308,67,326,78,337,92,344,105,346,116,347,126,347,140,344,154,338,165,326,169,307,169,262,202,262,202,305,196,339,180,360,158,373,136,379,117,380,97,379,74,373,52,361,36,339,30,306,30,65,36,32,51,11,72,0,94,-5,114,-6,134,-5,157,0,179,10,196,30,202,61,98,313,112,317,119,318,127,319,134,319,161,314,179,300,191,279,198,255,200,228,200,221,199,214,199,207,198,200,196,194,189,203,180,210,169,214,159,217,148,218,107,210,72,188,44,156,26,117,20,75,22,51,30,29,43,11,62,0,88,-5,148,9,190,47,217,98,231,154,235,204,232,250,220,287,202,313,175,329,142,334,131,334,121,333,101,327,93,323,16383,16383,184,160,182,140,180,131, +105,346,116,347,116,347,117,380,116,347,126,347,117,380,126,347,136,379,136,379,126,347,140,344,136,379,140,344,158,373,158,373,140,344,154,338,158,373,154,338,165,326,202,305,196,339,202,262,202,262,196,339,180,360,202,262,180,360,169,307,169,307,180,360,165,326,78,337,92,344,97,379,97,379,92,344,105,346,97,379,105,346,117,380,117,380,105,346,116,347,74,373,52,361,63,308,74,373,63,308,67,326,74,373,67,326,78,337,74,373,78,337,97,379,30,306,30,65,36,32,30,306,36,32,36,339,36,339,36,32,51,11,36,339,51,11,52,361,52,361,51,11,63,65,52,361,63,65,63,308,165,48,155,37,157,0,157,0,155,37,141,30,157,0,141,30,134,-5,134,-5,141,30,128,27,134,-5,128,27,117,26,117,26,107,26,114,-6,114,-6,107,26,94,-5,107,26,92,29,94,-5,94,-5,92,29,78,36,94,-5,78,36,72,0,72,0,78,36,67,47,72,0,67,47,63,65,63,65,51,11,72,0,202,110,169,110,179,10,202,110,179,10,196,30,202,110,196,30,202,61,179,10,169,110,169,65,179,10,169,65,165,48,179,10,165,48,157,0,117,26,114,-6,134,-5,202,262,169,307,169,262,158,373,165,326,180,360, +98,313,112,317,119,318,127,319,134,319,161,314,179,300,191,279,198,255,200,228,200,221,199,214,199,207,198,200,196,194,189,203,180,210,169,214,159,217,148,218,107,210,72,188,44,156,26,117,20,75,22,51,30,29,43,11,62,0,88,-5,148,9,190,47,217,98,231,154,235,204,232,250,220,287,202,313,175,329,142,334,131,334,121,333,101,327,93,323,16383,16383,184,160,182,140,180,131,178,121,176,110,166,80,152,53,135,30,116,15,94,9,78,13,68,21,63,33,61,46,60,59,65,100,79,139,99,172,124,194,153,203,161,201,169,197,177,189,182,176,184,160,243,0,243,331,36,331,36,298,210,298,210,182,42,182,42,149,210,149,210,33,36,33,36,0,243,0,243,331,199,331,219,387,190,387,170,331,36,331,36,298,159,298,119,182,42,182,42,149,108,149,68,33,36,33,36,0,56,0,36,-60,65,-60,85,0,16383,16383,210,182,148,182,188,298,210,298,16383,16383,210,33,97,33,137,149,210,149,353,291,318,291,289,258,272,270,253,279,233,285,212,290,190,291,138,283,93,259,57,223,34,178,25,126,27,100,33,75,43,51,56,30,72,11,28,-39,63,-39,92,-6,110,-17,129,-26,148,-33,169,-37,190,-39,242,-30,288,-6, +127,319,134,319,134,319,142,334,134,319,161,314,142,334,161,314,175,329,175,329,161,314,179,300,175,329,179,300,202,313,202,313,179,300,191,279,202,313,191,279,198,255,112,317,119,318,121,333,121,333,119,318,127,319,121,333,127,319,131,334,131,334,127,319,134,319,131,334,134,319,142,334,93,323,98,313,101,327,101,327,98,313,105,315,101,327,105,315,111,330,111,330,105,315,112,317,111,330,112,317,121,333,152,53,135,30,148,9,148,9,135,30,116,15,148,9,116,15,94,9,94,9,78,13,88,-5,88,-5,78,13,68,21,88,-5,68,21,62,0,62,0,68,21,63,33,62,0,63,33,61,46,61,46,60,59,62,0,62,0,60,59,44,156,44,156,60,59,72,188,72,188,60,59,65,100,20,75,22,51,26,117,26,117,22,51,30,29,26,117,30,29,44,156,44,156,30,29,43,11,44,156,43,11,62,0,159,217,153,203,161,201,159,217,161,201,169,214,169,214,161,201,169,197,169,214,169,197,180,210,180,210,169,197,177,189,180,210,177,189,182,176,79,139,99,172,107,210,107,210,99,172,124,194,107,210,124,194,148,218,148,218,124,194,153,203,148,218,153,203,159,217,72,188,65,100,79,139,72,188,79,139,107,210,182,140,180,131,190,47,190,47,180,131,178,121,190,47,178,121,176,110,176,110,166,80,190,47,190,47,166,80,152,53,190,47,152,53,148,9,198,200,196,194,217,98,217,98,196,194,190,47,190,47,196,194,189,203,190,47,189,203,184,160,184,160,189,203,182,176,190,47,184,160,183,150,190,47,183,150,182,140,94,9,88,-5,148,9,235,204,232,250,231,154,231,154,232,250,220,287,231,154,220,287,217,98,217,98,220,287,202,313,217,98,202,313,200,228,200,228,202,313,198,255,217,98,200,228,200,221,217,98,200,221,199,214,217,98,199,214,199,207,217,98,199,207,198,200,180,210,182,176,189,203, +243,0,243,331,36,331,36,298,210,298,210,182,42,182,42,149,210,149,210,33,36,33,36,0,243,0,243,331,199,331,219,387,190,387,170,331,36,331,36,298,159,298,119,182,42,182,42,149, +42,182,210,149,210,182,210,182,210,149,243,0,210,182,243,0,210,298,210,298,243,0,243,331,210,298,243,331,36,331,243,0,210,149,210,33,243,0,210,33,36,33,243,0,36,33,36,0,210,298,36,331,36,298,210,149,42,182,42,149, +243,0,243,331,199,331,219,387,190,387,170,331,36,331,36,298,159,298,119,182,42,182,42,149,108,149,68,33,36,33,36,0,56,0,36,-60,65,-60,85,0,16383,16383,210,182,148,182,188,298,210,298,16383,16383,210,33,97,33,137,149,210,149,353,291,318,291,289,258,272,270,253,279,233,285,212,290,190,291,138,283,93,259,57,223,34,178,25,126,27,100,33,75,43,51,56,30,72,11,28,-39,63,-39,92,-6,110,-17,129,-26,148,-33,169,-37,190,-39,242,-30,288,-6,324,28,348,74, +36,331,159,298,170,331,170,331,159,298,188,298,170,331,188,298,190,387,190,387,188,298,199,331,190,387,199,331,219,387,159,298,137,149,148,182,148,182,137,149,210,149,148,182,210,149,210,182,210,182,210,149,243,0,210,182,243,0,210,298,210,298,243,0,243,331,210,298,243,331,199,331,159,298,119,182,137,149,137,149,119,182,108,149,137,149,108,149,97,33,97,33,108,149,85,0,97,33,85,0,243,0,68,33,36,33,56,0,68,33,56,0,65,-60,68,33,65,-60,85,0,68,33,85,0,108,149,210,33,97,33,243,0,210,33,243,0,210,149,42,182,42,149,108,149,42,182,108,149,119,182,65,-60,56,0,36,-60,159,298,36,331,36,298,56,0,36,33,36,0,159,298,148,182,188,298,199,331,188,298,210,298, +353,291,318,291,289,258,272,270,253,279,233,285,212,290,190,291,138,283,93,259,57,223,34,178,25,126,27,100,33,75,43,51,56,30,72,11,28,-39,63,-39,92,-6,110,-17,129,-26,148,-33,169,-37,190,-39,242,-30,288,-6,324,28,348,74,356,126,354,152,348,176,338,200,325,221,309,241,16383,16383,287,217,300,201,310,184,317,166,322,147,323,127,316,85,297,48,269,19,232,0,190,-6,174,-5,158,-2,142,2,127,9,113,18,16383,16383,94,36,81,51,71,68,64,86,60,106,58,127,65,168,84,205,112,233,148,252,190,258,208,257,225,254,241,248,256,241,267,233,333,0,185,337,175,337,31,0,16383,16383,272,21,63,21,167,267,334,331,31,331,180,-5,190,-5,16383,16383,302,310,197,64,93,310,313,-12,313,20,167,20,137,24,111,37,89,57,73,82,64,109,313,109,313,142,65,142,74,170,90,195,112,215,138,228,167,233,313,233,313,266,166,266,121,258,84,238,55,207,37,169,30,126,37,83,55,45,84,14,122,-5,167,-12,313,-12,313,20,154,20,148,22,142,23,136,25,179,109,313,109,313,142,195,142,239,233,313,233,313,266,256,266,289,331,257,331,225,266,166,266,121,258,84,238,55,207,37,169,30,126,33,97,42,70, +323,127,316,85,324,28,324,28,316,85,297,48,324,28,297,48,288,-6,288,-6,297,48,269,19,288,-6,269,19,242,-30,242,-30,269,19,232,0,242,-30,232,0,190,-39,190,-39,232,0,190,-6,127,9,129,-26,142,2,142,2,129,-26,148,-33,142,2,148,-33,158,-2,158,-2,148,-33,169,-37,158,-2,169,-37,174,-5,174,-5,169,-37,190,-39,174,-5,190,-39,190,-6,127,9,113,18,129,-26,267,233,113,18,287,217,267,233,287,217,272,270,129,-26,113,18,110,-17,110,-17,113,18,94,36,110,-17,94,36,92,-6,92,-6,94,36,81,51,92,-6,81,51,72,11,72,11,81,51,71,68,72,11,71,68,64,86,58,127,65,168,57,223,58,127,57,223,56,30,58,127,56,30,60,106,60,106,56,30,72,11,60,106,72,11,64,86,27,100,33,75,34,178,34,178,33,75,43,51,34,178,43,51,57,223,57,223,43,51,56,30,267,233,272,270,256,241,256,241,272,270,253,279,256,241,253,279,241,248,241,248,253,279,233,285,241,248,233,285,225,254,225,254,233,285,212,290,225,254,212,290,208,257,208,257,212,290,190,258,148,252,190,258,190,291,148,252,190,291,138,283,65,168,84,205,93,259,93,259,84,205,112,233,93,259,112,233,138,283,138,283,112,233,148,252,212,290,190,291,190,258,318,291,289,258,300,201,318,291,300,201,309,241,318,291,309,241,353,291,289,258,272,270,287,217,289,258,287,217,300,201,63,-39,92,-6,72,11,63,-39,72,11,28,-39,348,176,338,200,348,74,348,176,348,74,356,126,348,176,356,126,354,152,325,221,309,241,310,184,325,221,310,184,317,166,325,221,317,166,322,147,325,221,322,147,323,127,325,221,323,127,324,28,325,221,324,28,348,74,325,221,348,74,338,200,310,184,309,241,300,201,94,36,113,18,267,233,57,223,65,168,93,259,27,100,34,178,25,126, +333,0,185,337,175,337,31,0,16383,16383,272,21,63,21,167,267,334,331,31,331,180,-5,190,-5,16383,16383,302,310,197,64,93,310, +175,337,31,0,63,21,63,21,31,0,333,0,63,21,333,0,272,21,272,21,333,0,185,337,272,21,185,337,175,337,175,337,63,21,167,267,175,337,167,267,272,21, +334,331,31,331,180,-5,190,-5,16383,16383,302,310,197,64,93,310,313,-12,313,20,167,20,137,24,111,37,89,57,73,82,64,109, +334,331,31,331,93,310,334,331,93,310,302,310,334,331,302,310,197,64,334,331,197,64,190,-5,180,-5,190,-5,197,64,180,-5,197,64,93,310,180,-5,93,310,31,331, +313,-12,313,20,167,20,137,24,111,37,89,57,73,82,64,109,313,109,313,142,65,142,74,170,90,195,112,215,138,228,167,233,313,233,313,266,166,266,121,258,84,238,55,207,37,169,30,126,37,83,55,45,84,14,122,-5,167,-12,313,-12,313,20,154,20,148,22,142,23,136,25,179,109,313,109,313,142,195,142,239,233,313,233,313,266,256,266,289,331,257,331,225,266,166,266,121,258,84,238,55,207,37,169,30,126,33,97,42,70,55,45,73,24,96,7,54,-78, +55,45,84,14,64,109,64,109,65,142,55,45,55,45,65,142,55,207,55,45,55,207,37,83,37,83,55,207,37,169,37,83,37,169,30,126,65,142,64,109,313,109,65,142,313,109,313,142,90,195,112,215,121,258,121,258,112,215,138,228,121,258,138,228,166,266,166,266,138,228,167,233,166,266,167,233,313,266,313,266,167,233,313,233,84,238,55,207,65,142,84,238,65,142,74,170,84,238,74,170,90,195,84,238,90,195,121,258,167,-12,313,-12,313,20,167,-12,313,20,167,20,167,-12,167,20,137,24,167,-12,137,24,122,-5,137,24,111,37,122,-5,122,-5,111,37,89,57,122,-5,89,57,84,14,84,14,89,57,73,82,84,14,73,82,64,109, +313,-12,313,20,154,20,148,22,142,23,136,25,179,109,313,109,313,142,195,142,239,233,313,233,313,266,256,266,289,331,257,331,225,266,166,266,121,258,84,238,55,207,37,169,30,126,33,97,42,70,55,45,73,24,96,7,54,-78,84,-78,121,-5,130,-7,139,-10,157,-12,167,-12,16383,16383,209,233,164,142,65,142,74,170,90,195,112,215,138,228,167,233,16383,16383,147,109,112,37,98,49,86,62,76,77,69,93,64,109,211,22,211,55,138,55,116,57,97,64,83,75,72,90,65,109,211,109,211,142,65,142,72,162,82,177,97,188,115,194,137,196,211,196,211,229,137,229,102,224,73,210,51,188,37,159,32,126,37,93,51,65,73,42,102,28,137,22,30,266,30,233,175,233,205,228,231,215,253,195,269,170,278,142,30,142,30,109,278,109,269,82,253,57,232,37,205,24,175,20,30,20,30,-12,175,-12,220,-5,258,14,287,45,306,83, +96,7,96,7,84,-78,96,7,84,-78,121,-5,96,7,121,-5,98,49,96,7,98,49,86,62,96,7,86,62,76,77,96,7,76,77,73,24,55,45,73,24,64,109,64,109,73,24,69,93,69,93,73,24,76,77,161,20,154,20,157,-12,157,-12,154,20,148,22,157,-12,148,22,148,-11,148,-11,148,22,142,23,148,-11,142,23,139,-10,139,-10,142,23,136,25,139,-10,136,25,130,-7,147,109,112,37,121,-5,147,109,121,-5,130,-7,147,109,130,-7,136,25,147,109,136,25,179,109,147,109,179,109,164,142,147,109,164,142,65,142,147,109,65,142,64,109,167,-12,313,-12,313,20,167,-12,313,20,167,20,167,-12,167,20,161,20,167,-12,161,20,157,-12,90,195,112,215,121,258,121,258,112,215,138,228,121,258,138,228,166,266,166,266,138,228,167,233,166,266,167,233,225,266,225,266,167,233,209,233,225,266,209,233,239,233,239,233,209,233,195,142,256,266,289,331,257,331,256,266,257,331,239,233,256,266,239,233,313,233,256,266,313,233,313,266,179,109,313,109,195,142,179,109,195,142,209,233,179,109,209,233,164,142,84,238,55,207,65,142,84,238,65,142,74,170,84,238,74,170,90,195,84,238,90,195,121,258,30,126,33,97,37,169,37,169,33,97,42,70,37,169,42,70,55,207,55,207,42,70,55,45,55,207,55,45,65,142,65,142,55,45,64,109,195,142,313,109,313,142,84,-78,96,7,54,-78,98,49,121,-5,112,37,225,266,239,233,257,331, +211,22,211,55,138,55,116,57,97,64,83,75,72,90,65,109,211,109,211,142,65,142,72,162,82,177,97,188,115,194,137,196,211,196,211,229,137,229,102,224,73,210,51,188,37,159,32,126,37,93,51,65,73,42,102,28,137,22,30,266,30,233,175,233,205,228,231,215,253,195,269,170,278,142,30,142,30,109,278,109,269,82,253,57,232,37,205,24,175,20,30,20,30,-12,175,-12,220,-5,258,14,287,45,306,83,312,126,313,126,306,169,288,207,259,238,222,258, +83,75,72,90,73,42,73,42,72,90,65,109,73,42,65,109,51,188,73,42,51,188,51,65,51,65,51,188,37,159,51,65,37,159,37,93,37,93,37,159,32,126,82,177,97,188,102,224,102,224,97,188,115,194,102,224,115,194,137,229,137,229,115,194,137,196,51,188,65,109,65,142,65,142,65,109,211,142,211,142,65,109,211,109,211,229,137,229,137,196,211,229,137,196,211,196,73,210,51,188,65,142,73,210,65,142,72,162,73,210,72,162,82,177,73,210,82,177,102,224,97,64,102,28,116,57,116,57,102,28,137,22,116,57,137,22,138,55,138,55,137,22,211,22,138,55,211,22,211,55,83,75,73,42,102,28,83,75,102,28,97,64, +30,266,30,233,175,233,205,228,231,215,253,195,269,170,278,142,30,142,30,109,278,109,269,82,253,57,232,37,205,24,175,20,30,20,30,-12,175,-12,220,-5,258,14,287,45,306,83,312,126,313,126,306,169,288,207,259,238,222,258,177,266,289,331,257,331,222,258,213,261,204,263,196,264,186,265,177,266,30,266,30,233,175,233,182,232,188,232,194,231,200,229,206,228,164,142,30,142,30,109,147,109,103,20,30,20,30,-12,86,-12,54,-78,84,-78,117,-12,175,-12,220,-5,258,14, +269,82,253,57,258,14,258,14,253,57,232,37,258,14,232,37,220,-5,220,-5,232,37,205,24,220,-5,205,24,175,20,177,266,30,266,175,233,177,266,175,233,205,228,177,266,205,228,222,258,312,126,306,169,306,83,306,83,306,169,288,207,306,83,288,207,287,45,287,45,288,207,278,109,287,45,278,109,269,82,231,215,253,195,259,238,259,238,253,195,269,170,259,238,269,170,288,207,288,207,269,170,278,142,288,207,278,142,278,109,222,258,205,228,231,215,222,258,231,215,259,238,175,-12,220,-5,175,20,175,-12,175,20,30,20,175,-12,30,20,30,-12,278,109,278,142,30,142,278,109,30,142,30,109,269,82,258,14,287,45,175,233,30,266,30,233, +289,331,257,331,222,258,213,261,204,263,196,264,186,265,177,266,30,266,30,233,175,233,182,232,188,232,194,231,200,229,206,228,164,142,30,142,30,109,147,109,103,20,30,20,30,-12,86,-12,54,-78,84,-78,117,-12,175,-12,220,-5,258,14,287,45,306,83,312,126,313,126,310,155,301,183,287,208,269,229,247,247,16383,16383,195,142,230,214,244,203,256,190,266,175,273,159,278,142,16383,16383,278,109,269,82,253,57,232,37,205,24,175,20,133,20,179,109,32,229,32,196,105,196,128,194,146,188,161,177,171,162,177,142,32,142,32,109,177,109,171,90,161,75,146,64,127,57,105,55,32,55,32,22,107,22,141,28,170,42,192,65,206,93,211,126,206,159,192,188,170,210,140,224,105,229,243,0,243,320,30,320,30,0,474,-128,474,-115,465,-115,447,-112,433,-104,424,-92,418,-74,416,-51,416,307,418,330,423,347,434,359,451,366,474,368,474,382,26,382,26,368,35,368,52,366,66,360,76,349,83,331,85,305, +86,-12,54,-78,84,-78,86,-12,84,-78,117,-12,86,-12,117,-12,103,20,86,-12,103,20,30,20,86,-12,30,20,30,-12,147,109,103,20,117,-12,147,109,117,-12,133,20,147,109,133,20,179,109,147,109,179,109,164,142,147,109,164,142,30,142,147,109,30,142,30,109,269,82,253,57,258,14,258,14,253,57,232,37,258,14,232,37,220,-5,220,-5,232,37,205,24,220,-5,205,24,175,20,195,142,230,214,206,228,206,228,213,261,204,263,206,228,204,263,200,229,200,229,204,263,196,264,200,229,196,264,194,231,194,231,196,264,188,232,30,266,175,233,177,266,177,266,175,233,182,232,177,266,182,232,186,265,186,265,182,232,188,232,186,265,188,232,196,264,257,331,222,258,230,214,257,331,230,214,247,247,257,331,247,247,289,331,230,214,244,203,247,247,247,247,244,203,256,190,247,247,256,190,269,229,269,229,256,190,266,175,269,229,266,175,273,159,213,261,206,228,230,214,213,261,230,214,222,258,273,159,278,142,287,208,278,109,278,142,195,142,278,109,195,142,179,109,179,109,195,142,206,228,179,109,206,228,164,142,312,126,310,155,306,83,306,83,310,155,301,183,306,83,301,183,287,45,287,45,301,183,287,208,287,45,287,208,278,109,278,109,287,208,278,142,269,82,258,14,287,45,269,82,287,45,278,109,175,-12,220,-5,175,20,175,-12,175,20,133,20,175,-12,133,20,117,-12,269,229,273,159,287,208,175,233,30,266,30,233, +32,229,32,196,105,196,128,194,146,188,161,177,171,162,177,142,32,142,32,109,177,109,171,90,161,75,146,64,127,57,105,55,32,55,32,22,107,22,141,28,170,42,192,65,206,93,211,126,206,159,192,188,170,210,140,224,105,229,243,0,243,320,30,320,30,0,474,-128,474,-115,465,-115,447,-112,433,-104,424,-92,418,-74,416,-51,416,307,418,330,423,347,434,359,451,366,474,368,474,382,26,382,26,368,35,368,52,366,66,360,76,349,83,331,85,305,85,-60,83,-80, +105,229,32,229,105,229,105,229,32,229,105,196,105,229,105,196,140,224,140,224,105,196,128,194,140,224,128,194,146,188,192,188,177,142,192,65,192,65,177,142,177,109,192,65,177,109,171,90,32,142,32,109,177,109,32,142,177,109,177,142,146,188,161,177,170,210,170,210,161,177,171,162,170,210,171,162,192,188,192,188,171,162,177,142,206,159,192,188,192,65,206,159,192,65,206,93,206,159,206,93,211,126,170,42,192,65,171,90,170,42,171,90,161,75,170,42,161,75,146,64,170,42,146,64,141,28,127,57,105,55,107,22,127,57,107,22,141,28,127,57,141,28,146,64,32,55,32,22,107,22,32,55,107,22,105,55,105,196,32,229,32,196,140,224,146,188,170,210, +243,0,243,320,30,320,30,0,474,-128,474,-115,465,-115,447,-112, +243,0,243,320,30,320,243,0,30,320,30,0, +474,-128,474,-115,465,-115,447,-112,433,-104,424,-92,418,-74,416,-51,416,307,418,330,423,347,434,359,451,366,474,368,474,382,26,382,26,368,35,368,52,366,66,360,76,349,83,331,85,305,85,-60,83,-80,77,-95,67,-106,54,-112,36,-115,26,-115,26,-128,210,-128,210,-115,195,-115,177,-112,165,-104,157,-91,152,-72,151,-48,151,349,350,349,350,-48,349,-69,344,-88,337,-102,324,-111,306,-115,290,-115,290,-128,474,-128,474,-115,451,-112,434,-106,423,-94,418,-77,416,-54,416,304,418,327,424,345,433,358,447,365,465,368,474,368,474,382,290,382,290,368,306,368,324,364,337,355,344,341,349,322,350,300,350,-96,151,-96,151,300,152,325,157,344,165,357,177,365,195,368,210,368,210,382,26,382,26,368,36,368,54,366,67,359,77,348,83,333,85,313,85,-53,83,-78,76,-96,66,-107,52,-113,35,-115,26,-115,26,-128, +77,-95,67,-106,210,-128,210,-128,67,-106,54,-112,210,-128,54,-112,36,-115,344,-88,337,-102,474,-128,474,-128,337,-102,324,-111,474,-128,324,-111,306,-115,474,382,26,382,35,368,474,382,35,368,52,366,474,382,52,366,66,360,474,382,66,360,76,349,474,382,76,349,151,349,474,382,151,349,350,349,474,382,350,349,434,359,474,382,434,359,451,366,474,382,451,366,474,368,433,-104,424,-92,350,-48,350,-48,424,-92,418,-74,350,-48,418,-74,350,349,350,349,418,-74,416,-51,350,349,416,-51,416,307,350,349,416,307,418,330,350,349,418,330,423,347,350,349,423,347,434,359,165,-104,157,-91,85,-60,85,-60,157,-91,152,-72,85,-60,152,-72,85,305,85,305,152,-72,151,-48,85,305,151,-48,151,349,83,331,85,305,151,349,83,331,151,349,76,349,474,-128,474,-115,465,-115,474,-128,465,-115,447,-112,474,-128,447,-112,433,-104,474,-128,433,-104,349,-69,474,-128,349,-69,344,-88,290,-115,290,-128,474,-128,290,-115,474,-128,306,-115,210,-128,210,-115,195,-115,210,-128,195,-115,177,-112,210,-128,177,-112,83,-80,210,-128,83,-80,77,-95,85,-60,83,-80,177,-112,85,-60,177,-112,165,-104,26,-115,26,-128,210,-128,26,-115,210,-128,36,-115,349,-69,433,-104,350,-48,35,368,26,382,26,368, +474,-128,474,-115,451,-112,434,-106,423,-94,418,-77,416,-54,416,304,418,327,424,345,433,358,447,365,465,368,474,368,474,382,290,382,290,368,306,368,324,364,337,355,344,341,349,322,350,300,350,-96,151,-96,151,300,152,325,157,344,165,357,177,365,195,368,210,368,210,382,26,382,26,368,36,368,54,366,67,359,77,348,83,333,85,313,85,-53,83,-78,76,-96,66,-107,52,-113,35,-115,26,-115,26,-128,428,20,413,20,405,-7,394,-30,379,-48,357,-59,328,-63,121,-63,289,153,144,349,304,349,339,346,364,336,381,318,392,292,400,256,415,256,415,382,41,382,225,126,29,-128,401,-128,310,110,310,143,32,143,32,110,319,218,319,251,24,251,24,218,16383,16383,319,54,319,86,188,86,188,191,155,191,155,86,24,86,24,54,155,54,155,-43,188,-43,188,54,203,339,201,349,196,358,189,365,180,369,171,371, +76,-96,66,-107,474,-128,474,-128,66,-107,52,-113,474,-128,52,-113,35,-115,77,348,83,333,210,382,210,382,83,333,177,365,210,382,177,365,195,368,210,382,195,368,210,368,85,313,85,-53,151,-96,85,313,151,-96,151,300,85,313,151,300,152,325,85,313,152,325,157,344,85,313,157,344,165,357,85,313,165,357,177,365,85,313,177,365,83,333,210,382,26,382,36,368,210,382,36,368,54,366,210,382,54,366,67,359,210,382,67,359,77,348,434,-106,423,-94,350,-96,350,-96,423,-94,418,-77,350,-96,418,-77,350,300,349,322,350,300,433,358,349,322,433,358,474,382,474,382,433,358,447,365,474,382,447,365,465,368,474,382,465,368,474,368,416,-54,416,304,350,300,350,300,416,304,418,327,350,300,418,327,424,345,474,382,290,382,306,368,474,382,306,368,324,364,474,382,324,364,337,355,474,382,337,355,344,341,474,382,344,341,349,322,474,-128,474,-115,451,-112,474,-128,451,-112,434,-106,474,-128,434,-106,350,-96,474,-128,350,-96,151,-96,474,-128,151,-96,76,-96,83,-78,76,-96,151,-96,83,-78,151,-96,85,-53,26,-115,26,-128,474,-128,26,-115,474,-128,35,-115,350,300,418,-77,416,-54,306,368,290,382,290,368,433,358,350,300,424,345,36,368,26,382,26,368, +428,20,413,20,405,-7,394,-30,379,-48,357,-59,328,-63,121,-63,289,153,144,349,304,349,339,346,364,336,381,318,392,292,400,256,415,256,415,382,41,382,225,126,29,-128,401,-128,310,110,310,143,32,143,32,110,319,218,319,251,24,251,24,218,16383,16383,319,54,319,86,188,86,188,191,155,191,155,86,24,86,24,54,155,54,155,-43,188,-43,188,54,203,339, +415,382,41,382,144,349,415,382,144,349,304,349,415,382,304,349,339,346,415,382,339,346,364,336,415,382,364,336,381,318,415,382,381,318,392,292,415,382,392,292,400,256,415,382,400,256,415,256,225,126,29,-128,121,-63,225,126,121,-63,289,153,225,126,289,153,144,349,225,126,144,349,41,382,394,-30,379,-48,401,-128,401,-128,379,-48,357,-59,401,-128,357,-59,328,-63,405,-7,394,-30,401,-128,405,-7,401,-128,428,20,405,-7,428,20,413,20,121,-63,29,-128,401,-128,121,-63,401,-128,328,-63, +310,110,310,143,32,143,32,110,319,218,319,251,24,251,24,218, +310,110,310,143,32,143,310,110,32,143,32,110, +319,218,319,251,24,251,24,218,16383,16383,319,54,319,86,188,86,188,191,155,191,155,86,24,86,24,54,155,54,155,-43,188,-43,188,54,203,339,201,349,196,358,189,365,180,369,171,371,161,369,153,365,146,358,141,350,139,339,140,328,145,319,151,313,160,308,171,307,181,309, +24,251,24,218,319,218,24,251,319,218,319,251,188,191,155,191,188,-43,188,-43,155,191,155,86,188,-43,155,86,155,54,155,54,155,86,24,86,155,54,24,86,24,54,188,54,319,54,188,86,188,86,319,54,319,86,188,-43,155,54,155,-43, +203,339,201,349,196,358,189,365,180,369,171,371,161,369,153,365,146,358,141,350,139,339,140,328,145,319,151,313,160,308,171,307,181,309,190,313,197,320,201,329,203,339,16383,16383,318,110,318,143,188,143,188,273,155,273,155,143,24,143,24,110,155,110,155,-20,188,-20,188,110,239,355,203,355,23,-110,59,-110,201,46,44,205,12,205,171,46,228,169,227,175,225,181,221,185,216,189,210,190,208,190,206,189,204,189,202,188,200,186,191,180,182,170,170,158,156,145,137,133,138,153,142,172,146,190,150,204,151,215,150,222,147,227,143,231,138,234,132,235, +171,371,171,307,180,369,180,369,171,307,181,309,180,369,181,309,189,365,189,365,181,309,190,313,189,365,190,313,196,358,196,358,190,313,197,320,196,358,197,320,201,349,201,349,197,320,201,329,201,349,201,329,203,339,139,339,140,328,141,350,141,350,140,328,145,319,141,350,145,319,146,358,146,358,145,319,151,313,146,358,151,313,153,365,153,365,151,313,160,308,153,365,160,308,161,369,161,369,160,308,171,307,161,369,171,307,171,371,188,273,155,273,188,-20,188,-20,155,273,155,143,188,-20,155,143,155,110,155,110,155,143,24,143,155,110,24,143,24,110,188,110,318,110,188,143,188,143,318,110,318,143,188,-20,155,110,155,-20, +239,355,203,355,23,-110,59,-110,201,46,44,205,12,205,171,46, +239,355,203,355,23,-110,239,355,23,-110,59,-110, +201,46,44,205,12,205,171,46,228,169,227,175,225,181,221,185, +201,46,44,205,12,205,201,46,12,205,171,46, +228,169,227,175,225,181,221,185,216,189,210,190,208,190,206,189,204,189,202,188,200,186,191,180,182,170,170,158,156,145,137,133,138,153,142,172,146,190,150,204,151,215,150,222,147,227,143,231,138,234,132,235,127,234,121,231,117,227,114,222,113,215,114,204,118,189,122,172,126,153,127,132,111,143,96,155,72,179,62,186,63,186,60,188,58,189,56,189,54,190,51,190,45,189,40,185,37,181,34,175,33,169,34,165,35,162,37,159,40,156,44,153,55,149,70,144,87,139,105,133,122,125,105,117,88,111,71,106,56,102,46,98,42,95,39,91,37,87,36,82,35,78,36,73,38,69,42,65,47,63,54,62,56,62,59,63,61,64,67,66,75,72,85,83,98,95,112,108,127,118,126,98,122,80,118,63,114,49,113,37,114,31,117,26,121,21,127,18,132,17,138,18,143,21,147,26,150,31,151,37,150,49,146,63,142,80,138,98,137,118,157,104,173,89,185,75,196,65,208,61,215,62,220,65,224,70,227,75,228,81,227,85,226,88,224,91,221,95,217,97,207,101,193,105,177,109,159,116,140,125,161,135,179,142,195,146,208,149,218,153,221,155,224,158,226,162,228,165,228,169,155,126,152,147,142,166,128,180,110,190,89,194,67,190,48,181,33,167,24,148,20,127,23,105,33,86,47,72,66,62,88,59,109,62,128,72,142,86,152,105,155,126,16383,16383,122,126,120,115,116,105,108,98,99,93,88,92,77,93,67,98,60,106,55,115,53,127,55,138,59,147,67,154,77,159,89,161,99,159,108,154,116,147,120,137,122,126,155,126,152,147,142,166,128,180,110,190,89,194,67,190,48,181,33,167,24,148,20,127,23,105,33,86,47,72,66,62,88,59,109,62,128,72,142,86,152,105,155,126,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,149,381,156,391,162,399,169,404,177,407,185,408,195,407,202,404,208,399,212,392,213,382,211,369,204,359,195,351,183,345,171,340,171,335,184,335,189,334,193,333,196,333,206,328,213,323,219,315,222,306,223,296,222,284,217,274,210,266,201,261,190,259,186,260,182,260,178,262,173,264,168,267,164,270,161,272,152,275,146,273,144,271,142,268,142,265,143,260,146,255,152,251,160,249,171,248,193,250,214,257,231,269,242,286, +146,63,142,80,143,21,143,21,142,80,138,98,143,21,138,98,138,18,138,18,138,98,137,118,137,133,138,234,132,17,132,17,138,234,132,235,132,17,132,235,127,118,127,118,132,235,127,132,127,118,127,132,122,125,122,125,127,132,111,143,138,153,142,172,143,231,143,231,142,172,146,190,143,231,146,190,147,227,147,227,146,190,150,204,147,227,150,204,150,222,150,222,150,204,151,215,138,234,137,133,138,153,138,234,138,153,143,231,127,118,126,98,127,18,127,118,127,18,132,17,113,37,114,31,114,49,114,49,114,31,117,26,114,49,117,26,118,63,118,63,117,26,121,21,118,63,121,21,122,80,122,80,121,21,127,18,122,80,127,18,126,98,137,118,157,104,140,125,140,125,157,104,159,116,159,116,157,104,173,89,159,116,173,89,177,109,177,109,173,89,185,75,177,109,185,75,193,105,193,105,185,75,196,65,193,105,196,65,207,101,207,101,196,65,208,61,207,101,208,61,217,97,217,97,208,61,215,62,217,97,215,62,220,65,221,155,224,158,225,181,225,181,224,158,226,162,225,181,226,162,227,175,227,175,226,162,228,165,227,175,228,165,228,169,221,185,216,189,218,153,221,185,218,153,221,155,221,185,221,155,225,181,216,189,210,190,218,153,218,153,210,190,208,190,218,153,208,190,208,149,208,149,208,190,206,189,208,149,206,189,204,189,204,189,202,188,208,149,208,149,202,188,200,186,208,149,200,186,195,146,195,146,200,186,191,180,195,146,191,180,182,170,156,145,140,125,161,135,156,145,161,135,170,158,170,158,161,135,179,142,170,158,179,142,182,170,182,170,179,142,195,146,137,133,137,118,140,125,137,133,140,125,156,145,137,118,137,133,132,17,137,118,132,17,138,18,228,81,227,85,227,75,227,75,227,85,226,88,227,75,226,88,224,70,224,70,226,88,224,91,224,70,224,91,221,95,221,95,217,97,220,65,221,95,220,65,224,70,150,49,146,63,147,26,150,49,147,26,150,31,150,49,150,31,151,37,127,132,132,235,127,234,127,132,127,234,126,153,126,153,127,234,122,172,122,172,127,234,121,231,122,172,121,231,118,189,118,189,121,231,117,227,118,189,117,227,114,204,114,204,117,227,114,222,114,204,114,222,113,215,75,72,85,83,88,111,88,111,85,83,98,95,88,111,98,95,105,117,105,117,98,95,112,108,105,117,112,108,122,125,122,125,112,108,127,118,71,106,56,102,59,63,71,106,59,63,61,64,71,106,61,64,64,65,71,106,64,65,67,66,71,106,67,66,75,72,71,106,75,72,88,111,56,102,46,98,47,63,56,102,47,63,54,62,56,102,54,62,56,62,56,102,56,62,59,63,42,65,47,63,46,98,42,65,46,98,42,95,42,65,42,95,39,91,42,65,39,91,38,69,37,87,36,82,36,73,37,87,36,73,38,69,37,87,38,69,39,91,122,125,111,143,105,133,105,133,111,143,96,155,105,133,96,155,87,139,87,139,96,155,83,168,87,139,83,168,72,179,70,144,87,139,72,179,70,144,72,179,62,186,70,144,62,186,60,188,70,144,60,188,58,189,70,144,58,189,56,189,70,144,56,189,55,149,55,149,56,189,54,190,55,149,54,190,51,190,55,149,51,190,45,189,55,149,45,189,44,153,40,185,37,181,37,159,40,185,37,159,40,156,40,185,40,156,44,153,40,185,44,153,45,189,33,169,34,165,34,175,34,175,34,165,35,162,34,175,35,162,37,181,37,181,35,162,37,159,36,73,36,82,35,78,146,63,143,21,147,26, +155,126,152,147,142,166,128,180,110,190,89,194,67,190,48,181,33,167,24,148,20,127,23,105,33,86,47,72,66,62,88,59,109,62,128,72,142,86,152,105,155,126,16383,16383,122,126,120,115,116,105,108,98,99,93,88,92,77,93,67,98,60,106,55,115,53,127,55,138,59,147,67,154,77,159,89,161,99,159,108,154,116,147,120,137,122,126,155,126,152,147,142,166,128,180,110,190,89,194,67,190,48,181,33,167,24,148,20,127,23,105,33,86,47,72,66,62,88,59,109,62,128,72,142,86,152,105,155,126,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,149,381,156,391,162,399, +60,106,66,62,67,98,67,98,66,62,88,59,67,98,88,59,77,93,77,93,88,59,88,92,99,93,88,92,88,59,99,93,88,59,109,62,55,138,59,147,67,190,67,190,59,147,67,154,67,190,67,154,89,194,89,194,67,154,77,159,89,194,77,159,89,161,89,161,99,159,110,190,110,190,99,159,108,154,110,190,108,154,116,147,20,127,23,105,24,148,24,148,23,105,33,86,24,148,33,86,33,167,33,167,33,86,47,72,33,167,47,72,48,181,48,181,47,72,53,127,55,138,67,190,48,181,55,138,48,181,53,127,155,126,152,147,152,105,152,105,152,147,142,166,152,105,142,166,142,86,142,86,142,166,128,180,142,86,128,180,128,72,128,72,128,180,122,126,128,72,122,126,120,115,128,72,120,115,116,105,128,180,110,190,116,147,128,180,116,147,120,137,128,180,120,137,122,126,110,190,89,194,89,161,109,62,128,72,116,105,109,62,116,105,108,98,109,62,108,98,99,93,55,115,53,127,47,72,55,115,47,72,66,62,55,115,66,62,60,106, +155,126,152,147,142,166,128,180,110,190,89,194,67,190,48,181,33,167,24,148,20,127,23,105,33,86,47,72,66,62,88,59,109,62,128,72,142,86,152,105,155,126,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,149,381,156,391, +20,127,23,105,24,148,24,148,23,105,33,86,24,148,33,86,33,167,33,167,33,86,47,72,33,167,47,72,48,181,48,181,47,72,66,62,48,181,66,62,67,190,67,190,66,62,88,59,67,190,88,59,89,194,89,194,88,59,109,62,89,194,109,62,110,190,110,190,109,62,128,72,110,190,128,72,128,180,128,180,128,72,142,86,128,180,142,86,142,166,142,166,142,86,152,105,142,166,152,105,152,147,152,147,152,105,155,126, +482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,149,381,156,391,162,399,169,404,177,407,185,408,195,407,202,404,208,399,212,392,213,382,211,369,204,359,195,351,183,345,171,340,171,335,184,335,189,334, +76,159,83,163,134,222,134,222,83,163,89,165,134,222,89,165,94,165,94,165,102,164,134,222,134,222,102,164,108,161,134,222,108,161,114,155,143,222,134,222,227,-128,227,-128,134,222,126,136,120,147,126,136,134,222,120,147,134,222,114,155,134,222,56,160,62,150,134,222,62,150,69,155,134,222,69,155,76,159,143,222,227,-128,246,-45,246,-45,227,-128,243,-128,246,-45,243,-128,248,-45,248,-45,243,-128,482,487,248,-45,482,487,454,487, +149,381,156,391,162,399,169,404,177,407,185,408,195,407,202,404,208,399,212,392,213,382,211,369,204,359,195,351,183,345,171,340,171,335,184,335,189,334,193,333,196,333,206,328,213,323,219,315,222,306,223,296,222,284,217,274,210,266,201,261,190,259,186,260,182,260,178,262,173,264,168,267,164,270,161,272,152,275,146,273,144,271,142,268,142,265,143,260,146,255,152,251,160,249,171,248,193,250,214,257,231,269,242,286,247,307,245,320,240,331,233,340,223,347,210,352,218,358,224,365,229,373,232,381,233,388,231,400,226,410,218,417,206,421,193,423,178,421,166,416,156,407,149,396,143,382,16383,16383,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,252,291,252,312,225,312,225,421,210,421,131,312,131,291,201,291,201,249,225,249,225,291,16383,16383,201,312,142,312,201,395,16383,16383,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,321,42,304,45,287,54,270,70,253,92,235,121,235,123,245,137,258,150,275,162,296,170,321,173,321,215,294,211,272,201,254,185,239,165,225,142,199,174,177,195,156,207,137,213,116,215,95,212,70,201,46,180,28,147,21,100,26,63,39,35,59,15,83,4,108,0,135,3,159,12,180,27,198,47,213,73,232,47,250,27,271,12,294,3,321,0,16383,16383,202,90,193,78,180,66,164,54,144,45,120,42,96,47,76,59,62,78,53,101,50,126,53,144,60,161,71,174, +158,273,160,249,161,272,161,272,160,249,171,248,161,272,171,248,164,270,164,270,171,248,168,267,173,264,168,267,171,248,173,264,171,248,193,250,149,381,156,391,156,407,156,407,156,391,162,399,156,407,162,399,166,416,166,416,162,399,169,404,166,416,169,404,178,421,178,421,169,404,177,407,178,421,177,407,185,408,185,408,195,407,193,423,193,423,195,407,206,421,149,396,143,382,149,381,149,396,149,381,156,407,184,335,189,334,195,351,195,351,189,334,193,333,195,351,193,333,196,333,196,333,206,328,204,359,204,359,206,328,211,369,183,345,171,340,178,335,183,345,178,335,184,335,183,345,184,335,195,351,204,359,195,351,196,333,210,352,218,358,211,369,211,369,218,358,213,382,218,417,213,382,218,358,218,417,218,358,226,410,226,410,218,358,224,365,226,410,224,365,229,373,195,407,202,404,206,421,206,421,202,404,208,399,206,421,208,399,218,417,218,417,208,399,212,392,218,417,212,392,213,382,231,400,226,410,229,373,231,400,229,373,232,381,231,400,232,381,233,388,210,352,211,369,206,328,210,352,206,328,213,323,210,352,213,323,223,347,242,286,247,307,245,320,242,286,245,320,240,331,242,286,240,331,233,340,242,286,233,340,231,269,223,296,231,269,233,340,223,296,233,340,223,347,223,347,213,323,219,315,223,347,219,315,222,306,223,347,222,306,223,296,210,266,214,257,217,274,217,274,214,257,231,269,217,274,231,269,222,284,222,284,231,269,223,296,190,259,193,250,201,261,201,261,193,250,214,257,201,261,214,257,210,266,193,423,178,421,185,408,186,260,182,260,193,250,186,260,193,250,190,259,178,262,173,264,193,250,178,262,193,250,182,260,155,274,152,275,152,251,155,274,152,251,160,249,155,274,160,249,158,273,149,274,146,273,146,255,149,274,146,255,152,251,149,274,152,251,152,275,144,271,142,268,143,260,144,271,143,260,146,255,144,271,146,255,146,273,76,159,83,163,134,222,134,222,83,163,89,165,134,222,89,165,94,165,94,165,102,164,134,222,134,222,102,164,108,161,134,222,108,161,114,155,143,222,134,222,227,-128,227,-128,134,222,126,136,120,147,126,136,134,222,120,147,134,222,114,155,134,222,56,160,62,150,134,222,62,150,69,155,134,222,69,155,76,159,143,222,227,-128,246,-45,246,-45,227,-128,243,-128,246,-45,243,-128,248,-45,248,-45,243,-128,482,487,248,-45,482,487,454,487,143,260,142,268,142,265,178,335,171,340,171,335, +252,291,252,312,225,312,225,421,210,421,131,312,131,291,201,291,201,249,225,249,225,291,16383,16383,201,312,142,312,201,395,16383,16383,482,487,454,487,248,-45,246,-45,143,222,134,222,56,160,62,150,69,155,83,163,89,165,94,165,102,164,108,161,114,155,120,147,126,136,227,-128,243,-128,321,42,304,45,287,54,270,70,253,92,235,121,235,123,245,137,258,150,275,162,296,170,321,173,321,215,294,211,272,201,254,185,239,165,225,142,199,174,177,195,156,207,137,213,116,215,95,212,70,201,46,180,28,147,21,100,26,63,39,35,59,15,83,4,108,0,135,3,159,12, +131,291,201,291,131,312,131,312,201,291,142,312,131,312,142,312,210,421,210,421,142,312,201,395,210,421,201,395,225,249,225,249,201,395,201,312,225,249,201,312,201,291,201,291,201,312,142,312,210,421,225,249,225,421,225,312,225,291,252,291,225,312,252,291,252,312,76,159,83,163,134,222,134,222,83,163,89,165,134,222,89,165,94,165,94,165,102,164,134,222,134,222,102,164,108,161,134,222,108,161,114,155,143,222,134,222,227,-128,227,-128,134,222,126,136,120,147,126,136,134,222,120,147,134,222,114,155,134,222,56,160,62,150,134,222,62,150,69,155,134,222,69,155,76,159,143,222,227,-128,246,-45,246,-45,227,-128,243,-128,246,-45,243,-128,248,-45,248,-45,243,-128,482,487,248,-45,482,487,454,487,225,249,201,291,201,249, +321,42,304,45,287,54,270,70,253,92,235,121,235,123,245,137,258,150,275,162,296,170,321,173,321,215,294,211,272,201,254,185,239,165,225,142,199,174,177,195,156,207,137,213,116,215,95,212,70,201,46,180,28,147,21,100,26,63,39,35,59,15,83,4,108,0,135,3,159,12,180,27,198,47,213,73,232,47,250,27,271,12,294,3,321,0,16383,16383,202,90,193,78,180,66,164,54,144,45,120,42,96,47,76,59,62,78,53,101,50,126,53,144,60,161,71,174,85,182,100,185,121,181,140,169,160,150,181,124,202,92,427,111,422,148,408,177,387,198,363,210,336,215,309,211,287,201,269,185,253,165,239,142,213,174,191,195,171,207,151,213,131,215,110,212,84,201,60,180,42,147,35,100,40,63,54,35,73,15,97,4,123,0,150,3,174,12,195,27,213,47,228,73,246,47,264,27,284,12,305,3,328,0,363,7,390,25,410,51,423,81,427,111,16383,16383,249,123,259,136,270,149,285,161,304,170,328,173,352,169,371,157,385,138,394,115,397,89,394,70,387,54,377,41,363,33,347,30,327,33,308,45,290,63,270,89,249,121,16383,16383,217,90, +213,73,232,47,213,73,213,73,232,47,225,142,213,73,225,142,202,92,202,92,199,174,181,124,181,124,199,174,177,195,181,124,177,195,160,150,160,150,177,195,156,207,160,150,156,207,140,169,140,169,156,207,137,213,140,169,137,213,121,181,121,181,137,213,116,215,121,181,116,215,100,185,53,144,60,161,70,201,70,201,60,161,71,174,70,201,71,174,95,212,95,212,71,174,85,182,95,212,85,182,100,185,21,100,26,63,28,147,28,147,26,63,39,35,28,147,39,35,46,180,46,180,39,35,59,15,46,180,59,15,50,126,50,126,53,144,46,180,46,180,53,144,70,201,202,90,193,78,198,47,198,47,193,78,180,66,198,47,180,66,180,27,180,27,180,66,164,54,180,27,164,54,159,12,159,12,164,54,144,45,159,12,144,45,135,3,135,3,144,45,120,42,135,3,120,42,108,0,108,0,120,42,96,47,108,0,96,47,83,4,83,4,96,47,76,59,83,4,76,59,62,78,59,15,83,4,62,78,59,15,62,78,53,101,59,15,53,101,50,126,287,54,270,70,271,12,271,12,270,70,253,92,271,12,253,92,250,27,250,27,253,92,235,121,250,27,235,121,232,47,321,173,321,215,296,170,296,170,321,215,294,211,296,170,294,211,275,162,275,162,294,211,272,201,275,162,272,201,258,150,258,150,272,201,254,185,258,150,254,185,245,137,245,137,254,185,239,165,245,137,239,165,235,123,235,123,239,165,225,142,235,123,225,142,232,47,235,123,232,47,235,121,304,45,287,54,294,3,304,45,294,3,321,0,304,45,321,0,321,42,199,174,202,92,225,142,213,73,202,92,202,90,213,73,202,90,198,47,100,185,116,215,95,212,287,54,271,12,294,3, +427,111,422,148,408,177,387,198,363,210,336,215,309,211,287,201,269,185,253,165,239,142,213,174,191,195,171,207,151,213,131,215,110,212,84,201,60,180,42,147,35,100,40,63,54,35,73,15,97,4,123,0,150,3,174,12,195,27,213,47,228,73,246,47,264,27,284,12,305,3,328,0,363,7,390,25,410,51,423,81,427,111,16383,16383,249,123,259,136,270,149,285,161,304,170,328,173,352,169,371,157,385,138,394,115,397,89,394,70,387,54,377,41,363,33,347,30,327,33,308,45,290,63,270,89,249,121,16383,16383,217,90,207,78,195,66,179,54,159,45,134,42,110,47,91,59,77,78,68,101,65,126,67,144,74,161,85,174,99,182,115,185,135,181,155,169,175,150,195,124,217,92,317,0,317,33,58,33,58,292,25,292,25,0,321,0,321,33,91,33,310,252,285,273,12,0,321,0,321,33,271,33,265,61,257,88,247,113,233,138,218,160,310,252,284,273,196,185,186,195,174,205,169,209,148,182,168,166,172,161,11,0,239,0,239,-18,238,-24,238,-30,270,-35,272,-21,272,0,16383,16383,90,33,194,137,207,118,217,98,226,77,233,56,237,33,326,40,281,59,284,72,286,86,288,99,290,127,289,140,288,154,286,168,280,196,326,216,314,246,269,228,266,234,263,241,257,253,253,259,225,243,228,237,231,232,233,226,236,220,238,215,28,127,239,40,237,34,234,29,232,23,229,17,225,12,254,-5,258,1,261,8,265,14,268,21,270,27,314,9,16383,16383,114,127,249,184, +228,73,246,47,228,73,228,73,246,47,239,142,228,73,239,142,217,92,217,92,213,174,195,124,195,124,213,174,191,195,195,124,191,195,175,150,175,150,191,195,171,207,175,150,171,207,155,169,155,169,171,207,151,213,155,169,151,213,135,181,135,181,151,213,131,215,135,181,131,215,115,185,67,144,74,161,84,201,84,201,74,161,85,174,84,201,85,174,110,212,110,212,85,174,99,182,110,212,99,182,115,185,35,100,40,63,42,147,42,147,40,63,54,35,42,147,54,35,60,180,60,180,54,35,73,15,60,180,73,15,65,126,65,126,67,144,60,180,60,180,67,144,84,201,217,90,207,78,213,47,213,47,207,78,195,66,213,47,195,66,195,27,195,27,195,66,179,54,195,27,179,54,174,12,174,12,179,54,159,45,174,12,159,45,150,3,150,3,159,45,134,42,150,3,134,42,123,0,123,0,134,42,110,47,123,0,110,47,97,4,97,4,110,47,91,59,97,4,91,59,77,78,73,15,97,4,77,78,73,15,77,78,68,101,73,15,68,101,65,126,336,215,328,173,352,169,336,215,352,169,363,210,363,210,352,169,371,157,363,210,371,157,387,198,387,198,371,157,385,138,387,198,385,138,394,115,270,149,285,161,287,201,287,201,285,161,304,170,287,201,304,170,309,211,309,211,304,170,328,173,309,211,328,173,336,215,239,142,249,123,253,165,253,165,249,123,259,136,253,165,259,136,269,185,269,185,259,136,270,149,269,185,270,149,287,201,264,27,249,121,246,47,246,47,249,121,249,123,246,47,249,123,239,142,249,121,264,27,270,89,270,89,264,27,284,12,270,89,284,12,290,63,290,63,284,12,305,3,290,63,305,3,308,45,308,45,305,3,328,0,308,45,328,0,327,33,327,33,328,0,347,30,363,33,347,30,363,7,363,33,363,7,390,25,387,198,394,115,408,177,408,177,394,115,397,89,410,51,397,89,394,70,410,51,394,70,390,25,390,25,394,70,387,54,390,25,387,54,377,41,422,148,408,177,410,51,422,148,410,51,423,81,422,148,423,81,427,111,347,30,328,0,363,7,213,174,217,92,239,142,228,73,217,92,217,90,228,73,217,90,213,47,115,185,131,215,110,212,363,33,390,25,377,41,397,89,410,51,408,177, +317,0,317,33,58,33,58,292,25,292,25,0,321,0,321,33,91,33,310,252,285,273,12,0, +58,33,58,292,25,292,58,33,25,292,25,0,58,33,25,0,317,0,58,33,317,0,317,33, +321,0,321,33,91,33,310,252,285,273,12,0,321,0,321,33,271,33,265,61,257,88,247,113, +91,33,310,252,285,273,91,33,285,273,12,0,91,33,12,0,321,0,91,33,321,0,321,33, +321,0,321,33,271,33,265,61,257,88,247,113,233,138,218,160,310,252,284,273,196,185,186,195,174,205,169,209,148,182,168,166,172,161,11,0,239,0,239,-18,238,-24,238,-30,270,-35,272,-21,272,0,16383,16383,90,33,194,137,207,118,217,98,226,77,233,56,237,33,326,40,281,59,284,72,286,86,288,99,290,127,289,140,288,154,286,168,280,196,326,216,314,246,269,228,266,234,263,241,257,253,253,259,225,243,228,237,231,232,233,226,236,220,238,215,28,127,239,40,237,34,234,29,232,23,229,17,225,12,254,-5,258,1,261,8, +90,33,194,137,172,161,172,161,174,205,169,209,172,161,169,209,168,166,168,166,169,209,163,170,169,209,148,182,153,178,169,209,153,178,158,174,169,209,158,174,163,170,194,137,207,118,196,185,196,185,207,118,218,160,196,185,218,160,284,273,284,273,218,160,310,252,207,118,217,98,218,160,218,160,217,98,226,77,218,160,226,77,233,138,233,138,226,77,233,56,233,138,233,56,237,33,194,137,196,185,191,190,194,137,191,190,186,195,194,137,186,195,180,200,194,137,180,200,174,205,194,137,174,205,172,161,233,138,237,33,247,113,239,0,237,33,90,33,239,0,90,33,11,0,11,0,90,33,172,161,265,61,257,88,270,-35,270,-35,257,88,247,113,270,-35,247,113,239,0,239,0,247,113,237,33,272,0,321,0,321,33,272,0,321,33,271,33,272,0,271,33,271,-28,272,0,271,-28,272,-21,272,0,272,-21,272,-14,272,0,272,-14,272,-6,271,33,265,61,270,-35,271,33,270,-35,271,-28,270,-35,239,0,239,-5,270,-35,239,-5,239,-12,270,-35,239,-12,239,-18,270,-35,239,-18,238,-24,270,-35,238,-24,238,-30, +326,40,281,59,284,72,286,86,288,99,290,127,289,140,288,154,286,168,280,196,326,216,314,246,269,228,266,234,263,241,257,253,253,259,225,243,228,237,231,232,233,226,236,220,238,215,28,127,239,40,237,34,234,29,232,23,229,17,225,12,254,-5,258,1,261,8,265,14,268,21,270,27,314,9,16383,16383,114,127,249,184,252,172,254,161,255,149,257,127,256,115,254,93,252,82,249,71,83,-93,83,345,50,345,50,-93,190,152,179,178,118,147,118,345,84,345,84,130,12,93,23,66,84,98,84,-93,118,-93,118,114,197,-93,197,345,164,345,164,-93,16383,16383,98,-93,98,345,65,345,65,-93,293,181,281,207,219,175,219,345,185,345,185,158,119,125,119,345,86,345,86,108,12,70,23,44,86,75,86,-93,119,-93,119,93,185,126,185,-93,219,-93,219,143,295,-14,157,268,152,268, +256,115,258,1,257,127,257,127,258,1,260,247,260,247,258,1,261,8,260,247,261,8,263,241,263,241,261,8,265,14,263,241,265,14,266,234,266,234,265,14,268,21,266,234,268,21,269,228,269,228,268,21,270,27,269,228,270,27,280,196,280,196,270,27,281,59,280,196,281,59,283,182,283,182,281,59,284,72,283,182,284,72,286,168,286,168,284,72,286,86,286,168,286,86,288,154,288,154,286,86,288,99,288,154,288,99,289,140,289,140,288,99,289,113,289,140,289,113,290,127,314,9,326,40,281,59,314,9,281,59,270,27,314,246,269,228,280,196,314,246,280,196,326,216,255,149,256,138,257,253,257,253,256,138,257,127,257,253,257,127,260,247,249,184,252,172,253,259,253,259,252,172,254,161,253,259,254,161,257,253,257,253,254,161,255,149,253,259,225,243,228,237,253,259,228,237,231,232,253,259,231,232,233,226,253,259,233,226,236,220,253,259,236,220,238,215,253,259,238,215,249,184,255,104,254,93,254,-5,255,104,254,-5,258,1,255,104,258,1,256,115,254,-5,254,93,252,82,254,-5,252,82,249,71,254,-5,249,71,239,40,254,-5,239,40,237,34,254,-5,237,34,234,29,254,-5,234,29,232,23,254,-5,232,23,229,17,254,-5,229,17,225,12,238,215,28,127,114,127,114,127,28,127,239,40,114,127,239,40,249,71,238,215,114,127,249,184, +83,-93,83,345,50,345,50,-93,190,152,179,178,118,147,118,345, +83,-93,83,345,50,345,83,-93,50,345,50,-93, +190,152,179,178,118,147,118,345,84,345,84,130,12,93,23,66,84,98,84,-93,118,-93,118,114,197,-93,197,345,164,345,164,-93,16383,16383,98,-93,98,345,65,345,65,-93,293,181,281,207,219,175, +84,130,12,93,23,66,84,130,23,66,84,98,84,130,84,98,118,-93,84,130,118,-93,84,345,84,345,118,-93,118,345,118,147,118,114,190,152,118,147,190,152,179,178,118,-93,84,98,84,-93, +197,-93,197,345,164,345,164,-93,16383,16383,98,-93,98,345,65,345,65,-93,293,181,281,207,219,175,219,345,185,345,185,158,119,125,119,345,86,345, +164,345,164,-93,197,-93,164,345,197,-93,197,345,65,345,65,-93,98,-93,65,345,98,-93,98,345, +293,181,281,207,219,175,219,345,185,345,185,158,119,125,119,345,86,345,86,108,12,70,23,44,86,75,86,-93,119,-93,119,93,185,126,185,-93,219,-93,219,143,295,-14,157,268,152,268,16,-14,47,-14,155,201,262,-14,295,268,263,268,156,52,48,268,16,268,153,-14,158,-14,286,-15,286,132,280,177,261,215,233,243,197,261, +86,108,12,70,23,44,86,108,23,44,86,75,86,108,86,75,119,-93,86,108,119,-93,86,345,219,345,185,345,219,-93,219,-93,185,345,185,158,219,-93,185,158,185,126,185,126,185,158,119,125,185,126,119,125,119,93,119,-93,119,345,86,345,219,143,293,181,219,175,219,175,293,181,281,207,219,-93,185,126,185,-93,119,-93,86,75,86,-93, +295,-14,157,268,152,268,16,-14,47,-14,155,201,262,-14,295,268,263,268,156,52,48,268,16,268,153,-14,158,-14, +16,-14,47,-14,152,268,152,268,47,-14,155,201,152,268,155,201,157,268,157,268,155,201,262,-14,157,268,262,-14,295,-14, +295,268,263,268,156,52,48,268,16,268,153,-14,158,-14,286,-15,286,132,280,177,261,215,233,243,197,261,155,268, +295,268,263,268,158,-14,158,-14,263,268,156,52,158,-14,156,52,153,-14,153,-14,156,52,48,268,153,-14,48,268,16,268, +286,-15,286,132,280,177,261,215,233,243,197,261,155,268,113,262,77,244,49,216,30,178,24,134,24,-15,57,-15,57,132,62,165,76,193,97,215,124,230,155,235,186,230,212,215,234,193,248,165,253,132,253,-15,286,268,253,268,253,120,248,87,234,59,212,37,186,23,155,17,124,23,97,37,76,60,62,88,57,121,57,268,24,268,24,118,30,74,49,37,77,9,113,-8,155,-15,197,-8,233,9,261,38,280,75,286,120, +253,132,253,132,248,165,248,165,253,132,261,215,248,165,261,215,234,193,234,193,261,215,233,243,234,193,233,243,212,215,212,215,233,243,197,261,212,215,197,261,186,230,186,230,197,261,155,235,124,230,155,235,155,268,124,230,155,268,113,262,62,165,76,193,77,244,77,244,76,193,97,215,77,244,97,215,113,262,113,262,97,215,124,230,49,216,30,178,57,-15,49,216,57,-15,57,132,49,216,57,132,62,165,49,216,62,165,77,244,24,134,24,-15,57,-15,24,134,57,-15,30,178,197,261,155,268,155,235,286,-15,286,132,280,177,286,-15,280,177,261,215,286,-15,261,215,253,132,286,-15,253,132,253,-15, +286,268,253,268,253,120,248,87,234,59,212,37,186,23,155,17,124,23,97,37,76,60,62,88,57,121,57,268,24,268,24,118,30,74,49,37,77,9,113,-8,155,-15,197,-8,233,9,261,38,280,75,286,120,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,18,-143,22,-150,28,-155, +253,120,248,87,261,38,261,38,248,87,234,59,261,38,234,59,233,9,233,9,234,59,212,37,233,9,212,37,197,-8,197,-8,212,37,186,23,197,-8,186,23,155,-15,155,-15,186,23,155,17,286,268,253,268,261,38,286,268,261,38,280,75,286,268,280,75,286,120,76,60,77,9,97,37,97,37,77,9,113,-8,97,37,113,-8,124,23,124,23,113,-8,155,-15,124,23,155,-15,155,17,62,88,57,121,49,37,62,88,49,37,77,9,62,88,77,9,76,60,57,268,24,268,30,74,57,268,30,74,49,37,57,268,49,37,57,121,30,74,24,268,24,118,253,120,261,38,253,268, +102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,18,-143,22,-150,28,-155,37,-158,49,-159,78,-153,102,-135,119,-111,131,-84,140,-58,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,318,396,314,402,307,407,298,411,287,412,255,404,231,385,213,359,201,330,193,303,223,-61,215,-89,207,-112,198,-129,188,-140,175,-144,173,-143,172,-143,170,-142,170,-140,171,-137,173,-135,175,-132,178,-127,179,-120,178,-116,175,-112,172,-109,168,-108,163,-107,155,-109,148,-113,142,-119,139,-127,137,-136,138,-143,141,-150,146,-155,154,-158,165,-159,195,-153,219,-135,238,-111,252,-84,261,-58,352,308,360,337,368,362,378,380,389,393,402,397,404,397,406,396,408,394,408,392,407,390,405,387,402,384,400,379,399,372,400,368,402,364,410,360,415,360,423,361,430,366,435,372,439,380,440,390,439,396,436,402,431,407,424,411,413,412,381,404,355,385,336,359, +49,-140,49,-137,51,-109,51,-109,49,-137,52,-135,51,-109,52,-135,54,-112,54,-112,52,-135,54,-132,54,-112,54,-132,57,-116,57,-116,54,-132,57,-127,57,-116,57,-127,57,-120,18,-127,18,-143,21,-119,21,-119,18,-143,22,-150,21,-119,22,-150,27,-113,27,-113,22,-150,28,-155,27,-113,28,-155,34,-109,34,-109,28,-155,37,-158,34,-109,37,-158,42,-107,42,-107,37,-158,49,-159,42,-107,49,-159,46,-108,46,-108,49,-159,49,-140,86,-112,77,-129,78,-153,78,-153,77,-129,67,-140,78,-153,67,-140,54,-144,54,-144,52,-143,78,-153,78,-153,52,-143,50,-143,78,-153,50,-143,49,-159,49,-159,50,-143,49,-142,49,-159,49,-142,49,-141,285,396,287,412,283,397,283,397,287,412,281,397,268,393,281,397,287,412,268,393,287,412,255,404,289,360,294,360,298,411,298,411,294,360,302,361,298,411,302,361,307,407,307,407,302,361,309,366,307,407,309,366,314,402,314,402,309,366,315,372,314,402,315,372,318,396,318,396,315,372,318,380,318,396,318,380,320,390,279,379,279,368,281,384,281,384,279,368,281,364,281,384,281,364,284,387,284,387,281,364,285,362,284,387,285,362,286,390,286,390,285,362,289,360,286,390,289,360,287,392,287,392,289,360,298,411,287,412,285,396,286,395,287,412,286,395,287,394,287,412,287,394,287,392,287,412,287,392,298,411,255,404,231,385,231,308,255,404,231,308,239,337,255,404,239,337,247,362,255,404,247,362,257,380,255,404,257,380,268,393,231,308,231,385,213,359,231,308,213,359,201,330,231,308,201,330,193,303,231,308,193,303,140,-58,94,-89,102,-135,102,-61,102,-61,102,-135,119,-111,102,-61,119,-111,193,303,193,303,119,-111,131,-84,193,303,131,-84,140,-58,86,-112,78,-153,102,-135,86,-112,102,-135,94,-89,49,-140,49,-159,49,-141,279,368,279,379,278,372,18,-143,18,-127,16,-136,46,-108,49,-140,51,-109, +223,-61,215,-89,207,-112,198,-129,188,-140,175,-144,173,-143,172,-143,170,-142,170,-140,171,-137,173,-135,175,-132,178,-127,179,-120,178,-116,175,-112,172,-109,168,-108,163,-107,155,-109,148,-113,142,-119,139,-127,137,-136,138,-143,141,-150,146,-155,154,-158,165,-159,195,-153,219,-135,238,-111,252,-84,261,-58,352,308,360,337,368,362,378,380,389,393,402,397,404,397,406,396,408,394,408,392,407,390,405,387,402,384,400,379,399,372,400,368,402,364,410,360,415,360,423,361,430,366,435,372,439,380,440,390,439,396,436,402,431,407,424,411,413,412,381,404,355,385,336,359,323,330,314,303,16383,16383,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,98,-135,117,-111,131,-84,140,-58,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,359,201,330,193,303,344,-61,336,-89,328,-112,319,-129,309,-140,296,-144,294,-143,293,-143,291,-141,291,-140,292,-137,297,-132,299,-127,300,-120,299,-116,296,-112,293,-109,288,-108,284,-107,276,-109,269,-113,263,-119,259,-127,258,-136,259,-143,262,-150,267,-155,275,-158,286,-159,316,-153,341,-135,359,-111,373,-84,382,-58,473,308,481,337,489,362,499,380,510,393,523,397,525,397,527,396,529,394,529,392,528,390,526,387,523,384,521,379,520,372,521,368,523,364,531,360,536,360,544,361,551,366,556,372,560,380,561,390,560,396,558,402,552,407,545,411,534,412,502,404,476,385,457,359,443,330,435,303,16383,16383,223,-61,215,-89,207,-112,198,-129,187,-140,175,-144,173,-143,171,-143,169,-141,169,-140,170,-137,175,-132,177,-127,178,-120,177,-116,175,-112,171,-109,167,-108,162,-107,154,-109,147,-113,142,-119,138,-127,137,-136,138,-143,141,-150,146,-155,154,-158,164,-159,194,-153,219,-135,238,-111,251,-84,260,-58,352,308,359,337,368,362,377,380,388,393,402,397,404,397,405,396,407,395,407,392,406,390,402,384,399,379,398,372,399,368,402,364,405,362,409,360,414,360,422,361,429,366,435,372,438,380,440,390,439,396,436,402,431,407,423,411,412,412,380,404,355,385,336,359,322,330,314,303, +49,-137,51,-109,49,-140,49,-140,46,-108,44,-159,44,-159,46,-108,42,-107,44,-159,42,-107,34,-109,51,-109,52,-135,54,-112,54,-112,52,-135,54,-132,54,-112,54,-132,57,-116,57,-116,54,-132,57,-127,57,-116,57,-127,57,-120,94,-89,86,-112,98,-135,98,-135,86,-112,77,-129,98,-135,77,-129,74,-153,74,-153,77,-129,67,-140,74,-153,67,-140,54,-144,54,-144,52,-143,74,-153,74,-153,52,-143,50,-143,74,-153,50,-143,44,-159,44,-159,50,-143,49,-142,44,-159,49,-142,49,-141,171,-137,172,-109,170,-140,170,-140,168,-108,165,-159,165,-159,168,-108,163,-107,165,-159,163,-107,155,-109,172,-109,173,-135,175,-112,175,-112,173,-135,175,-132,175,-112,175,-132,178,-116,178,-116,175,-132,178,-127,178,-116,178,-127,179,-120,215,-89,207,-112,219,-135,219,-135,207,-112,198,-129,219,-135,198,-129,195,-153,195,-153,198,-129,188,-140,195,-153,188,-140,175,-144,175,-144,173,-143,195,-153,195,-153,173,-143,172,-143,195,-153,172,-143,165,-159,165,-159,172,-143,170,-142,165,-159,170,-142,170,-141,285,396,292,412,283,397,283,397,292,412,281,397,268,393,281,397,292,412,268,393,292,412,260,404,302,361,302,411,294,360,294,360,302,411,292,412,294,360,292,412,289,360,289,360,292,412,287,392,289,360,287,392,286,390,289,360,286,390,285,362,285,362,286,390,284,387,285,362,284,387,281,364,281,364,284,387,281,384,281,364,281,384,279,368,279,368,281,384,279,379,279,368,279,379,278,372,320,390,319,396,318,380,318,380,319,396,316,402,318,380,316,402,315,372,315,372,316,402,310,407,315,372,310,407,309,366,309,366,310,407,302,411,309,366,302,411,302,361,292,412,285,396,286,395,292,412,286,395,287,394,292,412,287,394,287,392,260,404,234,385,239,337,260,404,239,337,247,362,260,404,247,362,257,380,260,404,257,380,268,393,231,308,239,337,234,385,231,308,234,385,215,359,231,308,215,359,201,330,231,308,201,330,193,303,231,308,193,303,140,-58,94,-89,98,-135,102,-61,102,-61,98,-135,117,-111,102,-61,117,-111,193,303,193,303,117,-111,131,-84,193,303,131,-84,140,-58,49,-140,44,-159,49,-141,16,-136,17,-143,18,-127,18,-127,17,-143,20,-150,18,-127,20,-150,21,-119,21,-119,20,-150,25,-155,21,-119,25,-155,27,-113,27,-113,25,-155,33,-158,27,-113,33,-158,34,-109,34,-109,33,-158,44,-159,406,396,413,412,404,397,404,397,413,412,402,397,389,393,402,397,413,412,389,393,413,412,381,404,423,361,424,411,415,360,415,360,424,411,413,412,415,360,413,412,410,360,410,360,413,412,408,392,410,360,408,392,407,390,410,360,407,390,406,362,406,362,407,390,405,387,406,362,405,387,402,364,402,364,405,387,402,384,402,364,402,384,400,379,400,379,399,372,400,368,400,379,400,368,402,364,440,390,439,396,439,380,439,380,439,396,436,402,439,380,436,402,435,372,435,372,436,402,431,407,435,372,431,407,430,366,430,366,431,407,424,411,430,366,424,411,423,361,413,412,406,396,407,395,413,412,407,395,408,394,413,412,408,394,408,392,381,404,355,385,360,337,381,404,360,337,368,362,381,404,368,362,378,380,381,404,378,380,389,393,352,308,360,337,355,385,352,308,355,385,336,359,352,308,336,359,323,330,352,308,323,330,314,303,352,308,314,303,261,-58,215,-89,219,-135,223,-61,223,-61,219,-135,238,-111,223,-61,238,-111,314,303,314,303,238,-111,252,-84,314,303,252,-84,261,-58,170,-140,165,-159,170,-141,137,-136,138,-143,139,-127,139,-127,138,-143,141,-150,139,-127,141,-150,142,-119,142,-119,141,-150,146,-155,142,-119,146,-155,148,-113,148,-113,146,-155,154,-158,148,-113,154,-158,155,-109,155,-109,154,-158,165,-159,168,-108,170,-140,172,-109,172,-109,171,-137,173,-135,46,-108,49,-140,51,-109,51,-109,49,-137,52,-135, +344,-61,336,-89,328,-112,319,-129,309,-140,296,-144,294,-143,293,-143,291,-141,291,-140,292,-137,297,-132,299,-127,300,-120,299,-116,296,-112,293,-109,288,-108,284,-107,276,-109,269,-113,263,-119,259,-127,258,-136,259,-143,262,-150,267,-155,275,-158,286,-159,316,-153,341,-135,359,-111,373,-84,382,-58,473,308,481,337,489,362,499,380,510,393,523,397,525,397,527,396,529,394,529,392,528,390,526,387,523,384,521,379,520,372,521,368,523,364,531,360,536,360,544,361,551,366,556,372,560,380,561,390,560,396,558,402,552,407,545,411,534,412,502,404,476,385,457,359,443,330,435,303,16383,16383,223,-61,215,-89,207,-112,198,-129,187,-140,175,-144,173,-143,171,-143,169,-141,169,-140,170,-137,175,-132,177,-127,178,-120,177,-116,175,-112,171,-109,167,-108,162,-107,154,-109,147,-113,142,-119,138,-127,137,-136,138,-143,141,-150,146,-155,154,-158,164,-159,194,-153,219,-135,238,-111,251,-84,260,-58,352,308,359,337,368,362,377,380,388,393,402,397,404,397,405,396,407,395,407,392,406,390,402,384,399,379,398,372,399,368,402,364,405,362,409,360,414,360,422,361,429,366,435,372,438,380,440,390,439,396,436,402,431,407,423,411,412,412,380,404,355,385,336,359,322,330,314,303,16383,16383,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,98,-135,117,-111,131,-84,140,-58,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,359,201,330,193,303,176,238,167,238,131,232,101,216,76,192,60,161,55,126,58,99,67,74,81,53,100,35,123,22,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,18,-143,22,-150,28,-155,37,-158,49,-159,78,-153,102,-135,119,-111,131,-84,140,-58,157,13,167,13,202,19,233,35,258,59,274,90,280,126,276,152,267,177,253,199,234,216,211,229,231,308,239,337,247,362,257,381,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,318,396,314,402,307,407,298,411,287,412,255,404,231,385,213,358,201,330,193,303,16383,16383,162,32,206,210,224,199,239,185,251,167,258,147,261,126,256,96,243,70,222,50,197,37,167,32,16383,16383,172,219,127,41,109,52,95,66,83,84,76,104,74,126,78,155,92,181,112,201,137,214,167,219,296,231,284,234,271,236,258,237,244,238,214,238,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,358,201,330,193,303,175,233,135,222,101,204,76,182,61,155,55,126,58,104,67,84,82,65,102,48,126,35,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,99,-135,117,-111,131,-84,140,-58,160,22,172,19,200,15,230,13, +49,-137,51,-109,49,-140,49,-140,46,-108,44,-159,44,-159,46,-108,42,-107,44,-159,42,-107,34,-109,51,-109,52,-135,54,-112,54,-112,52,-135,54,-132,54,-112,54,-132,57,-116,57,-116,54,-132,57,-127,57,-116,57,-127,57,-120,94,-89,86,-112,98,-135,98,-135,86,-112,77,-129,98,-135,77,-129,74,-153,74,-153,77,-129,67,-140,74,-153,67,-140,54,-144,54,-144,52,-143,74,-153,74,-153,52,-143,50,-143,74,-153,50,-143,44,-159,44,-159,50,-143,49,-142,44,-159,49,-142,49,-141,170,-137,171,-109,169,-140,169,-140,167,-108,164,-159,164,-159,167,-108,162,-107,164,-159,162,-107,154,-109,171,-109,172,-135,175,-112,175,-112,172,-135,175,-132,175,-112,175,-132,177,-116,177,-116,175,-132,177,-127,177,-116,177,-127,178,-120,215,-89,207,-112,219,-135,219,-135,207,-112,198,-129,219,-135,198,-129,194,-153,194,-153,198,-129,187,-140,194,-153,187,-140,175,-144,175,-144,173,-143,194,-153,194,-153,173,-143,171,-143,194,-153,171,-143,164,-159,164,-159,171,-143,170,-142,164,-159,170,-142,169,-141,285,396,292,412,283,397,283,397,292,412,281,397,268,393,281,397,292,412,268,393,292,412,260,404,302,361,302,411,294,360,294,360,302,411,292,412,294,360,292,412,289,360,289,360,292,412,287,392,289,360,287,392,286,390,289,360,286,390,285,362,285,362,286,390,284,387,285,362,284,387,281,364,281,364,284,387,281,384,281,364,281,384,279,368,279,368,281,384,279,379,279,368,279,379,278,372,292,-137,293,-109,291,-140,291,-140,288,-108,286,-159,286,-159,288,-108,284,-107,286,-159,284,-107,276,-109,293,-109,294,-135,296,-112,296,-112,294,-135,297,-132,296,-112,297,-132,299,-116,299,-116,297,-132,299,-127,299,-116,299,-127,300,-120,320,390,319,396,318,380,318,380,319,396,316,402,318,380,316,402,315,372,315,372,316,402,310,407,315,372,310,407,309,366,309,366,310,407,302,411,309,366,302,411,302,361,292,412,285,396,286,395,292,412,286,395,287,394,292,412,287,394,287,392,260,404,234,385,239,337,260,404,239,337,247,362,260,404,247,362,257,380,260,404,257,380,268,393,231,308,239,337,234,385,231,308,234,385,215,359,231,308,215,359,201,330,231,308,201,330,193,303,231,308,193,303,140,-58,94,-89,98,-135,102,-61,102,-61,98,-135,117,-111,102,-61,117,-111,193,303,193,303,117,-111,131,-84,193,303,131,-84,140,-58,49,-140,44,-159,49,-141,16,-136,17,-143,18,-127,18,-127,17,-143,20,-150,18,-127,20,-150,21,-119,21,-119,20,-150,25,-155,21,-119,25,-155,27,-113,27,-113,25,-155,33,-158,27,-113,33,-158,34,-109,34,-109,33,-158,44,-159,336,-89,328,-112,341,-135,341,-135,328,-112,319,-129,341,-135,319,-129,316,-153,316,-153,319,-129,309,-140,316,-153,309,-140,296,-144,296,-144,294,-143,316,-153,316,-153,294,-143,293,-143,316,-153,293,-143,286,-159,286,-159,293,-143,292,-142,286,-159,292,-142,291,-141,405,396,412,412,404,397,404,397,412,412,402,397,388,393,402,397,412,412,388,393,412,412,380,404,422,361,423,411,414,360,414,360,423,411,412,412,414,360,412,412,409,360,409,360,412,412,407,392,409,360,407,392,406,390,409,360,406,390,405,362,405,362,406,390,404,387,405,362,404,387,402,364,402,364,404,387,402,384,402,364,402,384,399,379,399,379,398,372,399,368,399,379,399,368,402,364,440,390,439,396,438,380,438,380,439,396,436,402,438,380,436,402,435,372,435,372,436,402,431,407,435,372,431,407,429,366,429,366,431,407,423,411,429,366,423,411,422,361,412,412,405,396,407,395,412,412,407,395,407,394,412,412,407,394,407,392,380,404,355,385,359,337,380,404,359,337,368,362,380,404,368,362,377,380,380,404,377,380,388,393,352,308,359,337,355,385,352,308,355,385,336,359,352,308,336,359,322,330,352,308,322,330,314,303,352,308,314,303,260,-58,215,-89,219,-135,223,-61,223,-61,219,-135,238,-111,223,-61,238,-111,314,303,314,303,238,-111,251,-84,314,303,251,-84,260,-58,169,-140,164,-159,169,-141,137,-136,138,-143,138,-127,138,-127,138,-143,141,-150,138,-127,141,-150,142,-119,142,-119,141,-150,146,-155,142,-119,146,-155,147,-113,147,-113,146,-155,154,-158,147,-113,154,-158,154,-109,154,-109,154,-158,164,-159,435,303,344,-61,359,-111,435,303,359,-111,373,-84,435,303,373,-84,382,-58,435,303,382,-58,473,308,435,303,473,308,443,330,344,-61,336,-89,341,-135,344,-61,341,-135,359,-111,291,-140,286,-159,291,-141,258,-136,259,-143,259,-127,259,-127,259,-143,262,-150,259,-127,262,-150,263,-119,263,-119,262,-150,267,-155,263,-119,267,-155,269,-113,269,-113,267,-155,275,-158,269,-113,275,-158,276,-109,276,-109,275,-158,286,-159,527,396,534,412,525,397,525,397,534,412,523,397,510,393,523,397,534,412,510,393,534,412,502,404,544,361,545,411,536,360,536,360,545,411,534,412,536,360,534,412,531,360,531,360,534,412,529,392,531,360,529,392,528,390,531,360,528,390,527,362,527,362,528,390,526,387,527,362,526,387,523,364,523,364,526,387,523,384,523,364,523,384,521,379,521,379,520,372,521,368,521,379,521,368,523,364,561,390,560,396,560,380,560,380,560,396,558,402,560,380,558,402,556,372,556,372,558,402,552,407,556,372,552,407,551,366,551,366,552,407,545,411,551,366,545,411,544,361,534,412,527,396,528,395,534,412,528,395,529,394,534,412,529,394,529,392,502,404,476,385,481,337,502,404,481,337,489,362,502,404,489,362,499,380,502,404,499,380,510,393,473,308,481,337,476,385,473,308,476,385,457,359,473,308,457,359,443,330,288,-108,291,-140,293,-109,293,-109,292,-137,294,-135,167,-108,169,-140,171,-109,171,-109,170,-137,172,-135,46,-108,49,-140,51,-109,51,-109,49,-137,52,-135, +176,238,167,238,131,232,101,216,76,192,60,161,55,126,58,99,67,74,81,53,100,35,123,22,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,18,-143,22,-150,28,-155,37,-158,49,-159,78,-153,102,-135,119,-111,131,-84,140,-58,157,13,167,13,202,19,233,35,258,59,274,90,280,126,276,152,267,177,253,199,234,216,211,229,231,308,239,337,247,362,257,381,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,318,396,314,402,307,407,298,411,287,412,255,404,231,385,213,358,201,330,193,303,16383,16383,162,32,206,210,224,199,239,185,251,167,258,147,261,126,256,96,243,70,222,50,197,37,167,32,16383,16383,172,219,127,41,109,52,95,66,83,84,76,104,74,126,78,155,92,181,112,201,137,214,167,219,296,231,284,234,271,236,258,237,244,238,214,238,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,358,201,330,193,303,175,233,135,222,101,204,76,182,61,155,55,126,58,104,67,84,82,65,102,48,126,35,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,99,-135,117,-111,131,-84,140,-58,160,22,172,19,200,15,230,13,235,13,237,14,242,14,223,-61,216,-89,208,-112,199,-129,188,-140,175,-144,173,-143,172,-143,170,-142,170,-140,171,-137,173,-135,175,-132,178,-127,179,-120,178,-116,175,-112,172,-109,168,-108,163,-107,155,-109,148,-113,142,-119,139,-127,137,-136,138,-143, +49,-140,49,-137,51,-109,51,-109,49,-137,52,-135,51,-109,52,-135,54,-112,54,-112,52,-135,54,-132,54,-112,54,-132,57,-116,57,-116,54,-132,57,-127,57,-116,57,-127,57,-120,18,-127,18,-143,21,-119,21,-119,18,-143,22,-150,21,-119,22,-150,27,-113,27,-113,22,-150,28,-155,27,-113,28,-155,34,-109,34,-109,28,-155,37,-158,34,-109,37,-158,42,-107,42,-107,37,-158,49,-159,42,-107,49,-159,46,-108,46,-108,49,-159,49,-140,86,-112,77,-129,78,-153,78,-153,77,-129,67,-140,78,-153,67,-140,54,-144,54,-144,52,-143,78,-153,78,-153,52,-143,50,-143,78,-153,50,-143,49,-159,49,-159,50,-143,49,-142,49,-159,49,-142,49,-141,95,66,100,35,109,52,109,52,100,35,123,22,109,52,123,22,127,41,127,41,123,22,131,-84,127,41,131,-84,172,219,172,219,131,-84,140,-58,172,219,140,-58,157,13,83,84,76,104,81,53,83,84,81,53,100,35,83,84,100,35,95,66,76,104,74,126,81,53,81,53,74,126,67,74,67,74,74,126,76,192,76,192,74,126,78,155,201,330,193,303,206,210,206,210,193,303,176,238,206,210,176,238,172,219,172,219,176,238,167,238,172,219,167,238,167,219,167,219,167,238,137,214,78,155,92,181,101,216,101,216,92,181,112,201,101,216,112,201,131,232,131,232,112,201,137,214,131,232,137,214,167,238,60,161,55,126,58,99,60,161,58,99,67,74,60,161,67,74,76,192,289,360,294,360,298,411,298,411,294,360,302,361,298,411,302,361,307,407,307,407,302,361,309,366,307,407,309,366,314,402,314,402,309,366,315,372,314,402,315,372,318,396,318,396,315,372,318,380,318,396,318,380,320,390,279,379,279,368,281,384,281,384,279,368,281,364,281,384,281,364,284,387,284,387,281,364,285,362,284,387,285,362,286,390,286,390,285,362,289,360,286,390,289,360,287,392,287,392,289,360,298,411,287,412,255,404,268,393,287,412,268,393,281,397,287,412,281,397,283,397,287,412,283,397,285,396,287,412,285,396,286,395,287,412,286,395,287,394,287,412,287,394,287,392,287,412,287,392,298,411,255,404,231,385,231,308,255,404,231,308,239,337,255,404,239,337,247,362,255,404,247,362,257,381,255,404,257,381,268,393,213,358,201,330,206,210,213,358,206,210,211,229,213,358,211,229,231,308,213,358,231,308,231,385,162,32,206,210,172,219,162,32,172,219,159,13,162,32,159,13,161,13,162,32,161,13,163,13,162,32,163,13,167,32,94,-89,102,-135,102,-61,102,-61,102,-135,119,-111,102,-61,119,-111,123,22,123,22,119,-111,131,-84,86,-112,78,-153,102,-135,86,-112,102,-135,94,-89,49,-140,49,-159,49,-141,258,59,274,90,261,126,261,126,267,177,258,147,258,147,267,177,253,199,258,147,253,199,251,167,251,167,253,199,239,185,234,216,211,229,224,199,234,216,224,199,239,185,234,216,239,185,253,199,274,90,280,126,276,152,274,90,276,152,267,177,274,90,267,177,261,126,258,59,261,126,256,96,258,59,256,96,243,70,258,59,243,70,233,35,163,13,165,13,167,32,167,32,165,13,167,13,167,32,167,13,197,37,197,37,167,13,202,19,197,37,202,19,222,50,222,50,202,19,233,35,222,50,233,35,243,70,224,199,211,229,206,210,279,368,279,379,278,372,18,-143,18,-127,16,-136,172,219,157,13,159,13,76,192,78,155,101,216,46,-108,49,-140,51,-109, +296,231,284,234,271,236,258,237,244,238,214,238,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,358,201,330,193,303,175,233,135,222,101,204,76,182,61,155,55,126,58,104,67,84,82,65,102,48,126,35,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,99,-135,117,-111,131,-84,140,-58,160,22,172,19,200,15,230,13,235,13,237,14,242,14,223,-61,216,-89,208,-112,199,-129,188,-140,175,-144,173,-143,172,-143,170,-142,170,-140,171,-137,173,-135,175,-132,178,-127,179,-120,178,-116,175,-112,172,-109,168,-108,163,-107,155,-109,148,-113,142,-119,139,-127,137,-136,138,-143,141,-150,146,-155,154,-158,165,-159,195,-153,220,-135,239,-111,252,-84,261,-58,280,18,321,29,356,47,382,70,398,96,404,126,401,149,391,170,376,189,355,206,330,219,352,308,360,337,368,362,378,380,389,393,402,397,404,397,406,396,408,394,408,392,407,390,405,387,402,384,400,379,399,372,400,368,402,364,410,360,415,360,423,361,430,366,435,372,439,380,440,390,439,396,436,402,431,407,424,411,413,412,381,404,355,385,336,359,323,330,314,303,16383,16383,325,200,345,188,362,175,374,160,382,143,385,126,380,103,367,82,345,64,318,50,285,39,16383,16383,247,33,235,33,232,32,228,32,214,33,201,34,188,36,176,38,165,41,209,219,241,219,267,217,291,211,16383,16383,131,54,111,65,96,78,84,93,77,109,74,126,79,149,91,170,112,188,138,203,171,213,415,225,385,231,368,234,351,236,334,237,352,308,360,337,368,362,377,381,388,393,402,397,404,397,405,396,407,395,407,392,406,390,402,384,399,379,398,372,399,368,402,364,405,362,409,360,414,360,422,361,429,366,435,372,438,380,440,390,439,396,436,402,431,407,423,411,412,412,380,404,355,385,336,359,322,330,314,303,297,238,257,238,227,236,213,234,231,308,239,337,247,362,257,380,268,393,281,397,283,397,285,396,287,394,287,392,286,390,284,387,281,384,279,379,278,372,279,368,281,364,289,360,294,360,302,361,309,366,315,372,318,380,320,390,319,396,316,402,310,407,302,411,292,412,260,404,234,385,215,359,201,330,193,303,174,227,132,214,99,197,74,177,59,153,54,126,57,103,66,82,80,64,101,49,127,37,102,-61,94,-89,86,-112,77,-129,67,-140,54,-144,52,-143,50,-143,49,-142,49,-137,52,-135,54,-132,57,-127,57,-116,54,-112,51,-109,46,-108,42,-107,34,-109,27,-113,21,-119,18,-127,16,-136,17,-143,20,-150,25,-155,33,-158,44,-159,74,-153,99,-135,117,-111,131,-84,140,-58,161,26,175,23,191,20,207,18,224,16,242,15,223,-61,215,-89,207,-112,198,-129,187,-140,175,-144,173,-143,171,-143,169,-141,169,-140,170,-137,175,-132,177,-127,178,-120,177,-116,175,-112,171,-109,167,-108,162,-107,154,-109,147,-113,142,-119,138,-127,137,-136,138,-143,141,-150,146,-155,154,-158,164,-159,194,-153,219,-135,238,-111,251,-84,260,-58,278,13,289,13,305,14,320,14,335,15,349,16,363,18,344,-61,336,-89,328,-112,319,-129,309,-140,296,-144,294,-143,292,-143,290,-141,290,-140,291,-137,296,-132,298,-127,299,-120,298,-116,296,-112,292,-109,288,-108,283,-107,275,-109,268,-113,262,-119,259,-127,257,-136,258,-143,261,-150,267,-155,275,-158,285,-159,316,-153,340,-135,359,-111,372,-84,381,-58,401,24,444,36,478,53,503,73,519,98,524,126,521,148, +49,-137,51,-109,49,-140,49,-140,46,-108,44,-159,44,-159,46,-108,42,-107,44,-159,42,-107,34,-109,51,-109,52,-135,54,-112,54,-112,52,-135,54,-132,54,-112,54,-132,57,-116,57,-116,54,-132,57,-127,57,-116,57,-127,57,-120,94,-89,86,-112,99,-135,99,-135,86,-112,77,-129,99,-135,77,-129,74,-153,74,-153,77,-129,67,-140,74,-153,67,-140,54,-144,54,-144,52,-143,74,-153,74,-153,52,-143,50,-143,74,-153,50,-143,44,-159,44,-159,50,-143,49,-142,44,-159,49,-142,49,-141,96,78,102,48,111,65,111,65,102,48,126,35,111,65,126,35,131,54,131,54,126,35,131,-84,131,54,131,-84,171,213,171,213,131,-84,140,-58,171,213,140,-58,160,22,84,93,77,109,82,65,84,93,82,65,102,48,84,93,102,48,96,78,77,109,74,126,82,65,82,65,74,126,67,84,67,84,74,126,76,182,76,182,74,126,79,149,171,-137,172,-109,170,-140,170,-140,168,-108,165,-159,165,-159,168,-108,163,-107,165,-159,163,-107,155,-109,172,-109,173,-135,175,-112,175,-112,173,-135,175,-132,175,-112,175,-132,178,-116,178,-116,175,-132,178,-127,178,-116,178,-127,179,-120,216,-89,208,-112,220,-135,220,-135,208,-112,199,-129,220,-135,199,-129,195,-153,195,-153,199,-129,188,-140,195,-153,188,-140,175,-144,175,-144,173,-143,195,-153,195,-153,173,-143,172,-143,195,-153,172,-143,165,-159,165,-159,172,-143,170,-142,165,-159,170,-142,170,-141,201,330,193,303,209,219,209,219,193,303,175,233,209,219,175,233,171,213,171,213,175,233,138,203,138,203,175,233,135,222,138,203,135,222,112,188,112,188,135,222,101,204,112,188,101,204,91,170,91,170,101,204,79,149,61,155,55,126,58,104,61,155,58,104,67,84,61,155,67,84,76,182,285,396,292,412,283,397,283,397,292,412,281,397,268,393,281,397,292,412,268,393,292,412,260,404,302,361,302,411,294,360,294,360,302,411,292,412,294,360,292,412,289,360,289,360,292,412,287,392,289,360,287,392,286,390,289,360,286,390,285,362,285,362,286,390,284,387,285,362,284,387,281,364,281,364,284,387,281,384,281,364,281,384,279,368,279,368,281,384,279,379,279,368,279,379,278,372,320,390,319,396,318,380,318,380,319,396,316,402,318,380,316,402,315,372,315,372,316,402,310,407,315,372,310,407,309,366,309,366,310,407,302,411,309,366,302,411,302,361,292,412,285,396,286,395,292,412,286,395,287,394,292,412,287,394,287,392,260,404,234,385,239,337,260,404,239,337,247,362,260,404,247,362,257,380,260,404,257,380,268,393,239,337,234,385,231,308,231,308,234,385,215,358,231,308,215,358,214,238,214,238,215,358,212,219,214,238,212,219,216,219,215,358,201,330,209,219,215,358,209,219,212,219,176,38,165,41,172,19,171,213,165,41,209,219,160,22,172,19,165,41,160,22,165,41,171,213,94,-89,99,-135,102,-61,102,-61,99,-135,117,-111,102,-61,117,-111,126,35,126,35,117,-111,131,-84,49,-140,44,-159,49,-141,16,-136,17,-143,18,-127,18,-127,17,-143,20,-150,18,-127,20,-150,21,-119,21,-119,20,-150,25,-155,21,-119,25,-155,27,-113,27,-113,25,-155,33,-158,27,-113,33,-158,34,-109,34,-109,33,-158,44,-159,296,231,284,234,291,211,291,211,325,200,296,231,296,231,325,200,314,303,406,396,413,412,404,397,404,397,413,412,402,397,389,393,402,397,413,412,389,393,413,412,381,404,423,361,424,411,415,360,415,360,424,411,413,412,415,360,413,412,410,360,410,360,413,412,408,392,410,360,408,392,407,390,410,360,407,390,406,362,406,362,407,390,405,387,406,362,405,387,402,364,402,364,405,387,402,384,402,364,402,384,400,379,400,379,399,372,400,368,400,379,400,368,402,364,440,390,439,396,439,380,439,380,439,396,436,402,439,380,436,402,435,372,435,372,436,402,431,407,435,372,431,407,430,366,430,366,431,407,424,411,430,366,424,411,423,361,413,412,406,396,407,395,413,412,407,395,408,394,413,412,408,394,408,392,381,404,355,385,360,337,381,404,360,337,368,362,381,404,368,362,378,380,381,404,378,380,389,393,336,359,330,219,352,308,336,359,352,308,355,385,355,385,352,308,360,337,336,359,325,200,330,219,330,219,325,200,345,188,330,219,345,188,355,206,355,206,345,188,362,175,355,206,362,175,376,189,376,189,362,175,374,160,376,189,374,160,382,143,323,330,314,303,325,200,323,330,325,200,336,359,291,211,247,33,252,-84,291,211,252,-84,261,-58,291,211,261,-58,280,18,291,211,280,18,285,39,291,211,285,39,325,200,243,33,239,33,239,14,243,33,239,14,242,14,243,33,242,14,252,-84,243,33,252,-84,247,33,216,-89,220,-135,223,-61,223,-61,220,-135,239,-111,223,-61,239,-111,242,14,242,14,239,-111,252,-84,170,-140,165,-159,170,-141,137,-136,138,-143,139,-127,139,-127,138,-143,141,-150,139,-127,141,-150,142,-119,142,-119,141,-150,146,-155,142,-119,146,-155,148,-113,148,-113,146,-155,154,-158,148,-113,154,-158,155,-109,155,-109,154,-158,165,-159,404,126,401,149,398,96,398,96,401,149,391,170,398,96,391,170,385,126,385,126,382,70,398,96,391,170,376,189,382,143,391,170,382,143,385,126,385,126,380,103,382,70,382,70,380,103,367,82,382,70,367,82,356,47,356,47,367,82,345,64,356,47,345,64,321,29,321,29,345,64,318,50,321,29,318,50,285,39,280,18,321,29,285,39,176,38,186,17,188,36,188,36,186,17,200,15,188,36,200,15,201,34,201,34,200,15,215,14,201,34,215,14,214,33,214,33,215,14,228,32,232,32,228,32,230,13,232,32,230,13,232,13,291,211,284,234,279,214,279,214,284,234,271,236,279,214,271,236,267,217,267,217,271,236,258,237,267,217,258,237,254,218,254,218,258,237,244,238,254,218,244,238,241,219,241,219,244,238,230,238,241,219,230,238,228,219,232,13,235,13,235,33,235,33,235,13,237,14,235,33,237,14,239,33,239,33,237,14,239,14,230,238,214,238,216,219,230,238,216,219,220,219,230,238,220,219,224,219,230,238,224,219,228,219,228,32,215,14,230,13,232,32,232,13,235,33,176,38,172,19,186,17,76,182,79,149,101,204,168,-108,170,-140,172,-109,172,-109,171,-137,173,-135,46,-108,49,-140,51,-109,51,-109,49,-137,52,-135, +319,60,319,93,170,93,200,160,319,160,319,193,214,193,274,331,247,331,187,193,24,193,24,160,172,160,143,93,24,93,24,60,128,60,69,-77,95,-77,156,60,319,206,319,239,24,239,24,206,16383,16383,319,110,319,143,24,143,24,110,16383,16383,319,14,319,47,24,47,24,14,319,14,319,47,150,47,177,110,319,110,319,143, +128,60,69,-77,95,-77,128,60,95,-77,156,60,128,60,156,60,143,93,128,60,143,93,24,93,128,60,24,93,24,60,172,160,143,93,156,60,172,160,156,60,170,93,172,160,170,93,200,160,172,160,200,160,187,193,172,160,187,193,24,193,172,160,24,193,24,160,214,193,274,331,247,331,214,193,247,331,200,160,214,193,200,160,319,160,214,193,319,160,319,193,170,93,156,60,319,60,170,93,319,60,319,93,187,193,200,160,247,331, +319,206,319,239,24,239,24,206,16383,16383,319,110,319,143,24,143,24,110,16383,16383,319,14,319,47,24,47,24,14,319,14,319,47,150,47,177,110,319,110,319,143,192,143,219,206,319,206,319,239,233,239,274,331,247,331,207,239, +24,239,24,206,319,206,24,239,319,206,319,239,24,143,24,110,319,110,24,143,319,110,319,143,24,47,24,14,319,14,24,47,319,14,319,47, +319,14,319,47,150,47,177,110,319,110,319,143,192,143,219,206,319,206,319,239,233,239,274,331,247,331,207,239,24,239,24,206,193,206,165,143,24,143,24,110,151,110,123,47,24,47,24,14,108,14,69,-77,95,-77,136,14,319,239,319,272,24,272,24,239,16383,16383,319,153,319,186,24,186,24,153,16383,16383,319,67,319,100,24,100,24,67,16383,16383,319,-18,319,14,24,14,24,-18,315,26,315,57,99,165,315,272,315,305,32,167,32,162,16383,16383,315,-50, +108,14,69,-77,95,-77,108,14,95,-77,136,14,108,14,136,14,123,47,108,14,123,47,24,47,108,14,24,47,24,14,151,110,123,47,136,14,151,110,136,14,150,47,151,110,150,47,177,110,151,110,177,110,165,143,151,110,165,143,24,143,151,110,24,143,24,110,193,206,165,143,177,110,193,206,177,110,192,143,193,206,192,143,219,206,193,206,219,206,207,239,193,206,207,239,24,239,193,206,24,239,24,206,233,239,274,331,247,331,233,239,247,331,219,206,233,239,219,206,319,206,233,239,319,206,319,239,192,143,177,110,319,110,192,143,319,110,319,143,150,47,136,14,319,14,150,47,319,14,319,47,207,239,219,206,247,331, +319,239,319,272,24,272,24,239,16383,16383,319,153,319,186,24,186,24,153,16383,16383,319,67,319,100,24,100,24,67,16383,16383,319,-18,319,14,24,14,24,-18,315,26,315,57,99,165,315,272,315,305,32,167,32,162,16383,16383,315,-50,315,-17,32,-17,32,-50,315,162,315,167,32,305,32,272,248,165,32,57,32,26, +24,272,24,239,319,239,24,272,319,239,319,272,24,186,24,153,319,153,24,186,319,153,319,186,24,100,24,67,319,67,24,100,319,67,319,100,24,14,24,-18,319,-18,24,14,319,-18,319,14, +315,26,315,57,99,165,315,272,315,305,32,167,32,162,16383,16383,315,-50,315,-17,32,-17,32,-50,315,162,315,167,32,305,32,272,248,165,32,57,32,26,16383,16383,315,-50,315,-17,32,-17,32,-50, +99,165,315,272,315,305,99,165,315,305,32,167,99,165,32,167,315,26,99,165,315,26,315,57,32,-17,32,-50,315,-50,32,-17,315,-50,315,-17,315,26,32,167,32,162, +315,162,315,167,32,305,32,272,248,165,32,57,32,26,16383,16383,315,-50,315,-17,32,-17,32,-50,311,80,311,112,95,219,311,326,311,359,28,222,28,217,16383,16383,311,-5,311,27,28,27,28,-5, +248,165,32,57,315,162,248,165,315,162,315,167,248,165,315,167,32,305,248,165,32,305,32,272,32,-17,32,-50,315,-50,32,-17,315,-50,315,-17,315,162,32,57,32,26, +311,80,311,112,95,219,311,326,311,359,28,222,28,217,16383,16383,311,-5,311,27,28,27,28,-5,16383,16383,311,-104,311,-72,28,-72,28,-104,311,217,311,222,28,359,28,326,244,219,28,112,28,80,16383,16383,311,-5,311,27,28,27,28,-5,16383,16383,311,-104,311,-72,28,-72,28,-104, +95,219,311,326,311,359,95,219,311,359,28,222,95,219,28,222,311,80,95,219,311,80,311,112,28,27,28,-5,311,-5,28,27,311,-5,311,27,28,-72,28,-104,311,-104,28,-72,311,-104,311,-72,311,80,28,222,28,217, +311,217,311,222,28,359,28,326,244,219,28,112,28,80,16383,16383,311,-5,311,27,28,27,28,-5,16383,16383,311,-104,311,-72,28,-72,28,-104,310,94,310,126,94,233,310,340,310,373,28,235,28,230,16383,16383,310,-91,310,-58,158,-58,200,8,310,8,310,41,221,41,245,79,215,79, +244,219,28,112,311,217,244,219,311,217,311,222,244,219,311,222,28,359,244,219,28,359,28,326,28,27,28,-5,311,-5,28,27,311,-5,311,27,28,-72,28,-104,311,-104,28,-72,311,-104,311,-72,311,217,28,112,28,80, +310,94,310,126,94,233,310,340,310,373,28,235,28,230,16383,16383,310,-91,310,-58,158,-58,200,8,310,8,310,41,221,41,245,79,215,79,191,41,28,41,28,8,171,8,128,-58,28,-58,28,-91,108,-91,84,-129,114,-129,138,-91,310,230,310,235,28,373,28,340,244,233,28,126,28,94,16383,16383,310,-91,310,-58,165,-58,207,8,310,8,310,41,228,41,252,79,222,79,198,41,28,41,28,8,177,8,135,-58,28,-58,28,-91,114,-91,91,-129,121,-129,145,-91, +94,233,310,340,310,373,94,233,310,373,28,235,94,233,28,235,310,94,94,233,310,94,310,126,28,41,171,8,191,41,191,41,171,8,200,8,191,41,200,8,215,79,215,79,200,8,221,41,215,79,221,41,245,79,221,41,200,8,310,8,221,41,310,8,310,41,108,-91,114,-129,128,-58,128,-58,114,-129,138,-91,128,-58,138,-91,171,8,171,8,138,-91,158,-58,171,8,158,-58,200,8,28,-58,28,-91,108,-91,28,-58,108,-91,128,-58,158,-58,138,-91,310,-91,158,-58,310,-91,310,-58,114,-129,108,-91,84,-129,171,8,28,41,28,8,310,94,28,235,28,230, +310,230,310,235,28,373,28,340,244,233,28,126,28,94,16383,16383,310,-91,310,-58,165,-58,207,8,310,8,310,41,228,41,252,79,222,79,198,41,28,41,28,8,177,8,135,-58,28,-58,28,-91,114,-91,91,-129,121,-129,145,-91,454,-12,454,18,238,127,454,233,454,266,171,129,171,124,16383,16383,295,-12,295,18,79,127,295,233,295,266,12,129,12,124,454,124,454,129,171,266,171,233,387,127,171,18,171,-12,16383,16383,295,124,295,129,12,266,12,233,228,127, +244,233,28,126,310,230,244,233,310,230,310,235,244,233,310,235,28,373,244,233,28,373,28,340,28,41,177,8,198,41,198,41,177,8,207,8,198,41,207,8,222,79,222,79,207,8,228,41,222,79,228,41,252,79,228,41,207,8,310,8,228,41,310,8,310,41,114,-91,121,-129,135,-58,135,-58,121,-129,145,-91,135,-58,145,-91,177,8,177,8,145,-91,165,-58,177,8,165,-58,207,8,28,-58,28,-91,114,-91,28,-58,114,-91,135,-58,165,-58,145,-91,310,-91,165,-58,310,-91,310,-58,121,-129,114,-91,91,-129,177,8,28,41,28,8,310,230,28,126,28,94, +454,-12,454,18,238,127,454,233,454,266,171,129,171,124,16383,16383,295,-12,295,18,79,127,295,233,295,266,12,129,12,124,454,124,454,129,171,266,171,233,387,127,171,18,171,-12,16383,16383,295,124,295,129,12,266,12,233,228,127,12,18,12,-12, +238,127,454,233,454,266,238,127,454,266,171,129,238,127,171,129,454,-12,238,127,454,-12,454,18,79,127,295,233,295,266,79,127,295,266,12,129,79,127,12,129,295,-12,79,127,295,-12,295,18,295,-12,12,129,12,124,454,-12,171,129,171,124, +454,124,454,129,171,266,171,233,387,127,171,18,171,-12,16383,16383,295,124,295,129,12,266,12,233,228,127,12,18,12,-12,190,-102,179,-89,167,-74,154,-59,130,-25,149,4,165,35,176,66,183,97,185,127,183,156,176,187,164,218,149,248,130,278, +387,127,171,18,454,124,387,127,454,124,454,129,387,127,454,129,171,266,387,127,171,266,171,233,228,127,12,18,295,124,228,127,295,124,295,129,228,127,295,129,12,266,228,127,12,266,12,233,295,124,12,18,12,-12,454,124,171,18,171,-12, +190,-102,179,-89,167,-74,154,-59,130,-25,149,4,165,35,176,66,183,97,185,127,183,156,176,187,164,218,149,248,130,278,142,296,154,312,167,328,179,342,190,355,190,365,174,353,158,340,143,326,130,312,117,296,103,312,89,326,74,340,59,353,42,365,42,357,66,329,78,313,91,296,103,278,84,249,68,218,57,187,50,156,47,127,50,97,57,66,68,35,84,4,103,-25,91,-42,78,-58,66,-74,42,-102,42,-111,59,-99,89,-73,117,-43,143,-73,158,-86,174,-99,190,-111,16383,16383,152,127,151,98,146,70,138,45,128,20,116,-2,104,20,95,45,87,71,82,98,80,127,82,155,87,182,95,208,105,233,117,256,128,233,138,208,146,182,151,155,152,127,319,22,300,49,273,71,242,87,207,96,174,100,198,155,227,162,255,173,281,188,303,208,319,232,319,249,302,230,283,215,261,204,237,195,213,190,254,286,228,286,184,186,171,186,138,188,105,195,75,206,47,224,24,249,24,232,43,204,69,182,101,166,135,156,170,153,146,98,116,92,88,81,61,65,40,46,24,22,24,4,40,22,60,38,82,49,106,58,131,64,89,-32,116,-32,159,66,161,67,171,67,204,65,237,58,268,46,295,28,319,4,310,-12,310,18,171,88,214,185,310,233,310,266,232,228,277,331,250,331,198,211,28,128,28,123,137,71,71,-77,99,-77,158,60,16383,16383,179,168,148,99,94,126,310,123,310,128,203,181,268,331,241,331, +130,278,142,296,143,326,143,326,142,296,154,312,143,326,154,312,158,340,158,340,154,312,167,328,158,340,167,328,174,353,174,353,167,328,179,342,174,353,179,342,190,365,190,365,179,342,190,355,117,296,103,312,105,233,117,296,105,233,117,256,117,256,128,233,130,312,130,312,128,233,130,278,130,312,130,278,143,326,116,-2,117,-43,128,20,128,20,117,-43,130,-58,128,20,130,-58,130,-25,130,-25,130,-58,143,-73,130,-25,138,45,128,20,183,97,183,156,176,66,176,66,183,156,176,187,176,66,176,187,165,35,165,35,176,187,164,218,165,35,164,218,152,127,152,127,164,218,151,155,149,248,130,278,138,208,149,248,138,208,146,182,149,248,146,182,151,155,149,248,151,155,164,218,130,312,117,296,117,256,165,35,152,127,151,98,165,35,151,98,149,4,149,4,151,98,146,70,149,4,146,70,138,45,142,-42,143,-73,154,-59,154,-59,143,-73,158,-86,154,-59,158,-86,167,-74,167,-74,158,-86,174,-99,167,-74,174,-99,179,-89,179,-89,174,-99,190,-111,179,-89,190,-111,190,-102,105,233,103,312,103,278,103,278,103,312,91,296,91,296,103,312,89,326,91,296,89,326,78,313,78,313,89,326,74,340,78,313,74,340,66,329,66,329,74,340,59,353,66,329,59,353,54,343,54,343,59,353,42,365,54,343,42,365,42,357,103,-58,103,-25,91,-42,103,-58,91,-42,89,-73,89,-73,91,-42,78,-58,89,-73,78,-58,74,-86,74,-86,78,-58,66,-74,74,-86,66,-74,59,-99,59,-99,66,-74,54,-88,59,-99,54,-88,42,-102,104,20,95,45,103,-25,104,20,103,-25,103,-58,104,20,103,-58,117,-43,104,20,117,-43,116,-2,103,278,84,249,87,182,103,278,87,182,95,208,103,278,95,208,105,233,84,249,68,218,68,35,84,249,68,35,80,127,84,249,80,127,82,155,84,249,82,155,87,182,87,71,82,98,84,4,84,4,82,98,80,127,68,35,68,218,57,66,57,66,68,218,57,187,57,66,57,187,50,97,50,97,57,187,50,156,50,97,50,156,47,127,87,71,84,4,103,-25,87,71,103,-25,95,45,84,4,80,127,68,35,59,-99,42,-102,42,-111,130,-25,143,-73,142,-42,138,45,130,-25,149,4,183,156,183,97,185,127,130,278,128,233,138,208, +319,22,300,49,273,71,242,87,207,96,174,100,198,155,227,162,255,173,281,188,303,208,319,232,319,249,302,230,283,215,261,204,237,195,213,190,254,286,228,286,184,186,171,186,138,188,105,195,75,206,47,224,24,249,24,232,43,204,69,182,101,166,135,156,170,153,146,98,116,92,88,81,61,65,40,46,24,22,24,4,40,22,60,38,82,49,106,58,131,64,89,-32,116,-32,159,66,161,67,171,67,204,65,237,58,268,46,295,28,319,4,310,-12,310,18,171,88,214,185,310,233,310,266,232,228,277,331,250,331,198,211,28,128,28,123,137,71,71,-77,99,-77,158,60,16383,16383,179,168,148,99,94,126,310,123,310,128,203,181,268,331,241,331,180,192,28,266,28,233,168,164,126,68,28,18,28,-12,108,26,63,-77,89,-77,142,42,16383,16383,244,126,161,84,190,153,310,-50,310,-17,129,-17,171,92,310,25,310,56,181,120,220,226,310,271,310,304,236,267,272,365,246,365,203,251,28,166, +40,22,60,38,61,65,61,65,60,38,82,49,61,65,82,49,88,81,88,81,82,49,106,58,88,81,106,58,116,92,116,92,106,58,131,64,146,98,131,64,159,66,146,98,159,66,170,153,170,153,159,66,161,67,170,153,161,67,164,67,40,22,61,65,40,46,40,22,40,46,24,22,40,22,24,22,24,4,135,156,170,153,138,188,138,188,170,153,171,186,173,186,171,186,171,67,173,186,171,67,174,100,174,100,171,67,204,65,174,100,204,65,207,96,207,96,204,65,237,58,207,96,237,58,242,87,242,87,237,58,268,46,242,87,268,46,273,71,273,71,268,46,295,28,273,71,295,28,300,49,300,49,295,28,319,4,300,49,319,4,319,22,24,249,43,204,47,224,47,224,43,204,69,182,47,224,69,182,75,206,75,206,69,182,101,166,75,206,101,166,105,195,105,195,101,166,135,156,105,195,135,156,138,188,171,67,171,186,170,153,171,67,170,153,168,67,170,153,164,67,166,67,170,153,166,67,168,67,131,64,89,-32,116,-32,131,64,116,-32,159,66,319,249,302,230,303,208,303,208,302,230,283,215,303,208,283,215,281,188,281,188,283,215,261,204,281,188,261,204,255,173,255,173,261,204,237,195,255,173,237,195,227,162,227,162,237,195,213,190,227,162,213,190,198,155,228,286,184,186,198,155,228,286,198,155,213,190,228,286,213,190,254,286,198,155,184,186,181,186,198,155,181,186,179,186,198,155,179,186,176,186,198,155,176,186,174,100,176,186,173,186,174,100,43,204,24,249,24,232,319,249,303,208,319,232,116,92,131,64,146,98, +310,-12,310,18,171,88,214,185,310,233,310,266,232,228,277,331,250,331,198,211,28,128,28,123,137,71,71,-77,99,-77,158,60,16383,16383,179,168,148,99,94,126,310,123,310,128,203,181,268,331,241,331,180,192,28,266,28,233,168,164,126,68,28,18,28,-12,108,26,63,-77,89,-77,142,42,16383,16383,244,126,161,84,190,153, +198,211,28,128,94,126,94,126,28,128,137,71,94,126,137,71,148,99,148,99,137,71,158,60,148,99,158,60,179,168,179,168,158,60,171,88,179,168,171,88,214,185,94,126,179,168,198,211,198,211,179,168,214,185,198,211,214,185,250,331,250,331,214,185,232,228,250,331,232,228,277,331,137,71,71,-77,99,-77,137,71,99,-77,158,60,232,228,214,185,310,233,232,228,310,233,310,266,171,88,158,60,310,-12,171,88,310,-12,310,18,137,71,28,128,28,123, +310,123,310,128,203,181,268,331,241,331,180,192,28,266,28,233,168,164,126,68,28,18,28,-12,108,26,63,-77,89,-77,142,42,16383,16383,244,126,161,84,190,153,310,-50,310,-17,129,-17,171,92,310,25,310,56,181,120,220,226,310,271,310,304,236,267,272,365,246,365,203,251,28,166,28,161,147,103,103,-17,28,-17,28,-50, +108,26,63,-77,89,-77,108,26,89,-77,142,42,108,26,142,42,126,68,108,26,126,68,28,18,108,26,28,18,28,-12,168,164,126,68,142,42,168,164,142,42,161,84,168,164,161,84,190,153,168,164,190,153,180,192,168,164,180,192,28,266,168,164,28,266,28,233,203,181,268,331,241,331,203,181,241,331,190,153,203,181,190,153,244,126,203,181,244,126,310,128,310,123,310,128,244,126,310,123,244,126,161,84,310,123,161,84,142,42,180,192,190,153,241,331, +320,0,320,33,190,33,190,331,157,331,157,33,26,33,26,0,313,126,309,150,298,171,281,188,260,199,235,203,211,199,189,188, +190,331,157,331,190,33,190,33,157,331,157,33,190,33,157,33,320,0,320,0,157,33,26,33,320,0,26,33,26,0,190,33,320,0,320,33 +}; diff --git a/src/eval.cpp b/src/eval.cpp new file mode 100644 index 0000000..ee3ee8b --- /dev/null +++ b/src/eval.cpp @@ -0,0 +1,738 @@ +/*************************************************************************** + * eval.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include + +#include "mgl2/data_cf.h" +#include "mgl2/eval.h" + +#if MGL_HAVE_GSL +#include +#include +#include +#endif +//----------------------------------------------------------------------------- +// constants for expression parsing +enum{ +EQ_NUM=0, // a variable substitution +EQ_RND, // random number +EQ_A, // numeric constant +// normal functions of 2 arguments +EQ_LT, // comparison xy +EQ_EQ, // comparison x=y +EQ_OR, // comparison x|y +EQ_AND, // comparison x&y +EQ_ADD, // addition x+y +EQ_SUB, // substraction x-y +EQ_MUL, // multiplication x*y +EQ_DIV, // division x/y +EQ_IPOW, // power x^n for integer n +EQ_POW, // power x^y +EQ_MOD, // x modulo y +EQ_LOG, // logarithm of x on base a, log_a(x) = ln(x)/ln(a) +EQ_ARG, // argument of complex number arg(x,y) = atan2(x,y) +EQ_HYPOT, // sqrt(x^2+y^2)=hypot(x,y) +// special functions of 2 arguments +EQ_BESJ, // regular cylindrical Bessel function of fractional order +EQ_BESY, // irregular cylindrical Bessel function of fractional order +EQ_BESI, // regular modified Bessel function of fractional order +EQ_BESK, // irregular modified Bessel function of fractional order +EQ_ELE, // elliptic integral E(\phi,k) = \int_0^\phi dt \sqrt((1 - k^2 \sin^2(t))) +EQ_ELF, // elliptic integral F(\phi,k) = \int_0^\phi dt 1/\sqrt((1 - k^2 \sin^2(t))) +EQ_LP, // Legendre polynomial P_l(x), (|x|<=1, l>=0) +EQ_BETA, // beta function B(x,y) = Gamma(x)*Gamma(y)/Gamma(x+y) +// normal functions of 1 argument +EQ_SIN, // sine function \sin(x). !!! MUST BE FIRST 1-PLACE FUNCTION +EQ_COS, // cosine function \cos(x). +EQ_TAN, // tangent function \tan(x). +EQ_ASIN, // inverse sine function \sin(x). +EQ_ACOS, // inverse cosine function \sin(x). +EQ_ATAN, // inverse tangent function \tan(x). +EQ_SINH, // hyperbolic sine function \sin(x). +EQ_COSH, // hyperbolic cosine function \sin(x). +EQ_TANH, // hyperbolic tangent function \tan(x). +EQ_ASINH, // inverse hyperbolic sine function \sin(x). +EQ_ACOSH, // inverse hyperbolic cosine function \sin(x). +EQ_ATANH, // inverse hyperbolic tangent function \tan(x). +EQ_SQRT, // square root function \sqrt(x) +EQ_EXP, // exponential function \exp(x) +EQ_LN, // logarithm of x, ln(x) +EQ_LG, // decimal logarithm of x, lg(x) = ln(x)/ln(10) +EQ_SIGN, // sign of number +EQ_STEP, // step function +EQ_INT, // integer part [x] +EQ_ABS, // absolute value of x +// special functions of 1 argument +EQ_LI2, // dilogarithm for a real argument Li2(x) = - \Re \int_0^x ds \log(1-s)/s. +EQ_ELLE, // complete elliptic integral is denoted by E(k) = E(\pi/2, k). +EQ_ELLK, // complete elliptic integral is denoted by K(k) = F(\pi/2, k). +EQ_AI, // Airy function Ai(x) +EQ_BI, // Airy function Bi(x) +EQ_ERF, // error function erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2). +EQ_EI3, // exponential integral Ei_3(x) = \int_0^x dt \exp(-t^3) for x >= 0. +EQ_EI, // exponential integral Ei(x), Ei(x) := - PV(\int_{-x}^\infty dt \exp(-t)/t), where PV denotes the principal value of the integral. +EQ_E1, // exponential integral E_1(x), E_1(x) := Re \int_1^\infty dt \exp(-xt)/t. +EQ_E2, // exponential integral E_2(x), E_2(x) := Re \int_1^\infty dt \exp(-xt)/t^2. +EQ_SI, // Sine integral Si(x) = \int_0^x dt \sin(t)/t. +EQ_CI, // Cosine integral Ci(x) = \int_0^x dt \cos(t)/t. +EQ_GAMMA, // Gamma function \Gamma(x) = \int_0^\infty dt t^{x-1} \exp(-t) +EQ_PSI, // digamma function \psi(x) = \Gamma'(x)/\Gamma(x) for general x, x \ne 0. +EQ_W0, // principal branch of the Lambert W function, W_0(x). Functions W(x), are defined to be solutions of the equation W\exp(W) = x. +EQ_W1, // secondary real-valued branch of the Lambert W function, W_{-1}(x). Functions W(x), are defined to be solutions of the equation W\exp(W) = x. +EQ_SINC, // compute \sinc(x) = \sin(\pi x) / (\pi x) for any value of x. +EQ_ZETA, // Riemann zeta function \zeta(s) = \sum_{k=1}^\infty k^{-s}for arbitrary s, s \ne 1. +EQ_ETA, // eta function \eta(s) = (1-2^{1-s}) \zeta(s) for arbitrary s. +EQ_AID, // Derivative of Airy function Ai(x) +EQ_BID, // Derivative of Airy function Bi(x) +EQ_Z, // Dawson function \exp(-x^2) \int_0^x dt \exp(t^2) +// Jacoby functions of 2 arguments +EQ_SN, // Jacobian elliptic function sn(u|m) // !!! MUST BE FIRST NON 1-PLACE FUNCTION +EQ_SC, // Jacobian elliptic function sn(u|m)/cn(u|m) +EQ_SD, // Jacobian elliptic function sn(u|m)/dn(u|m) +EQ_NS, // Jacobian elliptic function 1/sn(u|m) +EQ_NC, // Jacobian elliptic function 1/cn(u|m) +EQ_ND, // Jacobian elliptic function 1/dn(u|m) +EQ_CN, // Jacobian elliptic function cn(u|m) +EQ_CS, // Jacobian elliptic function cn(u|m)/sn(u|m) +EQ_CD, // Jacobian elliptic function cn(u|m)/dn(u|m) +EQ_DN, // Jacobian elliptic function dn(u|m) +EQ_DS, // Jacobian elliptic function dn(u|m)/sn(u|m) +EQ_DC, // Jacobian elliptic function dn(u|m)/cn(u|m) + // MUST BE LAST ELLIPTIC FUNCTION +// not-ready +EQ_EN, +EQ_CL // Clausen function +}; +//----------------------------------------------------------------------------- +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif +//----------------------------------------------------------------------------- +int mglFormula::Error=0; +bool mglCheck(char *str,int n); +int mglFindInText(char *str,const char *lst); +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +MGL_NO_EXPORT gsl_rng *mgl_rng=0; // NOTE: should be deleted by gsl_rng_free() but I don't know where :( +#endif +void MGL_EXPORT mgl_srnd(long seed) +{ +#if MGL_HAVE_GSL + if(mgl_rng==0) + { + gsl_rng_env_setup(); + mgl_rng = gsl_rng_alloc(gsl_rng_default); + } + gsl_rng_set(mgl_rng, seed); +#else + srand(seed); +#endif +} +void MGL_EXPORT mgl_srnd_(int *seed) { mgl_srnd(*seed); } +//----------------------------------------------------------------------------- +double MGL_EXPORT mgl_hypot(double x, double y) { return hypot(x,y); } +//----------------------------------------------------------------------------- +#if MGL_HAVE_PTHREAD +pthread_mutex_t mutexRnd; +#endif +double MGL_EXPORT mgl_rnd() +{ +#if MGL_HAVE_PTHREAD + pthread_mutex_lock(&mutexRnd); +#endif + double res; +#pragma omp critical(rnd) + { +#if MGL_HAVE_GSL + if(mgl_rng==0) + { + gsl_rng_env_setup(); + mgl_rng = gsl_rng_alloc(gsl_rng_default); + gsl_rng_set(mgl_rng, time(0)); + } + res = gsl_rng_uniform(mgl_rng); +// gsl_rng_free(r); +#else + res = rand()/(RAND_MAX-1.); +#endif + } +#if MGL_HAVE_PTHREAD + pthread_mutex_unlock(&mutexRnd); +#endif + return res; +} +double MGL_EXPORT mgl_rnd_() { return mgl_rnd(); } +//----------------------------------------------------------------------------- +mglFormula::~mglFormula() +{ + if(Left) delete Left; + if(Right) delete Right; +} +//----------------------------------------------------------------------------- +// Formula constructor (automatically parse and "compile" formula) +mglFormula::mglFormula(const char *string) +{ +#if MGL_HAVE_GSL + gsl_set_error_handler_off(); +#endif + Error=0; + Left=Right=0; + Res=0; Kod=0; + if(!string) { Kod = EQ_NUM; Res = 0; return; } + char *str = new char[strlen(string)+1]; + strcpy(str,string); + long n,len; + mgl_strtrim(str); + mgl_strlwr(str); + len=strlen(str); + if(str[0]==0) { delete []str; return; } + if(str[0]=='(' && mglCheck(str+1,len-2)) // remove braces + { + memmove(str,str+1,len); + len-=2; str[len]=0; + } + len=strlen(str); + n=mglFindInText(str,"&|"); // lowest priority -- logical + if(n>=0) + { + if(str[n]=='|') Kod=EQ_OR; else Kod=EQ_AND; + str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"<>="); // low priority -- conditions + if(n>=0) + { + if(str[n]=='<') Kod=EQ_LT; + else if(str[n]=='>') Kod=EQ_GT; + else Kod=EQ_EQ; + str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"+-"); // normal priority -- additions + if(n>=0 && (n<2 || str[n-1]!='e' || (str[n-2]!='.' && !isdigit(str[n-2])))) + { + if(str[n]=='+') Kod=EQ_ADD; else Kod=EQ_SUB; + str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"*/"); // high priority -- multiplications + if(n>=0) + { + if(str[n]=='*') Kod=EQ_MUL; else Kod=EQ_DIV; + str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"^"); // highest priority -- power + if(n>=0) + { + Kod=EQ_IPOW; str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + delete []str; return; + } + + for(n=0;n=len) // this is number or variable + { + Kod = EQ_NUM; +// Left = Right = 0; + if(str[1]==0 && str[0]>='a' && str[0]<='z') // available variables + { Kod=EQ_A; Res = str[0]-'a'; } + else if(!strcmp(str,"rnd")) Kod=EQ_RND; + else if(!strcmp(str,"pi")) Res=M_PI; + else Res=atof(str); // this is number + } + else + { + char name[128]; + strncpy(name,str,128); name[127]=name[n]=0; + memmove(str,str+n+1,len-n); + len=strlen(str); str[--len]=0; + if(!strncmp(name,"jacobi_",7)) + memmove(name,name+7,(strlen(name+7)+1)*sizeof(char)); + if(name[0]=='a') + { + if(!strcmp(name+1,"sin")) Kod=EQ_ASIN; + else if(!strcmp(name+1,"cos")) Kod=EQ_ACOS; + else if(!strcmp(name+1,"tan")) Kod=EQ_ATAN; + else if(!strcmp(name+1,"sinh")) Kod=EQ_ASINH; + else if(!strcmp(name+1,"cosh")) Kod=EQ_ACOSH; + else if(!strcmp(name+1,"tanh")) Kod=EQ_ATANH; + else if(!strcmp(name+1,"rg")) Kod=EQ_ARG; + else if(!strcmp(name+1,"bs")) Kod=EQ_ABS; + else if(!strcmp(name+1,"i")) Kod=EQ_AI; + else if(!strcmp(name+1,"iry_ai")) Kod=EQ_AI; + else if(!strcmp(name+1,"iry_bi")) Kod=EQ_BI; + else if(!strcmp(name+1,"iry_dai")) Kod=EQ_AID; + else if(!strcmp(name+1,"iry_dbi")) Kod=EQ_BID; + } + else if(name[0]=='b') + { + if(!strcmp(name+1,"i")) Kod=EQ_BI; + else if(!strcmp(name+1,"essel_j")) Kod=EQ_BESJ; + else if(!strcmp(name+1,"essel_i")) Kod=EQ_BESI; + else if(!strcmp(name+1,"essel_k")) Kod=EQ_BESK; + else if(!strcmp(name+1,"essel_y")) Kod=EQ_BESY; + else if(!strcmp(name+1,"eta")) Kod=EQ_BETA; + } + else if(name[0]=='c') + { + if(!strcmp(name+1,"os")) Kod=EQ_COS; + else if(!strcmp(name+1,"osh")) Kod=EQ_COSH; + else if(!strcmp(name+1,"h")) Kod=EQ_COSH; + else if(!strcmp(name+1,"i")) Kod=EQ_CI; + else if(!strcmp(name+1,"n")) Kod=EQ_CN; + else if(!strcmp(name+1,"s")) Kod=EQ_CS; + else if(!strcmp(name+1,"d")) Kod=EQ_CD; + else if(!strcmp(name+1,"l")) Kod=EQ_CL; + } + else if(name[0]=='d') + { + if(!strcmp(name+1,"n")) Kod=EQ_DN; + else if(!strcmp(name+1,"s")) Kod=EQ_DS; + else if(!strcmp(name+1,"c")) Kod=EQ_DC; + else if(!strcmp(name+1,"ilog")) Kod=EQ_LI2; + } + else if(name[0]=='e') + { + if(!strcmp(name+1,"xp")) Kod=EQ_EXP; + else if(!strcmp(name+1,"rf")) Kod=EQ_ERF; + else if(!strcmp(name+1,"n")) Kod=EQ_EN; + else if(!strcmp(name+1,"e")) Kod=EQ_ELLE; + else if(!strcmp(name+1,"k")) Kod=EQ_ELLK; + else if(name[0]==0) Kod=EQ_ELE; + else if(!strcmp(name+1,"i")) Kod=EQ_EI; + else if(!strcmp(name+1,"1")) Kod=EQ_E1; + else if(!strcmp(name+1,"2")) Kod=EQ_E2; + else if(!strcmp(name+1,"ta")) Kod=EQ_ETA; + else if(!strcmp(name+1,"i3")) Kod=EQ_EI3; + else if(!strcmp(name+1,"lliptic_e")) Kod=EQ_ELE; + else if(!strcmp(name+1,"lliptic_f")) Kod=EQ_ELF; + else if(!strcmp(name+1,"lliptic_ec")) Kod=EQ_ELLE; + else if(!strcmp(name+1,"lliptic_kc")) Kod=EQ_ELLK; + } + else if(name[0]=='l') + { + if(!strcmp(name+1,"og")) Kod=EQ_LOG; + else if(!strcmp(name+1,"g")) Kod=EQ_LG; + else if(!strcmp(name+1,"n")) Kod=EQ_LN; + else if(!strcmp(name+1,"i2")) Kod=EQ_LI2; + else if(!strcmp(name+1,"egendre")) Kod=EQ_LP; + } + else if(name[0]=='s') + { + if(!strcmp(name+1,"qrt")) Kod=EQ_SQRT; + else if(!strcmp(name+1,"in")) Kod=EQ_SIN; + else if(!strcmp(name+1,"tep")) Kod=EQ_STEP; + else if(!strcmp(name+1,"ign")) Kod=EQ_SIGN; + else if(!strcmp(name+1,"inh")) Kod=EQ_SINH; + else if(!strcmp(name+1,"h")) Kod=EQ_SINH; + else if(!strcmp(name+1,"i")) Kod=EQ_SI; + else if(!strcmp(name+1,"n")) Kod=EQ_SN; + else if(!strcmp(name+1,"c")) Kod=EQ_SC; + else if(!strcmp(name+1,"d")) Kod=EQ_SD; + else if(!strcmp(name+1,"inc")) Kod=EQ_SINC; + } + else if(name[0]=='t') + { + if(!strcmp(name+1,"g")) Kod=EQ_TAN; + else if(!strcmp(name+1,"an")) Kod=EQ_TAN; + else if(!strcmp(name+1,"anh")) Kod=EQ_TANH; + else if(!strcmp(name+1,"h")) Kod=EQ_TANH; + } + else if(!strcmp(name,"hypot")) Kod=EQ_HYPOT; + else if(!strcmp(name,"pow")) Kod=EQ_POW; + else if(!strcmp(name,"mod")) Kod=EQ_MOD; + else if(!strcmp(name,"i")) Kod=EQ_BESI; + else if(!strcmp(name,"int")) Kod=EQ_INT; + else if(!strcmp(name,"j")) Kod=EQ_BESJ; + else if(!strcmp(name,"k")) Kod=EQ_BESK; + else if(!strcmp(name,"y")) Kod=EQ_BESY; + else if(!strcmp(name,"f")) Kod=EQ_ELF; + else if(!strcmp(name,"gamma")) Kod=EQ_GAMMA; + else if(!strcmp(name,"ns")) Kod=EQ_NS; + else if(!strcmp(name,"nc")) Kod=EQ_NC; + else if(!strcmp(name,"nd")) Kod=EQ_ND; + else if(!strcmp(name,"w0")) Kod=EQ_W0; + else if(!strcmp(name,"w1")) Kod=EQ_W1; + else if(!strcmp(name,"psi")) Kod=EQ_PSI; + else if(!strcmp(name,"zeta")) Kod=EQ_ZETA; + else if(!strcmp(name,"z")) Kod=EQ_Z; + else { delete []str; return; } // unknown function + n=mglFindInText(str,","); + if(n>=0) + { + str[n]=0; + Left=new mglFormula(str); + Right=new mglFormula(str+n+1); + } + else Left=new mglFormula(str); + } + delete []str; +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n'='v', 't'='z', 'u'='a' variables +mreal mglFormula::Calc(mreal x,mreal y,mreal t,mreal u) const +{ + Error=0; + mreal a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(mreal)); + a1['a'-'a'] = a1['c'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = a1['v'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + return CalcIn(a1); +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n', 't'='z', 'u'='a', 'v'='b', 'w'='c' variables +mreal mglFormula::Calc(mreal x,mreal y,mreal t,mreal u,mreal v,mreal w) const +{ + Error=0; + mreal a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(mreal)); + a1['c'-'a'] = a1['w'-'a'] = w; + a1['b'-'a'] = a1['v'-'a'] = v; + a1['a'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + return CalcIn(a1); +} +//----------------------------------------------------------------------------- +// evaluate formula for arbitrary set of variables +mreal mglFormula::Calc(const mreal var[MGL_VS]) const +{ + Error=0; + return CalcIn(var); +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n'='v', 't'='z', 'u'='a' variables +mreal mglFormula::CalcD(char diff,mreal x,mreal y,mreal t,mreal u) const +{ + Error=0; + mreal a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(mreal)); + a1['a'-'a'] = a1['c'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = a1['v'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + return CalcDIn(diff-'a', a1); +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n', 't'='z', 'u'='a', 'v'='b', 'w'='c' variables +mreal mglFormula::CalcD(char diff,mreal x,mreal y,mreal t,mreal u,mreal v,mreal w) const +{ + Error=0; + mreal a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(mreal)); + a1['c'-'a'] = a1['w'-'a'] = w; + a1['b'-'a'] = a1['v'-'a'] = v; + a1['a'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + return CalcDIn(diff-'a', a1); +} +//----------------------------------------------------------------------------- +// evaluate derivate of formula respect to 'diff' variable for arbitrary set of other variables +mreal mglFormula::CalcD(const mreal var[MGL_VS], char diff) const +{ + Error=0; + return CalcDIn(diff-'a', var); +} +//----------------------------------------------------------------------------- +double MGL_NO_EXPORT cand(double a,double b) {return a&&b?1:0;} +double MGL_NO_EXPORT cor(double a,double b) {return a||b?1:0;} +double MGL_NO_EXPORT ceq(double a,double b) {return a==b?1:0;} +double MGL_NO_EXPORT clt(double a,double b) {return ab?1:0;} +double MGL_NO_EXPORT add(double a,double b) {return a+b;} +double MGL_NO_EXPORT sub(double a,double b) {return a-b;} +double MGL_NO_EXPORT mul(double a,double b) {return a&&b?a*b:0;} +double MGL_NO_EXPORT del(double a,double b) {return b?a/b:NAN;} +double MGL_NO_EXPORT ipw(double a,double b) {return fabs(b-int(b))<1e-5 ? mgl_ipow(a,int(b)) : pow(a,b);} +double MGL_NO_EXPORT llg(double a,double b) {return log(a)/log(b);} +#if MGL_HAVE_GSL +double MGL_NO_EXPORT gslEllE(double a,double b) {return gsl_sf_ellint_E(a,b,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslEllF(double a,double b) {return gsl_sf_ellint_F(a,b,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslLegP(double a,double b) {return gsl_sf_legendre_Pl(int(a),b);} +double MGL_NO_EXPORT gslEllEc(double a) {return gsl_sf_ellint_Ecomp(a,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslEllFc(double a) {return gsl_sf_ellint_Kcomp(a,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslAi(double a) {return gsl_sf_airy_Ai(a,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslBi(double a) {return gsl_sf_airy_Bi(a,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslAi_d(double a) {return gsl_sf_airy_Ai_deriv(a,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslBi_d(double a) {return gsl_sf_airy_Bi_deriv(a,GSL_PREC_SINGLE);} +#endif +double MGL_NO_EXPORT sgn(double a) {return a<0 ? -1:(a>0?1:0);} +double MGL_NO_EXPORT stp(double a) {return a>0 ? 1:0;} +double MGL_NO_EXPORT arg(double a,double b) { return atan2(b,a); } +double MGL_NO_EXPORT mgz1(double) {return 0;} +double MGL_NO_EXPORT mgz2(double,double) {return 0;} +#ifdef WIN32 +double MGL_NO_EXPORT asinh(double x) { return log(x+sqrt(x*x+1.)); } +double MGL_NO_EXPORT acosh(double x) { return x>1 ? log(x+sqrt(x*x-1.)) : NAN; } +double MGL_NO_EXPORT atanh(double x) { return fabs(x)<1 ? log((1.+x)/(1.-x))/2 : NAN; } +#endif +//----------------------------------------------------------------------------- +typedef double (*func_1)(double); +typedef double (*func_2)(double, double); +// evaluation of embedded (included) expressions +mreal mglFormula::CalcIn(const mreal *a1) const +{ + mreal z2[EQ_SIN-EQ_LT] = {3,3,3,3,0,3,3,0,0,0,0,0,NAN,0 +#if MGL_HAVE_GSL + ,3,NAN, 3,NAN, 0,0,3,1 +#else + ,0,0,0,0,0,0,0,0 +#endif + }; + func_2 f2[EQ_SIN-EQ_LT] = {clt,cgt,ceq,cor,cand,add,sub,mul,del,ipw,pow,fmod,llg,arg,hypot +#if MGL_HAVE_GSL + ,gsl_sf_bessel_Jnu,gsl_sf_bessel_Ynu, + gsl_sf_bessel_Inu,gsl_sf_bessel_Knu, + gslEllE,gslEllF,gslLegP,gsl_sf_beta +#else + ,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2 +#endif + }; + func_1 f1[EQ_SN-EQ_SIN] = {sin,cos,tan,asin,acos,atan,sinh,cosh,tanh, + asinh,acosh,atanh,sqrt,exp,log,log10,sgn,stp,floor,fabs +#if MGL_HAVE_GSL + ,gsl_sf_dilog,gslEllEc,gslEllFc,gslAi,gslBi,gsl_sf_erf, + gsl_sf_expint_3,gsl_sf_expint_Ei,gsl_sf_expint_E1,gsl_sf_expint_E2, + gsl_sf_Si,gsl_sf_Ci,gsl_sf_gamma,gsl_sf_psi,gsl_sf_lambert_W0, + gsl_sf_lambert_Wm1,gsl_sf_sinc,gsl_sf_zeta,gsl_sf_eta,gslAi_d,gslBi_d, + gsl_sf_dawson +#else + ,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1, + mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1 +#endif + }; +// if(Error) return 0; + if(KodCalcIn(a1); + if(mgl_isfin(a)) + { + if(KodCalcIn(a1); + b = mgl_isfin(b) ? f2[Kod-EQ_LT](a,b):NAN; + return mgl_isfin(b) ? b : NAN; + } + else if(KodCalcIn(a1); + if(mgl_isbad(b)) return NAN; + gsl_sf_elljac_e(a,b, &sn, &cn, &dn); + switch(Kod) + { + case EQ_SN: return sn; + case EQ_SC: return sn/cn; + case EQ_SD: return sn/dn; + case EQ_CN: return cn; + case EQ_CS: return cn/sn; + case EQ_CD: return cn/dn; + case EQ_DN: return dn; + case EQ_DS: return dn/sn; + case EQ_DC: return dn/cn; + case EQ_NS: return 1./sn; + case EQ_NC: return 1./cn; + case EQ_ND: return 1./dn; + } + } +#endif + } + return NAN; +} +//----------------------------------------------------------------------------- +double MGL_NO_EXPORT mgp(double ,double ) {return 1;} +double MGL_NO_EXPORT mgm(double ,double ) {return -1;} +double MGL_NO_EXPORT mul1(double ,double b) {return b;} +double MGL_NO_EXPORT mul2(double a,double ) {return a;} +double MGL_NO_EXPORT div1(double ,double b) {return b?1/b:NAN;} +double MGL_NO_EXPORT div2(double a,double b) {return b?-a/(b*b):NAN;} +double MGL_NO_EXPORT ipw1(double a,double b) {return b*(fabs(b-int(b))<1e-5 ? mgl_ipow(a,int(b-1)) : pow(a,b-1));} +double MGL_NO_EXPORT pow1(double a,double b) {return b*pow(a,b-1);} +double MGL_NO_EXPORT pow2(double a,double b) {return log(a)*pow(a,b);} +double MGL_NO_EXPORT llg1(double a,double b) {return 1/(a*log(b));} +double MGL_NO_EXPORT llg2(double a,double b) {return -log(a)/(b*log(b)*log(b));} +double MGL_NO_EXPORT cos_d(double a) {return -sin(a);} +double MGL_NO_EXPORT tan_d(double a) {return 1./(cos(a)*cos(a));} +double MGL_NO_EXPORT asin_d(double a) {return 1./sqrt(1.-a*a);} +double MGL_NO_EXPORT acos_d(double a) {return -1./sqrt(1.-a*a);} +double MGL_NO_EXPORT atan_d(double a) {return 1./(1.+a*a);} +double MGL_NO_EXPORT tanh_d(double a) {return 1./(cosh(a)*cosh(a));} +double MGL_NO_EXPORT atanh_d(double a){return 1./(1.-a*a);} +double MGL_NO_EXPORT asinh_d(double a){return 1./sqrt(1.+a*a);} +double MGL_NO_EXPORT acosh_d(double a){return 1./sqrt(a*a-1.);} +double MGL_NO_EXPORT sqrt_d(double a) {return 0.5/sqrt(a);} +double MGL_NO_EXPORT log10_d(double a){return M_LN10/a;} +double MGL_NO_EXPORT log_d(double a) {return 1./a;} +double MGL_NO_EXPORT erf_d(double a) {return 2*exp(-a*a)/sqrt(M_PI);} +double MGL_NO_EXPORT dilog_d(double a){return log(a)/(1.-a);} +double MGL_NO_EXPORT ei_d(double a) {return exp(a)/a;} +double MGL_NO_EXPORT si_d(double a) {return a?sin(a)/a:1;} +double MGL_NO_EXPORT ci_d(double a) {return cos(a)/a;} +double MGL_NO_EXPORT exp3_d(double a) {return exp(-a*a*a);} +double MGL_NO_EXPORT e1_d(double a) {return exp(-a)/a;} +double MGL_NO_EXPORT sinc_d(double a) {return a ? (cos(M_PI*a)/a-sin(M_PI*a)/(M_PI*a*a)) : 0;} +#if MGL_HAVE_GSL +double MGL_NO_EXPORT e2_d(double a) {return -gsl_sf_expint_E1(a);} +double MGL_NO_EXPORT gslJnuD(double a,double b) {return 0.5*(gsl_sf_bessel_Jnu(a-1,b)-gsl_sf_bessel_Jnu(a+1,b));} +double MGL_NO_EXPORT gslYnuD(double a,double b) {return 0.5*(gsl_sf_bessel_Ynu(a-1,b)-gsl_sf_bessel_Ynu(a+1,b));} +double MGL_NO_EXPORT gslKnuD(double a,double b) {return -(a*gsl_sf_bessel_Knu(a,b)/b +gsl_sf_bessel_Knu(a-1,b));} +double MGL_NO_EXPORT gslInuD(double a,double b) {return -(a*gsl_sf_bessel_Inu(a,b)/b -gsl_sf_bessel_Inu(a-1,b));} +double MGL_NO_EXPORT gslEllE1(double a,double b) {return sqrt(1.-sin(a)*sin(a)*b);} +double MGL_NO_EXPORT gslEllE2(double a,double b) {return (gsl_sf_ellint_E(a,b,GSL_PREC_SINGLE) - gsl_sf_ellint_F(a,b,GSL_PREC_SINGLE))/(2.*b);} +double MGL_NO_EXPORT gslEllF1(double a,double b) {return 1./sqrt(1.-sin(a)*sin(a)*b);} +double MGL_NO_EXPORT gslEllF2(double a,double b) {return (gsl_sf_ellint_E(a,b,GSL_PREC_SINGLE) - gsl_sf_ellint_F(a,b,GSL_PREC_SINGLE)*(1.-b))/(2*b*(1.-b)) - sin(2.*a)/(sqrt(1.-sin(a)*sin(a)*b)*2.*(1.-b));} +double MGL_NO_EXPORT gslE_d(double a) {return (gsl_sf_ellint_Ecomp(a,GSL_PREC_SINGLE) - gsl_sf_ellint_Kcomp(a,GSL_PREC_SINGLE))/(2.*a);} +double MGL_NO_EXPORT gslK_d(double a) {return (gsl_sf_ellint_Ecomp(a,GSL_PREC_SINGLE) - (1.-a)*gsl_sf_ellint_Kcomp(a,GSL_PREC_SINGLE))/(2.*a*(1.-a));} +double MGL_NO_EXPORT gamma_d(double a) {return gsl_sf_psi(a)*gsl_sf_gamma(a);} +#endif +//----------------------------------------------------------------------------- +// evaluation of derivative of embedded (included) expressions +mreal mglFormula::CalcDIn(int id, const mreal *a1) const +{ + func_2 f21[EQ_SIN-EQ_LT] = {mgz2,mgz2,mgz2, mgz2,mgz2,mgp, mgp,mul1,div1, ipw1,pow1,mgp,llg1, mgz2 +#if MGL_HAVE_GSL + ,mgz2,mgz2,mgz2, mgz2,gslEllE1,gslEllF2, mgz2,mgz2 +#else + ,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2 +#endif + }; + func_2 f22[EQ_SIN-EQ_LT] = {mgz2,mgz2,mgz2,mgz2,mgz2,mgp,mgm,mul2,div2,pow2,pow2,mgz2,llg2, mgz2 +#if MGL_HAVE_GSL + ,gslJnuD,gslYnuD,gslInuD,gslKnuD,gslEllE2,gslEllF2,mgz2/*gslLegP*/,mgz2 +#else + ,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2,mgz2 +#endif + }; + func_1 f11[EQ_SN-EQ_SIN] = {cos,cos_d,tan_d,asin_d,acos_d,atan_d,cosh,sinh,tanh_d, + asinh_d,acosh_d,atanh_d,sqrt_d,exp,log_d,log10_d,mgz1,mgz1,mgz1,sgn +#if MGL_HAVE_GSL + ,dilog_d,gslE_d,gslK_d,gslAi_d,gslBi_d,erf_d,exp3_d,ei_d,e1_d,e2_d, + si_d,ci_d,gamma_d,gsl_sf_psi_1,mgz1,mgz1,sinc_d,mgz1,mgz1,mgz1,mgz1,mgz1 +#else + ,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1, + mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1,mgz1 +#endif + }; + if(KodCalcIn(a1), d = Left->CalcDIn(id,a1); + if(mgl_isfin(a) && mgl_isfin(d)) + { + if(KodCalcIn(a1), c = Right->CalcDIn(id,a1); + b = mgl_isfin(b) ? (d?f21[Kod-EQ_LT](a,b)*d:0) + (c?f22[Kod-EQ_LT](a,b)*c:0) : NAN; + return mgl_isfin(b) ? b : NAN; + } + else if(KodCalcIn(a1); + if(mgl_isbad(b)) return NAN; + gsl_sf_elljac_e(a,b, &sn, &cn, &dn); + switch(Kod) // At this moment parse only differentiation or argument NOT mu !!! + { + case EQ_SN: return cn*dn*d; + case EQ_SC: return dn*d/(cn*cn); + case EQ_SD: return cn*d/(dn*dn); + case EQ_CN: return -dn*sn*d; + case EQ_CS: return dn*d/(sn*sn); + case EQ_CD: return (b-1)*d*sn/(dn*dn); + case EQ_DN: return -b*d*cn*sn; + case EQ_DS: return -cn*d/(sn*sn); + case EQ_DC: return (1-b)*sn*d/(cn*cn); + case EQ_NS: return -cn*dn*d/(sn*sn); + case EQ_NC: return dn*sn*d/(cn*cn); + case EQ_ND: return b*cn*sn*d/(dn*dn); + } + } +#endif + } + return NAN; +} +//----------------------------------------------------------------------------- +// Check braces correctness +bool MGL_NO_EXPORT mglCheck(char *str,int n) +{ + register long s = 0,i; + for(i=0;i=0;i--) + { + if(str[i]=='(') l++; + if(str[i]==')') r++; + if(l==r && strchr(lst,str[i])) return i; + } + return -1; +} +//----------------------------------------------------------------------------- +HMEX MGL_EXPORT mgl_create_expr(const char *expr) { return new mglFormula(expr); } +void MGL_EXPORT mgl_delete_expr(HMEX ex) { delete ex; } +double MGL_EXPORT mgl_expr_eval(HMEX ex, double x, double y,double z) +{ return ex->Calc(x,y,z); } +double MGL_EXPORT mgl_expr_eval_v(HMEX ex, mreal *var) +{ return ex->Calc(var); } +double MGL_EXPORT mgl_expr_diff(HMEX ex, char dir, double x, double y,double z) +{ return ex->CalcD(dir,x,y,z); } +double MGL_EXPORT mgl_expr_diff_v(HMEX ex, char dir, mreal *var) +{ return ex->CalcD(var, dir); } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_expr_(const char *expr, int l) +{ char *s=new char[l+1]; memcpy(s,expr,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_create_expr(s)); + delete []s; return res; } +void MGL_EXPORT mgl_delete_expr_(uintptr_t *ex) { mgl_delete_expr((HMEX)ex); } +double MGL_EXPORT mgl_expr_eval_(uintptr_t *ex, mreal *x, mreal *y, mreal *z) +{ return mgl_expr_eval((HMEX) ex, *x,*y,*z); } +double MGL_EXPORT mgl_expr_diff_(uintptr_t *ex, const char *dir, mreal *x, mreal *y, mreal *z, int) +{ return mgl_expr_diff((HMEX) ex, *dir,*x,*y,*z); } +//----------------------------------------------------------------------------- diff --git a/src/evalc.cpp b/src/evalc.cpp new file mode 100644 index 0000000..8834f3a --- /dev/null +++ b/src/evalc.cpp @@ -0,0 +1,290 @@ +/*************************************************************************** + * evalc.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/datac_cf.h" +#include "mgl2/evalc.h" +#if MGL_HAVE_GSL +#include +#endif +//----------------------------------------------------------------------------- +// constants for expression parsing +enum{ +EQ_NUM=0, // a variable substitution +EQ_RND, // random number +EQ_A, // numeric constant +// normal functions of 2 arguments +EQ_ADD, // addition x+y +EQ_SUB, // substraction x-y +EQ_MUL, // multiplication x*y +EQ_DIV, // division x/y +EQ_IPOW, // power x^n for integer n +EQ_POW, // power x^y +EQ_LOG, // logarithm of x on base a, log_a(x) = ln(x)/ln(a) +// normal functions of 1 argument +EQ_SIN, // sine function \sin(x). !!! MUST BE FIRST 1-PLACE FUNCTION +EQ_COS, // cosine function \cos(x). +EQ_TAN, // tangent function \tan(x). +EQ_ASIN, // inverse sine function \asin(x). +EQ_ACOS, // inverse cosine function \acos(x). +EQ_ATAN, // inverse tangent function \atan(x). +EQ_SINH, // hyperbolic sine function \sinh(x). +EQ_COSH, // hyperbolic cosine function \cosh(x). +EQ_TANH, // hyperbolic tangent function \tanh(x). +EQ_ASINH, // inverse hyperbolic sine function \asinh(x). +EQ_ACOSH, // inverse hyperbolic cosine function \acosh(x). +EQ_ATANH, // inverse hyperbolic tangent function \atanh(x). +EQ_SQRT, // square root function \sqrt(x) +EQ_EXP, // exponential function \exp(x) +EQ_EXPI, // exponential function \exp(i*x) +EQ_LN, // logarithm of x, ln(x) +EQ_LG, // decimal logarithm of x, lg(x) = ln(x)/ln(10) +EQ_ABS, // absolute value +EQ_LAST // id of last entry +}; +//----------------------------------------------------------------------------- +int mglFormulaC::Error=0; +bool mglCheck(char *str,int n); +int mglFindInText(char *str,const char *lst); +//----------------------------------------------------------------------------- +mglFormulaC::~mglFormulaC() +{ + if(Left) delete Left; + if(Right) delete Right; +} +//----------------------------------------------------------------------------- +// Formula constructor (automatically parse and "compile" formula) +mglFormulaC::mglFormulaC(const char *string) +{ + Error=0; + Left=Right=0; + Res=0; Kod=0; + if(!string) { Kod = EQ_NUM; Res = 0; return; } +//printf("%s\n",string); fflush(stdout); + char *str = new char[strlen(string)+1]; + strcpy(str,string); + long n,len; + mgl_strtrim(str); + mgl_strlwr(str); + len=strlen(str); + if(str[0]==0) { delete []str; return; } + if(str[0]=='(' && mglCheck(&(str[1]),len-2)) // remove braces + { + memmove(str,str+1,len); + len-=2; str[len]=0; + } + len=strlen(str); + n=mglFindInText(str,"+-"); // normal priority -- additions + if(n>=0 && (n<2 || str[n-1]!='e' || (str[n-2]!='.' && !isdigit(str[n-2])))) + { + if(str[n]=='+') Kod=EQ_ADD; else Kod=EQ_SUB; + str[n]=0; + Left=new mglFormulaC(str); + Right=new mglFormulaC(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"*/"); // high priority -- multiplications + if(n>=0) + { + if(str[n]=='*') Kod=EQ_MUL; else Kod=EQ_DIV; + str[n]=0; + Left=new mglFormulaC(str); + Right=new mglFormulaC(str+n+1); + delete []str; return; + } + n=mglFindInText(str,"^"); // highest priority -- power + if(n>=0) + { + Kod=EQ_IPOW; str[n]=0; + Left=new mglFormulaC(str); + Right=new mglFormulaC(str+n+1); + delete []str; return; + } + + for(n=0;n=len) // this is number or variable + { + Kod = EQ_NUM; +// Left = Right = 0; + if(str[1]==0 && str[0]>='a' && str[0]<='z') // available variables + { Kod=EQ_A; Res = str[0]-'a'; } + else if(!strcmp(str,"rnd")) Kod=EQ_RND; + else if(!strcmp(str,"pi")) Res=M_PI; + else if(str[0]=='i') Res = dual(0,str[1]>' '?atof(str+1):1); + else Res=atof(str); // this is number + } + else + { + char name[128]; + strncpy(name,str,128); name[127]=name[n]=0; + memmove(str,str+n+1,len-n); + len=strlen(str); str[--len]=0; + if(!strcmp(name,"sin")) Kod=EQ_SIN; + else if(!strcmp(name,"cos")) Kod=EQ_COS; + else if(!strcmp(name,"tg")) Kod=EQ_TAN; + else if(!strcmp(name,"tan")) Kod=EQ_TAN; + else if(!strcmp(name,"asin")) Kod=EQ_ASIN; + else if(!strcmp(name,"acos")) Kod=EQ_ACOS; + else if(!strcmp(name,"atan")) Kod=EQ_ATAN; + else if(!strcmp(name,"sinh")) Kod=EQ_SINH; + else if(!strcmp(name,"cosh")) Kod=EQ_COSH; + else if(!strcmp(name,"tanh")) Kod=EQ_TANH; + else if(!strcmp(name,"sh")) Kod=EQ_SINH; + else if(!strcmp(name,"ch")) Kod=EQ_COSH; + else if(!strcmp(name,"th")) Kod=EQ_TANH; + else if(!strcmp(name,"sqrt")) Kod=EQ_SQRT; + else if(!strcmp(name,"log")) Kod=EQ_LOG; + else if(!strcmp(name,"pow")) Kod=EQ_POW; + else if(!strcmp(name,"exp")) Kod=EQ_EXP; + else if(!strcmp(name,"lg")) Kod=EQ_LG; + else if(!strcmp(name,"ln")) Kod=EQ_LN; + else if(!strcmp(name,"abs")) Kod=EQ_ABS; + else { delete []str; return; } // unknown function + n=mglFindInText(str,","); + if(n>=0) + { + str[n]=0; + Left=new mglFormulaC(str); + Right=new mglFormulaC(str+n+1); + } + else + Left=new mglFormulaC(str); + } + delete []str; +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n'='v', 't'='z', 'u'='a' variables +dual mglFormulaC::Calc(dual x,dual y,dual t,dual u) const +{ + Error=0; + dual a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(dual)); + a1['a'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = a1['v'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + a1['i'-'a'] = dual(0,1); + return CalcIn(a1); +} +//----------------------------------------------------------------------------- +// evaluate formula for 'x'='r', 'y'='n', 't'='z', 'u'='a', 'v'='b', 'w'='c' variables +dual mglFormulaC::Calc(dual x,dual y,dual t,dual u,dual v,dual w) const +{ + Error=0; + dual a1[MGL_VS]; memset(a1,0,MGL_VS*sizeof(dual)); + a1['c'-'a'] = a1['w'-'a'] = w; + a1['b'-'a'] = a1['v'-'a'] = v; + a1['a'-'a'] = a1['u'-'a'] = u; + a1['x'-'a'] = a1['r'-'a'] = x; + a1['y'-'a'] = a1['n'-'a'] = y; + a1['z'-'a'] = a1['t'-'a'] = t; + a1['i'-'a'] = dual(0,1); + return CalcIn(a1); +} +//----------------------------------------------------------------------------- +// evaluate formula for arbitrary set of variables +dual mglFormulaC::Calc(const dual var[MGL_VS]) const +{ + Error=0; + return CalcIn(var); +} +//----------------------------------------------------------------------------- +dual MGL_NO_EXPORT addc(dual a,dual b) {return a+b;} +dual MGL_NO_EXPORT subc(dual a,dual b) {return a-b;} +dual MGL_NO_EXPORT mulc(dual a,dual b) {return a*b;} +dual MGL_NO_EXPORT divc(dual a,dual b) {return a/b;} +dual MGL_NO_EXPORT ipwc(dual a,dual b) {return mgl_ipowc(a,int(b.real()));} +dual MGL_NO_EXPORT powc(dual a,dual b) {return exp(b*log(a)); } +dual MGL_NO_EXPORT llgc(dual a,dual b) {return log(a)/log(b); } +dual MGL_NO_EXPORT expi(dual a) { return exp(dual(0,1)*a); } +dual MGL_NO_EXPORT expi(double a) { return dual(cos(a),sin(a)); } +//----------------------------------------------------------------------------- +dual MGL_NO_EXPORT ic = dual(0,1); +dual MGL_NO_EXPORT asinhc(dual x) { return log(x+sqrt(x*x+mreal(1))); } +dual MGL_NO_EXPORT acoshc(dual x) { return log(x+sqrt(x*x-mreal(1))); } +dual MGL_NO_EXPORT atanhc(dual x) { return log((mreal(1)+x)/(mreal(1)-x))/mreal(2); } +dual MGL_NO_EXPORT sinc(dual x) { return sin(x); } +dual MGL_NO_EXPORT cosc(dual x) { return cos(x); } +dual MGL_NO_EXPORT tanc(dual x) { return tan(x); } +dual MGL_NO_EXPORT sinhc(dual x) { return sinh(x); } +dual MGL_NO_EXPORT coshc(dual x) { return cosh(x); } +dual MGL_NO_EXPORT tanhc(dual x) { return tanh(x); } +dual MGL_NO_EXPORT asinc(dual x) { return log(ic*x+sqrt(mreal(1)-x*x))/ic; } +dual MGL_NO_EXPORT acosc(dual x) { return log(x+sqrt(x*x-mreal(1)))/ic; } +dual MGL_NO_EXPORT atanc(dual x) { return log((ic-x)/(ic+x))/(mreal(2)*ic); } +dual MGL_NO_EXPORT expc(dual x) { return exp(x); } +dual MGL_NO_EXPORT sqrtc(dual x) { return sqrt(x); } +dual MGL_NO_EXPORT logc(dual x) { return log(x); } +dual MGL_NO_EXPORT absc(dual x) { return abs(x); } +dual MGL_NO_EXPORT lgc(dual x) { return log10(x);} +//----------------------------------------------------------------------------- +typedef dual (*func_1)(dual); +typedef dual (*func_2)(dual, dual); +// evaluation of embedded (included) expressions +dual mglFormulaC::CalcIn(const dual *a1) const +{ + func_2 f2[EQ_SIN-EQ_ADD] = {addc,subc,mulc,divc,ipwc,powc,llgc}; + func_1 f1[EQ_LAST-EQ_SIN] = {sinc,cosc,tanc,asinc,acosc,atanc,sinhc,coshc,tanhc, + asinhc,acoshc,atanhc,sqrtc,expc,expi,logc,lgc,absc}; +// if(Error) return 0; + if(Kod==EQ_A) return a1[(int)Res.real()]; + if(Kod==EQ_RND) return mgl_rnd(); + if(Kod==EQ_NUM) return Res; + + dual a = Left->CalcIn(a1); + if(mgl_isfin(a)) + { + if(KodCalcIn(a1); + b = mgl_isfin(b)?f2[Kod-EQ_ADD](a,b):NAN; + return mgl_isfin(b)?b:NAN; + } + else + { a = f1[Kod-EQ_SIN](a); return mgl_isfin(a)?a:NAN; } + } + return NAN; +} +//----------------------------------------------------------------------------- +dual MGL_EXPORT mgl_ipowc(dual x,int n) +{ + dual t; + if(n==2) return x*x; + if(n==1) return x; + if(n<0) return mreal(1)/mgl_ipowc(x,-n); + if(n==0) return mreal(1); + t = mgl_ipowc(x,n/2); t = t*t; + if(n%2==1) t *= x; + return t; +} +dual MGL_EXPORT mgl_ipowc_(dual *x,int *n) { return mgl_ipowc(*x,*n); } +//----------------------------------------------------------------------------- +HAEX MGL_EXPORT mgl_create_cexpr(const char *expr) { return new mglFormulaC(expr); } +uintptr_t MGL_EXPORT mgl_create_cexpr_(const char *expr, int l) +{ char *s=new char[l+1]; memcpy(s,expr,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_create_cexpr(s)); + delete []s; return res; } +void MGL_EXPORT mgl_delete_cexpr(HAEX ex) { delete ex; } +void MGL_EXPORT mgl_delete_cexpr_(uintptr_t *ex) { mgl_delete_cexpr((HAEX)ex); } +dual MGL_EXPORT mgl_cexpr_eval(HAEX ex, dual x, dual y,dual z) +{ return ex->Calc(x,y,z); } +dual MGL_EXPORT mgl_cexpr_eval_(uintptr_t *ex, dual *x, dual *y, dual *z) +{ return mgl_cexpr_eval((HAEX) ex, *x,*y,*z); } +dual MGL_EXPORT mgl_cexpr_eval_v(HAEX ex, dual *var) +{ return ex->Calc(var); } +//----------------------------------------------------------------------------- diff --git a/src/evalp.cpp b/src/evalp.cpp new file mode 100644 index 0000000..602bfcf --- /dev/null +++ b/src/evalp.cpp @@ -0,0 +1,580 @@ +/*************************************************************************** + * evalp.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include "mgl2/parser.h" +#if MGL_HAVE_GSL +#include +#include +#endif +//----------------------------------------------------------------------------- +std::wstring mgl_trim_ws(const std::wstring &str); +int mglFormulaError; +mglData MGL_NO_EXPORT mglFormulaCalc(std::wstring string, mglParser *arg, const mglVar *head); +//----------------------------------------------------------------------------- +void mglApplyFunc(mglData &d, double (*func)(double)) +{ + long n = d.nx*d.ny*d.nz; +#pragma omp parallel for + for(long i=0;i=0;i--) + { + if(str[i]=='(') l++; + if(str[i]==')') r++; + if(l==r && strchr(lst,str[i])) return i; + } + return -1; +} +//----------------------------------------------------------------------------- +double MGL_NO_EXPORT cand(double a,double b);// {return a&&b?1:0;} +double MGL_NO_EXPORT cor(double a,double b);// {return a||b?1:0;} +double MGL_NO_EXPORT ceq(double a,double b);// {return a==b?1:0;} +double MGL_NO_EXPORT clt(double a,double b);// {return ab?1:0;} +double MGL_NO_EXPORT add(double a,double b);// {return a+b;} +double MGL_NO_EXPORT sub(double a,double b);// {return a-b;} +double MGL_NO_EXPORT mul(double a,double b);// {return a&&b?a*b:0;} +double MGL_NO_EXPORT del(double a,double b);// {return b?a/b:NAN;} +double MGL_NO_EXPORT ipw(double a,double b);// {return mgl_ipow(a,int(b));} +double MGL_NO_EXPORT llg(double a,double b);// {return log(a)/log(b);} +//double MGL_NO_EXPORT asinh(double x);// { return log(x+sqrt(x*x+1)); } +//double MGL_NO_EXPORT acosh(double x);// { return x>1 ? log(x+sqrt(x*x-1)) : NAN; } +//double MGL_NO_EXPORT atanh(double x);// { return fabs(x)<1 ? log((1+x)/(1-x))/2 : NAN; } +double MGL_NO_EXPORT gslEllE(double a,double b);// {return gsl_sf_ellint_E(a,b,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslEllF(double a,double b);// {return gsl_sf_ellint_F(a,b,GSL_PREC_SINGLE);} +double MGL_NO_EXPORT gslLegP(double a,double b);// {return gsl_sf_legendre_Pl(int(a),b);} +//----------------------------------------------------------------------------- +// It seems that standard wcstombs() have a bug. So, I replace by my own. +void MGL_EXPORT mgl_wcstombs(char *dst, const wchar_t *src, int size) +{ + register int j; + for(j=0;js==name) return v; + v = v->next; + } + return 0; +} +//----------------------------------------------------------------------------- +/// Parse string and substitute the script argument +// All numbers are presented as mglData(1). Do boundary checking. +// NOTE: In any case where number is required the mglData::a[0] is used. +// String flag is binary 0x1 -> 'x', 0x2 -> 'y', 0x4 -> 'z' +// NOTE: the speed is not a goal (mglFormula is faster). It is true interpreter! +mglData MGL_NO_EXPORT mglFormulaCalc(std::wstring str, mglParser *arg, const mglVar *head) +{ +#if MGL_HAVE_GSL + gsl_set_error_handler_off(); +#endif + mglData res; + if(str.empty() || mglFormulaError) return res; // nothing to parse + if(!head && arg) head = arg->DataList; + str = mgl_trim_ws(str); + long n,len=str.length(); + if(str[0]=='(' && mglCheck(str.substr(1,len-2))) // remove braces + { str = str.substr(1,len-2); len-=2; } + if(str[0]=='[') // this is manual subdata + { + mglData a1; + long i, j, br=0,k; + bool ar=true,mt=false; + for(i=1,j=1;i0) br--; + if(str[i]==',' && !br) + { + a1=mglFormulaCalc(str.substr(j,i-j), arg, head); + if(j==1) + { res = a1; ar = (a1.nx==1); mt = (a1.nx>1 && a1.ny==1); } + else + { + if(ar) // res 1d array + { k = res.nx; res.Insert('x',k); res.Put(a1,k); } + else if(mt) // res 2d array + { k = res.ny; res.Insert('y',k); res.Put(a1,-1,k); } + else // res 3d array + { k = res.nz; res.Insert('z',k); res.Put(a1,-1,-1,k); } + } + j=i+1; + } + } + a1=mglFormulaCalc(str.substr(j,i-j), arg, head); + if(j==1) + { res = a1; ar = (a1.nx==1); mt = (a1.nx>1 && a1.ny==1); } + else + { + if(ar) // res 1d array + { k = res.nx; res.Insert('x',k); res.Put(a1,k); } + else if(mt) // res 2d array + { k = res.ny; res.Insert('y',k); res.Put(a1,-1,k); } + else // res 3d array + { k = res.nz; res.Insert('z',k); res.Put(a1,-1,-1,k); } + } + return res; + } + + n=mglFindInText(str,"&|"); // lowest priority -- logical + if(n>=0) + return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, str[n]=='|'?cor:cand); + n=mglFindInText(str,"<>="); // low priority -- conditions + if(n>=0) + return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, str[n]=='<'?clt:(str[n]=='>'?cgt:ceq)); + n=mglFindInText(str,"+-"); // normal priority -- additions + if(n>=0 && (n<2 || str[n-1]!='e' || (str[n-2]!='.' && !isdigit(str[n-2])))) + return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, str[n]=='+'?add:sub); + n=mglFindInText(str,"*/"); // high priority -- multiplications + if(n>=0) + return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, str[n]=='*'?mul:del); + n=mglFindInText(str,"@"); // high priority -- combine + if(n>=0) + return mglFormulaCalc(str.substr(0,n),arg, head).Combine(mglFormulaCalc(str.substr(n+1),arg, head)); + n=mglFindInText(str,"^"); // highest priority -- power + if(n>=0) + return mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, ipw); + n=mglFindInText(str,":"); // highest priority -- array + if(n>=0 && str.compare(L":")) + { + const mglData &a1=mglFormulaCalc(str.substr(0,n), arg, head); + const mglData &a2=mglFormulaCalc(str.substr(n+1), arg, head); + res.Create(abs(int(a2.a[0]+0.5)-int(a1.a[0]+0.5))+1); + res.Fill(a1.a[0], a2.a[0]); + return res; + } + n=mglFindInText(str,"."); // highest priority -- suffixes + if(n>=0) + { + mreal x,y,z,k,v=NAN; + mglData d = mglFormulaCalc(str.substr(0,n), arg, head); + const std::wstring &p=str.substr(n+1); + if(!p.compare(L"a")) v = d.a[0]; + else if(!p.compare(L"fst")) { long i=-1,j=-1,l=-1; v = d.Find(0,i,j,l); } + else if(!p.compare(L"lst")) { long i=-1,j=-1,l=-1; v = d.Last(0,i,j,l); } + else if(!p.compare(L"nx")) v=d.nx; + else if(!p.compare(L"ny")) v=d.ny; + else if(!p.compare(L"nz")) v=d.nz; + else if(!p.compare(L"max")) v=d.Maximal(); + else if(!p.compare(L"min")) v=d.Minimal(); + else if(!p.compare(L"pmax")) { v=d.Maximal(); v = v>0?v:0; } + else if(!p.compare(L"pmin")) { v=d.MinimalPos(); } + else if(!p.compare(L"nmax")) { v=d.MaximalNeg(); } + else if(!p.compare(L"nmin")) { v=d.Minimal(); v = v<0?v:0; } + else if(!p.compare(L"sum")) v=d.Momentum('x',x,y); + else if(!p.compare(L"mx")) { d.Maximal(x,y,z); v=x/d.nx; } + else if(!p.compare(L"my")) { d.Maximal(x,y,z); v=y/d.ny; } + else if(!p.compare(L"mz")) { d.Maximal(x,y,z); v=z/d.nz; } + else if(!p.compare(L"ax")) { d.Momentum('x',x,y); v=x/d.nx; } + else if(!p.compare(L"ay")) { d.Momentum('y',x,y); v=x/d.ny; } + else if(!p.compare(L"az")) { d.Momentum('z',x,y); v=x/d.nz; } + else if(!p.compare(L"wx")) { d.Momentum('x',x,y); v=y/d.nx; } + else if(!p.compare(L"wy")) { d.Momentum('y',x,y); v=y/d.ny; } + else if(!p.compare(L"wz")) { d.Momentum('z',x,y); v=y/d.nz; } + else if(!p.compare(L"sx")) { d.Momentum('x',x,y,z,k); v=z/d.nx; } + else if(!p.compare(L"sy")) { d.Momentum('y',x,y,z,k); v=z/d.ny; } + else if(!p.compare(L"sz")) { d.Momentum('z',x,y,z,k); v=z/d.nz; } + else if(!p.compare(L"kx")) { d.Momentum('x',x,y,z,k); v=k/d.nx; } + else if(!p.compare(L"ky")) { d.Momentum('y',x,y,z,k); v=k/d.ny; } + else if(!p.compare(L"kz")) { d.Momentum('z',x,y,z,k); v=k/d.nz; } + else if(!p.compare(L"aa")) { d.Momentum('a',x,y); v=x; } + else if(!p.compare(L"wa")) { d.Momentum('a',x,y); v=y; } + else if(!p.compare(L"sa")) { d.Momentum('a',x,y,z,k);v=z; } + else if(!p.compare(L"ka")) { d.Momentum('a',x,y,z,k);v=k; } + // if this is valid suffix when finish parsing (it can be mreal number) + if(mgl_isfin(v)) { res.a[0] = v; return res; } + } + for(n=0;n=len) // this is number or variable + { + const mglVar *v = FindVar(head, str); + mglNum *f = arg?arg->FindNum(str.c_str()):0; + if(v) res = v; + else if(f) res.a[0] = f->d; + else if(!str.compare(L"rnd")) res.a[0] = mgl_rnd(); + else if(!str.compare(L"nan")) res.a[0] = NAN; + else if(!str.compare(L"pi")) res.a[0] = M_PI; + else if(!str.compare(L"on")) res.a[0] = 1; + else if(!str.compare(L"off")) res.a[0] = 0; + else if(!str.compare(L":")) res.a[0] = -1; + else res.a[0] = wcstod(str.c_str(),0); // this is number + return res; + } + else + { + std::wstring nm = str.substr(0,n); + str = str.substr(n+1,len-n-2); len -= n+2; + const mglVar *v = FindVar(head, nm); +// mglVar *v = arg->FindVar(nm.c_str()); + if(!v && !nm.compare(0,7,L"jacobi_")) nm = nm.substr(7); + if(v) // subdata + { + if(str[0]=='\'' && str[len-1]=='\'') // this is column call + { + char *buf = new char[len]; + mgl_wcstombs(buf, str.substr(1).c_str(), len-1); buf[len-1]=0; + res=v->Column(buf); delete []buf; + } + else + { + long m; + mglData a1, a2, a3; + a1.a[0] = a2.a[0] = a3.a[0] = -1; + n=mglFindInText(str,","); + if(n>0) + { + m=mglFindInText(str.substr(0,n),","); + if(m>0) + { + str[m]=0; + a1 = mglFormulaCalc(str.substr(0,m), arg, head); + a2 = mglFormulaCalc(str.substr(m+1,n-m-1), arg, head); + a3 = mglFormulaCalc(str.substr(n+1), arg, head); + } + else + { + a1 = mglFormulaCalc(str.substr(0,n), arg, head); + a2 = mglFormulaCalc(str.substr(n+1), arg, head); + } + } + else a1 = mglFormulaCalc(str, arg, head); + res = v->SubData(a1,a2,a3); + } + } + else if(nm[0]=='a') // function + { + if(!nm.compare(L"asin")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,asin); } + else if(!nm.compare(L"acos")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,acos); } + else if(!nm.compare(L"atan")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,atan); } + else if(!nm.compare(L"arg")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(n+1),str.substr(0,n),arg, head, atan2); + } + else if(!nm.compare(L"abs")) + { + n=mglFindInText(str,","); + if(n<=0) { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,fabs); } + else res = mglApplyOper(str.substr(n+1),str.substr(0,n),arg, head, hypot); + } +#if MGL_HAVE_GSL + else if(!nm.compare(L"ai") || !nm.compare(L"airy_ai")) + { res=mglFormulaCalc(str, arg, head); +#pragma omp parallel for + for(long i=0;i0?1:0; } + else if(!nm.compare(L"sign")) + { res=mglFormulaCalc(str, arg, head); +#pragma omp parallel for + for(long i=0;i0?1:(res.a[i]<0?-1:0); } + else if(!nm.compare(L"sinh") || !nm.compare(L"sh")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,sinh); } +#if MGL_HAVE_GSL + else if(!nm.compare(L"si")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_Si); } + else if(!nm.compare(L"sinc")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_sinc); } +#endif + } + else if(nm[0]=='t') + { + if(!nm.compare(L"tg") || !nm.compare(L"tan")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,tan); } + else if(!nm.compare(L"tanh") || !nm.compare(L"th")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,tanh); } + } + else if(!nm.compare(L"pow")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, pow); + } + else if(!nm.compare(L"mod")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, fmod); + } + else if(!nm.compare(L"int")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,floor); } +#if MGL_HAVE_GSL + else if(!nm.compare(L"i")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Inu); + } + else if(!nm.compare(L"j")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Jnu); + } + else if(!nm.compare(L"k")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Knu); + } + else if(!nm.compare(L"y")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gsl_sf_bessel_Ynu); + } + else if(!nm.compare(L"f")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(0,n),str.substr(n+1),arg, head, gslEllF); + } + else if(!nm.compare(L"hypot")) + { + n=mglFindInText(str,","); + if(n<=0) mglFormulaError=true; + else res = mglApplyOper(str.substr(n+1),str.substr(0,n),arg, head, hypot); + } + else if(!nm.compare(L"gamma")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_gamma); } + else if(!nm.compare(L"w0")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_lambert_W0); } + else if(!nm.compare(L"w1")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_lambert_Wm1); } + else if(!nm.compare(L"psi")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_psi); } + else if(!nm.compare(L"zeta")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_zeta); } + else if(!nm.compare(L"z")) + { res=mglFormulaCalc(str, arg, head); mglApplyFunc(res,gsl_sf_dawson); } +#endif + } + return res; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_wcslwr(wchar_t *str) +{ + register size_t l=mgl_wcslen(str); + for(size_t k=0;k='A' && str[k]<='Z') ? str[k]+'a'-'A' : str[k]; +} +//----------------------------------------------------------------------------- diff --git a/src/exec.cpp b/src/exec.cpp new file mode 100644 index 0000000..3a3be14 --- /dev/null +++ b/src/exec.cpp @@ -0,0 +1,2896 @@ +/*************************************************************************** + * exec.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifdef WIN32 +#include +#include +#else +#include +#endif + +#include "mgl2/base.h" +#include "mgl2/parser.h" +#define iint(x) long((x)+0.5) +wchar_t *mgl_str_copy(const char *s); +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_addlegend(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ss")) gr->AddLegend(a[0].w.c_str(),a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_addto(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) *(a[0].d) += *(a[1].d); + else if(!strcmp(k,"dn"))*(a[0].d) += a[1].v; + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_sort(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Sort(a[1].v, -1); + else if(!strcmp(k,"dnn")) a[0].d->Sort(a[1].v, a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_alpha(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->Alpha(true); + else if(!strcmp(k,"n")) gr->Alpha(a[0].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_plotid(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) gr->SetPlotId(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_mask(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"sn")) gr->SetMask(a[0].s[0],a[1].v); + else if(!strcmp(k,"ss")) gr->SetMask(a[0].s[0],a[1].s.c_str()); + else if(!strcmp(k,"n")) gr->SetMaskAngle(iint(a[0].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_alphadef(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetAlphaDef(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ambient(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetAmbient(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_diffuse(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetDiffuse(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_area(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Area(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Area(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Area(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Area(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Area(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Area(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_aspect(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->Aspect(a[0].v, a[1].v, 1); + else if(!strcmp(k,"nnn")) gr->Aspect(a[0].v, a[1].v, a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_axial(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Axial(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Axial(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Axial(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Axial(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_axis(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"")) gr->Axis("xyz","",opt); + else if(!strcmp(k,"s")) gr->Axis(a[0].s.c_str(), "",opt); + else if(!strcmp(k,"ss")) gr->Axis(a[0].s.c_str(), a[1].s.c_str(),opt); + else if(!strcmp(k,"sss")) gr->SetFunc(a[0].s.c_str(),a[1].s.c_str(),a[2].s.c_str(),""); + else if(!strcmp(k,"ssss")) gr->SetFunc(a[0].s.c_str(),a[1].s.c_str(),a[2].s.c_str(),a[3].s.c_str()); + else if(!strcmp(k,"n")) gr->SetCoor(iint(a[0].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ball(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nn")) gr->Mark(mglPoint(a[0].v,a[1].v,NAN),"r."); + else if(!strcmp(k,"nns")) gr->Mark(mglPoint(a[0].v,a[1].v,NAN),a[2].s.c_str()); + else if(!strcmp(k,"nnn")) gr->Mark(mglPoint(a[0].v,a[1].v,a[2].v),"r."); + else if(!strcmp(k,"nnns")) gr->Mark(mglPoint(a[0].v,a[1].v,a[2].v),a[3].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_box(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"")) gr->Box(); + else if(!strcmp(k,"s")) gr->Box(a[0].s.c_str()); + else if(!strcmp(k,"sn")) gr->Box(a[0].s.c_str(), a[1].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ohlc(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dddd")) gr->OHLC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->OHLC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) gr->OHLC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), "",opt); + else if(!strcmp(k,"ddddds")) gr->OHLC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_bars(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Bars(*(a[0].d), "",opt); + else if(!strcmp(k,"ds")) gr->Bars(*(a[0].d), a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Bars(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Bars(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Bars(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Bars(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_barh(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Barh(*(a[0].d), "",opt); + else if(!strcmp(k,"ds")) gr->Barh(*(a[0].d), a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Barh(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Barh(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cones(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Cones(*(a[0].d), "",opt); + else if(!strcmp(k,"ds")) gr->Cones(*(a[0].d), a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Cones(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Cones(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Cones(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Cones(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_belt(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Belt(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Belt(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Belt(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Belt(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_boxs(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Boxs(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Boxs(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Boxs(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Boxs(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_beam(mglGraph *gr, long , mglArg *a, const char *k, const char *) // NOTE beam can be made obsolete ??? +{ + int res=0; + if(!strcmp(k,"ddddn")) + gr->Beam(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].v,"",0, 3); + else if(!strcmp(k,"ddddns")) + gr->Beam(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].v,a[5].s.c_str(),0, 3); + else if(!strcmp(k,"ddddnsn")) + gr->Beam(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].v,a[5].s.c_str(),iint(a[6].v), 3); + else if(!strcmp(k,"ddddnsnn")) + gr->Beam(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].v,a[5].s.c_str(),iint(a[6].v), iint(a[7].v)); + else if(!strcmp(k,"nddddn")) + gr->Beam(a[0].v,*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].v,"",0); + else if(!strcmp(k,"nddddns")) + gr->Beam(a[0].v,*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].v,a[6].s.c_str(),0); + else if(!strcmp(k,"nddddnsn")) + gr->Beam(a[0].v,*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].v,a[6].s.c_str(),iint(a[7].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_clearlegend(mglGraph *gr, long , mglArg *, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->ClearLegend(); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_clf(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->Clf(); + else if(!strcmp(k,"s")) gr->Clf(a[0].s[0]); + else if(!strcmp(k,"nnn")) gr->Clf(a[0].v,a[1].v,a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_chart(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Chart(*(a[0].d), "",opt); + else if(!strcmp(k,"ds")) gr->Chart(*(a[0].d), a[1].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cloud(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Cloud(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Cloud(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Cloud(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Cloud(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_crange(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) gr->SetRange('c',*(a[0].d)); + else if(!strcmp(k,"dn")) gr->SetRange('c',*(a[0].d),a[1].v); + else if(!strcmp(k,"nn")) gr->SetRange('c', a[0].v, a[1].v); + else if(!strcmp(k,"nnn")) + { + if(a[2].v) gr->AddRange('c', a[0].v, a[1].v); + else gr->SetRange('c', a[0].v, a[1].v); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_crop(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dnns")) a[0].d->Crop(iint(a[1].v),iint(a[2].v),a[3].s.c_str()[0]); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_clean(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Clean(iint(a[1].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cumsum(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->CumSum(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_curve(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnnnnnn")) + gr->Curve(mglPoint(a[0].v,a[1].v,NAN), + mglPoint(a[2].v,a[3].v), + mglPoint(a[4].v,a[5].v,NAN), + mglPoint(a[6].v,a[7].v)); + else if(!strcmp(k,"nnnnnnnns")) + gr->Curve(mglPoint(a[0].v,a[1].v,NAN), + mglPoint(a[2].v,a[3].v), + mglPoint(a[4].v,a[5].v,NAN), + mglPoint(a[6].v,a[7].v), a[8].s.c_str()); + else if(!strcmp(k,"nnnnnnnnnnnn")) + gr->Curve(mglPoint(a[0].v,a[1].v,a[2].v), + mglPoint(a[3].v,a[4].v,a[5].v), + mglPoint(a[6].v,a[7].v,a[8].v), + mglPoint(a[9].v,a[10].v,a[11].v)); + else if(!strcmp(k,"nnnnnnnnnnnns")) + gr->Curve(mglPoint(a[0].v,a[1].v,a[2].v), + mglPoint(a[3].v,a[4].v,a[5].v), + mglPoint(a[6].v,a[7].v,a[8].v), + mglPoint(a[9].v,a[10].v,a[11].v), a[12].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cut(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetCut(a[0].v != 0); + else if(!strcmp(k,"nnnnnn")) + gr->SetCutBox(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v)); + else if(!strcmp(k,"s")) gr->CutOff(a[0].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_crust(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) gr->Crust(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Crust(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_colorbar(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"")) gr->Colorbar(); + else if(!strcmp(k,"s")) gr->Colorbar(a[0].s.c_str()); + else if(!strcmp(k,"d")) gr->Colorbar(*(a[0].d)); + else if(!strcmp(k,"ds")) gr->Colorbar(*(a[0].d), a[1].s.c_str()); + else if(!strcmp(k,"snn")) gr->Colorbar(a[0].s.c_str(), a[1].v, a[2].v); + else if(!strcmp(k,"snnn")) gr->Colorbar(a[0].s.c_str(), a[1].v, a[2].v, a[3].v,1); + else if(!strcmp(k,"snnnn")) gr->Colorbar(a[0].s.c_str(), a[1].v, a[2].v, a[3].v,a[4].v); + else if(!strcmp(k,"dsnn")) gr->Colorbar(*(a[0].d), a[1].s.c_str(), a[2].v, a[3].v); + else if(!strcmp(k,"dsnnn")) gr->Colorbar(*(a[0].d), a[1].s.c_str(), a[2].v, a[3].v, a[4].v,1); + else if(!strcmp(k,"dsnnnn")) + gr->Colorbar(*(a[0].d), a[1].s.c_str(), a[2].v, a[3].v, a[4].v,a[5].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_copy(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) a[0].d->Set(*(a[1].d)); + else if(!strcmp(k,"dds")) + { a[0].d->Set(*(a[1].d)); gr->Fill(*(a[0].d), a[2].s.c_str()); } + else if(!strcmp(k,"dn")) *(a[0].d) = a[1].v; + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cont(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Cont(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Cont(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Cont(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Cont(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Cont(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Cont(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Cont(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Cont(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contv(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContV(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->ContV(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->ContV(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->ContV(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->ContV(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->ContV(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->ContV(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->ContV(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contf(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContF(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->ContF(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->ContF(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->ContF(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->ContF(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->ContF(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->ContF(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->ContF(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contd(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContD(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->ContD(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->ContD(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->ContD(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->ContD(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->ContD(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->ContD(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->ContD(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cont3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Cont3(*(a[0].d), "", -1,opt); + else if(!strcmp(k,"ds")) gr->Cont3(*(a[0].d), a[1].s.c_str(), -1,opt); + else if(!strcmp(k,"dsn")) gr->Cont3(*(a[0].d), a[1].s.c_str(), iint(a[2].v),opt); + else if(!strcmp(k,"dd")) gr->Cont3(*(a[0].d), *(a[1].d), "", -1,opt); + else if(!strcmp(k,"dds")) gr->Cont3(*(a[0].d), *(a[1].d), a[2].s.c_str(),-1,opt); + else if(!strcmp(k,"ddsn")) gr->Cont3(*(a[0].d), *(a[1].d), a[2].s.c_str(),iint(a[3].v),opt); + else if(!strcmp(k,"dddd")) gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "", -1,opt); + else if(!strcmp(k,"dddds")) gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),-1,opt); + else if(!strcmp(k,"ddddsn")) gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),iint(a[5].v),opt); + else if(!strcmp(k,"ddddd")) gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), "", -1,opt); + else if(!strcmp(k,"ddddds")) gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(),-1,opt); + else if(!strcmp(k,"dddddsn"))gr->Cont3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(),iint(a[6].v),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contf3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContF3(*(a[0].d), "", -1,opt); + else if(!strcmp(k,"ds")) gr->ContF3(*(a[0].d), a[1].s.c_str(), -1,opt); + else if(!strcmp(k,"dsn")) gr->ContF3(*(a[0].d), a[1].s.c_str(), iint(a[2].v),opt); + else if(!strcmp(k,"dd")) gr->ContF3(*(a[0].d), *(a[1].d), "", -1,opt); + else if(!strcmp(k,"dds")) gr->ContF3(*(a[0].d), *(a[1].d), a[2].s.c_str(),-1,opt); + else if(!strcmp(k,"ddsn")) gr->ContF3(*(a[0].d), *(a[1].d), a[2].s.c_str(),iint(a[3].v),opt); + else if(!strcmp(k,"dddd")) gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), "", -1,opt); + else if(!strcmp(k,"dddds")) gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),-1,opt); + else if(!strcmp(k,"ddddsn")) gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(),iint(a[5].v),opt); + else if(!strcmp(k,"ddddd")) gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), "", -1,opt); + else if(!strcmp(k,"ddddds")) gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(),-1,opt); + else if(!strcmp(k,"dddddsn"))gr->ContF3(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(),iint(a[6].v),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contx(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContX(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContX(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContX(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contfx(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContFX(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContFX(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContFX(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_conty(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContY(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContY(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContY(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contfy(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContFY(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContFY(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContFY(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contz(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContZ(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContZ(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContZ(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_contfz(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->ContFZ(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->ContFZ(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->ContFZ(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cone(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnnnn")) gr->Cone(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v); + else if(!strcmp(k,"nnnnnnns")) gr->Cone(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v,-1, a[7].s.c_str()); + else if(!strcmp(k,"nnnnnnnn")) gr->Cone(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].v); + else if(!strcmp(k,"nnnnnnnns")) gr->Cone(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].v, a[8].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ellipse(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) + gr->Ellipse(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].v); + else if(!strcmp(k,"nnnnns")) + gr->Ellipse(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnnn")) + gr->Ellipse(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v); + else if(!strcmp(k,"nnnnnnns")) + gr->Ellipse(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_circle(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnn")) gr->Circle(mglPoint(a[0].v,a[1].v, NAN), a[2].v); + else if(!strcmp(k,"nnns")) gr->Circle(mglPoint(a[0].v,a[1].v, NAN), a[2].v, a[3].s.c_str()); + else if(!strcmp(k,"nnnn")) gr->Circle(mglPoint(a[0].v,a[1].v,a[2].v), a[3].v); + else if(!strcmp(k,"nnnns")) gr->Circle(mglPoint(a[0].v,a[1].v,a[2].v), a[3].v, a[4].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_rhomb(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) + gr->Rhomb(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].v); + else if(!strcmp(k,"nnnnns")) + gr->Rhomb(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnnn")) + gr->Rhomb(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v); + else if(!strcmp(k,"nnnnnnns")) + gr->Rhomb(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_dens(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Dens(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Dens(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Dens(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Dens(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_dens3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Dens3(*(a[0].d),"",-1,opt); + else if(!strcmp(k,"ds")) gr->Dens3(*(a[0].d),a[1].s.c_str(),-1,opt); + else if(!strcmp(k,"dsn")) gr->Dens3(*(a[0].d),a[1].s.c_str(),iint(a[2].v),opt); + else if(!strcmp(k,"dddd")) gr->Dens3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"", -1,opt); + else if(!strcmp(k,"dddds")) gr->Dens3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),-1,opt); + else if(!strcmp(k,"ddddsn")) gr->Dens3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),iint(a[5].v),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_densx(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->DensX(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->DensX(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->DensX(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_densy(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->DensY(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->DensY(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->DensY(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_densz(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->DensZ(*(a[0].d),"",NAN,opt); + else if(!strcmp(k,"ds")) gr->DensZ(*(a[0].d),a[1].s.c_str(),NAN,opt); + else if(!strcmp(k,"dsn")) gr->DensZ(*(a[0].d),a[1].s.c_str(),a[2].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_divto(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) *(a[0].d) /= *(a[1].d); + else if(!strcmp(k,"dn")) *(a[0].d) /= a[1].v; + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_multo(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) *(a[0].d) *= *(a[1].d); + else if(!strcmp(k,"dn")) *(a[0].d) *= a[1].v; + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_subto(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) *(a[0].d) -= *(a[1].d); + else if(!strcmp(k,"dn")) *(a[0].d) -= a[1].v; + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_dots(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"ddddds"))gr->Dots(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_diff(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Diff(a[1].s.c_str()); + else if(!strcmp(k,"ddd")) a[0].d->Diff(*(a[1].d), *(a[2].d)); + else if(!strcmp(k,"dddd")) a[0].d->Diff(*(a[1].d), *(a[2].d), *(a[3].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_diff2(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Diff2(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_drop(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) + gr->Drop(mglPoint(a[0].v,a[1].v), mglPoint(a[2].v,a[3].v), a[4].v); + else if(!strcmp(k,"nnnnns")) + gr->Drop(mglPoint(a[0].v,a[1].v), mglPoint(a[2].v,a[3].v), a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnsn")) + gr->Drop(mglPoint(a[0].v,a[1].v), mglPoint(a[2].v,a[3].v), a[4].v, a[5].s.c_str(), a[6].v); + else if(!strcmp(k,"nnnnnsnn")) + gr->Drop(mglPoint(a[0].v,a[1].v), mglPoint(a[2].v,a[3].v), a[4].v, a[5].s.c_str(), a[6].v, a[7].v); + else if(!strcmp(k,"nnnnnnn")) + gr->Drop(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v); + else if(!strcmp(k,"nnnnnnns")) + gr->Drop(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].s.c_str()); + else if(!strcmp(k,"nnnnnnnsn")) + gr->Drop(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].s.c_str(), a[8].v); + else if(!strcmp(k,"nnnnnnnsnn")) + gr->Drop(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].v, a[7].s.c_str(), a[8].v, a[9].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_dew(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Dew(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Dew(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Dew(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Dew(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fall(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Fall(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Fall(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Fall(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Fall(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_mesh(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Mesh(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Mesh(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Mesh(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Mesh(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surf(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Surf(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Surf(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Surf(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Surf(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surfc(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->SurfC(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->SurfC(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->SurfC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->SurfC(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surfa(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->SurfA(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->SurfA(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->SurfA(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->SurfA(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_flow(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Flow(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Flow(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"dddddd")) + gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"dddddds")) + gr->Flow(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else if(!strcmp(k,"nndd")) + gr->FlowP(mglPoint(a[0].v,a[1].v,NAN), *(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"nndds")) + gr->FlowP(mglPoint(a[0].v,a[1].v,NAN), *(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"nndddd")) + gr->FlowP(mglPoint(a[0].v,a[1].v,NAN), *(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"nndddds")) + gr->FlowP(mglPoint(a[0].v,a[1].v,NAN), *(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else if(!strcmp(k,"nnnddd")) + gr->FlowP(mglPoint(a[0].v,a[1].v,a[2].v), *(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"nnnddds")) + gr->FlowP(mglPoint(a[0].v,a[1].v,a[2].v), *(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else if(!strcmp(k,"nnndddddd")) + gr->FlowP(mglPoint(a[0].v,a[1].v,a[2].v), *(a[3].d),*(a[4].d),*(a[5].d),*(a[6].d),*(a[7].d),*(a[8].d),"",opt); + else if(!strcmp(k,"nnndddddds")) + gr->FlowP(mglPoint(a[0].v,a[1].v,a[2].v), *(a[3].d),*(a[4].d),*(a[5].d),*(a[6].d),*(a[7].d),*(a[8].d),a[9].s.c_str(),opt); + else res = 1; + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_grad(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Grad(*(a[0].d), "",opt); + else if(!strcmp(k,"ds")) gr->Grad(*(a[0].d), a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Grad(*(a[0].d),*(a[1].d),*(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Grad(*(a[0].d),*(a[1].d),*(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Grad(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Grad(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fill(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dnn")) a[0].d->Fill(a[1].v,a[2].v); + else if(!strcmp(k,"dnns")) a[0].d->Fill(a[1].v,a[2].v,a[3].s.c_str()[0]); + else if(!strcmp(k,"ds")) gr->Fill(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dsd")) gr->Fill(*(a[0].d),a[1].s.c_str(), *(a[2].d),opt); + else if(!strcmp(k,"dsdd")) gr->Fill(*(a[0].d),a[1].s.c_str(), *(a[2].d), *(a[3].d),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_refill(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) gr->Refill(*(a[0].d),*(a[1].d),*(a[2].d),-1,opt); + else if(!strcmp(k,"dddn")) gr->Refill(*(a[0].d),*(a[1].d),*(a[2].d),iint(a[3].v),opt); + else if(!strcmp(k,"dddd")) gr->Refill(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),-1,opt); + else if(!strcmp(k,"ddddn")) gr->Refill(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),iint(a[4].v),opt); + else if(!strcmp(k,"ddddd")) gr->Refill(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fillsample(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->FillSample(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fog(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->Fog(a[0].v); + else if(!strcmp(k,"nn")) gr->Fog(a[0].v,a[1].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_font(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) gr->SetFontDef(a[0].s.c_str()); + else if(!strcmp(k,"sn")) + { gr->SetFontDef(a[0].s.c_str()); gr->SetFontSize(a[1].v); } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_loadfont(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"") || (!strcmp(k,"s") && a[0].s[0]==0)) gr->RestoreFont(); + else if(!strcmp(k,"s")) gr->LoadFont(a[0].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_grid(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"")) gr->Grid("xyzt", "B",opt); + else if(!strcmp(k,"s")) gr->Grid(a[0].s.c_str(), "B",opt); + else if(!strcmp(k,"ss"))gr->Grid(a[0].s.c_str(), a[1].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_grid2(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Grid(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Grid(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Grid(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Grid(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_grid3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Grid3(*(a[0].d),"",-1,opt); + else if(!strcmp(k,"ds")) gr->Grid3(*(a[0].d),a[1].s.c_str(),-1,opt); + else if(!strcmp(k,"dsn")) gr->Grid3(*(a[0].d),a[1].s.c_str(),iint(a[2].v),opt); + else if(!strcmp(k,"dddd")) gr->Grid3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",-1,opt); + else if(!strcmp(k,"dddds")) gr->Grid3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),-1,opt); + else if(!strcmp(k,"ddddsn"))gr->Grid3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),iint(a[5].v),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_light(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->Light(true); + else if(!strcmp(k,"n")) gr->Light(a[0].v!=0); + else if(!strcmp(k,"nn")) gr->Light(iint(a[0].v),a[1].v!=0); + else if(!strcmp(k,"nnnn")) gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v)); + else if(!strcmp(k,"nnnns")) gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v), a[4].s.c_str()[0]); + else if(!strcmp(k,"nnnnsn"))gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v), a[4].s.c_str()[0],a[5].v); + else if(!strcmp(k,"nnnnsnn")) + gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v), a[4].s.c_str()[0],a[5].v,a[6].v); + else if(!strcmp(k,"nnnnnnn")) + gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v),mglPoint(a[4].v,a[5].v,a[6].v)); + else if(!strcmp(k,"nnnnnnns")) + gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v),mglPoint(a[4].v,a[5].v,a[6].v), a[7].s.c_str()[0]); + else if(!strcmp(k,"nnnnnnnsn")) + gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v),mglPoint(a[4].v,a[5].v,a[6].v), a[7].s.c_str()[0],a[8].v); + else if(!strcmp(k,"nnnnnnnsnn")) + gr->AddLight(iint(a[0].v),mglPoint(a[1].v,a[2].v,a[3].v),mglPoint(a[4].v,a[5].v,a[6].v), a[7].s.c_str()[0],a[8].v,a[9].v); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_line(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnn")) + gr->Line(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN)); + else if(!strcmp(k,"nnnns")) + gr->Line(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].s.c_str()); + else if(!strcmp(k,"nnnnnn")) + gr->Line(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v)); + else if(!strcmp(k,"nnnnnns")) + gr->Line(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_errbox(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnn")) + gr->Error(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN)); + else if(!strcmp(k,"nnnns")) + gr->Error(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), a[4].s.c_str()); + else if(!strcmp(k,"nnnnnn")) + gr->Error(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v)); + else if(!strcmp(k,"nnnnnns")) + gr->Error(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_legend(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"")) gr->Legend(3, "#", opt); + else if(!strcmp(k,"n")) gr->Legend(iint(a[0].v), "#", opt); + else if(!strcmp(k,"ns")) gr->Legend(iint(a[0].v), a[1].s.c_str(), opt); + else if(!strcmp(k,"nn")) gr->Legend(a[0].v, a[1].v, "#", opt); + else if(!strcmp(k,"nns")) gr->Legend(a[0].v, a[1].v, a[2].s.c_str(), opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_barwidth(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetBarWidth(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_legendmarks(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetLegendMarks(iint(a[0].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_modify(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Modify(a[1].s.c_str()); + else if(!strcmp(k,"dsn")) a[0].d->Modify(a[1].s.c_str(), iint(a[2].v)); + else if(!strcmp(k,"dsd")) a[0].d->Modify(a[1].s.c_str(),*(a[2].d)); + else if(!strcmp(k,"dsdd")) a[0].d->Modify(a[1].s.c_str(),*(a[2].d),*(a[3].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_max(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) *(a[0].d) = a[1].d->Max(a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_min(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) *(a[0].d) = a[1].d->Min(a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_sum(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) *(a[0].d) = a[1].d->Sum(a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_meshnum(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetMeshNum(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_facenum(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetFaceNum(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_quality(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->SetQuality(); + else if(!strcmp(k,"n")) gr->SetQuality(iint(a[0].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_marksize(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetMarkSize(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_mark(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Mark(*(a[0].d), *(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Mark(*(a[0].d), *(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Mark(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Mark(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Mark(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Mark(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_map(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Map(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Map(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Map(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Map(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_read(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + bool rr=true; + if(!strcmp(k,"ds")) rr=a[0].d->Read(a[1].s.c_str()); + else if(!strcmp(k,"dsn")) rr=a[0].d->Read(a[1].s.c_str(), iint(a[2].v)); + else if(!strcmp(k,"dsnn")) rr=a[0].d->Read(a[1].s.c_str(), iint(a[2].v),iint(a[3].v)); + else if(!strcmp(k,"dsnnn")) rr=a[0].d->Read(a[1].s.c_str(), iint(a[2].v),iint(a[3].v),iint(a[4].v)); + if(!rr) gr->SetWarn(mglWarnFile,"Read"); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_readmat(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + bool rr=true; + if(!strcmp(k,"ds")) rr=a[0].d->ReadMat(a[1].s.c_str()); + else if(!strcmp(k,"dsn")) rr=a[0].d->ReadMat(a[1].s.c_str(), iint(a[2].v)); + else res = 1; + if(!rr) gr->SetWarn(mglWarnFile,"ReadMat"); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_readall(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + bool rr=true; + if(!strcmp(k,"ds")) rr=a[0].d->ReadAll(a[1].s.c_str()); + else if(!strcmp(k,"dsn")) rr=a[0].d->ReadAll(a[1].s.c_str(), a[2].v); + else if(!strcmp(k,"dsnn")) rr=a[0].d->ReadRange(a[1].s.c_str(), a[2].v, a[3].v); + else if(!strcmp(k,"dsnnn")) rr=a[0].d->ReadRange(a[1].s.c_str(), a[2].v, a[3].v, a[4].v); + else if(!strcmp(k,"dsnnnn"))rr=a[0].d->ReadRange(a[1].s.c_str(), a[2].v, a[3].v, a[4].v, a[5].v); + else res = 1; + if(!rr) gr->SetWarn(mglWarnFile,"ReadMat"); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_readhdf(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dss")) a[0].d->ReadHDF(a[1].s.c_str(), a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_savehdf(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dss")) a[0].d->SaveHDF(a[1].s.c_str(), a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_rect(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnn")) + gr->Face(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[0].v,a[3].v,NAN), + mglPoint(a[2].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN)); + else if(!strcmp(k,"nnnns")) + gr->Face(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[0].v,a[3].v,NAN), + mglPoint(a[2].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN),a[4].s.c_str()); + else if(!strncmp(k,"nnnnnn",6)) + { + if(a[0].v==a[3].v) gr->Face(mglPoint(a[0].v,a[1].v,a[2].v), + mglPoint(a[0].v,a[4].v,a[2].v), + mglPoint(a[3].v,a[1].v,a[5].v), + mglPoint(a[3].v,a[4].v,a[5].v), + k[6]=='s' ? a[6].s.c_str() : 0); + else gr->Face(mglPoint(a[0].v,a[1].v,a[2].v), + mglPoint(a[0].v,a[4].v,a[5].v), + mglPoint(a[3].v,a[1].v,a[2].v), + mglPoint(a[3].v,a[4].v,a[5].v), + k[6]=='s' ? a[6].s.c_str() : 0); + } + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_face(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnnnnn")) + gr->Face(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), + mglPoint(a[4].v,a[5].v,NAN), mglPoint(a[6].v,a[7].v,NAN)); + else if(!strcmp(k,"nnnnnnnns")) + gr->Face(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v,NAN), + mglPoint(a[4].v,a[5].v,NAN), mglPoint(a[6].v,a[7].v,NAN), a[8].s.c_str()); + else if(!strcmp(k,"nnnnnnnnnnnn")) + gr->Face(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), + mglPoint(a[6].v,a[7].v,a[8].v), mglPoint(a[9].v,a[10].v,a[11].v)); + else if(!strcmp(k,"nnnnnnnnnnnns")) + gr->Face(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), + mglPoint(a[6].v,a[7].v,a[8].v), mglPoint(a[9].v,a[10].v,a[11].v), a[12].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_resize(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddn")) *(a[0].d) = a[1].d->Resize(iint(a[2].v)); + else if(!strcmp(k,"ddnn")) *(a[0].d) = a[1].d->Resize(iint(a[2].v), iint(a[3].v)); + else if(!strcmp(k,"ddnnn")) *(a[0].d) = a[1].d->Resize(iint(a[2].v), iint(a[3].v), iint(a[4].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_rotate(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->Rotate(a[0].v, a[1].v, 0); + else if(!strcmp(k,"nnn")) gr->Rotate(a[0].v, a[1].v, a[2].v); + else if(!strcmp(k,"nnnn")) gr->RotateN(a[0].v, a[1].v, a[2].v, a[3].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_rotatetext(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetRotatedText(a[0].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tuneticks(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTuneTicks(iint(a[0].v)); + else if(!strcmp(k,"nn")) gr->SetTuneTicks(iint(a[0].v),a[1].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ticktime(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) gr->SetTicksTime(a[0].s[0]); + else if(!strcmp(k,"sn")) gr->SetTicksTime(a[0].s[0],a[1].v); + else if(!strcmp(k,"sns")) gr->SetTicksTime(a[0].s[0],a[1].v,a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_save(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Save(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_smooth(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) a[0].d->Smooth(); + else if(!strcmp(k,"ds")) a[0].d->Smooth(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_swap(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Swap(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_idset(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->SetColumnId(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_stem(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Stem(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Stem(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Stem(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Stem(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Stem(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Stem(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_step(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Step(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Step(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Step(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Step(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Step(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Step(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_plot(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Plot(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Plot(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Plot(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Plot(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Plot(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Plot(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tape(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Tape(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Tape(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Tape(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Tape(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Tape(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Tape(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_boxplot(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->BoxPlot(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->BoxPlot(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->BoxPlot(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->BoxPlot(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_candle(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Candle(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Candle(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dd")) gr->Candle(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Candle(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"ddddds"))gr->Candle(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_radar(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Radar(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Radar(*(a[0].d),a[1].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_squeeze(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Squeeze(iint(a[1].v)); + else if(!strcmp(k,"dnn")) a[0].d->Squeeze(iint(a[1].v), iint(a[2].v)); + else if(!strcmp(k,"dnnn")) a[0].d->Squeeze(iint(a[1].v), iint(a[2].v),iint(a[3].v)); + else if(!strcmp(k,"dnnnn")) a[0].d->Squeeze(iint(a[1].v), iint(a[2].v),iint(a[3].v), a[4].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_stfad(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dddn")) + *(a[0].d) = mglSTFA(*(a[1].d),*(a[2].d), iint(a[3].v)); + else if(!strcmp(k,"dddns")) + *(a[0].d) = mglSTFA(*(a[1].d),*(a[2].d), iint(a[3].v), a[4].s.c_str()[0]); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_setsize(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn") && a[1].v>1 && a[0].v>1) + gr->SetSize(iint(a[0].v), iint(a[1].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_sphere(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnn")) gr->Sphere(mglPoint(a[0].v,a[1].v), a[2].v); + else if(!strcmp(k,"nnns")) gr->Sphere(mglPoint(a[0].v,a[1].v), a[2].v, a[3].s.c_str()); + else if(!strcmp(k,"nnnn")) gr->Sphere(mglPoint(a[0].v,a[1].v,a[2].v), a[3].v); + else if(!strcmp(k,"nnnns")) gr->Sphere(mglPoint(a[0].v,a[1].v,a[2].v), a[3].v, a[4].s.c_str()); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_stfa(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddn")) + gr->STFA(*(a[0].d),*(a[1].d), iint(a[2].v), "",opt); + else if(!strcmp(k,"ddns")) + gr->STFA(*(a[0].d),*(a[1].d), iint(a[2].v), a[3].s.c_str(),opt); + else if(!strcmp(k,"ddddn")) + gr->STFA(*(a[0].d),*(a[1].d), *(a[2].d),*(a[3].d), iint(a[4].v), "",opt); + else if(!strcmp(k,"ddddns")) + gr->STFA(*(a[0].d),*(a[1].d), *(a[2].d),*(a[3].d), iint(a[4].v), a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surf3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Surf3(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Surf3(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"dn")) gr->Surf3(a[1].v,*(a[0].d),"",opt); + else if(!strcmp(k,"dns")) gr->Surf3(a[1].v,*(a[0].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Surf3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Surf3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddn")) gr->Surf3(a[4].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"ddddns"))gr->Surf3(a[4].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surf3c(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Surf3C(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Surf3C(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddn")) gr->Surf3C(a[2].v,*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"ddns")) gr->Surf3C(a[2].v,*(a[0].d),*(a[1].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) + gr->Surf3C(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), "",opt); + else if(!strcmp(k,"ddddds")) + gr->Surf3C(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), a[5].s.c_str(),opt); + else if(!strcmp(k,"dddddn")) + gr->Surf3C(a[5].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"dddddns")) + gr->Surf3C(a[5].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_surf3a(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Surf3A(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Surf3A(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddn")) gr->Surf3A(a[2].v,*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"ddns")) gr->Surf3A(a[2].v,*(a[0].d),*(a[1].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) + gr->Surf3A(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), "",opt); + else if(!strcmp(k,"ddddds")) + gr->Surf3A(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d), a[5].s.c_str(),opt); + else if(!strcmp(k,"dddddn")) + gr->Surf3A(a[5].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"dddddns")) + gr->Surf3A(a[5].v,*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_subplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnn")) gr->SubPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v)); + else if(!strcmp(k,"nnns")) gr->SubPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v), a[3].s.c_str()); + else if(!strcmp(k,"nnnsnn")) gr->SubPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v), a[3].s.c_str(), a[4].v,a[5].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_multiplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnnn")) + gr->MultiPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v), iint(a[3].v), iint(a[4].v)); + else if(!strcmp(k,"nnnnns")) + gr->MultiPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v), iint(a[3].v), iint(a[4].v), a[3].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_title(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"s")) gr->Title(a[0].w.c_str()); + else if(!strcmp(k,"ss")) gr->Title(a[0].w.c_str(), a[1].s.c_str()); + else if(!strcmp(k,"ssn")) gr->Title(a[0].w.c_str(), a[1].s.c_str(),a[2].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_column(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) *(a[0].d) = a[1].d->Column(a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_subdata(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddn")) *(a[0].d) = a[1].d->SubData(iint(a[2].v)); + else if(!strcmp(k,"ddnn")) *(a[0].d) = a[1].d->SubData(iint(a[2].v), iint(a[3].v)); + else if(!strcmp(k,"ddnnn")) *(a[0].d) = a[1].d->SubData(iint(a[2].v), iint(a[3].v), iint(a[4].v)); + else res = 1; + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_trace(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) *(a[0].d) = a[1].d->Trace(); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tile(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Tile(*(a[0].d),"",opt); + else if(!strcmp(k,"ds")) gr->Tile(*(a[0].d),a[1].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Tile(*(a[0].d), *(a[1].d), *(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Tile(*(a[0].d), *(a[1].d), *(a[2].d), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tiles(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->TileS(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->TileS(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->TileS(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->TileS(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_text(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) // NOTE don't use options -- Puts can be part of group +{ + int res=0; + if(k[0]=='n') + { + gr->Self()->SaveState(opt); + if(!strcmp(k,"nns")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN),a[2].w.c_str()); + else if(!strcmp(k,"nnss")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN),a[2].w.c_str(), a[3].s.c_str()); + else if(!strcmp(k,"nnssn")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN),a[2].w.c_str(), a[3].s.c_str(),a[4].v); + else if(!strcmp(k,"nnns")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v),a[3].w.c_str()); + else if(!strcmp(k,"nnnss")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v),a[3].w.c_str(), a[4].s.c_str()); + else if(!strcmp(k,"nnnssn")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v),a[3].w.c_str(), a[4].s.c_str(),a[5].v); + else if(!strcmp(k,"nnnns")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v), a[4].w.c_str()); + else if(!strcmp(k,"nnnnss")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v), a[4].w.c_str(), a[5].s.c_str()); + else if(!strcmp(k,"nnnnssn")) gr->Putsw(mglPoint(a[0].v,a[1].v,NAN), mglPoint(a[2].v,a[3].v), a[4].w.c_str(), a[5].s.c_str(),a[6].v); + else if(!strcmp(k,"nnnnnns")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].w.c_str()); + else if(!strcmp(k,"nnnnnnss")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].w.c_str(), a[7].s.c_str()); + else if(!strcmp(k,"nnnnnnssn")) gr->Putsw(mglPoint(a[0].v,a[1].v,a[2].v), mglPoint(a[3].v,a[4].v,a[5].v), a[6].w.c_str(), a[7].s.c_str(),a[8].v); + else res=1; + gr->Self()->LoadState(); + } + else if(!strcmp(k,"ds")) gr->Text(*(a[0].d),a[1].w.c_str(),"",opt); + else if(!strcmp(k,"dss")) gr->Text(*(a[0].d),a[1].w.c_str(),a[2].s.c_str(),opt); + else if(!strcmp(k,"dds")) gr->Text(*(a[0].d),*(a[1].d),a[2].w.c_str(),"",opt); + else if(!strcmp(k,"ddss")) gr->Text(*(a[0].d),*(a[1].d),a[2].w.c_str(),a[3].s.c_str(),opt); + else if(!strcmp(k,"ddds")) gr->Text(*(a[0].d),*(a[1].d),*(a[2].d),a[3].w.c_str(),"",opt); + else if(!strcmp(k,"dddss")) gr->Text(*(a[0].d),*(a[1].d),*(a[2].d),a[3].w.c_str(),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_torus(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Torus(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Torus(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_transptype(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTranspType(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fourier(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) mglFourier(*(a[0].d),*(a[1].d),a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_transform(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsdd")) *(a[0].d) = mglTransform(*(a[2].d),*(a[3].d),a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_transforma(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsdd")) *(a[0].d) = mglTransformA(*(a[2].d),*(a[3].d),a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tube(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dn")) + gr->Tube(*(a[0].d),a[1].v,"",opt); + else if(!strcmp(k,"dns")) + gr->Tube(*(a[0].d),a[1].v,a[2].s.c_str(),opt); + else if(!strcmp(k,"dd")) + gr->Tube(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) + gr->Tube(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddn")) + gr->Tube(*(a[0].d),*(a[1].d),a[2].v,"",opt); + else if(!strcmp(k,"ddns")) + gr->Tube(*(a[0].d),*(a[1].d),a[2].v,a[3].s.c_str(),opt); + else if(!strcmp(k,"ddd")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddn")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),a[3].v,"",opt); + else if(!strcmp(k,"dddns")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),a[3].v,a[4].s.c_str(),opt); + else if(!strcmp(k,"dddd")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) + gr->Tube(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_textmark(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ds")) gr->TextMark(*(a[0].d),a[1].w.c_str(),"",opt); + else if(!strcmp(k,"dss")) gr->TextMark(*(a[0].d),a[1].w.c_str(),a[2].s.c_str(),opt); + else if(!strcmp(k,"dds")) gr->TextMark(*(a[0].d),*(a[1].d),a[2].w.c_str(),"",opt); + else if(!strcmp(k,"ddss")) gr->TextMark(*(a[0].d),*(a[1].d),a[2].w.c_str(),a[3].s.c_str(),opt); + else if(!strcmp(k,"ddds")) gr->TextMark(*(a[0].d),*(a[1].d),*(a[2].d),a[3].w.c_str(),"",opt); + else if(!strcmp(k,"dddss")) gr->TextMark(*(a[0].d),*(a[1].d),*(a[2].d),a[3].w.c_str(),a[4].s.c_str(),opt); + else if(!strcmp(k,"dddds")) gr->TextMark(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].w.c_str(),"",opt); + else if(!strcmp(k,"ddddss"))gr->TextMark(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].w.c_str(),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_triplot(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"ddddds"))gr->TriPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_quadplot(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"ddddds"))gr->QuadPlot(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tricont(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dddd")) + gr->TriCont(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) + gr->TriCont(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"ddddd")) + gr->TriContV(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),"",opt); + else if(!strcmp(k,"ddddds")) + gr->TriContV(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),a[5].s.c_str(),opt); + else if(!strcmp(k,"dddddd")) + gr->TriContV(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"dddddds")) + gr->TriContV(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ternary(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->Ternary(int(a[0].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_transpose(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) a[0].d->Transpose(); + else if(!strcmp(k,"ds")) a[0].d->Transpose(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_vect(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Vect(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Vect(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"dddddd")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"dddddds")) gr->Vect(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_vect3(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),"",-1,opt); + else if(!strcmp(k,"ddds")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),-1,opt); + else if(!strcmp(k,"dddsn")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),a[4].v,opt); + else if(!strcmp(k,"dddddd")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",-1,opt); + else if(!strcmp(k,"dddddds")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),-1,opt); + else if(!strcmp(k,"ddddddsn")) + gr->Vect3(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),a[7].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_traj(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dddd")) + gr->Traj(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) + gr->Traj(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"dddddd")) + gr->Traj(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"dddddds")) + gr->Traj(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_xlabel(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->Label('x', a[0].w.c_str(), 1, opt); + else if(!strcmp(k,"sn")) gr->Label('x', a[0].w.c_str(), a[1].v, opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ylabel(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->Label('y', a[0].w.c_str(), 1, opt); + else if(!strcmp(k,"sn")) gr->Label('y', a[0].w.c_str(), a[1].v, opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_zlabel(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->Label('z', a[0].w.c_str(), 1, opt); + else if(!strcmp(k,"sn")) gr->Label('z', a[0].w.c_str(), a[1].v, opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tlabel(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->Label('t', a[0].w.c_str(), 1, opt); + else if(!strcmp(k,"sn")) gr->Label('t', a[0].w.c_str(), a[1].v, opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_label(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ds")) gr->Label(*(a[0].d), a[1].w.c_str(), "",opt); + else if(!strcmp(k,"dss")) gr->Label(*(a[0].d), a[1].w.c_str(), a[2].s.c_str(),opt); + else if(!strcmp(k,"dds")) gr->Label(*(a[0].d), *(a[1].d), a[2].w.c_str(), "",opt); + else if(!strcmp(k,"ddss")) gr->Label(*(a[0].d), *(a[1].d), a[2].w.c_str(), a[3].s.c_str(),opt); + else if(!strcmp(k,"ddds")) gr->Label(*(a[0].d), *(a[1].d), *(a[2].d), a[3].w.c_str(), "",opt); + else if(!strcmp(k,"dddss")) gr->Label(*(a[0].d), *(a[1].d), *(a[2].d), a[3].w.c_str(), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_table(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"d")) gr->Table(*(a[0].d), L"", "#|",opt); + else if(!strcmp(k,"ds")) gr->Table(*(a[0].d), a[1].w.c_str(), "#|",opt); + else if(!strcmp(k,"dss")) gr->Table(*(a[0].d), a[1].w.c_str(), a[2].s.c_str(),opt); + else if(!strcmp(k,"nnd")) gr->Table(a[0].v, a[1].v, *(a[2].d), L"", "#|",opt); + else if(!strcmp(k,"nnds")) gr->Table(a[0].v, a[1].v, *(a[2].d), a[3].w.c_str(), "#|",opt); + else if(!strcmp(k,"nndss")) gr->Table(a[0].v, a[1].v, *(a[2].d), a[3].w.c_str(), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_xrange(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) gr->SetRange('x',*(a[0].d)); + else if(!strcmp(k,"dn")) gr->SetRange('x',*(a[0].d),a[1].v); + else if(!strcmp(k,"nn")) gr->SetRange('x', a[0].v, a[1].v); + else if(!strcmp(k,"nnn")) + { + if(a[2].v) gr->AddRange('x', a[0].v, a[1].v); + else gr->SetRange('x', a[0].v, a[1].v); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_yrange(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) gr->SetRange('y',*(a[0].d)); + else if(!strcmp(k,"dn")) gr->SetRange('y',*(a[0].d),a[1].v); + else if(!strcmp(k,"nn")) gr->SetRange('y', a[0].v, a[1].v); + else if(!strcmp(k,"nnn")) + { + if(a[2].v) gr->AddRange('y', a[0].v, a[1].v); + else gr->SetRange('y', a[0].v, a[1].v); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_zrange(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) gr->SetRange('z',*(a[0].d)); + else if(!strcmp(k,"dn")) gr->SetRange('z',*(a[0].d),a[1].v); + else if(!strcmp(k,"nn")) gr->SetRange('z', a[0].v, a[1].v); + else if(!strcmp(k,"nnn")) + { + if(a[2].v) gr->AddRange('z', a[0].v, a[1].v); + else gr->SetRange('z', a[0].v, a[1].v); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_xtick(mglGraph *gr, long n, mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTicks('x', a[0].v); + else if(!strcmp(k,"nn")) gr->SetTicks('x', a[0].v, iint(a[1].v)); + else if(!strcmp(k,"nnn")) gr->SetTicks('x', a[0].v, iint(a[1].v), a[2].v); + else if(!strcmp(k,"s")) gr->SetTickTempl('x',a[0].w.c_str()); + else if(!strcmp(k,"ds")) gr->SetTicksVal('x', *(a[0].d), a[1].w.c_str()); + else if(!strcmp(k,"dsn")) gr->SetTicksVal('x', *(a[0].d), a[1].w.c_str(), a[2].v); + else if(!strncmp(k,"ns",2)) + { + mreal v[50]; std::wstring s; int i; + for(i=0;i<50 && iSetTicksVal('x',mglData(i,v),s.c_str()); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ytick(mglGraph *gr, long n, mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTicks('y', a[0].v); + else if(!strcmp(k,"nn")) gr->SetTicks('y', a[0].v, iint(a[1].v)); + else if(!strcmp(k,"nnn")) gr->SetTicks('y', a[0].v, iint(a[1].v), a[2].v); + else if(!strcmp(k,"s")) gr->SetTickTempl('y',a[0].w.c_str()); + else if(!strcmp(k,"ds")) gr->SetTicksVal('y', *(a[0].d), a[1].w.c_str()); + else if(!strcmp(k,"dsn")) gr->SetTicksVal('y', *(a[0].d), a[1].w.c_str(), a[2].v); + else if(!strncmp(k,"ns",2)) + { + mreal v[50]; std::wstring s; int i; + for(i=0;i<50 && iSetTicksVal('y',mglData(i,v),s.c_str()); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ztick(mglGraph *gr, long n, mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTicks('z', a[0].v); + else if(!strcmp(k,"nn")) gr->SetTicks('z', a[0].v, iint(a[1].v)); + else if(!strcmp(k,"nnn")) gr->SetTicks('z', a[0].v, iint(a[1].v), a[2].v); + else if(!strcmp(k,"s")) gr->SetTickTempl('z',a[0].w.c_str()); + else if(!strcmp(k,"ds")) gr->SetTicksVal('z', *(a[0].d), a[1].w.c_str()); + else if(!strcmp(k,"dsn")) gr->SetTicksVal('z', *(a[0].d), a[1].w.c_str(), a[2].v); + else if(!strncmp(k,"ns",2)) + { + mreal v[50]; std::wstring s; int i; + for(i=0;i<50 && iSetTicksVal('z',mglData(i,v),s.c_str()); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_error(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Error(*(a[0].d),*(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Error(*(a[0].d),*(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Error(*(a[0].d),*(a[1].d),*(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Error(*(a[0].d),*(a[1].d),*(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Error(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Error(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_extend(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Extend(iint(a[1].v)); + else if(!strcmp(k,"dnn")) a[0].d->Extend(iint(a[1].v),iint(a[2].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_join(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dd")) a[0].d->Join(*(a[1].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_datas(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) + { + char *buf=new char[1024]; + mgl_datas_hdf(a[0].s.c_str(),buf,1024); + gr->SetWarn(-1,buf); + delete []buf; + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_info(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) gr->SetWarn(-1,a[0].d->PrintInfo()); + else if(!strcmp(k,"s")) gr->SetWarn(-1,a[0].s.c_str()); + else if(!strcmp(k,"n")) + { char buf[128]; snprintf(buf,128,"value = %g",a[0].v); gr->SetWarn(-1,buf); } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_integrate(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Integral(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_inplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnn")) gr->InPlot(a[0].v, a[1].v, a[2].v, a[3].v); + else if(!strcmp(k,"nnnnn")) gr->InPlot(a[0].v, a[1].v, a[2].v, a[3].v, a[4].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_columnplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->ColumnPlot(iint(a[0].v), iint(a[1].v)); + else if(!strcmp(k,"nnn")) gr->ColumnPlot(iint(a[0].v), iint(a[1].v), a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_gridplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnn")) gr->GridPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v)); + else if(!strcmp(k,"nnnn")) gr->GridPlot(iint(a[0].v), iint(a[1].v), iint(a[2].v), a[3].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_stickplot(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnn")) gr->StickPlot(iint(a[0].v), iint(a[1].v), a[2].v, a[3].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_pipe(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Pipe(*(a[0].d),*(a[1].d),"",0.05,opt); + else if(!strcmp(k,"dds")) gr->Pipe(*(a[0].d),*(a[1].d),a[2].s.c_str(),0.05,opt); + else if(!strcmp(k,"ddsn")) gr->Pipe(*(a[0].d),*(a[1].d),a[2].s.c_str(),a[3].v,opt); + else if(!strcmp(k,"dddd")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",0.05,opt); + else if(!strcmp(k,"dddds")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),0.05,opt); + else if(!strcmp(k,"ddddsn")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),a[5].v,opt); + else if(!strcmp(k,"ddd")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),"",0.05,opt); + else if(!strcmp(k,"ddds")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),0.05,opt); + else if(!strcmp(k,"dddsn")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),a[4].v,opt); + else if(!strcmp(k,"dddddd")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",0.05,opt); + else if(!strcmp(k,"dddddds")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),0.05,opt); + else if(!strcmp(k,"ddddddsn")) + gr->Pipe(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),a[7].v,opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_origin(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->SetOrigin(a[0].v,a[1].v,NAN); + else if(!strcmp(k,"nnn")) gr->SetOrigin(a[0].v,a[1].v,a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_norm(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dnn")) a[0].d->Norm(a[1].v,a[2].v); + else if(!strcmp(k,"dnnn")) a[0].d->Norm(a[1].v,a[2].v,a[3].v!=0); + else if(!strcmp(k,"dnnnn")) a[0].d->Norm(a[1].v,a[2].v,a[3].v!=0,iint(a[4].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_hist(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddd")) *(a[0].d) = gr->Hist(*(a[1].d), *(a[2].d),opt); + else if(!strcmp(k,"dddd")) *(a[0].d) = gr->Hist(*(a[1].d), *(a[2].d), *(a[3].d),opt); + else if(!strcmp(k,"ddddd")) *(a[0].d) = gr->Hist(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d),opt); + else if(!strcmp(k,"ddnnn")) *(a[0].d) = a[1].d->Hist(int(a[2].v+0.5), a[3].v, a[4].v); + else if(!strcmp(k,"ddnnnn")) *(a[0].d) = a[1].d->Hist(int(a[2].v+0.5), a[3].v, a[4].v, int(a[5].v+0.5)); + else if(!strcmp(k,"dddnnn")) *(a[0].d) = a[1].d->Hist(*(a[2].d), int(a[3].v+0.5), a[4].v, a[5].v); + else if(!strcmp(k,"dddnnnn")) *(a[0].d) = a[1].d->Hist(*(a[2].d), int(a[3].v+0.5), a[4].v, a[5].v, int(a[6].v+0.5)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_mirror(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Mirror(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_hankel(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Hankel(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_sinfft(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->SinFFT(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_cosfft(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->CosFFT(a[1].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_new(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Create(iint(a[1].v)); + else if(!strcmp(k,"dns")) + { a[0].d->Create(iint(a[1].v)); + a[0].d->Fill(gr->Self(),a[2].s.c_str(),opt); } + else if(!strcmp(k,"dnn")) a[0].d->Create(iint(a[1].v),iint(a[2].v)); + else if(!strcmp(k,"dnns")) + { a[0].d->Create(iint(a[1].v),iint(a[2].v)); + a[0].d->Fill(gr->Self(),a[3].s.c_str(),opt); } + else if(!strcmp(k,"dnnn")) a[0].d->Create(iint(a[1].v),iint(a[2].v),iint(a[3].v)); + else if(!strcmp(k,"dnnns")) + { a[0].d->Create(iint(a[1].v),iint(a[2].v),iint(a[3].v)); + a[0].d->Fill(gr->Self(),a[4].s.c_str(),opt); } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_var(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dnn")) + { a[0].d->Create(iint(a[1].v)); a[0].d->Fill(a[2].v, NAN); } + else if(!strcmp(k,"dnnn")) + { a[0].d->Create(iint(a[1].v)); a[0].d->Fill(a[2].v, a[3].v); } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_chdir(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) + { if(chdir(a[0].s.c_str())) gr->SetWarn(mglWarnFile,"chdir"); } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_perspective(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->Perspective(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_facex(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) gr->FaceX(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v); + else if(!strcmp(k,"nnnnns")) gr->FaceX(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnsnn")) gr->FaceX(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str(),a[6].v,a[7].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_facey(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) gr->FaceY(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v); + else if(!strcmp(k,"nnnnns")) gr->FaceY(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnsnn")) gr->FaceY(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str(),a[6].v,a[7].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_facez(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nnnnn")) gr->FaceZ(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v); + else if(!strcmp(k,"nnnnns")) gr->FaceZ(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str()); + else if(!strcmp(k,"nnnnnsnn")) gr->FaceZ(mglPoint(a[0].v, a[1].v, a[2].v), a[3].v, a[4].v, a[5].s.c_str(),a[6].v,a[7].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_normsl(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dnn")) a[0].d->NormSl(a[1].v, a[2].v); + else if(!strcmp(k,"dnns")) a[0].d->NormSl(a[1].v, a[2].v, a[3].s.c_str()[0]); + else if(!strcmp(k,"dnnsn")) a[0].d->NormSl(a[1].v, a[2].v, a[3].s.c_str()[0],a[4].v); + else if(!strcmp(k,"dnnsnn"))a[0].d->NormSl(a[1].v, a[2].v, a[3].s.c_str()[0],a[4].v,a[5].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_momentum(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dds")) *(a[0].d) = a[1].d->Momentum('z', a[2].s.c_str()); + else if(!strcmp(k,"ddss")) *(a[0].d) = a[1].d->Momentum(a[3].s.c_str()[0], a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fit(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dddddssd")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(), a[6].s.c_str(), *(a[7].d),opt); + else if(!strcmp(k,"dddddss")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(), a[6].s.c_str(),opt); + else if(!strcmp(k,"ddddssd")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(), a[5].s.c_str(), *(a[6].d),opt); + else if(!strcmp(k,"ddddss")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(), a[5].s.c_str(),opt); + else if(!strcmp(k,"dddssd")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), a[3].s.c_str(), a[4].s.c_str(), *(a[5].d),opt); + else if(!strcmp(k,"dddss")) + *(a[0].d) = gr->Fit(*(a[1].d), *(a[2].d), a[3].s.c_str(), a[4].s.c_str(),opt); + else if(!strcmp(k,"ddssd")) + *(a[0].d) = gr->Fit(*(a[1].d), a[2].s.c_str(), a[3].s.c_str(), *(a[4].d),opt); + else if(!strcmp(k,"ddss")) + *(a[0].d) = gr->Fit(*(a[1].d), a[2].s.c_str(), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fits(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"ddddddssd")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), *(a[5].d), a[6].s.c_str(), a[7].s.c_str(), *(a[8].d),opt); + else if(!strcmp(k,"ddddddss")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), *(a[5].d), a[6].s.c_str(), a[7].s.c_str(),opt); + else if(!strcmp(k,"dddddssd")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(), a[6].s.c_str(), *(a[7].d),opt); + else if(!strcmp(k,"dddddss")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), *(a[4].d), a[5].s.c_str(), a[6].s.c_str(),opt); + else if(!strcmp(k,"ddddssd")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(), a[5].s.c_str(), *(a[6].d),opt); + else if(!strcmp(k,"ddddss")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), *(a[3].d), a[4].s.c_str(), a[5].s.c_str(),opt); + else if(!strcmp(k,"dddssd")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), a[3].s.c_str(), a[4].s.c_str(), *(a[5].d),opt); + else if(!strcmp(k,"dddss")) + *(a[0].d) = gr->FitS(*(a[1].d), *(a[2].d), a[3].s.c_str(), a[4].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_putsfit(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; gr->Self()->SaveState(opt); + if(!strcmp(k,"nn")) gr->PutsFit(mglPoint(a[0].v,a[1].v)); + else if(!strcmp(k,"nns")) gr->PutsFit(mglPoint(a[0].v,a[1].v), a[2].s.c_str()); + else if(!strcmp(k,"nnss")) gr->PutsFit(mglPoint(a[0].v,a[1].v), a[2].s.c_str(),a[3].s.c_str()); + else if(!strcmp(k,"nnssn")) gr->PutsFit(mglPoint(a[0].v,a[1].v), a[2].s.c_str(),a[3].s.c_str(),a[4].v); + else if(!strcmp(k,"nnn")) gr->PutsFit(mglPoint(a[0].v,a[1].v,a[2].v)); + else if(!strcmp(k,"nnns")) gr->PutsFit(mglPoint(a[0].v,a[1].v,a[2].v), a[3].s.c_str()); + else if(!strcmp(k,"nnnss")) gr->PutsFit(mglPoint(a[0].v,a[1].v,a[2].v), a[3].s.c_str(),a[4].s.c_str()); + else if(!strcmp(k,"nnnssn"))gr->PutsFit(mglPoint(a[0].v,a[1].v,a[2].v), a[3].s.c_str(),a[4].s.c_str(),a[5].v); + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_arrowsize(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetArrowSize(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_rearrange(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Rearrange(iint(a[1].v)); + else if(!strcmp(k,"dnn")) a[0].d->Rearrange(iint(a[1].v), iint(a[2].v)); + else if(!strcmp(k,"dnnn")) a[0].d->Rearrange(iint(a[1].v), iint(a[2].v), iint(a[3].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ctick(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) gr->SetTickTempl('c',a[0].w.c_str()); + else if(!strcmp(k,"n")) gr->SetTicks('c',a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fplot(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->FPlot(a[0].s.c_str(), "",opt); + else if(!strcmp(k,"ss")) gr->FPlot(a[0].s.c_str(), a[1].s.c_str(),opt); + else if(!strcmp(k,"sss")) gr->FPlot(a[0].s.c_str(), a[1].s.c_str(), a[2].s.c_str(), "",opt); + else if(!strcmp(k,"ssss")) gr->FPlot(a[0].s.c_str(), a[1].s.c_str(), a[2].s.c_str(), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fsurf(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"s")) gr->FSurf(a[0].s.c_str(), "",opt); + else if(!strcmp(k,"ss")) gr->FSurf(a[0].s.c_str(), a[1].s.c_str(),opt); + else if(!strcmp(k,"sss")) gr->FSurf(a[0].s.c_str(), a[1].s.c_str(), a[2].s.c_str(), "",opt); + else if(!strcmp(k,"ssss")) gr->FSurf(a[0].s.c_str(), a[1].s.c_str(), a[2].s.c_str(), a[3].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_fgets(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) // NOTE don't use options -- Puts can be part of group +{ + int res=0; gr->Self()->SaveState(opt); + char buf[1024]; + FILE *fp; + if(!strncmp(k,"nns",3)) + { + int i, n = (k[3]=='n'?iint(a[3].v):0); + fp = fopen(a[2].s.c_str(),"rt"); + if(!fp) + { + gr->SetWarn(mglWarnOpen,a[2].s.c_str()); + return res; +} + for(i=0;iSetWarn(mglWarnOpen,(a[2].s+" - line "+b).c_str()); + fclose(fp); return res; + } + fclose(fp); + gr->Puts(mglPoint(a[0].v,a[1].v,NAN),buf, (k[4]=='s')?a[4].s.c_str():"", k[5]=='n'?a[5].v:-1); + } + else if(!strncmp(k,"nnns",4)) + { + int i, n = (k[4]=='n'?iint(a[4].v):0); + fp = fopen(a[3].s.c_str(),"rt"); + if(!fp) + { + gr->SetWarn(mglWarnOpen,a[3].s.c_str()); + return res; + } + for(i=0;iSetWarn(mglWarnOpen,(a[3].s+" - line "+b).c_str()); + fclose(fp); return res; + } + fclose(fp); + gr->Puts(mglPoint(a[0].v,a[1].v,a[2].v),buf, (k[5]=='s')?a[5].s.c_str():"", k[6]=='n'?a[6].v:-1); + } + else res = 1; gr->Self()->LoadState(); return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_import(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dss")) a[0].d->Import(a[1].s.c_str(), a[2].s.c_str()); + else if(!strcmp(k,"dssnn")) a[0].d->Import(a[1].s.c_str(), a[2].s.c_str(), a[3].v,a[4].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_export(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dss")) a[0].d->Export(a[1].s.c_str(), a[2].s.c_str()); + else if(!strcmp(k,"dssnn")) a[0].d->Export(a[1].s.c_str(), a[2].s.c_str(), a[3].v,a[4].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_write(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->WriteFrame("", "MathGL"); + else if(!strcmp(k,"s")) gr->WriteFrame(a[0].s.c_str(), "MathGL"); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_region(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Region(*(a[0].d),*(a[1].d),"",opt); + else if(!strcmp(k,"dds")) gr->Region(*(a[0].d),*(a[1].d),a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),"",opt); + else if(!strcmp(k,"ddds")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),"",opt); + else if(!strcmp(k,"dddds")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),a[4].s.c_str(),opt); + else if(!strcmp(k,"dddddd")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),"",opt); + else if(!strcmp(k,"dddddds")) gr->Region(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d),*(a[4].d),*(a[5].d),a[6].s.c_str(),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_envelop(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) a[0].d->Envelop(); + else if(!strcmp(k,"ds")) a[0].d->Envelop(a[1].s.c_str()[0]); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_sew(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"d")) a[0].d->Sew(); + else if(!strcmp(k,"ds")) a[0].d->Sew(a[1].s.c_str()); + else if(!strcmp(k,"dsn")) a[0].d->Sew(a[1].s.c_str(), a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_evaluate(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddd")) *(a[0].d) = a[1].d->Evaluate(*(a[2].d)); + else if(!strcmp(k,"dddn")) *(a[0].d) = a[1].d->Evaluate(*(a[2].d), a[3].v!=0); + else if(!strcmp(k,"dddd")) *(a[0].d) = a[1].d->Evaluate(*(a[2].d), *(a[3].d)); + else if(!strcmp(k,"ddddn")) *(a[0].d) = a[1].d->Evaluate(*(a[2].d), *(a[3].d), a[4].v!=0); + else if(!strcmp(k,"ddddd")) *(a[0].d) = a[1].d->Evaluate(*(a[2].d), *(a[3].d), *(a[4].d)); + else if(!strcmp(k,"dddddn"))*(a[0].d) = a[1].d->Evaluate(*(a[2].d), *(a[3].d), *(a[4].d), a[5].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_solve(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddns")) *(a[0].d) = a[1].d->Solve(a[2].v, a[3].s[0]); + else if(!strcmp(k,"ddnsn")) *(a[0].d) = a[1].d->Solve(a[2].v, a[3].s[0], a[4].v!=0); + else if(!strcmp(k,"ddnsd")) *(a[0].d) = a[1].d->Solve(a[2].v, a[3].s[0], *(a[4].d)); + else if(!strcmp(k,"ddnsdn"))*(a[0].d) = a[1].d->Solve(a[2].v, a[3].s[0], *(a[4].d), a[5].v!=0); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_put(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dn")) a[0].d->Put(a[1].v); + else if(!strcmp(k,"dnn")) a[0].d->Put(a[1].v, iint(a[2].v)); + else if(!strcmp(k,"dnnn")) a[0].d->Put(a[1].v, iint(a[2].v),iint(a[3].v)); + else if(!strcmp(k,"dnnnn")) a[0].d->Put(a[1].v, iint(a[2].v),iint(a[3].v),iint(a[4].v)); + else if(!strcmp(k,"dd")) a[0].d->Put(*(a[1].d)); + else if(!strcmp(k,"ddn")) a[0].d->Put(*(a[1].d), iint(a[2].v)); + else if(!strcmp(k,"ddnn")) a[0].d->Put(*(a[1].d), iint(a[2].v),iint(a[3].v)); + else if(!strcmp(k,"ddnnn")) a[0].d->Put(*(a[1].d), iint(a[2].v),iint(a[3].v),iint(a[4].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_palette(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"s")) gr->SetPalette(a[0].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_combine(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddd")) *(a[0].d) = a[1].d->Combine(*(a[2].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_correl(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddds")) *(a[0].d) = a[1].d->Correl(*(a[2].d), a[3].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_roots(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsds")) *(a[0].d) = a[2].d->Roots(a[1].s.c_str(), a[3].s[0]); + else if(!strcmp(k,"dsns")) a[0].d->a[0] = mgl_find_root_txt(a[1].s.c_str(), a[2].v, a[3].s[0]); + else if(!strcmp(k,"dsd")) *(a[0].d) = a[2].d->Roots(a[1].s.c_str(), 'x'); + else if(!strcmp(k,"dsn")) a[0].d->a[0] = mgl_find_root_txt(a[1].s.c_str(), a[2].v, 'x'); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_pde(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dsdd")) + *(a[0].d) = gr->PDE(a[1].s.c_str(), *(a[2].d), *(a[3].d), 0.1,100,opt); + else if(!strcmp(k,"dsddn")) + *(a[0].d) = gr->PDE(a[1].s.c_str(), *(a[2].d), *(a[3].d), a[4].v,100,opt); + else if(!strcmp(k,"dsddnn")) + *(a[0].d) = gr->PDE(a[1].s.c_str(), *(a[2].d), *(a[3].d), a[4].v,a[5].v,opt); + else if(!strcmp(k,"ddsdd")) + { + HADT res = mgl_pde_solve_c(gr->Self(),a[2].s.c_str(), a[3].d, a[4].d, 0.1,100,opt); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsddn")) + { + HADT res = mgl_pde_solve_c(gr->Self(),a[2].s.c_str(), a[3].d, a[4].d, a[5].v,100,opt); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsddnn")) + { + HADT res = mgl_pde_solve_c(gr->Self(),a[2].s.c_str(), a[3].d, a[4].d, a[5].v,a[6].v,opt); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_qo2d(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsddd")) + *(a[0].d) = mglData(true, mgl_qo2d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, 1,100, 0,0)); + else if(!strcmp(k,"dsdddn")) + *(a[0].d) = mglData(true, mgl_qo2d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,100, 0,0)); + else if(!strcmp(k,"dsdddnn")) + *(a[0].d) = mglData(true, mgl_qo2d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,a[6].v, 0,0)); + else if(!strcmp(k,"dsdddnndd")) + *(a[0].d) = mglData(true, mgl_qo2d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,a[6].v, a[7].d,a[8].d)); + else if(!strcmp(k,"ddsddd")) + { + HADT res = mgl_qo2d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, 1,100, 0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddn")) + { + HADT res = mgl_qo2d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,100, 0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddnn")) + { + HADT res = mgl_qo2d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,a[7].v, 0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddnndd")) + { + HADT res = mgl_qo2d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,a[7].v, a[8].d,a[9].d); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_qo3d(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsddd")) + *(a[0].d) = mglData(true, mgl_qo3d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, 1,100, 0,0,0)); + else if(!strcmp(k,"dsdddn")) + *(a[0].d) = mglData(true, mgl_qo3d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,100, 0,0,0)); + else if(!strcmp(k,"dsdddnn")) + *(a[0].d) = mglData(true, mgl_qo3d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,a[6].v, 0,0,0)); + else if(!strcmp(k,"dsdddnnddd")) + *(a[0].d) = mglData(true, mgl_qo3d_solve(a[1].s.c_str(), a[2].d, a[3].d, a[4].d, a[5].v,a[6].v, a[7].d,a[8].d,a[9].d)); + else if(!strcmp(k,"ddsddd")) + { + HADT res = mgl_qo3d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, 1,100, 0,0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddn")) + { + HADT res = mgl_qo3d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,100, 0,0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddnn")) + { + HADT res = mgl_qo3d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,a[7].v, 0,0,0); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else if(!strcmp(k,"ddsdddnnddd")) + { + HADT res = mgl_qo3d_solve_c(a[2].s.c_str(), a[3].d, a[4].d, a[5].d, a[6].v,a[7].v, a[8].d,a[9].d,a[10].d); + *(a[0].d) = res->Abs(); *(a[1].d) = res->Arg(); + } + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ray(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsnnnn")) + *(a[0].d) = mglRay(a[1].s.c_str(), mglPoint(a[2].v, a[3].v), mglPoint(a[4].v, a[5].v)); + else if(!strcmp(k,"dsnnnnnn")) + *(a[0].d) = mglRay(a[1].s.c_str(), mglPoint(a[2].v, a[3].v, a[4].v), mglPoint(a[5].v, a[6].v, a[7].v)); + else if(!strcmp(k,"dsnnnnnnn")) + *(a[0].d) = mglRay(a[1].s.c_str(), mglPoint(a[2].v, a[3].v, a[4].v), mglPoint(a[5].v, a[6].v, a[7].v), a[8].v); + else if(!strcmp(k,"dsnnnnnnnn")) + *(a[0].d) = mglRay(a[1].s.c_str(), mglPoint(a[2].v, a[3].v, a[4].v), mglPoint(a[5].v, a[6].v, a[7].v), a[8].v,a[9].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_jacobian(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddd")) *(a[0].d) = mglJacobian(*(a[1].d), *(a[2].d)); + else if(!strcmp(k,"dddd")) *(a[0].d) = mglJacobian(*(a[1].d), *(a[2].d), *(a[3].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tens(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dd")) gr->Tens(*(a[0].d),*(a[1].d), "",opt); + else if(!strcmp(k,"dds")) gr->Tens(*(a[0].d),*(a[1].d), a[2].s.c_str(),opt); + else if(!strcmp(k,"ddd")) gr->Tens(*(a[0].d),*(a[1].d),*(a[2].d), "",opt); + else if(!strcmp(k,"ddds")) gr->Tens(*(a[0].d),*(a[1].d),*(a[2].d), a[3].s.c_str(),opt); + else if(!strcmp(k,"dddd")) gr->Tens(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), "",opt); + else if(!strcmp(k,"dddds")) gr->Tens(*(a[0].d),*(a[1].d),*(a[2].d),*(a[3].d), a[4].s.c_str(),opt); + return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ticklen(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTickLen(a[0].v); + else if(!strcmp(k,"nn")) gr->SetTickLen(a[0].v, a[1].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_tickshift(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetTickShift(mglPoint(a[0].v)); + else if(!strcmp(k,"nn")) gr->SetTickShift(mglPoint(a[0].v, a[1].v)); + else if(!strcmp(k,"nnn")) gr->SetTickShift(mglPoint(a[0].v, a[1].v, a[2].v)); + else if(!strcmp(k,"nnnn")) gr->SetTickShift(mglPoint(a[0].v, a[1].v, a[2].v, a[3].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_origintick(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"n")) gr->SetOriginTick(a[0].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_axisstl(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->SetAxisStl(); + else if(!strcmp(k,"s")) gr->SetAxisStl(a[0].s.c_str()); + else if(!strcmp(k,"ss")) gr->SetAxisStl(a[0].s.c_str(), a[1].s.c_str()); + else if(!strcmp(k,"sss")) gr->SetAxisStl(a[0].s.c_str(), a[1].s.c_str(), a[2].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_ranges(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnn")) gr->SetRanges(a[0].v,a[1].v, a[2].v,a[3].v); + else if(!strcmp(k,"nnnnnn"))gr->SetRanges(a[0].v,a[1].v,a[2].v, a[3].v,a[4].v,a[5].v); + else if(!strcmp(k,"dd")) gr->SetRanges(*(a[0].d),*(a[1].d)); + else if(!strcmp(k,"ddd")) gr->SetRanges(*(a[0].d),*(a[1].d), *(a[2].d)); + else if(!strcmp(k,"dddd")) gr->SetRanges(*(a[0].d),*(a[1].d), *(a[2].d),*(a[3].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_adjust(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->Adjust(); + else if(!strcmp(k,"s")) gr->Adjust(a[0].s.c_str()); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_insert(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Insert(a[1].s.c_str()[0]); + else if(!strcmp(k,"dsn")) a[0].d->Insert(a[1].s.c_str()[0], iint(a[2].v)); + else if(!strcmp(k,"dsnn")) a[0].d->Insert(a[1].s.c_str()[0], iint(a[2].v), iint(a[3].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_delete(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ds")) a[0].d->Delete(a[1].s.c_str()[0]); + else if(!strcmp(k,"dsn")) a[0].d->Delete(a[1].s.c_str()[0], iint(a[2].v)); + else if(!strcmp(k,"dsnn")) a[0].d->Delete(a[1].s.c_str()[0], iint(a[2].v), iint(a[3].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_roll(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"dsn")) a[0].d->Roll(a[1].s.c_str()[0], iint(a[2].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_datagrid(mglGraph *gr, long , mglArg *a, const char *k, const char *opt) +{ + int res=0; + if(!strcmp(k,"dddd")) gr->DataGrid(*(a[0].d), *(a[1].d), *(a[2].d), *(a[3].d),opt); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_triangulate(mglGraph *, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"ddd")) + *(a[0].d) = mglTriangulation(*(a[1].d), *(a[2].d)); + else if(!strcmp(k,"dddd")) + *(a[0].d) = mglTriangulation(*(a[1].d), *(a[2].d), *(a[3].d)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_view(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->View(a[0].v, a[1].v); + else if(!strcmp(k,"nnn")) gr->View(a[0].v, a[1].v, a[2].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_zoom(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nnnn")) gr->Zoom(a[0].v, a[1].v, a[2].v, a[3].v); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_zoomaxis(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"nn")) gr->ZoomAxis(mglPoint(a[0].v), mglPoint(a[1].v)); + else if(!strcmp(k,"nnnn")) gr->ZoomAxis(mglPoint(a[0].v, a[1].v), mglPoint(a[2].v, a[3].v)); + else if(!strcmp(k,"nnnnnn")) gr->ZoomAxis(mglPoint(a[0].v, a[1].v, a[2].v), mglPoint(a[3].v, a[4].v, a[5].v)); + else if(!strcmp(k,"nnnnnnnn")) gr->ZoomAxis(mglPoint(a[0].v, a[1].v, a[2].v, a[3].v), mglPoint(a[4].v, a[5].v, a[6].v, a[7].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgls_drawreg(mglGraph *gr, long , mglArg *a, const char *k, const char *) +{ + int res=0; + if(!strcmp(k,"")) gr->SetDrawReg(); + if(!strcmp(k,"nnn")) gr->SetDrawReg(iint(a[0].v), iint(a[1].v), iint(a[2].v)); + else res = 1; return res; +} +//----------------------------------------------------------------------------- +mglCommand mgls_base_cmd[] = { + {"addlegend","Add legend entry","addlegend 'txt' 'fmt'", mgls_addlegend,15}, + {"addto","Add data or number","addto Var Dat|Var num", mgls_addto ,3}, + {"adjust","Adjust ticks for best view","adjust ['dir']", mgls_adjust ,14}, + {"alpha","Switch on/off transparency","alpha [val]", mgls_alpha ,2}, + {"alphadef","Set default transparency","alphadef val", mgls_alphadef ,2}, + {"ambient","Set ambient light brightness","ambient val", mgls_ambient ,2}, + {"area","Draw area plot for 1D data","area Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_area ,7}, + {"arrowsize","Set size of arrows","arrowsize val", mgls_arrowsize ,2}, + {"ask","Define parameter from user input","ask $N 'question'", 0, 6}, + {"aspect","Set aspect ration","aspect valx valy [valz]", mgls_aspect ,5}, + {"axial","Draw surfaces of contour lines rotation","axial Zdat ['fmt' num]|Xdat Ydat Zdat ['fmt' num]", mgls_axial ,8}, + {"axis","Setup or draw axis","axis ['dir' 'fmt']|'fx' 'fy' 'fz' ['fc']|how", mgls_axis ,12}, + {"axisstl","Set axis and tick style","axisstl 'stl' ['sub']", mgls_axisstl ,14}, + {"ball","Draw point (ball)","ball posx posy ['fmt']|posx posy posz ['fmt']", mgls_ball ,13}, + {"barh","Draw horizontal bars for 1D data", "barh Ydat ['fmt' above]|Xdat Ydat ['fmt' above]", mgls_barh ,7}, + {"bars","Draw bars for 1D data","bars Ydat ['fmt' above]|Xdat Ydat ['fmt' above]|Xdat Ydat Zdat ['fmt' above]", mgls_bars ,7}, + {"barwidth","Set default bars width","barwidth val", mgls_barwidth ,2}, + {"beam","Draw quasioptical beam","beam Tr G1 G2 Adat r ['sch' flag num] ", mgls_beam ,9}, + {"belt","Draw belts","belt Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_belt ,8}, + {"box","Draw bounding box","box ['fmt' ticks]", mgls_box ,12}, + {"boxplot","Draw boxplot for 2D data","boxplot Ydat ['fmt']|Xdat Ydat ['fmt']", mgls_boxplot ,7}, + {"boxs","Draw boxes","boxs Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_boxs ,8}, + {"break","Break for-cycle","break", 0, 6}, + {"call","Execute script in external file","call 'name' [args]", 0, 6}, + {"candle","Draw candlestick chart","candle candle Vdat1 ['fmt']|Vdat1 Vdat2 ['fmt']|Vdat1 Ydat1 Ydat2 ['fmt']||Vdat1 Vdat2 Ydat1 Ydat2 ['fmt']|Xdat Vdat1 Vdat2 Ydat1 Ydat2 ['fmt']", mgls_candle ,7}, + {"chart","Draw chart","chart Dat ['fmt']", mgls_chart ,7}, + {"chdir","Change current directory","chdir 'path'", mgls_chdir ,2}, + {"circle","Draw circle","circle x y r ['fmt']|x y z r ['fmt']", mgls_circle ,13}, + {"clean","Remove duplicate rows","clean Dat id", mgls_clean ,3}, + {"clearlegend","Clear legend antries","clearlegend", mgls_clearlegend ,15}, + {"clf","Clear picture","clf|'col'|r g b", mgls_clf ,12}, + {"cloud","Draw cloud","cloud Adat ['fmt']|Xdat Ydat Zdat Adat ['fmt']", mgls_cloud ,9}, + {"colorbar","Draw colorbar","colorbar ['fmt' pos]|Vdat ['fmt' pos]|'sch' pos x y [w h]|Vdat 'sch' pos x y [w h]", mgls_colorbar ,12}, + {"column","Get data column filled by formula on column ids","column Res Dat 'eq'", mgls_column ,4}, + {"columnplot","Set position of plot inside cell of column", "columnplot num ind [d]", mgls_columnplot ,5}, + {"combine", "Direct multiplication of arrays", "combine Res Adat Bdat", mgls_combine ,4}, + {"cone","Draw cone","cone x1 y1 z1 x2 y2 z2 r1 [r2 'fmt' edge]", mgls_cone ,13}, + {"cones","Draw cones for 1D data","cones Ydat ['fmt' above]|Xdat Ydat ['fmt' above]|Xdat Ydat Zdat ['fmt' above]", mgls_cones ,7}, + {"cont","Draw contour lines","cont Zdat ['fmt' num zpos]|Vdat Zdat ['fmt' zpos]|Xdat Ydat Zdat ['fmt' num zpos]|Vdat Xdat Ydat Zdat ['fmt' zpos]", mgls_cont ,8}, + {"cont3","Draw contour lines for 3D data","cont3 Adat 'dir' [val 'fmt' num]|Vdat Adat 'dir' [val 'fmt']|Xdat Ydat Zdat Adat 'dir' [val 'fmt' num]|Vdat Xdat Ydat Zdar Adat 'dir' [val 'fmt']", mgls_cont3 ,9}, + {"contd","Draw solid contours with manual colors","contd Zdat ['fmt' num zpos]|Vdat Zdat ['fmt' zpos]|Xdat Ydat Zdat ['fmt' num zpos]|Vdat Xdat Ydat Zdat ['fmt' zpos]", mgls_contd ,8}, + {"contf","Draw solid contours","contf Zdat ['fmt' num zpos]|Vdat Zdat ['fmt' zpos]|Xdat Ydat Zdat ['fmt' num zpos]|Vdat Xdat Ydat Zdat ['fmt' zpos]", mgls_contf ,8}, + {"contf3","Draw solid contour lines for 3D data","contf3 Adat 'dir' [val 'fmt' num]|Vdat Adat 'dir' [val 'fmt']|Xdat Ydat Zdat Adat 'dir' [val 'fmt' num]|Vdat Xdat Ydat Zdar Adat 'dir' [val 'fmt']", mgls_contf3 ,9}, + {"contfx","Draw solid contour lines at x-slice (or x-plane)","contfx Dat ['fmt' pos num]", mgls_contfx ,0}, + {"contfy","Draw solid contour lines at y-slice (or y-plane)","contfy Dat ['fmt' pos num]", mgls_contfy ,0}, + {"contfz","Draw solid contour lines at z-slice (or z-plane)","contfz Dat ['fmt' pos num]", mgls_contfz ,0}, + {"continue","Skip commands and iterate for-cycle again","continue", 0, 6}, + {"contv","Draw contour tubes","contv Zdat ['fmt' num zpos]|Vdat Zdat ['fmt' zpos]|Xdat Ydat Zdat ['fmt' num zpos]|Vdat Xdat Ydat Zdat ['fmt' zpos]", mgls_contv ,0}, + {"contx","Draw contour lines at x-slice (or x-plane)","contx Dat ['fmt' pos num]", mgls_contx ,0}, + {"conty","Draw contour lines at y-slice (or y-plane)","conty Dat ['fmt' pos num]", mgls_conty ,0}, + {"contz","Draw contour lines at z-slice (or z-plane)","contz Dat ['fmt' pos num]", mgls_contz ,0}, + {"copy","Copy data from another variable","copy Dat1 Dat2 ['eq' onaxis]", mgls_copy ,4}, + {"correl", "Find correlation between data arrays", "correl Res Adat Bdat 'dir'", mgls_correl ,4}, + {"cosfft","Cos-Fourier transform at some direction","cosfft Dat 'dir'", mgls_cosfft ,16}, + {"crange","Set color range","crange Dat [add] | c1 c2 [add]", mgls_crange ,14}, + {"crop","Crop edge of data","crop Dat n1 n2 'dir'", mgls_crop ,16}, + {"crust","Draw reconstructed surface for arbitrary data points","crust Xdat Ydat Zdat ['fmt']", mgls_crust ,0}, + {"ctick","Set ticks for colorbar","ctick 'tmpl' | dx", mgls_ctick ,14}, + {"cumsum","Cumulative summation","cumsum Dat 'dir'", mgls_cumsum ,16}, + {"curve","Draw curve","curve x1 y1 dx1 dy1 x2 y2 dx2 dy2 ['fmt']|x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2 ['fmt']", mgls_curve ,13}, + {"cut","Setup plot points cutting","cut val|x1 y1 z1 x2 y2 z2|'cond'", mgls_cut ,2}, + {"datagrid","Fill data by triangulated values","datagrid Var Xdat Ydat Zdat", mgls_datagrid ,3}, + {"datas","Print list of data names in HDF file","datas 'fname'", mgls_datas ,3}, + {"defchr","Define parameter as character","defchr $N val", 0, 6}, + {"define","Define constant or parameter","define $N sth | Var val", 0, 6}, + {"defnum","Define parameter as numerical value","defnum $N val", 0, 6}, + {"defpal","Define parameter as palette color","defpal $N val", 0, 6}, + {"delete","Delete slice of data","delete Dat 'dir' [pos=0 num=1]", mgls_delete ,3}, + {"dens","Draw density plot","dens Zdat ['fmt' zpos]|Xdat Ydat Zdat ['fmt' zpos]", mgls_dens ,8}, + {"dens3","Draw density plot at slices of 3D data","dens3 Adat 'dir' [pos 'fmt']|Xdat Ydat Zdat Adat 'dir' [pos 'fmt']", mgls_dens3 ,9}, + {"densx","Draw density plot at x-slice (or x-plane)","densx Dat ['fmt' pos]", mgls_densx ,0}, + {"densy","Draw density plot at y-slice (or y-plane)","densy Dat ['fmt' pos]", mgls_densy ,0}, + {"densz","Draw density plot at z-slice (or z-plane)","densz Dat ['fmt' pos]", mgls_densz ,0}, + {"dew","Draw dew plot","dew Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']", mgls_dew ,11}, + {"diff","Numerically differentiate data","diff Var 'dir'", mgls_diff ,16}, + {"diff2","Numerically double differentiate data","diff2 Var 'dir'", mgls_diff2 ,16}, + {"diffuse","Set diffusive light brightness","diffuse val", mgls_diffuse ,2}, + {"divto","Divide by data or number","divto Var Dat|Var num", mgls_divto ,3}, + {"dots","Draw dots for arbitrary data points","dots Xdat Ydat Zdat ['fmt']|Xdat Ydat Zdat Adat ['fmt']|Xdat Ydat Zdat Cdat Adat ['fmt']", mgls_dots ,9}, + {"drawreg","Set draw region for quality&4","drawreg|nx ny m", mgls_drawreg ,2}, + {"drop","Draw drop","drop x0 y0 dx dy r ['col' sh asp]|x0 y0 z0 dx dy dz r ['col' sh asp]", mgls_drop ,13}, + {"ellipse","Draw ellipse","ellipse x1 y1 x2 y2 r ['fmt']|x1 y1 z1 x2 y2 z2 r ['fmt']", mgls_ellipse ,13}, + {"else","Execute if condition is false","else", 0, 6}, + {"elseif","Conditional operator","elseif val|Dat ['cond']", 0, 6}, + {"endif","Finish if/else block","endif", 0, 6}, + {"envelop","Find envelop for the data","envelop Dat ['dir']", mgls_envelop ,16}, + {"errbox","Draw error box","errbox x y ex ey ['fmt']|x y z ex ey ez ['fmt']", mgls_errbox ,13}, + {"error","Draw error boxes","error Ydat Yerr ['fmt']|Xdat Ydat Yerr ['fmt']|Xdat Ydat Xerr Yerr ['fmt']", mgls_error ,7}, + {"evaluate","Evaluate (interpolate) values of array Dat at points i=idat,j=jdat,k=kdat","evaluate Res Dat Idat [norm]|Res Dat Idat Jdat [norm]|Res Dat Idat Jdat Kdat [norm]", mgls_evaluate ,4}, + {"export","Export data to PNG picture","export Dat 'fname' 'sch' [v1 v2]", mgls_export ,3}, + {"extend","Extend data array","extend Dat dim1 [dim2]", mgls_extend ,3}, + {"face","Draw face (quadrangle)","face x1 y1 x2 y2 x3 y3 x4 y4 ['fmt']|x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 ['fmt']", mgls_face ,13}, + {"facenum","Set number of visible faces","facenum val", mgls_facenum ,2}, + {"facex","Draw face perpendicular to x-axis","facex x0 y0 z0 wy wz ['fmt' d1 d2]", mgls_facex ,13}, + {"facey","Draw face perpendicular to y-axis","facex x0 y0 z0 wx wz ['fmt' d1 d2]", mgls_facey ,13}, + {"facez","Draw face perpendicular to z-axis","facex x0 y0 z0 wy wz ['fmt' d1 d2]", mgls_facez ,13}, + {"fall","Draw waterfalls","fall Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_fall ,8}, + {"fgets","Print string from file","fgets x y z 'fname' [pos=0 'fmt' size]|x y z 'fname' [pos=0 'fmt' size]", mgls_fgets ,15}, + {"fill","Fill data linearly in range [v1, v2]","fill Var v1 v2 ['dir'] | Var 'eq' [Vdat Wdat]", mgls_fill ,3}, + {"fillsample","Fill x-,k-samples for transforms","fillsample Var 'how'", mgls_fillsample ,3}, + {"fit","Fit data to formula","fit Res A 'eq' 'var' [Ini]|Res X A 'eq' 'var' [Ini]|Res X Y A 'eq' 'var' [Ini]|Res X Y Z A 'eq' 'var' [Ini]", mgls_fit ,4}, + {"fits","Fit data to formula","fits Res A S 'eq' 'var' [Ini]|Res X A S 'eq' 'var' [Ini]|Res X Y A S 'eq' 'var' [Ini]|Res X Y Z A S 'eq' 'var' [Ini]", mgls_fits ,4}, + {"flow","Draw flow threads for vector field","flow Udat Vdat ['fmt' num]|Xdat Ydat Udat Vdat ['fmt' num]|Udat Vdat Wdat ['fmt' num]|Xdat Ydat Zdat Udat Vdat ['fmt' num]|\ + x0 y0 Udat Vdat ['fmt']|x0 y0 Xdat Ydat Udat Vdat ['fmt']|x0 y0 z0 Udat Vdat Wdat ['fmt']|x0 y0 z0 Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_flow ,11}, + {"fog","Switch on/off fog","fog val [pos]", mgls_fog ,2}, + {"font","Setup font","font 'fmt' [size]", mgls_font ,15}, + {"for","For cycle","for $N v1 v2 [dv] | $N Dat", 0, 6}, + {"fourier","In-place Fourier transform","fourier ReDat ImDat 'dir'", mgls_fourier , 16}, + {"fplot","Plot curve by formula","fplot 'y_x' ['fmt']|'x_t' 'y_t' 'z_t' ['fmt']", mgls_fplot ,1}, + {"fsurf","Plot surface by formula","fsurf 'z_xy' ['fmt']|'x_uv' 'y_uv' 'z_uv' ['fmt']", mgls_fsurf ,1}, + {"func","Start function definition and stop execution of main script","func 'name' [narg]", 0, 6}, + {"grad","Draw gradient lines for scalar field","grad Phi ['fmt' num]|Xdat Ydat Phi ['fmt' num]|Xdat Ydat Zdat Phi ['fmt' num]", mgls_grad ,8}, + {"grid","Draw grid","grid ['dir' 'fmt']", mgls_grid ,12}, + {"grid2","Draw grid for data array(s)","grid Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_grid2 ,8}, + {"grid3","Draw grid at slices of 3D data","grid3 Adat 'dir' [pos 'fmt']|Xdat Ydat Zdat Adat 'dir' [pos 'fmt']", mgls_grid3 ,9}, + {"gridplot","Set position of plot inside cell of matrix", "gridplot nx ny ind [d]", mgls_gridplot ,5}, + {"hankel","Hankel transform at some direction","hankel Dat 'dir'", mgls_hankel ,16}, + {"hist","Create histogram (distribution) of data values","hist Res Dat num v1 v2 [nsub]|Res Dat Wdat num v1 v2 [nsub]", mgls_hist ,4}, + {"idset","Set column id for data","idset Dat 'ids'", mgls_idset ,3}, + {"if","Conditional operator","if val|Dat ['cond']", 0, 6}, + {"import","Import data from PNG picture","import Dat 'fname' 'scheme' [v1 v2]", mgls_import ,4}, + {"info","Print information about data","info Dat [detail]|'message'", mgls_info ,3}, + {"inplot","Set position of plot in picture","x1 x2 y1 y2 [rel]", mgls_inplot ,5}, + {"insert","Insert slice of data","insert Dat 'dir' [pos=0 num=1]", mgls_insert ,3}, + {"integrate","Integrate data","integrate Dat 'dir'", mgls_integrate ,16}, + {"jacobian","Get Jacobian","jacobian Res Xdat Ydat [Zdat]", mgls_jacobian ,4}, + {"join","Join data arrays","join Dat Add", mgls_join ,3}, + {"label","Draw label at arbitrary position","label Ydat 'txt' ['fmt'='']|Xdat Ydat 'txt' ['fmt'='']|Xdat Ydat Zdat 'txt' ['fmt'='']", mgls_label ,7}, + {"legend","Draw legend","legend [pos 'fmt']|x y ['fmt']", mgls_legend ,15}, + {"legendmarks","Set number of marks in the legend","legendmarks val", mgls_legendmarks ,15}, + {"light","Setup light","light [val] | val num | num xpos ypos zpos ['fmt' br]", mgls_light ,2}, + {"line","Draw line","line x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_line ,13}, + {"list","Creates new variable from list of numbers or data","list Var v1 ...|Var D1 ...", 0, 6}, + {"loadfont","Load fontfaces","loadfont ['face']", mgls_loadfont ,15}, + {"map","Draw mapping plot","map Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']", mgls_map ,10}, + {"mark","Draw mark plot for 1D data","mark Ydat Rdat ['fmt']|Xdat Ydat Rdat ['fmt']|Xdat Ydat Zdat Rdat ['fmt']", mgls_mark ,7}, + {"marksize","Set size of markers","marksize val", mgls_marksize ,2}, + {"mask","Set brush for given mask","mask 'id' 'val'|'id' val|angle", mgls_mask ,2}, + {"max","Find maximal value over direction","max Res Dat 'dir'", mgls_max ,4}, + {"mesh","Draw mesh surface","mesh Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_mesh ,8}, + {"meshnum","Set number of lines in mesh/fall/vect and so on","meshnum val", mgls_meshnum ,2}, + {"min","Find minimal value over direction","min Res Dat 'dir'", mgls_min ,4}, + {"mirror","Mirror data at some direction","mirror Dat 'dir'", mgls_mirror ,16}, + {"modify","Modify data values by formula","modify Dat 'eq' [num] | Dat 'eq' Vdat [Wdat]", mgls_modify ,3}, + {"momentum","Get momentum along direction","momentum Res Dat 'how' ['dir']", mgls_momentum ,4}, + {"multiplot","Set position of plot","multiplot m n pos dx dy 'style'", mgls_multiplot ,5}, + {"multo","Multiply by data or number","multo Var Dat|Var num", mgls_multo ,3}, + {"new","Create new data","new Dat nx ny nz ['eq']|new Dat nx ny ['eq']|new Dat nx ['eq']", mgls_new ,4}, + {"next","Start next for-cycle iteration","next", 0, 6}, + {"norm","Normalize data","norm Dat v1 v2 [sym dim]", mgls_norm ,16}, + {"normsl","Normalize data slice by slice","normsl Dat v1 v2 ['dir' keep sym] ", mgls_normsl ,16}, + {"ohlc","Draw Open-High-Low-Close (OHLC) diagram","ohlc Odat Hdat Ldat Cdat ['fmt']|Xdat Odat Hdat Ldat Cdat ['fmt']", mgls_ohlc ,7}, + {"once","Start/close commands which should executed only once","once val", 0, 6}, + {"origin","Set axis origin","origin x0 y0 [z0]", mgls_origin ,14}, + {"origintick","Set tick labels drawing at origin","origintick val", mgls_origintick ,14}, + {"palette","Set palette for 1D plots","palette 'colors'", mgls_palette ,2}, + {"pde","Solve PDE","pde Res 'ham' IniRe IniIm [dz k0]", mgls_pde ,4}, + {"perspective","Set perspective","perspective val", mgls_perspective ,2}, + {"pipe","Draw flow pipes for vector field","pipe Udat Vdat ['fmt' rad num]|Xdat Ydat Udat Vdat ['fmt' rad num]|Udat Vdat Wdat ['fmt' rad num]|Xdat Ydat Zdat Udat Vdat Wdat ['fmt' rad num]", mgls_pipe ,11}, + {"plot","Draw usual plot for 1D data","plot Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_plot ,7}, + {"plotid","Set default filename","plotid 'name'", mgls_plotid ,2}, + {"put","Put value (numeric or array) to given data element","put Dat val [i j k] | Dat Val [i j k]", mgls_put ,3}, + {"putsfit","Print fitted formula","putsfit x y ['pre' 'font' size]|x y z ['pre' 'font' size]", mgls_putsfit ,15}, + {"qo2d","Solve PDE in accompanied coordinates for 2d case","qo2d Res 'ham' IniRe IniIm Ray [r k0 Xout Yout]", mgls_qo2d ,4}, + {"qo3d","Solve PDE in accompanied coordinates for 3d case","qo3d Res 'ham' IniRe IniIm Ray [r k0 Xout Yout Zout]", mgls_qo3d ,4}, + {"quadplot","Draw surface of quadrangles","quadplot Idat Xdat Ydat ['fmt']|Idat Xdat Ydat Zdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt'] ", mgls_quadplot ,0}, + {"quality","Set plot quality","quality [val]", mgls_quality ,2}, + {"radar","Draw radar chart","radar Rdat ['fmt']", mgls_radar ,7}, + {"ranges","Set axis ranges","ranges x1 x2 y1 y2 [z1 z2]", mgls_ranges ,14}, + {"ray","Solve Hamiltonian ODE (find GO ray or trajectory)","ray Res 'ham' x0 y0 z0 px0 py0 pz0 [dz=0.1 tmax=10]", mgls_ray ,4}, + {"read","Read data from file","read Dat 'file' [nx ny nz]", mgls_read ,4}, + {"readall","Read and join data from several files","readall Dat 'templ' [slice]", mgls_readall ,4}, + {"readhdf","Read data from HDF5 file","readhdf Dat 'file' 'id'", mgls_readhdf ,4}, + {"readmat","Read data from file with sizes specified in first row","readmat Dat 'file' [dim]", mgls_readmat ,4}, + {"rearrange","Rearrange data dimensions","rearrange Dat mx [my mz]", mgls_rearrange ,3}, + {"rect","Draw rectangle","rect x1 y1 x2 y2 ['fmt']|x1 y1 z1 x2 y2 z2 ['fmt']", mgls_rect ,13}, + {"refill","Fill data by interpolation of Vdat","refill Dat Xdat Vdat [sl] | Dat Xdat Ydat Vdat [sl] | Dat Xdat Ydat Zdat Vdat", mgls_refill ,3}, + {"region","Draw filled region (ribbon) between 2 curves","region Ydat1 Ydat2 ['fmt']|Xdat Ydat1 Ydat2 ['fmt']||Xdat1 Ydat1 Xdat2 Ydat2 ['fmt']|Xdat1 Ydat1 Zdat1 Xdat2 Ydat2 Zdat2 ['fmt']", mgls_region ,7}, + {"resize","Resize data","resize Res Dat mx [my mz]", mgls_resize ,4}, + {"return","Return from function","return", 0, 6}, + {"rhomb","Draw rhombus","rhomb x1 y1 x2 y2 r ['fmt']|x1 y1 z1 x2 y2 z2 r ['fmt']", mgls_rhomb ,13}, + {"roll","Roll data along direction","roll Dat 'dir' num", mgls_roll ,16}, + {"roots", "Find roots using data as initial values", "roots Res 'func' Ini ['var']|Res 'func' ini ['var']", mgls_roots ,4}, + {"rotate","Rotate plot","rotate tetz tetx [tety] | tet x y z", mgls_rotate ,5}, + {"rotatetext","Set to auto rotate text or not","rotatetext val", mgls_rotatetext ,15}, + {"save","Save data to file","save Dat 'file'", mgls_save ,3}, + {"savehdf","Save data to HDF5 file","savehdf Dat 'file' 'id'", mgls_savehdf ,3}, + {"setsize","Set picture size","setsize width height", mgls_setsize ,2}, + {"sew","Remove jump into the data, like phase jumps","sew Dat ['dir' da]", mgls_sew ,16}, + {"sinfft","Sin-Fourier transform at some direction","sinfft Dat 'dir'", mgls_sinfft ,16}, + {"smooth","Smooth data","smooth Dat [kind 'dir']", mgls_smooth ,16}, + {"solve","Find root Dat_{i,j,k}=val (inverse evaluate)","solve Res Dat val 'dir' [Idat norm]", mgls_solve ,4}, + {"sort","Sort data by values in column","sort Dat idx [idy]", mgls_sort ,3}, + {"sphere","Draw sphere","sphere x0 y0 r ['fmt']|x0 y0 z0 r ['fmt']", mgls_sphere ,13}, + {"squeeze","Squeeze data","squeeze Dat kx [ky kz]", mgls_squeeze ,3}, + {"stem","Draw stem plot for 1D data","stem Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_stem ,7}, + {"step","Draw step plot for 1D data","step Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_step ,7}, + {"stfa","Draw STFA diagram","stfa Udat Vdat dn ['fmt']|Xdat Ydat Udat Vdat dn ['fmt']", mgls_stfa ,10}, + {"stfad","Do STFA transform","stfad Res Real Imag dn ['dir']", mgls_stfad ,4}, + {"stickplot","Set position of plot inside cell of stick", "stickplot num ind tet phi", mgls_stickplot ,5}, + {"stop","Stop execution","stop", 0, 6}, + {"subdata","Extract sub-array","subdata Res Dat nx [ny nz]", mgls_subdata ,4}, + {"subplot","Set position of plot","subplot m n pos ['style' dx dy]", mgls_subplot ,5}, + {"subto","Subtract data or number","subto Var Dat|Var num", mgls_subto ,3}, + {"sum","Find summation over direction","sum Res Dat 'dir'", mgls_sum ,4}, + {"surf","Draw solid surface","surf Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_surf ,8}, + {"surf3","Draw isosurface for 3D data","surf3 Adat ['fmt' num]|Xdat Ydat Zdat Adat ['fmt' num]|Adat val ['fmt']|Xdat Ydat Zdat Adat val ['fmt']", mgls_surf3 ,9}, + {"surf3a","Draw isosurface for 3D data transpared by other data","surf3a Adat Cdat ['fmt' num]|Xdat Ydat Zdat Adat Cdat ['fmt' num]|Adat Cdat val ['fmt']|Xdat Ydat Zdat Adat Cdat val ['fmt']", mgls_surf3a ,10}, + {"surf3c","Draw isosurface for 3D data colored by other data","surf3c Adat Cdat ['fmt' num]|Xdat Ydat Zdat Adat Cdat ['fmt' num]|Adat Cdat val ['fmt']|Xdat Ydat Zdat Adat Cdat val ['fmt']", mgls_surf3c ,10}, + {"surfa","Draw solid surface transpared by other data","surfa Zdat Cdat ['fmt']|Xdat Ydat Zdat Cdat ['fmt']", mgls_surfa ,10}, + {"surfc","Draw solid surface colored by other data","surfc Zdat Cdat ['fmt']|Xdat Ydat Zdat Cdat ['fmt']", mgls_surfc ,10}, + {"swap","Swap data (usefull after Fourier transform)","swap Dat 'dir'", mgls_swap ,16}, + {"table","Draw table with data values","table Dat ['txt' 'fmt']|x y Dat ['txt' 'fmt']", mgls_table ,7}, + {"tape","Draw binormales for 1D data","tape Ydat ['fmt']|Xdat Ydat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_tape ,7}, + {"tens","Draw tension plot for 1D data","tens Ydat Cdat ['fmt']|Xdat Ydat Cdat ['fmt']|Xdat Ydat Zdat Cdat ['fmt']", mgls_tens ,7}, + {"ternary","Switch on/off to use ternary axis","ternary val", mgls_ternary ,14}, + {"text","Draw text at some position or along curve","text x y 'txt' ['fmt' size]|x y z 'txt' ['fmt' size]|x y dx dy 'txt' ['fmt' size]|x y z dx dy dz 'txt' ['fmt' size]|Ydat 'txt' ['font' sise]|Xdat Ydat 'txt' ['font' sise]", mgls_text ,15}, + {"textmark","Draw TeX mark at point position","textmark Ydat Rdat 'text' ['fmt']|Xdat Ydat Rdat 'text' ['fmt']|Xdat Ydat Zdat Rdat 'text' ['fmt']", mgls_textmark ,7}, + {"ticklen","Set tick length","ticklen val [stt]", mgls_ticklen ,14}, + {"tickshift","Set additional tick and axis labels shift","tickshift dx [dy dz dc]", mgls_tickshift ,14}, + {"ticktime","Set ticks in time format","ticktime 'dir' [dv 'tmpl']", mgls_ticktime ,14}, + {"tile","Draw horizontal tiles","tile Zdat ['fmt']|Xdat Ydat Zdat ['fmt']", mgls_tile ,8}, + {"tiles","Draw horizontal tiles with variable size","tiles Zdat Rdat ['fmt']|Xdat Ydat Zdat Rdat ['fmt']", mgls_tiles ,10}, + {"title","Add title for current subplot/inplot","title 'txt' ['fmt' size]", mgls_title ,5}, + {"tlabel","Draw label for t-axis","tlabel 'txt' [pos]", mgls_tlabel ,12}, + {"torus","Draw surface of curve rotation","torus Rdat ['fmt']|Zdat Rdat ['fmt']", mgls_torus ,7}, + {"trace","Get trace of array","trace Res Dat", mgls_trace ,4}, + {"traj","Draw vectors along a curve","traj Xdat Ydat Udat Vdat ['fmt' len]|Xdat Ydat Zdat Udat Vdat Wdat ['fmt' len]", mgls_traj ,11}, + {"transform","Do integral transform of data","transform Res 'how' Rdat Idat", mgls_transform ,4}, + {"transforma","Do integral transform of data","transforma Res 'how' Adat Pdat", mgls_transforma ,4}, + {"transpose","Transpose data array","transpose Dat ['dir']", mgls_transpose ,16}, + {"transptype","Set type transparency","transptype val", mgls_transptype ,2}, + {"triangulate","Find triangles of randomly placed points","triangulate Res Xdat Ydat [er]|Res Xdat Ydat Zdat [er]", mgls_triangulate ,4}, + {"tricont","Draw contour lines for surface of triangles","tricont Vdat Idat Xdat Ydat ['fmt']|Vdat Idat Xdat Ydat Zdat ['fmt']|Vdat Idat Xdat Ydat Zdat Cdat ['fmt'] ", mgls_tricont ,0}, + {"triplot","Draw surface of triangles","triplot Idat Xdat Ydat ['fmt']|Idat Xdat Ydat Zdat ['fmt']|Idat Xdat Ydat Zdat Cdat ['fmt'] ", mgls_triplot ,0}, + {"tube","Draw curve by tube","tube Ydat Rdat ['fmt']|Ydat rval ['fmt']|Xdat Ydat Rdat ['fmt']|Xdat Ydat rval ['fmt']|Xdat Ydat Zdat Rdat ['fmt']|Xdat Ydat Zdat rval ['fmt']", mgls_tube ,7}, + {"tuneticks","Set ticks tuning","tuneticks val [fctr]", mgls_tuneticks ,14}, + {"var","Create new 1D data and fill it in range","var Dat nx x1 [x2]", mgls_var ,4}, + {"vect","Draw vector field","vect Udat Vdat ['fmt']|Xdat Ydat Udat Vdat ['fmt']|Udat Vdat Wdat ['fmt']|Xdat Ydat Zdat Udat Vdat Wdat ['fmt']", mgls_vect ,11}, + {"vect3","Draw vector field at slices of 3D data","vect Udat Vdat Wdat ['fmt' sval]|Xdat Ydat Zdat Udat Vdat Wdat ['fmt' sval]", mgls_vect3 ,11}, + {"view","Change view angles - use 'rotate' for plot rotation","view tetz tetx [tety]", mgls_view ,5}, + {"write","Write current image to graphical file","write 'fname' [solid]", mgls_write ,2}, + {"xlabel","Draw label for x-axis","xlabel 'txt' [pos]", mgls_xlabel ,12}, + {"xrange","Set range for x-axis","xrange Dat [add] | x1 x2 [add]", mgls_xrange ,14}, + {"xtick","Set ticks for x-axis","xtick dx [sx tx] | 'tmpl' | Xdat 'lbl' [add] | v1 'lbl1' ...", mgls_xtick,14}, + {"ylabel","Draw label for y-axis","ylabel 'txt' [pos]", mgls_ylabel,12}, + {"yrange","Set range for y-axis","yrange Dat [add] | y1 y2 [add]", mgls_yrange,14}, + {"ytick","Set ticks for y-axis","ytick dy [sy ty] | 'tmpl' | Ydat 'lbl' [add] | v1 'lbl1' ...", mgls_ytick,14}, + {"zlabel","Draw label for z-axis","zlabel 'txt' [pos]", mgls_zlabel,12}, + {"zoom","Zoom plot region","zoom x1 x2 y1 y2", mgls_zoom,5}, + {"zoomaxis","Zoom axis range","zoomaxis x1 x2|x1 x2 y1 y2|x1 x2 y1 y2 z1 z2|x1 x2 y1 y2 z1 z2 c1 c2", mgls_zoomaxis,14}, + {"zrange","Set range for z-axis","yrange Dat [add] | z1 z2 [add]", mgls_zrange ,14}, + {"ztick","Set ticks for z-axis","ztick dz [sz tz] | 'tmpl' | Zdat 'lbl' [add] | v1 'lbl1' ...", mgls_ztick,14}, +{"","","",NULL,0}}; +//----------------------------------------------------------------------------- diff --git a/src/export.cpp b/src/export.cpp new file mode 100644 index 0000000..742b704 --- /dev/null +++ b/src/export.cpp @@ -0,0 +1,623 @@ +/*************************************************************************** + * export.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include + +#if defined(WIN32) || defined(_MSC_VER) || defined(__BORLANDC__) +#include +#else +#include +#endif + +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" + +#if MGL_HAVE_PNG +#include +#endif + +#if MGL_HAVE_JPEG +extern "C" { +#include +} +#endif + +#if MGL_HAVE_GIF +#include +#endif +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_pnga_save(const char *fname, int w, int h, unsigned char **p) +{ +#if MGL_HAVE_PNG + bool fl = strcmp(fname,"-"); + FILE *fp = fl ? fopen(fname, "wb") : stdout; + if (!fp) return 1; + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + if (png_ptr) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + if (info_ptr) + { + png_init_io(png_ptr, fp); + png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + png_set_IHDR(png_ptr, info_ptr, w, h, 8, + PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_set_rows(png_ptr, info_ptr, p); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0); + png_write_end(png_ptr, info_ptr); + } + png_destroy_write_struct(&png_ptr, &info_ptr); + } + if(fl) fclose(fp); + return 0; +#else + mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; + return 1; +#endif +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_png_save(const char *fname, int w, int h, unsigned char **p) +{ +#if MGL_HAVE_PNG + bool fl = strcmp(fname,"-"); + FILE *fp = fl ? fopen(fname, "wb") : stdout; + if (!fp) return 1; + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + if (png_ptr) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + if (info_ptr) + { + png_init_io(png_ptr, fp); + png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + png_set_IHDR(png_ptr, info_ptr, w, h, 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_set_rows(png_ptr, info_ptr, p); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0); + png_write_end(png_ptr, info_ptr); + } + png_destroy_write_struct(&png_ptr, &info_ptr); + } + if(fl) fclose(fp); + return 0; +#else + mglGlobalMess += "PNG support was disabled. Please, enable it and rebuild MathGL.\n"; + return 1; +#endif +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_bmp_save(const char *fname, int w, int h, unsigned char **p) +{ + bool fl = strcmp(fname,"-"); + FILE *fp = fl ? fopen(fname, "wb") : stdout; + if (!fp) return 1; + + char z[4] = {0,0,0,0}; + unsigned u = w*h*3 + 54; + // BITMAPFILEHEADER + fwrite("BM",2,1,fp); fwrite(&u,4,1,fp); + fwrite(z,4,1,fp); u=54; fwrite(&u,4,1,fp); + // BITMAPINFOHEADER + u=40; fwrite(&u,4,1,fp); fwrite(&w,4,1,fp); fwrite(&h,4,1,fp); + unsigned short pp=1; + fwrite(&pp,2,1,fp); pp=24; fwrite(&pp,2,1,fp); u = w*h*3; + fwrite(z,4,1,fp); fwrite(&u,4,1,fp); + fwrite(z,4,1,fp); fwrite(z,4,1,fp); + fwrite(z,4,1,fp); fwrite(z,4,1,fp); + // image + const unsigned char *q; + register int i,j; + for(i=h-1;i>=0;i--) for(j=0;j=0;i--) for(j=0;j=0;j--) for(i=0;i0) mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "%02x%02x%02x",p[j][3*i],p[j][3*i+1],p[j][3*i+2]); + } + mgl_printf(fp, gz, "\n\nshowpage\n%%%%EOF\n"); + if(strcmp(fname,"-")) { if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); } + return 0; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_gif_save(const char *fname, int w, int h, unsigned char **l) +{ +#if MGL_HAVE_GIF +#if GIFLIB_MAJOR>=5 + GifFileType *fg = EGifOpenFileName(fname, 0, 0); +#else + GifFileType *fg = EGifOpenFileName(fname, 0); +#endif + // define colormap + GifColorType col[256]; + memset(col,0,256*sizeof(GifColorType)); + register long m; + register int i,j,k,ii; + for(i=0;i<6;i++) for(j=0;j<6;j++) for(k=0;k<6;k++) + { + m = i+6*(j+6*k); // part 1 + col[m].Red = 51*i; + col[m].Green=51*j; + col[m].Blue =51*k; + } + // write header +#if GIFLIB_MAJOR>=5 + ColorMapObject *gmap = GifMakeMapObject(256, col); + EGifPutScreenDesc(fg, w, h, 256,0,gmap); + GifFreeMapObject(gmap); +#else + ColorMapObject *gmap = MakeMapObject(256, col); + EGifPutScreenDesc(fg, w, h, 256,0,gmap); + FreeMapObject(gmap); +#endif + // write frame + EGifPutImageDesc(fg, 0, 0, w, h, 0, 0); + GifPixelType *line = new GifPixelType[w*h]; + for(m=0;m=5 + gif = EGifOpenFileName(fname, 0, 0); + EGifSetGifVersion(gif,true); +#else + EGifSetGifVersion("89a"); + gif = EGifOpenFileName(fname, 0); +#endif + // get picture sizes + // NOTE: you shouldn't call SetSize() after StartGIF() !!! + long width, height; + unsigned char *f=0, **l=GetRGBLines(width, height, f); + if(f) free(f); + if(l) free(l); + // define colormap + GifColorType col[256]; + memset(col,0,256*sizeof(GifColorType)); + register int i,j,k,m; + for(i=0;i<6;i++) for(j=0;j<6;j++) for(k=0;k<6;k++) + { + m = i+6*(j+6*k); // part 1 + col[m].Red = 51*i; + col[m].Green=51*j; + col[m].Blue =51*k; + } + // write header +#if GIFLIB_MAJOR>=5 + ColorMapObject *gmap = GifMakeMapObject(256, col); + EGifPutScreenDesc(gif, width, height, 256,0,gmap); + GifFreeMapObject(gmap); +#else + ColorMapObject *gmap = MakeMapObject(256, col); + EGifPutScreenDesc(gif, width, height, 256,0,gmap); + FreeMapObject(gmap); +#endif + // put animation parameters + ms /= 10; + unsigned char ext1[11] = {0x4E, 0x45, 0x54, 0x53, 0x43, 0x41, 0x50, 0x45, 0x32, 0x2E, 0x30}, ext3[3] = {0x01, 0xff, 0xff}, ext2[9] = {0x08, ms%256, ms/256, 0xff}; +#if GIFLIB_MAJOR>=5 + EGifPutExtensionLeader(gif,0xff); + EGifPutExtensionBlock(gif,11,ext1); + EGifPutExtensionBlock(gif,3,ext3); + EGifPutExtensionTrailer(gif); + EGifPutExtension(gif,0xf9,4,ext2); +#else + EGifPutExtensionFirst(gif,0xff,11,ext1); + EGifPutExtensionLast(gif,0xff,3,ext3); + EGifPutExtension(gif,0xf9,4,ext2); +#endif +#else + mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n"; +#endif +} +//----------------------------------------------------------------------------- +void mglCanvas::CloseGIF() +{ +#if MGL_HAVE_GIF + if(gif) EGifCloseFile(gif); +#else + mglGlobalMess += "GIF support was disabled. Please, enable it and rebuild MathGL.\n"; +#endif + gif = 0; +} +//----------------------------------------------------------------------------- +int mglCanvas::NewFrame() +{ + Clf(); Identity(); CurFrameId++; + return CurFrameId-1; +} +//----------------------------------------------------------------------------- +void mglCanvas::EndFrame() +{ + Finish(); + if(get(MGL_VECT_FRAME)) PushDrwDat(); +#if MGL_HAVE_GIF + if(!gif) return; + long width, height, n; + unsigned char *f=0, **l=GetRGBLines(width, height, f); + n = width*height; + if(!l) return; + EGifPutImageDesc(gif, 0, 0, width, height, 0, 0); + GifPixelType *line = new GifPixelType[n]; + register long m; + register int i,j,k,ii; + for(m=0;mGetRGBLines(w,h,f,true); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".png"; fname = fn.c_str(); } + if(mgl_pnga_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_png_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_png(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_png_solid(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".png"; fname = fn.c_str(); } + if(mgl_png_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_png_solid_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_png_solid(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_jpg(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".jpg"; fname = fn.c_str(); } + if(mgl_jpeg_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_jpg_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_jpg(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_tga(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f,true); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".tga"; fname = fn.c_str(); } + if(mgl_tga_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_tga_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_tga(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_bmp(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".bmp"; fname = fn.c_str(); } + if(mgl_bmp_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_bmp_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_bmp(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_bps(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".eps"; fname = fn.c_str(); } + if(mgl_bps_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_bps_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_bps(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_gif(HMGL gr, const char *fname,const char *) +{ + long w,h; unsigned char *f=0, **p=0; + p =_Gr_->GetRGBLines(w,h,f); + if(p) + { + std::string fn=fname; + if(fn.empty()) { fn=gr->PlotId+".gif"; fname = fn.c_str(); } + if(mgl_gif_save(fname,w,h,p)) gr->SetWarn(mglWarnOpen,fname); + free(p); if(f) free(f); + } +} +void MGL_EXPORT mgl_write_gif_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_gif(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_start_gif(HMGL gr, const char *fname,int ms) +{ _Gr_->StartGIF(fname,ms); } +void MGL_EXPORT mgl_start_gif_(uintptr_t *gr, const char *fname,int *ms,int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + mgl_start_gif(_GR_,s,*ms); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_close_gif(HMGL gr) { _Gr_->CloseGIF(); } +void MGL_EXPORT mgl_close_gif_(uintptr_t *gr) { mgl_close_gif(_GR_); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_frame(HMGL gr, const char *fname,const char *descr) +{ + char buf[64]; + if(!fname || !fname[0]) + { snprintf(buf,64,"%s%04d.jpg",_Gr_->PlotId.c_str(),_Gr_->GetNumFrame()); fname = buf; } + int len=strlen(fname); + if(!strcmp(fname+len-4,".jpg")) mgl_write_jpg(gr,fname,descr); + if(!strcmp(fname+len-5,".jpeg")) mgl_write_jpg(gr,fname,descr); + if(!strcmp(fname+len-4,".prc")) mgl_write_prc(gr,fname,descr,1); + if(!strcmp(fname+len-4,".pdf")) mgl_write_prc(gr,fname,descr,1); + if(!strcmp(fname+len-4,".png")) mgl_write_png(gr,fname,descr); + if(!strcmp(fname+len-4,".eps")) mgl_write_eps(gr,fname,descr); + if(!strcmp(fname+len-5,".epsz")) mgl_write_eps(gr,fname,descr); + if(!strcmp(fname+len-4,".bps")) mgl_write_bps(gr,fname,descr); + if(!strcmp(fname+len-5,".bpsz")) mgl_write_bps(gr,fname,descr); + if(!strcmp(fname+len-4,".svg")) mgl_write_svg(gr,fname,descr); + if(!strcmp(fname+len-5,".svgz")) mgl_write_svg(gr,fname,descr); + if(!strcmp(fname+len-4,".gif")) mgl_write_gif(gr,fname,descr); + if(!strcmp(fname+len-4,".bmp")) mgl_write_bmp(gr,fname,descr); + if(!strcmp(fname+len-4,".tga")) mgl_write_tga(gr,fname,descr); + if(!strcmp(fname+len-5,".mgld")) mgl_export_mgld(gr,fname,descr); + if(!strcmp(fname+len-5,".json")) mgl_write_json(gr,fname,descr); + if(!strcmp(fname+len-6,".jsonz")) mgl_write_json(gr,fname,descr); + if(!strcmp(fname+len-4,".obj")) mgl_write_obj(gr,fname,descr,1); + if(!strcmp(fname+len-4,".tex")) mgl_write_tex(gr,fname,descr); + if(!strcmp(fname+len-4,".xyz")) mgl_write_xyz(gr,fname,descr); + if(!strcmp(fname+len-4,".stl")) mgl_write_stl(gr,fname,descr); + if(!strcmp(fname+len-4,".off")) mgl_write_off(gr,fname,descr,0); +// if(!strcmp(fname+len-4,".x3d")) mgl_write_x3d(gr,fname,descr,1); +} +void MGL_EXPORT mgl_write_frame_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_frame(_GR_,s,f); delete []s; delete []f;} +//----------------------------------------------------------------------------- +#ifdef WIN32 +#include +#include +#endif +void MGL_EXPORT mgl_show_image(HMGL gr, const char *viewer, int keep) +{ + char fname[128], *cmd = new char [128]; + snprintf(fname,128,"%s.png", tmpnam(NULL)); + mgl_write_png_solid(gr,fname,"MathGL ShowImage file"); + if(!viewer || !viewer[0]) + viewer = MGL_DEF_VIEWER; +#ifdef WIN32 + if(keep) + { + snprintf(cmd,128,"%s %s &", viewer,fname); + if(system(cmd)==-1) printf("Error to call external viewer\n"); + Sleep(2000); + snprintf(cmd,128,"del %s", fname); + } + else snprintf(cmd,128,"%s %s; del %s", viewer,fname,fname); +#else + if(keep) + { + snprintf(cmd,128,"%s %s &", viewer,fname); + if(system(cmd)==-1) printf("Error to call external viewer\n"); + sleep(2); + snprintf(cmd,128,"rm %s", fname); + } + else snprintf(cmd,128,"%s %s; rm %s", viewer,fname,fname); +#endif + if(system(cmd)==-1) printf("Error to call external viewer\n"); + delete []cmd; +} +void MGL_EXPORT mgl_show_image_(uintptr_t *gr, const char *viewer, int *keep, int l) +{ char *s=new char[l+1]; memcpy(s,viewer,l); s[l]=0; + mgl_show_image(_GR_,s,*keep); delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/export_2d.cpp b/src/export_2d.cpp new file mode 100644 index 0000000..0a90d95 --- /dev/null +++ b/src/export_2d.cpp @@ -0,0 +1,657 @@ +/*************************************************************************** + * export_2d.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" +#include "mgl2/font.h" +#include +#include +#include +#include +#include +#undef _GR_ +#define _GR_ ((mglCanvas *)(*gr)) +#define _Gr_ ((mglCanvas *)(gr)) +void mgl_printf(void *fp, bool gz, const char *str, ...); +//----------------------------------------------------------------------------- +MGL_NO_EXPORT const char *mgl_get_dash(unsigned short d, mreal w) +{ + static char b[32]; + static std::string s; + if(d==0xffff) return ""; + int f=0, p=d&1, n=p?0:1, i, j; + s = p ? "" : "0"; + for(i=0;i<16;i++) + { + j = i;//15-i; + if(((d>>j)&1) == p) f++; + else + { + snprintf(b,32," %g",f*w); s += b; + p = (d>>j)&1; f = 1; n++; + } + } + snprintf(b,32," %g",f*w); s += b; + s += n%2 ? "" : " 0"; + return s.c_str(); +} +//----------------------------------------------------------------------------- +bool MGL_NO_EXPORT mgl_is_same(HMGL gr, long i, mreal wp,uint32_t cp, int st) +{ + const mglPrim &pr=_Gr_->GetPrm(i); + if(abs(pr.type)!=1) return false; + if(pr.w>=1 && wp!=pr.w) return false; + if(pr.w<1 && wp!=1) return false; + if(st!=pr.n3) return false; + return (cp==_Gr_->GetPrmCol(i)); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT put_line(HMGL gr, void *fp, bool gz, long i, mreal wp, uint32_t cp,int st, const char *ifmt, const char *nfmt, bool neg, mreal fc) +{ + long n1=gr->GetPrm(i).n1, n2=gr->GetPrm(i).n2; + if(n1>n2) { n1=gr->GetPrm(i).n2; n2=gr->GetPrm(i).n1; } + if(n1<0 || n2<0) return; + const mglPnt &pp1 = gr->GetPnt(n1), &pp2 = gr->GetPnt(n2); + mreal x0=pp1.x, y0=pp1.y; + bool ok=true; + register long j; // first point + std::vector ids; + while(ok) // try to find starting point + { + for(ok=false,j=i+1;jGetPrmNum();j++) + { + mglPrim &q = gr->GetPrm(j); + if(q.type>1) break; + if(mgl_is_same(gr, j, wp,cp,st) && q.type==1 && q.n1>=0 && q.n2>=0) // previous point + { + const mglPnt &p1 = gr->GetPnt(q.n1); + const mglPnt &p2 = gr->GetPnt(q.n2); + if(p2.x==x0 && p2.y==y0) + { + ok = true; ids.push_back(q.n1); + x0 = p1.x; y0 = p1.y; q.type = -1; + } + else if(p1.x==x0 && p1.y==y0) + { + ok = true; ids.push_back(q.n2); + x0 = p2.x; y0 = p2.y; q.type = -1; + } + } + } + } + std::reverse(ids.begin(),ids.end()); + ids.push_back(n1); ids.push_back(n2); + x0 = pp2.x; y0 = pp2.y; ok = true; + while(ok) // try to find starting point + { + for(ok=false,j=i+1;jGetPrmNum();j++) + { + mglPrim &q = gr->GetPrm(j); + if(q.type>1) break; + if(mgl_is_same(gr, j,wp,cp,st) && q.type==1 && q.n1>=0 && q.n2>=0) // next point + { + const mglPnt &p1 = gr->GetPnt(q.n1); + const mglPnt &p2 = gr->GetPnt(q.n2); + if(p2.x==x0 && p2.y==y0) + { + ok = true; ids.push_back(q.n1); + x0 = p1.x; y0 = p1.y; q.type = -1; + } + else if(p1.x==x0 && p1.y==y0) + { + ok = true; ids.push_back(q.n2); + x0 = p2.x; y0 = p2.y; q.type = -1; + } + } + } + } + for(size_t j=0;jGetPnt(ids[j]); + x0 = p.x; y0 = p.y; + mgl_printf(fp, gz, j>0?nfmt:ifmt,fc*x0,(neg?_Gr_->GetHeight()-y0:y0)*fc); + } +} +//----------------------------------------------------------------------------- +//put_desc(fp,"%c%c%c_%04x {", "np %d %d mt %d %d ll %d %d ll cp fill\n", +//"np %d %d mt ", "%d %d ll ", "cp dr\n", "} def") +void MGL_NO_EXPORT put_desc(HMGL gr, void *fp, bool gz, const char *pre, const char *ln1, const char *ln2, const char *ln3, const char *suf) +{ + register long i,j,n; + wchar_t *g; + int *s; + for(n=i=0;iGetPrmNum();i++) if(gr->GetPrm(i).type==4) n++; + if(n==0) return; // no glyphs + g = new wchar_t[n]; s = new int[n]; + for(n=i=0;iGetPrmNum();i++) + { + const mglPrim q = gr->GetPrm(i); + if(q.type!=4 || (q.n3&8)) continue; // not a glyph + bool is=false; + for(j=0;jGetGlf(q.n4); + int nl=g.nl; + const short *ln=g.line; + long ik,ii; + bool np=true; + if(ln && nl>0) for(ik=0;ikGetPrmNum()<1) return; + _Gr_->clr(MGL_FINISHED); _Gr_->PreparePrim(1); + time_t now; time(&now); + + bool gz = fname[strlen(fname)-1]=='z'; + void *fp; + if(!strcmp(fname,"-")) fp = stdout; // allow to write in stdout + else fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + mgl_printf(fp, gz, "%%!PS-Adobe-3.0 EPSF-3.0\n%%%%BoundingBox: 0 0 %d %d\n", _Gr_->GetWidth(), _Gr_->GetHeight()); + mgl_printf(fp, gz, "%%%%Created by MathGL library\n%%%%Title: %s\n",descr ? descr : fname); + mgl_printf(fp, gz, "%%%%CreationDate: %s\n",ctime(&now)); + mgl_printf(fp, gz, "/lw {setlinewidth} def\n/rgb {setrgbcolor} def\n"); + mgl_printf(fp, gz, "/np {newpath} def\n/cp {closepath} def\n"); + mgl_printf(fp, gz, "/ll {lineto} def\n/mt {moveto} def\n"); + mgl_printf(fp, gz, "/rl {rlineto} def\n/rm {rmoveto} def\n/dr {stroke} def\n"); + mgl_printf(fp, gz, "/ss {%g} def\n",0.35*gr->mark_size()); + mgl_printf(fp, gz, "/s2 {%g} def\n",0.7*gr->mark_size()); + mgl_printf(fp, gz, "/sm {-%g} def\n",0.35*gr->mark_size()); + mgl_printf(fp, gz, "/m_c {ss 0.3 mul 0 360 arc} def\n"); + mgl_printf(fp, gz, "/d0 {[] 0 setdash} def\n/sd {setdash} def\n"); + + bool m_p=false,m_x=false,m_d=false,m_v=false,m_t=false, + m_s=false,m_a=false,m_o=false,m_T=false, + m_V=false,m_S=false,m_D=false,m_Y=false,m_l=false, + m_L=false,m_r=false,m_R=false,m_X=false,m_P=false; + register long i; + // add mark definition if present + for(i=0;iGetPrmNum();i++) + { + const mglPrim q = gr->GetPrm(i); + if(q.type>0) continue; if(q.n4=='+') m_p = true; + if(q.n4=='x') m_x = true; if(q.n4=='s') m_s = true; + if(q.n4=='d') m_d = true; if(q.n4=='v') m_v = true; + if(q.n4=='^') m_t = true; if(q.n4=='*') m_a = true; + if(q.n4=='o' || q.n4=='O' || q.n4=='C') m_o = true; + if(q.n4=='S') m_S = true; if(q.n4=='D') m_D = true; + if(q.n4=='V') m_V = true; if(q.n4=='T') m_T = true; + if(q.n4=='<') m_l = true; if(q.n4=='L') m_L = true; + if(q.n4=='>') m_r = true; if(q.n4=='R') m_R = true; + if(q.n4=='Y') m_Y = true; + if(q.n4=='P') m_P = true; if(q.n4=='X') m_X = true; + } + if(m_P) { m_p=true; m_s=true; } + if(m_X) { m_x=true; m_s=true; } + if(m_p) mgl_printf(fp, gz, "/m_p {sm 0 rm s2 0 rl sm sm rm 0 s2 rl d0} def\n"); + if(m_x) mgl_printf(fp, gz, "/m_x {sm sm rm s2 s2 rl 0 sm 2 mul rm sm 2 mul s2 rl d0} def\n"); + if(m_s) mgl_printf(fp, gz, "/m_s {sm sm rm 0 s2 rl s2 0 rl 0 sm 2 mul rl cp d0} def\n"); + if(m_d) mgl_printf(fp, gz, "/m_d {sm 0 rm ss ss rl ss sm rl sm sm rl cp d0} def\n"); + if(m_v) mgl_printf(fp, gz, "/m_v {sm ss 2 div rm s2 0 rl sm sm 1.5 mul rl d0 cp} def\n"); + if(m_t) mgl_printf(fp, gz, "/m_t {sm sm 2 div rm s2 0 rl sm ss 1.5 mul rl d0 cp} def\n"); + if(m_a) mgl_printf(fp, gz, "/m_a {sm 0 rm s2 0 rl sm 1.6 mul sm 0.8 mul rm ss 1.2 mul ss 1.6 mul rl 0 sm 1.6 mul rm sm 1.2 mul ss 1.6 mul rl d0} def\n"); + if(m_o) mgl_printf(fp, gz, "/m_o {ss 0 360 d0 arc} def\n"); + if(m_S) mgl_printf(fp, gz, "/m_S {sm sm rm 0 s2 rl s2 0 rl 0 sm 2 mul rl cp} def\n"); + if(m_D) mgl_printf(fp, gz, "/m_D {sm 0 rm ss ss rl ss sm rl sm sm rl cp} def\n"); + if(m_V) mgl_printf(fp, gz, "/m_V {sm ss 2 div rm s2 0 rl sm sm 1.5 mul rl cp} def\n"); + if(m_T) mgl_printf(fp, gz, "/m_T {sm sm 2 div rm s2 0 rl sm ss 1.5 mul rl cp} def\n"); + if(m_Y) mgl_printf(fp, gz, "/m_Y {0 sm rm 0 ss rl sm ss rl s2 0 rm sm sm rl d0} def\n"); + if(m_r) mgl_printf(fp, gz, "/m_r {sm 2 div sm rm 0 s2 rl ss 1.5 mul sm rl d0 cp} def\n"); + if(m_l) mgl_printf(fp, gz, "/m_l {ss 2 div sm rm 0 s2 rl sm 1.5 mul sm rl d0 cp} def\n"); + if(m_R) mgl_printf(fp, gz, "/m_R {sm 2 div sm rm 0 s2 rl ss 1.5 mul sm rl cp} def\n"); + if(m_L) mgl_printf(fp, gz, "/m_L {ss 2 div sm rm 0 s2 rl sm 1.5 mul sm rl cp} def\n"); + if(m_P) mgl_printf(fp, gz, "/m_P {m_p 0 sm rm m_s} def\n"); + if(m_X) mgl_printf(fp, gz, "/m_X {m_x ss sm rm m_s} def\n"); + // if(m_C) mgl_printf(fp, gz, "/m_C {m_c m_o} def\n"); + mgl_printf(fp, gz, "\n"); + + // write definition for all glyphs + put_desc(gr,fp,gz,"/%c%c_%04x { np\n", "\t%d %d mt ", "%d %d ll ", "cp\n", "} def\n"); + // write primitives + mreal wp=-1; + float qs_old=gr->mark_size()/gr->FontFactor(); + mglRGBA cp; + int st=0; + char str[256]=""; + for(i=0;iGetPrmNum();i++) + { + const mglPrim &q = gr->GetPrm(i); + if(q.type<0) continue; // q.n1>=0 always + cp.c = _Gr_->GetPrmCol(i); + const mglPnt p1 = gr->GetPnt(q.n1); + if(q.type>1) snprintf(str,256,"%.2g %.2g %.2g rgb ", cp.r[0]/255.,cp.r[1]/255.,cp.r[2]/255.); + + if(q.type==0) // mark + { + mreal x0 = p1.x,y0 = p1.y; + snprintf(str,256,"%.2g lw %.2g %.2g %.2g rgb ", 50*q.s*q.w>1?50*q.s*q.w:1, cp.r[0]/255.,cp.r[1]/255.,cp.r[2]/255.); + wp=1; // NOTE: this may renew line style if a mark inside! + if(q.s!=qs_old) + { + mgl_printf(fp, gz, "/ss {%g} def\n",q.s); + mgl_printf(fp, gz, "/s2 {%g} def\n",q.s*2); + mgl_printf(fp, gz, "/sm {-%g} def\n",q.s); + qs_old = q.s; + } + switch(q.n4) + { + case '+': mgl_printf(fp, gz, "np %g %g mt m_p %sdr\n",x0,y0,str); break; + case 'x': mgl_printf(fp, gz, "np %g %g mt m_x %sdr\n",x0,y0,str); break; + case 's': mgl_printf(fp, gz, "np %g %g mt m_s %sdr\n",x0,y0,str); break; + case 'd': mgl_printf(fp, gz, "np %g %g mt m_d %sdr\n",x0,y0,str); break; + case '*': mgl_printf(fp, gz, "np %g %g mt m_a %sdr\n",x0,y0,str); break; + case 'v': mgl_printf(fp, gz, "np %g %g mt m_v %sdr\n",x0,y0,str); break; + case '^': mgl_printf(fp, gz, "np %g %g mt m_t %sdr\n",x0,y0,str); break; + case 'S': mgl_printf(fp, gz, "np %g %g mt m_S %sfill\n",x0,y0,str); break; + case 'D': mgl_printf(fp, gz, "np %g %g mt m_D %sfill\n",x0,y0,str); break; + case 'V': mgl_printf(fp, gz, "np %g %g mt m_V %sfill\n",x0,y0,str); break; + case 'T': mgl_printf(fp, gz, "np %g %g mt m_T %sfill\n",x0,y0,str); break; + case 'o': mgl_printf(fp, gz, "%g %g m_o %sdr\n",x0,y0,str);break; + case 'O': mgl_printf(fp, gz, "%g %g m_o %sfill\n",x0,y0,str);break; + case 'Y': mgl_printf(fp, gz, "np %g %g mt m_Y %sdr\n",x0,y0,str); break; + case '<': mgl_printf(fp, gz, "np %g %g mt m_l %sdr\n",x0,y0,str); break; + case '>': mgl_printf(fp, gz, "np %g %g mt m_r %sdr\n",x0,y0,str); break; + case 'L': mgl_printf(fp, gz, "np %g %g mt m_L %sfill\n",x0,y0,str); break; + case 'R': mgl_printf(fp, gz, "np %g %g mt m_R %sfill\n",x0,y0,str); break; + case 'P': mgl_printf(fp, gz, "np %g %g mt m_P %sdr\n",x0,y0,str); break; + case 'X': mgl_printf(fp, gz, "np %g %g mt m_X %sdr\n",x0,y0,str); break; + case 'C': mgl_printf(fp, gz, "%g %g m_o %g %g m_c %sdr\n",x0,y0,x0,y0,str); break; + default: mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str); + } + } + else if(q.type==3) // quad + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3), &p4=gr->GetPnt(q.n4); + if(cp.r[3]) mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll %g %g ll cp %sfill\n", p1.x, p1.y, p2.x, p2.y, p4.x, p4.y, p3.x, p3.y, str); + } + else if(q.type==2) // trig + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3); + if(cp.r[3]) mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll cp %sfill\n", p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, str); + } + else if(q.type==1) // line + { + snprintf(str,256,"%.2g lw %.2g %.2g %.2g rgb ", q.w>1 ? q.w:1., cp.r[0]/255.,cp.r[1]/255.,cp.r[2]/255.); + wp = q.w>1 ? q.w:1; st = q.n3; + put_line(gr,fp,gz,i,wp,cp.c,st, "np %g %g mt ", "%g %g ll ", false, 1); + const char *sd = mgl_get_dash(q.n3,q.w); + if(sd && sd[0]) mgl_printf(fp, gz, "%s [%s] %g sd dr\n",str,sd,q.w*q.s); + else mgl_printf(fp, gz, "%s d0 dr\n",str); + } + else if(q.type==4) // glyph + { + float phi = gr->GetGlyphPhi(gr->GetPnt(q.n2),q.w); + if(mgl_isnan(phi)) continue; + mreal ss = q.s/2, xx = p1.u, yy = p1.v, zz = q.p; + mgl_printf(fp, gz, "gsave\t%g %g translate %g %g scale %g rotate %s\n", + p1.x, p1.y, ss, ss, -phi, str); + if(q.n3&8) // this is "line" + { + mreal dy = 0.004,f=fabs(zz); + mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll %g %g ll cp ", + xx,yy+dy, xx+f,yy+dy, xx+f,yy-dy, xx,yy-dy); + } + else + mgl_printf(fp, gz, "%.3g %.3g translate %g %g scale %c%c_%04x ", + xx, yy, zz, zz, q.n3&1?'b':'n', q.n3&2?'i':'n', q.n4); + if(q.n3&4) mgl_printf(fp, gz, "dr"); + else mgl_printf(fp, gz, "eofill"); + mgl_printf(fp, gz, " grestore\n"); + } + } + for(i=0;iGetPrmNum();i++) + { + mglPrim &q = gr->GetPrm(i); + if(q.type==-1) q.type = 1; + } + mgl_printf(fp, gz, "\nshowpage\n%%%%EOF\n"); + if(strcmp(fname,"-")) { if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); } + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_eps_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_eps(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_svg(HMGL gr, const char *fname,const char *descr) +{ + if(!fname || *fname==0) return; + if(gr->GetPrmNum()<1) return; + _Gr_->clr(MGL_FINISHED); _Gr_->PreparePrim(1); + time_t now; time(&now); + + bool gz = fname[strlen(fname)-1]=='z'; + long hh = _Gr_->GetHeight(); + void *fp; + if(!strcmp(fname,"-")) fp = stdout; // allow to write in stdout + else fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n", _Gr_->GetWidth(), hh); + + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n\n\n",descr?descr:fname,ctime(&now)); + + // write definition for all glyphs + put_desc(gr,fp,gz,"\n"); + // currentColor -> inherit ??? + mgl_printf(fp, gz, "\n"); + // write primitives + mreal wp=-1; + register long i; + int st=0; + mglRGBA cp; + + for(i=0;iGetPrmNum();i++) + { + const mglPrim &q = gr->GetPrm(i); + if(q.type<0) continue; // q.n1>=0 always + cp.c = _Gr_->GetPrmCol(i); + const mglPnt p1=gr->GetPnt(q.n1); + if(q.type==0) + { + mreal x=p1.x,y=hh-p1.y,s=q.s; + if(!strchr("xsSoO",q.n4)) s *= 1.1; + wp = 1; + if(strchr("SDVTLR",q.n4)) + mgl_printf(fp, gz, "\n", int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + else + mgl_printf(fp, gz, "\n", int(cp.r[0]),int(cp.r[1]),int(cp.r[2]), 50*q.s*q.w>1?50*q.s*q.w:1); + switch(q.n4) + { + case 'P': + mgl_printf(fp, gz, "\n", + x-s,y,x+s,y,x,y-s,x,y+s, x-s,y-s,x+s,y-s,x+s,y+s,x-s,y+s,x-s,y-s); break; + case '+': + mgl_printf(fp, gz, "\n", x-s,y,x+s,y,x,y-s,x,y+s); break; + case 'X': + mgl_printf(fp, gz, "\n", + x-s,y-s,x+s,y+s,x+s,y-s,x-s,y+s, x-s,y-s,x+s,y-s,x+s,y+s,x-s,y+s,x-s,y-s); break; + case 'x': + mgl_printf(fp, gz, "\n", x-s,y-s,x+s,y+s,x+s,y-s,x-s,y+s); break; + case 's': + case 'S': + mgl_printf(fp, gz, "\n", x-s,y-s,x+s,y-s,x+s,y+s,x-s,y+s); break; + case 'd': + case 'D': + mgl_printf(fp, gz, "\n", x-s,y,x,y-s,x+s,y,x,y+s); break; + case 'v': + case 'V': + mgl_printf(fp, gz, "\n", x-s,y-s/2,x+s,y-s/2,x,y+s); break; + case '^': + case 'T': + mgl_printf(fp, gz, "\n", x-s,y+s/2,x+s,y+s/2,x,y-s); break; + case '<': + case 'L': + mgl_printf(fp, gz, "\n", x+s/2,y+s,x+s/2,y-s,x-s,y); break; + case '>': + case 'R': + mgl_printf(fp, gz, "\n", x-s/2,y+s,x-s/2,y-s,x+s,y); break; + case 'Y': + mgl_printf(fp, gz, "\n", x,y-s, x,y, x+s,y+s, x,y, x-s,y+s); break; + case 'C': + mgl_printf(fp, gz, "\n\n", + int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),x,y,x,y,s); break; + case 'o': + mgl_printf(fp, gz, "\n", x,y,s); break; + case 'O': + mgl_printf(fp, gz, "\n", + int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),x,y,s); break; + case '*': + mgl_printf(fp, gz, "\n", + x-s,y,x+s,y,x-0.6*s,y-0.8*s,x+0.6*s,y+0.8*s,x+0.6*s,y-0.8*s,x-0.6*s,y+0.8*s); break; + default: + mgl_printf(fp, gz, "\n", + int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),x,y); break; + } + mgl_printf(fp, gz, "\n"); + } + else if(q.type==1) + { + mgl_printf(fp,gz,"1) mgl_printf(fp, gz, " stroke-width=\"%g\"", q.w); + wp = q.w>1 ? q.w:1; st = q.n3; + put_line(gr,fp,gz,i,wp,cp.c,st, "> \n"); + } + else if(q.type==2 && cp.r[3]) + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3); + mgl_printf(fp, gz, "\n", int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),cp.r[3]/255.); + mgl_printf(fp, gz, " \n", p1.x, hh-p1.y, p2.x, hh-p2.y, p3.x, hh-p3.y); + } + else if(q.type==3 && cp.r[3]) + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3), &p4=gr->GetPnt(q.n4); + mgl_printf(fp, gz, "\n", int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),cp.r[3]/255.); + mgl_printf(fp, gz, " \n", p1.x, hh-p1.y, p2.x, hh-p2.y, p4.x, hh-p4.y, p3.x, hh-p3.y); + } + else if(q.type==4) + { + float phi = gr->GetGlyphPhi(gr->GetPnt(q.n2),q.w); + if(mgl_isnan(phi)) continue; + mreal ss = q.s/2, xx = p1.u, yy = p1.v, zz = q.p; + if(q.n3&8) // this is "line" + { + mgl_printf(fp, gz, "", int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + else + mgl_printf(fp, gz, " fill=\"#%02x%02x%02x\">", int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + mreal dy = 0.004,f=fabs(zz); + mgl_printf(fp, gz, "\n", xx,yy+dy, xx+f,yy+dy, xx+f,yy-dy, xx,yy-dy); + } + else + { + ss *= zz; + mgl_printf(fp, gz, "", int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + else + mgl_printf(fp, gz, " fill=\"#%02x%02x%02x\">", int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + mgl_printf(fp, gz, "\n", xx/zz, yy/zz, q.n3&1?'b':'n', q.n3&2?'i':'n', q.n4); + } + } + } + + for(i=0;iGetPrmNum();i++) + { mglPrim &q=gr->GetPrm(i); if(q.type==-1) q.type = 1; } + mgl_printf(fp, gz, ""); + if(strcmp(fname,"-")) { if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); } + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_svg_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_svg(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr) +{ + if(gr->GetPrmNum()<1) return; + _Gr_->clr(MGL_FINISHED); _Gr_->PreparePrim(1); + + FILE *fp = fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + fprintf(fp, "%% Created by MathGL library\n%% Title: %s\n\n",descr?descr:fname); + // provide marks + fprintf(fp, "\\providecommand{\\mglp}[4]{\\draw[#3] (#1-#4, #2) -- (#1+#4,#2) (#1,#2-#4) -- (#1,#2+#4);}\n"); + fprintf(fp, "\\providecommand{\\mglx}[4]{\\draw[#3] (#1-#4, #2-#4) -- (#1+#4,#2+#4) (#1+#4,#2-#4) -- (#1-#4,#2+#4);}\n"); + fprintf(fp, "\\providecommand{\\mgls}[4]{\\draw[#3] (#1-#4, #2-#4) -- (#1+#4,#2-#4) -- (#1+#4,#2+#4) -- (#1-#4,#2+#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglS}[4]{\\fill[#3] (#1-#4, #2-#4) -- (#1+#4,#2-#4) -- (#1+#4,#2+#4) -- (#1-#4,#2+#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mgld}[4]{\\draw[#3] (#1, #2-#4) -- (#1+#4,#2) -- (#1,#2+#4) -- (#1-#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglD}[4]{\\fill[#3] (#1, #2-#4) -- (#1+#4,#2) -- (#1,#2+#4) -- (#1-#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglv}[4]{\\draw[#3] (#1-#4, #2+#4/2) -- (#1+#4,#2+#4/2) -- (#1,#2-#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglV}[4]{\\fill[#3] (#1-#4, #2+#4/2) -- (#1+#4,#2+#4/2) -- (#1,#2-#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglt}[4]{\\draw[#3] (#1-#4, #2-#4/2) -- (#1+#4,#2-#4/2) -- (#1,#2+#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglT}[4]{\\fill[#3] (#1-#4, #2-#4/2) -- (#1+#4,#2-#4/2) -- (#1,#2+#4) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mgll}[4]{\\draw[#3] (#1+#4/2, #2-#4) -- (#1+#4/2,#2+#4) -- (#1-#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglL}[4]{\\fill[#3] (#1+#4/2, #2-#4) -- (#1+#4/2,#2+#4) -- (#1-#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglr}[4]{\\draw[#3] (#1-#4/2, #2-#4) -- (#1-#4/2,#2+#4) -- (#1+#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglR}[4]{\\fill[#3] (#1-#4/2, #2-#4) -- (#1-#4/2,#2+#4) -- (#1+#4,#2) -- cycle;}\n"); + fprintf(fp, "\\providecommand{\\mglR}[4]{\\draw[#3] (#1, #2-#4) -- (#1,#2) -- (#1-#4,#2+#4) (#1,#2) -- (#1+#4,#2+#4);}\n"); + fprintf(fp, "\\providecommand{\\mgla}[4]{\\draw[#3] (#1-#4, #2) -- (#1+#4,#2) (#1-0.6*#4,#2-0.8*#4) -- (#1+0.6*#4,#2+0.8*#4) (#1-0.6*#4,#2+0.8*#4) -- (#1+0.6*#4,#2-0.8*#4);}\n"); + fprintf(fp, "\\providecommand{\\mglY}[4]{\\draw[#3] (#1, #2-#4) -- (#1,#2) (#1-#4,#2+#4) -- (#1,#2) (#1+#4,#2+#4) -- (#1,#2);}\n"); + fprintf(fp, "\\providecommand{\\mglo}[4]{\\draw[#3] (#1, #2) circle (#4);}\n"); + fprintf(fp, "\\providecommand{\\mglO}[4]{\\fill[#3] (#1, #2) circle (#4);}\n"); + fprintf(fp, "\\providecommand{\\mglc}[3]{\\draw[#3] (#1, #2) circle (%g);}\n\n", 4e-4*gr->mark_size()); + fprintf(fp, "\\begin{tikzpicture}\n"); + + // write primitives first + mreal wp=-1; + int st=0; + mglRGBA cp; + char cname[128]; + + for(long i=0;iGetPrmNum();i++) + { + const mglPrim &q = gr->GetPrm(i); + if(q.type<0) continue; // q.n1>=0 always + cp.c = _Gr_->GetPrmCol(i); + snprintf(cname,128,"color={rgb,255:red,%d;green,%d;blue,%d}",cp.r[0],cp.r[1],cp.r[2]); + + const mglPnt p1=gr->GetPnt(q.n1); + mreal x=p1.x/100,y=p1.y/100,s=q.s/100; + if(q.type==0) + { + if(!strchr("xsSoO",q.n4)) s *= 1.1; + wp = 1; + switch(q.n4) // NOTE: no thickness for marks in TeX + { + case 'P': + fprintf(fp, "\\mglp{%.4g}{%.4g}{%s}{%.4g} \\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break; + case 'X': + fprintf(fp, "\\mglx{%.4g}{%.4g}{%s}{%.4g} \\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break; + case 'C': + fprintf(fp, "\\mglc{%.4g}{%.4g}{%s}{%.4g} \\mglo{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break; + case '+': fprintf(fp, "\\mglp{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'x': fprintf(fp, "\\mglx{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 's': fprintf(fp, "\\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'S': fprintf(fp, "\\mglS{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'd': fprintf(fp, "\\mgld{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'D': fprintf(fp, "\\mglD{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case '^': fprintf(fp, "\\mglt{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'T': fprintf(fp, "\\mglT{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'v': fprintf(fp, "\\mglv{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'V': fprintf(fp, "\\mglV{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case '<': fprintf(fp, "\\mgll{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'L': fprintf(fp, "\\mglL{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case '>': fprintf(fp, "\\mglr{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'R': fprintf(fp, "\\mglR{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'Y': fprintf(fp, "\\mglY{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'o': fprintf(fp, "\\mglo{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case 'O': fprintf(fp, "\\mglO{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + case '*': fprintf(fp, "\\mgla{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break; + default: fprintf(fp, "\\mglc{%.4g}{%.4g}{%s}\n", x,y,cname); break; + } + } + else if(q.type==2 && cp.r[3]) + { + const mglPnt p2=gr->GetPnt(q.n2), p3=gr->GetPnt(q.n3); + if(cp.r[3]<255) + fprintf(fp, "\\fill[%s, fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100); + else + fprintf(fp, "\\fill[%s, fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100); + } + else if(q.type==3 && cp.r[3]) + { + const mglPnt p2=gr->GetPnt(q.n2), p3=gr->GetPnt(q.n3), p4=gr->GetPnt(q.n4); + if(cp.r[3]<255) + fprintf(fp, "\\fill[%s, fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100); + else + fprintf(fp, "\\fill[%s, fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100); + + } + else if(q.type==1) // lines + { + //const char *dash[]={"", "8 8","4 4","1 3","7 4 1 4","3 2 1 2"}; + const char *w[]={"semithick","thick","very thick","ultra thick"}; + register int iw=int(q.w-0.5); if(iw>3) iw=3; + if(iw<0) fprintf(fp,"\\draw[%s] ",cname); + else fprintf(fp,"\\draw[%s,%s] ",cname,w[iw]); + // TODO: add line dashing + wp = q.w>1 ? q.w:1; st = q.n3; + put_line(gr,fp,false,i,wp,cp.c,st, "(%.4g,%.4g)", " -- (%.4g,%.4g)", false, 0.01); + fprintf(fp, ";\n"); + } + else if(q.type==6 && mgl_isnum(q.p)) // text + { + const mglText &t = gr->GetPtx(q.n3); + mreal dy = q.w*cos(q.p*M_PI/180)/100, dx = q.w*sin(q.p*M_PI/180)/100; + int f,a; mglGetStyle(t.stl.c_str(), &f, &a); + std::string ss=cname; + if((a&3)==0) ss.append(",anchor=base west"); + if((a&3)==1) ss.append(",anchor=base"); + if((a&3)==2) ss.append(",anchor=base east"); +// if(f&MGL_FONT_ITAL) ss.append(",font=\\itshape"); +// if(f&MGL_FONT_BOLD) ss.append(",font=\\bfshape"); + if(t.text.find('\\')!=std::string::npos || t.text.find('{')!=std::string::npos || t.text.find('_')!=std::string::npos || t.text.find('^')!=std::string::npos) + fprintf(fp,"\\draw[%s] (%.4g,%.4g) node[rotate=%.2g]{$%ls$};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str()); + else + fprintf(fp,"\\draw[%s] (%.4g,%.4g) node[rotate=%.2g]{%ls};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str()); + } + } + fprintf(fp, "\\end{tikzpicture}\n"); + for(long i=0;iGetPrmNum();i++) + { mglPrim &q=gr->GetPrm(i); if(q.type==-1) q.type = 1; } + fclose(fp); + setlocale(LC_NUMERIC, ""); + + // provide main file for viewing figure + fp=fopen("mglmain.tex","wt"); + if(fp) + { + fprintf(fp, "%% this file just show figure\n"); + fprintf(fp, "\\documentclass{article}\n\\usepackage{tikz}\n"); + fprintf(fp, "\\begin{document}\n\\input{%s}\n\\end{document}\n",fname); + fclose(fp); + } +} +void MGL_EXPORT mgl_write_tex_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_tex(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- diff --git a/src/export_3d.cpp b/src/export_3d.cpp new file mode 100644 index 0000000..4d0ac83 --- /dev/null +++ b/src/export_3d.cpp @@ -0,0 +1,1328 @@ +/*************************************************************************** + * export_3d.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" +#undef _GR_ +#define _GR_ ((mglCanvas *)(*gr)) +#define _Gr_ ((mglCanvas *)(gr)) +int MGL_NO_EXPORT mgl_tga_save(const char *fname, int w, int h, unsigned char **p); +int MGL_NO_EXPORT mgl_pnga_save(const char *fname, int w, int h, unsigned char **p); +void MGL_NO_EXPORT mgl_printf(void *fp, bool gz, const char *str, ...); +std::string MGL_NO_EXPORT mgl_sprintf(const char *str, ...); +//----------------------------------------------------------------------------- +void mglTexture::GetRGBA(unsigned char *f) const +{ + register long i,j,i0; + mglColor c1,c2,c; + for(i=255;i>=0;i--) + { + c1 = col[2*i]; c2 = col[2*i+1]; + for(j=0;j<256;j++) + { + i0 = 4*(j+256*i); + c = c1 + (c2-c1)*(j/255.); + f[i0] = int(255*c.r); + f[i0+1] = int(255*c.g); + f[i0+2] = int(255*c.b); + f[i0+3] = int(255*c.a); + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_obj_glyph_old(HMGL gr, const mglPrim &q, const mglPnt &p, FILE *fp) +{ + mreal f = q.p/2, dx=p.u/2, dy=p.v/2, x,y; + mreal c=q.s*cos(q.w*M_PI/180), s=-q.s*sin(q.w*M_PI/180); + if(mgl_isnan(q.s)) c=s=0; + double b[4] = {c,-s, s,c}; + long i=q.n1+1, ik,il=0; + + const mglGlyph &g = gr->GetGlf(q.n4); + const mreal dd = 0.004; + if(q.n3&8) + { + fprintf(fp,"v %g %g %g\n",p.x+b[0]*dx+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + fprintf(fp,"v %g %g %g\n",p.x+b[0]*dx+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + fprintf(fp,"v %g %g %g\n",p.x+b[0]*(dx+f)+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + fprintf(fp,"v %g %g %g\n",p.x+b[0]*(dx+f)+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + if(!(q.n3&4)) // glyph_line(p,f,true, d); + { + fprintf(fp,"f -1/%ld -3/%ld -2/%ld\n",i,i,i); + fprintf(fp,"f -4/%ld -2/%ld -3/%ld\n",i,i,i); + } + else // glyph_line(p,f,false, d); + { + fprintf(fp,"l -1/%ld -2/%ld\n",i,i); + fprintf(fp,"l -3/%ld -4/%ld\n",i,i); + fprintf(fp,"l -1/%ld -3/%ld\n",i,i); + fprintf(fp,"l -2/%ld -4/%ld\n",i,i); + } + } + else + { + if(!(q.n3&4)) // glyph_fill(p,f,g, d); + { + for(ik=0;ik': + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); break; + case 'O': + for(j=0;j<=20;j++) + fprintf(fp,"v %g %g %g\n",p.x+ss*mgl_cos[(j*36)%360],p.y+ss*mgl_cos[(270+j*36)%360],p.z); + for(j=0;j<20;j++) + fprintf(fp,"f %ld/%ld %ld/%ld %ld/%ld\n", j-21,i, j-20,i, i,i); + break; + case 'C': fprintf(fp,"p %ld\n", i); + case 'o': + for(j=0;j<=20;j++) + fprintf(fp,"v %g %g %g\n",p.x+ss*mgl_cos[(j*36)%360],p.y+ss*mgl_cos[(270+j*36)%360],p.z); + for(j=0;j<20;j++) + fprintf(fp,"l %ld/%ld %ld/%ld\n", j-21,i, j-20,i); + break; + } + break; + case 1: fprintf(fp,"l %ld/%ld %ld/%ld\n", n1,n1, n2,n2); break; + case 2: fprintf(fp,"f %ld/%ld %ld/%ld %ld/%ld\n", n1,n1, n2,n2, n3,n3); break; + case 3: fprintf(fp,"f %ld/%ld %ld/%ld %ld/%ld\n", n1,n1, n2,n2, n3,n3); + fprintf(fp,"f %ld/%ld %ld/%ld %ld/%ld\n", n2,n2, n4,n4, n3,n3); break; + case 4: mgl_obj_glyph_old(gr,q,p,fp); break; + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_obj_old(HMGL gr, const char *fname,const char *descr, int use_png) +{ + if(gr->GetPrmNum()==0) return; // nothing to do + long m1=0,m2=0,m,j; + for(size_t i=0;iGrp.size();i++) // prepare array of indirect indexing + { m = gr->Grp[i].Id; if(mm2) m2=m; } + long *ng = new long[m2-m1+1]; + for(size_t i=0;iGrp.size();i++) ng[gr->Grp[i].Id-m1] = i; + for(long i=0;iGetPrmNum();i++) // collect data for groups + // it is rather expensive (extra 4b per primitive) but need for export to 3D + { + m = gr->GetPrm(i).id-m1; + if(m>=0 && mGrp[ng[m]].p.push_back(i); + } + delete []ng; + + size_t len=strlen(fname),ntxt=gr->GetTxtNum(); + FILE *fp=fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + // vertices definition + setlocale(LC_NUMERIC, "C"); + fprintf(fp,"# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + for(long i=0;iGetPntNum();i++) + { + const mglPnt &pp = gr->GetPnt(i); + fprintf(fp,"v %g %g %g\n",pp.x,pp.y,pp.z); + fprintf(fp,"vt %g %g\n",1-pp.ta,pp.c/ntxt); +// if(mgl_isnan(pp.u)) fprintf(fp,"vn 0 0 0\n"); +// else fprintf(fp,"vn %g %g %g\n",pp.u,pp.v,pp.w); + } + // primitive definition in groups + char *tname = new char[len+5]; strcpy(tname,fname); + tname[len-4]=0; fprintf(fp,"# Primitives Definitions\nmtllib %s.mtl\nusemtl %s\n",tname,tname); + for(size_t i=0;iGrp.size();i++) + { + fprintf(fp,"g %s\n",gr->Grp[i].Lbl.c_str()); + std::vector &p = gr->Grp[i].p; + for(size_t j=0;jGetPrm(p[j]); + mgl_obj_prim_old(gr, q, gr->GetPnt(q.n1), fp, mgl_isnan(q.s)?0:q.s); + } + gr->Grp[i].p.clear(); // we don't need indexes anymore + } + // try to save "ungrouped" primitives + fclose(fp); + // prepare MTL file + tname[len-4]='.'; tname[len-3]='m'; tname[len-2]='t'; tname[len-1]='l'; + fp=fopen(tname,"wt"); + tname[len-4]=0; fprintf(fp,"newmtl %s\n",tname); + fprintf(fp,"Ka 1.000 1.000 1.000\n"); + fprintf(fp,"Kd 1.000 1.000 1.000\n"); + fprintf(fp,"Ks 0.000 0.000 0.000\n"); + fprintf(fp,"d 1.0\nillum 2\n"); + if(use_png) strcat(tname,"_txt.png"); +// { tname[len-4]='.'; tname[len-3]='p'; tname[len-2]='n'; tname[len-1]='g'; } + else strcat(tname,"_txt.tga"); +// { tname[len-4]='.'; tname[len-3]='t'; tname[len-2]='g'; tname[len-1]='a'; } + fprintf(fp,"map_Ka %s\nmap_Kd %s\nmap_Ks %s\n",tname,tname,tname); + fclose(fp); + // prepare texture file (TGA or PNG) + j=gr->GetTxtNum(); + unsigned char *buf = new unsigned char[4*256*256*j]; + unsigned char **pbuf= (unsigned char **)malloc(256*j*sizeof(unsigned char *)); + for(long i=0;i<256*j;i++) pbuf[i] = buf+4*256*i; + for(long i=0;iGetTxt(i).GetRGBA(buf+i*256*256*4); + if(use_png) mgl_pnga_save(tname,256,256*j,pbuf); + else mgl_tga_save(tname,256,256*j,pbuf); + free(pbuf); delete []buf; delete []tname; + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_obj_old_(uintptr_t *gr, const char *fname,const char *descr, int *use_png,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_obj_old(_GR_,s,d,*use_png); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_stl(HMGL gr, const char *fname,const char *descr) +{ + if(gr->GetPrmNum()==0) return; // nothing to do + FILE *fp = fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + fprintf(fp,"solid %s\n",(descr && *descr)?descr:"mathgl"); + register long i; + mglPnt pp; + for(i=0;iGetPrmNum();i++) + { + const mglPrim &q=gr->GetPrm(i); + if(q.type==2) // triangles + { + pp = gr->GetPnt(q.n1); + fprintf(fp,"facet normal %.2g %.2g %.2g\nouter loop\n",pp.u,pp.v,pp.w); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n2); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n3); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + fprintf(fp,"endloop\nendfacet\n"); + } + if(q.type==3) // quadrangles + { + pp = gr->GetPnt(q.n1); + fprintf(fp,"facet normal %.2g %.2g %.2g\nouter loop\n",pp.u,pp.v,pp.w); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n2); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n3); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + fprintf(fp,"endloop\nendfacet\n"); + pp = gr->GetPnt(q.n1); + fprintf(fp,"facet normal %.2g %.2g %.2g\nouter loop\n",pp.u,pp.v,pp.w); + pp = gr->GetPnt(q.n4); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n2); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + pp = gr->GetPnt(q.n3); + fprintf(fp,"vertex %g %g %g\n",pp.x,pp.y,pp.z); + fprintf(fp,"endloop\nendfacet\n"); + } + } + fprintf(fp,"endsolid %s",(descr && *descr)?descr:"mathgl"); + fclose(fp); + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_stl_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_stl(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_xyz(HMGL gr, const char *fname,const char *descr) +{ + if(gr->GetPrmNum()==0) return; // nothing to do + + register long i; + FILE *fp=fopen(fname,"wt"), *ff; // vertices definition + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + fprintf(fp,"# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + fprintf(fp,"# List of Vertices, with (x,y,z) coordinates.\n"); + for(i=0;iGetPntNum();i++) + { + const mglPnt &pp = gr->GetPnt(i); + fprintf(fp,"%g %g %g\n",pp.x,pp.y,pp.z); + } + fclose(fp); + + // primitive definition + size_t len=strlen(fname); + char *tname = new char[len+2]; strcpy(tname,fname); tname[len+1]=tname[len]=0; + tname[len]='l'; fp = fopen(tname,"wt"); + tname[len]='f'; ff = fopen(tname,"wt"); + fprintf(fp,"# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + fprintf(fp,"# Indices of vertices to connect for lines\n"); + fprintf(ff,"# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + fprintf(ff,"# Indices of vertices to connect for faces\n"); + for(i=0;iGetPrmNum();i++) + { + const mglPrim &q=gr->GetPrm(i); + if(q.type==1) fprintf(fp,"%ld %ld\n",q.n1+1,q.n2+1); + if(q.type==2) fprintf(ff,"%ld %ld %ld\n",q.n1+1,q.n2+1,q.n3+1); + if(q.type==3) fprintf(ff,"%ld %ld %ld\n%ld %ld %ld\n",q.n1+1,q.n2+1,q.n3+1,q.n4+1,q.n2+1,q.n3+1); + } + fclose(fp); fclose(ff); delete []tname; + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_xyz_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_xyz(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_off(HMGL gr, const char *fname,const char *descr, int colored) +{ + register long i,nf=0; + for(i=0;iGetPrmNum();i++) // find number of faces + { + const mglPrim &q=gr->GetPrm(i); + if(q.type==2 || q.type==3) nf++; + } + if(nf<=0) return; // nothing to do + + FILE *fp=fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + // vertices definition + if(colored) + fprintf(fp,"COFF\n# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + else + fprintf(fp,"OFF\n# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + fprintf(fp,"# List of Vertices, with (x,y,z,r,g,b,a) coordinates.\n"); + fprintf(fp,"%ld %ld 0\n",gr->GetPntNum(), nf); + for(i=0;iGetPntNum();i++) + { + const mglPnt &pp = gr->GetPnt(i); + if(colored) + fprintf(fp,"%g %g %g %g %g %g %g\n", pp.x, pp.y, pp.z, pp.r, pp.g, pp.b, pp.a); + else fprintf(fp,"%g %g %g\n", pp.x, pp.y, pp.z); + } + for(i=0;iGetPrmNum();i++) + { + const mglPrim &q=gr->GetPrm(i); + const mglPnt &p1=gr->GetPnt(q.n1); + if(colored) + { + if(q.type==2) + fprintf(fp,"3 %ld %ld %ld\n",q.n1,q.n2,q.n3); + if(q.type==3) + fprintf(fp,"4 %ld %ld %ld %ld\n",q.n1,q.n2,q.n4,q.n3); + } + else + { + if(q.type==2) + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3); + if(p1.a>mgl_min_a || p2.a>mgl_min_a || p3.a>mgl_min_a) + fprintf(fp,"3 %ld %ld %ld %.2g %.2g %.2g %.2g\n",q.n1,q.n2,q.n3, + (p1.r+p2.r+p3.r)/3, (p1.g+p2.g+p3.g)/3, (p1.b+p2.b+p3.b)/3, (p1.a+p2.a+p3.a)/3); + } + if(q.type==3) + { + const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3), &p4=gr->GetPnt(q.n4); + if(p1.a>mgl_min_a || p2.a>mgl_min_a || p3.a>mgl_min_a || p4.a>mgl_min_a) + fprintf(fp,"4 %ld %ld %ld %ld %.2g %.2g %.2g %.2g\n",q.n1,q.n2,q.n4,q.n3, + (p1.r+p2.r+p3.r+p4.r)/4, (p1.g+p2.g+p3.g+p4.g)/4, (p1.b+p2.b+p3.b+p4.b)/4, (p1.a+p2.a+p3.a+p4.a)/4); + } + } + } + fclose(fp); + setlocale(LC_NUMERIC, ""); +} +void MGL_EXPORT mgl_write_off_(uintptr_t *gr, const char *fname,const char *descr,int *colored,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_off(_GR_,s,d,*colored); delete []s; delete []d; } +//----------------------------------------------------------------------------- +bool mglCanvas::WriteJSON(const char *fname, bool force_zlib) +{ + bool fl = strcmp(fname,"-"); + bool gz = force_zlib || fname[strlen(fname)-1]=='z'; + void *fp = fl ? (gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt")) : stdout; + if (!fp) return true; + std::string s=GetJSON(); + if(gz) gzprintf((gzFile)fp, "%s", s.c_str()); + else fprintf((FILE *)fp, "%s", s.c_str()); + if(fl) { if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); } + return false; +} +//----------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_get_json(HMGL gr) +{ + static std::string json; + mglCanvas *g = dynamic_cast(gr); + if(g) json = g->GetJSON(); + return json.c_str(); +} +//----------------------------------------------------------------------------- +std::string mglCanvas::GetJSON() +{ + ClearUnused(); // clear unused points + std::string res, buf; + long i,ll=0,l=(long)Pnt.size(); + long factor = Width>1?10:10000; + setlocale(LC_NUMERIC, "C"); + res = res + mgl_sprintf("{\n\"width\":%d,\t\"height\":%d,\t\"depth\":%d,\t\"plotid\":\"%s\",\t\"npnts\":%ld,\t\"pnts\":[\n", + factor*Width, factor*Height, factor*Depth, PlotId.c_str(), l); + std::string *tmp=new std::string[l]; +#pragma omp parallel for reduction(+:ll) + for(long i=0;i xy; // vector for glyphs coordinates (to be separated from pnts) + res.reserve(60*(ll+1)); +#pragma omp parallel for private(buf) + for(long i=0;in2) { n1=p.n2; n2=p.n1; } + register long ps=p.s==p.s?long(100*factor*p.s):0, pw=p.w==p.w?long(100*p.w):0, pp=p.p==p.p?long(1e5*p.p+0.5):0; + if(cp.r[3]==255 || p.type==0 || p.type==1 || p.type==4 || p.type==6) + buf = mgl_sprintf("[%d,%ld,%ld,%ld,%ld,%d,%ld,%ld,%ld,0,\"#%02x%02x%02x\"],\n", + p.type, n1, n2, n3, n4, p.id, ps,pw,pp, int(cp.r[0]),int(cp.r[1]),int(cp.r[2])); + else if(cp.r[3]) + buf = mgl_sprintf("[%d,%ld,%ld,%ld,%ld,%d,%ld,%ld,%ld,0,\"rgba(%d,%d,%d,%.2g)\"],\n", + p.type, n1, n2, n3, n4, p.id, ps,pw,pp, int(cp.r[0]),int(cp.r[1]),int(cp.r[2]),cp.r[3]/255.); + else buf = ""; +#pragma omp critical + res += buf; + } + res += "[-1,0,0,0,0,0,0,0,0,0,\"#000000\"]\n"; // need to add this empty block + + l = (long)xy.size(); + res = res + mgl_sprintf("],\t\"ncoor\":%lu,\t\"coor\":[\n",(unsigned long)l); + for(i=0;iWriteJSON(fname); } +void MGL_EXPORT mgl_write_json_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_json(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_json_z(HMGL gr, const char *fname,const char *) +{ _Gr_->WriteJSON(fname,true); } +void MGL_EXPORT mgl_write_json_z_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_json_z(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +bool mglCanvas::ExportMGLD(const char *fname, const char *descr) +{ + if(Pnt.size()<1 || Prm.size()<1) return true; + FILE *fp=fopen(fname,"wt"); + if(!fp) return true; + setlocale(LC_NUMERIC, "C"); + // NOTE: I'll save Ptx. So prim type=6 is useless,and no LaTeX + fprintf(fp,"MGLD %lu %lu %lu %lu %d %d\n# %s\n", (unsigned long)Pnt.size(), (unsigned long)Prm.size(), (unsigned long)Txt.size(), (unsigned long)Glf.size(), Width, Height, (descr && *descr) ? descr : fname); + fprintf(fp,"# Vertexes: x y z c t ta u v w r g b a\n"); + for(size_t i=0;iExportMGLD(fname, descr); } +void MGL_EXPORT mgl_export_mgld_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_export_mgld(_GR_,s,f); delete []s; delete []f; } +//----------------------------------------------------------------------------- +bool mglCanvas::ImportMGLD(const char *fname, bool add) +{ + FILE *fp=fopen(fname,"rt"); + if(!fp) return true; + char *buf=new char[512]; + if(!fgets(buf,512,fp)) *buf=0; + if(strncmp(buf,"MGLD",4)) { delete []buf; fclose(fp); return true; } + unsigned long i,n=0,m=0,l=0,k=0, npnt=0, nglf=0; + int w=0,h=0,d; + sscanf(buf+5,"%lu%lu%lu%lu%d%d",&n,&m,&l,&k,&w,&h); + if(w<=0 || h<=0) { w=Width; h=Height; } + d = long(sqrt(double(w*h))); + if(n==0 || m==0 || l==0) { delete []buf; fclose(fp); return true; } + setlocale(LC_NUMERIC, "C"); + if(!add) { Clf(); Txt.clear(); } + else { ClfZB(); npnt=Pnt.size(); nglf=Glf.size(); } +#if MGL_HAVE_PTHREAD + pthread_mutex_lock(&mutexGlf); + pthread_mutex_lock(&mutexPnt); + pthread_mutex_lock(&mutexPrm); + pthread_mutex_lock(&mutexTxt); +#endif +#pragma omp critical + { + Pnt.reserve(n); Prm.reserve(m); Txt.reserve(l); Glf.reserve(k); + mglPnt p; + for(i=0;i=0?q.n1+npnt:-1; + q.n2 = q.n2>=0?q.n2+npnt:-1; + if(q.type==2 || q.type==3) + { q.n3 = q.n3>=0?q.n3+npnt:-1; q.n4 = q.n4>=0?q.n4+npnt:-1; } + if(q.type==4) + { q.n4 = q.n4>=0?q.n4+nglf:-1; q.s *= font_factor/(w' ') k=1; + if(sm==2 && k) break; + } + sscanf(buf,"%d%g", &sm, &a); + t.Set(buf+j, sm, a); + Txt.push_back(t); + } + mglGlyph g; + for(i=0;iImportMGLD(fname, add); } +void MGL_EXPORT mgl_import_mgld_(uintptr_t *gr, const char *fname, int *add, int l) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + mgl_import_mgld(_GR_,s,*add); delete []s; } +//----------------------------------------------------------------------------- +/*void MGL_EXPORT mgl_xgl_prim(const mglPrim &q, const mglPnt &p, FILE *fp, mreal size) +{ + char type = q.n4; mreal ss=size*0.35; + register long i=q.n1,j; + switch(q.type) + { + case 0: + if(!strchr("xsSoO",type)) ss *= 1.1; + if(type=='.' || ss==0) fprintf(fp,"p %ld\n", i); + else switch(type) // TODO: save mark by PATCH + { + case 'P': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss,p.z); + fprintf(fp,"l -4/%ld -3/%ld\n", i,i); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -4/%ld\n", i,i); + case '+': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"l -4/%ld -3/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); break; + case 'X': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss,p.z); + fprintf(fp,"l -4/%ld -3/%ld\n", i,i); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -4/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); + fprintf(fp,"l -2/%ld -4/%ld\n", i,i); break; + case 'x': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss,p.z); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); + fprintf(fp,"l -2/%ld -4/%ld\n", i,i); break; + case 'S': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss,p.z); + fprintf(fp,"f -4/%ld -3/%ld -2/%ld -1/%ld\n",i,i,i,i); break; + case 's': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss,p.z); + fprintf(fp,"l -4/%ld -3/%ld\n", i,i); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -4/%ld\n", i,i); break; + case 'D': + fprintf(fp,"v %g %g %g\n",p.x,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"f -4/%ld -3/%ld -2/%ld -1/%ld\n",i,i,i,i); break; + case 'd': + fprintf(fp,"v %g %g %g\n",p.x,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"l -4/%ld -3/%ld\n", i,i); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -4/%ld\n", i,i); break; + case 'Y': + fprintf(fp,"v %g %g %g\n",p.x,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+0.8*ss,p.y+0.6*ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-0.8*ss,p.y+0.6*ss,p.z); + fprintf(fp,"l -3/%ld %ld/%ld\n", i,i,i); + fprintf(fp,"l -2/%ld %ld/%ld\n", i,i,i); + fprintf(fp,"l -1/%ld %ld/%ld\n", i,i,i); break; + case '*': + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"v %g %g %g\n",p.x+0.6*ss,p.y+0.8*ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-0.6*ss,p.y-0.8*ss,p.z); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"v %g %g %g\n",p.x+0.6*ss,p.y-0.8*ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-0.6*ss,p.y+0.8*ss,p.z); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); break; + case 'T': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"f -3/%ld -2/%ld -1/%ld\n", i,i,i); break; + case '^': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y-ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y-ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y+ss,p.z); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); break; + case 'V': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y-ss,p.z); + fprintf(fp,"f -3/%ld -2/%ld -1/%ld\n", i,i,i); break; + case 'v': + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y+ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y+ss/2,p.z); + fprintf(fp,"v %g %g %g\n",p.x,p.y-ss,p.z); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); break; + case 'L': + fprintf(fp,"v %g %g %g\n",p.x+ss/2,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss/2,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"f -3/%ld -2/%ld -1/%ld\n", i,i,i); break; + case '<': + fprintf(fp,"v %g %g %g\n",p.x+ss/2,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss/2,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss,p.y,p.z); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); break; + case 'R': + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"f -3/%ld -2/%ld -1/%ld\n", i,i,i); break; + case '>': + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y+ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x-ss/2,p.y-ss,p.z); + fprintf(fp,"v %g %g %g\n",p.x+ss,p.y,p.z); + fprintf(fp,"l -3/%ld -2/%ld\n", i,i); + fprintf(fp,"l -2/%ld -1/%ld\n", i,i); + fprintf(fp,"l -1/%ld -3/%ld\n", i,i); break; + case 'O': + for(long j=0;j<=20;j++) + fprintf(fp,"v %g %g %g\n",p.x+ss*mgl_cos[(j*36)%360],p.y+ss*mgl_cos[(270+j*36)%360],p.z); + for(long j=0;j<20;j++) + fprintf(fp,"f %ld/%ld %ld/%ld %ld/%ld\n", j-21,i, j-20,i, i,i); + break; + case 'C': fprintf(fp,"p %ld\n", i); + case 'o': + for(long j=0;j<=20;j++) + fprintf(fp,"v %g %g %g\n",p.x+ss*mgl_cos[(j*36)%360],p.y+ss*mgl_cos[(270+j*36)%360],p.z); + for(long j=0;j<20;j++) + fprintf(fp,"l %ld/%ld %ld/%ld\n", j-21,i, j-20,i); + break; + } + break; + case 1: fprintf(fp,"l %ld/%ld %ld/%ld\n", q.n1,q.n1, q.n2,q.n2); break; + case 2: fprintf(fp,"f %ld/%ld/%ld %ld/%ld/%ld %ld/%ld/%ld\n", + q.n1,q.n1,q.n1, q.n2,q.n2,q.n2, q.n3,q.n3,q.n3); break; + case 3: fprintf(fp,"f %ld/%ld/%ld %ld/%ld/%ld %ld/%ld/%ld %ld/%ld/%ld\n", + q.n1,q.n1,q.n1, q.n2,q.n2,q.n2, q.n3,q.n3,q.n3, q.n4,q.n4,q.n4); break; + case 4: break; // TODO: add glyphs export later + } +} +//----------------------------------------------------------------------------- +void mglCanvas::WriteXGL(const char *fname,const char *descr) +{ + if(GetPrmNum()==0) return; // nothing to do + FILE *fp=fopen(fname,"wt"); + if(!fp) return true; + fprintf(fp,"\n%s\n", (descr && *descr)?descr:fname); + fprintf(fp,"%g, %g, %g\n", BDef[0]/255., BDef[1]/255., BDef[2]/255.); + fprintf(fp,"\n%g, %g, %g\n",AmbBr, AmbBr, AmbBr); + register size_t i,j; + if(get(MGL_ENABLE_LIGHT)) for(i=0;i<10;i++) + if(light[i].n && mgl_isnan(light[i].r.x)) + { + fprintf(fp, "\n%g, %g, %g\n", light[i].d.x, light[i].d.y, light[i].d.z); + fprintf(fp, "%g, %g, %g\n\n", light[i].c.r, light[i].c.g, light[i].c.b); + } + fprintf(fp,""); + + // TODO: add textures + + long m1=0,m2=0,m; + for(i=0;im2) m2=m; } + long *ng = new long[m2-m1+1]; + for(i=0;iGrp[i].Id-m1] = i; + for(i=0;i=0 && m p; + mglPrim q; + char *pg=new char[GetPntNum()]; + for(i=0;i\n%s\n\n",Grp[i].Lbl.c_str()); + for(j=0;j%g, %g, %g

\n",j, s.x, s.y, s.z); + fprintf(fp,"%g, %g, %g\n",j, s.x, s.y, s.z); + } + // TODO: add line styles + for(j=0;j\n"); // finish with this object + Grp[i].p.clear(); // we don't need indexes anymore + } + // TODO: try to save "ungrouped" primitives + + fprintf(fp,"
"); fclose(fp); delete []pg; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_xgl(HMGL gr, const char *fname,const char *descr) +{ _Gr_->WriteXGL(fname,descr); } +void MGL_EXPORT mgl_write_xgl_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; + mgl_write_xgl(_GR_,s,d); delete []s; delete []d; }*/ +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_x3d_mdef(HMGL gr, void *fp, bool gz) +{ + bool m_p=false,m_x=false,m_d=false,m_v=false,m_t=false, + m_s=false,m_a=false,m_o=false,m_T=false, + m_V=false,m_S=false,m_D=false,m_Y=false,m_l=false, + m_L=false,m_r=false,m_R=false,m_X=false,m_P=false; + for(long i=0;iGetPrmNum();i++) + { + const mglPrim q = gr->GetPrm(i); + if(q.type>0) continue; if(q.n4=='+') m_p = true; + if(q.n4=='x') m_x = true; if(q.n4=='s') m_s = true; + if(q.n4=='d') m_d = true; if(q.n4=='v') m_v = true; + if(q.n4=='^') m_t = true; if(q.n4=='*') m_a = true; + if(q.n4=='o' || q.n4=='O' || q.n4=='C') m_o = true; + if(q.n4=='S') m_S = true; if(q.n4=='D') m_D = true; + if(q.n4=='V') m_V = true; if(q.n4=='T') m_T = true; + if(q.n4=='<') m_l = true; if(q.n4=='L') m_L = true; + if(q.n4=='>') m_r = true; if(q.n4=='R') m_R = true; + if(q.n4=='Y') m_Y = true; + if(q.n4=='P') m_P = true; if(q.n4=='X') m_X = true; + } + if(m_P) { m_p=true; m_s=true; } + if(m_X) { m_x=true; m_s=true; } + if(m_p) mgl_printf(fp, gz, "\n" + "\n" + "\n\n"); + /*if(m_x) mgl_printf(fp, gz, "/m_x {sm sm rm s2 s2 rl 0 sm 2 mul rm sm 2 mul s2 rl d0} def\n"); // TODO + * if(m_s) mgl_printf(fp, gz, "/m_s {sm sm rm 0 s2 rl s2 0 rl 0 sm 2 mul rl cp d0} def\n"); + * if(m_d) mgl_printf(fp, gz, "/m_d {sm 0 rm ss ss rl ss sm rl sm sm rl cp d0} def\n"); + * if(m_v) mgl_printf(fp, gz, "/m_v {sm ss 2 div rm s2 0 rl sm sm 1.5 mul rl d0 cp} def\n"); + * if(m_t) mgl_printf(fp, gz, "/m_t {sm sm 2 div rm s2 0 rl sm ss 1.5 mul rl d0 cp} def\n"); + * if(m_a) mgl_printf(fp, gz, "/m_a {sm 0 rm s2 0 rl sm 1.6 mul sm 0.8 mul rm ss 1.2 mul ss 1.6 mul rl 0 sm 1.6 mul rm sm 1.2 mul ss 1.6 mul rl d0} def\n"); + * if(m_o) mgl_printf(fp, gz, "/m_o {ss 0 360 d0 arc} def\n"); + * if(m_S) mgl_printf(fp, gz, "/m_S {sm sm rm 0 s2 rl s2 0 rl 0 sm 2 mul rl cp} def\n"); + * if(m_D) mgl_printf(fp, gz, "/m_D {sm 0 rm ss ss rl ss sm rl sm sm rl cp} def\n"); + * if(m_V) mgl_printf(fp, gz, "/m_V {sm ss 2 div rm s2 0 rl sm sm 1.5 mul rl cp} def\n"); + * if(m_T) mgl_printf(fp, gz, "/m_T {sm sm 2 div rm s2 0 rl sm ss 1.5 mul rl cp} def\n"); + * if(m_Y) mgl_printf(fp, gz, "/m_Y {0 sm rm 0 ss rl sm ss rl s2 0 rm sm sm rl d0} def\n"); + * if(m_r) mgl_printf(fp, gz, "/m_r {sm 2 div sm rm 0 s2 rl ss 1.5 mul sm rl d0 cp} def\n"); + * if(m_l) mgl_printf(fp, gz, "/m_l {ss 2 div sm rm 0 s2 rl sm 1.5 mul sm rl d0 cp} def\n"); + * if(m_R) mgl_printf(fp, gz, "/m_R {sm 2 div sm rm 0 s2 rl ss 1.5 mul sm rl cp} def\n"); + * if(m_L) mgl_printf(fp, gz, "/m_L {ss 2 div sm rm 0 s2 rl sm 1.5 mul sm rl cp} def\n"); + * if(m_P) mgl_printf(fp, gz, "/m_P {m_p 0 sm rm m_s} def\n"); + * if(m_X) mgl_printf(fp, gz, "/m_X {m_x ss sm rm m_s} def\n");*/ + // if(m_C) mgl_printf(fp, gz, "/m_C {m_c m_o} def\n"); + mgl_printf(fp, gz, "\n"); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_x3d_prim(const mglPrim &q, const mglPnt &p, const long *pnt, void *fp,bool gz, mreal size) +{ + // +/* if(q.type==0) // mark + { + mreal x0 = p1.x,y0 = p1.y; + sprintf(str,"1 lw %.2g %.2g %.2g rgb ", cp.r,cp.g,cp.b); + wp=1; + if(q.s!=gr->mark_size()/gr->FontFactor()) + { + mgl_printf(fp, gz, "/ss {%g} def\n",q.s*0.4*gr->FontFactor()); + mgl_printf(fp, gz, "/s2 {%g} def\n",q.s*0.8*gr->FontFactor()); + mgl_printf(fp, gz, "/sm {-%g} def\n",q.s*0.4*gr->FontFactor()); + } + switch(q.n4) + { + case '+': mgl_printf(fp, gz, "np %g %g mt m_p %sdr\n",x0,y0,str); break; + case 'x': mgl_printf(fp, gz, "np %g %g mt m_x %sdr\n",x0,y0,str); break; + case 's': mgl_printf(fp, gz, "np %g %g mt m_s %sdr\n",x0,y0,str); break; + case 'd': mgl_printf(fp, gz, "np %g %g mt m_d %sdr\n",x0,y0,str); break; + case '*': mgl_printf(fp, gz, "np %g %g mt m_a %sdr\n",x0,y0,str); break; + case 'v': mgl_printf(fp, gz, "np %g %g mt m_v %sdr\n",x0,y0,str); break; + case '^': mgl_printf(fp, gz, "np %g %g mt m_t %sdr\n",x0,y0,str); break; + case 'S': mgl_printf(fp, gz, "np %g %g mt m_S %sfill\n",x0,y0,str); break; + case 'D': mgl_printf(fp, gz, "np %g %g mt m_D %sfill\n",x0,y0,str); break; + case 'V': mgl_printf(fp, gz, "np %g %g mt m_V %sfill\n",x0,y0,str); break; + case 'T': mgl_printf(fp, gz, "np %g %g mt m_T %sfill\n",x0,y0,str); break; + case 'o': mgl_printf(fp, gz, "%g %g m_o %sdr\n",x0,y0,str);break; + case 'O': mgl_printf(fp, gz, "%g %g m_o %sfill\n",x0,y0,str);break; + case 'Y': mgl_printf(fp, gz, "np %g %g mt m_Y %sdr\n",x0,y0,str); break; + case '<': mgl_printf(fp, gz, "np %g %g mt m_l %sdr\n",x0,y0,str); break; + case '>': mgl_printf(fp, gz, "np %g %g mt m_r %sdr\n",x0,y0,str); break; + case 'L': mgl_printf(fp, gz, "np %g %g mt m_L %sfill\n",x0,y0,str); break; + case 'R': mgl_printf(fp, gz, "np %g %g mt m_R %sfill\n",x0,y0,str); break; + case 'P': mgl_printf(fp, gz, "np %g %g mt m_P %sdr\n",x0,y0,str); break; + case 'X': mgl_printf(fp, gz, "np %g %g mt m_X %sdr\n",x0,y0,str); break; + case 'C': mgl_printf(fp, gz, "%g %g m_o %g %g m_c %sdr\n",x0,y0,x0,y0,str); break; + default: mgl_printf(fp, gz, "%g %g m_c %sfill\n",x0,y0,str); + } + if(q.s!=gr->mark_size()/gr->FontFactor()) + { + mgl_printf(fp, gz, "/ss {%g} def\n",0.4*gr->mark_size()); + mgl_printf(fp, gz, "/s2 {%g} def\n",0.8*gr->mark_size()); + mgl_printf(fp, gz, "/sm {-%g} def\n",0.4*gr->mark_size()); + } + } + else if(q.type==3) // quad + { + const mglPnt p2=gr->GetPnt(q.n2), p3=gr->GetPnt(q.n3), p4=gr->GetPnt(q.n4); + mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll %g %g ll cp %sfill\n", + p1.x, p1.y, p2.x, p2.y, p4.x, p4.y, p3.x, p3.y, str); + } + else if(q.type==2) // trig + { + const mglPnt p2=gr->GetPnt(q.n2), p3=gr->GetPnt(q.n3); + mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll cp %sfill\n", + p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, str); + } + else if(q.type==1) // line + { + sprintf(str,"%.2g lw %.2g %.2g %.2g rgb ", q.w>1 ? q.w:1., cp.r,cp.g,cp.b); + wp = q.w>1 ? q.w:1; st = q.n3; + put_line(gr,fp,gz,i,wp,cp,st, "np %g %g mt ", "%g %g ll ", false, 1); + const char *sd = mgl_get_dash(q.n3,q.w); + if(sd && sd[0]) mgl_printf(fp, gz, "%s [%s] %g sd dr\n",str,sd,q.w*q.s); + else mgl_printf(fp, gz, "%s d0 dr\n",str); + } + else if(q.type==4) // glyph + { + mreal ss = q.s/2, xx = p1.u, yy = p1.v, zz = p1.w; + mgl_printf(fp, gz, "gsave\t%g %g translate %g %g scale %g rotate %s\n", + p1.x, p1.y, ss, ss, -q.w, str); + if(q.n3&8) // this is "line" + { + mreal dy = 0.004,f=fabs(zz); + mgl_printf(fp, gz, "np %g %g mt %g %g ll %g %g ll %g %g ll cp ", + xx,yy+dy, xx+f,yy+dy, xx+f,yy-dy, xx,yy-dy); + } + else + mgl_printf(fp, gz, "%.3g %.3g translate %g %g scale %c%c_%04x ", + xx, yy, zz, zz, q.n3&1?'b':'n', q.n3&2?'i':'n', q.n4); + if(q.n3&4) mgl_printf(fp, gz, "dr"); + else mgl_printf(fp, gz, "eofill"); + mgl_printf(fp, gz, " grestore\n"); + }*/ +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_x3d(HMGL gr, const char *fname,const char *descr) +{ + if(gr->GetPrmNum()<1) return; + time_t now; time(&now); + + bool gz = fname[strlen(fname)-1]=='z'; + void *fp = gz ? (void*)gzopen(fname,"wt") : (void*)fopen(fname,"wt"); + if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; } + setlocale(LC_NUMERIC, "C"); + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n\n\n",fname); + mgl_printf(fp, gz, "\n",(descr && *descr)?descr:fname); + mgl_printf(fp, gz, "\n",ctime(&now)); + mgl_printf(fp, gz, "\n"); + mgl_printf(fp, gz, "\n\n"); + + // 1. first we have to define proto for marks and glyphs + mgl_x3d_mdef(gr, fp, gz); + + // here should be defined textures ... but since X3D support RGBA then omit it in this version + + // 2. now find group for primitives + long m1=0,m2=0,m; + for(size_t i=0;iGrp.size();i++) // prepare array of indirect indexing + { m = gr->Grp[i].Id; if(mm2) m2=m; } + long *ng = new long[m2-m1+1]; + for(size_t i=0;iGrp.size();i++) ng[gr->Grp[i].Id-m1] = i; + for(long i=0;iGetPrmNum();i++) // collect data for groups + // it is rather expensive (extra 4b per primitive) but need for export to 3D + { + m = gr->GetPrm(i).id-m1; + if(m>=0 && mGrp[ng[m]].p.push_back(i); + } + delete []ng; + + // resort in creation order for proper drawing of lines and faces + gr->resort(); + + // primitive definition in groups + long npnt = gr->GetPntNum(), k; + long *pnt=new long[npnt]; + mglPrim q; + for(size_t i=0;iGrp.size();i++) + { + mgl_printf(fp,gz,"\n",gr->Grp[i].Lbl.c_str()); + std::vector &p = gr->Grp[i].p; + + // define coordinates, colors and so on + long line=-1, face=-1, other=-1; k=0; + for(size_t j=0;jGetPrm(p[j]); + if(q.type==1) line=q.n1; // find kind of primitives in the group + if(q.type==2 || q.type==3) face =q.n1; + if(q.type>3 || q.type==0) other=q.n1; + } + + // now save lines + if(line>=0) + { + mglColor c=gr->GetPntC(line); + bool same=true; // check if there are the same colors for all line segments + for(size_t j=0;jGetPrm(p[j]); + if(q.type==1 && c!=gr->GetPntC(q.n1)) same=false; + } + memset(pnt,-1,npnt*sizeof(long)); + for(size_t j=0,k=0;jGetPrm(p[j]); + if(q.type!=1) continue; + if(q.n1>=0 && pnt[q.n1]<0) { pnt[q.n1]=k; k++; } + if(q.n2>=0 && pnt[q.n2]<0) { pnt[q.n2]=k; k++; } + } + mgl_printf(fp, gz, ""); + mgl_printf(fp, gz, ""); + + // TODO save IndexedLineSet here + manual color is same==true + + mgl_printf(fp, gz, ""); + } + + // now save faces + if(face>=0) + { + mglColor c=gr->GetPntC(face); + bool same=true; // check if there are the same colors for all line segments + for(size_t j=0;jGetPrm(p[j]); + if((q.type==2 || q.type==3) && c!=gr->GetPntC(q.n1)) same=false; + } + memset(pnt,-1,npnt*sizeof(long)); + for(size_t j=0,k=0;jGetPrm(p[j]); + if(q.type!=2 && q.type!=3) continue; + if(q.n1>=0 && pnt[q.n1]<0) { pnt[q.n1]=k; k++; } + if(q.n2>=0 && pnt[q.n2]<0) { pnt[q.n2]=k; k++; } + if(q.n3>=0 && pnt[q.n3]<0) { pnt[q.n3]=k; k++; } + if(q.type==3 && q.n4>=0 && pnt[q.n4]<0) { pnt[q.n4]=k; k++; } + } + mgl_printf(fp, gz, ""); + mgl_printf(fp, gz, ""); + + // TODO save IndexedLineSet here + manual color is same==true + + mgl_printf(fp, gz, ""); + } + + // now save other primitives + if(other>=0) + { +/* memset(pnt,-1,npnt*sizeof(long)); + for(j=0,k=0;jGetPrm(p[j]); + if(q.type!=2 && q.type!=3) continue; + if(q.n1>=0 && pnt[q.n1]<0) { pnt[q.n1]=k; k++; } + if(q.n2>=0 && pnt[q.n2]<0) { pnt[q.n2]=k; k++; } + if(q.n3>=0 && pnt[q.n3]<0) { pnt[q.n3]=k; k++; } + if(q.type==3 && q.n4>=0 && pnt[q.n4]<0) { pnt[q.n4]=k; k++; } + } + mgl_printf(fp, gz, ""); + mgl_printf(fp, gz, ""); + + // TODO save IndexedLineSet here + manual color is same==true + + mgl_printf(fp, gz, "");*/ + } + // no normals since mathgl ones are "signless" -- x3d should calculate it by itself + + for(size_t j=0;jGetPrm(p[j]); // TODO: collect by type (quads,trig,line) and draw together??? + mgl_x3d_prim(q, gr->GetPnt(q.n1), pnt, fp,gz, q.s*gr->FontFactor()); + } + mgl_printf(fp,gz,"\n",gr->Grp[i].Lbl.c_str()); + gr->Grp[i].p.clear(); // we don't need indexes anymore + } + mgl_printf(fp, gz, "\n"); + if(gz) gzclose((gzFile)fp); else fclose((FILE *)fp); + setlocale(LC_NUMERIC, ""); + delete []pnt; +} +void MGL_EXPORT mgl_write_x3d_(uintptr_t *gr, const char *fname,const char *descr,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; +char *d=new char[n+1]; memcpy(d,descr,n); d[n]=0; +mgl_write_x3d(_GR_,s,d); delete []s; delete []d; } +//----------------------------------------------------------------------------- diff --git a/src/fft.cpp b/src/fft.cpp new file mode 100644 index 0000000..c606b04 --- /dev/null +++ b/src/fft.cpp @@ -0,0 +1,1311 @@ +/*************************************************************************** + * fft.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/datac.h" +#include "mgl2/data.h" +#include "mgl2/thread.h" +#if MGL_HAVE_GSL +#include +#include +#include +#endif +//----------------------------------------------------------------------------- +void MGL_EXPORT mglStartThreadT(void *(*func)(void *), long n, void *a, double *b, const void *v, void **w, const long *p, const void *re, const void *im) +{ + if(!func) return; +#if MGL_HAVE_PTHREAD + if(mglNumThr<1) mgl_set_num_thr(0); + if(mglNumThr>1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadT *par=new mglThreadT[mglNumThr]; + register long i; + for(i=0;i0) for(long i=0;i0) for(long i=0;ip[0]; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + mgl_fft(t->b+2*nx*i, 1, nx, t->v, w, t->p[3]); + mgl_fft_free_thr(w); + } + return 0; +} +MGL_NO_EXPORT void* mgl_ffty(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + register long i,nx=t->p[0],ny=t->p[1]; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(i=t->id;in;i+=mglNumThr) + mgl_fft(t->b+2*(i%nx)+2*nx*ny*(i/nx), nx, ny, t->v, w, t->p[3]); + mgl_fft_free_thr(w); + } + return 0; +} +MGL_NO_EXPORT void* mgl_fftz(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + register long i,nx=t->p[0],ny=t->p[1],nz=t->p[2]; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(i=t->id;in;i+=mglNumThr) + mgl_fft(t->b+2*i, nx*ny, nz, t->v, w, t->p[3]); + mgl_fft_free_thr(w); + } + return 0; +} +void MGL_EXPORT mgl_datac_fft(HADT d, const char *dir) +{ + if(!dir || *dir==0) return; + long nx = d->nx, ny = d->ny, nz = d->nz; + void *wt=0; + bool clear=false; + long par[4]={nx,ny,nz,strchr(dir,'i')!=0}; +#if MGL_USE_DOUBLE + double *a = (double *)(d->a); +#else + double *a = new double[2*nx*ny*nz]; // manually convert to double +#pragma omp parallel for + for(long i=0;ia[i]); a[2*i+1] = imag(d->a[i]); } +#endif + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.wnx==nx) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx,0,0); } + mglStartThreadT(mgl_fftx,ny*nz,0,a,wt,0,par); + if(mgl_fft_data.wnx==0) + { clear = false; mgl_fft_data.wtx = wt; mgl_fft_data.wnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.wny==ny) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny,0,0); } + mglStartThreadT(mgl_ffty,nx*nz,0,a,wt,0,par); + if(mgl_fft_data.wny==0) + { clear = false; mgl_fft_data.wty = wt; mgl_fft_data.wny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.wnz==nz) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz,0,0); } + mglStartThreadT(mgl_fftz,nx*ny,0,a,wt,0,par); + if(mgl_fft_data.wnz==0) + { clear = false; mgl_fft_data.wtz = wt; mgl_fft_data.wnz=nz; } + } + if(clear) mgl_fft_free(wt,0,0); +#if !MGL_USE_DOUBLE +#pragma omp parallel for + for(long i=0;ia[i] = dual(a[2*i], a[2*i+1]); + delete []a; +#endif +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_fourier(HMDT re, HMDT im, const char *dir) +{ + if(!dir || *dir==0) return; + long nx = re->nx, ny = re->ny, nz = re->nz; + if(nx*ny*nz != im->nx*im->ny*im->nz || !dir || dir[0]==0) return; + bool clear=false; + void *wt=0; + long par[4]={nx,ny,nz,strchr(dir,'i')!=0}; + double *a = new double[2*nx*ny*nz]; +#pragma omp parallel for + for(long i=0;ia[i]; a[2*i+1] = im->a[i]; } + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.wnx==nx) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx,0,0); } + mglStartThreadT(mgl_fftx,ny*nz,0,a,wt,0,par); + if(mgl_fft_data.wnx==0) + { mgl_fft_data.wtx = wt; clear = false; mgl_fft_data.wnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.wny==ny) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny,0,0); } + mglStartThreadT(mgl_ffty,nx*nz,0,a,wt,0,par); + if(mgl_fft_data.wny==0) + { mgl_fft_data.wty = wt; clear = false; mgl_fft_data.wny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.wnz==nz) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz,0,0); } + mglStartThreadT(mgl_fftz,nx*ny,0,a,wt,0,par); + if(mgl_fft_data.wnz==0) + { mgl_fft_data.wtz = wt; clear = false; mgl_fft_data.wnz=nz; } + } + if(clear) { mgl_fft_free(wt,0,0); } +#pragma omp parallel for + for(long i=0;ia[i] = a[2*i]; im->a[i] = a[2*i+1]; } + delete []a; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void* mgl_envx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0]; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nx]; + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jv, w, false); + for(long j=0;jv, w, true); + for(long j=0;jp[0],ny=t->p[1]; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*ny]; + void *w = mgl_fft_alloc_thr(ny); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jv, t->w[t->id], false); + for(long j=0;jv, t->w[t->id], true); + for(long j=0;jp[0],ny=t->p[1],nz=t->p[2],k=nx*ny; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nz]; + void *w = mgl_fft_alloc_thr(nz); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jv, t->w[t->id], false); + for(long j=0;jv, t->w[t->id], true); + for(long j=0;jnx,ny=d->ny,nz=d->nz,par[3]={nx,ny,nz}; + bool clear=false; + void *wt=0; + if(dir=='x' && nx>1) + { + if(mgl_fft_data.wnx==nx) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx,0,0); } + mglStartThreadT(mgl_envx,ny*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wnx==0) + { mgl_fft_data.wtx = wt; clear = false; mgl_fft_data.wnx=nx; } + } + if(dir=='y' && ny>1) + { + if( mgl_fft_data.wny==ny) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny,0,0); } + mglStartThreadT(mgl_envy,nx*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wny==0) + { mgl_fft_data.wty = wt; clear = false; mgl_fft_data.wny=ny; } + } + if(dir=='z' && nz>1) + { + if(mgl_fft_data.wnz==nz) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz,0,0); } + mglStartThreadT(mgl_envz,nx*ny,d->a,0,wt,0,par); + if(mgl_fft_data.wnz==0) + { mgl_fft_data.wtz = wt; clear = false; mgl_fft_data.wnz=nz; } + } + if(clear) mgl_fft_free(wt,0,0); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void* mgl_stfa1(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long mx=t->p[0],mz=t->p[2],dn=t->p[3],dd=dn/2,ny=t->p[4]; + mreal *d = (mreal*)t->a; + HCDT re = (HCDT)t->re, im = (HCDT)t->im; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *a = new double[4*dn], ff; + void *w = mgl_fft_alloc_thr(2*dn); +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%mx, j = ii/mx, i0; + for(long k=0;k<2*dn;k++) + { + i0 = k-dd+j*dn; ff = 1; + if(i0<0) i0=0; else if(i0>=ny) i0=ny-1; + if(k=dn+dd) + { ff = 0.5*(k-3.5*dd)/dd; ff=0.5-ff*(3-ff*ff); } + a[2*k] = re->v(i,i0)*ff; a[2*k+1] = im->v(i,i0)*ff; + } + mgl_fft(a, 1, 2*dn, t->v, w, false); + for(long k=0;kp[0],my=t->p[1],dn=t->p[3],dd=dn/2,nx=t->p[4]; + mreal *d = (mreal*)t->a; + HCDT re = (HCDT)t->re, im = (HCDT)t->im; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *a = new double[4*dn], ff; + void *w = mgl_fft_alloc_thr(2*dn); +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%my, j = ii/my, i0; + for(long k=0;k<2*dn;k++) + { + i0 = k-dd+i*dn; ff = 1; + if(i0<0) i0=0; else if(i0>=nx) i0=nx-1; + if(k=3*dd) + { ff = 0.5*(k-3.5*dd)/dd; ff=0.5-ff*(3-ff*ff); } + a[2*k] = re->v(i0,j)*ff; a[2*k+1] = im->v(i0,j)*ff; + } + mgl_fft(a, 1, 2*dn, t->v, w, false); + for(long k=0;kGetNx(), ny = re->GetNy(); + if(nx*ny!=im->GetNx()*im->GetNy()) return 0; + void *wt = mgl_fft_alloc(2*dn,0,0); + long mx,my,mz; + mglData *d=new mglData; + if(dir=='y') + { + mx = nx; my = dn; mz = ny/dn; + mgl_data_create(d, mx, mz, my); + long par[5]={mx,my,mz,dn,ny}; + mglStartThreadT(mgl_stfa1,mx*mz,d->a,0,wt,0,par,re,im); + } + else + { + mx = dn; my = nx/dn; mz = ny; + mgl_data_create(d, my, mx, mz); + long par[5]={mx,my,mz,dn,nx}; + mglStartThreadT(mgl_stfa2,my*mz,d->a,0,wt,0,par,re,im); + } + mgl_fft_free(wt,0,0); + return d; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void* mgl_sinx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0]; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nx], f=sqrt(2./nx); + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + register long k = i*nx; memset(b,0,2*nx*sizeof(double)); + for(long j=1;jv,w,false); + a[k]=0; a[k+1]=b[0]*f/2; // fill sinfft + for(long j=1;jp[0],ny=t->p[1]; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*ny], f=sqrt(2./ny); + void *w = mgl_fft_alloc_thr(ny); +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%nx, k = ii/nx; memset(b,0,2*ny*sizeof(double)); + for(long j=1;jv,w,false); + a[i+nx*ny*k]=0; a[i+nx*(ny*k+1)]=b[0]*f/2; // fill sinfft + for(long j=1;jp[0],ny=t->p[1],nz=t->p[2],k=nx*ny; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nz], f=sqrt(2./nz); + void *w = mgl_fft_alloc_thr(nz); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + memset(b,0,2*nz*sizeof(double)); + for(long j=1;jv,w,false); + a[i]=0; a[i+k]=b[0]*f/2; // fill sinfft + for(long j=1;jnx, ny=d->ny, nz=d->nz, par[3]={nx,ny,nz}; + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.wnx==nx) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx,0,0); } + mglStartThreadT(mgl_sinx,ny*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wnx==0) + { mgl_fft_data.wtx = wt; clear = false; mgl_fft_data.wnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.wny==ny) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny,0,0); } + mglStartThreadT(mgl_siny,nx*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wny==0) + { mgl_fft_data.wty = wt; clear = false; mgl_fft_data.wny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.wnz==nz) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz,0,0); } + mglStartThreadT(mgl_sinz,nx*ny,d->a,0,wt,0,par); + if(mgl_fft_data.wnz==0) + { mgl_fft_data.wtz = wt; clear = false; mgl_fft_data.wnz=nz; } + } + if(clear) mgl_fft_free(wt,0,0); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void* mgl_cosx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0],nn=nx-1; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nx], f=sqrt(2./nn); + void *w = mgl_fft_alloc_thr(nn); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + register long k = i*nx; memset(b,0,2*nx*sizeof(double)); + for(long j=0;jv,w,false); + double f1=0.5*(a[k]-a[nn+k]), s=-1; + a[nn+k]=0.5*(a[k]+a[nn+k]*(nn%2?-1:1)); + for(long j=1;jp[0],ny=t->p[1],nn=ny-1; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*ny], f=sqrt(2./nn); + void *w = mgl_fft_alloc_thr(nn); +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%nx, k = ii/nx; memset(b,0,2*ny*sizeof(double)); + for(long j=0;jv,w,false); + double f1=0.5*(a[i+nx*ny*k]-a[i+nx*(ny*k+nn)]), s=-1; + a[i+nx*(ny*k+nn)]=0.5*(a[i+nx*ny*k]+a[i+nx*(ny*k+nn)]*(nn%2?-1:1)); + for(long j=1;jp[0],ny=t->p[1],nz=t->p[2],k=nx*ny,nn=nz-1; + mreal *a = (mreal*)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nz], f=sqrt(2./nn); + void *w = mgl_fft_alloc_thr(nn); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + memset(b,0,2*nz*sizeof(double)); + for(long j=0;jv,w,false); + double f1=0.5*(a[i]-a[i+k*nn]), s=-1; + a[i+k*nn]=0.5*(a[i]+a[i+k*nn]*(nn%2?-1:1)); + for(long j=1;jnx, ny=d->ny, nz=d->nz, par[3]={nx,ny,nz}; + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.wnx==nx-1) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx-1,0,0); } + mglStartThreadT(mgl_cosx,ny*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wnx==0) + { mgl_fft_data.wtx = wt; clear = false; mgl_fft_data.wnx=nx-1; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.wny==ny-1) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny-1,0,0); } + mglStartThreadT(mgl_cosy,nx*nz,d->a,0,wt,0,par); + if(mgl_fft_data.wny==0) + { mgl_fft_data.wty = wt; clear = false; mgl_fft_data.wny=ny-1; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.wnz==nz-1) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz-1,0,0); } + mglStartThreadT(mgl_cosz,nx*ny,d->a,0,wt,0,par); + if(mgl_fft_data.wnz==0) + { mgl_fft_data.wtz = wt; clear = false; mgl_fft_data.wnz=nz-1; } + } + if(clear) mgl_fft_free(wt,0,0); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_transform_a(HCDT am, HCDT ph, const char *tr) +{ + long nx = am->GetNx(), ny = am->GetNy(), nz = am->GetNz(); + if(nx*ny*nz != ph->GetNx()*ph->GetNy()*ph->GetNz() || !tr || tr[0]==0) + return 0; + mglData re(nx,ny,nz), im(nx,ny,nz); + const mglData *da=dynamic_cast(am); + const mglData *dp=dynamic_cast(ph); + if(da && dp) +#pragma omp parallel for + for(long i=0;ia[i]*cos(dp->a[i]); + im.a[i] = da->a[i]*sin(dp->a[i]); } + else +#pragma omp parallel for + for(long i=0;ivthr(i)*cos(ph->vthr(i)); + im.a[i] = am->vthr(i)*sin(ph->vthr(i)); } + return mgl_transform(&re, &im, tr); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_transform(HCDT re, HCDT im, const char *tr) +{ + if(!tr || *tr==0) return 0; + long nx = re->GetNx(), ny = re->GetNy(), nz = re->GetNz(); + if(nx*ny*nz != im->GetNx()*im->GetNy()*im->GetNz() || !tr || tr[0]==0) + return 0; + mglData rr(re),ii(im); + if(strchr(tr,'i') && strchr(tr,'f')) // general case + { + if(tr[0]=='f') mgl_data_fourier(&rr,&ii,"x"); + if(tr[0]=='i') mgl_data_fourier(&rr,&ii,"xi"); + if(tr[1]=='f') mgl_data_fourier(&rr,&ii,"y"); + if(tr[1]=='i') mgl_data_fourier(&rr,&ii,"yi"); + if(tr[2]=='f') mgl_data_fourier(&rr,&ii,"z"); + if(tr[2]=='i') mgl_data_fourier(&rr,&ii,"zi"); + } + else if(strchr(tr,'f')) // do Fourier only once for speeding up + { + char str[4] = " "; + if(tr[0]=='f') str[0]='x'; + if(tr[1]=='f') str[1]='y'; + if(tr[2]=='f') str[2]='z'; + mgl_data_fourier(&rr,&ii,str); + } + else if(strchr(tr,'i')) // do Fourier only once for speeding up + { + char str[5] = " i"; + if(tr[0]=='i') str[0]='x'; + if(tr[1]=='i') str[1]='y'; + if(tr[2]=='i') str[2]='z'; + mgl_data_fourier(&rr,&ii,str); + } + else if(strchr(tr,'s')) // do Fourier only once for speeding up + { + if(tr[0]=='s') { rr.SinFFT("x"); ii.SinFFT("x"); } + if(tr[1]=='s') { rr.SinFFT("y"); ii.SinFFT("y"); } + if(tr[2]=='s') { rr.SinFFT("z"); ii.SinFFT("z"); } + } + else if(strchr(tr,'c')) // do Fourier only once for speeding up + { + if(tr[0]=='c') { rr.CosFFT("x"); ii.CosFFT("x"); } + if(tr[1]=='c') { rr.CosFFT("y"); ii.CosFFT("y"); } + if(tr[2]=='c') { rr.CosFFT("z"); ii.CosFFT("z"); } + } + else if(strchr(tr,'h')) // do Fourier only once for speeding up + { + if(tr[0]=='h') { rr.Hankel("x"); ii.Hankel("x"); } + if(tr[1]=='h') { rr.Hankel("y"); ii.Hankel("y"); } + if(tr[2]=='h') { rr.Hankel("z"); ii.Hankel("z"); } + } + mglData *d = new mglData(nx, ny, nz); +#pragma omp parallel for + for(long i=0;ia[i] = hypot(rr.a[i],ii.a[i]); + return d; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_transform_a_(uintptr_t *am, uintptr_t *ph, const char *tr, int l) +{ char *s=new char[l+1]; memcpy(s,tr,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_transform_a(_DA_(am),_DA_(ph),s)); + delete []s; return res; } +uintptr_t MGL_EXPORT mgl_transform_(uintptr_t *re, uintptr_t *im, const char *tr, int l) +{ char *s=new char[l+1]; memcpy(s,tr,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_transform(_DA_(re),_DA_(im),s)); + delete []s; return res; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_envelop_(uintptr_t *d, const char *dir, int) +{ mgl_data_envelop(_DT_,*dir); } +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +MGL_NO_EXPORT void* mgl_chnkx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0]; + dual *a = (dual*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(nx+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[3*nx]; +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jp[0],ny=t->p[1]; + dual *a = (dual*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(ny+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[3*ny]; +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%nx, k = ii/nx; + for(long j=0;jp[0]*t->p[1],nz=t->p[2]; + dual *a = (dual*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(nz+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[3*nz]; +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jnx, ny=d->ny, nz=d->nz; + long par[3]={nx,ny,nz}; + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.hnx==nx) dht = (gsl_dht *)mgl_fft_data.htx; + else { dht = gsl_dht_new(nx,0,1); clear = true; } + mglStartThreadT(mgl_chnkx,ny*nz,d->a,0,dht,0,par); + if(mgl_fft_data.hnx==0) + { mgl_fft_data.htx = dht; clear = false; mgl_fft_data.hnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.hny==ny) dht = (gsl_dht *)mgl_fft_data.hty; + else { dht = gsl_dht_new(ny,0,1); clear = true; } + mglStartThreadT(mgl_chnky,nx*nz,d->a,0,dht,0,par); + if(mgl_fft_data.hny==0) + { mgl_fft_data.hty = dht; clear = false; mgl_fft_data.hny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.hnz==nz) dht = (gsl_dht *)mgl_fft_data.htz; + else { dht = gsl_dht_new(nz,0,1); clear = true; } + mglStartThreadT(mgl_chnkz,nx*ny,d->a,0,dht,0,par); + if(mgl_fft_data.hnz==0) + { mgl_fft_data.htz = dht; clear = false; mgl_fft_data.hnz=nz; } + } + if(clear) gsl_dht_free(dht); +} +#else +void MGL_EXPORT mgl_datac_hankel(HADT , const char *){} +#endif +void MGL_EXPORT mgl_datac_hankel_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_hankel(_DC_,s); delete []s; } +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +MGL_NO_EXPORT void* mgl_hnkx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0]; + mreal *a = (mreal*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(nx+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nx]; +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jp[0],ny=t->p[1]; + mreal *a = (mreal*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(ny+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*ny]; +#pragma omp for nowait + for(long ii=t->id;iin;ii+=mglNumThr) + { + register long i = ii%nx, k = ii/nx; + for(long j=0;jp[0]*t->p[1],nz=t->p[2]; + mreal *a = (mreal*)t->a; + const gsl_dht *dht = (const gsl_dht*)t->v; + double mm = gsl_sf_bessel_zero_J0(nz+1); + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + double *b = new double[2*nz]; +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + for(long j=0;jnx, ny=d->ny, nz=d->nz; + long par[3]={nx,ny,nz}; + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.hnx==nx) dht = (gsl_dht *)mgl_fft_data.htx; + else { dht = gsl_dht_new(nx,0,1); clear = true; } + mglStartThreadT(mgl_hnkx,ny*nz,d->a,0,dht,0,par); + if(mgl_fft_data.hnx==0) + { mgl_fft_data.htx = dht; clear = false; mgl_fft_data.hnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.hny==ny) dht = (gsl_dht *)mgl_fft_data.hty; + else { dht = gsl_dht_new(ny,0,1); clear = true; } + mglStartThreadT(mgl_hnky,nx*nz,d->a,0,dht,0,par); + if(mgl_fft_data.hny==0) + { mgl_fft_data.hty = dht; clear = false; mgl_fft_data.hny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.hnz==nz) dht = (gsl_dht *)mgl_fft_data.htz; + else { dht = gsl_dht_new(nz,0,1); clear = true; } + mglStartThreadT(mgl_hnkz,nx*ny,d->a,0,dht,0,par); + if(mgl_fft_data.hnz==0) + { mgl_fft_data.htz = dht; clear = false; mgl_fft_data.hnz=nz; } + } + if(clear) gsl_dht_free(dht); +} +#else +void MGL_EXPORT mgl_data_hankel(HMDT , const char *){} +#endif +void MGL_EXPORT mgl_data_hankel_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_hankel(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_data_fill_sample(HMDT d, const char *how) +{ + if(!how || *how==0) return; + bool xx = strchr(how,'x'); + long n=d->nx; + mreal *aa=d->a; + if(strchr(how,'h')) // Hankel + { +#if MGL_HAVE_GSL + gsl_dht *dht = gsl_dht_new(n,0,1); +#pragma omp parallel for + for(long i=0;iny*d->nz;i++) memcpy(aa+i*n,aa,n*sizeof(mreal)); +} +void MGL_EXPORT mgl_data_fill_sample_(uintptr_t *d, const char *how,int l) +{ char *s=new char[l+1]; memcpy(s,how,l); s[l]=0; + mgl_data_fill_sample(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_datac_fft_(uintptr_t *d, const char *dir, int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_datac_fft(_DC_,s); delete []s; } +void MGL_EXPORT mgl_data_fourier_(uintptr_t *re, uintptr_t *im, const char *dir, int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_fourier(_DM_(re),_DM_(im),s); delete []s; } +uintptr_t MGL_EXPORT mgl_data_stfa_(uintptr_t *re, uintptr_t *im, int *dn, char *dir, int) +{ return uintptr_t(mgl_data_stfa(_DA_(re),_DA_(im),*dn,*dir)); } +void MGL_EXPORT mgl_data_cosfft_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_cosfft(_DT_,s); delete []s; } +void MGL_EXPORT mgl_data_sinfft_(uintptr_t *d, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + mgl_data_sinfft(_DT_,s); delete []s; } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void* mgl_corx(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0]; + double *a = (double *)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(nx); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + mgl_fft(t->b+2*nx*i, 1, nx, t->v, w, false); + mgl_fft(a+2*nx*i, 1, nx, t->v, w, false); + for(long j=0;jb[ii], im = t->b[ii+1]; + t->b[ii] = re*a[ii] + im*a[ii+1]; + t->b[ii+1] = im*a[ii] - re*a[ii+1]; + } + mgl_fft(t->b+2*nx*i, 1, nx, t->v, w, true); + } + mgl_fft_free_thr(w); + } + return 0; +} +MGL_NO_EXPORT void* mgl_cory(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0],ny=t->p[1]; + double *a = (double *)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(ny); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + register long k = 2*(i%nx)+2*nx*ny*(i/nx); + mgl_fft(t->b+k, nx, ny, t->v, w, false); + mgl_fft(a+k, nx, ny, t->v, w, false); + for(long j=0;jb[ii], im = t->b[ii+1]; + t->b[ii] = re*a[ii] + im*a[ii+1]; + t->b[ii+1] = im*a[ii] - re*a[ii+1]; + } + mgl_fft(t->b+k, nx, ny, t->v, w, true); + } + mgl_fft_free_thr(w); + } + return 0; +} +MGL_NO_EXPORT void* mgl_corz(void *par) +{ + mglThreadT *t=(mglThreadT *)par; + long nx=t->p[0],ny=t->p[1],nz=t->p[2]; + double *a = (double *)t->a; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + void *w = mgl_fft_alloc_thr(nz); +#pragma omp for nowait + for(long i=t->id;in;i+=mglNumThr) + { + mgl_fft(t->b+2*i, nx*ny, nz, t->v, w, false); + mgl_fft(a+2*i, nx*ny, nz, t->v, w, false); + for(long j=0;jb[ii], im = t->b[ii+1]; + t->b[ii] = re*a[ii] + im*a[ii+1]; + t->b[ii+1] = im*a[ii] - re*a[ii+1]; + } + mgl_fft(t->b+2*i, nx*ny, nz, t->v, w, true); + } + mgl_fft_free_thr(w); + } + return 0; +} +MGL_NO_EXPORT double *mgl_d_correl(HCDT d1, HCDT d2, const char *dir) +{ + if(!dir || *dir==0) return 0; + long nx = d1->GetNx(), ny = d1->GetNy(), nz = d1->GetNz(), nn=nx*ny*nz; + if(nx*ny*nz!=d2->GetNN()) return 0; + void *wt=0; + bool clear=false; + long par[3]={nx,ny,nz}; + + double *a = new double[2*nn]; memset(a,0,2*nn*sizeof(double)); + double *b = new double[2*nn]; memset(b,0,2*nn*sizeof(double)); + const mglDataC *dd1 = dynamic_cast(d1); + const mglDataC *dd2 = dynamic_cast(d2); + const mglData *rd1 = dynamic_cast(d1); + const mglData *rd2 = dynamic_cast(d2); + if(dd1) +#pragma omp parallel for + for(long i=0;ia[i]); a[2*i+1] = imag(dd1->a[i]); } + else if(rd1) +#pragma omp parallel for + for(long i=0;ia[i]; + else +#pragma omp parallel for + for(long i=0;ivthr(i); + if(dd2) +#pragma omp parallel for + for(long i=0;ia[i]); b[2*i+1] = imag(dd2->a[i]); } + else if(rd2) +#pragma omp parallel for + for(long i=0;ia[i]; + else +#pragma omp parallel for + for(long i=0;ivthr(i); + + if(strchr(dir,'x') && nx>1) + { + if(mgl_fft_data.wnx==nx) wt = mgl_fft_data.wtx; + else { clear = true; wt = mgl_fft_alloc(nx,0,0); } + mglStartThreadT(mgl_corx,ny*nz,b,a,wt,0,par); + if(mgl_fft_data.wnx==0) + { mgl_fft_data.wtx = wt; clear = false; mgl_fft_data.wnx=nx; } + } + if(strchr(dir,'y') && ny>1) + { + if(mgl_fft_data.wny==ny) wt = mgl_fft_data.wty; + else { clear = true; wt = mgl_fft_alloc(ny,0,0); } + mglStartThreadT(mgl_cory,nx*nz,b,a,wt,0,par); + if(mgl_fft_data.wny==0) + { mgl_fft_data.wty = wt; clear = false; mgl_fft_data.wny=ny; } + } + if(strchr(dir,'z') && nz>1) + { + if(mgl_fft_data.wnz==nz) wt = mgl_fft_data.wtz; + else { clear = true; wt = mgl_fft_alloc(nz,0,0); } + mglStartThreadT(mgl_corz,nx*ny,b,a,wt,0,par); + if(mgl_fft_data.wnz==0) + { mgl_fft_data.wtz = wt; clear = false; mgl_fft_data.wnz=nz; } + } + if(clear) mgl_fft_free(wt,0,0); + return a; +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_datac_correl(HCDT d1, HCDT d2, const char *dir) +{ + double *a = mgl_d_correl(d1,d2,dir); + if(!a) return 0; + const long nx = d1->GetNx(), ny = d1->GetNy(), nz = d1->GetNz(); + mglDataC *res = new mglDataC(nx,ny,nz); +#pragma omp parallel for + for(long i=0;ia[i] = dual(a[2*i], a[2*i+1]); + delete []a; return res; +} +uintptr_t MGL_EXPORT mgl_datac_correl_(uintptr_t *d1, uintptr_t *d2, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_datac_correl(_DA_(d1),_DA_(d2),s)); + delete []s; return res; } +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_data_correl(HCDT d1, HCDT d2, const char *dir) +{ + double *a = mgl_d_correl(d1,d2,dir); // NOTE: this is not so effective but straightforward way + if(!a) return 0; + const long nx = d1->GetNx(), ny = d1->GetNy(), nz = d1->GetNz(); + mglData *res = new mglData(nx,ny,nz); +#pragma omp parallel for + for(long i=0;ia[i] = a[2*i]; + delete []a; return res; +} +uintptr_t MGL_EXPORT mgl_data_correl_(uintptr_t *d1, uintptr_t *d2, const char *dir,int l) +{ char *s=new char[l+1]; memcpy(s,dir,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_datac_correl(_DA_(d1),_DA_(d2),s)); + delete []s; return res; } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- diff --git a/src/fit.cpp b/src/fit.cpp new file mode 100644 index 0000000..e5f4f82 --- /dev/null +++ b/src/fit.cpp @@ -0,0 +1,569 @@ +/*************************************************************************** + * fit.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/fit.h" +#include "mgl2/prim.h" +#include "mgl2/eval.h" +#include "mgl2/data.h" +#include "mgl2/base.h" + +#if MGL_HAVE_GSL +#include +#include +#endif +//----------------------------------------------------------------------------- +int mglFitPnts=100; ///< Number of output points in fitting +char mglFitRes[1024]; ///< Last fitted formula +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_puts_fit(HMGL gr, double x, double y, double z, const char *pre, const char *font, double size) +{ + long n = strlen(mglFitRes)+(pre?strlen(pre):0)+1; + char *buf = new char[n]; + if(pre) snprintf(buf,n,"%s%s",pre,mglFitRes); + else strcpy(buf,mglFitRes); + mgl_puts(gr,x,y,z,buf,font,size); + delete []buf; +} +void MGL_EXPORT mgl_puts_fit_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, const char *prefix, const char *font, mreal *size, int l, int n) +{ + char *s=new char[l+1]; memcpy(s,prefix,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,font,n); d[n]=0; + mgl_puts_fit(_GR_, *x,*y,*z, s, d, *size); + delete []s; delete []d; +} +//----------------------------------------------------------------------------- +/// Structure for keeping data and precompiled fitted formula +struct mglFitData +{ + long n; ///< number of points + mreal *x; ///< x values + mreal *y; ///< y values + mreal *z; ///< z values + mreal *a; ///< function values + mreal *s; ///< value dispersions (sigma) + mglFormula *eq; ///< approximation formula + int m; ///< number of variables + const char *var; ///< variables for fitting +}; +//----------------------------------------------------------------------------- +#if MGL_HAVE_GSL +int mgl_fit__f (const gsl_vector *x, void *data, gsl_vector *f) +{ + mglFitData *fd = (mglFitData *)data; +#pragma omp parallel + { + mreal val[MGL_VS]; + for(long i=0;im;i++) val[fd->var[i]-'a'] = gsl_vector_get(x,i); +#pragma omp for + for(long i=0;in;i++) + { + val['x'-'a'] = fd->x[i]; + val['y'-'a'] = fd->y ? fd->y[i] : 0; + val['z'-'a'] = fd->z ? fd->z[i] : 0; + gsl_vector_set (f, i, (fd->eq->Calc(val) - fd->a[i])/fd->s[i]); + } + } + return GSL_SUCCESS; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_fit__df (const gsl_vector * x, void *data, gsl_matrix * J) +{ + mglFitData *fd = (mglFitData *)data; +#pragma omp parallel + { + mreal val[MGL_VS],s; + for(long i=0;im;i++) val[fd->var[i]-'a'] = gsl_vector_get(x,i); +#pragma omp for + for(long i=0;in;i++) + { + val['x'-'a'] = fd->x[i]; s = fd->s[i]; + val['y'-'a'] = fd->y ? fd->y[i] : 0; + val['z'-'a'] = fd->z ? fd->z[i] : 0; + for(long j=0;jm;j++) + gsl_matrix_set (J, i, j, fd->eq->CalcD(val, fd->var[j])/s); + } + } + return GSL_SUCCESS; +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_fit__fdf (const gsl_vector * x, void *data, gsl_vector * f, gsl_matrix * J) +{ + mgl_fit__f(x, data, f); + mgl_fit__df(x, data, J); + return GSL_SUCCESS; +} +#endif +//----------------------------------------------------------------------------- +/// GSL based fitting procedure for formula/arguments specified by string +mreal MGL_NO_EXPORT mgl_fit_base(mglFitData &fd, mreal *ini) +{ +#if MGL_HAVE_GSL + register long i,m=fd.m,n=fd.n,iter=0; + if(n<1 || ini==0) return -1; + // setup data + double *x_init = new double[fd.m]; + for(i=0;idx, s->x, 1e-4, 1e-4 ); + } + while ( status == GSL_CONTINUE && iter < 500 ); + gsl_multifit_covar (s->J, 0.0, covar ); + mreal res = gsl_blas_dnrm2(s->f); + for(i=0;ix, i); + // free memory + gsl_multifit_fdfsolver_free (s); + gsl_matrix_free (covar); + delete []x_init; + return res; +#else + return 0.0; +#endif +} +//----------------------------------------------------------------------------- +void mglPrepareFitEq(mglBase *gr,mreal chi, const char *eq, const char *var, mreal *par) +{ + char buf[32]=""; + snprintf(mglFitRes,1024,"chi=%g",chi); + size_t i,k,len=strlen(var); + for(i=0;iSetWarn(-1,mglFitRes); + + memset(mglFitRes, 0, 1024); //mglFitRes[0] = 0; + len=strlen(eq); + for(i=k=0;iSaveState(opt); + mglData x(y->GetNx()); x.Fill(gr->Min.x, gr->Max.x); + mglData s(y); s.Fill(1,1); + return mgl_fit_xys(gr,&x,y,&s,eq,var,ini,0); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_2(HMGL gr, HCDT z, const char *eq, const char *var, HMDT ini, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()); x.Fill(gr->Min.x, gr->Max.x); + mglData y(z->GetNy()); y.Fill(gr->Min.y, gr->Max.y); + mglData s(z); s.Fill(1,1); + return mgl_fit_xyzs(gr,&x,&y,z,&s,eq,var,ini,0); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_3(HMGL gr, HCDT a, const char *eq, const char *var, HMDT ini, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()); x.Fill(gr->Min.x, gr->Max.x); + mglData y(a->GetNy()); y.Fill(gr->Min.y, gr->Max.y); + mglData z(a->GetNz()); z.Fill(gr->Min.z, gr->Max.z); + mglData s(a); s.Fill(1,1); + return mgl_fit_xyzas(gr,&x,&y,&z,a,&s,eq,var,ini,0); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xy(HMGL gr, HCDT x, HCDT y, const char *eq, const char *var, HMDT ini, const char *opt) +{ + mglData s(y); s.Fill(1,1); + return mgl_fit_xys(gr,x,y,&s,eq,var,ini,opt); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *eq, const char *var, HMDT ini, const char *opt) +{ + mglData s(z); s.Fill(1,1); + return mgl_fit_xyzs(gr,x,y,z,&s,eq,var,ini,opt); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xyza(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *eq, const char *var, HMDT ini, const char *opt) +{ + mglData s(a); s.Fill(1,1); + return mgl_fit_xyzas(gr,x,y,z,a,&s,eq,var,ini,opt); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_ys(HMGL gr, HCDT y, HCDT s, const char *eq, const char *var, HMDT ini, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()); x.Fill(gr->Min.x, gr->Max.x); + return mgl_fit_xys(gr,&x,y,s,eq,var,ini,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_fill_fit(HMGL gr, mglData &fit, mglData &in, mglFitData &fd, const char *var, long nx, long ny, long nz, long k) +{ + long nn = nx*ny*nz; + mreal dx = nx>1?(gr->Max.x-gr->Min.x)/(nx-1):0; + mreal dy = ny>1?(gr->Max.y-gr->Min.y)/(ny-1):0; + mreal dz = nz>1?(gr->Max.z-gr->Min.z)/(nz-1):0; +#pragma omp parallel + { + mreal val[MGL_VS]; memset(val,0,MGL_VS*sizeof(mreal)); + for(long j=0;jMin.x+jx*dx; + if(dy) val['y'-'a'] = gr->Min.y+jy*dy; + if(dz) val['z'-'a'] = gr->Min.z+jz*dz; + fit.a[jx+nx*(jy+ny*jz)+k*nn] = fd.eq->Calc(val); + } + } +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xys(HMGL gr, HCDT xx, HCDT yy, HCDT ss, const char *eq, const char *var, HMDT ini, const char *opt) +{ + long m = yy->GetNx(); + mreal rr = gr->SaveState(opt); + long nn = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + if(xx->GetNx()!=m) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(m<2) + { gr->SetWarn(mglWarnLow,"Fit[S]"); return 0; } + if(ss->GetNx()*ss->GetNy()*ss->GetNz() != m*yy->GetNy()*yy->GetNz()) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(!var || *var==0) + { gr->SetWarn(mglWarnNull,"Fit[S]"); return 0; } + + mglData x(xx), y(yy), s(ss); + mglFitData fd; + fd.n = m; fd.x = x.a; fd.y = 0; + fd.z = 0; fd.a = y.a; fd.s = s.a; + fd.var = var; fd.m = strlen(var); + fd.eq = new mglFormula(eq); + mglData in(fd.m), *fit=new mglData(nn, yy->GetNy(), yy->GetNz()); + mreal res=-1; + for(long i=0;iGetNy()*yy->GetNz();i++) + { + if(ini && ini->nx>=fd.m) in.Set(ini->a,fd.m); + else in.Fill(0.,0); + fd.a = y.a+i*m; fd.x = x.a+(i%x.ny)*m; + fd.s = s.a+i*m; + res = mgl_fit_base(fd,in.a); + mgl_fill_fit(gr,*fit,in,fd,var,nn,1,1,i); + if(ini && ini->nx>=fd.m) memcpy(ini->a,in.a,fd.m*sizeof(mreal)); + } + mglPrepareFitEq(gr,res,eq,var,in.a); + delete fd.eq; gr->LoadState(); return fit; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xyzs(HMGL gr, HCDT xx, HCDT yy, HCDT zz, HCDT ss, const char *eq, const char *var, HMDT ini, const char *opt) +{ + long m=zz->GetNx(),n=zz->GetNy(); + mreal rr = gr->SaveState(opt); + long nn = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + if(xx->GetNx()!=m) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(ss->GetNx()*ss->GetNy()*ss->GetNz() != m*n*zz->GetNz()) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(yy->GetNx()!=n && (xx->GetNy()!=n || yy->GetNx()!=m || yy->GetNy()!=n)) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(m<2|| n<2) + { gr->SetWarn(mglWarnLow,"Fit[S]"); return 0; } + if(!var || *var==0) + { gr->SetWarn(mglWarnNull,"Fit[S]"); return 0; } + + mglData x(m, n), y(m, n), z(zz), s(ss); +#pragma omp parallel for collapse(2) + for(long i=0;iGetNz()); + mreal res = -1; + for(long i=0;iGetNz();i++) + { + if(ini && ini->nx>=fd.m) in.Set(ini->a,fd.m); + else in.Fill(0.,0); + fd.a = z.a+i*m*n; fd.s = s.a+i*m*n; + res = mgl_fit_base(fd,in.a); + mgl_fill_fit(gr,*fit,in,fd,var,nn,nn,1,i); + if(ini && ini->nx>=fd.m) memcpy(ini->a,in.a,fd.m*sizeof(mreal)); + } + mglPrepareFitEq(gr,res, eq,var,in.a); + delete fd.eq; gr->LoadState(); return fit; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_fit_xyzas(HMGL gr, HCDT xx, HCDT yy, HCDT zz, HCDT aa, HCDT ss, const char *eq, const char *var, HMDT ini, const char *opt) +{ + long m=aa->GetNx(), n=aa->GetNy(), l=aa->GetNz(), i = n*m*l; + mreal rr = gr->SaveState(opt); + long nn = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + if(m<2 || n<2 || l<2) + { gr->SetWarn(mglWarnLow,"Fit[S]"); return 0; } + if(ss->GetNx()*ss->GetNy()*ss->GetNz() != i) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + bool both = xx->GetNx()*xx->GetNy()*xx->GetNz()==i && yy->GetNx()*yy->GetNy()*yy->GetNz()==i && zz->GetNx()*zz->GetNy()*zz->GetNz()==i; + if(!(both || (xx->GetNx()==m && yy->GetNx()==n && zz->GetNx()==l))) + { gr->SetWarn(mglWarnDim,"Fit[S]"); return 0; } + if(!var || *var==0) + { gr->SetWarn(mglWarnNull,"Fit[S]"); return 0; } + + mglData x(aa), y(aa), z(aa), a(aa), s(ss); +#pragma omp parallel for collapse(3) + for(long i=0;inx>=fd.m) in.Set(ini->a,fd.m); + else in.Fill(0.,0); + res = mgl_fit_base(fd,in.a); + mgl_fill_fit(gr,*fit,in,fd,var,nn,nn,nn,0); + if(ini && ini->nx>=fd.m) memcpy(ini->a,in.a,fd.m*sizeof(mreal)); + + mglPrepareFitEq(gr,res, eq,var,in.a); + delete fd.eq; gr->LoadState(); return fit; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_hist_x(HMGL gr, HCDT x, HCDT a, const char *opt) +{ + long nn=a->GetNx()*a->GetNy()*a->GetNz(); + if(nn!=x->GetNx()*x->GetNy()*x->GetNz()) + { gr->SetWarn(mglWarnDim,"Hist"); return 0; } + mreal rr = gr->SaveState(opt); + long n = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + mglData *res = new mglData(n); + + const mglData *dx = dynamic_cast(x); + const mglData *da = dynamic_cast(a); + mreal vx = n/(gr->Max.x-gr->Min.x); + if(dx && da) +#pragma omp parallel for + for(long i=0;ia[i]-gr->Min.x)*vx); + if(j1>=0 && j1a[j1] += da->a[i]; + } + else +#pragma omp parallel for + for(long i=0;ivthr(i)-gr->Min.x)*vx); + if(j1>=0 && j1a[j1] += a->vthr(i); + } + gr->LoadState(); return res; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_hist_xy(HMGL gr, HCDT x, HCDT y, HCDT a, const char *opt) +{ + long nn=a->GetNx()*a->GetNy()*a->GetNz(); + if(nn!=x->GetNx()*x->GetNy()*x->GetNz() || nn!=y->GetNx()*y->GetNy()*y->GetNz()) + { gr->SetWarn(mglWarnDim,"Hist"); return 0; } + mreal rr = gr->SaveState(opt); + long n = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + mglData *res = new mglData(n, n); + const mglData *dx = dynamic_cast(x); + const mglData *dy = dynamic_cast(y); + const mglData *da = dynamic_cast(a); + mreal vx = n/(gr->Max.x-gr->Min.x); + mreal vy = n/(gr->Max.y-gr->Min.y); + if(dx && dy && da) +#pragma omp parallel for + for(long i=0;ia[i]-gr->Min.x)*vx); + register long j2 = long((dy->a[i]-gr->Min.y)*vy); + if(j1>=0 && j1=0 && j2a[j1+n*j2] += da->a[i]; + } + else +#pragma omp parallel for + for(long i=0;ivthr(i)-gr->Min.x)*vx); + register long j2 = long((y->vthr(i)-gr->Min.y)*vy); + if(j1>=0 && j1=0 && j2a[j1+n*j2] += a->vthr(i); + } + gr->LoadState(); return res; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_hist_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *opt) +{ + long nn=a->GetNx()*a->GetNy()*a->GetNz(); + if(nn!=x->GetNx()*x->GetNy()*x->GetNz() || nn!=y->GetNx()*y->GetNy()*y->GetNz() || nn!=z->GetNx()*z->GetNy()*z->GetNz()) + { gr->SetWarn(mglWarnDim,"Hist"); return 0; } + mreal rr = gr->SaveState(opt); + long n = (mgl_isnan(rr) || rr<=0) ? mglFitPnts:long(rr+0.5); + mglData *res = new mglData(n, n, n); + const mglData *dx = dynamic_cast(x); + const mglData *dy = dynamic_cast(y); + const mglData *dz = dynamic_cast(z); + const mglData *da = dynamic_cast(a); + mreal vx = n/(gr->Max.x-gr->Min.x), vy = n/(gr->Max.y-gr->Min.y), vz = n/(gr->Max.z-gr->Min.z); + if(dx && dy && dz && da) +#pragma omp parallel for + for(long i=0;ia[i]-gr->Min.x)*vx); + register long j2 = long((dy->a[i]-gr->Min.y)*vy); + register long j3 = long((dz->a[i]-gr->Min.z)*vz); + if(j1>=0 && j1=0 && j2=0 && j3a[j1+n*(j2+n*j3)] += da->a[i]; + } + else +#pragma omp parallel for + for(long i=0;iStop) continue; + register long j1 = long((x->vthr(i)-gr->Min.x)*vx); + register long j2 = long((y->vthr(i)-gr->Min.y)*vy); + register long j3 = long((z->vthr(i)-gr->Min.z)*vz); + if(j1>=0 && j1=0 && j2=0 && j3a[j1+n*(j2+n*j3)] += a->vthr(i); + } + gr->LoadState(); return gr->Stop?0:res; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_hist_x_(uintptr_t* gr, uintptr_t* x, uintptr_t* a, const char *opt, int lo) +{ char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_hist_x(_GR_, _DA_(x), _DA_(a), o); + delete []o; return r; } +uintptr_t MGL_EXPORT mgl_hist_xy_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* a, const char *opt, int lo) +{ char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_hist_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), o); + delete []o; return r; } +uintptr_t MGL_EXPORT mgl_hist_xyz_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, const char *opt, int lo) +{ char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_hist_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), o); + delete []o; return r; } +//----------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_get_fit(HMGL ) { return mglFitRes; } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_fit_1_(uintptr_t* gr, uintptr_t* y, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_1(_GR_, _DA_(y), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_2_(uintptr_t* gr, uintptr_t* z, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_2(_GR_, _DA_(z), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_3_(uintptr_t* gr, uintptr_t* a, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_3(_GR_, _DA_(a), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xy_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xy(_GR_, _DA_(x), _DA_(y), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xyz_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xyza_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xyza(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_ys_(uintptr_t* gr, uintptr_t* y, uintptr_t* ss, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_ys(_GR_, _DA_(y), _DA_(ss), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xys_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* ss, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xys(_GR_, _DA_(x), _DA_(y), _DA_(ss), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xyzs_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* ss, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xyzs(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ss), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +uintptr_t MGL_EXPORT mgl_fit_xyzas_(uintptr_t* gr, uintptr_t* x, uintptr_t* y, uintptr_t* z, uintptr_t* a, uintptr_t* ss, const char *eq, const char *var, uintptr_t *ini, const char *opt, int l, int n, int lo) +{ + char *s=new char[l+1]; memcpy(s,eq,l); s[l]=0; + char *d=new char[n+1]; memcpy(d,var,n); d[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t r = (uintptr_t)mgl_fit_xyzas(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), _DA_(ss), s, d, _DM_(ini), o); + delete []o; delete []s; delete []d; return r; +} +//----------------------------------------------------------------------------- diff --git a/src/font.cpp b/src/font.cpp new file mode 100644 index 0000000..40c12a2 --- /dev/null +++ b/src/font.cpp @@ -0,0 +1,898 @@ +/*************************************************************************** + * font.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include + +// #ifdef WIN32 +// #include +// #else +// #include +// #endif + +#include "mgl2/base.h" +#include "mgl2/font.h" +//----------------------------------------------------------------------------- +extern unsigned mgl_numg, mgl_cur; +extern float mgl_fact; +extern long mgl_gen_fnt[516][6]; +extern short mgl_buf_fnt[246080]; +extern mglTeXsymb mgl_tex_symb[]; +//mglFont mglDefFont("nofont"); +mglFont mglDefFont; +//----------------------------------------------------------------------------- +char mglGetStyle(const char *how, int *font, int *align) +{ + char col=0; + if(align) *align = 1; // centering text by default + if(!how || *how==0) return col; + // NOTE: no brightness for text color + for(;*how && *how!=':';how++) + if(strchr(MGL_COLORS,*how)) col=*how; + if(align) + { + *align = 1; + if(strchr(how,'R')) *align = 2; + if(strchr(how,'C')) *align = 1; + if(strchr(how,'L')) *align = 0; + if(strchr(how,'D')) *align+= 4; + } + if(font) + { + *font = 0; + if(strchr(how,'b')) *font = *font|MGL_FONT_BOLD; + if(strchr(how,'i')) *font = *font|MGL_FONT_ITAL; + if(strchr(how,'w')) *font = *font|MGL_FONT_WIRE; + if(strchr(how,'o')) *font = *font|MGL_FONT_OLINE; + if(strchr(how,'u')) *font = *font|MGL_FONT_ULINE; + } + return col; +} +//----------------------------------------------------------------------------- +float mglFont::Puts(const char *str,const char *how,float col) const +{ + int font=0, align=1; float w=0; + char cc=mglGetStyle(how,&font,&align); + MGL_TO_WCS(str,w = Puts(wcs,font,align,cc?-cc:col)); + return w; +} +//----------------------------------------------------------------------------- +float mglFont::Width(const char *str,const char *how) const +{ + int font=0; float w=0; + mglGetStyle(how,&font); + MGL_TO_WCS(str,w = Width(wcs,font)); + return w; +} +//----------------------------------------------------------------------------- +float mglFont::Puts(const wchar_t *str,const char *how,float col) const +{ + int font=0, align=1; + char cc=mglGetStyle(how,&font,&align); + return Puts(str, font, align,cc?-cc:col); +} +//----------------------------------------------------------------------------- +float mglFont::Width(const wchar_t *str,const char *how) const +{ + int font=0; + mglGetStyle(how,&font); + return Width(str, font); +} +//----------------------------------------------------------------------------- +float mglFont::Puts(const wchar_t *str,int font,int align, float col) const +{ + if(numg==0 || !str || *str==0) return 0; + float ww=0,w=0,h = (align&4) ? 500./fact[0] : 0; + size_t size = mgl_wcslen(str)+1,i,num=0; + if(parse) + { + unsigned *wcs = new unsigned[size], *buf=wcs; + memcpy(wcs,str,size*sizeof(wchar_t)); + Convert(str, wcs); + for(i=0;wcs[i];i++) + { + if(wcs[i]=='\n') // parse '\n' symbol + { + wcs[i]=0; w = Puts(buf,0,0,1.f,0x10|font,col); // find width + Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,col); // draw it really + buf=wcs+i+1; num++; if(w>ww) ww=w; + } + if(wcs[i]=='\\' && wcs[i+1]=='n' && (wcs[i+2]>' ' || wcschr(L"{}[]()!@#$%^&*/-?.,_=+\\\"", wcs[i+2]))) // parse '\n' symbol + { + wcs[i]=0; w = Puts(buf,0,0,1.f,0x10|font,col); // find width + Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,col); // draw it really + buf=wcs+i+2; num++; if(w>ww) ww=w; + } + } + // draw string itself + w = Puts(buf,0,0,1.f,0x10|font,col); // find width + Puts(buf,-w*(align&3)/2.f,-h - 500.*num/fact[0],1.f,font,col); // draw it really + if(w>ww) ww=w; + delete []wcs; + } + else + { + int s = (font/MGL_FONT_BOLD)&3; + long j; + h *= fact[0]/fact[s]; + for(i=0;iGlyph(w, -h, 1, s+(font&MGL_FONT_WIRE)?4:0, j, col); + } + else j = 0;//Internal('!'); + w+= width[s][j]/fact[s]; + } + } + return ww; +} +//----------------------------------------------------------------------------- +float mglFont::Width(const wchar_t *str,int font) const +{ + if(numg==0 || !str || *str==0) return 0; + float ww=0,w=0; + size_t size = mgl_wcslen(str)+1,i; + if(parse) + { + unsigned *wcs = new unsigned[size], *buf=wcs; + memcpy(wcs,str,size*sizeof(wchar_t)); + Convert(str, wcs); + for(i=0;wcs[i];i++) if(wcs[i]=='\n') // parse '\n' symbol + { + wcs[i]=0; w = Puts(buf,0,0,1.,0x10|font,'k'); // find width + buf=wcs+i+1; if(w>ww) ww=w; + } + w = Puts(buf,0,0,1.,0x10|font,'k'); + if(wid[i]) i1=i+1; // i is bad + else return i; + } + return j==id[i2] ? i2 : -1; +} +//----------------------------------------------------------------------------- +/// Table of acents and its UTF8 codes +MGL_NO_EXPORT mglTeXsymb mgl_act_symb[] = { + {0x02c6, L"hat"}, {0x02dc, L"tilde"}, {0x02d9, L"dot"}, {0x00a8, L"ddot"}, {0x20db, L"dddot"}, {0x20dc, L"ddddot"}, {0x02ca, L"acute"}, {0x02c7, L"check"}, {0x02cb, L"grave"}, {0x20d7, L"vec"}, {0x02c9, L"bar"}, {0x02d8, L"breve"}, + /*end*/{0, L"\0"}}; +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_tex_symb_cmp(const void *a, const void *b) +{ + const mglTeXsymb *aa = (const mglTeXsymb *)a; + const mglTeXsymb *bb = (const mglTeXsymb *)b; + return wcscmp(aa->tex, bb->tex); +} +//----------------------------------------------------------------------------- +// parse LaTeX commands (mostly symbols and acents, and some font-style commands) +unsigned mglFont::Parse(const wchar_t *s) const +{ + register long k; + unsigned res = unsigned(-2); // Default is no symbol + if(!s || !s[0]) return res; + for(k=0;mgl_tex_symb[k].kod;k++); // determine the number of symbols + mglTeXsymb tst, *rts; + tst.tex = s; + rts = (mglTeXsymb *) bsearch(&tst, mgl_tex_symb, k, sizeof(mglTeXsymb), mgl_tex_symb_cmp); + if(rts) return rts->kod; + +// for(k=0;mgl_tex_symb[k].kod;k++) // special symbols +// if(!wcscmp(s,mgl_tex_symb[k].tex)) +// return mgl_tex_symb[k].kod; + for(k=0;mgl_act_symb[k].kod;k++) // acents + if(!wcscmp(s,mgl_act_symb[k].tex)) + return mgl_act_symb[k].kod | MGL_FONT_ZEROW; + // arbitrary UTF symbol + if(s[0]=='u' && s[1]=='t' && s[2]=='f') +// { wscanf(s+3,"%lx",&k); return wchar_t(k); } + { k = wcstoul(s+3,NULL,16); return wchar_t(k); } + // font/style changes for next symbol + if(!wcscmp(s,L"big")) res = unsigned(-5); + else if(!wcscmp(s,L"frac")) res = unsigned(-6); + else if(!wcscmp(s,L"stack")) res = unsigned(-7); + else if(!wcscmp(s,L"overset")) res = unsigned(-8); + else if(!wcscmp(s,L"underset")) res = unsigned(-9); + else if(!wcscmp(s,L"stackr")) res = unsigned(-10); + else if(!wcscmp(s,L"stackl")) res = unsigned(-11); + else if(!wcscmp(s,L"sub")) res = unsigned(-12); + else if(!wcscmp(s,L"sup")) res = unsigned(-13); + else if(!wcscmp(s,L"textsc")) res = unsigned(-14); // new + else if(!wcscmp(s,L"b")) res = MGL_FONT_BOLD; + else if(!wcscmp(s,L"i")) res = MGL_FONT_ITAL; + else if(!wcscmp(s,L"bi")) res = MGL_FONT_BOLD|MGL_FONT_ITAL; + else if(!wcscmp(s,L"r")) res = unsigned(-1); + else if(!wcscmp(s,L"a")) res = MGL_FONT_OLINE; + else if(!wcscmp(s,L"u")) res = MGL_FONT_ULINE; + else if(!wcscmp(s,L"n")) res = '\n'; + else if(!wcscmp(s,L"overline")) res = MGL_FONT_OLINE; + else if(!wcscmp(s,L"underline"))res = MGL_FONT_ULINE; + else if(!wcscmp(s,L"textbf")) res = MGL_FONT_BOLD; + else if(!wcscmp(s,L"textit")) res = MGL_FONT_ITAL; + else if(!wcscmp(s,L"textrm")) res = unsigned(-1); + else if(!wcscmp(s,L"w")) res = MGL_FONT_WIRE; + else if(!wcscmp(s,L"wire")) res = MGL_FONT_WIRE; + else if(!wcsncmp(s,L"color",5)) res = MGL_COLOR_MASK + (0xff & s[5]); + return res; +} +//----------------------------------------------------------------------------- +void mglFont::Convert(const wchar_t *str, unsigned *res) const +{ + register size_t r,i,j,k,i0; + wchar_t s[128]=L"", ch; // TeX command and current char + for(i=j=0;str[i];i++) + { + ch = str[i]; + if(ch=='\\') // It can be TeX command + { + if(wcschr(L"{}_^\\@# ",str[i+1])) // No, it is usual symbol + res[j++] = str[++i]; + else // Yes, it is TeX command + { + i0=i+1; + for(k=0;isalnum(str[++i]) && k<127;k++) s[k] = str[i]; + s[k] = 0; + r = Parse(s); + if(r==unsigned(-2)) // command not found, so use next symbol itself + { res[j++] = str[i0]; i = i0; } + else if(r) + { + res[j++] = r; + if(str[i]>' ') i--; + if(str[i]==0) break; + } + } + } + else if(ch<=' ' && ch!='\n') res[j++] = ' '; // no \t at this moment :( + else if(ch=='_') res[j++] = MGL_FONT_LOWER; + else if(ch=='^') res[j++] = MGL_FONT_UPPER; + else if(ch=='@') res[j++] = MGL_FONT_UPPER|MGL_FONT_LOWER; + else if(ch=='{') res[j++] = unsigned(-3); + else if(ch=='}') res[j++] = unsigned(-4); + else if(ch=='#' && str[i+1]>' ') + res[j++] = MGL_COLOR_MASK + (0xff & str[++i]); + else res[j++] = ch; // It is just symbol + } + res[j] = 0; +} +//----------------------------------------------------------------------------- +float mglFont::get_ptr(long &i,unsigned *str, unsigned **b1, unsigned **b2,float &w1,float &w2, float f1, float f2, int st) const +{ + static unsigned s1[2]={0,0}, s2[2]={0,0}; + register long k; + i++; + if(str[i]==unsigned(-3)) + { + i++; *b1 = str+i; + for(k=1;k>0 && str[i];i++) + { + if(str[i]==unsigned(-4)) k--; + if(str[i]==unsigned(-3)) k++; + } + str[i-1]=0; + } + else { s1[0] = str[i]; *b1 = s1; i++; } + if(str[i]==unsigned(-3)) + { + i++; *b2 = str+i; + for(k=1;k>0 && str[i];i++) + { + if(str[i]==unsigned(-4)) k--; + if(str[i]==unsigned(-3)) k++; + } + str[i-1]=0; + } + else { s2[0] = str[i]; *b2 = s2; i++; } + i--; + w1 = Puts(*b1, 0, 0, f1, 0x10|st,'k'); + w2 = Puts(*b2, 0, 0, f2, 0x10|st,'k'); + return w1>w2 ? w1 : w2; +} +//----------------------------------------------------------------------------- +void mglFont::draw_ouline(int st, float x, float y, float f, float g, float ww, float ccol) const +{ + if(st&MGL_FONT_OLINE) + gr->Glyph(x,y+499*f/g, ww*g, (st&MGL_FONT_WIRE)?12:8, 0, ccol); + if(st&MGL_FONT_ULINE) + gr->Glyph(x,y-200*f/g, ww*g, (st&MGL_FONT_WIRE)?12:8, 0, ccol); +} +//----------------------------------------------------------------------------- +#define MGL_CLEAR_STYLE {st = style; yy = y; ff = f; ccol=col; a = (st/MGL_FONT_BOLD)&3;} +float mglFont::Puts(const unsigned *text, float x,float y,float f,int style,float col) const +{ + if(numg==0) return 0; + register long j,k; + long i; + register unsigned s,ss; + float w=0; // string width + int st = style; // current style + unsigned *b1, *b2; // pointer to substring + unsigned *str; // string itself + float yy=y, ff=f, ww, w1, w2; + float ccol=col; + int a = (st/MGL_FONT_BOLD)&3; + for(i=0;text[i];i++); + str = new unsigned[i+1]; + memcpy(str,text,(i+1)*sizeof(unsigned)); + + for(i=0;str[i];i++) + { + s = str[i]; ww = 0; + if(s==unsigned(-3)) // recursion call here + { + i++; b1 = str+i; + for(k=1;k>0 && str[i];i++) + { + if(str[i]==unsigned(-4)) k--; + if(str[i]==unsigned(-3)) k++; + } + str[i-1]=0; i--; + ww = Puts(b1, x, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s=='\n') // newline + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff, ff, st); + Puts(b1, x+(ww-w1)/2, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy-600*ff/fact[a], ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-9)) // underset + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff, ff/4, st); + Puts(b1, x+(ww-w1)/2, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy-150*ff/fact[a], ff/4, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-8)) // overset + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff, ff/4, st); + Puts(b1, x+(ww-w1)/2, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy+375*ff/fact[a], ff/4, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-12)) // sub + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff, ff/4, st); + Puts(b1, x+(ww-w1)/2, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy-250*ff/fact[a], ff/4, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-13)) // sup + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff, ff/4, st); + Puts(b1, x+(ww-w1)/2, yy, ff, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy+450*ff/fact[a], ff/4, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-11)) // stackl + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff*0.45, ff*0.45, st); + Puts(b1, x, yy+250*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x, yy-110*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-10)) // stacr + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff*0.45, ff*0.45, st); + Puts(b1, x+(ww-w1), yy+250*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2), yy-110*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-7)) // stack + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff*0.45, ff*0.45, st); + Puts(b1, x+(ww-w1)/2, yy+250*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy-110*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + MGL_CLEAR_STYLE + } + else if(s==unsigned(-6)) // frac + { + ww = get_ptr(i, str, &b1, &b2, w1, w2, ff*0.45, ff*0.45, st); + Puts(b1, x+(ww-w1)/2, yy+250*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + Puts(b2, x+(ww-w2)/2, yy-110*ff/fact[a], ff*0.45, (st&(~MGL_FONT_OLINE)&(~MGL_FONT_ULINE)), ccol); + if(gr && !(style&0x10)) // add under-/over- line now + { + draw_ouline(st,x,y,f,fact[a],ww,ccol); + gr->Glyph(x,y+150*f/fact[a], ww*fact[a], (st&MGL_FONT_WIRE)?12:8, 0, ccol); + } + MGL_CLEAR_STYLE + } + else if(s==unsigned(-4)) MGL_CLEAR_STYLE // should be never here but if I miss sth ... + else if(s==unsigned(-14)) // script symbols + { + k=1; + if(str[i+1]==unsigned(-3)) for(j=i+2;k>0 && str[j];j++) + { + if(str[j]==unsigned(-3)) k++; + if(str[j]==unsigned(-4)) k--; + if(iswlower(str[j])) + str[j] = MGL_FONT_UPPER|MGL_FONT_LOWER|towupper(str[j]); + } + } + else if(s==unsigned(-5)) // large symbol + ff *= 1.5; + else if(s==unsigned(-1)) // set normal font + st = style & MGL_FONT_ROMAN; + else if((s&MGL_COLOR_MASK)==MGL_COLOR_MASK) // color specification + ccol = -float(s & 0xff); + else + { + ss = s&MGL_FONT_MASK; + if(ss) // draw symbol (glyph) + { + if(ss>' ') + { + j = Internal(ss); + if(j==-1) continue; + if(s & MGL_FONT_ZEROW) yy += 100*ff/fact[a]; + if(gr && !(style&0x10)) + { + if(st & MGL_FONT_WIRE) gr->Glyph(x,yy,ff,a+4,j,ccol); + else gr->Glyph(x,yy,ff,a,j,ccol); + } + } + else j = Internal('!'); + ww = ff*width[a][j]/fact[a]; + if(gr && !(style&0x10)) // add under-/over- line now + draw_ouline(st,x,y,f,fact[a],ww,ccol); + if(s & MGL_FONT_ZEROW) ww = 0; + MGL_CLEAR_STYLE + } + // apply new styles + if(s/MGL_FONT_BOLD) st = st | (s & MGL_FONT_STYLE); + a = (st/MGL_FONT_BOLD)&3; + ss = (s/MGL_FONT_UPPER)%4; + if(ss) + { + if(ss==1) { ff *=0.6; yy += 200*ff/fact[a]; } // = 500*0.4 + else if(ss==2) { ff *=0.6; yy -= 80*ff/fact[a]; } // = -500*0.16 + else if(ss==3) { ff *=0.8; yy += 0*60*ff/fact[a]; } // = 500*0.12 + } + } + x += ww; w += ww; + } + delete []str; + return w; +} +//----------------------------------------------------------------------------- +void mglFont::mem_alloc() +{ + id = new wchar_t[numg]; + width[0] = new short[numg]; width[1] = new short[numg]; + width[2] = new short[numg]; width[3] = new short[numg]; + tr[0] = new int[numg]; numt[0] = new short[numg]; + tr[1] = new int[numg]; numt[1] = new short[numg]; + tr[2] = new int[numg]; numt[2] = new short[numg]; + tr[3] = new int[numg]; numt[3] = new short[numg]; + ln[0] = new int[numg]; numl[0] = new short[numg]; + ln[1] = new int[numg]; numl[1] = new short[numg]; + ln[2] = new int[numg]; numl[2] = new short[numg]; + ln[3] = new int[numg]; numl[3] = new short[numg]; +} +//----------------------------------------------------------------------------- +// copy normal style as default for other styles +void mglFont::main_copy() +{ +#pragma omp parallel sections + { +#pragma omp section + memcpy(numl[1],numl[0],numg*sizeof(short)); +#pragma omp section + memcpy(numl[2],numl[0],numg*sizeof(short)); +#pragma omp section + memcpy(numl[3],numl[0],numg*sizeof(short)); +#pragma omp section + memcpy(ln[1],ln[0],numg*sizeof(int)); +#pragma omp section + memcpy(ln[2],ln[0],numg*sizeof(int)); +#pragma omp section + memcpy(ln[3],ln[0],numg*sizeof(int)); +#pragma omp section + memcpy(numt[1],numt[0],numg*sizeof(short)); +#pragma omp section + memcpy(numt[2],numt[0],numg*sizeof(short)); +#pragma omp section + memcpy(numt[3],numt[0],numg*sizeof(short)); +#pragma omp section + memcpy(tr[1],tr[0],numg*sizeof(int)); +#pragma omp section + memcpy(tr[2],tr[0],numg*sizeof(int)); +#pragma omp section + memcpy(tr[3],tr[0],numg*sizeof(int)); +#pragma omp section + memcpy(width[1],width[0],numg*sizeof(short)); +#pragma omp section + memcpy(width[2],width[0],numg*sizeof(short)); +#pragma omp section + memcpy(width[3],width[0],numg*sizeof(short)); + } +} +//----------------------------------------------------------------------------- +bool mglFont::read_def() +{ + numg = mgl_numg; + // copy default factor for other font styles; + fact[1] = fact[2] = fact[3] = fact[0] = mgl_fact*mgl_fgen; + Buf = new short[mgl_cur]; // prealocate buffer + memset(Buf,0,mgl_cur*sizeof(short)); + // now allocate memory for all fonts + mem_alloc(); + // and load symbols itself +#ifndef WIN32 // win32 don't initialized threads before main() +#pragma omp parallel for +#endif + for(long i=0;i &buf) // TODO add buffer for input file?! +{ + gzFile fp; + char str[256]; + int n, tmpw, tmpnl, tmpnt, retVal; + unsigned s, tmpi, tmppl, tmppt; + fp = gzopen(fname,"r"); if(!fp) return false; // false if no file + // first string is comment (not used), second string have information + if(!gzgets(fp,str,256) || strncmp(str,"# font",6) || !gzgets(fp,str,256)) + { gzclose(fp); return false; } + retVal = sscanf(str, "%d%f%u", &n, ff, &s); + //Check sscanf read all data (3 items) + if(retVal != 3) { gzclose(fp); return false; } + + for(int i=0;i &buf) // TODO add buffer for input file?! +{ + gzFile fp; + int tmpi, tmpw, tmpnl, tmpnt; + unsigned s, tmppl, tmppt; + char str[256]; + + fp = gzopen(fname,"r"); if(!fp) return false; // this font must be in any case + // first string is comment (not used), second string have information + if(!gzgets(fp,str,256) || strncmp(str,"# font",6) || !gzgets(fp,str,256)) + { gzclose(fp); return false; } + sscanf(str, "%u%f%u", &numg, fact, &s); + fact[1] = fact[2] = fact[3] = fact[0]; // copy default factor for other font styles; + // now allocate memory for all fonts + mem_alloc(); + // and load symbols itself + for(size_t i=0;i=0 && buf[i]!=sep;i--); + path = buf; buf[i]=0; base = buf+i+1; + } + } + Clear(); // first clear old + + snprintf(str,256,"%s%c%s.vfm",path,sep,base?base:""); + std::vector norm, bold, ital, both; + if(!(base && *base) || !read_main(str,norm)) + { +// mglGlobalMess += "Load built-in font.\n"; + read_def(); setlocale(LC_NUMERIC,oldLocale); + if(buf) delete []buf; return true; + } + fact[1] = fact[2] = fact[3] = fact[0]; + +#pragma omp parallel sections + { + //================== bold =========================================== +#pragma omp section + { char str[256]; snprintf(str,256,"%s%c%s_b.vfm",path,sep,base); // this file may absent + read_data(str, fact+1, width[1], numl[1], ln[1], numt[1], tr[1], bold); } + + //================== italic ========================================= +#pragma omp section + { char str[256]; snprintf(str,256,"%s%c%s_i.vfm",path,sep,base); + read_data(str, fact+2, width[2], numl[2], ln[2], numt[2], tr[2], ital); } + + //================== bold-italic ==================================== +#pragma omp section + { char str[256]; snprintf(str,256,"%s%c%s_bi.vfm",path,sep,base); + read_data(str, fact+3, width[3], numl[3], ln[3], numt[3], tr[3], both); } + } + + // now collect data + numb = norm.size()+bold.size()+ital.size()+both.size(); + Buf = new short[numb]; +#pragma omp parallel for + for(long i=0;i0) +#pragma omp parallel for + for(long i=0;i0) +#pragma omp parallel for + for(long i=0;i0) +#pragma omp parallel for + for(long i=0;iClf(); + if(numg) + { + delete []id; delete []Buf; numg = 0; + delete [](width[0]); delete [](width[1]); delete [](width[2]); delete [](width[3]); + delete [](tr[0]); delete [](tr[1]); delete [](tr[2]); delete [](tr[3]); + delete [](ln[0]); delete [](ln[1]); delete [](ln[2]); delete [](ln[3]); + delete [](numt[0]); delete [](numt[1]); delete [](numt[2]); delete [](numt[3]); + delete [](numl[0]); delete [](numl[1]); delete [](numl[2]); delete [](numl[3]); + } +} +//----------------------------------------------------------------------------- +void mglFont::Copy(mglFont *f) +{ + if(!f || f==this) return; + Clear(); + numg = f->numg; numb = f->numb; + mem_alloc(); + // copy general data +#pragma omp parallel sections + { +#pragma omp section + memcpy(id,f->id,numg*sizeof(wchar_t)); +#pragma omp section + memcpy(width[0],f->width[0],numg*sizeof(short)); +#pragma omp section + memcpy(width[1],f->width[1],numg*sizeof(short)); +#pragma omp section + memcpy(width[2],f->width[2],numg*sizeof(short)); +#pragma omp section + memcpy(width[3],f->width[3],numg*sizeof(short)); +#pragma omp section + memcpy(tr[0],f->tr[0],numg*sizeof(unsigned)); +#pragma omp section + memcpy(tr[1],f->tr[1],numg*sizeof(unsigned)); +#pragma omp section + memcpy(tr[2],f->tr[2],numg*sizeof(unsigned)); +#pragma omp section + memcpy(tr[3],f->tr[3],numg*sizeof(unsigned)); +#pragma omp section + memcpy(numt[0],f->numt[0],numg*sizeof(short)); +#pragma omp section + memcpy(numt[1],f->numt[1],numg*sizeof(short)); +#pragma omp section + memcpy(numt[2],f->numt[2],numg*sizeof(short)); +#pragma omp section + memcpy(numt[3],f->numt[3],numg*sizeof(short)); +#pragma omp section + memcpy(ln[0],f->ln[0],numg*sizeof(unsigned)); +#pragma omp section + memcpy(ln[1],f->ln[1],numg*sizeof(unsigned)); +#pragma omp section + memcpy(ln[2],f->ln[2],numg*sizeof(unsigned)); +#pragma omp section + memcpy(ln[3],f->ln[3],numg*sizeof(unsigned)); +#pragma omp section + memcpy(numl[0],f->numl[0],numg*sizeof(short)); +#pragma omp section + memcpy(numl[1],f->numl[1],numg*sizeof(short)); +#pragma omp section + memcpy(numl[2],f->numl[2],numg*sizeof(short)); +#pragma omp section + memcpy(numl[3],f->numl[3],numg*sizeof(short)); +#pragma omp section + memcpy(fact,f->fact,4*sizeof(float)); + } + // now copy symbols descriptions + Buf = new short[numb]; memcpy(Buf, f->Buf, numb*sizeof(short)); +} +//----------------------------------------------------------------------------- diff --git a/src/interp.hpp b/src/interp.hpp new file mode 100644 index 0000000..daab03f --- /dev/null +++ b/src/interp.hpp @@ -0,0 +1,384 @@ +//----------------------------------------------------------------------------- +template void mglFillP(long x,long y, const Treal *a,long nx,long ny,Treal _p[4][4]) +{ + Treal sx[4]={0,0,0,0},sy[4]={0,0,0,0},f[4]={0,0,0,0},d[4]={0,0,0,0}; + if(x<0 || y<0 || x>nx-2 || y>ny-2) + { + memset(_p[0],0,4*sizeof(Treal)); + memset(_p[1],0,4*sizeof(Treal)); + memset(_p[2],0,4*sizeof(Treal)); + memset(_p[3],0,4*sizeof(Treal)); + return; + } + // �������� ������� + f[0]=a[x+nx*y]; f[1]=a[x+nx*(y+1)]; + if(nx>1) { f[2]=a[x+1+nx*y]; f[3]=a[x+1+nx*(y+1)]; } + else { f[2] = f[0]; f[3] = f[1]; } + // ����������� �� x + if(nx>1) + { + if(x==0) + { + sx[0]=a[x+1+y*nx]-a[x+nx*y]; + sx[1]=a[x+1+nx*(y+1)]-a[x+nx*(y+1)]; + } + else + { + sx[0]=(a[x+1+nx*y]-a[x-1+nx*y])/mreal(2); + sx[1]=(a[x+1+nx*(y+1)]-a[x-1+nx*(y+1)])/mreal(2); + } + } + if(x==nx-2) + { + sx[2]=a[x+1+nx*y]-a[x+nx*y]; + sx[3]=a[x+1+nx*(y+1)]-a[x+nx*(y+1)]; + } + else + { + sx[2]=(a[x+2+nx*y]-a[x+nx*y])/mreal(2); + sx[3]=(a[x+2+nx*(y+1)]-a[x+nx*(y+1)])/mreal(2); + } + // ����������� �� y + if(y==0) + { + sy[0]=a[x+nx*(y+1)]-a[x+nx*y]; + sy[2]=a[x+1+nx*(y+1)]-a[x+1+nx*y]; + } + else + { + sy[0]=(a[x+nx*(y+1)]-a[x+nx*(y-1)])/mreal(2); + sy[2]=(a[x+1+nx*(y+1)]-a[x+1+nx*(y-1)])/mreal(2); + } + if(y==ny-2) + { + sy[1]=a[x+nx*(y+1)]-a[x+nx*y]; + sy[3]=a[x+1+nx*(y+1)]-a[x+1+nx*y]; + } + else + { + sy[1]=(a[x+nx*(y+2)]-a[x+nx*y])/mreal(2); + sy[3]=(a[x+1+nx*(y+2)]-a[x+1+nx*y])/mreal(2); + } + // ������������ ����������� + if(nx>1) + { + // ������ d[0] + if(y==0 && x==0) + d[0]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*y]+a[x+nx*y]); + else if(y==0) + d[0]=(a[x+1+nx*(y+1)]-a[x-1+nx*(y+1)]-a[x+1+nx*y]+a[x-1+nx*y])/mreal(2); + else if(x==0) + d[0]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*(y-1)]+a[x+nx*(y-1)])/mreal(2); + else + d[0]=(a[x+1+nx*(y+1)]-a[x-1+nx*(y+1)]-a[x+1+nx*(y-1)]+a[x-1+nx*(y-1)])/mreal(4); + // ������ d[1] + if(y==ny-2 && x==0) + d[1]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*y]+a[x+nx*y]); + else if(y==ny-2) + d[1]=(a[x+1+nx*(y+1)]-a[x-1+nx*(y+1)]-a[x+1+nx*y]+a[x-1+nx*y])/mreal(2); + else if(x==0) + d[1]=(a[x+1+nx*(y+2)]-a[x+nx*(y+2)]-a[x+1+nx*y]+a[x+nx*y])/mreal(2); + else + d[1]=(a[x+1+nx*(y+2)]-a[x-1+nx*(y+2)]-a[x+1+nx*y]+a[x-1+nx*y])/mreal(4); + // ������ d[2] + if(y==0 && x==nx-2) + d[2]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*y]+a[x+nx*y]); + else if(y==0) + d[2]=(a[x+2+nx*(y+1)]-a[x+nx*(y+1)]-a[x+2+nx*y]+a[x+nx*y])/mreal(2); + else if(x==nx-2) + d[2]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*(y-1)]+a[x+nx*(y-1)])/mreal(2); + else + d[2]=(a[x+2+nx*(y+1)]-a[x+nx*(y+1)]-a[x+2+nx*(y-1)]+a[x+nx*(y-1)])/mreal(4); + // ������ d[3] + if(y==ny-2 && x==nx-2) + d[3]=(a[x+1+nx*(y+1)]-a[x+nx*(y+1)]-a[x+1+nx*y]+a[x+nx*y]); + else if(y==ny-2) + d[3]=(a[x+2+nx*(y+1)]-a[x+nx*(y+1)]-a[x+2+nx*y]+a[x+nx*y])/mreal(2); + else if(x==nx-2) + d[3]=(a[x+1+nx*(y+2)]-a[x+nx*(y+2)]-a[x+1+nx*y]+a[x+nx*y])/mreal(2); + else + d[3]=(a[x+2+nx*(y+2)]-a[x+nx*(y+2)]-a[x+2+nx*y]+a[x+nx*y])/mreal(4); + } + // ��������� ������������ �������� + _p[0][0]=f[0]; _p[1][0]=sx[0]; + _p[2][0]=mreal(3)*(f[2]-f[0])-mreal(2)*sx[0]-sx[2]; + _p[3][0]=sx[0]+sx[2]+mreal(2)*(f[0]-f[2]); + _p[0][1]=sy[0]; _p[1][1]=d[0]; + _p[2][1]=mreal(3)*(sy[2]-sy[0])-mreal(2)*d[0]-d[2]; + _p[3][1]=d[0]+d[2]+mreal(2)*(sy[0]-sy[2]); + _p[0][2]=mreal(3)*(f[1]-f[0])-mreal(2)*sy[0]-sy[1]; + _p[1][2]=mreal(3)*(sx[1]-sx[0])-mreal(2)*d[0]-d[1]; + _p[2][2]=mreal(9)*(f[0]-f[1]-f[2]+f[3])+mreal(6)*(sy[0]-sy[2]+sx[0]-sx[1])+ + mreal(3)*(sx[2]-sx[3]+sy[1]-sy[3])+mreal(2)*(d[1]+d[2])+mreal(4)*d[0]+d[3]; + _p[3][2]=mreal(6)*(f[1]+f[2]-f[0]-f[3])+mreal(3)*(sx[1]-sx[0]+sx[3]-sx[2])+ + mreal(4)*(sy[2]-sy[0])+mreal(2)*(sy[3]-sy[1]-d[0]-d[2])-d[1]-d[3]; + _p[0][3]=mreal(2)*(f[0]-f[1])+sy[0]+sy[1]; + _p[1][3]=mreal(2)*(sx[0]-sx[1])+d[0]+d[1]; + _p[2][3]=mreal(6)*(f[1]+f[2]-f[0]-f[3])+mreal(3)*(sy[2]-sy[1]+sy[3]-sy[0])+ + mreal(4)*(sx[1]-sx[0])+mreal(2)*(sx[3]-sx[2]-d[0]-d[1])-d[2]-d[3]; + _p[3][3]=d[0]+d[1]+d[2]+d[3]+mreal(4)*(f[0]-f[1]-f[2]+f[3])+ + mreal(2)*(sx[0]-sx[1]+sx[2]-sx[3]+sy[0]-sy[2]+sy[1]-sy[3]); +} +//----------------------------------------------------------------------------- +template void mglFillP(long x, const Treal *a,long nx,Treal _p[4]) +{ + if(x<0 || x>nx-2) + { + memset(_p,0,4*sizeof(Treal)); + return; + } + Treal s[2],f[2]; + // �������� ������� + f[0]=a[x]; f[1]=a[x+1]; + // ����������� �� x + if(x==0) s[0]=a[x+1]-a[x]; + else s[0]=(a[x+1]-a[x-1])/mreal(2); + if(x==nx-2) s[1]=a[x+1]-a[x]; + else s[1]=(a[x+2]-a[x])/mreal(2); + // ��������� ������������ �������� + _p[0]=f[0]; _p[1]=s[0]; + _p[2]=mreal(3)*(f[1]-f[0])-mreal(2)*s[0]-s[1]; + _p[3]=s[0]+s[1]+mreal(2)*(f[0]-f[1]); +} +//----------------------------------------------------------------------------- +template Treal mglLineart(const Treal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z) +{ + if(!a || nx<1 || ny<1 || nz<1) return 0; + register long i0; + long kx,ky,kz; + Treal b=0,dx,dy,dz,b1,b0; + if(x<0 || y<0 || z<0 || x>nx-1 || y>ny-1 || z>nz-1) + return 0; + if(nz>1 && z!=floor(z)) // 3d interpolation + { + kx=long(x); ky=long(y); kz=long(z); + dx = x-mreal(kx); dy = y-mreal(ky); dz = z-mreal(kz); + + i0 = kx+nx*(ky+ny*kz); + b0 = a[i0]*(mreal(1)-dx-dy+dx*dy) + dx*(mreal(1)-dy)*a[i0+1] + + dy*(mreal(1)-dx)*a[i0+nx] + dx*dy*a[i0+nx+1]; + i0 = kx+nx*(ky+ny*(kz+1)); + b1 = a[i0]*(mreal(1)-dx-dy+dx*dy) + dx*(mreal(1)-dy)*a[i0+1] + + dy*(mreal(1)-dx)*a[i0+nx] + dx*dy*a[i0+nx+1]; + b = b0 + dz*(b1-b0); + } + else if(ny>1 && y!=floor(y)) // 2d interpolation + { + kx=long(x); ky=long(y); + dx = x-kx; dy=y-ky; + i0 = kx+nx*ky; + b = a[i0]*(mreal(1)-dx-dy+dx*dy) + dx*(mreal(1)-dy)*a[i0+1] + + dy*(mreal(1)-dx)*a[i0+nx] + dx*dy*a[i0+nx+1]; + } + else if(nx>1 && x!=floor(x)) // 1d interpolation + { + kx = long(x); + b = a[kx] + (x-kx)*(a[kx+1]-a[kx]); + } + else // no interpolation + b = a[long(x+nx*(y+ny*z))]; + return b; +} +//----------------------------------------------------------------------------- +template Treal mglSpline3t(const Treal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z, Treal *dx=0, Treal *dy=0, Treal *dz=0) +{ + if(!a || nx<1 || ny<1 || nz<1) return 0; + Treal _p[4][4]; + register long i,j; + Treal fx=1, fy=1; + long kx=long(x),ky=long(y),kz=long(z); + Treal b=0; + x = x>0 ?(x0 ?(y0 ?(znx-1 || y>ny-1 || z>nz-1) return 0; + if(dx) *dx=0; if(dy) *dy=0; if(dz) *dz=0; + if(kx>nx-2) kx = nx-2; if(kx<0) kx = 0; + if(ky>ny-2) ky = ny-2; if(ky<0) ky = 0; + if(kz>nz-2) kz = nz-2; if(kz<0) kz = 0; +// if(nz>1 && z!=kz) // 3d interpolation + if(nz>1) // 3d interpolation + { + Treal b1[4]={0,0,0,0}, x1[4]={0,0,0,0}, y1[4]={0,0,0,0}; + long kk=1; + if(kz==0) { kk=0; } + else if(nz>3 && kz==nz-2) { kk=2; } + for(long k=0;k<4;k++) + { + if(kz+k-kk=0) + mglFillP(kx, ky, a+(kz+k-kk)*nx*ny, nx, ny, _p); + else + { + memset(_p[0],0,4*sizeof(Treal)); + memset(_p[1],0,4*sizeof(Treal)); + memset(_p[2],0,4*sizeof(Treal)); + memset(_p[3],0,4*sizeof(Treal)); + } + for(i=0,fx=1;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { b1[k] += fy*fx*_p[i][j]; fy *= y-ky; } + for(j=1,fy=1;j<4;j++) + { y1[k] += mreal(j)*fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + for(i=1,fx=1;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { x1[k] += mreal(i)*fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + } + mglFillP(kk, b1, nz>3 ? 4:3, _p[0]); + mglFillP(kk, x1, nz>3 ? 4:3, _p[1]); + mglFillP(kk, y1, nz>3 ? 4:3, _p[2]); + for(i=0,fx=1,b=0;i<4;i++) + { + b += fx*_p[0][i]; + if(dx) *dx += fx*_p[1][i]; + if(dy) *dy += fx*_p[2][i]; + fx *= z-kz; + } + if(dz) for(i=1,fx=1;i<4;i++) + { *dz += mreal(i)*fx*_p[0][i]; fx *= z-kz; } + } +// else if(ny>1 && y!=ky) // 2d interpolation + else if(ny>1) // 2d interpolation + { + mglFillP(kx, ky, a+kz*nx*ny, nx, ny, _p); + for(i=0,fx=1,b=0;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { b += fy*fx*_p[i][j]; fy *= y-ky; } + if(dy) for(j=1,fy=1;j<4;j++) + { *dy+= mreal(j)*fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + if(dx) for(i=1,fx=1;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { *dx+= mreal(i)*fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + } +// else if(nx>1 && x!=kx) // 1d interpolation + else if(nx>1) // 1d interpolation + { + mglFillP(kx, a+(ky+ny*kz)*nx, nx, _p[0]); + for(i=0,fx=1,b=0;i<4;i++) + { b += fx*_p[0][i]; fx *= x-kx; } + if(dx) for(i=1,fx=1;i<4;i++) + { *dx+= mreal(i)*fx*_p[0][i]; fx *= x-kx; } + } + else // no interpolation + b = a[kx+nx*(ky+ny*kz)]; + return b; +} +//----------------------------------------------------------------------------- +template Treal mglSpline3st(const Treal *a, long nx, long ny, long nz, mreal x, mreal y, mreal z) +{ + if(!a || nx<1 || ny<1 || nz<1) return 0; + Treal _p[4][4]; + register long i,j; + Treal fx=1, fy=1; + long kx=long(x),ky=long(y),kz=long(z); + Treal b=0; + x = x>0 ?(x0 ?(y0 ?(znx-1 || y>ny-1 || z>nz-1) return 0; + if(kx>nx-2) kx = nx-2; if(kx<0) kx = 0; + if(ky>ny-2) ky = ny-2; if(ky<0) ky = 0; + if(kz>nz-2) kz = nz-2; if(kz<0) kz = 0; +// if(nz>1 && z!=kz) // 3d interpolation + if(nz>1) // 3d interpolation + { + Treal b1[4]={0,0,0,0}, x1[4]={0,0,0,0}, y1[4]={0,0,0,0}; + long kk=1; + if(kz==0) { kk=0; } + else if(nz>3 && kz==nz-2) { kk=2; } + for(long k=0;k<4;k++) + { + if(kz+k-kk=0) + mglFillP(kx, ky, a+(kz+k-kk)*nx*ny, nx, ny, _p); + else + { + memset(_p[0],0,4*sizeof(Treal)); + memset(_p[1],0,4*sizeof(Treal)); + memset(_p[2],0,4*sizeof(Treal)); + memset(_p[3],0,4*sizeof(Treal)); + } + for(i=0,fx=1;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { b1[k] += fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + } + mglFillP(kk, b1, nz>3 ? 4:3, _p[0]); + mglFillP(kk, x1, nz>3 ? 4:3, _p[1]); + mglFillP(kk, y1, nz>3 ? 4:3, _p[2]); + for(i=0,fx=1,b=0;i<4;i++) + { + b += fx*_p[0][i]; + fx *= z-kz; + } + } +// else if(ny>1 && y!=ky) // 2d interpolation + else if(ny>1) // 2d interpolation + { + mglFillP(kx, ky, a+kz*nx*ny, nx, ny, _p); + for(i=0,fx=1,b=0;i<4;i++) + { + for(j=0,fy=1;j<4;j++) + { b += fy*fx*_p[i][j]; fy *= y-ky; } + fx *= x-kx; + } + } +// else if(nx>1 && x!=kx) // 1d interpolation + else if(nx>1) // 1d interpolation + { + mglFillP(kx, a+(ky+ny*kz)*nx, nx, _p[0]); + for(i=0,fx=1,b=0;i<4;i++) + { b += fx*_p[0][i]; fx *= x-kx; } + } + else // no interpolation + b = a[kx+nx*(ky+ny*kz)]; + return b; +} +//----------------------------------------------------------------------------- +template Treal mglSpline1t(const Treal *a, long nx, mreal x, Treal *dx=0) +{ + Treal _p[4]; + long kx=long(x); + Treal b=0; + x = x>0 ?(xnx-2) kx = nx-2; if(kx<0) kx = 0; + if(nx>1) // 1d interpolation + { + mglFillP(kx, a, nx, _p); + b = _p[0]+(x-kx)*(_p[1]+(x-kx)*(_p[2]+(x-kx)*_p[3])); + if(dx) *dx = _p[1]+(x-kx)*(mreal(2)*_p[2]+mreal(3)*(x-kx)*_p[3]); + } + else // no interpolation + { b = a[0]; if(dx) *dx=0; } + return b; +} +//----------------------------------------------------------------------------- +template Treal mglSpline1st(const Treal *a, long nx, mreal x) +{ + Treal _p[4]; + long kx=long(x); + Treal b=0; + x = x>0 ?(xnx-2) kx = nx-2; if(kx<0) kx = 0; + if(nx>1) // 1d interpolation + { + mglFillP(kx, a, nx, _p); + b = _p[0]+(x-kx)*(_p[1]+(x-kx)*(_p[2]+(x-kx)*_p[3])); + } + else // no interpolation + b = a[0]; + return b; +} +//----------------------------------------------------------------------------- diff --git a/src/mpi.cpp b/src/mpi.cpp new file mode 100644 index 0000000..47ff410 --- /dev/null +++ b/src/mpi.cpp @@ -0,0 +1,50 @@ +#include "mgl2/mpi.h" +#include "mgl2/canvas.h" +#include +#define MCW MPI_COMM_WORLD +#define TAG_DATA_Z 0 +#define TAG_DATA_C 1 +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mpi_send(HMGL gr, int id) +{ + mglCanvas *g = dynamic_cast(gr); if(!g) return; + g->Finish(); + long n = g->GetWidth()*g->GetHeight(); + MPI_Send(g->Z,3*n,MPI_FLOAT,id,TAG_DATA_Z,MCW); + MPI_Send(g->C,12*n,MPI_CHAR,id,TAG_DATA_C,MCW); + MPI_Send(g->OI,n,MPI_INT,id,TAG_DATA_C,MCW); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mpi_recv(HMGL gr, int id) +{ + mglCanvas *g = dynamic_cast(gr); if(!g) return; + g->Finish(); + MPI_Status status; + long w = g->GetWidth(), h = g->GetHeight(), n = w*h; + float *zz = new float[3*n]; + int *oi = new int[n]; + unsigned char *cc = new unsigned char[12*n]; + MPI_Recv(zz,3*n,MPI_FLOAT,id,TAG_DATA_Z,MCW,&status); + MPI_Recv(cc,12*n,MPI_CHAR,id,TAG_DATA_C,MCW,&status); + MPI_Recv(oi,n,MPI_INT,id,TAG_DATA_C,MCW,&status); + // NOTE: No need for check errors. The matter is MPI docs: + // "All MPI routines return an error value. Before the value is returned, + // the current MPI error handler is called. By default, this error handler aborts the MPI job." +#pragma omp parallel for + for(long k=0;kGetQuality()&MGL_DRAW_NORM) + { + g->pnt_plot(i,j,zz[3*k+2],cc+12*k+8,oi[k]); + g->pnt_plot(i,j,zz[3*k+1],cc+12*k+4,oi[k]); + } + g->pnt_plot(i,j,zz[3*k],cc+12*k,oi[k]); + } + g->set(MGL_FINISHED); + delete []oi; delete []zz; delete []cc; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mpi_send_(uintptr_t *gr, int *id) { mgl_mpi_send(_GR_, *id); } +void MGL_EXPORT mgl_mpi_recv_(uintptr_t *gr, int *id) { mgl_mpi_recv(_GR_, *id); } +//----------------------------------------------------------------------------- diff --git a/src/obj.cpp b/src/obj.cpp new file mode 100644 index 0000000..92f4454 --- /dev/null +++ b/src/obj.cpp @@ -0,0 +1,969 @@ +/*************************************************************************** + * obj.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" +#undef _GR_ +#define _GR_ ((mglCanvas *)(*gr)) +#define _Gr_ ((mglCanvas *)(gr)) +int MGL_NO_EXPORT mgl_tga_save(const char *fname, int w, int h, unsigned char **p); +int MGL_NO_EXPORT mgl_pnga_save(const char *fname, int w, int h, unsigned char **p); +void MGL_NO_EXPORT mgl_printf(void *fp, bool gz, const char *str, ...); +//----------------------------------------------------------------------------- +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +/* Size prefixes for printf/scanf for size_t and ptrdiff_t */ +#ifdef _MSC_VER +# define PRIuS "Iu" /* printf size_t */ +# define PRIdS "Id" /* printf ptrdiff_t */ +#else +# define PRIuS "zu" /* printf size_t */ +# define PRIdS "zd" /* printf ptrdiff_t */ +#endif + +//----------------------------------------------------------------------------- +void mglTexture::GetRGBAOBJ(unsigned char *f) const +{ + const size_t bw = 128; //border width + register size_t i,j,i0; + mglColor c1,c2,c; + for(i=0;i<256;i++) + { + c1 = col[2*i]; c2 = col[2*i+1]; + for(j=0;j<512;j++) + { + i0 = 4*(j+512*(255-i)); + if (j511-bw) + c = c2; + else + c = c1 + (c2-c1)*((j-bw)/(255.)); + f[i0] = int(255*c.r); + f[i0+1] = int(255*c.g); + f[i0+2] = int(255*c.b); + f[i0+3] = int(255*c.a); + } + } + +} + +//----------------------------------------------------------------------------- + +struct ObjUV +{ + ObjUV() : + u(0.0), v(0.0) {} + ObjUV(mreal U, mreal V) : + u(U), v(V) {} + mreal u; + mreal v; + + void Set(mreal U, mreal V) + { u = U; v = V; } + + bool operator==(const ObjUV &c) const + { + return u==c.u && v==c.v; + } + bool operator!=(const ObjUV &c) const + { + return !(u==c.u && v==c.v); + } + bool operator<(const ObjUV &c) const + { + if(u!=c.u) + return (u texturecoords; + FILE* const fp; + ObjUVs(FILE *f) : fp(f) {} + + size_t addTextureCoords(mreal ta, mreal c, size_t ntxt) + { + const mreal gap = 1./512; + const mreal u = 0.25+0.5*(ta*(1-2*gap)+gap); + const mreal v = ((c-floor(c))*(1-2*gap) + gap + floor(c))/ntxt; + + const ObjUV point(u, v); + std::map::iterator pPoint = texturecoords.find(point); + if(pPoint!=texturecoords.end()) + return pPoint->second; + else + { + const size_t point_index = texturecoords.size()+1; + texturecoords.insert(std::make_pair(point,point_index)); + fprintf(fp,"vt %.15g %.15g\n",u,v); + + return point_index; + } + } + +}; + + +class ObjXYZ +{ + public : + mreal x; + mreal y; + mreal z; + ObjXYZ() : + x(0), y(0), z(0) {} + ObjXYZ(mreal fx, mreal fy, mreal fz) : + x(fx), y(fy), z(fz) {} + + void Set(mreal fx, mreal fy, mreal fz) + { x = fx; y = fy; z = fz; } + mreal Dot(const ObjXYZ & sPt) const + { return(x*sPt.x)+(y*sPt.y)+(z*sPt.z); } + mreal LengthSquared() + { return(x*x+y*y+z*z); } + + friend ObjXYZ operator + (const ObjXYZ& a, const ObjXYZ& b) + { return ObjXYZ(a.x+b.x,a.y+b.y,a.z+b.z); } + friend ObjXYZ operator - (const ObjXYZ& a) + { return ObjXYZ(-a.x,-a.y,-a.z); } + friend ObjXYZ operator - (const ObjXYZ& a, const ObjXYZ& b) + { return ObjXYZ(a.x-b.x,a.y-b.y,a.z-b.z); } + friend ObjXYZ operator * (const ObjXYZ& a, const mreal d) + { return ObjXYZ(a.x*d,a.y*d,a.z*d); } + friend ObjXYZ operator * (const mreal d, const ObjXYZ& a) + { return ObjXYZ(a.x*d,a.y*d,a.z*d); } + friend ObjXYZ operator / (const ObjXYZ& a, const mreal d) + { return ObjXYZ(a.x/d,a.y/d,a.z/d); } + friend ObjXYZ operator * (const ObjXYZ& a, const ObjXYZ& b) + { return ObjXYZ((a.y*b.z)-(a.z*b.y), (a.z*b.x)-(a.x*b.z), (a.x*b.y)-(a.y*b.x)); } + + mreal Length() + { + return sqrt(x*x+y*y+z*z); + } + + bool Normalize() + { + mreal fLength=Length(); + if(fLength < FLT_EPSILON) return false; + mreal factor=1.0/fLength; + x *= factor; + y *= factor; + z *= factor; + return true; + } + + bool operator==(const ObjXYZ &v) const + { + return x==v.x && y==v.y && z==v.z; + } + bool operator!=(const ObjXYZ &v) const + { + return !(x==v.x && y==v.y && z==v.z); + } + bool operator<(const ObjXYZ &v) const + { + if(x!=v.x) + return (x vertexcoords; + FILE* const fp; + ObjXYZs(FILE *f) : fp(f) {} + + size_t addVertexCoords(mreal x, mreal y, mreal z) + { + const ObjXYZ point(x,y,z); + + std::map::iterator pPoint = vertexcoords.find(point); + if(pPoint!=vertexcoords.end()) + return pPoint->second; + else + { + const size_t point_index = vertexcoords.size()+1; + vertexcoords.insert(std::make_pair(point,point_index)); + fprintf(fp,"v %.15g %.15g %.15g\n",x,y,z); + + return point_index; + } + } + +}; + +struct ObjTriangle { + size_t p1, p2, p3; + size_t t1, t2, t3; + ObjTriangle() : + p1(0), p2(0), p3(0), t1(0), t2(0), t3(0) {} + ObjTriangle(size_t P1, size_t T1, size_t P2, size_t T2, size_t P3, size_t T3) : + p1(P1), p2(P2), p3(P3), t1(T1), t2(T2), t3(T3) {} +}; + +struct ObjLine { + size_t p1, p2; + ObjLine() : + p1(0), p2(0) {} + ObjLine(size_t P1, size_t P2) : + p1(P1), p2(P2) {} +}; + +struct ObjGroup { + std::deque triangles; + mglColor commoncolor; + bool samecolor; + std::map > lines; + std::map > points; + FILE* const fp; + ObjXYZs &vertexcoords; + ObjGroup(FILE *f,ObjXYZs& v) : commoncolor(NC), samecolor(true), fp(f), vertexcoords(v) {} + +// const HMGL gr; + +// ObjGroup(const HMGL g) : samecolor(true), gr(g) {} + + void addSegment(size_t m, size_t p1, size_t p2) + { + lines[m].push_back(ObjLine(p1,p2)); + } + void addLines(size_t m, size_t n, const size_t* p) + { + for (size_t i=0; i >::const_iterator pm = lines.begin(); pm != lines.end(); pm++) + { + fprintf(fp,"usemtl Material%"PRIuS"\n", pm->first); + for(std::deque::const_iterator pl = pm->second.begin(); pl != pm->second.end(); pl++) + fprintf(fp,"l %"PRIuS" %"PRIuS"\n", pl->p1, pl->p2); + } + } + void writePoints() { + for(std::map >::const_iterator pm = points.begin(); pm != points.end(); pm++) + { + fprintf(fp,"usemtl Material%"PRIuS"\n", pm->first); + for(std::deque::const_iterator pp = pm->second.begin(); pp != pm->second.end(); pp++) + fprintf(fp,"p %"PRIuS"\n", *pp); + } + } + void writeTriangles() { + for(std::deque::const_iterator pt = triangles.begin(); pt != triangles.end(); pt++) + fprintf(fp,"f %"PRIuS" %"PRIuS" %"PRIuS"\n", pt->p1, pt->p2, pt->p3); + } + void writeTexturedTriangles() { + for(std::deque::const_iterator pt = triangles.begin(); pt != triangles.end(); pt++) + fprintf(fp,"f %"PRIuS"/%"PRIuS" %"PRIuS"/%"PRIuS" %"PRIuS"/%"PRIuS"\n", pt->p1,pt->t1, pt->p2,pt->t2, pt->p3,pt->t3); + } +}; + +struct lt_mglColor +{ + bool operator()(const mglColor& c1, const mglColor& c2) const + { + if(c1.r!=c2.r) + return (c1.r colormap; + + +struct ObjMaterials { + colormap materialmap; + FILE* const fp; + ObjMaterials(FILE *f) : fp(f) {} + + size_t addColor(const mglColor& color) + { + colormap::iterator pc = materialmap.find(color); + if(pc!=materialmap.end()) + return pc->second; + else + { + const size_t color_index = materialmap.size(); + materialmap.insert(std::make_pair(color,color_index)); + fprintf(fp,"newmtl Material%"PRIuS"\n", color_index); + fprintf(fp,"Ka 0.1 0.1 0.1\n"); + fprintf(fp,"Kd %g %g %g\n", color.r, color.g, color.b); + fprintf(fp,"Ks 0.0 0.0 0.0\n"); + fprintf(fp,"d %g\nillum 2\nNs 15.0\n",color.a); + + return color_index; + } + } + size_t addColor(mreal r, mreal g, mreal b, mreal a) + { + const mglColor color(r,g,b,a); + return addColor(color); + } + size_t addColorInfo(const mglPnt& p) + { + return addColor(p.r,p.g,p.b,p.a); + } +}; + + +static size_t power_of_two(size_t input) +{ + size_t value = 1; + while ( value < input ) { + value <<= 1; + } + return value; +} + + +void MGL_EXPORT mgl_write_obj(HMGL gr, const char *fname,const char *descr, int use_png) +{ + if(gr->GetPrmNum()==0) return; // nothing to do + + register size_t i,j; + { + long mmin=0,mmax=0,m; + for(i=0;iGrp.size();i++) // prepare array of indirect indexing + { m = gr->Grp[i].Id; if(mmmax) mmax=m; } + long *ng = new long[mmax-mmin+1]; + for(i=0;iGrp.size();i++) ng[gr->Grp[i].Id-mmin] = i; + for(i=0;iGetPrmNum());i++) // collect data for groups + // it is rather expensive (extra 4b per primitive) but need for export to 3D + { + m = gr->GetPrm(i).id-mmin; + if(m>=0 && mGrp[ng[m]].p.push_back(i); + } + delete []ng; + } + + const size_t len=strlen(fname); + const size_t ntxt=gr->GetTxtNum(); + const size_t Ntxt=power_of_two(ntxt); + const size_t pntnum = gr->GetPntNum(); + char *tname = new char[len+5]; strcpy(tname,fname); + FILE *fp=fopen(fname,"wt"); + ObjXYZs vertexcoords(fp); + std::vector vcs(pntnum); // vertex coord ids + ObjUVs texturecoords(fp); + std::vector tcs(pntnum); // texture coord ids + + // center point + mglPnt p0; + const mreal width = dynamic_cast(gr)->GetWidth(); + const mreal height = dynamic_cast(gr)->GetHeight(); + const mreal depth = sqrt(width*height); + + p0.x = width/2.; + p0.y = height/2.; + p0.z = (1.f-sqrt(width*height)/(2*depth))*depth; + + // vertices definition + fprintf(fp,"# Created by MathGL library\n# Title: %s\n",(descr && *descr) ? descr : fname); + for(i=0;iGetPnt(i); + vcs[i] = vertexcoords.addVertexCoords(pp.x-p0.x, pp.y-p0.y, pp.z-p0.z); + tcs[i] = texturecoords.addTextureCoords(pp.ta, pp.c, Ntxt); + } + + // prepare MTL file + tname[len-4]='.'; tname[len-3]='m'; tname[len-2]='t'; tname[len-1]='l'; + FILE *fpmat=fopen(tname,"wt"); + tname[len-4]='\0'; + fprintf(fpmat,"newmtl Material\n"); + fprintf(fpmat,"Ka 0.0 0.0 0.0\n"); + fprintf(fpmat,"Kd 1.0 1.0 1.0\n"); + fprintf(fpmat,"Ks 0.0 0.0 0.0\n"); + fprintf(fpmat,"d 1.0\nillum 2\n"); + if(use_png) + fprintf(fpmat,"map_Kd %s_txt.png\n",tname); + else + fprintf(fpmat,"map_Kd %s_txt.tga\n",tname); + if(use_png) + strcat(tname,"_txt.png"); + else + strcat(tname,"_txt.tga"); + // prepare texture file (TGA or PNG) + const size_t txtwidth = 512; + unsigned char *buf = new unsigned char[4*256*txtwidth*Ntxt]; + unsigned char **pbuf= (unsigned char **)malloc(256*Ntxt*sizeof(unsigned char *)); + for(i=0;i<256*Ntxt;i++) pbuf[i] = buf+4*txtwidth*i; + for(i=0;iGetTxt(i).GetRGBAOBJ(buf+(Ntxt-1-i)*256*txtwidth*4); + for(i=ntxt;iGrp.size();i++) + { + std::vector &p = gr->Grp[i].p; + ObjGroup grp(fp, vertexcoords); + for(j=0;jGetPrm(p[j]); + + register long n1=q.n1,n2=q.n2,n3=q.n3,n4=q.n4; + switch(q.type) + { + case 0: + if (gr->GetPnt(q.n1).a > mgl_min_a) { + const mglPnt p = gr->GetPnt(q.n1) - p0; + const mreal size = q.s; + const char type = q.n4; + mreal ss=size; + const mglColor c(p.r, p.g, p.b, p.a); + + if(!strchr("xsSoO",type)) ss *= 1.1; + if(type=='.' || ss==0) + { + const size_t m = materials.addColor(c); + grp.addPoint(m, vcs[n1]); + } + else + switch(type) + { + case 'P': + { + const size_t m = materials.addColor(c); + const mreal P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + grp.addLines(m, 5, P); + } + case '+': + { + const size_t m = materials.addColor(c); + const mreal P1[2][3] = + { + { p.x-ss,p.y,p.z }, + { p.x+ss,p.y,p.z } + }; + grp.addLines(m, 2, P1); + const mreal P2[2][3] = + { + { p.x,p.y-ss,p.z }, + { p.x,p.y+ss,p.z } + }; + grp.addLines(m, 2, P2); + } + break; + case 'X': + { + const size_t m = materials.addColor(c); + const mreal P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + grp.addLines(m, 5, P); + const mreal P1[2][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z } + }; + grp.addLines(m, 2, P1); + const mreal P2[2][3] = + { + { p.x+ss,p.y-ss,p.z }, + { p.x-ss,p.y+ss,p.z } + }; + grp.addLines(m, 2, P2); + } + break; + case 'x': + { + const size_t m = materials.addColor(c); + const mreal P1[2][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z } + }; + grp.addLines(m, 2, P1); + const mreal P2[2][3] = + { + { p.x+ss,p.y-ss,p.z }, + { p.x-ss,p.y+ss,p.z } + }; + grp.addLines(m, 2, P2); + } + break; + case 'S': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x-ss,p.y-ss,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x+ss,p.y-ss,p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x-ss,p.y+ss,p.z); + const size_t pi4 = vertexcoords.addVertexCoords(p.x+ss,p.y+ss,p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + grp.addTriangle(pi4, ti, pi3, ti, pi2, ti); + } + break; + case 's': + { + const size_t m = materials.addColor(c); + const mreal P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + grp.addLines(m, 5, P); + } + break; + case 'D': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x,p.y-ss,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x+ss,p.y,p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x-ss,p.y,p.z); + const size_t pi4 = vertexcoords.addVertexCoords(p.x,p.y+ss,p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + grp.addTriangle(pi4, ti, pi3, ti, pi2, ti); + } + break; + case 'd': + { + const size_t m = materials.addColor(c); + const mreal P[5][3] = + { + { p.x,p.y-ss,p.z }, + { p.x+ss,p.y,p.z }, + { p.x,p.y+ss,p.z }, + { p.x-ss,p.y,p.z }, + { p.x,p.y-ss,p.z } + }; + grp.addLines(m, 5, P); + } + break; + case 'Y': + { + const size_t m = materials.addColor(c); + const mreal P1[3][3] = + { + { p.x, p.y-ss, p.z }, + { p.x, p.y, p.z }, + { p.x+0.8*ss,p.y+0.6*ss,p.z } + }; + grp.addLines(m, 3, P1); + const mreal P2[2][3] = + { + { p.x, p.y, p.z }, + { p.x-0.8*ss,p.y+0.6*ss,p.z } + }; + grp.addLines(m, 2, P2); + } + break; + case '*': + { + const size_t m = materials.addColor(c); + const mreal P1[2][3] = + { + { p.x-ss,p.y,p.z }, + { p.x+ss,p.y,p.z } + }; + grp.addLines(m, 2, P1); + const mreal P2[2][3] = + { + { p.x-0.6*ss,p.y-0.8*ss,p.z }, + { p.x+0.6*ss,p.y+0.8*ss,p.z } + }; + grp.addLines(m, 2, P2); + const mreal P3[2][3] = + { + { p.x-0.6*ss,p.y+0.8*ss,p.z }, + { p.x+0.6*ss,p.y-0.8*ss,p.z } + }; + grp.addLines(m, 2, P3); + + } + break; + case 'T': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x-ss,p.y-ss/2,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x+ss,p.y-ss/2,p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x,p.y+ss,p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + } + break; + case '^': + { + const size_t m = materials.addColor(c); + const mreal P[4][3] = + { + { p.x-ss,p.y-ss/2,p.z }, + { p.x+ss,p.y-ss/2,p.z }, + { p.x, p.y+ss, p.z }, + { p.x-ss,p.y-ss/2,p.z } + }; + grp.addLines(m, 4, P); + } + break; + case 'V': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x-ss,p.y+ss/2,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x,p.y-ss,p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x+ss,p.y+ss/2,p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + } + break; + case 'v': + { + const size_t m = materials.addColor(c); + const mreal P[4][3] = + { + { p.x-ss,p.y+ss/2,p.z }, + { p.x+ss,p.y+ss/2,p.z }, + { p.x, p.y-ss, p.z }, + { p.x-ss,p.y+ss/2,p.z } + }; + grp.addLines(m, 4, P); + } + break; + case 'L': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x+ss/2,p.y+ss,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x-ss, p.y, p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x+ss/2,p.y-ss,p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + } + break; + case '<': + { + const size_t m = materials.addColor(c); + const mreal P[4][3] = + { + { p.x+ss/2,p.y+ss,p.z }, + { p.x+ss/2,p.y-ss,p.z }, + { p.x-ss, p.y, p.z }, + { p.x+ss/2,p.y+ss,p.z } + }; + grp.addLines(m, 4, P); + } + break; + case 'R': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t pi1 = vertexcoords.addVertexCoords(p.x-ss/2,p.y+ss,p.z); + const size_t pi2 = vertexcoords.addVertexCoords(p.x-ss/2,p.y-ss,p.z); + const size_t pi3 = vertexcoords.addVertexCoords(p.x+ss, p.y, p.z); + + grp.addTriangle(pi1, ti, pi2, ti, pi3, ti); + } + break; + case '>': + { + const size_t m = materials.addColor(c); + const mreal P[4][3] = + { + { p.x-ss/2,p.y+ss,p.z }, + { p.x-ss/2,p.y-ss,p.z }, + { p.x+ss, p.y, p.z }, + { p.x-ss/2,p.y+ss,p.z } + }; + grp.addLines(m, 4, P); + } + break; + case 'O': + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + + const size_t cpi=vertexcoords.addVertexCoords(p.x, p.y, p.z); + size_t pnti[21]; + for(size_t k=0;k<=20;k++) + pnti[k]=vertexcoords.addVertexCoords(p.x+ss*cos(k*M_PI/10),p.y+ss*sin(k*M_PI/10),p.z); + for(size_t k=0;k<20;k++) { + grp.addTriangle(pnti[k], ti, pnti[k+1], ti, cpi, ti); + } + } + break; + case 'C': + { + const size_t m = materials.addColor(c); + grp.addPoint(m, vcs[n1]); + } + case 'o': + { + const size_t m = materials.addColor(c); + mreal P[21][3]; + for(size_t k=0;k<=20;k++) { + P[k][0] = p.x+ss*cos(k*M_PI/10); + P[k][1] = p.y+ss*sin(k*M_PI/10); + P[k][2] = p.z; + } + grp.addLines(m, 21, P); + } + break; + } + } + break; + case 1: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a) { + const mglPnt& p1 = gr->GetPnt(q.n1); + const mglPnt& p2 = gr->GetPnt(q.n2); + const size_t m = materials.addColor((p1.r+p2.r)/2, (p1.g+p2.g)/2, (p1.b+p2.b)/2, (p1.a+p2.a)/2); + grp.addSegment(m, vcs[n1], vcs[n2]); + } + break; + case 2: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a || gr->GetPnt(q.n3).a > mgl_min_a) { + grp.addTriangle(vcs[n1],tcs[n1], vcs[n2],tcs[n2], vcs[n3],tcs[n3]); + grp.addColourInfo(gr->GetPnt(n1)); + grp.addColourInfo(gr->GetPnt(n2)); + grp.addColourInfo(gr->GetPnt(n3)); + } + break; + case 3: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a || gr->GetPnt(q.n3).a > mgl_min_a || gr->GetPnt(q.n4).a > mgl_min_a) { + grp.addTriangle(vcs[n1],tcs[n1], vcs[n2],tcs[n2], vcs[n3],tcs[n3]); + grp.addTriangle(vcs[n2],tcs[n2], vcs[n4],tcs[n4], vcs[n3],tcs[n3]); + grp.addColourInfo(gr->GetPnt(n1)); + grp.addColourInfo(gr->GetPnt(n2)); + grp.addColourInfo(gr->GetPnt(n3)); + grp.addColourInfo(gr->GetPnt(n4)); + } + break; + case 4: + { + const mglPnt p = gr->GetPnt(q.n1) - p0; + + const mreal f = q.p/2, dx=p.u/2, dy=p.v/2; + const mreal c=q.s*cos(q.w*M_PI/180), s=-q.s*sin(q.w*M_PI/180); + const double b[4] = {c,-s, s,c}; + long ik,il=0; + + const mglGlyph &g = gr->GetGlf(q.n4); + const mreal dd = 0.004; + if(q.n3&8) + { + const size_t p_4 = vertexcoords.addVertexCoords(p.x+b[0]*dx+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + const size_t p_3 = vertexcoords.addVertexCoords(p.x+b[0]*dx+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + const size_t p_2 = vertexcoords.addVertexCoords(p.x+b[0]*(dx+f)+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + const size_t p_1 = vertexcoords.addVertexCoords(p.x+b[0]*(dx+f)+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + + if(!(q.n3&4)) // glyph_line(p,f,true, d); + { + const size_t ti = tcs[n1]; grp.addColourInfo(p); + grp.addMonoTriangle(ti, p_1, p_3, p_2); + grp.addMonoTriangle(ti, p_4, p_2, p_3); + } + else // glyph_line(p,f,false, d); + { + const size_t m = materials.addColor(p.r, p.g, p.b, p.a); + grp.addSegment(m, p_1, p_2); + grp.addSegment(m, p_3, p_4); + grp.addSegment(m, p_1, p_3); + grp.addSegment(m, p_2, p_4); + } + } + else + { + if(!(q.n3&4)) // glyph_fill(p,f,g, d); + { + for(ik=0;ikGrp[i].Lbl.c_str()); + + if (!grp.triangles.empty()) { + if (grp.samecolor) { + fprintf(fp,"usemtl Material%"PRIuS"\n", materials.addColor(grp.commoncolor)); + grp.writeTriangles(); + } else { + fprintf(fp,"usemtl Material\n"); + grp.writeTexturedTriangles(); + } + } + grp.writeLines(); + grp.writePoints(); + + gr->Grp[i].p.clear(); // we don't need indexes anymore + } + fclose(fp); + fclose(fpmat); + delete []tname; +} + +void MGL_EXPORT mgl_write_obj_(uintptr_t *gr, const char *fname,const char *descr, int *use_png,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]='\0'; + char *d=new char[n+1]; memcpy(d,descr,n); d[n]='\0'; + mgl_write_obj(_GR_,s,d,*use_png); delete []s; delete []d; } +//----------------------------------------------------------------------------- diff --git a/src/opengl.cpp b/src/opengl.cpp new file mode 100644 index 0000000..1da1b53 --- /dev/null +++ b/src/opengl.cpp @@ -0,0 +1,445 @@ +#ifdef WIN32 +#include +#endif +#ifdef __APPLE__ +#include +#else +#include +#endif +#include "mgl2/opengl.h" +#include "mgl2/mgl_cf.h" +#include +//----------------------------------------------------------------------------- +/// Create mglGraph object in OpenGL mode. +HMGL MGL_EXPORT mgl_create_graph_gl() +{ return new mglCanvasGL; } +/// Create mglGraph object in OpenGL mode. +uintptr_t MGL_EXPORT mgl_create_graph_gl_() +{ return uintptr_t(new mglCanvasGL); } +//----------------------------------------------------------------------------- +mglCanvasGL::mglCanvasGL() : mglCanvas(1,1) {} +//----------------------------------------------------------------------------- +mglCanvasGL::~mglCanvasGL(){} +//----------------------------------------------------------------------------- +void mglCanvasGL::Finish() +{ + if(Prm.size()>0) + { + PreparePrim(0); + glVertexPointer(3, GL_FLOAT, sizeof(mglPnt), &(Pnt[0].x)); + glNormalPointer(GL_FLOAT, sizeof(mglPnt), &(Pnt[0].u)); + glColorPointer(4, GL_FLOAT, sizeof(mglPnt), &(Pnt[0].r)); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + int pdef=PDef; + mreal ss=pPos, ww=PenWidth; + mglPrim p; + for(size_t i=0;i7) { SetWarn(mglWarnLId,"AddLight"); return; } + if(c.Valid()) + { + DifLight = c*br; + AmbLight = c*AmbBr; + } + dif[0] = DifLight.r; dif[1] = DifLight.g; + dif[2] = DifLight.b; dif[3] = 1.; + amb[0] = AmbLight.r; amb[1] = AmbLight.g; + amb[2] = AmbLight.b; amb[3] = 1.; + if(inf) + { pos[0] = d.x; pos[1] = d.y; pos[2] = d.z; pos[3] = 0; } + else + { pos[0] = r.x; pos[1] = r.y; pos[2] = r.z; pos[3] = 1; } + dir[0] = d.x; dir[1] = d.y; dir[2] = d.z; + glShadeModel(GL_SMOOTH); + //glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 5.0); + //glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, pos); + + glLightfv(lght[n], GL_AMBIENT, amb); + glLightfv(lght[n], GL_DIFFUSE, dif); + //glLightfv(lght[n], GL_SPECULAR, spc); + glLightfv(lght[n], GL_POSITION, pos); + if(!inf) glLightfv(lght[n], GL_SPOT_DIRECTION, dir); + glEnable(lght[n]); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::Light(int n, bool enable) +{ + GLenum lght[8] = {GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4, + GL_LIGHT5,GL_LIGHT6,GL_LIGHT7}; + if(enable) glEnable(lght[n]); + else glDisable(lght[n]); +} +//----------------------------------------------------------------------------- +bool mglCanvasGL::Light(bool enable) +{ + if(enable) { glEnable(GL_LIGHTING); glEnable(GL_NORMALIZE);} + else { glDisable(GL_LIGHTING); glDisable(GL_NORMALIZE); } + return mglCanvas::Light(enable); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::LightScale(const mglMatrix *M) +{ + mglCanvas::LightScale(M); + GLenum ll[8] = {GL_LIGHT0,GL_LIGHT1,GL_LIGHT2,GL_LIGHT3,GL_LIGHT4, + GL_LIGHT5,GL_LIGHT6,GL_LIGHT7}; + float pos[4]={0,0,0,0}; + for(int i=0;i<8;i++) + { + pos[0] = light[i].p.x; + pos[1] = light[i].p.y; + pos[2] = light[i].p.z; + if(light[i].n) glLightfv(ll[i], GL_POSITION, pos); + } +} +//----------------------------------------------------------------------------- +void mglCanvasGL::Zoom(mreal x1, mreal y1, mreal x2, mreal y2) +{ + glMatrixMode(GL_PROJECTION);//GL_PROJECTION GL_VIEWPORT GL_MODELVIEW + glLoadIdentity(); + glScaled(x2-x1,y2-y1,1); + glTranslated((x1+x2-1)/2,(y1+y2-1)/2,0); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::View(mreal TetX,mreal TetY,mreal TetZ) +{ + glMatrixMode(GL_PROJECTION);//GL_PROJECTION GL_VIEWPORT GL_MODELVIEW + glRotated(TetX,1.,0.,0.); + glRotated(TetY,0.,1.,0.); + glRotated(TetZ,0.,0.,1.); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::Fog(mreal d, mreal) +{ + if(d>0) + { + float back[4]={BDef[0]/255.f,BDef[1]/255.f,BDef[2]/255.f,BDef[3]/255.f}; + glFogf(GL_FOG_MODE,GL_EXP); + glFogf(GL_FOG_DENSITY,5*d); + glFogfv(GL_FOG_COLOR,back); + glEnable(GL_FOG); + } + else glDisable(GL_FOG); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::Clf(mglColor Back) +{ + mglCanvas::Clf(Back); + if(Back==NC) Back = mglColor(BDef[0]/255.,BDef[1]/255.,BDef[2]/255.); + gl_clf(Back); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::gl_clf(mglColor Back) +{ + if(Back==NC) Back = WC; +// glDepthFunc(GL_LESS); + glDepthFunc(GL_GREATER); +// back[0]=Back.r; back[1]=Back.g; back[2]=Back.b; + glClearColor(Back.r,Back.g,Back.b,1.); + glClearDepth(-10.); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_COLOR_MATERIAL); + + glMatrixMode(GL_MODELVIEW);//GL_MODELVIEW GL_VIEWPORT GL_PROJECTION + glLoadIdentity(); +// glScaled(1.5,1.5,1.5); +// glTranslated(-0.5,-0.5,-0.5); +} +//----------------------------------------------------------------------------- +void mglCanvasGL::set_pen(unsigned style,mreal width) +{ + if(style==0) return; + if(style!=0xffff) + { + glEnable(GL_LINE_STIPPLE); + glLineStipple(int(width+0.5),style); + } + else glDisable(GL_LINE_STIPPLE); + if(width>0) glLineWidth(width); + else glLineWidth(1); +} +//----------------------------------------------------------------------------- +/*void mglCanvasGL::EndFrame() +{ +// mglGraph::EndFrame(); + glEndList(); +} +//----------------------------------------------------------------------------- +int mglCanvasGL::NewFrame() +{ + Clf(); Identity(); + glNewList(CurFrameId,GL_COMPILE); + CurFrameId++; + return CurFrameId-1; +}*/ +//----------------------------------------------------------------------------- +unsigned char **mglCanvasGL::GetRGBLines(long &width, long &height, unsigned char *&f, bool alpha) +{ + long x, y, d = alpha ? 4:3; + GLint w[4]; + glGetIntegerv(GL_VIEWPORT,w); + x=w[0]; y=w[1]; width=w[2]; height=w[3]; + unsigned char **p; + + p = (unsigned char **)malloc(height * sizeof(unsigned char *)); + f = (unsigned char *) malloc(width*height * sizeof(unsigned char)*d); + for(long i=0;iPenWidth = ss?ss:sqrt(font_factor/400); + pnt_draw(q,d); + } + else + { + if(d) + { + d->PDef = MGL_SOLID_MASK; d->angle = 0; + d->PenWidth*=fabs(50*size); + if(d->PenWidth<1) d->PenWidth=1; + } + if(!strchr("xsSoO",type)) ss *= 1.1; + switch(type) + { + case 'P': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p3,d); line_draw(p3,p0,d); + case '+': + p0.x = q.x-ss; p0.y = q.y; p1.x = q.x+ss; p1.y = q.y; line_draw(p0,p1,d); + p2.x = q.x; p2.y = q.y-ss; p3.x = q.x; p3.y = q.y+ss; line_draw(p2,p3,d); + break; + case 'X': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p3,d); line_draw(p3,p0,d); + case 'x': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y+ss; line_draw(p0,p1,d); + p2.x = q.x+ss; p2.y = q.y-ss; p3.x = q.x-ss; p3.y = q.y+ss; line_draw(p2,p3,d); + break; + case 'S': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x-ss; p1.y = q.y+ss; + p2.x= q.x+ss; p2.y= q.y+ss; p3.x = q.x+ss; p3.y = q.y-ss; + quad_draw(p0,p1,p3,p2,d); + case 's': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p3,d); line_draw(p3,p0,d); + break; + case 'D': + p0.x = q.x; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y; + p2.x= q.x; p2.y= q.y+ss; p3.x = q.x-ss; p3.y = q.y; + quad_draw(p0,p1,p3,p2,d); + case 'd': + p0.x = q.x; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y; + p2.x = q.x; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p3,d); line_draw(p3,p0,d); + break; + case 'Y': + p1.x = q.x; p1.y = q.y-ss; line_draw(q,p1,d); + p2.x = q.x-0.8*ss; p2.y = q.y+0.6*ss; line_draw(q,p2,d); + p3.x = q.x+0.8*ss; p3.y = q.y+0.6*ss; line_draw(q,p3,d); + break; + case '*': + p0.x = q.x-ss; p0.y = q.y; + p1.x = q.x+ss; p1.y = q.y; line_draw(p0,p1,d); + p0.x = q.x-0.6*ss; p0.y = q.y-0.8*ss; + p1.x = q.x+0.6*ss; p1.y = q.y+0.8*ss; line_draw(p0,p1,d); + p0.x = q.x-0.6*ss; p0.y = q.y+0.8*ss; + p1.x = q.x+0.6*ss; p1.y = q.y-0.8*ss; line_draw(p0,p1,d); + break; + case 'T': + p0.x = q.x-ss; p0.y = q.y-ss/2; + p1.x = q.x+ss; p1.y = q.y-ss/2; + p2.x= q.x; p2.y= q.y+ss; + trig_draw(p0,p1,p2,false,d); + case '^': + p0.x = q.x-ss; p0.y = q.y-ss/2; + p1.x = q.x+ss; p1.y = q.y-ss/2; + p2.x= q.x; p2.y= q.y+ss; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p0,d); break; + case 'V': + p0.x = q.x-ss; p0.y = q.y+ss/2; + p1.x = q.x+ss; p1.y = q.y+ss/2; + p2.x= q.x; p2.y= q.y-ss; + trig_draw(p0,p1,p2,false,d); + case 'v': + p0.x = q.x-ss; p0.y = q.y+ss/2; + p1.x = q.x+ss; p1.y = q.y+ss/2; + p2.x= q.x; p2.y= q.y-ss; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p0,d); break; + case 'L': + p0.x = q.x+ss/2; p0.y = q.y+ss; + p1.x = q.x+ss/2; p1.y = q.y-ss; + p2.x= q.x-ss; p2.y= q.y; + trig_draw(p0,p1,p2,false,d); + case '<': + p0.x = q.x+ss/2; p0.y = q.y+ss; + p1.x = q.x+ss/2; p1.y = q.y-ss; + p2.x= q.x-ss; p2.y= q.y; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p0,d); break; + case 'R': + p0.x = q.x-ss/2; p0.y = q.y+ss; + p1.x = q.x-ss/2; p1.y = q.y-ss; + p2.x= q.x+ss; p2.y= q.y; + trig_draw(p0,p1,p2,false,d); + case '>': + p0.x = q.x-ss/2; p0.y = q.y+ss; + p1.x = q.x-ss/2; p1.y = q.y-ss; + p2.x= q.x+ss; p2.y= q.y; + line_draw(p0,p1,d); line_draw(p1,p2,d); + line_draw(p2,p0,d); break; + case 'O': +/* for(long j=long(-ss);j<=long(ss);j++) for(long i=long(-ss);i<=long(ss);i++) + { + register long x=long(q.x)+i, y=long(q.y)+j; + if(i*i+j*j>=ss*ss || !d || xx1 || x>d->x2 || yy1 || y>d->y2) continue; + pnt_plot(x,y,q.z+1,cs,d->ObjId); + }*/ + case 'o': + for(long i=0;i<=20;i++) // TODO copy from mark_pix()?! + { + p0 = p1; p1.x = q.x+ss*cos(i*M_PI/10); p1.y = q.y+ss*sin(i*M_PI/10); + if(i>0) line_draw(p0,p1,d); + } + break; + case 'C': + pnt_draw(q,d); + for(long i=0;i<=20;i++) + { + p0 = p1; p1.x = q.x+ss*cos(i*M_PI/10); p1.y = q.y+ss*sin(i*M_PI/10); + if(i>0) line_draw(p0,p1,d); + } + break; + } + } +} +//----------------------------------------------------------------------------- diff --git a/src/other.cpp b/src/other.cpp new file mode 100644 index 0000000..b5d4e00 --- /dev/null +++ b/src/other.cpp @@ -0,0 +1,537 @@ +/*************************************************************************** + * other.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/other.h" +#include "mgl2/surf.h" +#include "mgl2/cont.h" +#include "mgl2/eval.h" +#include "mgl2/data.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// DensX, DensY, DensZ series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_x(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensX"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensX"); return; } + mglData xx,yy,zz,aa; + gr->SaveState(opt); + + if(l>1) + { + aa.Create(m,l); xx.Create(m,l); yy.Create(m,l); zz.Create(m,l); + mreal d = (n-1)*(sv - gr->Min.x)/(gr->Max.x - gr->Min.x); + long k = long(d); d = d - k; + if(k>n-2) { k=n-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[k+n*(i+m*j)]*(1-d) + d*ma->a[k+1+n*(i+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(k,i,j)*(1-d) + d*a->v(k+1,i,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + xx.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); + mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_y(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensY"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensY"); return; } + mglData xx,yy,zz,aa; + gr->SaveState(opt); + + if(l>1) + { + aa.Create(n,l); xx.Create(n,l); yy.Create(n,l); zz.Create(n,l); + mreal d = (m-1)*(sv - gr->Min.y)/(gr->Max.y - gr->Min.y); + long k = long(d); d = d - k; + if(k>m-2) { k=m-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(k+m*j)]*(1-d) + d*ma->a[i+n+n*(k+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,k,j)*(1-d) + d*a->v(i,k+1,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + yy.Fill(sv, sv); + xx.Fill(gr->Min.x, gr->Max.x,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); + mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"DensZ"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"DensZ"); return; } + mglData xx,yy,zz,aa; + gr->SaveState(opt); + + xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); + if(l>1) + { + aa.Create(n,m); + mreal d = (l-1)*(sv - gr->Min.z)/(gr->Max.z - gr->Min.z); + long k = long(d); d = d - k; + if(k>l-2) { k=l-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(j+m*k)]*(1-d) + d*ma->a[i+n*m+n*(j+m*k)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,j,k)*(1-d) + d*a->v(i,j,k+1); + a = &aa; + } + zz.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'y'); + xx.Fill(gr->Min.x, gr->Max.x,'x'); + mgl_surfc_xy(gr,&xx,&yy,&zz,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_x_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dens_x(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_y_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ + char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dens_y(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_z_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ + char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dens_z(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContX, ContY, ContZ series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_gen(HMGL gr, mreal val, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, int text,long ak); +void MGL_EXPORT mgl_cont_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContX"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContX"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContX",cgid++); + mglData xx,yy,zz,aa; + + bool text=(mglchr(sch,'t')); + long ss=gr->AddTexture(sch); + gr->SetPenPal(sch); + + if(l>1) + { + aa.Create(m,l); xx.Create(m,l); yy.Create(m,l); zz.Create(m,l); + mreal d = (n-1)*(sv - gr->Min.x)/(gr->Max.x - gr->Min.x); + long k = long(d); d = d - k; + if(k>n-2) { k=n-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[k+n*(i+m*j)]*(1-d) + d*ma->a[k+1+n*(i+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(k,i,j)*(1-d) + d*a->v(k+1,i,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + xx.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); +#pragma omp parallel for + for(long i=0;iGetNx();i++) + { + register mreal v0 = v->v(i); + mgl_cont_gen(gr,v0,a,&xx,&yy,&zz,gr->GetC(ss,v0),text,0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContY"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContY"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContY",cgid++); + mglData xx,yy,zz,aa; + + bool text=(mglchr(sch,'t')); + long ss=gr->AddTexture(sch); + gr->SetPenPal(sch); + + if(l>1) + { + aa.Create(n,l); xx.Create(n,l); yy.Create(n,l); zz.Create(n,l); + mreal d = (m-1)*(sv - gr->Min.y)/(gr->Max.y - gr->Min.y); + long k = long(d); d = d - k; + if(k>m-2) { k=m-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(k+m*j)]*(1-d) + d*ma->a[i+n+n*(k+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,k,j)*(1-d) + d*a->v(i,k+1,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + yy.Fill(sv, sv); + xx.Fill(gr->Min.x, gr->Max.x,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); +#pragma omp parallel for + for(long i=0;iGetNx();i++) + { + register mreal v0 = v->v(i); + mgl_cont_gen(gr,v0,a,&xx,&yy,&zz,gr->GetC(ss,v0),text,0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContZ"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContZ"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContZ",cgid++); + mglData xx,yy,zz,aa; + + bool text=(mglchr(sch,'t')); + long ss=gr->AddTexture(sch); + gr->SetPenPal(sch); + + xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); + if(l>1) + { + aa.Create(n,m); + mreal d = (l-1)*(sv - gr->Min.z)/(gr->Max.z - gr->Min.z); + long k = long(d); d = d - k; + if(k>l-2) { k=l-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(j+m*k)]*(1-d) + d*ma->a[i+n*m+n*(j+m*k)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,j,k)*(1-d) + d*a->v(i,j,k+1); + a = &aa; + } + zz.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'y'); + xx.Fill(gr->Min.x, gr->Max.x,'x'); +#pragma omp parallel for + for(long i=0;iGetNx();i++) + { + register mreal v0 = v->v(i); + mgl_cont_gen(gr,v0,a,&xx,&yy,&zz,gr->GetC(ss,v0),text,0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_x(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont_x_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_y(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont_y_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); + for(long i=0;iMin.c + (gr->Max.c-gr->Min.c)*mreal(i+1)/(Num+1); + mgl_cont_z_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_x_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_x(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_y_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_y(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_z_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_z(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_x_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_x_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_y_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_y_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cont_z_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cont_z_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// ContFX, ContFY, ContFZ series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_gen(HMGL gr, mreal v1, mreal v2, HCDT a, HCDT x, HCDT y, HCDT z, mreal c, long ak); +void MGL_EXPORT mgl_contf_x_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFX"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFX"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContFX",cgid++); + mglData xx,yy,zz,aa; + long ss=gr->AddTexture(sch); + + if(l>1) + { + aa.Create(m,l); xx.Create(m,l); yy.Create(m,l); zz.Create(m,l); + mreal d = (n-1)*(sv - gr->Min.x)/(gr->Max.x - gr->Min.x); + long k = long(d); d = d - k; + if(k>n-2) { k=n-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[k+n*(i+m*j)]*(1-d) + d*ma->a[k+1+n*(i+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(k,i,j)*(1-d) + d*a->v(k+1,i,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + xx.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); +#pragma omp parallel for + for(long i=0;iGetNx()-1;i++) + { + register mreal v0 = v->v(i); + mgl_contf_gen(gr,v0,v->v(i+1),a,&xx,&yy,&zz,gr->GetC(ss,v0),0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_y_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFY"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFY"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContFY",cgid++); + mglData xx,yy,zz,aa; + long ss=gr->AddTexture(sch); + + if(l>1) + { + aa.Create(n,l); xx.Create(n,l); yy.Create(n,l); zz.Create(n,l); + mreal d = (m-1)*(sv - gr->Min.y)/(gr->Max.y - gr->Min.y); + long k = long(d); d = d - k; + if(k>m-2) { k=m-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(k+m*j)]*(1-d) + d*ma->a[i+n+n*(k+m*j)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,k,j)*(1-d) + d*a->v(i,k+1,j); + a = &aa; + } + else + { xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); } + yy.Fill(sv, sv); + xx.Fill(gr->Min.x, gr->Max.x,'x'); + zz.Fill(gr->Min.z, gr->Max.z,'y'); +#pragma omp parallel for + for(long i=0;iGetNx()-1;i++) + { + register mreal v0 = v->v(i); + mgl_contf_gen(gr,v0,v->v(i+1),a,&xx,&yy,&zz,gr->GetC(ss,v0),0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_z_val(HMGL gr, HCDT v, HCDT a, const char *sch, double sv, const char *opt) +{ + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + if(mgl_isnan(sv)) sv = gr->GetOrgX('x'); + if(n<2 || m<2) { gr->SetWarn(mglWarnLow,"ContFZ"); return; } + if(svMin.x || sv>gr->Max.x) { gr->SetWarn(mglWarnSlc,"ContFZ"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("ContFZ",cgid++); + mglData xx,yy,zz,aa; + long ss=gr->AddTexture(sch); + + xx.Create(n,m); yy.Create(n,m); zz.Create(n,m); + if(l>1) + { + aa.Create(n,m); + mreal d = (l-1)*(sv - gr->Min.z)/(gr->Max.z - gr->Min.z); + long k = long(d); d = d - k; + if(k>l-2) { k=l-2; d=1; } + if(k<0) { k=0; d=0; } + const mglData *ma=dynamic_cast(a); + if(ma) +#pragma omp parallel for collapse(2) + for(long j=0;ja[i+n*(j+m*k)]*(1-d) + d*ma->a[i+n*m+n*(j+m*k)]; + else +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,j,k)*(1-d) + d*a->v(i,j,k+1); + a = &aa; + } + zz.Fill(sv, sv); + yy.Fill(gr->Min.y, gr->Max.y,'y'); + xx.Fill(gr->Min.x, gr->Max.x,'x'); +#pragma omp parallel for + for(long i=0;iGetNx()-1;i++) + { + register mreal v0 = v->v(i); + mgl_contf_gen(gr,v0,v->v(i+1),a,&xx,&yy,&zz,gr->GetC(ss,v0),0); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_x(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf_x_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_y(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf_y_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_z(HMGL gr, HCDT a, const char *sch, double sv, const char *opt) +{ + mreal r = gr->SaveState(opt); + long Num = (mgl_isnan(r) || r<=0) ? 7:long(r+0.5); + mglData v(Num); v.Fill(gr->Min.c, gr->Max.c); + mgl_contf_z_val(gr,&v,a,sch,sv,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_contf_x_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_x(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +/// Draw several contour plots for data a at y = *sv +void MGL_EXPORT mgl_contf_y_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_y(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +/// Draw several contour plots for data a at z = *sv +void MGL_EXPORT mgl_contf_z_(uintptr_t *gr, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_z(_GR_, _DA_(a), s, *sv, o); delete []o; delete []s; } +/// Draw contour plots for data a at x = *sv +void MGL_EXPORT mgl_contf_x_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_x_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s;} +/// Draw contour plots for data a at y = *sv +void MGL_EXPORT mgl_contf_y_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_y_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s;} +/// Draw contour plots for data a at z = *sv +void MGL_EXPORT mgl_contf_z_val_(uintptr_t *gr, uintptr_t *v, uintptr_t *a, const char *sch, mreal *sv, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_contf_z_val(_GR_, _DA_(v), _DA_(a), s, *sv, o); delete []o; delete []s;} +//----------------------------------------------------------------------------- diff --git a/src/parser.cpp b/src/parser.cpp new file mode 100644 index 0000000..2b61cda --- /dev/null +++ b/src/parser.cpp @@ -0,0 +1,1039 @@ +/*************************************************************************** + * parse.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/parser.h" +#include "mgl2/canvas_cf.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +#ifdef WIN32 +#include +wchar_t *wcstokw32(wchar_t *wcs, const wchar_t *delim) { return wcstok(wcs,delim); } +#define wcstok(a,b,c) wcstokw32(a,b) +#else +#include +#endif +MGL_EXPORT void (*mgl_ask_func)(const wchar_t *, wchar_t *)=0; +void MGL_EXPORT mgl_ask_gets(const wchar_t *quest, wchar_t *res) +{ printf("%ls\n",quest); if(!fgetws(res,1024,stdin)) *res=0; } +//----------------------------------------------------------------------------- +mglFunc::mglFunc(const mglFunc &f) +{ pos=f.pos; narg=f.narg; func=f.func; } +mglFunc::mglFunc(long p, const wchar_t *f) +{ + pos = p; func = f; + size_t i; + for(i=0;(isalnum(f[i]) || f[i]=='_');i++); + narg = wcstol(f+i+1,0,0); func = func.substr(0,i); + if(narg<0 || narg>9) narg=0; +} +//----------------------------------------------------------------------------- +long mglParser::IsFunc(const std::wstring &name, int *na) +{ + for(size_t i=0;i' ') return; + register long i; + for(i=4;line[i]<=' ' || line[i]=='\'';i++); + func.push_back(mglFunc(num-1, line+i)); +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT wchar_t *mgl_str_copy(const char *s) +{ + register size_t i,l=strlen(s); + wchar_t *str = new wchar_t[l+1]; + for(i=0;iname, bb->name); +} +//----------------------------------------------------------------------------- +bool mgl_check_for_name(const std::wstring &s) +{ + return !isalpha(s[0])||s.find_first_of(L".:()")!=std::wstring::npos; +} +//----------------------------------------------------------------------------- +mglCommand *mglParser::FindCommand(const char *com) +{ + if(!AllowFileIO && ( !strncmp(com,"read",4) || !strncmp(com,"save",4) || !strcmp(com,"fgets") || !strcmp(com,"import") || !strcmp(com,"export") )) + return 0; + mglCommand tst, *rts, *cmd = Cmd; + long i; + for(i=0;cmd[i].name[0];i++); // determine the number of symbols + tst.name = com; + rts = (mglCommand *) bsearch(&tst, cmd, i, sizeof(mglCommand), mgl_cmd_cmp); + return rts; +} +//----------------------------------------------------------------------------- +mglCommand *mglParser::FindCommand(const wchar_t *com) +{ + size_t s = 15type==6) return 2; + if(rts->type == 4) + { + if(n<1 || mgl_check_for_name(var)) return 2; + mglVar *v = AddVar(var.c_str()); + v->Create(1,1,1); + a[0].type = 0; a[0].d = v; + a[0].w = var; k[0] = 'd'; + } + char *o=0; + if(opt && *opt) // TODO: parse arguments of options + { + long len = mgl_wcslen(opt); + o = new char[len+1]; + for(i=0;iexec(gr, n, a, k.c_str(), o); + if(o) delete []o; + return res; +} +//----------------------------------------------------------------------------- +void mglNum::MoveAfter(mglNum *var) +{ + if(prev) prev->next = next; + if(next) next->prev = prev; + prev = next = 0; + if(var) + { prev = var; next = var->next; var->next = this; } + if(next) next->prev = this; +} +//----------------------------------------------------------------------------- +mglNum::~mglNum() +{ + if(prev) prev->next = next; + if(next) next->prev = prev; +} +//----------------------------------------------------------------------------- +mglParser::mglParser(bool setsize) +{ + DataList=0; NumList=0; +// wchar_t *par[40]; ///< Parameter for substituting instead of $1, ..., $9 + InUse = 1; + Skip=Stop=for_br=false; + memset(for_stack,0,40*sizeof(int)); + memset(if_stack,0,40*sizeof(int)); + memset(if_for,0,40*sizeof(int)); + if_pos=for_addr=0; + for(long i=0;i<40;i++) par[i]=L""; + + Cmd = mgls_base_cmd; + AllowSetSize=setsize; AllowFileIO=true; + Once = true; + fval = new mglData[40]; +} +//----------------------------------------------------------------------------- +mglParser::~mglParser() +{ + DeleteAll(); delete []fval; + if(Cmd && Cmd!=mgls_base_cmd) delete []Cmd; +} +//----------------------------------------------------------------------------- +void mglParser::DeleteAll() +{ + if(DataList) + { + while(DataList->next) delete DataList->next; + delete DataList; DataList = 0; + } + if(NumList) + { + while(NumList->next) delete NumList->next; + delete NumList; NumList = 0; + } +} +//----------------------------------------------------------------------------- +void mglParser::AddParam(int n, const char *str) +{ + MGL_TO_WCS(str,AddParam(n,wcs)); +} +//----------------------------------------------------------------------------- +int mglParser::Parse(mglGraph *gr, const char *str, long pos) +{ + int r=0; + MGL_TO_WCS(str,r = Parse(gr,wcs,pos)); + return r; +} +//----------------------------------------------------------------------------- +mglVar *mglParser::AddVar(const char *str) +{ + mglVar *v=0; + MGL_TO_WCS(str,v = AddVar(wcs)); + return v; +} +//----------------------------------------------------------------------------- +mglVar *mglParser::FindVar(const char *str) +{ + if(!str || *str==0) return DataList; + mglVar *v=DataList; + MGL_TO_WCS(str,v = FindVar(wcs)); + return v; +} +//----------------------------------------------------------------------------- +mglNum *mglParser::AddNum(const char *str) +{ + mglNum *v=0; + MGL_TO_WCS(str,v = AddNum(wcs)); + return v; +} +//----------------------------------------------------------------------------- +mglNum *mglParser::FindNum(const char *str) +{ + mglNum *v=0; + MGL_TO_WCS(str,v = FindNum(wcs)); + return v; +} +//----------------------------------------------------------------------------- +void mglParser::AddParam(int n, const wchar_t *str) +{ +// if(str && n>=0 && n<40 && !wcschr(str,'$')) par[n] = str; + if(str && n>=0 && n<40) par[n] = str; +} +//----------------------------------------------------------------------------- +mglVar *mglParser::FindVar(const wchar_t *name) +{ + if(!name || *name==0) return DataList; + mglVar *v=DataList; + while(v) + { + if(v->s==name) return v; + v = v->next; + } + return 0; +} +//----------------------------------------------------------------------------- +mglVar *mglParser::AddVar(const wchar_t *name) +{ + mglVar *v = FindVar(name); + if(v) return v; + v = new mglVar; v->s = name; + if(DataList) v->MoveAfter(DataList); + else DataList = v; + return v; +} +//----------------------------------------------------------------------------- +mglNum *mglParser::FindNum(const wchar_t *name) +{ + mglNum *v=NumList; + while(v) + { + if(v->s==name) return v; + v = v->next; + } + return 0; +} +//----------------------------------------------------------------------------- +mglNum *mglParser::AddNum(const wchar_t *name) +{ + mglNum *v = FindNum(name); + if(v) return v; + v = new mglNum; v->s = name; + if(NumList) v->MoveAfter(NumList); + else NumList = v; + return v; +} +//----------------------------------------------------------------------------- +int mglFindArg(const std::wstring &str) +{ + register long l=0,k=0,i; + for(i=0;ii1) + { + mglData d = mglFormulaCalc(w.substr(i1,i-i1-(w[i]=='\''?1:0)), this, DataList); + mglprintf(buf,32,L"%g",d.a[0]); a[n-1].w += buf; + } + } + else a[n-1].w += w[i]; + } + } + else if(arg[n][0]=='{') + { // this is temp data + u=new mglVar; u->temp=true; + std::wstring s = arg[n].substr(1,arg[n].length()-2); + a[n-1].w = L"/*"+s+L"*/"; + if(DataList) u->MoveAfter(DataList); + else DataList = u; + a[n-1].type = 0; a[n-1].d = u; + ParseDat(gr, s, *u); + } + else if((v = FindVar(arg[n].c_str()))!=0) // have to find normal variables (for data creation) + { a[n-1].type=0; a[n-1].d=v; a[n-1].w=v->s; } + else if((f = FindNum(arg[n].c_str()))!=0) // have to find normal variables (for data creation) + { a[n-1].type=2; a[n-1].d=0; a[n-1].v=f->d; a[n-1].w = f->s; } + else + { // parse all numbers and formulas by unified way + mglData d = mglFormulaCalc(arg[n], this, DataList); + if(d.nx*d.ny*d.nz==1) + { a[n-1].type = 2; a[n-1].v = d.a[0]; } + else + { + u=new mglVar; u->temp=true; u->Set(d); + a[n-1].w = L"/*"+arg[n]+L"*/"; + if(DataList) u->MoveAfter(DataList); + else DataList = u; + a[n-1].type = 0; a[n-1].d = u; + } + } + } +} +//----------------------------------------------------------------------------- +// return values: 0 - not found, 1 - OK, 2 - wrong arguments, 3 - wrong command, 4 - string too long +int mglParser::PreExec(mglGraph *, long k, std::wstring *arg, mglArg *a) +{ + long n=0; + mglVar *v; + if(!arg[0].compare(L"delete") && k==2) // parse command "delete" + { + DeleteVar(arg[1].c_str()); n=1; + } + else if(!arg[0].compare(L"list")) // parse command "list" + { + if(k<3 || mgl_check_for_name(arg[1])) return 2; + long nx=0, ny=1,j=0,i,t=0; + char ch; + for(i=2;inx ? j:nx; j=0; ny++; } + } + v = AddVar(arg[1].c_str()); + if(t==1) nx = j>nx ? j:nx; + if(t==1) // list of numeric values + { + v->Create(nx,ny); + j=t=0; + for(i=2;ia[j+nx*t] = a[i-1].v; j++; } + } + } + if(t==2) // list of data + { + mglData *b = a[1].d; + long nn = 0; + if(b->nz>1) return 2; + if(b->ny>1) + { + v->Create(b->nx, b->ny, nx); + nn = b->nx*b->ny; + for(i=2,j=0;inx*b->ny) continue; + memcpy(v->a+j*nn,b->a,nn*(b->nz)*sizeof(mreal)); + j+=b->nz; + } + } + else + { + v->Create(b->nx, nx); + nn = b->nx; + for(i=2,j=0;inx) continue; + memcpy(v->a+j*nn,b->a,nn*(b->ny)*sizeof(mreal)); + j+=b->ny; + } + } + } + n=1; + } + return n; +} +//----------------------------------------------------------------------------- +void mglParser::PutArg(std::wstring &str, bool def) +{ + size_t pos = str.find('$',def?10:0); + while(pos='0' && ch<='9') str.replace(pos,2,par[ch-'0']); + if(ch>='a' && ch<='z') str.replace(pos,2,par[ch-'a'+10]); + if(ch=='$') str.replace(pos,2,L"\xffff"); + pos = str.find('$',def?10:0); + } + while((pos = str.find(L'\xffff'))' ') break; + for(i=n;i>k;i--) if(str[i-1]>' ') break; + return str.substr(k,i-k); +} +//----------------------------------------------------------------------------- +int mglParser::ParseDef(std::wstring &str) +{ + if(!skip() && !str.compare(0,3,L"def") && (str[6]==' ' || str[6]=='\t')) + { + int res = 1; mreal d; + PutArg(str,true); + const std::wstring s = mgl_trim_ws(str.substr(7)); + if(!str.compare(3,3,L"ine")) + { + int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); + if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) + { + AddParam(nn, mgl_trim_ws(s.substr(2)).c_str()); return 1; + } + } + if(!str.compare(3,3,L"num")) + { + int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); + if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) + { + res = 0; + d = mglFormulaCalc(mgl_trim_ws(s.substr(2)), this, DataList).a[0]; + char buf[32]; snprintf(buf,32,"%g",d); AddParam(nn, buf); + } + return res+1; + } + if(!str.compare(3,3,L"chr")) + { + int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); + if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) + { + res = 0; + d=mglFormulaCalc(mgl_trim_ws(s.substr(2)), this, DataList).a[0]; + wchar_t buf[2]={0,0}; buf[0] = wchar_t(d); AddParam(nn, buf); + } + return res+1; + } + } + if(!skip() && !str.compare(0,3,L"ask") && (str[3]==' ' || str[3]=='\t')) + { + PutArg(str,true); + std::wstring s = mgl_trim_ws(str.substr(4)); + int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); + if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) + { + static wchar_t res[1024]; + s = mgl_trim_ws(s.substr(2)); + if(s[0]=='\'') s=s.substr(1,s.length()-2); + if(mgl_ask_func) + { mgl_ask_func(s.c_str(),res); if(*res) AddParam(nn, res); } + return mgl_ask_func?1:2; + } + else return 2; + } + if(!skip() && !str.compare(0,3,L"for") && (str[3]==' ' || str[3]=='\t')) + { + size_t i; + for(i=4;str[i]<=' ';i++); + // if command have format 'for $N ...' then change it to 'for N ...' + if(str[i]=='$' && str[i+1]>='0' && str[i+1]<='9') str[i] = ' '; + if(str[i]=='$' && str[i+1]>='a' && str[i+1]<='z') str[i] = ' '; + } + return 0; +} +//----------------------------------------------------------------------------- +// return values: 0 - OK, 1 - wrong arguments, 2 - wrong command, 3 - string too long, 4 -- unclosed string +int mglParser::Parse(mglGraph *gr, std::wstring str, long pos) +{ + if(Stop) return 0; + std::wstring arg[1024]; + str=mgl_trim_ws(str); + long n,k=0,m=0,mm=0,res; + // try parse ':' -- several commands in line + for(n=0;nd = mglFormulaCalc(arg[2],this, DataList).a[0]; + } + delete []a; return k==3?0:1; + } + if(!arg[0].compare(L"call")) + { + n = 1; + if(a[0].type==1) + { + int na=0; + a[0].s.assign(a[0].w.begin(),a[0].w.end()); + n=-IsFunc(a[0].w.c_str(),&na); + if(n && k!=na+2) + { + char buf[64]; + snprintf(buf,64,"Bad arguments for %ls: %ld instead of %d\n", + a[0].w.c_str(),k-2,na); + gr->SetWarn(-1,buf); n = 1; + } + else if(n) + { + mglFnStack fn; fn.pos = pos; + for(int i=0;i<10;i++) { fn.par[i] = par[i]; par[i]=L""; } + for(int i=1;iDataList=DataList; prs->NumList=NumList; prs->Cmd=Cmd; + for(i=10;i<30;i++) prs->AddParam(i,par[i].c_str()); + prs->Execute(gr,fp); + for(i=10;i<30;i++) AddParam(i,prs->par[i].c_str()); + DataList=prs->DataList; prs->DataList=0; + NumList =prs->NumList; prs->NumList=0; + prs->Cmd=0; delete prs; fclose(fp); + } + else n=1; + } + } + delete []a; return n; + } + if(!arg[0].compare(L"for")) + { + n = 1; + char ch = arg[1][0]; + int r = ch-'0'; + if(ch>='a' && ch<='z') r = 10+ch-'a'; +// int r = int(a[0].v); + if(arg[1][1]==0 && (r>=0 && r<40)) // TODO: check this + { + if(a[1].type==0) + { + n=0; fval[r] = *(a[1].d); + fval[r].nx *= fval[r].ny*fval[r].nz; + } + else if(a[1].type==2 && a[2].type==2 && a[2].v>a[1].v) + { + mreal step = a[3].type==2?a[3].v:1; + mm = int(step>0 ? (a[2].v-a[1].v)/step : 0); + if(mm>0) + { + n=0; fval[r].Create(mm+1); + for(int ii=0;ii0;i--) + { for_stack[i]=for_stack[i-1]; if_for[i]=if_for[i-1]; } + for_stack[0] = r+1; fval[r].nz = pos; if_for[0]=if_pos; + wchar_t buf[32]; mglprintf(buf,32,L"%g",fval[r].a[0]); + AddParam(r, buf); fval[r].ny = 1; + } + } + delete []a; return n; + } + // alocate new arrays and execute the command itself + n = PreExec(gr, k, arg, a); + if(n>0) n--; + else if(!arg[0].compare(L"setsize") && !AllowSetSize) n = 2; + else n = Exec(gr, arg[0].c_str(),k-1,a, arg[1].c_str(), opt.c_str()); + delete []a; + } + mglVar *v = DataList, *u; + while(v) // remove temporary data arrays + { + u = v->next; + if(v->temp) { if(DataList==v) DataList = v->next; delete v; } + v = u; + } + return n; +} +//----------------------------------------------------------------------------- +// return values: 0 - OK, 1 - wrong arguments, 2 - wrong command, 3 - string too long, 4 -- unclosed string +int mglParser::ParseDat(mglGraph *gr, std::wstring str, mglData &res) +{ + std::wstring arg[32]; + str = mgl_trim_ws(str); + long n,k=0; + for(k=0;k<32;k++) // parse string to substrings (by spaces) + { + n = mglFindArg(str); + if(n<1) { if(n<0) str=str.substr(0,-n); break; } + arg[k] = str.substr(0,n);// k++; + str = str.substr(n+1); str = mgl_trim_ws(str); + } + // try to find last argument + if(!str.empty()) { arg[k] = str; k++; } + if(k<1) n =0; + else + { // fill arguments by its values + mglArg *a = new mglArg[k+1]; + FillArg(gr, k, arg, a+1); a[0].type=0; a[0].d=&res; + // alocate new arrays and execute the command itself + int i; + std::string kk; + const char *id="dsn"; + for(i=0;itype!=4) n = 2; + else n = rts->exec(gr, k, a, kk.c_str(), 0); + delete []a; + } + return n; +} +//----------------------------------------------------------------------------- +int mglParser::FlowExec(mglGraph *, const std::wstring &com, long m, mglArg *a) +{ + int n=-1; + if(!ifskip() && !com.compare(L"once")) + { + if(a[0].type==2) + { + n = 0; + if(a[0].v) Skip = !Once; + else Skip = Once = false; + } + else n = 1; + } + else if(!Skip && !com.compare(L"if")) + { + int cond; + if(a[0].type==2) + { n = 0; cond = (a[0].v!=0)?3:0; } + else if(a[0].type==0) + { + n = 0; a[1].s.assign(a[1].w.begin(),a[1].w.end()); + cond = a[0].d->FindAny((m>1 && a[1].type==1) ? a[1].s.c_str():"u")?3:0; + } + else n = 1; + if(n==0) + { if_stack[if_pos] = cond; if_pos = if_pos<39 ? if_pos+1 : 39; } + } + else if(!Skip && !com.compare(L"endif")) + { if_pos = if_pos>0 ? if_pos-1 : 0; n = 0; } + else if(!Skip && !com.compare(L"else")) + { + if(if_pos>0) + { n=0; if_stack[if_pos-1] = (if_stack[if_pos-1]&2)?2:3; } + else n = 1; + } + else if(!Skip && !com.compare(L"elseif")) + { + int cond; + if(if_pos<1 || m<1) n = 1; + else if(if_stack[if_pos-1]&2) { n = 0; cond = 2; } + else if(a[0].type==2) + { n = 0; cond = (a[0].v!=0)?3:0; } + else if(a[0].type==0) + { + n = 0; a[1].s.assign(a[1].w.begin(),a[1].w.end()); + cond = a[0].d->FindAny((m>1 && a[1].type==1) ? a[1].s.c_str():"u")?3:0; + } + else n = 1; + if(n==0) if_stack[if_pos-1] = cond; + } + else if(!ifskip() && !Skip && !com.compare(L"break")) + { + if(if_pos==if_for[0]) if_pos = if_pos>0 ? if_pos-1 : 0; + } + else if(!skip() && !com.compare(L"return")) + { + if(fn_stack.size()<1) return 2; + const mglFnStack &fn=fn_stack.back(); + for(int i=0;i<10;i++) par[i]=fn.par[i]; + n = -fn.pos-1; fn_stack.pop_back(); + } + else if(!ifskip() && !Skip && !com.compare(L"next")) + { + if(if_pos==if_for[0]) if_pos = if_pos>0 ? if_pos-1 : 0; + int r = for_stack[0]-1; + n = for_stack[0] ? 0:1; + if(for_stack[0]) + { + if(fval[r].ny0 ? if_pos-1 : 0; + int r = for_stack[0]-1; + n = for_stack[0] ? 0:1; + if(for_stack[0]) + { + if(fval[r].ny +void mglParser::Execute(mglGraph *gr, FILE *fp, bool print) +{ + if(gr==0 || fp==0) return; + std::wstring str; + wchar_t ch; + while((ch=fgetwc(fp))!=WEOF) str.push_back(ch); +// while(!feof(fp)) str.push_back(fgetwc(fp)); + Execute(gr,str.c_str()); + if(print) printf("%s\n",gr->Message()); +} +//----------------------------------------------------------------------------- +void mglParser::Execute(mglGraph *gr, int n, const wchar_t **text) +{ + if(n<1 || text==0) return; + long i, r, res=0; + char buf[64]; + for_br=Skip=false; if_pos=0; ScanFunc(0); fn_stack.clear(); + for(i=0;iSetWarn(-1, ""); + gr->SetObjId(i+1); + r = Parse(gr,text[i],i+1); + if(r<0) { i = -r-2; continue; } + if(r==1) snprintf(buf,64,"\nWrong argument(s) in line %ld\n", i+1); + else if(r==2) snprintf(buf,64,"\nWrong command in line %ld\n", i+1); + else if(r==3) snprintf(buf,64,"\nString too long in line %ld\n", i+1); + else if(r==4) snprintf(buf,64,"\nUnbalanced ' in line %ld\n", i+1); + else if(gr->GetWarn()>0) snprintf(buf,64," in line %ld\n", i+1); + else *buf=0; + if(*buf) gr->SetWarn(-2,buf); + if(r>0 && r<5) res=r; + } + int code[]={mglScrArg, mglScrCmd, mglScrLong, mglScrStr}; + if(res>0) gr->SetWarn(code[res-1],"MGL Parser"); +} +//----------------------------------------------------------------------------- +void mglParser::Execute(mglGraph *gr, const wchar_t *text) +{ + size_t s = mgl_wcslen(text)+1, n=1; + wchar_t *wcs = new wchar_t[s]; + const wchar_t **str; + for(size_t i=0;i' ')next = 0; + if(text[i]=='\n') + { // if string need to be continued then I but ' ' instead of 0x0 and + // pointer next string to 0x0. Last one for keeping number of strings. + if(next) + { wcs[i]=wcs[next]=' '; str[n] = wcs+s-1; next=0; } + else + { wcs[i]=0; str[n] = wcs+i+1; } + n++; + + } + } + Execute(gr, n, str); + delete []wcs; free(str); +} +//----------------------------------------------------------------------------- +void mglParser::Execute(mglGraph *gr, const char *text) +{ + MGL_TO_WCS(text, Execute(gr, wcs)); +} +//----------------------------------------------------------------------------- +void mglParser::DeleteVar(mglVar *v) +{ + if(!v) return; + if(DataList==v) DataList = v->next; + delete v; +} +//----------------------------------------------------------------------------- +void mglParser::DeleteVar(const char *name) +{ + mglVar *v = FindVar(name); + DeleteVar(v); +} +//----------------------------------------------------------------------------- +void mglParser::DeleteVar(const wchar_t *name) +{ + mglVar *v = FindVar(name); + DeleteVar(v); +} +//----------------------------------------------------------------------------- +void mglParser::AddCommand(mglCommand *cmd, int mc) +{ + int i, mp; + if(mc<1) + { for(i=0;cmd[i].name[0];i++){}; mc = i; } + // determine the number of symbols + for(i=0;Cmd[i].name[0];i++){}; mp = i; + mglCommand *buf = new mglCommand[mp+mc+1]; + memcpy(buf, cmd, mc*sizeof(mglCommand)); + memcpy(buf+mc, Cmd, (mp+1)*sizeof(mglCommand)); + qsort(buf, mp+mc, sizeof(mglCommand), mgl_cmd_cmp); + if(Cmd!=mgls_base_cmd) delete []Cmd; + Cmd = buf; +} +//----------------------------------------------------------------------------- +HMPR MGL_EXPORT mgl_create_parser() { return new mglParser; } +void MGL_EXPORT mgl_delete_parser(HMPR p) { delete p; } +void MGL_EXPORT mgl_parser_add_param(HMPR p, int id, const char *str) { p->AddParam(id,str); } +void MGL_EXPORT mgl_parser_add_paramw(HMPR p, int id, const wchar_t *str) { p->AddParam(id,str); } +HMDT MGL_EXPORT mgl_parser_add_var(HMPR p, const char *name) { mglVar *v=p->AddVar(name); return v; } +HMDT MGL_EXPORT mgl_parser_find_var(HMPR p, const char *name) { mglVar *v=p->FindVar(name); return v; } +void MGL_EXPORT mgl_parser_del_var(HMPR p, const char *name) { p->DeleteVar(name); } +HMDT MGL_EXPORT mgl_parser_add_varw(HMPR p, const wchar_t *name) { mglVar *v=p->AddVar(name); return v; } +HMDT MGL_EXPORT mgl_parser_find_varw(HMPR p, const wchar_t *name) { mglVar *v=p->FindVar(name); return v; } +void MGL_EXPORT mgl_parser_del_varw(HMPR p, const wchar_t *name) { p->DeleteVar(name); } +int MGL_EXPORT mgl_parse_line(HMGL gr, HMPR p, const char *str, int pos) +{ return p->Parse(gr, str, pos); } +int MGL_EXPORT mgl_parse_linew(HMGL gr, HMPR p, const wchar_t *str, int pos) +{ return p->Parse(gr, str, pos); } +void MGL_EXPORT mgl_parse_text(HMGL gr, HMPR p, const char *str) +{ p->Execute(gr, str); } +void MGL_EXPORT mgl_parse_textw(HMGL gr, HMPR p, const wchar_t *str) +{ p->Execute(gr, str); } +void MGL_EXPORT mgl_parse_file(HMGL gr, HMPR p, FILE *fp, int print) +{ p->Execute(gr,fp,print); } +void MGL_EXPORT mgl_parser_restore_once(HMPR p) { p->RestoreOnce(); } +void MGL_EXPORT mgl_parser_stop(HMPR p) { p->Stop = true; } +void MGL_EXPORT mgl_parser_allow_setsize(HMPR p, int a) { p->AllowSetSize= a; } +void MGL_EXPORT mgl_parser_allow_file_io(HMPR p, int a) { p->AllowFileIO = a; } +//----------------------------------------------------------------------------- +#define _PR_ ((mglParser *)(*p)) +uintptr_t MGL_EXPORT mgl_create_parser_() { return uintptr_t(new mglParser); } +void MGL_EXPORT mgl_delete_parser_(uintptr_t* p) { delete _PR_; } +void MGL_EXPORT mgl_parser_add_param_(uintptr_t* p, int *id, const char *str, int l) +{ char *s=new char[l+1]; memcpy(s,str,l); s[l]=0; + _PR_->AddParam(*id, s); delete []s; } +/*===!!! NOTE !!! You must not delete obtained data arrays !!!===============*/ +uintptr_t MGL_EXPORT mgl_parser_add_var_(uintptr_t* p, const char *name, int l) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + mglVar *v=_PR_->AddVar(s); delete []s; return uintptr_t(v); } +/*===!!! NOTE !!! You must not delete obtained data arrays !!!===============*/ +uintptr_t MGL_EXPORT mgl_parser_find_var_(uintptr_t* p, const char *name, int l) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + mglVar *v=_PR_->FindVar(s); delete []s; return uintptr_t(v); } +void MGL_EXPORT mgl_parser_del_var_(uintptr_t* p, const char *name, int l) +{ char *s=new char[l+1]; memcpy(s,name,l); s[l]=0; + _PR_->DeleteVar(s); delete []s; } +int MGL_EXPORT mgl_parse_line_(uintptr_t* gr, uintptr_t* p, const char *str, int *pos, int l) +{ char *s=new char[l+1]; memcpy(s,str,l); s[l]=0; + int r = _PR_->Parse(_GR_, s, *pos); delete []s; return r; } +void MGL_EXPORT mgl_parse_text_(uintptr_t* gr, uintptr_t* p, const char *str, int l) +{ char *s=new char[l+1]; memcpy(s,str,l); s[l]=0; + _PR_->Execute(_GR_, s); delete []s; } +void MGL_EXPORT mgl_parser_restore_once_(uintptr_t* p) { _PR_->RestoreOnce(); } +void MGL_EXPORT mgl_parser_allow_setsize_(uintptr_t* p, int *a) { _PR_->AllowSetSize= *a; } +void MGL_EXPORT mgl_parser_allow_file_io_(uintptr_t* p, int *a) { _PR_->AllowFileIO = *a; } +void MGL_EXPORT mgl_parser_stop_(uintptr_t* p) { _PR_->Stop = true; } +//----------------------------------------------------------------------------- +long MGL_EXPORT mgl_use_parser(HMPR pr, int inc) +{ pr->InUse+=inc; return pr->InUse; } +long MGL_EXPORT mgl_use_parser_(uintptr_t *p, int *inc) +{ _PR_->InUse+=*inc; return _PR_->InUse; } +//--------------------------------------------------------------------------- +int MGL_EXPORT mgl_parser_cmd_type(HMPR pr, const char *name) +{ + mglCommand *cmd = pr->FindCommand(name); + return cmd ? cmd->type + 1 : 0; +} +int MGL_EXPORT mgl_parser_cmd_type_(uintptr_t* p, const char *str, int l) +{ char *s=new char[l+1]; memcpy(s,str,l); s[l]=0; + l = mgl_parser_cmd_type(_PR_, s); delete []s; return l; } +//--------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_parser_cmd_desc(HMPR pr, const char *name) +{ + mglCommand *cmd = pr->FindCommand(name); + return cmd ? cmd->desc : 0; +} +MGL_EXPORT const char *mgl_parser_cmd_frmt(HMPR pr, const char *name) +{ + mglCommand *cmd = pr->FindCommand(name); + return cmd ? cmd->form : 0; +} +//--------------------------------------------------------------------------- +MGL_EXPORT const char *mgl_parser_cmd_name(HMPR pr, long id) +{ return (id=0) ? pr->Cmd[id].name:""; } +long MGL_EXPORT mgl_parser_cmd_num(HMPR pr) +{ register long i=0; while(pr->Cmd[i].name[0]) i++; return i; } +//--------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_parser_calc(HMPR pr, const char *formula) +{ + HMDT d=0; + MGL_TO_WCS(formula,d = mgl_parser_calcw(pr,wcs)); + return d; +} +HMDT MGL_EXPORT mgl_parser_calcw(HMPR pr, const wchar_t *formula) +{ mglData *d = new mglData(mglFormulaCalc(formula,pr, pr->DataList)); return d; } +uintptr_t MGL_EXPORT mgl_parser_calc_(uintptr_t *p, const char *str,int l) +{ char *s=new char[l+1]; memcpy(s,str,l); s[l]=0; + uintptr_t d = (uintptr_t)mgl_parser_calc(_PR_, s); delete []s; return d; } +//--------------------------------------------------------------------------- +void MGL_EXPORT mgl_parser_del_all(HMPR p) { p->DeleteAll(); } +void MGL_EXPORT mgl_parser_del_all_(uintptr_t *p) { _PR_->DeleteAll(); } +//--------------------------------------------------------------------------- diff --git a/src/pde.cpp b/src/pde.cpp new file mode 100644 index 0000000..6dc1b2c --- /dev/null +++ b/src/pde.cpp @@ -0,0 +1,829 @@ +/*************************************************************************** + * pde.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/data.h" +#include "mgl2/datac.h" +#include "mgl2/eval.h" +#include "mgl2/thread.h" +#include "mgl2/base.h" +#define GAMMA 0.1 +//----------------------------------------------------------------------------- +struct mgl_pde_ham +{ + dual *a,*hxy,*hxv,*huv,*huy; + mglFormula *eqs; + long nx,ny; + mreal xx,yy,xs,ys,dx,dy,dq,dp,zz; + double dd; +}; +MGL_NO_EXPORT void *mgl_pde_hprep(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + const mgl_pde_ham *f = (const mgl_pde_ham *)t->v; + mglFormula *eqs = f->eqs; + long nx=2*f->nx, ny=2*f->ny; + dual *a = f->a; + +#if !MGL_HAVE_PTHREAD +#pragma omp parallel +#endif + { + mreal var[MGL_VS]; memset(var,0,MGL_VS*sizeof(mreal)); + var['z'-'a'] = f->zz; +#pragma omp for nowait + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i = i0%nx, j = i0/nx; var['u'-'a'] = abs(a[i0]); + var['x'-'a'] = f->xx+f->dx*i; var['p'-'a'] = 0; + var['y'-'a'] = f->yy+f->dy*j; var['q'-'a'] = 0; + f->hxy[i0] = dual(-eqs->CalcD(var,'i'), eqs->Calc(var))*f->dd; + } + if(f->ny>2) +#pragma omp for nowait + for(long i0=t->id;i0n;i0+=mglNumThr) // step 3/2 + { + register long i = i0%nx, j = i0/nx; var['u'-'a'] = abs(a[i0]); + var['x'-'a'] = f->xs; var['p'-'a'] = f->dp*(iyy+f->dy*j; var['q'-'a'] = 0; + f->huy[i0] = dual(-eqs->CalcD(var,'i'), eqs->Calc(var))*f->dd; + } +#pragma omp for nowait + for(long i0=t->id;i0n;i0+=mglNumThr) // step 2 + { + register long i = i0%nx, j = i0/nx; var['u'-'a'] = abs(a[i0]); + var['x'-'a'] = f->xs; var['p'-'a'] = f->dp*(iys; var['q'-'a'] = f->dq*(jhuv[i0] = dual(-eqs->CalcD(var,'i'), eqs->Calc(var))*f->dd; + } + if(f->ny>2) +#pragma omp for nowait + for(long i0=t->id;i0n;i0+=mglNumThr) // step 3/2 + { + register long i = i0%nx, j = i0/nx; var['u'-'a'] = abs(a[i0]); + var['x'-'a'] = f->xx+f->dx*i; var['p'-'a'] = 0; + var['y'-'a'] = f->ys; var['q'-'a'] = f->dq*(jhxv[i0] = dual(-eqs->CalcD(var,'i'), eqs->Calc(var))*f->dd; + } + } + return 0; +} +//----------------------------------------------------------------------------- +// Solve equation dx/dz = func(p,q,x,y,z,|u|)[u] where p=d/dx, q=d/dy. At this moment simplified form of ham is supported: ham = f(p,q,z) + g(x,y,z,'u'), where variable 'u'=|u| (for allowing solve nonlinear problems). You may specify imaginary part like ham = p^2 + i*x*(x>0) but only if dependence on variable 'i' is linear (i.e. ham = hre+i*him). +HADT MGL_EXPORT mgl_pde_solve_c(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt) +{ + gr->SaveState(opt); + mglPoint Min=gr->Min, Max=gr->Max; + long nx=ini_re->GetNx(), ny=ini_re->GetNy(), nz = long((Max.z-Min.z)/dz)+1; + if(nx<2 || nz<2 || Max.x==Min.x) // Too small data + { gr->SetWarn(mglWarnLow,"PDE"); return 0; } + if(ini_im->GetNx()*ini_im->GetNy() != nx*ny)// Wrong dimensions + { gr->SetWarn(mglWarnDim,"PDE"); return 0; } + mglDataC *res=new mglDataC(nz, nx, ny); + + mglFormula eqs(ham); + dual *a = new dual[4*nx*ny], hh0; // Add "damping" area + dual *hxy = new dual[4*nx*ny], *hxv = new dual[4*nx*ny]; + dual *huy = new dual[4*nx*ny], *huv = new dual[4*nx*ny]; + dual *hx = new dual[2*nx], *hv = new dual[2*ny]; + dual *hy = new dual[2*ny], *hu = new dual[2*nx]; + mreal *dmp = new mreal[4*nx*ny]; + memset(a,0,4*nx*ny*sizeof(dual)); + memset(dmp,0,4*nx*ny*sizeof(mreal)); +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,j), ini_im->v(i,j)); + res->a[nz*(i+nx*j)] = a[i0]; + } +#pragma omp parallel for collapse(2) + for(long j=0;j<2*ny;j++) for(long i=0;i<2*nx;i++) // step 1 + { + register long i0 = i+2*nx*j; + if(i3*nx/2) dmp[i0] += GAMMA*mgl_ipow((i-3*nx/2-1)/(nx/2.),2); + if(j3*ny/2) dmp[i0] += GAMMA*mgl_ipow((j-3*ny/2-1)/(ny/2.),2); + } + mreal dx = (Max.x-Min.x)/(nx-1), dy = ny>1?(Max.y-Min.y)/(ny-1):0; + mreal dp = M_PI/(Max.x-Min.x)/k0, dq = M_PI/(Max.y-Min.y)/k0; + mreal xs=(Min.x+Max.x)/2, ys=(Min.y+Max.y)/2; +// double xx = Min.x - dx*nx/2, yy = Min.x - dy*ny/2; + double dd = k0*dz; + + mgl_pde_ham tmp;tmp.eqs = &eqs; + tmp.nx = nx; tmp.ny = ny; tmp.dd = dd; tmp.a=a; + tmp.hxy=hxy; tmp.hxv=hxv; tmp.huy=huy; tmp.huv=huv; + tmp.xx = Min.x-dx*(nx/2); tmp.xs = xs; tmp.dx = dx; tmp.dp = dp; + tmp.yy = Min.y-dy*(ny/2); tmp.ys = ys; tmp.dy = dy; tmp.dq = dq; + + // prepare fft. NOTE: slow procedures due to unknown nx, ny. + void *wtx = mgl_fft_alloc(2*nx,0,0); + void *wty = mgl_fft_alloc(2*ny,0,0); + for(long k=1;kStop) continue; + tmp.zz = Min.z+dz*k; + memset(hxy,0,4*nx*ny*sizeof(dual)); memset(hxv,0,4*nx*ny*sizeof(dual)); + memset(huv,0,4*nx*ny*sizeof(dual)); memset(huy,0,4*nx*ny*sizeof(dual)); + mglStartThread(mgl_pde_hprep,0,4*nx*ny,0,0,0,0,&tmp); +#pragma omp parallel for + for(long i=0;i<2*nx;i++) { hx[i] = hxv[i]; hu[i] = huv[i]; } +#pragma omp parallel for + for(long j=0;j<2*ny;j++) { hy[j] = huy[2*nx*j]; hv[j] = huv[2*nx*j];} + // rearrange arrays + hh0=hu[0]; + if(ny>1) +#pragma omp parallel for collapse(2) + for(long i=0;i<2*nx;i++) for(long j=0;j<2*ny;j++) + { + register long i0 = i+2*nx*j; huv[i0] -= hh0; + hxv[i0] -= hx[i]+hv[j]-hh0; + huy[i0] -= hu[i]+hy[j]-hh0; + } + else +#pragma omp parallel for + for(long i=0;i<4*nx*ny;i++) huv[i] -= hh0; + // solve equation + if(ny>1) +#pragma omp parallel + { + void *wsx = mgl_fft_alloc_thr(2*nx), *wsy = mgl_fft_alloc_thr(2*ny); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(hxy[i])*exp(-double(dmp[i]*dz)); +#pragma omp for + for(long i=0;i<2*ny;i++) mgl_fft((double *)(a+i*2*nx), 1, 2*nx, wtx, wsx, false); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(huy[i]); +#pragma omp for + for(long i=0;i<2*nx;i++) mgl_fft((double *)(a+i), 2*nx, 2*ny, wty, wsy, false); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(huv[i]); +#pragma omp for + for(long i=0;i<2*ny;i++) mgl_fft((double *)(a+2*i*nx), 1, 2*nx, wtx, wsx, true); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(hxv[i]); +#pragma omp for + for(long i=0;i<2*nx;i++) mgl_fft((double *)(a+i), 2*nx, 2*ny, wty, wsy, true); + mgl_fft_free_thr(wsx); mgl_fft_free_thr(wsy); + } + else +#pragma omp parallel + { + void *wsx = mgl_fft_alloc_thr(2*nx); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(hxy[i])*exp(-double(dmp[i]*dz)); +#pragma omp for + for(long i=0;i<2*ny;i++) mgl_fft((double *)(a+i*2*nx), 1, 2*nx, wtx, wsx, false); +#pragma omp for + for(long i=0;i<4*nx*ny;i++) a[i] *= exp(huv[i]); +#pragma omp for + for(long i=0;i<2*ny;i++) mgl_fft((double *)(a+2*i*nx), 1, 2*nx, wtx, wsx, true); + mgl_fft_free_thr(wsx); + } +#pragma omp parallel for collapse(2) + for(long i=0;ia[k+nz*(i+nx*j)] = a[i+nx/2+2*nx*(j+ny/2)]; + } + mgl_fft_free(wtx,0,0); mgl_fft_free(wty,0,0); + delete []a; delete []dmp; + delete []hxy; delete []hxv; delete []huy; delete []huv; + delete []hx; delete []hy; delete []hu; delete []hv; + gr->LoadState(); + return res; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_pde_solve(HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt) +{ + HADT res = mgl_pde_solve_c(gr,ham,ini_re,ini_im,dz,k0,opt); + HMDT out = mgl_datac_abs(res); delete res; return out; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_ode_solve(void (*func)(const mreal *x, mreal *dx, void *par), int n, mreal *x0, mreal dt, mreal tmax, void *par) +{ + if(tmaxa[i] = x0[i]; + // Runge Kutta scheme of 4th order + for(k=1;ka[i+n*k] = x[i] += (k1[i]+k2[i]+2*k3[i])*dt/6; + } + delete []x; delete []k1; delete []k2; delete []k3; delete []v; + return res; +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_ray3d(const mreal *in, mreal *out, void *par) +{ + mglFormula *eqs = (mglFormula *)par; + const char *v="xyzpqvt"; + mreal var[MGL_VS]; memset(var,0,MGL_VS*sizeof(mreal)); + for(int i=0;i<7;i++) var[v[i]-'a'] = in[i]; + out[0] = eqs->CalcD(var,'p'); out[3] = -eqs->CalcD(var,'x'); + out[1] = eqs->CalcD(var,'q'); out[4] = -eqs->CalcD(var,'y'); + out[2] = eqs->CalcD(var,'v'); out[5] = -eqs->CalcD(var,'z'); + out[7] = eqs->CalcD(var,'i'); out[6] = 1; +} +// Solve GO ray equation like dr/dt = d ham/dp, dp/dt = -d ham/dr where ham = ham(x,y,z,p,q,v,t) and px=p, py=q, pz=v. The starting point (at t=0) is r0, p0. Result is array of {x,y,z,p,q,v,t} +HMDT MGL_EXPORT mgl_ray_trace(const char *ham, mreal x0, mreal y0, mreal z0, mreal px, mreal py, mreal pz, mreal dt, mreal tmax) +{ + mglFormula eqs(ham); + mreal in[8]={x0,y0,z0,px,py,pz,0,0}; + HMDT res = mgl_ode_solve(mgl_ray3d,8,in,dt,tmax,&eqs); + mgl_data_set_id(res,"xyzpqvti"); + return res; +} +//----------------------------------------------------------------------------- +struct mgl_ap +{ + double x0,y0,z0,x1,y1,z1,x2,y2,z2; // vectors {l, g1, g2} + double t1,t2,ch,q1,q2,pt,dt,d1,d2; // theta_{1,2}, chi, q_{1,2}, p_t, dtau, dq_{1,2} + mgl_ap() { memset(this,0,sizeof(mgl_ap)); } +}; +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_init_ra(int n, int n7, const mreal *r, mgl_ap *ra) // prepare some intermediate data for QO (3d case) +{ + register double tt; + tt = hypot(r[n7]-r[0], r[n7+1]-r[1]); + if(tt) + { + ra[0].x1 = (r[n7+1]-r[1])/tt; + ra[0].y1 = (r[0]-r[n7])/tt; + ra[0].z1 = 0; + } + else { ra[0].x1 = ra[0].y1 = 0; ra[0].z1 = 1; } + ra[0].x0 = r[n7] - r[0]; ra[0].y0 = r[n7+1] - r[1]; ra[0].z0 = r[n7+2] - r[2]; + tt = sqrt(ra[0].x0*ra[0].x0 + ra[0].y0*ra[0].y0 + ra[0].z0*ra[0].z0); + ra[0].x0 /= tt; ra[0].y0 /= tt; ra[0].z0 /= tt; + ra[0].x2 = ra[0].y1*ra[0].z0 - ra[0].y0*ra[0].z1; // vector g_2 + ra[0].y2 = ra[0].z1*ra[0].x0 - ra[0].z0*ra[0].x1; + ra[0].z2 = ra[0].x1*ra[0].y0 - ra[0].x0*ra[0].y1; + register long i; + for(i=1;iv; + mgl_ap *ra = f->ra; + + const mreal *r = f->r; + long nx=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=t->id;idr, hh = 1 - ra->t1*x1; + hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + register mreal tt = (ra->pt + ra->d1*x1)/hh - ra->pt; + f->hx[i] = f->ham(abs(f->a[i]), r[0]+ra->x1*x1, r[1]+ra->y1*x1, r[3]+ra->x0*tt, r[4]+ra->y0*tt, f->par) - f->h0/2.; + // u-y terms + x1 = f->dk/2*(ihu[i] = f->ham(0, r[0], r[1], r[3]+ra->x1*x1, r[4]+ra->y1*x1, f->par) - f->h0/2.; + + if(imag(f->hx[i])>0) f->hx[i] = f->hx[i].real(); + if(imag(f->hu[i])>0) f->hu[i] = f->hu[i].real(); + // add boundary conditions for x-direction + f->hx[i] -= dual(0,f->dmp[i]); + } + return 0; +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_qo2d_func_c(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy) +{ + const mglData *ray=dynamic_cast(ray_dat); // NOTE: Ray must be mglData! + if(!ray) return 0; + long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; + if(nx<2 || ini_im->GetNx()!=nx || nt<2) return 0; + mglDataC *res=new mglDataC(nx,nt,1); + + dual *a=new dual[2*nx], *hu=new dual[2*nx], *hx=new dual[2*nx]; + double *dmp=new double[2*nx]; + mgl_ap *ra = new mgl_ap[nt]; mgl_init_ra(nt, n7, ray->a, ra); // ray + + mreal dr = r/(nx-1), dk = M_PI*(nx-1)/(k0*r*nx); + memset(dmp,0,2*nx*sizeof(double)); +#pragma omp parallel for + for(long i=0;iv(i),ini_im->v(i)); // init + void *wsx, *wtx = mgl_fft_alloc(2*nx,&wsx,1); + if(xx && yy) { xx->Create(nx,nt); yy->Create(nx,nt); } + + mgl_qo2d_ham tmp; // parameters for Hamiltonian calculation + tmp.hx=hx; tmp.hu=hu; tmp.dmp=dmp; tmp.par=par; + tmp.dr=dr; tmp.dk=dk; tmp.ham=ham; tmp.a=a; + // start calculation + for(long k=0;ka[i+k*nx]=a[i+nx/2]*sqrt(ra[0].ch/ra[k].ch); + if(xx && yy) +#pragma omp parallel for + for(long i=0;ia[i+k*nx] = ray->a[n7*k] + ra[k].x1*x1; // new coordinates + yy->a[i+k*nx] = ray->a[n7*k+1] + ra[k].y1*x1; + } + tmp.r=ray->a+n7*k; tmp.ra=ra+k; + mreal hh = ra[k].pt*(1/sqrt(sqrt(1.041))-1); // 0.041=0.45^4 -- minimal value of h + tmp.h0 = ham(0, tmp.r[0], tmp.r[1], tmp.r[3]+ra[k].x0*hh, tmp.r[4]+ra[k].x0*hh, par); + mglStartThread(mgl_qo2d_hprep,0,2*nx,0,0,0,0,&tmp); + // Step for field + dual dt = dual(0, -ra[k].dt*k0); +#pragma omp parallel for + for(long i=0;i<2*nx;i++) a[i] *= exp(hx[i]*dt); + mgl_fft((double *)a, 1, 2*nx, wtx, wsx, false); +#pragma omp parallel for + for(long i=0;i<2*nx;i++) a[i] *= exp(hu[i]*dt); + mgl_fft((double *)a, 1, 2*nx, wtx, wsx, true); + +/* // Calculate B1 // TODO make more general scheme later!!! + hh = ra[k].pt*(1/sqrt(sqrt(1.041))-1); + var['x'-'a'] = ray->a[n7*k]; // new coordiantes + var['y'-'a'] = ray->a[n7*k+1]; + var['p'-'a'] = ray->a[n7*k+3] + ra[k].x0*hh; // new momentums + var['q'-'a'] = ray->a[n7*k+4] + ra[k].y0*hh; + tt = h.CalcD(var,'p')*ra[k].x1 + h.CalcD(var,'q')*ra[k].y1; + var['x'-'a'] = ray->a[n7*k] + ra[k].x1*dr; // new coordiantes + var['y'-'a'] = ray->a[n7*k+1] + ra[k].y1*dr; + hh = 1 - ra[k].t1*dr; hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + hh = (ra[k].ch*ra[k].pt + ra[k].d1*dr)/(hh*ra[k].ch) - ra[k].pt; + var['p'-'a'] = ray->a[n7*k+3] + ra[k].x0*hh; // new momentums + var['q'-'a'] = ray->a[n7*k+4] + ra[k].y0*hh; + B1 = h.CalcD(var,'p')*ra[k].x1 + h.CalcD(var,'q')*ra[k].y1; + B1 = (B1-tt)/dr; + double a1=0, a2=0; + for(i=0;i<2*nx;i++) a1 += norm(a[i]); + hx[0] = hx[2*nx-1] = 0.; + for(i=1;i<2*nx-1;i++) hx[i] = (B1*ra[k].dt*(i-nx))*(a[i+1]-a[i-1]); + for(i=0;i<2*nx;i++) { a[i] += hx[i]; a2 += norm(a[i]); } + a1 = sqrt(a1/a2); + for(i=0;i<2*nx;i++) a[i] *= a1;*/ + } + mgl_fft_free(wtx,&wsx,1); + delete []a; delete []hu; delete []hx; delete []ra; delete []dmp; + return res; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_qo2d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal px, mreal py, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy) +{ + HADT res = mgl_qo2d_func_c(ham,par,ini_re,ini_im,ray_dat,r,k0,xx,yy); + HMDT out = mgl_datac_abs(res); delete res; return out; +} +//----------------------------------------------------------------------------- +dual MGL_NO_EXPORT mgl_ham2d(mreal u, mreal x, mreal y, mreal px, mreal py, void *par) +{ + mglFormula *h = (mglFormula *)par; + mreal var[MGL_VS]; memset(var,0,MGL_VS*sizeof(mreal)); + var['x'-'a'] = x; var['y'-'a'] = y; var['u'-'a'] = u; + var['p'-'a'] = px; var['q'-'a'] = py; + return dual(h->Calc(var), -h->CalcD(var,'i')); +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_qo2d_solve_c(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy) +{ + mglFormula h(ham); + return mgl_qo2d_func_c(mgl_ham2d, &h, ini_re, ini_im, ray_dat, r, k0, xx, yy); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_qo2d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy) +{ + HADT res = mgl_qo2d_solve_c(ham,ini_re,ini_im,ray_dat,r,k0,xx,yy); + HMDT out = mgl_datac_abs(res); delete res; return out; +} +//----------------------------------------------------------------------------- +// +// QO2d series +// +//----------------------------------------------------------------------------- +struct mgl_qo3d_ham +{ + dual *hxy, *huv, *hxv, *huy, *a; + dual *hx, *hy, *hu, *hv, h0; + mreal *dmp; + mreal *r, dr, dk; + mgl_ap *ra; + dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par); + void *par; +}; +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_qo3d_hprep(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v; + mgl_ap *ra = f->ra; + const mreal *r = f->r; + long nx=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long ii=t->id;iidr, x2 = (2*j-nx+1)*f->dr, hh = 1-ra->t1*x1-ra->t2*x2; + hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + register mreal tt = (ra->pt + ra->d1*x1 + ra->d2*x2)/hh - ra->pt; + f->hxy[ii] = f->ham(abs(f->a[i]), r[0]+ra->x1*x1+ra->x2*x2, r[1]+ra->y1*x1+ra->y2*x2, r[2]+ra->z1*x1+ra->z2*x2, r[3]+ra->x0*tt, r[4]+ra->y0*tt, r[5]+ra->z0*tt, f->par); + // x-v terms + x1 = (2*i-nx+1)*f->dr; x2 = f->dk/2*(jt1*x1; + hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + tt = (ra->pt + ra->d1*x1)/hh - ra->pt; + f->hxv[ii] = f->ham(0, r[0]+ra->x1*x1, r[1]+ra->y1*x1, r[2]+ra->z1*x1, r[3]+ra->x0*tt+ra->x2*x2, r[4]+ra->y0*tt+ra->y2*x2, r[5]+ra->z0*tt+ra->z2*x2, f->par); + // u-y terms + x1 = f->dk/2*(idr; hh = 1-ra->t2*x2; + hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + tt = (ra->pt + ra->d2*x2)/hh - ra->pt; + f->huy[ii] = f->ham(0, r[0]+ra->x2*x2, r[1]+ra->y2*x2, r[2]+ra->z2*x2, r[3]+ra->x1*x1+ra->x0*tt, r[4]+ra->y1*x1+ra->y0*tt, r[5]+ra->z1*x1+ra->z0*tt, f->par); + // u-y terms + x1 = f->dk/2*(idk/2*(jhuv[ii] = f->ham(0, r[0], r[1], r[2], r[3]+ra->x1*x1+ra->x2*x2, r[4]+ra->y1*x1+ra->y2*x2, r[5]+ra->z1*x1+ra->z2*x2, f->par); + } + return 0; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_qo3d_post(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + mgl_qo3d_ham *f = (mgl_qo3d_ham *)t->v; + long nx=t->n; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long ii=t->id;iihxy[ii] -= (f->hx[i]+f->hy[j]-f->h0/2.)/2.; + if(imag(f->hxy[ii])>0) f->hxy[ii] = f->hxy[ii].real(); + f->hxv[ii] -= (f->hx[i]+f->hv[j]-f->h0/2.)/2.; + if(imag(f->hxv[ii])>0) f->hxv[ii] = f->hxv[ii].real(); + f->huy[ii] -= (f->hu[i]+f->hy[j]-f->h0/2.)/2.; + if(imag(f->huy[ii])>0) f->huy[ii] = f->huy[ii].real(); + f->huv[ii] -= (f->hu[i]+f->hv[j]-f->h0/2.)/2.; + if(imag(f->huv[ii])>0) f->huv[ii] = f->huv[ii].real(); + // add boundary conditions for x-direction + f->hxy[ii] -= dual(0,f->dmp[ii]); + } + return 0; +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_qo3d_func_c(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz) +{ + const mglData *ray=dynamic_cast(ray_dat); // NOTE: Ray must be mglData! + if(!ray) return 0; + long nx=ini_re->GetNx(), nt=ray->ny, n7=ray->nx; // NOTE: only square grids are supported now (for simplicity) + if(nx<2 || ini_re->GetNx()!=nx || ini_im->GetNx()*ini_im->GetNy()!=nx*nx || nt<2) return 0; + mglDataC *res=new mglDataC(nx,nx,nt); + + dual *a=new dual[4*nx*nx], *huv=new dual[4*nx*nx], *hxy=new dual[4*nx*nx], *huy=new dual[4*nx*nx], *hxv=new dual[4*nx*nx]; + dual *hu=new dual[2*nx], *hx=new dual[2*nx], *hy=new dual[2*nx], *hv=new dual[2*nx]; + mreal *dmp=new mreal[4*nx*nx]; + mgl_ap *ra = new mgl_ap[nt]; + mgl_init_ra(nt, n7, ray->a, ra); // prepare ray + + mreal dr = r/(nx-1), dk = M_PI*(nx-1)/(k0*r*nx); + memset(dmp,0,4*nx*nx*sizeof(mreal)); +#pragma omp parallel for collapse(2) + for(long i=0;iv(i,j),ini_im->v(i,j)); + void *wtx = mgl_fft_alloc(2*nx,0,0); + if(xx && yy && zz) { xx->Create(nx,nx,nt); yy->Create(nx,nx,nt); zz->Create(nx,nx,nt); } + + mgl_qo3d_ham tmp; // parameters for Hamiltonian calculation + tmp.hxy=hxy; tmp.hx=hx; tmp.huv=huv; tmp.hu=hu; + tmp.huy=huy; tmp.hy=hy; tmp.hxv=hxv; tmp.hv=hv; + tmp.dmp=dmp; tmp.par=par; + tmp.dr=dr; tmp.dk=dk; tmp.ham=ham; tmp.a=a; + // start calculation + for(long k=0;ka[i+nx*(j+k*nx)]=a[i+nx/2+2*nx*(j+nx/2)]*sqrt(ra[0].ch/ra[k].ch); + if(xx && yy && zz) +#pragma omp parallel for collapse(2) + for(long i=0;ia[i+nx*(j+k*nx)] = ray->a[n7*k] + ra[k].x1*x1 + ra[k].x2*x2; // new coordinates + yy->a[i+nx*(j+k*nx)] = ray->a[n7*k+1] + ra[k].y1*x1 + ra[k].y2*x2; + zz->a[i+nx*(j+k*nx)] = ray->a[n7*k+2] + ra[k].z1*x1 + ra[k].z2*x2; + } + tmp.r=ray->a+n7*k; tmp.ra=ra+k; + mglStartThread(mgl_qo3d_hprep,0,2*nx,0,0,0,0,&tmp); tmp.h0 = huv[0]; +#pragma omp parallel for + for(long i=0;i<2*nx;i++) // fill intermediate arrays + { + tmp.hx[i] = hxv[i]; tmp.hy[i] = huy[i*2*nx]; + tmp.hv[i] = huv[i]; tmp.hu[i] = huv[i*2*nx]; + } + mglStartThread(mgl_qo3d_post,0,2*nx,0,0,0,0,&tmp); + // Step for field + dual dt = dual(0, -ra[k].dt*k0); // TODO: this part can be paralleled +#pragma omp parallel + { + void *wsx = mgl_fft_alloc_thr(2*nx); +#pragma omp for + for(long i=0;i<4*nx*nx;i++) a[i] *= exp(hxy[i]*dt); // x-y +#pragma omp for + for(long i=0;i<2*nx;i++) // x->u + mgl_fft((double *)(a+i*2*nx), 1, 2*nx, wtx, wsx, false); +#pragma omp for + for(long i=0;i<4*nx*nx;i++) a[i] *= exp(huy[i]*dt); // u-y +#pragma omp for + for(long i=0;i<2*nx;i++) // y->v + mgl_fft((double *)(a+i), 2*nx, 2*nx, wtx, wsx, false); +#pragma omp for + for(long i=0;i<4*nx*nx;i++) a[i] *= exp(huv[i]*dt); // u-v +#pragma omp for + for(long i=0;i<2*nx;i++) // u->x + mgl_fft((double *)(a+i*2*nx), 1, 2*nx, wtx, wsx, true); +#pragma omp for + for(long i=0;i<4*nx*nx;i++) a[i] *= exp(hxv[i]*dt); // x-v +#pragma omp for + for(long i=0;i<2*nx;i++) // v->y + mgl_fft((double *)(a+i), 2*nx, 2*nx, wtx, wsx, true); + mgl_fft_free_thr(wsx); + } + +/* // Calculate B1 // TODO make more general scheme later!!! + hh = ra[k].pt*(1/sqrt(sqrt(1.041))-1); + var['x'-'a'] = ray->a[n7*k]; // new coordiantes + var['y'-'a'] = ray->a[n7*k+1]; + var['p'-'a'] = ray->a[n7*k+3] + ra[k].x0*hh; // new momentums + var['q'-'a'] = ray->a[n7*k+4] + ra[k].y0*hh; + tt = h.CalcD(var,'p')*ra[k].x1 + h.CalcD(var,'q')*ra[k].y1; + var['x'-'a'] = ray->a[n7*k] + ra[k].x1*dr; // new coordiantes + var['y'-'a'] = ray->a[n7*k+1] + ra[k].y1*dr; + hh = 1 - ra[k].t1*dr; hh = sqrt(sqrt(0.041+hh*hh*hh*hh)); + hh = (ra[k].ch*ra[k].pt + ra[k].d1*dr)/(hh*ra[k].ch) - ra[k].pt; + var['p'-'a'] = ray->a[n7*k+3] + ra[k].x0*hh; // new momentums + var['q'-'a'] = ray->a[n7*k+4] + ra[k].y0*hh; + B1 = h.CalcD(var,'p')*ra[k].x1 + h.CalcD(var,'q')*ra[k].y1; + B1 = (B1-tt)/dr; + double a1=0, a2=0; + for(i=0;i<2*nx;i++) a1 += norm(a[i]); + hx[0] = hx[2*nx-1] = 0.; + for(i=1;i<2*nx-1;i++) hx[i] = (B1*ra[k].dt*(i-nx))*(a[i+1]-a[i-1]); + for(i=0;i<2*nx;i++) { a[i] += hx[i]; a2 += norm(a[i]); } + a1 = sqrt(a1/a2); + for(i=0;i<2*nx;i++) a[i] *= a1;*/ + } + mgl_fft_free(wtx,0,0); + delete []a; delete []ra; delete []dmp; + delete []huv; delete []hxy; delete []hxv; delete []huy; + delete []hu; delete []hx; delete []hv; delete []hy; + return res; +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_qo3d_func(dual (*ham)(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par), void *par, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz) +{ + HADT res = mgl_qo3d_func_c(ham,par,ini_re,ini_im,ray_dat,r,k0,xx,yy,zz); + HMDT out = mgl_datac_abs(res); delete res; return out; +} +//----------------------------------------------------------------------------- +dual MGL_NO_EXPORT mgl_ham3d(mreal u, mreal x, mreal y, mreal z, mreal px, mreal py, mreal pz, void *par) +{ + mglFormula *h = (mglFormula *)par; + mreal var[MGL_VS]; memset(var,0,MGL_VS*sizeof(mreal)); + var['x'-'a'] = x; var['y'-'a'] = y; var['z'-'a'] = z; var['u'-'a'] = u; + var['p'-'a'] = px; var['q'-'a'] = py; var['v'-'a'] = pz; + return dual(h->Calc(var), -h->CalcD(var,'i')); +} +//----------------------------------------------------------------------------- +HADT MGL_EXPORT mgl_qo3d_solve_c(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz) +{ + mglFormula h(ham); + return mgl_qo3d_func_c(mgl_ham3d, &h, ini_re, ini_im, ray_dat, r, k0, xx, yy, zz); +} +//----------------------------------------------------------------------------- +HMDT MGL_EXPORT mgl_qo3d_solve(const char *ham, HCDT ini_re, HCDT ini_im, HCDT ray_dat, mreal r, mreal k0, HMDT xx, HMDT yy, HMDT zz) +{ + HADT res = mgl_qo3d_solve_c(ham,ini_re,ini_im,ray_dat,r,k0,xx,yy,zz); + HMDT out = mgl_datac_abs(res); delete res; return out; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_jacob2(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1]; + mreal *r=t->a; + const mreal *x=t->b, *y=t->c; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=i0/nx; + register long ip = i0 ? -1:0, jm = j>0 ? -nx:0; + r[i0] = (x[i0+ip]-x[i0+im])*(y[i0+jp]-y[i0+jm]) - + (y[i0+ip]-y[i0+im])*(x[i0+jp]-x[i0+jm]); + r[i0] *= mreal((nx-1)*(ny-1)) / ((ip-im)*(jp-jm)); + } + return 0; +} +HMDT MGL_EXPORT mgl_jacobian_2d(HCDT x, HCDT y) +{ + int nx = x->GetNx(), ny=x->GetNy(); + if(nx!=y->GetNx() || ny!=y->GetNy() || nx<2 || ny<2) return 0; + mglData *r=new mglData(nx,ny,1); + const mglData *xx=dynamic_cast(x); + const mglData *yy=dynamic_cast(y); + if(xx && yy) + { + long p[2]={nx,ny}; + mglStartThread(mgl_jacob2,0,nx*ny,r->a,xx->a,yy->a,p); + } + else // slow variant + { +#pragma omp parallel for collapse(2) + for(long j=0;j0 ? i-1:i, ip = i0 ? j-1:j, jp = ja[i+nx*j] = (x->v(ip,j)-x->v(im,j))*(y->v(i,jp)-y->v(i,jm)) - + (y->v(ip,j)-y->v(im,j))*(x->v(i,jp)-x->v(i,jm)); + r->a[i+nx*j] *= mreal((nx-1)*(ny-1)) / ((ip-im)*(jp-jm)); + } + } + return r; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_jacob3(void *par) +{ + mglThreadD *t=(mglThreadD *)par; + long nx=t->p[0], ny=t->p[1], nz=t->p[2]; + mreal *r=t->a; + const mreal *x=t->b, *y=t->c, *z=t->d; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i0=t->id;i0n;i0+=mglNumThr) + { + register long i=i0%nx, j=(i0/nx)%ny, k=i0/(nx*ny); + register long ip = i0 ? -1:0, jm = j>0 ? -nx:0, km = k>0 ? -nx*ny:0; + r[i0] = (x[i0+ip]-x[i0+im])*(y[i0+jp]-y[i0+jm])*(z[i0+kp]-z[i0+km]) - + (x[i0+ip]-x[i0+im])*(y[i0+kp]-y[i0+km])*(z[i0+jp]-z[i0+jm]) - + (x[i0+jp]-x[i0+jm])*(y[i0+ip]-y[i0+im])*(z[i0+kp]-z[i0+km]) + + (x[i0+jp]-x[i0+jm])*(y[i0+kp]-y[i0+km])*(z[i0+ip]-z[i0+im]) + + (x[i0+kp]-x[i0+km])*(y[i0+ip]-y[i0+im])*(z[i0+jp]-z[i0+jm]) - + (x[i0+kp]-x[i0+km])*(y[i0+jp]-y[i0+jm])*(z[i0+ip]-z[i0+im]); + r[i0] *= mreal((nx-1)*(ny-1)*(nz-1)) / ((ip-im)*(jp-jm)*(kp-km)); + } + return 0; +} +HMDT MGL_EXPORT mgl_jacobian_3d(HCDT x, HCDT y, HCDT z) +{ + int nx = x->GetNx(), ny=x->GetNy(), nz=x->GetNz(), nn = nx*ny*nz; + if(nx<2 || ny<2 || nz<2) return 0; + if(nn!=y->GetNx()*y->GetNy()*y->GetNz() || nn!=z->GetNx()*z->GetNy()*z->GetNz()) return 0; + mglData *r=new mglData(nx,ny,nz); + const mglData *xx=dynamic_cast(x); + const mglData *yy=dynamic_cast(y); + const mglData *zz=dynamic_cast(z); + if(xx && yy && zz) + { + long p[3]={nx,ny,nz}; + mglStartThread(mgl_jacob3,0,nx*ny*nz,r->a,xx->a,yy->a,p,0,zz->a); + } + else // slow variant + { +#pragma omp parallel for collapse(3) + for(long k=0;k0 ? i-1:i, ip = i0 ? j-1:j, jp = j0 ? k-1:k, kp = ka[i0] = (x->v(ip,j,k)-x->v(im,j,k))*(y->v(i,jp,k)-y->v(i,jm,k))*(z->v(i,j,kp)-z->v(i,j,km)) - + (x->v(ip,j,k)-x->v(im,j,k))*(y->v(i,j,kp)-y->v(i,j,km))*(z->v(i,jp,k)-z->v(i,jm,k)) - + (x->v(i,jp,k)-x->v(i,jm,k))*(y->v(ip,j,k)-y->v(im,j,k))*(z->v(i,j,kp)-z->v(i,j,km)) + + (x->v(i,jp,k)-x->v(i,jm,k))*(y->v(i,j,kp)-y->v(i,j,km))*(z->v(ip,j,k)-z->v(im,j,k)) + + (x->v(i,j,kp)-x->v(i,j,km))*(y->v(ip,j,k)-y->v(im,j,k))*(z->v(i,jp,k)-z->v(i,jm,k)) - + (x->v(i,j,kp)-x->v(i,j,km))*(y->v(i,jp,k)-y->v(i,jm,k))*(z->v(ip,j,k)-z->v(im,j,k)); + r->a[i0] *= mreal((nx-1)*(ny-1)*(nz-1)) / ((ip-im)*(jp-jm)*(kp-km)); + } + + } + return r; +} +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_pde_solve_c_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0, const char *opt, int l, int lo) +{ char *s=new char[l+1]; memcpy(s,ham,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t res = uintptr_t(mgl_pde_solve_c(_GR_, s, _DA_(ini_re), _DA_(ini_im), *dz, *k0, o)); + delete []o; delete []s; return res; } +uintptr_t MGL_EXPORT mgl_pde_solve_(uintptr_t* gr, const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, mreal *dz, mreal *k0, const char *opt, int l, int lo) +{ char *s=new char[l+1]; memcpy(s,ham,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + uintptr_t res = uintptr_t(mgl_pde_solve(_GR_, s, _DA_(ini_re), _DA_(ini_im), *dz, *k0, o)); + delete []o; delete []s; return res; } +uintptr_t MGL_EXPORT mgl_ray_trace_(const char *ham, mreal *x0, mreal *y0, mreal *z0, mreal *px, mreal *py, mreal *pz, mreal *dt, mreal *tmax,int l) +{ char *s=new char[l+1]; memcpy(s,ham,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_ray_trace(s, *x0,*y0,*z0, *px,*py,*pz, *dt,*tmax)); + delete []s; return res; } +uintptr_t MGL_EXPORT mgl_qo2d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, int l) +{ char *s=new char[l+1]; memcpy(s,ham,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_qo2d_solve(s, _DA_(ini_re), _DA_(ini_im), _DA_(ray), *r, *k0, _DM_(xx), _DM_(yy))); + delete []s; return res; } +uintptr_t MGL_EXPORT mgl_qo3d_solve_(const char *ham, uintptr_t* ini_re, uintptr_t* ini_im, uintptr_t* ray, mreal *r, mreal *k0, uintptr_t* xx, uintptr_t* yy, uintptr_t* zz, int l) +{ char *s=new char[l+1]; memcpy(s,ham,l); s[l]=0; + uintptr_t res = uintptr_t(mgl_qo3d_solve(s, _DA_(ini_re), _DA_(ini_im), _DA_(ray), *r, *k0, _DM_(xx), _DM_(yy), _DM_(zz))); + delete []s; return res; } +uintptr_t MGL_EXPORT mgl_jacobian_2d_(uintptr_t* x, uintptr_t* y) +{ return uintptr_t(mgl_jacobian_2d(_DA_(x), _DA_(y))); } +uintptr_t MGL_EXPORT mgl_jacobian_3d_(uintptr_t* x, uintptr_t* y, uintptr_t* z) +{ return uintptr_t(mgl_jacobian_3d(_DA_(x), _DA_(y), _DA_(z))); } +//----------------------------------------------------------------------------- diff --git a/src/pixel.cpp b/src/pixel.cpp new file mode 100644 index 0000000..f300239 --- /dev/null +++ b/src/pixel.cpp @@ -0,0 +1,1965 @@ +/*************************************************************************** + * pixel.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include "mgl2/canvas.h" +#include "mgl2/thread.h" +//----------------------------------------------------------------------------- +void mglCanvas::SetSize(int w,int h) +{ + if(w<=0 || h<=0) { SetWarn(mglWarnSize,"SetSize"); return; } + Width = w; Height = h; Depth = long(sqrt(double(w*h))); + if(G) { delete []G; delete []C; delete []Z; delete []G4;delete []OI; } + G = new unsigned char[w*h*3]; + G4= new unsigned char[w*h*4]; + C = new unsigned char[w*h*12]; + Z = new float[w*h*3]; // only 3 planes + OI= new int[w*h]; + InPlot(0,1,0,1,false); Clf(); +} +//----------------------------------------------------------------------------- +void mglDrawReg::set(mglCanvas *gr, int nx, int ny, int m) +{ + int mx = m%nx, my = m/nx; ObjId = gr->ObjId; + PDef = gr->mask; angle = gr->MaskAn; + x1 = gr->GetWidth()*mx/nx; y1 = gr->GetHeight()-gr->GetHeight()*(my+1)/ny; + x2 = gr->GetWidth()*(mx+1)/nx-1; y2 = gr->GetHeight()-gr->GetHeight()*my/ny-1; +} +//----------------------------------------------------------------------------- +void mglCanvas::PutDrawReg(mglDrawReg *d, const mglCanvas *gr) +{ + if(!gr) return; + int dd = d->x2 - d->x1; + register long i,j; + for(j=d->y1;jy2;j++) + { + i = d->x1+Width*(Height-1-j); + memcpy(OI+i,gr->OI+i,dd*sizeof(int)); + memcpy(Z+3*i,gr->Z+3*i,3*dd*sizeof(float)); + memcpy(C+12*i,gr->C+12*i,12*dd); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::PostScale(const mglMatrix *M, mglPoint &p) const +{ + mglPoint q=p/(2*M->pf); + p.x = M->x + q.x*M->b[0] + q.y*M->b[1] + q.z*M->b[2]; + p.y = M->y + q.x*M->b[3] + q.y*M->b[4] + q.z*M->b[5]; + p.z = M->z + q.x*M->b[6] + q.y*M->b[7] + q.z*M->b[8]; +} +//----------------------------------------------------------------------------- +bool mglCanvas::ScalePoint(const mglMatrix *M, mglPoint &p, mglPoint &n, bool use_nan) const +{ + bool res = get(MGL_DISABLE_SCALE) || mglBase::ScalePoint(M,p,n,use_nan); +// if(TernAxis&4) return res; + PostScale(M,p); + + mglPoint y=n; + n.x = y.x*M->b[0] + y.y*M->b[1] + y.z*M->b[2]; // simpler for rotation only + n.y = y.x*M->b[3] + y.y*M->b[4] + y.z*M->b[5]; + n.z = y.x*M->b[6] + y.y*M->b[7] + y.z*M->b[8]; + n.Normalize(); + return res; +} +//----------------------------------------------------------------------------- +long mglCanvas::ProjScale(int nf, long id, bool text) +{ + mglPoint pp = GetPntP(id), nn = GetPntN(id), q, p, n, u; + if(mgl_isnan(pp.x)) return -1; + q = RestorePnt(pp)/(2*B.pf); + u = RestorePnt(nn,true); u.Normalize(); + mreal w=B1.b[0]/2, h=B1.b[4]/2, d=B1.b[8]/2, xx=B1.x-w/2, yy=B1.y-h/2; + if(nf==0) + { p.x = xx + q.x*w; p.y = yy + q.y*h; p.z = B1.z + q.z*d; n = u; } + else if(nf==1) + { p.x = xx + q.x*w; p.y = yy+h + q.z*h; p.z = B1.z + q.y*d; n = mglPoint(u.x,u.z,u.y); } + else if(nf==2) + { p.x = xx+w + q.z*w; p.y = yy + q.y*h; p.z = B1.z+ q.x*d; n = mglPoint(u.z,u.y,u.x); } + else + { p.x = xx+w + q.x*B.b[0]/2 + q.y*B.b[1]/2 + q.z*B.b[2]/2; n = nn; + p.y = yy+h + q.x*B.b[3]/2 + q.y*B.b[4]/2 + q.z*B.b[5]/2; + p.z = B.z + q.x*B.b[6]/2 + q.y*B.b[7]/2 + q.z*B.b[8]/2; } + return CopyProj(id,p,text?n:nn); +} +//----------------------------------------------------------------------------- +void mglCanvas::LightScale(const mglMatrix *M) +{ +//#pragma omp parallel for + for(long i=0;i<10;i++) + { + if(!light[i].n) continue; + light[i].p=light[i].d; light[i].q=light[i].r; + ScalePoint(M,light[i].q,light[i].p,false); + light[i].p /= light[i].p.norm(); + } +} +//----------------------------------------------------------------------------- +// NOTE: Perspective is not fully supported now !!! Also it use LAST InPlot parameters!!! +mglPoint mglCanvas::RestorePnt(mglPoint ps, bool norm) const +{ + mreal s3 = 2*B.pf; + mglPoint p; + + mreal W=Width/2, H=Height/2, D=Depth/2; + mreal cx = B.z*Bp.b[2]+B.y*Bp.b[1]+B.x*Bp.b[0]-Bp.x*W-Bp.b[0]*W+W-Bp.b[1]*H-Bp.b[2]*D; + mreal c0 = B.b[6]*Bp.b[2]+B.b[3]*Bp.b[1]+B.b[0]*Bp.b[0]; + mreal c1 = B.b[7]*Bp.b[2]+B.b[4]*Bp.b[1]+B.b[1]*Bp.b[0]; + mreal c2 = B.b[8]*Bp.b[2]+B.b[5]*Bp.b[1]+B.b[2]*Bp.b[0]; + mreal cy = B.z*Bp.b[5]+B.y*Bp.b[4]+B.x*Bp.b[3]-Bp.b[3]*W-Bp.y*H-Bp.b[4]*H+H-Bp.b[5]*D; + mreal c3 = B.b[6]*Bp.b[5]+B.b[3]*Bp.b[4]+B.b[0]*Bp.b[3]; + mreal c4 = B.b[7]*Bp.b[5]+B.b[4]*Bp.b[4]+B.b[1]*Bp.b[3]; + mreal c5 = B.b[8]*Bp.b[5]+B.b[5]*Bp.b[4]+B.b[2]*Bp.b[3]; + mreal cz = B.z*Bp.b[8]+B.y*Bp.b[7]+B.x*Bp.b[6]-Bp.b[6]*W-Bp.b[7]*H-Bp.z*D-Bp.b[8]*D+D; + mreal c6 = B.b[6]*Bp.b[8]+B.b[3]*Bp.b[7]+B.b[0]*Bp.b[6]; + mreal c7 = B.b[7]*Bp.b[8]+B.b[4]*Bp.b[7]+B.b[1]*Bp.b[6]; + mreal c8 = B.b[8]*Bp.b[8]+B.b[5]*Bp.b[7]+B.b[2]*Bp.b[6]; + if(norm) cx=cy=cz=0; + + if(ps.z==ps.z) // try to take into account perspective if z-value is provided + { + register float d = (1-Bp.pf)/(1-Bp.pf*ps.z/Depth); + ps.x = Width/2 + (ps.x-Width/2)/d; + ps.y = Height/2+ (ps.y-Height/2)/d; + } + mreal xx = ps.x-cx, yy = ps.y-cy, zz = ps.z-cz; + mreal d1=c0*c4-c1*c3, d2=c1*c5-c2*c4, d3=c0*c5-c2*c3; + + if(zz==zz) // try to use z-values + { + // put inverse matrix here: [x,y,z]=B^(-1)[xx,yy,zz] + mreal det = (-c0*c4*c8+c1*c3*c8+c0*c5*c7-c2*c3*c7-c1*c5*c6+c2*c4*c6)/s3; + p.x = (c2*c4-c1*c5)*zz+(c1*c8-c2*c7)*yy+(c5*c7-c4*c8)*xx; p.x /= det; + p.y = (c0*c5-c2*c3)*zz+(c2*c6-c0*c8)*yy+(c3*c8-c5*c6)*xx; p.y /= det; + p.z = (c1*c3-c0*c4)*zz+(c0*c7-c1*c6)*yy+(c4*c6-c3*c7)*xx; p.z /= det; + } + else if(fabs(d1) > fabs(d2) && fabs(d1) > fabs(d3)) // x-y plane + { + p.z = 0; + p.x = s3*(c4*xx-c1*yy)/d1; + p.y = s3*(c0*yy-c3*xx)/d1; + } + else if(fabs(d2) > fabs(d3)) // y-z + { + p.x = 0; + p.y = s3*(c5*xx-c2*yy)/d2; + p.z = s3*(c1*yy-c4*xx)/d2; + } + else // x-z + { + p.y = 0; + p.x = s3*(c5*xx-c2*yy)/d3; + p.z = s3*(c0*yy-c3*xx)/d3; + } + return p; +} +//----------------------------------------------------------------------------- +mglPoint mglCanvas::CalcXYZ(int xs, int ys, bool real) const +{ + if(xs<0 || ys<0 || xs>=Width || ys>=Height) return mglPoint(NAN,NAN,NAN); + mglPoint p, ps(xs,Height-ys,NAN); + float zz = Z[3*(xs+Width*(Height-1-ys))]; + if(zz>-1e20f) { ps.z = zz; real=false; } + p = RestorePnt(ps); + return real ? mglPoint(NAN,NAN,NAN) : mglPoint(Min.x + (Max.x-Min.x)*(p.x+1)/2, + Min.y + (Max.y-Min.y)*(p.y+1)/2, Min.z + (Max.z-Min.z)*(p.z+1)/2); +} +//----------------------------------------------------------------------------- +void mglCanvas::CalcScr(mglPoint p, int *xs, int *ys) const +{ + mglPoint n; + ScalePoint(GetB(),p,n); + if(xs) *xs=int(p.x); + if(ys) *ys=int(p.y); +} +//----------------------------------------------------------------------------- +mglPoint mglCanvas::CalcScr(mglPoint p) const +{ int x,y; CalcScr(p,&x,&y); return mglPoint(x,y); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT int mgl_type_prior[8]={1,2,4,5, 0,3,0, 7}; +bool mglCreationOrder=false; +bool operator<(const mglPrim &a, const mglPrim &b) +{ + if(mglCreationOrder) return a.n1 t2; + if(a.w!=b.w) return a.w > b.w; + return a.n3 > b.n3; +} +//----------------------------------------------------------------------------- +bool operator>(const mglPrim &a, const mglPrim &b) +{ + if(mglCreationOrder) return a.n1>b.n1; + register int t1 = mgl_type_prior[a.type], t2 = mgl_type_prior[b.type]; + if(a.z!=b.z) return a.z > b.z; + if(t1!=t2) return t1 < t2; + if(a.w!=b.w) return a.w < b.w; + return a.n3 < b.n3; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_canvas_thr(void *par) +{ mglThreadG *t=(mglThreadG *)par; (t->gr->*(t->f))(t->id, t->n, t->p); return NULL; } +void mglStartThread(void (mglCanvas::*func)(long i, long n, const void *p), mglCanvas *gr, long n, const void *p=NULL) +{ + if(!func || !gr) return; +#if MGL_HAVE_PTHREAD + if(mglNumThr<1) mgl_set_num_thr(0); + if(mglNumThr>1) + { + pthread_t *tmp=new pthread_t[mglNumThr]; + mglThreadG *par=new mglThreadG[mglNumThr]; + register long i; + for(i=0;i*func)(0,n,p); } +} +//----------------------------------------------------------------------------- +void mglCanvas::pxl_combine(long id, long n, const void *) +{ + unsigned char c[4],*cc; +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for private(c,cc) +#endif + for(long i=id;i0) + { + mglStartThread(&mglCanvas::pxl_pntcol,this,Pnt.size()); + mglStartThread(&mglCanvas::pxl_prmcol,this,Prm.size()); + } +} +//----------------------------------------------------------------------------- +void mglBase::resort() +{ +#pragma omp critical + { + mglCreationOrder = true; + std::sort(Prm.begin(), Prm.end()); + mglCreationOrder = false; + clr(MGL_FINISHED); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::pxl_primdr(long id, long , const void *) +{ +#define Q 4 // should be >= sqrt(2*num_thr) ??? + int nx=Q,ny=Q; // TODO find dependence on Q for 1, 2, 4, 8 threads. Try to select optimal +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long i=id;i=0 && i0Z[3*i0]) + { Z[3*i0]=z; memcpy(C+12*i0,r,4); OI[i0]=-1; } + } +} +//----------------------------------------------------------------------------- +void mglCanvas::Finish() +{ + if(Quality==MGL_DRAW_DOTS) + { + mglStartThread(&mglCanvas::pxl_dotsdr,this,Pnt.size()); + mglStartThread(&mglCanvas::pxl_memcpy,this,Width*Height); + mglStartThread(&mglCanvas::pxl_backgr,this,Width*Height); + return; + } + static mglMatrix bp; + if(Quality==MGL_DRAW_NONE) return; + if(Quality&MGL_DRAW_LMEM) clr(MGL_FINISHED); + if(memcmp(&Bp,&bp,sizeof(mglMatrix)) && !(Quality&MGL_DRAW_LMEM) && Prm.size()>0) + clr(MGL_FINISHED); + if(get(MGL_FINISHED)) return; // nothing to do +/* static bool working=false; + if(working) return; + working = true;*/ + if(!(Quality&MGL_DRAW_LMEM) && Prm.size()>0) + { + PreparePrim(0); bp=Bp; + clr(MGL_FINISHED); + mglStartThread(&mglCanvas::pxl_primdr,this,Prm.size()); + } + size_t n=Width*Height; + BDef[3] = (Flag&3)!=2 ? 0:255; + if(Quality&MGL_DRAW_NORM) mglStartThread(&mglCanvas::pxl_combine,this,n); + else mglStartThread(&mglCanvas::pxl_memcpy,this,n); + BDef[3] = 255; + mglStartThread(&mglCanvas::pxl_backgr,this,n); + set(MGL_FINISHED); +// working = false; +} +//----------------------------------------------------------------------------- +void mglCanvas::ClfZB(bool force) +{ + if(!force && (Quality&MGL_DRAW_LMEM)) return; + register long n=Width*Height; + memset(C,0,12*n); memset(OI,0,n*sizeof(int)); +#pragma omp parallel for + for(long i=0;i<3*n;i++) Z[i] = -1e20f; + clr(MGL_FINISHED); +} +//----------------------------------------------------------------------------- +void mglCanvas::Clf(mglColor Back) +{ + Fog(0); PDef = 0xffff; pPos = 0; StartAutoGroup(NULL); + Pnt.clear(); Prm.clear(); Ptx.clear(); Glf.clear(); + Sub.clear(); Leg.clear(); Grp.clear(); Act.clear(); + pnt_col.clear(); prm_col.clear(); + +#pragma omp critical(txt) + { + Txt.clear(); Txt.reserve(3); + mglTexture t1(MGL_DEF_PAL,-1), t2(MGL_DEF_SCH,1); + MGL_PUSH(Txt,t1,mutexTxt); + MGL_PUSH(Txt,t2,mutexTxt); + } + +// if(Back==NC) Back = mglColor(1,1,1); + if((Flag&3)==2) Back = mglColor(0,0,0); + if(Back!=NC) + { BDef[0]=Back.r*255; BDef[1]=Back.g*255;BDef[2]=Back.b*255; BDef[3]=0; } + ClfZB(true); +} +//----------------------------------------------------------------------------- +void mglCanvas::pxl_other(long id, long n, const void *p) +{ + const mglCanvas *gr = (const mglCanvas *)p; + if(!gr) return; + if(Quality&MGL_DRAW_NORM) +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long k=id;kZ[3*k+2],gr->C+12*k+8,gr->OI[k]); + pnt_plot(i,j,gr->Z[3*k+1],gr->C+12*k+4,gr->OI[k]); + pnt_plot(i,j,gr->Z[3*k],gr->C+12*k,gr->OI[k]); + } + else +#if !MGL_HAVE_PTHREAD +#pragma omp parallel for +#endif + for(long k=id;kZ[3*k],gr->C+12*k,gr->OI[k]); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::Combine(const mglCanvas *gr) +{ + if(Width!=gr->Width || Height!=gr->Height) return; // wrong sizes + mglStartThread(&mglCanvas::pxl_other,this,Width*Height,gr); +} +//----------------------------------------------------------------------------- +void mglCanvas::pnt_plot(long x,long y,mreal z,const unsigned char ci[4], int obj_id) +{ + long i0=x+Width*(Height-1-y); + if(ci[3]==0) return; + unsigned char *cc = C+12*i0, c[4]; + memcpy(c,ci,4); + float *zz = Z+3*i0, zf = FogDist*(z/Depth-0.5-FogDz); + if(zf<0) // add fog + { + int d = int(255.f-255.f*exp(5.f*zf)); + unsigned char cb[4] = {BDef[0], BDef[1], BDef[2], (unsigned char)d}; + if(d==255) return; + combine(c,cb); + } + if(Quality&MGL_DRAW_NORM) + { + if(z>=zz[1]) // shift point on slice down and paste new point + { + zz[2] = zz[1]; combine(cc+8,cc+4); + if(z>=zz[0]) + { zz[1] = zz[0]; zz[0] = z; OI[i0]=obj_id; + memcpy(cc+4,cc,4); memcpy(cc,c,4); } + else { zz[1] = z; memcpy(cc+4,c,4); } + } + else + { + if(z>=zz[2]) // shift point on slice down and paste new point + { zz[2] = z; combine(cc+8,c); } + else // point below the background + { combine(c,cc+8); memcpy(cc+8,c,4); } + } + } + else + { + if(z>=zz[0]) // point upper the background + { zz[0]=z; memcpy(cc,c,4); OI[i0]=obj_id; } + } +} +//----------------------------------------------------------------------------- +unsigned char* mglCanvas::col2int(const mglPnt &p,unsigned char *r, int obj_id) +{ + if(!r) return r; + if(p.a<=0) { memset(r,0,4); return r; } + register float b0=0,b1=0,b2=0, ar,ag,ab; + ar = ag = ab = AmbBr; + +// if(get(MGL_ENABLE_LIGHT) && mgl_isnum(p.u)) + if(mgl_isnum(p.u+p.v+p.w)) + { + float d0,d1,d2,nn; + register long i; + for(i=0;i<10;i++) + { + const mglLight &ll=light[i]; + if(!ll.n) continue; + if(mgl_isnan(ll.q.x)) // source at infinity + { + nn = 2*(p.u*ll.p.x+p.v*ll.p.y+p.w*ll.p.z) / (p.u*p.u+p.v*p.v+p.w*p.w+1e-6); + d0 = ll.p.x - p.u*nn; + d1 = ll.p.y - p.v*nn; + d2 = ll.p.z - p.w*nn; + nn = 1 + d2/sqrt(d0*d0+d1*d1+d2*d2+1e-6); + + nn = exp(-ll.a*nn)*ll.b*2; + b0 += nn*ll.c.r; + b1 += nn*ll.c.g; + b2 += nn*ll.c.b; + } + else // diffuse and specular light + { + d0 = ll.q.x-p.x; // direction to light source + d1 = ll.q.y-p.y; + d2 = ll.q.z-p.z; + nn = 1+(d0*ll.p.x+d1*ll.p.y+d2*ll.p.z)/sqrt(d0*d0+d1*d1+d2*d2+1e-6); + float bb = exp(-3*ll.a*nn); nn = bb*DifBr*2; + ar += nn*ll.c.r; + ag += nn*ll.c.g; + ab += nn*ll.c.b; + + nn = 2*(p.u*d0+p.v*d1+p.w*d2) / (p.u*p.u+p.v*p.v+p.w*p.w+1e-6); + d0 -= p.u*nn; d1 -= p.v*nn; d2 -= p.w*nn; + nn = 1 + d2/sqrt(d0*d0+d1*d1+d2*d2+1e-6); + + nn = exp(-ll.a*nn)*bb*ll.b*2; + b0 += nn*ll.c.r; + b1 += nn*ll.c.g; + b2 += nn*ll.c.b; + } + } + b0 += (ar>1 ? 1:ar)*p.r; // diffuse light + b1 += (ag>1 ? 1:ag)*p.g; + b2 += (ab>1 ? 1:ab)*p.b; + b0 = b0<1 ? b0 : 1; // normalize components + b1 = b1<1 ? b1 : 1; + b2 = b2<1 ? b2 : 1; + } + else + { b0=p.r; b1=p.g; b2=p.b; } + // try to highlight faces + if(obj_id==HighId) { b0*=0.7; b1*=0.7; b2*=0.7; } + r[0] = (unsigned char)(255*b0); + r[1] = (unsigned char)(255*b1); + r[2] = (unsigned char)(255*b2); +// r[3] = get(MGL_ENABLE_ALPHA) ? (unsigned char)(255*p.a) : 255; + r[3] = (unsigned char)((Quality&MGL_DRAW_NORM)?255*p.a:255); + return r; +} +//----------------------------------------------------------------------------- +/// color mixing: color c1 is under color c2 !!! +void mglCanvas::combine(unsigned char *c1, const unsigned char *c2) +{ + if(!c2[3]) return; + register unsigned int a1=c1[3], a2=c2[3],b1=255-a2; + if(a1==0 || a2==255) { memcpy(c1,c2,4); return; } + if((Flag&3)==0) + { + c1[0] = (c1[0]*b1 + c2[0]*a2)/256; + c1[1] = (c1[1]*b1 + c2[1]*a2)/256; + c1[2] = (c1[2]*b1 + c2[2]*a2)/256; + c1[3] = (unsigned char)(a2+a1*b1/255); + } + else if((Flag&3)==1) + { + c1[0] = (unsigned char)((255-a1*(255-c1[0])/256)*(255-a2*(255-c2[0])/256)/256); + c1[1] = (unsigned char)((255-a1*(255-c1[1])/256)*(255-a2*(255-c2[1])/256)/256); + c1[2] = (unsigned char)((255-a1*(255-c1[2])/256)*(255-a2*(255-c2[2])/256)/256); + c1[3] = 255; + } + else if((Flag&3)==2) + { + unsigned int b2,b3; + b1 = (c1[0]*a1 + c2[0]*a2)/256; c1[0] = b1<255 ? b1 : 255; + b2 = (c1[1]*a1 + c2[1]*a2)/256; c1[1] = b2<255 ? b2 : 255; + b3 = (c1[2]*a1 + c2[2]*a2)/256; c1[2] = b3<255 ? b3 : 255; + c1[3] = a1+a2>255? 255 : a1+a2; + } +} +//----------------------------------------------------------------------------- +unsigned char **mglCanvas::GetRGBLines(long &w, long &h, unsigned char *&f, bool alpha) +{ + unsigned char **p; + Finish(); + p = (unsigned char **)malloc(Height * sizeof(unsigned char *)); + long d = (alpha ? 4:3)*Width; + unsigned char *gg = (alpha?G4:G); +#pragma omp parallel for + for(long i=0;ip2.x?p1.x:p2.x, p3.x>p4.x?p3.x:p4.x)); + y2 = long(fmax(p1.y>p2.y?p1.y:p2.y, p3.y>p4.y?p3.y:p4.y)); + x1=x1>d->x1?x1:d->x1; x2=x2x2?x2:d->x2; + y1=y1>d->y1?y1:d->y1; y2=y2y2?y2:d->y2; + if(x1>x2 || y1>y2) return; + + dd = d1.x*d2.y-d1.y*d2.x; + dsx =-4*(d2.y*d3.x - d2.x*d3.y)*d1.y; + dsy = 4*(d2.y*d3.x - d2.x*d3.y)*d1.x; + + if((d1.x==0 && d1.y==0) || (d2.x==0 && d2.y==0) || !(Quality&MGL_DRAW_NORM)) + { trig_draw(p1,p2,p4,true,d); trig_draw(p1,p3,p4,true,d); return; } + + mglPoint n1 = mglPoint(p2.x-p1.x,p2.y-p1.y,p2.z-p1.z)^mglPoint(p3.x-p1.x,p3.y-p1.y,p3.z-p1.z); + mglPoint n2 = mglPoint(p2.x-p4.x,p2.y-p4.y,p2.z-p4.z)^mglPoint(p3.x-p4.x,p3.y-p4.y,p3.z-p4.z); + mglPoint nr = (n1+n2)*0.5; + + float x0 = p1.x, y0 = p1.y; + for(long i=x1;i<=x2;i++) for(long j=y1;j<=y2;j++) + { + if(!visible(i,j,d->m, d->PenWidth,d->angle)) continue; + register float xx = (i-x0), yy = (j-y0), s; + s = dsx*xx + dsy*yy + (dd+d3.y*xx-d3.x*yy)*(dd+d3.y*xx-d3.x*yy); + if(s<0) continue; // no solution + s = sqrt(s); + register float qu = d3.x*yy - d3.y*xx + dd + s, u=-1; + register float qv = d3.y*xx - d3.x*yy + dd + s, v=-1; +// if(qu && qv) + { + u = 2.f*(d2.y*xx - d2.x*yy)/qu; + v = 2.f*(d1.x*yy - d1.y*xx)/qv; + } + if(u*(1.f-u)<0.f || v*(1.f-v)<0.f) // first root bad + { + qu = d3.x*yy - d3.y*xx + dd - s; + qv = d3.y*xx - d3.x*yy + dd - s; + u = v = -1.f; +// if(qu && qv) + { + u = 2.f*(d2.y*xx - d2.x*yy)/qu; + v = 2.f*(d1.x*yy - d1.y*xx)/qv; + } + if(u*(1.f-u)<0.f || v*(1.f-v)<0.f) continue; // second root bad + } + p = p1+d1*u+d2*v+d3*(u*v); + if(mgl_isnan(p.u) && mgl_isnum(p.v)) + { p.u = nr.x; p.v = nr.y; p.w = nr.z; } + pnt_plot(i,j,p.z,col2int(p,r,d->ObjId),d->ObjId); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::quad_pix(long i, long j, const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, const mglPnt &p4, const mglDrawReg *d) +{ + if(!visible(i,j,d->m, d->PenWidth,d->angle)) return; + mglPnt d1=p2-p1, d2=p3-p1, d3=p4+p1-p2-p3; + register float dd = d1.x*d2.y-d1.y*d2.x; + register float dsx =-4*(d2.y*d3.x - d2.x*d3.y)*d1.y; + register float dsy = 4*(d2.y*d3.x - d2.x*d3.y)*d1.x; + register float xx = (i-p1.x), yy = (j-p1.y), s; + s = dsx*xx + dsy*yy + (dd+d3.y*xx-d3.x*yy)*(dd+d3.y*xx-d3.x*yy); + if(s<0) return; // no solution + s = sqrt(s); + register float qu = d3.x*yy - d3.y*xx + dd + s, u=-1; + register float qv = d3.y*xx - d3.x*yy + dd + s, v=-1; + if(qu && qv) + { + u = 2.f*(d2.y*xx - d2.x*yy)/qu; + v = 2.f*(d1.x*yy - d1.y*xx)/qv; + } + if(u*(1.f-u)<0.f || v*(1.f-v)<0.f) // first root bad + { + qu = d3.x*yy - d3.y*xx + dd - s; + qv = d3.y*xx - d3.x*yy + dd - s; + u = v = -1.f; + if(qu && qv) + { + u = 2.f*(d2.y*xx - d2.x*yy)/qu; + v = 2.f*(d1.x*yy - d1.y*xx)/qv; + } + if(u*(1.f-u)<0.f || v*(1.f-v)<0.f) return; // second root bad + } + mglPnt p = p1+d1*u+d2*v+d3*(u*v); + if(mgl_isnan(p.u) && mgl_isnum(p.v)) + { + mglPoint n1 = mglPoint(p2.x-p1.x,p2.y-p1.y,p2.z-p1.z)^mglPoint(p3.x-p1.x,p3.y-p1.y,p3.z-p1.z); + mglPoint n2 = mglPoint(p2.x-p4.x,p2.y-p4.y,p2.z-p4.z)^mglPoint(p3.x-p4.x,p3.y-p4.y,p3.z-p4.z); + p.u = (n1.x+n2.x)*0.5; + p.v = (n1.y+n2.y)*0.5; + p.w = (n1.z+n2.z)*0.5; + } + unsigned char r[4]; + pnt_plot(i,j,p.z,col2int(p,r,d->ObjId),d->ObjId); +} +//----------------------------------------------------------------------------- +/* Linear interpolation r(u,v) = r0 + (r1-r0)*u + (r2-r0)*v is used, where r is + one of {x,y,z,R,G,B,A}. Variables u,v are determined for each point (x,y). + Point plotted is u>0 and v>0 and u+v<1.*/ +void mglCanvas::trig_draw(const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d) +{ + if(!(Quality&3) && anorm) + { + fast_draw(p1,p2,d); fast_draw(p1,p3,d); + fast_draw(p2,p3,d); return; + } + unsigned char r[4]; + long y1,x1,y2,x2; + float dxu,dxv,dyu,dyv; + mglPnt d1=p2-p1, d2=p3-p1, p; + + dxu = d2.x*d1.y - d1.x*d2.y; + if(fabs(dxu)<1e-5) return; // points lies on the same line + dyv =-d1.x/dxu; dxv = d1.y/dxu; + dyu = d2.x/dxu; dxu =-d2.y/dxu; + + x1 = long(fmin(p1.xp2.x?p1.x:p2.x, p3.x)); + y2 = long(fmax(p1.y>p2.y?p1.y:p2.y, p3.y)); + x1=x1>d->x1?x1:d->x1; x2=x2x2?x2:d->x2; + y1=y1>d->y1?y1:d->y1; y2=y2y2?y2:d->y2; + if(x1>x2 || y1>y2) return; + // default normale + mglPoint nr = mglPoint(p2.x-p1.x,p2.y-p1.y,p2.z-p1.z)^mglPoint(p3.x-p1.x,p3.y-p1.y,p3.z-p1.z); + float x0 = p1.x, y0 = p1.y; + if(Quality&MGL_DRAW_NORM) for(long i=x1;i<=x2;i++) for(long j=y1;j<=y2;j++) + { + if(!visible(i,j,d->m, d->PenWidth,d->angle)) continue; + register float xx = (i-x0), yy = (j-y0); + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; + if(u<0 || v<0 || u+v>1) continue; + p = p1+d1*u+d2*v; + if(mgl_isnan(p.u) && mgl_isnum(p.v) && anorm) + { p.u = nr.x; p.v = nr.y; p.w = nr.z; } + pnt_plot(i,j,p.z,col2int(p,r,d->ObjId),d->ObjId); + } + else for(long i=x1;i<=x2;i++) for(long j=y1;j<=y2;j++) + { + if(!visible(i,j,d->m, d->PenWidth,d->angle)) continue; + register float xx = (i-x0), yy = (j-y0); + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; + if(u<0 || v<0 || u+v>1) continue; + pnt_plot(i,j,p1.z,col2int(p1,r,d->ObjId),d->ObjId); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::trig_pix(long i, long j, const mglPnt &p1, const mglPnt &p2, const mglPnt &p3, bool anorm, const mglDrawReg *d) +{ + if(!visible(i,j,d->m, d->PenWidth,d->angle)) return; + mglPnt d1=p2-p1, d2=p3-p1; + register float dd = d2.x*d1.y - d1.x*d2.y; + if(fabs(dd)<1e-5) return; // points lies on the same line + register float dyv =-d1.x/dd, dxv = d1.y/dd, dyu = d2.x/dd, dxu =-d2.y/dd; + register float xx = (i-p1.x), yy = (j-p1.y); + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; + if(u<0 || v<0 || u+v>1) return; + mglPnt p = p1+d1*u+d2*v; + if(mgl_isnan(p.u) && mgl_isnum(p.v) && anorm) + { mglPoint nr = mglPoint(p2.x-p1.x,p2.y-p1.y,p2.z-p1.z)^mglPoint(p3.x-p1.x,p3.y-p1.y,p3.z-p1.z); + p.u = nr.x; p.v = nr.y; p.w = nr.z; } + unsigned char r[4]; + pnt_plot(i,j,p.z,col2int(p,r,d->ObjId),d->ObjId); +} +//----------------------------------------------------------------------------- +//#define mgl_sline(c,x) (unsigned char)((c)/cosh(x)) +inline unsigned char mgl_sline(unsigned char c,float x) +{ x*=x/2; return (unsigned char)((c)/(1+x+x*x/5)); } +void mglCanvas::line_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *dr) +{ + if((Quality&3)<2) { fast_draw(p1,p2,dr); return; } + unsigned char r[4]; + long y1,x1,y2,x2; + + float pw=dr->PenWidth, dxu,dxv,dyu,dyv,dd,dpw=3; + float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + + if(dr->ObjId==HighId) { pw *= 2; dpw=2; } + mglPnt d=p2-p1, p; + bool hor = fabs(d.x)>fabs(d.y); + + x1 = long(p1.xp2.x?p1.x:p2.x); y2 = long(p1.y>p2.y?p1.y:p2.y); + x1 -= pw+3.5; x2 += pw+3.5; + y1 -= pw+3.5; y2 += pw+3.5; + x1=x1>dr->x1?x1:dr->x1; x2=x2x2?x2:dr->x2; + y1=y1>dr->y1?y1:dr->y1; y2=y2y2?y2:dr->y2; + dd = hypot(d.x, d.y); + if(x1>x2 || y1>y2 || dd<1e-5) return; + + dxv = d.y/dd; dyv =-d.x/dd; + dxu = d.x/dd; dyu = d.y/dd; + + if(hor) for(long i=x1;i<=x2;i++) + { + y1 = int(p1.y+d.y*(i-p1.x)/d.x - pw - 3.5); + y2 = int(p1.y+d.y*(i-p1.x)/d.x + pw + 3.5); + y1=y1>dr->y1?y1:dr->y1; y2=y2y2?y2:dr->y2; + if(y1>y2) continue; + for(long j=y1;j<=y2;j++) + { + register float xx = (i-p1.x), yy = (j-p1.y); + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; v = v*v; + if(u<0) v += u*u; + else if(u>dd) v += (u-dd)*(u-dd); + if(v>pw*pw) continue; + if(!(dr->PDef & ( 1<pPos+u/pw/1.5, 16)) ) )) continue; + p = p1+d*(u/dd); col2int(p,r,dr->ObjId); + r[3] = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + pnt_plot(i,j,p.z+dz,r,dr->ObjId); + } + } + else for(long j=y1;j<=y2;j++) + { + x1 = int(p1.x+d.x*(j-p1.y)/d.y - pw - 3.5); + x2 = int(p1.x+d.x*(j-p1.y)/d.y + pw + 3.5); + x1=x1>dr->x1?x1:dr->x1; x2=x2x2?x2:dr->x2; + if(x1>x2) continue; + + for(long i=x1;i<=x2;i++) + { + register float xx = (i-p1.x), yy = (j-p1.y); + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; v = v*v; + if(u<0) v += u*u; + else if(u>dd) v += (u-dd)*(u-dd); + if(v>pw*pw) continue; + if(!(dr->PDef & (1<pPos+u/pw/1.5, 16))))) continue; + p = p1+d*(u/dd); col2int(p,r,dr->ObjId); + r[3] = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + pnt_plot(i,j,p.z+dz,r,dr->ObjId); + } + } +} +//----------------------------------------------------------------------------- +void mglCanvas::pnt_fast(long x,long y,mreal z,const unsigned char ci[4], int obj_id) +{ + register long i0=x+Width*(Height-1-y); + if(ci[3]!=0 && z>Z[3*i0]) // point upper the background + { Z[3*i0]=z; memcpy(C+12*i0,ci,4); OI[i0]=obj_id; } +} +//----------------------------------------------------------------------------- +void mglCanvas::fast_draw(const mglPnt &p1, const mglPnt &p2, const mglDrawReg *dr) +{ + if(p1.x==p2.x && p1.y==p2.y) return; + mglPnt d=p2-p1; + unsigned char r[4]; col2int(p1,r,dr->ObjId); + long y1,x1,y2,x2; + + bool hor = fabs(d.x)>fabs(d.y); + + x1 = long(p1.xp2.x?p1.x:p2.x); y2 = long(p1.y>p2.y?p1.y:p2.y); + x1=x1>dr->x1?x1:dr->x1; x2=x2x2?x2:dr->x2; + y1=y1>dr->y1?y1:dr->y1; y2=y2y2?y2:dr->y2; + if(x1>x2 || y1>y2) return; + float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + + if(hor) for(long i=x1;i<=x2;i++) + { + register long c = long(p1.y+d.y*(i-p1.x)/d.x); + if(c>=y1 && c<=y2) + pnt_fast(i, c, p1.z+d.z*(i-p1.x)/d.x+dz, r,dr->ObjId); + } + else for(long i=y1;i<=y2;i++) + { + register long c = long(p1.x+d.x*(i-p1.y)/d.y); + if(c>=x1 && c<=x2) + pnt_fast(c, i, p1.z+d.z*(i-p1.y)/d.y+dz, r,dr->ObjId); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::line_pix(long i, long j, const mglPnt &p1, const mglPnt &p2, const mglDrawReg *dr) +{ + register float xx = (i-p1.x), yy = (j-p1.y); + mglPnt d=p2-p1; + register float dd = hypot(d.x, d.y); + register float dxv = d.y/dd, dyv =-d.x/dd, dxu = d.x/dd, dyu = d.y/dd; + register float u = dxu*xx+dyu*yy, v = dxv*xx+dyv*yy; v = v*v; + if(u<0) v += u*u; + else if(u>dd) v += (u-dd)*(u-dd); + register float pw=dr->PenWidth, dpw=3; + if(dr->ObjId==HighId) { pw *= 2; dpw=2; } + if(v>pw*pw || !(dr->PDef & ( 1<pPos+u/pw/1.5, 16)) ) )) return; + mglPnt p = p1+d*(u/dd); + unsigned char r[4]; + col2int(p,r,dr->ObjId); + r[3] = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + register float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + pnt_plot(i,j,p.z+dz,r,dr->ObjId); +} +//----------------------------------------------------------------------------- +void mglCanvas::pnt_draw(const mglPnt &p, const mglDrawReg *dr) +{ +// if(k<0 || !dr) return; + float pw=3*dr->PenWidth,dpw=3; + if(dr->ObjId==HighId) { pw *= 2; dpw=2; } + unsigned char cs[4], cc; + col2int(p,cs,dr->ObjId); cc = cs[3]; + if(cc==0) return; + long s = long(5.5+fabs(pw)); + long i1=fmax(-s,dr->x1-p.x),i2=fmin(s,dr->x2-p.x), j1=fmax(-s,dr->y1-p.y),j2=fmin(s,dr->y2-p.y); + if(!(Quality&3)) for(long j=j1;j<=j2;j++) for(long i=i1;i<=i2;i++) // fast draw + { + register float v = i*i+j*j; + if(v>1+(pw-1)*(pw-1)/4) continue; + pnt_plot(p.x+i,p.y+j,p.z,cs,dr->ObjId); + } + else for(long j=j1;j<=j2;j++) for(long i=i1;i<=i2;i++) + { + register float v = i*i+j*j; + cs[3] = v<(pw-1)*(pw-1)/4 ? cc : mgl_sline(cc,dpw*(sqrt(v)+(1-pw)/2)); + pnt_plot(p.x+i,p.y+j,p.z,cs,dr->ObjId); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::pnt_pix(long i, long j, const mglPnt &p, const mglDrawReg *dr) +{ + register float pw=3*dr->PenWidth,dpw=3; + if(dr->ObjId==HighId) { pw *= 2; dpw=2; } + unsigned char cs[4]; + col2int(p,cs,dr->ObjId); + register float xx = (i-p.x), yy = (j-p.y), v = xx*xx+yy*yy; + if(cs[3]==0 || v>(5.5+pw)*(5.5+pw)) return; + if(v<(pw-1)*(pw-1)/4) cs[3] = mgl_sline(cs[3],dpw*(sqrt(v)+(1-pw)/2)); + pnt_plot(i,j,p.z,cs,dr->ObjId); +} +//----------------------------------------------------------------------------- +void mglCanvas::mark_draw(const mglPnt &q, char type, mreal size, mglDrawReg *d) +{ + unsigned char cs[4], ca; col2int(q,cs,d->ObjId); ca = cs[3];// = size>0 ? 255 : 255*q.t; + mreal ss=fabs(size), pw=1,dpw=3; + + if(type=='.' || ss==0) + { + if(d) pw = 3*(ss?ss:sqrt(font_factor/400)); + register mreal dd = pw+3.5; + long x1 = long(q.x-dd), y1 = long(q.y-dd); // bounding box + long x2 = long(q.x+dd), y2 = long(q.y+dd); + x1=x1>d->x1?x1:d->x1; x2=x2x2?x2:d->x2; + y1=y1>d->y1?y1:d->y1; y2=y2y2?y2:d->y2; + if(x1>x2 || y1>y2) return; + + if(d->ObjId==HighId) { pw *= 2; dpw=2; } + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v=dx*dx+dy*dy; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + } + else + { + if(d) + { + d->PDef = MGL_SOLID_MASK; d->angle = 0; + pw = d->PenWidth*fabs(50*size); + if(pw<1) pw=1; + } + if(!strchr("xsSoO",type)) ss *= 1.1; + if(d->ObjId==HighId) { pw *= 2; dpw=2; } + + register mreal dd = ss+pw+3.5; + long x1 = long(q.x-dd), y1 = long(q.y-dd); // bounding box + long x2 = long(q.x+dd), y2 = long(q.y+dd); + x1=x1>d->x1?x1:d->x1; x2=x2x2?x2:d->x2; + y1=y1>d->y1?y1:d->y1; y2=y2y2?y2:d->y2; + if(x1>x2 || y1>y2) return; + + switch(type) + { + case 'P': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = (dx-ss)*(dx-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dy)-ss; v = (dx+ss)*(dx+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dy)-ss; v = dx*dx+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy-ss)*(dy-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy+ss)*(dy+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = dy*dy+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case '+': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = dx*dx+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = dy*dy+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'X': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = (dx-ss)*(dx-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dy)-ss; v = (dx+ss)*(dx+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy-ss)*(dy-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy+ss)*(dy+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + + u = fabs(dx+dy)-2*ss; v = dx-dy; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx-dy)-2*ss; v = dx+dy; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'x': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dx+dy)-2*ss; v = dx-dy; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx-dy)-2*ss; v = dx+dy; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'S': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u = fabs(dy)-ss; if(u<0) u=0; + v = fabs(dx)-ss; if(v<0) v=0; v = u*u+v*v; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 's': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = (dx-ss)*(dx-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dy)-ss; v = (dx+ss)*(dx+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy-ss)*(dy-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx)-ss; v = (dy+ss)*(dy+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'D': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u = fabs(dx-dy)-ss; if(u<0) u=0; + v = fabs(dx+dy)-ss; if(v<0) v=0; v = u*u+v*v; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'd': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dx+dy)-ss; v = (dx-dy-ss)*(dx-dy-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx+dy)-ss; v = (dx-dy+ss)*(dx-dy+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx-dy)-ss; v = (dx+dy-ss)*(dx+dy-ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(dx-dy)-ss; v = (dx+dy+ss)*(dx+dy+ss)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'Y': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy+ss/2)-ss/2; v = dx*dx+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.87*dx+0.5*dy-ss/2)-ss/2; v = (0.5*dx-0.87*dy)*(0.5*dx-0.87*dy)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(-0.87*dx+0.5*dy-ss/2)-ss/2; v = (0.5*dx+0.87*dy)*(0.5*dx+0.87*dy)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case '*': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = dx*dx+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.87*dx+0.5*dy)-ss; v = (0.5*dx-0.87*dy)*(0.5*dx-0.87*dy)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(-0.87*dx+0.5*dy)-ss; v = (0.5*dx+0.87*dy)*(0.5*dx+0.87*dy)+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'T': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u=dy/1.5+ss/3; v=(dx+ss-u)/2; + if(u>0 && v>0 && u+v255?255:sum; cs[3] = ca*sum/255; + } + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case '^': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dx)-ss; v = dy+ss/2; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dx+0.83*dy)-0.9*ss; v = 0.83*dx-0.55*dy+0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dx-0.83*dy)-0.9*ss; v = 0.83*dx+0.55*dy-0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'V': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u=-dy/1.5+ss/3; v=(dx+ss-u)/2; + if(u>0 && v>0 && u+v255?255:sum; cs[3] = ca*sum/255; + } + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'v': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dx)-ss; v = dy-ss/2; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dx+0.83*dy)-0.9*ss; v = 0.83*dx-0.55*dy-0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dx-0.83*dy)-0.9*ss; v = 0.83*dx+0.55*dy+0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'L': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u=-dx/1.5+ss/3; v=(dy+ss-u)/2; + if(u>0 && v>0 && u+v255?255:sum; cs[3] = ca*sum/255; + } + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case '<': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = dx-ss/2; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dy+0.83*dx)-0.9*ss; v = 0.83*dy-0.55*dx-0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dy-0.83*dx)-0.9*ss; v = 0.83*dy+0.55*dx+0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'R': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + u=dx/1.5+ss/3; v=(dy+ss-u)/2; + if(u>0 && v>0 && u+v255?255:sum; cs[3] = ca*sum/255; + } + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case '>': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v,u; + register int sum=0; + u = fabs(dy)-ss; v = dx+ss/2; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dy+0.83*dx)-0.9*ss; v = 0.83*dy-0.55*dx+0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + u = fabs(0.55*dy-0.83*dx)-0.9*ss; v = 0.83*dy+0.55*dx-0.55*ss; v = v*v+(u<0?0:u*u); + sum += v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'O': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v; + v = hypot(dx,dy)-ss; v=v<0?0:v*v; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'o': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v; + v = hypot(dx,dy)-ss; v=v*v; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + case 'C': + for(long j=y1;j<=y2;j++) for(long i=x1;i<=x2;i++) + { + register float dx=i-q.x, dy=j-q.y, v; + v = hypot(dx,dy)-ss; v=v*v; + register int sum = v<(pw-1)*(pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-pw)/2)); + v = dx*dx+dy*dy; + sum += v<(2*pw-1)*(2*pw-1)/4 ? 255 : mgl_sline(255,dpw*(sqrt(v)+(1-2*pw)/2)); + sum = sum>255?255:sum; cs[3] = ca*sum/255; cs[3] = ca*sum/255; + pnt_plot(i,j,q.z+1,cs,d->ObjId); + } + break; + } + } +} +//----------------------------------------------------------------------------- +void mglCanvas::mark_pix(long i, long j, const mglPnt &q, char type, mreal size, mglDrawReg *d) +{ + unsigned char cs[4]; col2int(q,cs,d->ObjId); cs[3] = size>0 ? 255 : 255*q.t; + mglPnt p0=q,p1=q,p2=q,p3=q; + mreal ss=fabs(size); + + if(type=='.' || ss==0) + { + if(d) d->PenWidth = ss?ss:sqrt(font_factor/400); + pnt_pix(i,j,q,d); + } + else + { + if(d) + { + d->PDef = MGL_SOLID_MASK; d->angle = 0; + d->PenWidth*=fabs(50*size); + if(d->PenWidth<1) d->PenWidth=1; + } + if(!strchr("xsSoO",type)) ss *= 1.1; + switch(type) + { + case 'P': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p3,d); line_pix(i,j,p3,p0,d); + case '+': + p0.x = q.x-ss; p0.y = q.y; p1.x = q.x+ss; p1.y = q.y; line_pix(i,j,p0,p1,d); + p2.x = q.x; p2.y = q.y-ss; p3.x = q.x; p3.y = q.y+ss; line_pix(i,j,p2,p3,d); + break; + case 'X': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p3,d); line_pix(i,j,p3,p0,d); + case 'x': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y+ss; line_pix(i,j,p0,p1,d); + p2.x = q.x+ss; p2.y = q.y-ss; p3.x = q.x-ss; p3.y = q.y+ss; line_pix(i,j,p2,p3,d); + break; + case 'S': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x-ss; p1.y = q.y+ss; + p2.x= q.x+ss; p2.y= q.y+ss; p3.x = q.x+ss; p3.y = q.y-ss; + quad_pix(i,j,p0,p1,p3,p2,d); + case 's': + p0.x = q.x-ss; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y-ss; + p2.x = q.x+ss; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y+ss; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p3,d); line_pix(i,j,p3,p0,d); + break; + case 'D': + p0.x = q.x; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y; + p2.x= q.x; p2.y= q.y+ss; p3.x = q.x-ss; p3.y = q.y; + quad_pix(i,j,p0,p1,p3,p2,d); + case 'd': + p0.x = q.x; p0.y = q.y-ss; p1.x = q.x+ss; p1.y = q.y; + p2.x = q.x; p2.y = q.y+ss; p3.x = q.x-ss; p3.y = q.y; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p3,d); line_pix(i,j,p3,p0,d); + break; + case 'Y': + p1.x = q.x; p1.y = q.y-ss; line_pix(i,j,q,p1,d); + p2.x = q.x-0.8*ss; p2.y = q.y+0.6*ss; line_pix(i,j,q,p2,d); + p3.x = q.x+0.8*ss; p3.y = q.y+0.6*ss; line_pix(i,j,q,p3,d); + break; + case '*': + p0.x = q.x-ss; p0.y = q.y; + p1.x = q.x+ss; p1.y = q.y; line_pix(i,j,p0,p1,d); + p0.x = q.x-0.6*ss; p0.y = q.y-0.8*ss; + p1.x = q.x+0.6*ss; p1.y = q.y+0.8*ss; line_pix(i,j,p0,p1,d); + p0.x = q.x-0.6*ss; p0.y = q.y+0.8*ss; + p1.x = q.x+0.6*ss; p1.y = q.y-0.8*ss; line_pix(i,j,p0,p1,d); + break; + case 'T': + p0.x = q.x-ss; p0.y = q.y-ss/2; + p1.x = q.x+ss; p1.y = q.y-ss/2; + p2.x= q.x; p2.y= q.y+ss; + trig_pix(i,j,p0,p1,p2,false,d); + case '^': + p0.x = q.x-ss; p0.y = q.y-ss/2; + p1.x = q.x+ss; p1.y = q.y-ss/2; + p2.x= q.x; p2.y= q.y+ss; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p0,d); break; + case 'V': + p0.x = q.x-ss; p0.y = q.y+ss/2; + p1.x = q.x+ss; p1.y = q.y+ss/2; + p2.x= q.x; p2.y= q.y-ss; + trig_pix(i,j,p0,p1,p2,false,d); + case 'v': + p0.x = q.x-ss; p0.y = q.y+ss/2; + p1.x = q.x+ss; p1.y = q.y+ss/2; + p2.x= q.x; p2.y= q.y-ss; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p0,d); break; + case 'L': + p0.x = q.x+ss/2; p0.y = q.y+ss; + p1.x = q.x+ss/2; p1.y = q.y-ss; + p2.x= q.x-ss; p2.y= q.y; + trig_pix(i,j,p0,p1,p2,false,d); + case '<': + p0.x = q.x+ss/2; p0.y = q.y+ss; + p1.x = q.x+ss/2; p1.y = q.y-ss; + p2.x= q.x-ss; p2.y= q.y; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p0,d); break; + case 'R': + p0.x = q.x-ss/2; p0.y = q.y+ss; + p1.x = q.x-ss/2; p1.y = q.y-ss; + p2.x= q.x+ss; p2.y= q.y; + trig_pix(i,j,p0,p1,p2,false,d); + case '>': + p0.x = q.x-ss/2; p0.y = q.y+ss; + p1.x = q.x-ss/2; p1.y = q.y-ss; + p2.x= q.x+ss; p2.y= q.y; + line_pix(i,j,p0,p1,d); line_pix(i,j,p1,p2,d); + line_pix(i,j,p2,p0,d); break; + case 'O': + { + register float xx = (i-q.x), yy = (j-q.y); + register float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + if(xx*xx+yy*yyObjId); + // TODO add edge smoothing here? + } + case 'o': + { + register float pw=d->PenWidth, dpw=2; + register float xx = (i-q.x), yy = (j-q.y), v = hypot(xx,yy); + v = (v-ss)*(v-ss); + if(v>pw*pw) return; + if(v>(pw-1)*(pw-1)/4) cs[3] = mgl_sline(cs[3],dpw*(sqrt(v)+(1-pw)/2)); + register float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + pnt_plot(i,j,q.z+dz,cs,d->ObjId); + } + break; + case 'C': + pnt_pix(i,j,q,d); + { + register float pw=d->PenWidth, dpw=2; + register float xx = (i-q.x), yy = (j-q.y), v = hypot(xx,yy); + v = (v-ss)*(v-ss); + if(v>pw*pw) return; + if(v>(pw-1)*(pw-1)/4) cs[3] = mgl_sline(cs[3],dpw*(sqrt(v)+(1-pw)/2)); + register float dz = Width>2 ? 1 : 1e-5*Width; // provide additional height to be well visible on the surfaces + pnt_plot(i,j,q.z+dz,cs,d->ObjId); + } + break; + } + } +} +//----------------------------------------------------------------------------- +// scale direction for new view/zoom +float mglCanvas::GetGlyphPhi(const mglPnt &q, float phi) +{ + float x,y,z,ll; + if(q.sub) + { x = q.u; y = q.v; z = q.w; } + else + { + x = Bp.b[0]*q.u + Bp.b[1]*q.v + Bp.b[2]*q.w; + y = Bp.b[3]*q.u + Bp.b[4]*q.v + Bp.b[5]*q.w; + z = Bp.b[6]*q.u + Bp.b[7]*q.v + Bp.b[8]*q.w; + + register float dv = (1-Bp.pf)/(1-Bp.pf*q.z/Depth); + register float c=Bp.pf/(1-Bp.pf)/Depth; + x += (q.x-Width/2)*z*c*dv; + y += (q.y-Height/2)*z*c*dv; + } + ll = x*x+y*y; + if(ll < 1e-10) return NAN; + if(ll==ll && phi<1e4) + { + phi = -atan2(y,x)*180/M_PI; + if(fabs(phi)>90) phi+=180; + } + else phi=0; + return phi; +} +//----------------------------------------------------------------------------- +void mglCanvas::glyph_draw(const mglPrim &P, mglDrawReg *d) +{ + float phi = GetGlyphPhi(Pnt[P.n2],P.w); + if(mgl_isnan(phi)) return; + + if(d) { d->PDef = MGL_SOLID_MASK; d->angle = 0; d->PenWidth=0.6; } + mglPnt p=Pnt[P.n1]; + // NOTE check this later for mglInPlot + mreal pf=p.sub<0?1:sqrt((Bp.b[0]*Bp.b[0]+Bp.b[1]*Bp.b[1]+Bp.b[3]*Bp.b[3]+Bp.b[4]*Bp.b[4])/2), f = P.p*pf; + + mglMatrix M; + M.b[0] = M.b[4] = M.b[8] = P.s; + M.RotateN(phi,0,0,1); + M.x=p.x; M.y=p.y; M.z=p.z; M.pf = 1; + p.u *= pf; p.v *= pf; + + const mglGlyph &g = Glf[P.n4]; + if(P.n3&8) + { + if(!(P.n3&4)) glyph_line(&M,p,f,true, d); + glyph_line(&M,p,f,false, d); + } + else + { + if(!(P.n3&4)) glyph_fill(&M,p,f,g, d); + glyph_wire(&M,p,f,g, d); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::glyph_fill(const mglMatrix *M, const mglPnt &pp, mreal f, const mglGlyph &g, const mglDrawReg *d) +{ + if(!g.trig || g.nt<=0) return; + mglPnt q0=pp, q1=pp, q2=pp; + q0.u=q0.v=q1.u=q1.v=q2.u=q2.v=NAN; + for(long ik=0;ikPDef = MGL_SOLID_MASK; d->angle = 0; d->PenWidth=1; } + mglPnt p=Pnt[P.n1]; + mreal pf=sqrt((Bp.b[0]*Bp.b[0]+Bp.b[1]*Bp.b[1]+Bp.b[3]*Bp.b[3]+Bp.b[4]*Bp.b[4])/2), f = P.p*pf; + + mglMatrix M; + M.b[0] = M.b[4] = M.b[8] = P.s; + M.RotateN(phi,0,0,1); + M.x=p.x; M.y=p.y; M.z=p.z; M.pf = 1; + p.u *= pf; p.v *= pf; + + const mglGlyph &g = Glf[P.n4]; + if(P.n3&8) + { + if(!(P.n3&4)) glyph_lpix(i,j,&M,p,f,true, d); + glyph_lpix(i,j,&M,p,f,false, d); + } + else + { + if(!(P.n3&4)) glyph_fpix(i,j,&M,p,f,g, d); + glyph_wpix(i,j,&M,p,f,g, d); + } +} +//----------------------------------------------------------------------------- +void mglCanvas::glyph_fpix(long i, long j, const mglMatrix *M, const mglPnt &pp, mreal f, const mglGlyph &g, const mglDrawReg *d) +{ + if(!g.trig || g.nt<=0) return; + mglPnt q0=pp, q1=pp, q2=pp; + q0.u=q0.v=q1.u=q1.v=q2.u=q2.v=NAN; + for(long ik=0;ik0 && i0) quad_plot(nn[j-1], nn[j], nn[j+n-1], nn[j+n]); + } + delete []nn; break; + } + } +} +//----------------------------------------------------------------------------- diff --git a/src/plot.cpp b/src/plot.cpp new file mode 100644 index 0000000..c9ee24a --- /dev/null +++ b/src/plot.cpp @@ -0,0 +1,1921 @@ +/*************************************************************************** + * plot.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/plot.h" +#include "mgl2/eval.h" +#include "mgl2/data.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// Plot by formulas series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fplot(HMGL gr, const char *eqY, const char *pen, const char *opt) +{ + if(eqY==0 || eqY[0]==0) return; // nothing to plot + mreal r = gr->SaveState(opt); + long n = (mgl_isnan(r) || r<=0) ? 100:long(r+0.5); + long nm = gr->FaceNum?gr->FaceNum*n:10000, nd = gr->FaceNum?gr->FaceNum*10:1000; + + mreal *x = (mreal *)malloc(n*sizeof(mreal)); + mreal *y = (mreal *)malloc(n*sizeof(mreal)); + mglFormula *eq = new mglFormula(eqY); + mreal xs, ys, yr, ym=fabs(gr->Max.y - gr->Min.y)/nd; +#define islog(a, b) (((a)>0 && (b)>10*(a)) || ((b)<0 && (a)<10*(b))) + // initial data filling + if(gr->Min.x>0 && gr->Max.x>100*gr->Min.x) + { + mreal d = log(2*gr->Max.x/gr->Min.x)/(n-1); +#pragma omp parallel for + for(long i=0;iMax.x*exp(d*i)/(2*gr->Max.x/gr->Min.x+exp(d*i)); y[i]=eq->Calc(x[i]); } + } + else if(gr->Max.x<0 && gr->Min.x<100*gr->Max.x) + { + mreal d = log(2*gr->Min.x/gr->Max.x)/(n-1); +#pragma omp parallel for + for(long i=0;iMin.x*exp(d*i)/(2*gr->Min.x/gr->Max.x+exp(d*i)); y[i]=eq->Calc(x[i]); } + } + else + { + mreal d = (gr->Max.x - gr->Min.x)/(n-1.); +#pragma omp parallel for + for(long i=0;iMin.x + i*d; y[i]=eq->Calc(x[i]); } + } + + for(long i=0;iStop) { free(x); free(y); delete eq; return; } + xs=(x[i]+x[i+1])/2; + ys=(y[i]+y[i+1])/2; yr=eq->Calc(xs); + if(fabs(yr-ys)>ym) // bad approximation here + { + x = (mreal *)realloc(x,(n+1)*sizeof(mreal)); + y = (mreal *)realloc(y,(n+1)*sizeof(mreal)); + memmove(x+i+2,x+i+1,(n-i-1)*sizeof(mreal)); + memmove(y+i+2,y+i+1,(n-i-1)*sizeof(mreal)); + x[i+1] = xs; y[i+1] = yr; n++; + } + else i++; + } + + delete eq; + mglData yy,xx; + xx.Set(x,n); free(x); + yy.Set(y,n); free(y); + mgl_plot_xy(gr,&xx,&yy,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fplot_xyz(HMGL gr, const char *eqX, const char *eqY, const char *eqZ, const char *pen, const char *opt) +{ + mreal r = gr->SaveState(opt); + long n = (mgl_isnan(r) || r<=0) ? 100:long(r+0.5); + + mreal *x = (mreal *)malloc(n*sizeof(mreal)); + mreal *y = (mreal *)malloc(n*sizeof(mreal)); + mreal *z = (mreal *)malloc(n*sizeof(mreal)); + mreal *t = (mreal *)malloc(n*sizeof(mreal)); + mglFormula *ex, *ey, *ez; + ex = new mglFormula(eqX ? eqX : "0"); + ey = new mglFormula(eqY ? eqY : "0"); + ez = new mglFormula(eqZ ? eqZ : "0"); + mreal ts, xs, ys, zs, xr, yr, zr, xm=fabs(gr->Max.x - gr->Min.x)/1000, ym=fabs(gr->Max.y - gr->Min.y)/1000, zm=fabs(gr->Max.z - gr->Min.z)/1000; +#pragma omp parallel for + for(long i=0;iStop) continue; + t[i] = i/(n-1.); + x[i] = ex->Calc(0,0,t[i]); + y[i] = ey->Calc(0,0,t[i]); + z[i] = ez->Calc(0,0,t[i]); + } + + for(long i=0;iStop) + { + free(x); free(y); free(z); free(t); + delete ex; delete ey; delete ez; return; + } + ts=(t[i]+t[i+1])/2; + xs=(x[i]+x[i+1])/2; xr=ex->Calc(0,0,ts); + ys=(y[i]+y[i+1])/2; yr=ey->Calc(0,0,ts); + zs=(z[i]+z[i+1])/2; zr=ez->Calc(0,0,ts); + if(fabs(xr-xs)>xm || fabs(yr-ys)>ym || fabs(zr-zs)>zm) // bad approximation here + { + z = (mreal *)realloc(z,(n+1)*sizeof(mreal)); + t = (mreal *)realloc(t,(n+1)*sizeof(mreal)); + x = (mreal *)realloc(x,(n+1)*sizeof(mreal)); + y = (mreal *)realloc(y,(n+1)*sizeof(mreal)); + memmove(x+i+2,x+i+1,(n-i-1)*sizeof(mreal)); + memmove(y+i+2,y+i+1,(n-i-1)*sizeof(mreal)); + memmove(z+i+2,z+i+1,(n-i-1)*sizeof(mreal)); + memmove(t+i+2,t+i+1,(n-i-1)*sizeof(mreal)); + t[i+1]=ts; x[i+1]=xr; y[i+1]=yr; z[i+1]=zr; n++; + } + else i++; + } + delete ex; delete ey; delete ez; + + mglData xx,yy,zz; + xx.Set(x,n); yy.Set(y,n); zz.Set(z,n); + free(x); free(y); free(z); free(t); + mgl_plot_xyz(gr,&xx,&yy,&zz,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fplot_(uintptr_t *gr, const char *fy, const char *stl, const char *opt, int ly, int ls, int lo) +{ char *s=new char[ly+1]; memcpy(s,fy,ly); s[ly]=0; + char *p=new char[ls+1]; memcpy(p,stl,ls); p[ls]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_fplot(_GR_, s, p, o); + delete []s; delete []p; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fplot_xyz_(uintptr_t *gr, const char *fx, const char *fy, const char *fz, const char *stl, const char *opt, int lx, int ly, int lz, int ls, int lo) +{ char *sx=new char[lx+1]; memcpy(sx,fx,lx); sx[lx]=0; + char *sy=new char[ly+1]; memcpy(sy,fy,ly); sy[ly]=0; + char *sz=new char[lz+1]; memcpy(sz,fz,lz); sz[lz]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + char *p=new char[ls+1]; memcpy(p,stl,ls); p[ls]=0; + mgl_fplot_xyz(_GR_, sx, sy, sz, p, o); + delete []sx; delete []sy; delete []sz; delete []p; delete []o; } +//----------------------------------------------------------------------------- +// +// Radar series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_radar(HMGL gr, HCDT a, const char *pen, const char *opt) +{ + long n = a->GetNx(), ny=a->GetNy(); + if(n<2) { gr->SetWarn(mglWarnLow,"Radar"); return; } + mglData x(n+1,ny), y(n+1,ny); + mreal m=a->Minimal(), r=gr->SaveState(opt); + if(mgl_isnan(r) || r<0) r = m<0 ? -m:0; + mreal *co=new mreal[2*n]; +#pragma omp parallel for + for(long i=0;iv(i,j); + x.a[i+(n+1)*j] = (r+v)*co[i]; + y.a[i+(n+1)*j] = (r+v)*co[i+n]; + } + x.a[n+(n+1)*j] = r+a->v(0,j); y.a[n+(n+1)*j] = 0; + } + mgl_plot_xy(gr,&x,&y,pen,0); + if(mglchr(pen,'#')) // draw "grid" + { + m = 1.1*(a->Maximal()+r); + x.Create(2); y.Create(2); + for(long i=0;i0) + { + x.Create(101); y.Create(101); +#pragma omp parallel for + for(long i=0;i<91;i++) + { x.a[i]=r*mgl_cos[(4*i)%360]; y.a[i]=r*mgl_cos[(270+4*i)%360]; } + mgl_plot_xy(gr,&x,&y,"k",0); + } + } + delete []co; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_radar_(uintptr_t *gr, uintptr_t *a, const char *pen, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_radar(_GR_, _DA_(a),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +// +// Candle series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle_xyv(HMGL gr, HCDT x, HCDT v1, HCDT v2, HCDT y1, HCDT y2, const char *pen, const char *opt) +{ + long n=v1->GetNx(),pal,nx=x->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Candle"); return; } + if(nxGetNx()!=n) { gr->SetWarn(mglWarnDim,"Candle"); return; } + bool d1=false,d2=false; + if(!y1) { y1 = new mglData(n); d1=true; ((mglData *)y1)->Fill(NAN,NAN); } + if(!y2) { y2 = new mglData(n); d2=true; ((mglData *)y2)->Fill(NAN,NAN); } + if(y1->GetNx()!=n || y2->GetNx()!=n) + { gr->SetWarn(mglWarnDim,"Candle"); return; } + static int cgid=1; gr->StartGroup("Candle",cgid++); + gr->SaveState(opt); gr->SetPenPal(pen,&pal); + gr->NextColor(pal); gr->Reserve(8*n); + bool sh = mglchr(pen,'!'); + + mreal dv=nx>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + mreal zm = gr->AdjustZMin(); +#pragma omp parallel for + for(long i=0;iStop) continue; + mreal m1=v1->v(i), m2 = v2->v(i), xx = x->v(i); + mreal d = iv(i+1)-xx : xx-x->v(i-1); + mreal x1 = xx + d/2*(dv-gr->BarWidth); + mreal x2 = x1 + gr->BarWidth*d; xx = (x1+x2)/2; + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(xx,y1->v(i),zm),c); + long n2 = gr->AddPnt(mglPoint(xx,m1,zm),c); + gr->line_plot(n1,n2); + long n3 = gr->AddPnt(mglPoint(xx,y2->v(i),zm),c); + long n4 = gr->AddPnt(mglPoint(xx,m2,zm),c); + gr->line_plot(n3,n4); + + n1 = gr->AddPnt(mglPoint(x1,m1,zm),c); + n2 = gr->AddPnt(mglPoint(x2,m1,zm),c); + n3 = gr->AddPnt(mglPoint(x1,m2,zm),c); + n4 = gr->AddPnt(mglPoint(x2,m2,zm),c); + gr->line_plot(n1,n2); gr->line_plot(n1,n3); + gr->line_plot(n4,n2); gr->line_plot(n4,n3); + if(m1>m2) gr->quad_plot(n1,n2,n3,n4); + } + if(d1) delete y1; if(d2) delete y2; + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle_yv(HMGL gr, HCDT v1, HCDT v2, HCDT y1, HCDT y2, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(v1->GetNx()+1); + x.Fill(gr->Min.x,gr->Max.x); + mgl_candle_xyv(gr,&x,v1,v2,y1,y2,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle(HMGL gr, HCDT v1, HCDT y1, HCDT y2, const char *pen, const char *opt) +{ + mglData v2(v1); + v2.Roll('x',1); v2.a[0]=NAN; + mgl_candle_yv(gr,v1,&v2,y1,y2,pen,opt); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle_xyv_(uintptr_t *gr, uintptr_t *x, uintptr_t *v1, uintptr_t *v2, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_candle_xyv(_GR_,_DA_(x),_DA_(v1),_DA_(v2),_DA_(y1),_DA_(y2),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle_yv_(uintptr_t *gr, uintptr_t *v1, uintptr_t *v2, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_candle_yv(_GR_,_DA_(v1),_DA_(v2),_DA_(y1),_DA_(y2),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_candle_(uintptr_t *gr, uintptr_t *y, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_candle(_GR_,_DA_(y),_DA_(y1),_DA_(y2),s,o); + delete []s; delete []o; } +//----------------------------------------------------------------------------- +// +// Plot series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long j,m,mx,my,mz,n=y->GetNx(),pal; + if(mgl_check_dim1(gr,x,y,z,0,"Plot")) return; + + static int cgid=1; gr->StartGroup("Plot",cgid++); + gr->SaveState(opt); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); + bool t1,t2,t3; + mglPoint p1,nn,p2,pt; + long n1=-1,n2=-1,n3=-1; + bool sh = mglchr(pen,'!'); + + for(j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; gr->NextColor(pal); + t1 = t2 = false; + register long i; + for(i=0;iStop) return; + if(i>0) { n2=n1; p2 = p1; t2=t1; } + p1 = mglPoint(x->v(i,mx), y->v(i,my), z->v(i,mz)); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + n1 = gr->AddPnt(p1,c); t1 = n1>=0; + if(mk && t1) gr->mark_plot(n1,mk); + if(t1 && t2) + { + gr->line_plot(n1,n2); + if(i==1) gr->arrow_plot(n2,n1,gr->Arrow1); + if(i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + } + + if(i>0 && ((t1 && !t2) || (t2 && !t1))) // do smoothing + { + mreal i1=0, i2=1, ii; + mglPoint q(NAN),p; + do { + ii = (i1+i2)/2; + pt.x = p1.x*ii+p2.x*(1-ii); + pt.y = p1.y*ii+p2.y*(1-ii); + pt.z = p1.z*ii+p2.z*(1-ii); p=pt; + t3 = gr->ScalePoint(gr->GetB(),p,q,false); + if((t1 && t3) || (t2 && !t3)) i2 = ii; + else i1 = ii; + } while(fabs(i2-i1)>1e-3); + n3 = gr->AddPnt(pt,c,q,-1,2); + if(t2) gr->line_plot(n3,n2); + else gr->line_plot(n1,n3); + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_plot_xyz(gr,x,y,&z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Plot"); return; } + gr->SaveState(opt); + mglData x(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_plot_xyz(gr,&x,y,&z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_plot_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_plot_xy(_GR_, _DA_(x),_DA_(y),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_plot_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_plot(_GR_, _DA_(y),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +// +// Tens series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, const char *pen, const char *opt) +{ + long j,m,mx,my,mz,mc,n=y->GetNx(), pal; + if(mgl_check_dim1(gr,x,y,z,0,"Tens")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Tens",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + char mk=gr->SetPenPal(pen, &pal); gr->Reserve(2*n*m); + long ss=gr->AddTexture(pen); + bool t1,t2,t3; + mglPoint p1,p2,pt,nn; + long n1=-1,n2=-1,n3=-1; + + for(j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; mc = jGetNy() ? j:0; + register long i; + t1 = t2 = false; + for(i=0;iStop) return; + if(i>0) { n2=n1; p2=p1; t2=t1; } + p1 = mglPoint(x->v(i,mx), y->v(i,my), z->v(i,mz), c->v(i,mc)); + n1 = gr->AddPnt(p1,gr->GetC(ss,p1.c)); t1 = n1>=0; + if(mk && t1) gr->mark_plot(n1,mk); + if(t1 && t2) + { + gr->line_plot(n1,n2); + if(i==1) gr->arrow_plot(n2,n1,gr->Arrow1); + if(i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + } + + if(i>0 && ((t1 && !t2) || (t2 && !t1))) // do smoothing + { + mreal i1=0, i2=1, ii; + mglPoint q(NAN),p; + do { + ii = (i1+i2)/2; + pt.x = p1.x*ii+p2.x*(1-ii); + pt.y = p1.y*ii+p2.y*(1-ii); + pt.z = p1.z*ii+p2.z*(1-ii); p=pt; + pt.c = p1.c*ii+p2.c*(1-ii); + t3 = gr->ScalePoint(gr->GetB(),p,q,false); + if((t1 && t3) || (t2 && !t3)) i2 = ii; + else i1 = ii; + } while(fabs(i2-i1)>1e-3); + n3 = gr->AddPnt(pt,gr->GetC(ss,pt.c),q,-1,2); + if(t2) gr->line_plot(n3,n2); + else gr->line_plot(n1,n3); + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens_xy(HMGL gr, HCDT x, HCDT y, HCDT c, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tens_xyz(gr,x,y,&z,c,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens(HMGL gr, HCDT y, HCDT c, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Tens"); return; } + gr->SaveState(opt); + mglData x(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tens_xyz(gr,&x,y,&z,c,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *c, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tens_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),_DA_(c),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *c, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tens_xy(_GR_, _DA_(x),_DA_(y),_DA_(c),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tens_(uintptr_t *gr, uintptr_t *y, uintptr_t *c, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tens(_GR_, _DA_(y),_DA_(c),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Area series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long i,j,n=y->GetNx(),m,mx,my,mz,pal; + if(mgl_check_dim1(gr,x,y,z,0,"Area")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Area3",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + bool sh = mglchr(pen,'!'); + bool wire = mglchr(pen,'#'); + + mreal z0=gr->GetOrgZ('x'); + mreal c1,c2; + mglPoint p1,p2,p3,p4,nn; + long n1,n2,n3,n4; + gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); +// long s=gr->AddTexture(pen,1); + for(j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2 = gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; + + nn = mglPoint(-y->dvx(0,my),x->dvx(0,mx)); + mglPoint p = mglPoint(x->v(0,mx),y->v(0,my),z->v(0,mz)); + n1 = gr->AddPnt(p,c1,nn,-1,11); p.z = z0; n2 = gr->AddPnt(p,c2,nn,-1,11); + for(i=1;iStop) return; + n3=n1; n4=n2; + nn = mglPoint(-y->dvx(i,my),x->dvx(i,mx)); + p = mglPoint(x->v(i,mx),y->v(i,my),z->v(i,mz)); + if(sh) c2=c1=gr->NextColor(pal,i); + n1 = gr->AddPnt(p,c1,nn,-1,11); p.z = z0; n2 = gr->AddPnt(p,c2,nn,-1,11); + if(wire) + { + gr->line_plot(n1,n2); gr->line_plot(n3,n4); + gr->line_plot(n1,n3); gr->line_plot(n4,n2); + } + else gr->quad_plot(n1,n2,n3,n4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + long i,j,n=y->GetNx(),m=y->GetNy(),mx,my,pal; + if(mgl_check_dim1(gr,x,y,0,0,"Area")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Curve",cgid++); + mreal zm = gr->AdjustZMin(); + mreal y0=gr->GetOrgY('x'), z0; + mreal c1,c2; + mglPoint nn=mglPoint(0,0,1); + long n1,n2,n3,n4; + bool sh = mglchr(pen,'!'); + bool wire = mglchr(pen,'#'); + + gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); +// long s=gr->AddTexture(pen,1); + for(j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2=gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + z0 = zm + (m-1-j)*(gr->Max.z-zm)/m; + + mglPoint p = mglPoint(x->v(0,mx),y->v(0,my),z0); + n1 = gr->AddPnt(p,c1,nn,-1,11); p.y = y0; n2 = gr->AddPnt(p,c2,nn,-1,11); + for(i=1;iStop) return; + n3=n1; n4=n2; + p = mglPoint(x->v(i,mx),y->v(i,my),z0); + if(sh) c2=c1=gr->NextColor(pal,i); + n1 = gr->AddPnt(p,c1,nn,-1,11); p.y = y0; n2 = gr->AddPnt(p,c2,nn,-1,11); + if(wire) + { + gr->line_plot(n1,n2); gr->line_plot(n3,n4); + gr->line_plot(n1,n3); gr->line_plot(n4,n2); + } + else gr->quad_plot(n1,n2,n3,n4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mgl_area_xy(gr,&x,y,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_area_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_area_xy(_GR_, _DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_area_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_area(_GR_, _DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Region series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region_3d(HMGL gr, HCDT x1, HCDT y1, HCDT z1, HCDT x2, HCDT y2, HCDT z2, const char *pen, const char *opt) +{ + long i,j, n=y1->GetNx(), m, mx, my, mz, pal; + if(mgl_check_dim1(gr,x1,y1,z1,0,"Region")) return; + if(mgl_check_dim1(gr,x1,x2,y2,z2,"Region")) return; + m = x1->GetNy() > y1->GetNy() ? x1->GetNy() : y1->GetNy(); m = z1->GetNy() > m ? z1->GetNy() : m; + bool zhave = z1 && z2; + if(x1->GetNy()!=x2->GetNy() || y1->GetNy()!=y2->GetNy()) + { gr->SetWarn(mglWarnDim,"Region"); return; } + if(zhave && z1->GetNy()!=z2->GetNy()) + { gr->SetWarn(mglWarnDim,"Region"); return; } + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Region",cgid++); + mreal c1,c2; + mglPoint nn=mglPoint(0,0,1); + long n1,n2,n3,n4; + mreal zm = gr->AdjustZMin(); +// bool inside = (mglchr(pen,'i')); // NOTE: check if 'i' is free (used here for inside flag) + bool sh = mglchr(pen,'!'); + + gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); +// long s=gr->AddTexture(pen,1); + for(j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2=gr->NextColor(pal); + mx = jGetNy() ? j:0; + my = jGetNy() ? j:0; + mz = (zhave && jGetNy()) ? j:0; + mreal z0 = zm + (m-1-j)*(gr->Max.z-zm)/m; + + n1 = gr->AddPnt(mglPoint(x1->v(0,mx),y1->v(0,my),zhave?z1->v(0,mz):z0),c1,nn,-1,11); + n2 = gr->AddPnt(mglPoint(x2->v(0,mx),y2->v(0,my),zhave?z2->v(0,mz):z0),c2,nn,-1,11); + for(i=1;iStop) return; + n3=n1; n4=n2; + if(sh) c2=c1=gr->NextColor(pal,i); + n1 = gr->AddPnt(mglPoint(x1->v(i,mx),y1->v(i,my),zhave?z1->v(i,mz):z0),c1,nn,-1,11); + n2 = gr->AddPnt(mglPoint(x2->v(i,mx),y2->v(i,my),zhave?z2->v(i,mz):z0),c2,nn,-1,11); + gr->quad_plot(n1,n2,n3,n4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region_xy(HMGL gr, HCDT x, HCDT y1, HCDT y2, const char *pen, const char *opt) +{ + long i,j, n=y1->GetNx(), m=y1->GetNy(), mx, pal; + if(mgl_check_dim1(gr,x,y1,y2,0,"Region")) return; + if(y2->GetNy()!=m) { gr->SetWarn(mglWarnDim,"Region"); return; } + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Region",cgid++); + mreal c1,c2; + mglPoint nn=mglPoint(0,0,1); + long n1,n2,n3,n4; + mreal xx,f1,f2,f3,f4; + mreal zm = gr->AdjustZMin(); + bool inside = (mglchr(pen,'i')); // NOTE: check if 'i' is free (used here for inside flag) + bool sh = mglchr(pen,'!'); + + gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); +// long s=gr->AddTexture(pen,1); + for(j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2=gr->NextColor(pal); + mx = jGetNy() ? j:0; + mreal z0 = zm + (m-1-j)*(gr->Max.z-zm)/m; + + f1 = y1->v(0,j); f2 = y2->v(0,j); xx = x->v(0,mx); + n1 = gr->AddPnt(mglPoint(xx,f1,z0),c1,nn,-1,11); + n2 = gr->AddPnt(mglPoint(xx,f2,z0),c2,nn,-1,11); + for(i=1;iStop) return; + n3=n1; n4=n2; f3=f1; f4=f2; + f1 = y1->v(i,j); f2 = y2->v(i,j); xx = x->v(i,mx); + if(sh) c2=c1=gr->NextColor(pal,i); + n1 = gr->AddPnt(mglPoint(xx,f1,z0),c1,nn,-1,11); + n2 = gr->AddPnt(mglPoint(xx,f2,z0),c2,nn,-1,11); + if(!inside || (f2>f1 && f4>f3)) gr->quad_plot(n1,n2,n3,n4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region(HMGL gr, HCDT y1, HCDT y2, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y1->GetNx()); + x.Fill(gr->Min.x, gr->Max.x); + mgl_region_xy(gr,&x,y1,y2,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region_3d_(uintptr_t *gr, uintptr_t *x1, uintptr_t *y1, uintptr_t *z1, uintptr_t *x2, uintptr_t *y2, uintptr_t *z2, const char *pen, const char *opt, int l, int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_region_3d(_GR_, _DA_(x1),_DA_(y1),_DA_(z1),_DA_(x2),_DA_(y2),_DA_(z2),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt, int l, int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_region_xy(_GR_, _DA_(x),_DA_(y1),_DA_(y2),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_region_(uintptr_t *gr, uintptr_t *y1, uintptr_t *y2, const char *pen, const char *opt, int l, int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_region(_GR_, _DA_(y1),_DA_(y2),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Step series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long i,j,m,mx,my,mz,n=y->GetNx(), pal; + if(mgl_check_dim1(gr,x,y,z,0,"Step")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Step3",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + bool sh = mglchr(pen,'!'); + + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); + long n1,n2; + mglPoint p; + for(j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; gr->NextColor(pal); + n1 = gr->AddPnt(mglPoint(x->v(0,mx), y->v(0,my), z->v(0,mz))); + if(mk) gr->mark_plot(n1,mk); + for(i=1;iStop) return; + n2 = n1; // horizontal + p = mglPoint(x->v(i,mx), y->v(i,my), z->v(i-1,mz)); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + n1 = gr->AddPnt(p,c); gr->line_plot(n1,n2); + if(i==1) gr->arrow_plot(n2,n1,gr->Arrow1); + + n2 = n1; // vertical + p.z = z->v(i,mz); n1 = gr->AddPnt(p,c); + if(mk) gr->mark_plot(n1,mk); + gr->line_plot(n1,n2); + if(i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + long i,j,m,mx,my,n=y->GetNx(), pal; + if(mgl_check_dim1(gr,x,y,0,0,"Step")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Step",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + bool sh = mglchr(pen,'!'); + + mreal zVal =gr->AdjustZMin(); + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); + long n1,n2; + mglPoint p; + for(j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + gr->NextColor(pal); + n1 = gr->AddPnt(mglPoint(x->v(0,mx), y->v(0,my), zVal)); + if(mk) gr->mark_plot(n1,mk); + for(i=1;iStop) return; + n2 = n1; // horizontal + p = mglPoint(x->v(i,mx), y->v(i-1,my), zVal); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + n1 = gr->AddPnt(p,c); gr->line_plot(n1,n2); + if(i==1) gr->arrow_plot(n2,n1,gr->Arrow1); + + n2 = n1; // vertical + p.y = y->v(i,my); n1 = gr->AddPnt(p,c); + if(mk) gr->mark_plot(n1,mk); + gr->line_plot(n1,n2); + if(i==n-1) gr->arrow_plot(n1,n2,gr->Arrow2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mgl_step_xy(gr,&x,y,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_step_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_step_xy(_GR_, _DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_step_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_step(_GR_, _DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Stem series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long m,mx,my,mz,n=y->GetNx(), pal; + if(mgl_check_dim0(gr,x,y,z,0,"Stem")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Stem3",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + bool sh = mglchr(pen,'!'); + + mreal z0=gr->GetOrgZ('x'); + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); + for(long j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; gr->NextColor(pal); +#pragma omp parallel for + for(long i=0;iStop) continue; + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(x->v(i,mx), y->v(i,my), z->v(i,mz)),c); + if(mk) gr->mark_plot(n1,mk); + long n2 = gr->AddPnt(mglPoint(x->v(i,mx), y->v(i,my), z0),c); + gr->line_plot(n1,n2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + long m,mx,my,n=y->GetNx(), pal; + if(mgl_check_dim0(gr,x,y,0,0,"Stem")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Stem",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + bool sh = mglchr(pen,'!'); + + mreal zVal = gr->AdjustZMin(), y0=gr->GetOrgY('x'); + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(2*n*m); + for(long j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + gr->NextColor(pal); +#pragma omp parallel for + for(long i=0;iStop) continue; + mreal vv = x->v(i,mx); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vv, y->v(i,my), zVal),c); + if(mk) gr->mark_plot(n1,mk); + long n2 = gr->AddPnt(mglPoint(vv, y0, zVal),c); + gr->line_plot(n1,n2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mgl_stem_xy(gr,&x,y,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_stem_xyz(_GR_,_DA_(x),_DA_(y),_DA_(z),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_stem_xy(_GR_,_DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stem_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_stem(_GR_,_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Bars series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long m,mx,my,mz,n=z->GetNx(), pal,nx=x->GetNx(),ny=y->GetNx(); + if(mgl_check_dim1(gr,x,z,y,0,"Bars",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Bars3",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + m = z->GetNy() > m ? z->GetNy() : m; + bool sh = mglchr(pen,'!'); + + bool wire = mglchr(pen,'#'); + bool above = mglchr(pen,'a'), fall = mglchr(pen,'f'); + if(above) fall = false; + mreal c1,c2; + mreal *dd=new mreal[n], z0,zp,dv=nx>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + memset(dd,0,n*sizeof(mreal)); + + gr->SetPenPal(pen,&pal); + gr->Reserve(4*n*m); + for(long j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2 = gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; + zp = z0 = gr->GetOrgZ('x'); +#pragma omp parallel for ordered + for(long i=0;iStop) continue; + if(sh) c2=c1=gr->NextColor(pal,i); + mreal vv = x->v(i,mx), d = iv(i+1,mx)-vv : vv-x->v(i-1,mx), zz; + mreal x1 = vv + d/2*(dv-gr->BarWidth), x2 = x1 + gr->BarWidth*d; + vv = y->v(i,my); d = iv(i+1,my)-vv : vv-y->v(i-1,my); + mreal y1 = vv + d/2*(dv-gr->BarWidth), y2 = y1 + gr->BarWidth*d; + vv = zz = z->v(i,mz); + if(!above) + { + x2 = (x2-x1)/m; x1 += j*x2; x2 += x1; + y2 = (y2-y1)/m; y1 += j*y2; y2 += y1; + } + else +#pragma omp ordered + { z0 = gr->GetOrgZ('x') + dd[i]; dd[i] += zz; zz += z0; } + if(fall) +#pragma omp ordered + { z0 = zp; zz += z0; zp = zz; } + + mreal c = vv<0 ? c1 : c2; + mglPoint nn = mglPoint(-y->dvx(i,my),x->dvx(i,mx)); + long n1 = gr->AddPnt(mglPoint(x1,y1,zz),c,nn); + long n2 = gr->AddPnt(mglPoint(x1,y1,z0),c,nn); + long n3 = gr->AddPnt(mglPoint(x2,y2,z0),c,nn); + long n4 = gr->AddPnt(mglPoint(x2,y2,zz),c,nn); + if(wire) + { + gr->line_plot(n1,n2); gr->line_plot(n1,n4); + gr->line_plot(n3,n2); gr->line_plot(n3,n4); + } + else gr->quad_plot(n1,n2,n4,n3); + } + } + gr->EndGroup(); delete []dd; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + long m,mx,my,n=y->GetNx(),nx=x->GetNx(),pal; + if(mgl_check_dim1(gr,x,y,0,0,"Bars",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Bars",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + bool sh = mglchr(pen,'!'); + + bool wire = mglchr(pen,'#'); + bool above = mglchr(pen,'a'), fall = mglchr(pen,'f'); + if(above) fall = false; + mreal c1,c2; + mreal *dd=new mreal[n], y0,yp,dv=nx>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + mreal zm = gr->AdjustZMin(); + memset(dd,0,n*sizeof(mreal)); + + gr->SetPenPal(pen,&pal); + gr->Reserve(4*n*m); + for(long j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2 = gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + yp = y0 = gr->GetOrgY('x'); +#pragma omp parallel for ordered + for(long i=0;iStop) continue; + if(sh) c2=c1=gr->NextColor(pal,i); + mreal vv = x->v(i,mx), d = iv(i+1,mx)-vv : vv-x->v(i-1,mx), yy; + mreal x1 = vv + d/2*(dv-gr->BarWidth), x2 = x1 + gr->BarWidth*d; + vv = yy = y->v(i,my); + if(!above) + { x2 = (x2-x1)/m; x1 += j*x2; x2 += x1; } + else +#pragma omp ordered + { y0 = gr->GetOrgY('x') + dd[i]; dd[i] += yy; yy += y0; } + if(fall) +#pragma omp ordered + { y0 = yp; yy += y0; yp = yy; } + + mreal c = vv<0 ? c1 : c2; + long n1 = gr->AddPnt(mglPoint(x1,yy,zm),c); + long n2 = gr->AddPnt(mglPoint(x1,y0,zm),c); + long n3 = gr->AddPnt(mglPoint(x2,y0,zm),c); + long n4 = gr->AddPnt(mglPoint(x2,yy,zm),c); + if(wire) + { + gr->line_plot(n1,n2); gr->line_plot(n1,n4); + gr->line_plot(n3,n2); gr->line_plot(n3,n4); + } + else gr->quad_plot(n1,n2,n4,n3); + } + } + gr->EndGroup(); delete []dd; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()+1); + x.Fill(gr->Min.x,gr->Max.x); + mgl_bars_xy(gr,&x,y,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_bars_xyz(_GR_,_DA_(x),_DA_(y),_DA_(z),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_bars_xy(_GR_,_DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_bars_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_bars(_GR_,_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Barh series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_barh_yx(HMGL gr, HCDT y, HCDT v, const char *pen, const char *opt) +{ + long m,mx,my,n=v->GetNx(),ny=y->GetNx(),pal; + if(mgl_check_dim1(gr,y,v,0,0,"Barh",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Barh",cgid++); + m = y->GetNy() > v->GetNy() ? y->GetNy() : v->GetNy(); + bool sh = mglchr(pen,'!'); + + bool wire = mglchr(pen,'#'); + bool above = mglchr(pen,'a'), fall = mglchr(pen,'f'); + if(above) fall = false; + mreal c1,c2; + mreal *dd=new mreal[n], x0,xp,dv=ny>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + mreal zm = gr->AdjustZMin(); + memset(dd,0,n*sizeof(mreal)); + + gr->SetPenPal(pen,&pal); + gr->Reserve(4*n*m); + for(long j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2 = gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + xp = x0 = gr->GetOrgX('y'); +#pragma omp parallel for ordered + for(long i=0;iStop) continue; + if(sh) c2=c1=gr->NextColor(pal,i); + mreal vv = y->v(i,my), d = iv(i+1,my)-vv : vv-y->v(i-1,my), xx; + mreal y1 = vv + d/2*(dv-gr->BarWidth), y2 = y1 + gr->BarWidth*d; + vv = xx = v->v(i,mx); + if(!above) + { y2 = (y2-y1)/m; y1 += j*y2; y2 += y1; } + else +#pragma omp ordered + { x0 = gr->GetOrgX('y') + dd[i]; dd[i] += xx; xx += x0; } + if(fall) +#pragma omp ordered + { x0 = xp; xx += x0; xp = xx; } + + mreal c = vv<0 ? c1 : c2; + long n1 = gr->AddPnt(mglPoint(xx,y1,zm),c); + long n2 = gr->AddPnt(mglPoint(xx,y2,zm),c); + long n3 = gr->AddPnt(mglPoint(x0,y2,zm),c); + long n4 = gr->AddPnt(mglPoint(x0,y1,zm),c); + if(wire) + { + gr->line_plot(n1,n2); gr->line_plot(n1,n4); + gr->line_plot(n3,n2); gr->line_plot(n3,n4); + } + else gr->quad_plot(n1,n2,n4,n3); + } + } + gr->EndGroup(); delete []dd; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_barh(HMGL gr, HCDT v, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData y(v->GetNx()+1); + y.Fill(gr->Min.y,gr->Max.y); + mgl_barh_yx(gr,&y,v,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_barh_yx_(uintptr_t *gr, uintptr_t *y, uintptr_t *v, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_barh_yx(_GR_,_DA_(y),_DA_(v),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_barh_(uintptr_t *gr, uintptr_t *v, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_barh(_GR_,_DA_(v),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// OHLC series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ohlc_x(HMGL gr, HCDT x, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt) +{ + long n=open->GetNx(), nx=x->GetNx(), m=open->GetNy(), mx; + if(nxGetNx()*high->GetNy() || n*m!=low->GetNx()*low->GetNy() || n*m!=close->GetNx()*close->GetNy()) + { gr->SetWarn(mglWarnDim,"OHLC"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("OHLC",cgid++); + mreal dv=nx>n?1:0,dd,vv,x1,x2,cc; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + mreal zVal = gr->AdjustZMin(); + bool sh = mglchr(pen,'!'); + + long pal; + gr->SetPenPal(pen,&pal); gr->Reserve(6*n*m); + for(long j=0;jNextColor(pal); + mx = jGetNy() ? j:0; +#pragma omp parallel for private(vv,dd,x1,x2) + for(long i=0;iStop) continue; + vv = x->v(i,mx); dd = iv(i+1)-vv : vv-x->v(i-1); + x1 = vv + dd/2*(dv-gr->BarWidth); x2 = x1 + gr->BarWidth*dd; + x2 = (x2-x1)/m; x1 += j*x2; x2 += x1; vv = (x2+x1)/2; + mreal c = sh ? gr->NextColor(pal,i):cc; + register long n1,n2; + + dd = open->v(i,j); + n1=gr->AddPnt(mglPoint(x1,dd,zVal),c); + n2=gr->AddPnt(mglPoint(vv,dd,zVal),c); + gr->line_plot(n1,n2); + dd = close->v(i,j); + n1=gr->AddPnt(mglPoint(vv,dd,zVal),c); + n2=gr->AddPnt(mglPoint(x2,dd,zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(vv,low->v(i,j),zVal),c); + n2=gr->AddPnt(mglPoint(vv,high->v(i,j),zVal),c); + gr->line_plot(n1,n2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ohlc(HMGL gr, HCDT open, HCDT high, HCDT low, HCDT close, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(open->GetNx()+1); + x.Fill(gr->Min.x,gr->Max.x); + mgl_ohlc_x(gr,&x,open,high,low,close,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ohlc_x_(uintptr_t *gr, uintptr_t *x, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_ohlc_x(_GR_,_DA_(x),_DA_(open),_DA_(high),_DA_(low),_DA_(close),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ohlc_(uintptr_t *gr, uintptr_t *open, uintptr_t *high, uintptr_t *low, uintptr_t *close, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_ohlc(_GR_,_DA_(open),_DA_(high),_DA_(low),_DA_(close),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// BoxPlot series +// +//----------------------------------------------------------------------------- +double sgn(double a); +int MGL_NO_EXPORT mgl_cmp_flt(const void *a, const void *b) +{ + const mreal *aa = (const mreal *)a; + const mreal *bb = (const mreal *)b; + return int(sgn(*aa-*bb)); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxplot_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + long n=y->GetNx(), m=y->GetNy(), nx=x->GetNx(); + if(nxSetWarn(mglWarnDim,"BoxPlot"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("BoxPlot",cgid++); + mreal *b = new mreal[5*n], x1, x2, dd, dv=nx>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + mreal zVal = gr->AdjustZMin(), vv; + bool sh = mglchr(pen,'!'); +#pragma omp parallel + { + mreal *d = new mreal[m]; +#pragma omp for + for(long i=0;iStop) continue; + register long mm,k,j; + for(mm=j=0;jv(i,j); + if(mgl_isnum(vv)) { d[mm]=vv; mm++; } + } +// if(m==0) { b[i]=NAN; break; } + qsort(d, mm, sizeof(mreal), mgl_cmp_flt); + b[i] = d[0]; b[i+4*n] = d[mm-1]; k = mm/4; + b[i+n] = (mm%4) ? d[k] : (d[k]+d[k-1])/2.; + b[i+2*n] = (mm%2) ? d[mm/2] : (d[mm/2]+d[mm/2-1])/2.; + b[i+3*n] = (mm%4) ? d[mm-k-1] : (d[mm-k-1]+d[mm-k])/2.; + } + delete []d; + } + + long pal; + gr->SetPenPal(pen,&pal); gr->NextColor(pal); gr->Reserve(18*n); +#pragma omp parallel for private(vv,dd,x1,x2) + for(long i=0;iStop) continue; + vv = x->v(i); + dd = iv(i+1)-vv : vv-x->v(i-1); + x1 = vv + dd/2*(dv-gr->BarWidth); + x2 = x1 + gr->BarWidth*dd; + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + register long n1,n2; + // TODO why boxplot fail if I use for() + n1=gr->AddPnt(mglPoint(x1,b[i],zVal),c); // horizontal lines + n2=gr->AddPnt(mglPoint(x2,b[i],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(x1,b[i+n],zVal),c); + n2=gr->AddPnt(mglPoint(x2,b[i+n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(x1,b[i+2*n],zVal),c); + n2=gr->AddPnt(mglPoint(x2,b[i+2*n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(x1,b[i+3*n],zVal),c); + n2=gr->AddPnt(mglPoint(x2,b[i+3*n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(x1,b[i+4*n],zVal),c); + n2=gr->AddPnt(mglPoint(x2,b[i+4*n],zVal),c); + gr->line_plot(n1,n2); + + //vertical lines + n1=gr->AddPnt(mglPoint(x1,b[i+n],zVal),c); + n2=gr->AddPnt(mglPoint(x1,b[i+3*n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint(x2,b[i+n],zVal),c); + n2=gr->AddPnt(mglPoint(x2,b[i+3*n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint((x1+x2)/2,b[i],zVal),c); + n2=gr->AddPnt(mglPoint((x1+x2)/2,b[i+n],zVal),c); + gr->line_plot(n1,n2); + n1=gr->AddPnt(mglPoint((x1+x2)/2,b[i+3*n],zVal),c); + n2=gr->AddPnt(mglPoint((x1+x2)/2,b[i+4*n],zVal),c); + gr->line_plot(n1,n2); + } + delete []b; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxplot(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()+1); + x.Fill(gr->Min.x,gr->Max.x); + mgl_boxplot_xy(gr,&x,y,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxplot_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_boxplot_xy(_GR_,_DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxplot_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_boxplot(_GR_,_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Error series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_exy(HMGL gr, HCDT x, HCDT y, HCDT ex, HCDT ey, const char *pen, const char *opt) +{ + long m,mx,my,m1,m2,n=ey->GetNx(),pal; + if(mgl_check_dim0(gr,x,y,ey,ex,"Error")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Error",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + m = ex->GetNy() > m ? ex->GetNy() : m; + m = ey->GetNy() > m ? ey->GetNy() : m; + bool sh = mglchr(pen,'!'); + + bool ma = mglchr(pen,'@'); + char mk = gr->SetPenPal(pen,&pal); + mreal zVal=gr->AdjustZMin(); + gr->Reserve(5*n*m); + if(ma && (mk==0 || !strchr("PXsSdD+xoOC",mk) )) mk = 'S'; + gr->ResetMask(); + mglPoint q(NAN,NAN); + for(long j=0;jStop) return; + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + m1 = jGetNy() ? j:0; m2 = jGetNy() ? j:0; + gr->NextColor(pal); + if(ma) + { + if(strchr("PXsS",mk)) +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx-ve, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy-vf, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx+ve, vy+vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy-vf, zVal),c,q,-1,11); + gr->line_plot(n1,n2); gr->line_plot(n1,n3); + gr->line_plot(n4,n2); gr->line_plot(n4,n3); + } + if(strchr("dD",mk)) +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx, vy-vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy, zVal),c,q,-1,11); + gr->line_plot(n1,n2); gr->line_plot(n2,n3); + gr->line_plot(n3,n4); gr->line_plot(n4,n1); + } + if(strchr("oOC",mk)) +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1,n2,k; + for(k=0,n2=-1;k<=40;k++) + { + n1 = n2; + n2 = gr->AddPnt(mglPoint(vx+ve*mgl_cos[(18*k)%360], + vy+vf*mgl_cos[(270+18*k)%360], zVal),c,q,-1,11); + if(k>0) gr->line_plot(n1,n2); + } + } + switch(mk) + { + case 'P': case '+': +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx, vy-vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy, zVal),c,q,-1,11); + gr->line_plot(n1,n3); gr->line_plot(n2,n4); + } break; + case 'X': case 'x': +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx-ve, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy-vf, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx+ve, vy+vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy-vf, zVal),c,q,-1,11); + gr->line_plot(n1,n4); gr->line_plot(n2,n3); + } break; + case 'S': +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx-ve, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy-vf, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx+ve, vy+vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy-vf, zVal),c,q,-1,11); + gr->quad_plot(n1,n2,n3,n4); + } break; + case 'D': +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1 = gr->AddPnt(mglPoint(vx, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx-ve, vy, zVal),c,q,-1,11); + long n3 = gr->AddPnt(mglPoint(vx, vy-vf, zVal),c,q,-1,11); + long n4 = gr->AddPnt(mglPoint(vx+ve, vy, zVal),c,q,-1,11); + gr->quad_plot(n1,n4,n2,n3); + } break; + case 'O': +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + long n1, n2, n3 = gr->AddPnt(mglPoint(vx,vy,zVal),c),k; + for(k=0,n2=-1;k<=40;k++) + { + n1 = n2; + n2 = gr->AddPnt(mglPoint(vx+ve*mgl_cos[(18*k)%360], + vy+vf*mgl_cos[(270+18*k)%360], zVal),c,q,-1,11); + if(k>0) gr->trig_plot(n1,n2,n3); + } + } break; + case 'C': + for(long i=0;imark_plot(gr->AddPnt(mglPoint(x->v(i,mx),y->v(i,my),zVal),-1,q,-1,3), '.'); + if(sh) gr->NextColor(pal); + } + } + } + else +#pragma omp parallel for + for(long i=0;iv(i,mx), ve=ex->v(i,m1), vy=y->v(i,my), vf=ey->v(i,m2); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + if(mk) gr->mark_plot(gr->AddPnt(mglPoint(vx,vy,zVal),c), mk); + + long n1 = gr->AddPnt(mglPoint(vx, vy+vf, zVal),c,q,-1,11); + long n2 = gr->AddPnt(mglPoint(vx, vy-vf, zVal),c,q,-1,11); + gr->line_plot(n1,n2); gr->arrow_plot(n1,n2,'I'); gr->arrow_plot(n2,n1,'I'); + + n1 = gr->AddPnt(mglPoint(vx+ve, vy, zVal),-1,q,c,11); + n2 = gr->AddPnt(mglPoint(vx-ve, vy, zVal),-1,q,c,11); + gr->line_plot(n1,n2); gr->arrow_plot(n1,n2,'I'); gr->arrow_plot(n2,n1,'I'); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_xy(HMGL gr, HCDT x, HCDT y, HCDT ey, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData ex(y->GetNx()); + ex.Fill(NAN,NAN); + mgl_error_exy(gr,x,y,&ex,ey,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error(HMGL gr, HCDT y, HCDT ey, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(y->GetNx()); + x.Fill(gr->Min.x,gr->Max.x); + mgl_error_xy(gr,&x,y,ey,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_(uintptr_t *gr, uintptr_t *y, uintptr_t *ey, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_error(_GR_,_DA_(y),_DA_(ey),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ey, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_error_xy(_GR_,_DA_(x),_DA_(y),_DA_(ey),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_exy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ex, uintptr_t *ey, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_error_exy(_GR_,_DA_(x),_DA_(y),_DA_(ex),_DA_(ey),s,o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Chart series +// +//----------------------------------------------------------------------------- +void face_plot(mglBase *gr, mglPoint o, mglPoint d1, mglPoint d2, mreal c, bool wire) +{ + const int num=10; + mglPoint nn=d1^d2; + d1 = d1/num; d2 = d2/num; + long n=num+1, *id=new long[n*n]; + gr->Reserve(n*n); +#pragma omp parallel for collapse(2) + for(long j=0;jAddPnt(o+d1*i+d2*j,c,nn); +#pragma omp parallel for collapse(2) + for(long j=0;jquad_plot(ii[0],ii[1],ii[n],ii[n+1]); + } + if(wire) + { + gr->Reserve(4*n); gr->SetPenPal("k-"); + long *jj=id+n+1; + jj[0] = jj[1] = gr->CopyNtoC(id[0],gr->CDef); + jj[2] = jj[3] = gr->CopyNtoC(id[n*n-1],gr->CDef); + for(long i=1;iCopyNtoC(id[i],gr->CDef); + jj[1] = gr->CopyNtoC(id[n*i],gr->CDef); + jj[2] = gr->CopyNtoC(id[n*n-1-i],gr->CDef); + jj[3] = gr->CopyNtoC(id[n*n-1-n*i],gr->CDef); + gr->line_plot(jj[4],jj[0]); + gr->line_plot(jj[5],jj[1]); + gr->line_plot(jj[6],jj[2]); + gr->line_plot(jj[7],jj[3]); + } + } + delete []id; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_chart(HMGL gr, HCDT a, const char *cols, const char *opt) +{ + if(a->Minimal()<0) { gr->SetWarn(mglWarnNeg,"Chart"); return; } + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Chart",cgid++); + bool wire = mglchr(cols,'#'); // draw edges + register long n=a->GetNx(),i,j=0,len=cols?long(strlen(cols)):0; + if(cols) for(i=0;iAddTexture(cols[i]); nc++; } + // NOTE: nc>0 since j>0 or MGL_DEF_PAL is not empty + + mreal dy = (gr->Max.y-gr->Min.y)/a->GetNy(), dx, ss, cs, x1, y1, dz=gr->Max.z-gr->Min.z, vv; + mglPoint d1,d2,o; + + for(j=0;jGetNy();j++) + { + y1 = gr->Min.y + dy*j; + for(i=0,ss=0;iv(i,j); + if(ss==0) continue; + for(cs=0,i=0;iStop) { delete []c; return; } + vv = a->v(i,j); dx = vv/ss; cc = c[i%nc]; + if(dx==0) continue; + x1 = gr->Min.x + (gr->Max.x-gr->Min.x)*cs/ss; dx *= (gr->Max.x-gr->Min.x); + if(cc>=0) + { + face_plot(gr,mglPoint(x1,y1,gr->Min.z),mglPoint(dx,0,0),mglPoint(0,0,dz),cc,wire); + face_plot(gr,mglPoint(x1,y1,gr->Min.z),mglPoint(dx,0,0),mglPoint(0,dy,0),cc,wire); + face_plot(gr,mglPoint(x1,y1,gr->Min.z),mglPoint(0,dy,0),mglPoint(0,0,dz),cc,wire); + + face_plot(gr,mglPoint(x1+dx,y1+dy,gr->Max.z),mglPoint(-dx,0,0),mglPoint(0,0,-dz),cc,wire); + face_plot(gr,mglPoint(x1+dx,y1+dy,gr->Max.z),mglPoint(-dx,0,0),mglPoint(0,-dy,0),cc,wire); + face_plot(gr,mglPoint(x1+dx,y1+dy,gr->Max.z),mglPoint(0,-dy,0),mglPoint(0,0,-dz),cc,wire); + } + cs += vv; + } + } + gr->EndGroup(); delete []c; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_chart_(uintptr_t *gr, uintptr_t *a, const char *col, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,col,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_chart(_GR_, _DA_(a), s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Mark series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *pen, const char *opt) +{ + long j,m,mx,my,mz,mr,n=y->GetNx(),pal; + if(mgl_check_dim0(gr,x,y,z,r,"Mark")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Mark",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + m = z->GetNy() > m ? z->GetNy() : m; + char mk=gr->SetPenPal(pen,&pal); gr->Reserve(n*m); + if(mk==0) return; + bool sh = mglchr(pen,'!'); + + for(j=0;jNextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; mr = jGetNy() ? j:0; + for(int i=0;iStop) return; + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + gr->mark_plot(gr->AddPnt(mglPoint(x->v(i,mx),y->v(i,my),z->v(i,mz)),c), mk, fabs(r->v(i,mr))); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_xy(HMGL gr, HCDT x, HCDT y, HCDT r, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_mark_xyz(gr,x,y,&z,r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_y(HMGL gr, HCDT y, HCDT r, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + gr->SaveState(opt); + mglData x(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_mark_xyz(gr,&x,y,&z,r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_mark_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(r),s,o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_mark_xy(_GR_, _DA_(x), _DA_(y), _DA_(r),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_y_(uintptr_t *gr, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_mark_y(_GR_,_DA_(y),_DA_(r),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Tube series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyzr(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *pen, const char *opt) +{ + long j,m,mx,my,mz,mr,n=y->GetNx(),pal; + if(mgl_check_dim1(gr,x,y,z,r,"Tube")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Tube",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + m = z->GetNy() > m ? z->GetNy() : m; + m = r->GetNy() > m ? r->GetNy() : m; + bool sh = mglchr(pen,'!'); + bool wire = mglchr(pen,'#'); + + int num=!(gr->GetQuality()&3)?13:25; + gr->SetPenPal(pen,&pal); + gr->Reserve(n*m*num); + mglPoint p,l,t,u,q,d; + long *nn=new long[2*num]; + memset(nn,-1,2*num*sizeof(long)); + for(j=0;jNextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; mr = jGetNy() ? j:0; + for(long i=0;idvx(i,mx),y->dvx(i,my),z->dvx(i,mz)); + t = !l; t.Normalize(); u = t^l; u.Normalize(); + q = mglPoint(x->v(i,mx),y->v(i,my),z->v(i,mz)); + mreal rr=r->v(i,mr), dr=r->dvx(i,mr); + mreal c = sh ? gr->NextColor(pal,i):gr->CDef; + for(long k=0;kStop) { delete []nn; return; } + register int kk = k*360/(num-1); + register float co = mgl_cos[(kk)%360], si = mgl_cos[(270+kk)%360]; + p = q + t*(rr*co) + u*(rr*si); + d = (t*si - u*co)^(l + t*(dr*co) + u*(dr*si)); + nn[k+num]=nn[k]; nn[k] = gr->AddPnt(p,c,wire?mglPoint(NAN,NAN):d,-1,3); + if(i*k>0 && !wire) gr->quad_plot(nn[k],nn[k-1],nn[k+num],nn[k+num-1]); + if(i*k>0 && wire && k%4==0) gr->line_plot(nn[k],nn[k+num]); + if(k>0 && wire) gr->line_plot(nn[k],nn[k-1]); + } + } + } + delete []nn; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyr(HMGL gr, HCDT x, HCDT y, HCDT r, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tube_xyzr(gr,x,y,&z,r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_r(HMGL gr, HCDT y, HCDT r, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Tube"); return; } + gr->SaveState(opt); + mglData x(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tube_xyzr(gr,&x,y,&z,r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube(HMGL gr, HCDT y, double rr, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Tube"); return; } + gr->SaveState(opt); + mglData x(n), r(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + r.Fill(rr,rr); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tube_xyzr(gr,&x,y,&z,&r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xy(HMGL gr, HCDT x, HCDT y, double rr, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Tube"); return; } + gr->SaveState(opt); + mglData r(n), z(n); + r.Fill(rr,rr); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tube_xyzr(gr,x,y,&z,&r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, double rr, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData r(y->GetNx()); + r.Fill(rr,rr); + mgl_tube_xyzr(gr,x,y,z,&r,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyzr_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube_xyzr(_GR_,_DA_(x),_DA_(y),_DA_(z), _DA_(r),s,o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyr_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube_xyr(_GR_,_DA_(x),_DA_(y),_DA_(r),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_r_(uintptr_t *gr, uintptr_t *y, uintptr_t *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube_r(_GR_,_DA_(y),_DA_(r),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, mreal *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube_xyz(_GR_,_DA_(x),_DA_(y),_DA_(z),*r,s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, mreal *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube_xy(_GR_,_DA_(x),_DA_(y),*r,s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tube_(uintptr_t *gr, uintptr_t *y, mreal *r, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tube(_GR_,_DA_(y),*r,s,o); + delete []s; delete []o; } +//----------------------------------------------------------------------------- +// +// Tape series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long j,m,mx,my,mz,n=y->GetNx(),pal; + if(mgl_check_dim1(gr,x,y,z,0,"Tape")) return; + + static int cgid=1; gr->StartGroup("Tape",cgid++); + mreal ll, rr = gr->SaveState(opt); + if(rr==0 || mgl_isnan(rr)) rr = mgl_norm(gr->Max-gr->Min)*gr->BarWidth/25; + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + gr->SetPenPal(pen,&pal); gr->Reserve(4*n*m); + mglPoint p1,p2,q1,q2,l,nn,qn=mglPoint(NAN,NAN); + long n1=-1,n2=-1,n3=-1,n4=-1, m1=-1,m2=-1,m3=-1,m4=-1; + bool sh = mglchr(pen,'!'), xo = mglchr(pen,'x'), zo = mglchr(pen,'z'), wire = mglchr(pen,'#'); + if(!xo && !zo) xo = zo = true; + mreal c1,c2; + + for(j=0;jNextColor(pal); + if(gr->GetNumPal(pal)==2*m && !sh) c2 = gr->NextColor(pal); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; + // initial values for normales + p2 = mglPoint(x->v(0,mx), y->v(0,my), z->v(0,mz)); + l = mglPoint(x->v(1,mx), y->v(1,my), z->v(1,mz)) - p2; l /= mgl_norm(l); + q1 = mglPoint(-l.y,l.x,0); ll = mgl_norm(q1); + if(ll) q1 /= ll; else q1 = mglPoint(0,1,0); + q2 = (q1^l); + if(p2>gr->Min && p2Max) + { + if(xo) { n1 = gr->AddPnt(p2,c1,q2,-1,3); n2 = gr->AddPnt(p2+rr*q1,c1,q2,-1,3); } + if(zo) { n3 = gr->AddPnt(p2,c2,q1,-1,3); n4 = gr->AddPnt(p2+rr*q2,c2,q1,-1,3); } + } + else { n1=n2=n3=n4=-1; } + register long i; + for(i=1;iStop) return; + p1 = p2; p2 = mglPoint(x->v(i,mx), y->v(i,my), z->v(i,mz)); + l = p2-p1; l /= mgl_norm(l); + q1 -= l*(l*q1); q1/= mgl_norm(q1); q2 = (q1^l); + m1 = n1; m2 = n2; m3 = n3; m4 = n4; + if(sh) c2=c1=gr->NextColor(pal,i); + if(p2>gr->Min && p2Max) + { + if(xo) + { + n1 = gr->AddPnt(p2,c1,wire?qn:q2,-1,3); + n2 = gr->AddPnt(p2+rr*q1,c1,wire?qn:q2,-1,3); + if(wire) gr->line_plot(m2,n2); + else gr->quad_plot(n1,n2,m1,m2); + } + if(zo) + { + n3 = gr->AddPnt(p2,c2,wire?qn:q1,-1,3); + n4 = gr->AddPnt(p2+rr*q2,c2,wire?qn:q1,-1,3); + if(wire) gr->line_plot(m4,n4); + else gr->quad_plot(n3,n4,m3,m4); + } + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape_xy(HMGL gr, HCDT x, HCDT y, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tape_xyz(gr,x,y,&z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape(HMGL gr, HCDT y, const char *pen, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"Plot"); return; } + gr->SaveState(opt); + mglData x(n), z(n); + x.Fill(gr->Min.x,gr->Max.x); + mreal zm = gr->AdjustZMin(); z.Fill(zm,zm); + mgl_tape_xyz(gr,&x,y,&z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tape_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tape_xy(_GR_, _DA_(x),_DA_(y),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tape_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tape(_GR_, _DA_(y),s,o); delete []s; delete []o; } +//----------------------------------------------------------------------------- diff --git a/src/prc.cpp b/src/prc.cpp new file mode 100644 index 0000000..74c7fde --- /dev/null +++ b/src/prc.cpp @@ -0,0 +1,993 @@ +/*************************************************************************** + * prc.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include "mgl2/canvas.h" +#include "mgl2/canvas_cf.h" + +#include "prc/oPRCFile.h" +#include +#include +#include +#include +#include +#include + +#if MGL_HAVE_PDF +#include +#include +#include +#include +#endif // MGL_HAVE_PDF + + +#undef _GR_ +#define _GR_ ((mglCanvas *)(*gr)) +#define _Gr_ ((mglCanvas *)(gr)) + +//----------------------------------------------------------------------------- +void mglTexture::GetRGBAPRC(unsigned char *f) const +{ + register size_t i,j,i0; + mglColor c1,c2,c; + for(i=0;i<256;i++) + { + c1 = col[2*i]; c2 = col[2*i+1]; + for(j=0;j<256;j++) + { + i0 = 4*(j+256*(255-i)); + c = c1 + (c2-c1)*(j/255.); + f[i0] = int(255*c.r); + f[i0+1] = int(255*c.g); + f[i0+2] = int(255*c.b); + f[i0+3] = int(255*c.a); + } + } +} +//----------------------------------------------------------------------------- +int MGL_NO_EXPORT mgl_tga_save(const char *fname, int w, int h, unsigned char **p); +int MGL_NO_EXPORT mgl_pnga_save(const char *fname, int w, int h, unsigned char **p); +void MGL_NO_EXPORT mgl_printf(void *fp, bool gz, const char *str, ...); +//----------------------------------------------------------------------------- +struct prctriangle { + uint32_t pi[3]; + uint32_t ti[3]; +}; +//----------------------------------------------------------------------------- +struct prctriangles { + prctriangles(const HMGL g) : samecolour(true), samealpha(true), + gr(g), ntxt(g->GetTxtNum()), vertexcolor(g->get(MGL_PREFERVC)) {} + std::map points; + std::map texturecoords; + std::map colours; + std::vector triangles; + RGBAColour commoncolour; + bool samecolour; + float commonalpha; + bool samealpha; + const HMGL gr; + const size_t ntxt; + bool vertexcolor; + + + uint32_t addPoint(const mglPnt& p) + { + const PRCVector3d point(p.x,p.y,p.z); + + std::map::iterator pPoint = points.find(point); + if(pPoint!=points.end()) + return pPoint->second; + else + { + const uint32_t point_index = (uint32_t)points.size(); + points.insert(std::make_pair(point,point_index)); + return point_index; + } + } + + uint32_t addPoint(float x, float y, float z) + { + const PRCVector3d point(x,y,z); + + std::map::iterator pPoint = points.find(point); + if(pPoint!=points.end()) + return pPoint->second; + else + { + const uint32_t point_index = (uint32_t)points.size(); + points.insert(std::make_pair(point,point_index)); + return point_index; + } + } + + void writePoints(double (*P)[3]) + { + for(std::map::const_iterator pPoint = points.begin(); pPoint != points.end(); pPoint++) + { + P[pPoint->second][0] = pPoint->first.x; + P[pPoint->second][1] = pPoint->first.y; + P[pPoint->second][2] = pPoint->first.z; + } + } + + void addTriangle(uint32_t ti, uint32_t pi1, uint32_t pi2, uint32_t pi3) + { + prctriangle triangle; + triangle.pi[0] = pi1; + triangle.pi[1] = pi2; + triangle.pi[2] = pi3; + triangle.ti[0] = ti; + triangle.ti[1] = ti; + triangle.ti[2] = ti; + triangles.push_back(triangle); + } + void addTriangle(uint32_t pi1, uint32_t ti1, uint32_t pi2, uint32_t ti2, uint32_t pi3, uint32_t ti3) + { + prctriangle triangle; + triangle.pi[0] = pi1; + triangle.pi[1] = pi2; + triangle.pi[2] = pi3; + triangle.ti[0] = ti1; + triangle.ti[1] = ti2; + triangle.ti[2] = ti3; + triangles.push_back(triangle); + } + uint32_t addColourInfo(const mglPnt& p) + { + const RGBAColour colour(p.r,p.g,p.b,p.a); + + if (colours.empty() && texturecoords.empty()) { + commoncolour = colour; + commonalpha = p.a; + } + if (samecolour) { + if (commoncolour != colour) + samecolour = false; + } + if (samealpha) { + if (commonalpha != p.a) + samealpha = false; + } + + if (vertexcolor) { + std::map::iterator pColour = colours.find(colour); + if(pColour!=colours.end()) + return pColour->second; + else + { + const uint32_t colour_index = (uint32_t)colours.size(); + colours.insert(std::make_pair(colour,colour_index)); + return colour_index; + } + } else { + const mreal gap = 1./512; + const double u = p.ta*(1-2*gap)+gap; + const double v = ((p.c-floor(p.c))*(1-2*gap) + gap + floor(p.c))/ntxt; + + const PRCVector2d point(u, v); + std::map::iterator pPoint = texturecoords.find(point); + if(pPoint!=texturecoords.end()) + return pPoint->second; + else + { + const uint32_t point_index = (uint32_t)texturecoords.size(); + texturecoords.insert(std::make_pair(point,point_index)); + return point_index; + } + } + } + + void writeTextureCoords(double (*T)[2]) + { + for(std::map::const_iterator pPoint = texturecoords.begin(); pPoint != texturecoords.end(); pPoint++) + { + T[pPoint->second][0] = pPoint->first.x; + T[pPoint->second][1] = pPoint->first.y; + } + } + + void writeColours(RGBAColour *C) + { + for(std::map::const_iterator pColour = colours.begin(); pColour != colours.end(); pColour++) + { + C[pColour->second] = pColour->first; + } + } +}; + +//----------------------------------------------------------------------------- +/* structure to store PNG image bytes */ +struct png_buf +{ + uint8_t *data; + size_t size; +}; +//----------------------------------------------------------------------------- +void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + struct png_buf* p=(struct png_buf*)png_get_io_ptr(png_ptr); + size_t nsize = p->size + length; + + /* allocate or grow buffer */ + if(p->data) + p->data = (uint8_t*)realloc(p->data, nsize); + else + p->data = (uint8_t*)malloc(nsize); + + if(!p->data) + png_error(png_ptr, "Write Error - no mem"); + + /* copy new bytes to end of buffer */ + memcpy(p->data + p->size, data, length); + p->size += length; +} +//----------------------------------------------------------------------------- +void my_png_flush(png_structp /*png_ptr*/) +{ +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_prc(HMGL gr, const char *fname,const char* /*descr*/, int make_pdf) +{ + if(gr->GetPrmNum()==0) return; // nothing to do + { + long mmin=0,mmax=0,m; + for(size_t i=0;iGrp.size();i++) // prepare array of indirect indexing + { m = gr->Grp[i].Id; if(mmmax) mmax=m; } + long *ng = new long[mmax-mmin+1]; + for(size_t i=0;iGrp.size();i++) ng[gr->Grp[i].Id-mmin] = i; + for(size_t i=0;iGetPrmNum());i++) // collect data for groups + // it is rather expensive (extra 4b per primitive) but need for export to 3D + { + m = gr->GetPrm(i).id-mmin; + if(m>=0 && mGrp[ng[m]].p.push_back(i); + } + delete []ng; + } + const size_t len=strlen(fname); + char * const tname = new char[len+9]; strcpy(tname,fname); + if (strncmp(tname+len-4, ".prc", 4)!=0) + { + tname[len]='.'; tname[len+1]='p'; tname[len+2]='r'; tname[len+3]='c'; tname[len+4]='\0'; + } + oPRCFile file(tname); + PRCoptions grpopt; + grpopt.tess = true; + grpopt.closed = gr->get(MGL_ONESIDED); // set to true to make only front side visible + // grpopt.no_break = true; + // grpopt.do_break = false; + grpopt.crease_angle = 80; + + uint32_t materialMathGLid = m1; + if (gr->get(MGL_PREFERVC)) { + const PRCmaterial materialMathGL( + RGBAColour(0.1,0.1,0.1,1), // ambient + RGBAColour(1.0,1.0,1.0,1), // diffuse + RGBAColour(0.1,0.1,0.1,1), // emissive + RGBAColour(0.0,0.0,0.0,1), // spectral + 1.0,0.1 // alpha, shininess + ); + materialMathGLid = file.addMaterial(materialMathGL); + } + else + { + png_buf buffer; + buffer.data = (uint8_t*)malloc(1024);; + buffer.size = 0; + const size_t ntxt = gr->GetTxtNum(); + + // prepare texture file (PNG) + const png_uint_32 width=256, height=256*png_uint_32(ntxt); + png_bytep buf = new png_byte[4*width*height]; + png_bytepp pbuf= new png_bytep[height]; + for(size_t i=0;iGetTxt(i).GetRGBAPRC(buf+(ntxt-1-i)*256*width*4); + + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_infop info_ptr = png_create_info_struct(png_ptr); + + png_set_write_fn(png_ptr, &buffer, my_png_write_data, my_png_flush); + png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + png_set_IHDR(png_ptr, info_ptr, width, height, 8, + PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + png_set_rows(png_ptr, info_ptr, pbuf); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, 0); + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + delete []pbuf; delete []buf; + + PRCtexture* t = new PRCtexture(); + t->mapping = PRC_TEXTURE_MAPPING_DIFFUSE; + t->components = PRC_TEXTURE_MAPPING_COMPONENTS_RGBA; + // Modulate for OBJ compatibilty, Replace is a better setting + t->function = KEPRCTextureFunction_Replace; + // Repeat for OBJ compatibilty, ClampToEdge is a better setting + t->wrapping_mode_S = KEPRCTextureWrappingMode_ClampToEdge; + t->wrapping_mode_T = KEPRCTextureWrappingMode_ClampToEdge; + t->data = buffer.data; + t->size = buffer.size; + t->format = KEPRCPicture_PNG; + + PRCmaterial m( + RGBAColour(0.0,0.0,0.0,1), // ambient + RGBAColour(1.0,1.0,1.0,1), // diffuse + RGBAColour(0.0,0.0,0.0,1), // emissive + RGBAColour(0.0,0.0,0.0,1), // spectral + 1.0,0.1); // alpha, shininess + + materialMathGLid = file.addTexturedMaterial(m,1,&t); + delete t; + + // char * const pngname = new char[len+100]; + // strcpy(pngname, "test_texture_"); + // strcat(pngname,tname); + // const size_t tlen=strlen(pngname)-4; + // pngname[tlen+1]='p'; pngname[tlen+2]='n'; pngname[tlen+3]='g'; + // FILE *fp = fopen(pngname, "wb"); + // fwrite(buffer.data, 1, buffer.size, fp); + // fclose(fp); + // delete[] pngname; + + free(buffer.data); buffer.data = NULL; + } + + // primitive definition in groups + + mglPnt p0; + const double width = dynamic_cast(gr)->GetWidth(); + const double height = dynamic_cast(gr)->GetHeight(); + const double depth = sqrt(width*height); + + p0.x = width/2.; + p0.y = height/2.; + p0.z = (1.f-sqrt(width*height)/(2*depth))*depth; + + for(size_t i=0;iGrp.size();i++) + { + mglGroup& grp = gr->Grp[i]; + std::vector& prm = grp.p; + prctriangles group(gr); + file.begingroup(grp.Lbl.c_str(),&grpopt); + for(size_t j=0;jGetPrm(prm[j]); + const double w = (q.w>1)?(q.w*sqrt(gr->FontFactor()/400.)):1; + + const mglPnt p = gr->GetPnt(q.n1) - p0; + const mreal size = q.s; + { + switch(q.type) + { + case 0: + if (gr->GetPnt(q.n1).a > mgl_min_a) { + const char type = q.n4; + float ss=size; + const RGBAColour c(p.r, p.g, p.b, p.a); + + if(!strchr("xsSoO",type)) ss *= 1.1; + if(type=='.' || ss==0) + { + const double P[3] = {p.x, p.y, p.z}; + file.addPoint(P, c, w); + } + else + switch(type) + { + case 'P': + { + const double P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + file.addLine(5, P, c, w); + } + case '+': + { + const double P1[2][3] = + { + { p.x-ss,p.y,p.z }, + { p.x+ss,p.y,p.z } + }; + file.addLine(2, P1, c, w); + const double P2[2][3] = + { + { p.x,p.y-ss,p.z }, + { p.x,p.y+ss,p.z } + }; + file.addLine(2, P2, c, w); + } + break; + case 'X': + { + const double P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + file.addLine(5, P, c, w); + const double P1[2][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z } + }; + file.addLine(2, P1, c, w); + const double P2[2][3] = + { + { p.x+ss,p.y-ss,p.z }, + { p.x-ss,p.y+ss,p.z } + }; + file.addLine(2, P2, c, w); + } + break; + case 'x': + { + const double P1[2][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z } + }; + file.addLine(2, P1, c, w); + const double P2[2][3] = + { + { p.x+ss,p.y-ss,p.z }, + { p.x-ss,p.y+ss,p.z } + }; + file.addLine(2, P2, c, w); + } + break; + case 'S': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x-ss,p.y-ss,p.z); + const uint32_t pi2 = group.addPoint(p.x+ss,p.y-ss,p.z); + const uint32_t pi3 = group.addPoint(p.x-ss,p.y+ss,p.z); + const uint32_t pi4 = group.addPoint(p.x+ss,p.y+ss,p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + group.addTriangle(ti, pi4, pi3, pi2); + } + break; + case 's': + { + const double P[5][3] = + { + { p.x-ss,p.y-ss,p.z }, + { p.x+ss,p.y-ss,p.z }, + { p.x+ss,p.y+ss,p.z }, + { p.x-ss,p.y+ss,p.z }, + { p.x-ss,p.y-ss,p.z } + }; + file.addLine(5, P, c, w); + } + break; + case 'D': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x,p.y-ss,p.z); + const uint32_t pi2 = group.addPoint(p.x+ss,p.y,p.z); + const uint32_t pi3 = group.addPoint(p.x-ss,p.y,p.z); + const uint32_t pi4 = group.addPoint(p.x,p.y+ss,p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + group.addTriangle(ti, pi4, pi3, pi2); + } + break; + case 'd': + { + const double P[5][3] = + { + { p.x,p.y-ss,p.z }, + { p.x+ss,p.y,p.z }, + { p.x,p.y+ss,p.z }, + { p.x-ss,p.y,p.z }, + { p.x,p.y-ss,p.z } + }; + file.addLine(5, P, c, w); + } + break; + case 'Y': + { + const double P1[3][3] = + { + { p.x, p.y-ss, p.z }, + { p.x, p.y, p.z }, + { p.x+0.8*ss,p.y+0.6*ss,p.z } + }; + file.addLine(3, P1, c, w); + const double P2[2][3] = + { + { p.x, p.y, p.z }, + { p.x-0.8*ss,p.y+0.6*ss,p.z } + }; + file.addLine(2, P2, c, w); + } + break; + case '*': + { + const double P1[2][3] = + { + { p.x-ss,p.y,p.z }, + { p.x+ss,p.y,p.z } + }; + file.addLine(2, P1, c, w); + const double P2[2][3] = + { + { p.x-0.6*ss,p.y-0.8*ss,p.z }, + { p.x+0.6*ss,p.y+0.8*ss,p.z } + }; + file.addLine(2, P2, c, w); + const double P3[2][3] = + { + { p.x-0.6*ss,p.y+0.8*ss,p.z }, + { p.x+0.6*ss,p.y-0.8*ss,p.z } + }; + file.addLine(2, P3, c, w); + + } + break; + case 'T': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x-ss,p.y-ss/2,p.z); + const uint32_t pi2 = group.addPoint(p.x+ss,p.y-ss/2,p.z); + const uint32_t pi3 = group.addPoint(p.x,p.y+ss,p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + } + break; + case '^': + { + const double P[4][3] = + { + { p.x-ss,p.y-ss/2,p.z }, + { p.x+ss,p.y-ss/2,p.z }, + { p.x, p.y+ss, p.z }, + { p.x-ss,p.y-ss/2,p.z } + }; + file.addLine(4, P, c, w); + } + break; + case 'V': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x-ss,p.y+ss/2,p.z); + const uint32_t pi2 = group.addPoint(p.x,p.y-ss,p.z); + const uint32_t pi3 = group.addPoint(p.x+ss,p.y+ss/2,p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + } + break; + case 'v': + { + const double P[4][3] = + { + { p.x-ss,p.y+ss/2,p.z }, + { p.x+ss,p.y+ss/2,p.z }, + { p.x, p.y-ss, p.z }, + { p.x-ss,p.y+ss/2,p.z } + }; + file.addLine(4, P, c, w); + } + break; + case 'L': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x+ss/2,p.y+ss,p.z); + const uint32_t pi2 = group.addPoint(p.x-ss, p.y, p.z); + const uint32_t pi3 = group.addPoint(p.x+ss/2,p.y-ss,p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + } + break; + case '<': + { + const double P[4][3] = + { + { p.x+ss/2,p.y+ss,p.z }, + { p.x+ss/2,p.y-ss,p.z }, + { p.x-ss, p.y, p.z }, + { p.x+ss/2,p.y+ss,p.z } + }; + file.addLine(4, P, c, w); + } + break; + case 'R': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t pi1 = group.addPoint(p.x-ss/2,p.y+ss,p.z); + const uint32_t pi2 = group.addPoint(p.x-ss/2,p.y-ss,p.z); + const uint32_t pi3 = group.addPoint(p.x+ss, p.y, p.z); + + group.addTriangle(ti, pi1, pi2, pi3); + } + break; + case '>': + { + const double P[4][3] = + { + { p.x-ss/2,p.y+ss,p.z }, + { p.x-ss/2,p.y-ss,p.z }, + { p.x+ss, p.y, p.z }, + { p.x-ss/2,p.y+ss,p.z } + }; + file.addLine(4, P, c, w); + } + break; + case 'O': + { + const uint32_t ti = group.addColourInfo(p); + + const uint32_t cpi=group.addPoint(p); + uint32_t pnti[21]; + for(size_t k=0;k<=20;k++) + pnti[k]=group.addPoint(p.x+ss*cos(k*M_PI/10),p.y+ss*sin(k*M_PI/10),p.z); + for(size_t k=0;k<20;k++) { + group.addTriangle(ti, pnti[k], pnti[k+1], cpi); + } + } + break; + case 'C': + { + const double P[3] = {p.x, p.y, p.z}; + file.addPoint(P, c, w); + } + case 'o': + { + double P[21][3]; + for(size_t k=0;k<=20;k++) { + P[k][0] = p.x+ss*cos(k*M_PI/10); + P[k][1] = p.y+ss*sin(k*M_PI/10); + P[k][2] = p.z; + } + file.addLine(21, P, c, w); + } + break; + } + } + break; + + case 1: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a) { + const mglPnt p1 = gr->GetPnt(q.n1) - p0, p2 = gr->GetPnt(q.n2) - p0; + + const uint32_t n = 2; + double P[2][3]; + P[0][0] = p1.x; + P[0][1] = p1.y; + P[0][2] = p1.z; + P[1][0] = p2.x; + P[1][1] = p2.y; + P[1][2] = p2.z; + const RGBAColour colour((p1.r+p2.r)/2, (p1.g+p2.g)/2, (p1.b+p2.b)/2, (p1.a+p2.a)/2); + file.addLine(n, P, colour, w); + } + break; + + case 2: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a || gr->GetPnt(q.n3).a > mgl_min_a) { + const mglPnt p1 = gr->GetPnt(q.n1) - p0, p2 = gr->GetPnt(q.n2) - p0, p3 = gr->GetPnt(q.n3) - p0; + + prctriangle triangle; + triangle.pi[0] = group.addPoint(p1); + triangle.pi[1] = group.addPoint(p2); + triangle.pi[2] = group.addPoint(p3); + triangle.ti[0] = group.addColourInfo(p1); + triangle.ti[1] = group.addColourInfo(p2); + triangle.ti[2] = group.addColourInfo(p3); + group.triangles.push_back(triangle); + } + break; + case 3: + if (gr->GetPnt(q.n1).a > mgl_min_a || gr->GetPnt(q.n2).a > mgl_min_a || gr->GetPnt(q.n3).a > mgl_min_a || gr->GetPnt(q.n4).a > mgl_min_a) { + const mglPnt p1 = gr->GetPnt(q.n1) - p0; + const uint32_t pi1 = group.addPoint(p1); + const uint32_t ti1 = group.addColourInfo(p1); + + const mglPnt p2 = gr->GetPnt(q.n2) - p0; + const uint32_t pi2 = group.addPoint(p2); + const uint32_t ti2 = group.addColourInfo(p2); + + const mglPnt p3 = gr->GetPnt(q.n3) - p0; + const uint32_t pi3 = group.addPoint(p3); + const uint32_t ti3 = group.addColourInfo(p3); + + const mglPnt p4 = gr->GetPnt(q.n4) - p0; + const uint32_t pi4 = group.addPoint(p4); + const uint32_t ti4 = group.addColourInfo(p4); + + prctriangle triangle1, triangle2; + triangle1.pi[0] = pi1; + triangle1.pi[1] = pi2; + triangle1.pi[2] = pi3; + triangle1.ti[0] = ti1; + triangle1.ti[1] = ti2; + triangle1.ti[2] = ti3; + group.triangles.push_back(triangle1); + triangle2.pi[0] = pi4; + triangle2.pi[1] = pi3; + triangle2.pi[2] = pi2; + triangle2.ti[0] = ti4; + triangle2.ti[1] = ti3; + triangle2.ti[2] = ti2; + group.triangles.push_back(triangle2); + } + break; + case 4: + if (gr->GetPnt(q.n1).a > mgl_min_a) { + const mglPnt p = gr->GetPnt(q.n1) - p0; + + const mreal f = q.p/2, dx=p.u/2, dy=p.v/2; + const mreal c=q.s*cos(q.w*M_PI/180), s=-q.s*sin(q.w*M_PI/180); + const double b[4] = {c,-s, s,c}; + long ik,il=0; + + const mglGlyph &g = gr->GetGlf(q.n4); + const mreal dd = 0.004; + if(q.n3&8) + { + if(!(q.n3&4)) // glyph_line(p,f,true, d); + { + const uint32_t ti = group.addColourInfo(p); + const uint32_t p_4 = group.addPoint(p.x+b[0]*dx+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + const uint32_t p_3 = group.addPoint(p.x+b[0]*dx+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + const uint32_t p_2 = group.addPoint(p.x+b[0]*(dx+f)+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z); + const uint32_t p_1 = group.addPoint(p.x+b[0]*(dx+f)+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z); + + group.addTriangle(ti, p_1, p_3, p_2); + group.addTriangle(ti, p_4, p_2, p_3); + } + else // glyph_line(p,f,false, d); + { + const RGBAColour c(p.r, p.g, p.b, p.a); + const double p_4[3] = {p.x+b[0]*dx+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z}; + const double p_3[3] = {p.x+b[0]*dx+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z}; + const double p_2[3] = {p.x+b[0]*(dx+f)+b[1]*(dy-dd),p.y+b[2]*dx+b[3]*(dy-dd),p.z}; + const double p_1[3] = {p.x+b[0]*(dx+f)+b[1]*(dy+dd),p.y+b[2]*dx+b[3]*(dy+dd),p.z}; + + file.addSegment(p_1, p_2, c, w); + file.addSegment(p_3, p_4, c, w); + file.addSegment(p_1, p_3, c, w); + file.addSegment(p_2, p_4, c, w); + } + } + else + { + if(!(q.n3&4)) // glyph_fill(p,f,g, d); + { + for(ik=0;ikget(MGL_PREFERVC)) { + const uint32_t nC = (uint32_t)group.colours.size(); + RGBAColour *C = new RGBAColour[nC]; + group.writeColours(C); + uint32_t (*CI)[3] = new uint32_t[nI][3]; + for(uint32_t k = 0; k(gr)->GetWidth(); +// const HPDF_REAL height = dynamic_cast(gr)->GetHeight(); +// const HPDF_REAL depth = sqrt(width*height); + + const HPDF_Rect rect = {0, 0, width, height}; + + HPDF_Doc pdf; + HPDF_Page page; + HPDF_Annotation annot; + HPDF_U3D u3d; + + HPDF_Dict view; + pdf = HPDF_New (NULL, NULL); + + pdf->pdf_version = HPDF_VER_17; + + page = HPDF_AddPage (pdf); + + HPDF_Page_SetWidth (page, width); + HPDF_Page_SetHeight (page, height); + + u3d = HPDF_LoadU3DFromFile (pdf, tname); + + // Default view + view = HPDF_Create3DView (u3d->mmgr, "DefaultView"); + + // Position camera + HPDF_3DView_SetCamera (view, 0, 0, 0, 0, 0, 1, depth, 0); + + // Set ortho projection + HPDF_3DView_SetOrthogonalProjection (view, 1); + + // Background color + HPDF_3DView_SetBackgroundColor (view, 0.9, 0.9, 0.9); + + // Lighting + HPDF_3DView_SetLighting (view, "CAD"); + + // Add views + HPDF_U3D_Add3DView (u3d, view); + HPDF_U3D_SetDefault3DView(u3d, "DefaultView"); + + // Create annotation + annot = HPDF_Page_Create3DAnnot (page, rect, u3d ); + + // Enable toolbar + HPDF_Dict action = (HPDF_Dict)HPDF_Dict_GetItem (annot, "3DA", HPDF_OCLASS_DICT); + HPDF_Dict_AddBoolean (action, "TB", HPDF_TRUE); + + /* save the document to a file */ + const size_t tlen = strlen(tname); + tname[tlen-2]='p'; tname[tlen-2]='d'; tname[tlen-1]='f'; + HPDF_SaveToFile (pdf, tname); + + /* clean up */ + HPDF_Free (pdf); +#else + const size_t tlen = strlen(tname); + tname[tlen-2]='p'; tname[tlen-2]='d'; tname[tlen-1]='f'; + tname[tlen+0]='.'; tname[tlen+1]='t'; tname[tlen+2]='x'; tname[tlen+3]='t'; tname[tlen+4]='\0'; + FILE *fp=fopen(tname,"wt"); + fputs("Can not produce PDF file, MathGL compiled without PDF output support\n", fp); + fclose(fp); + mglGlobalMess += "PDF support was disabled. Please, enable it and rebuild MathGL.\n"; +#endif // MGL_HAVE_PDF + } + delete []tname; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_write_prc_(uintptr_t *gr, const char *fname,const char *descr, int *make_pdf,int l,int n) +{ char *s=new char[l+1]; memcpy(s,fname,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,descr,n); f[n]=0; + mgl_write_prc(_GR_,s,f,*make_pdf); delete []s; delete []f; } +//----------------------------------------------------------------------------- diff --git a/src/prc/PRC.h b/src/prc/PRC.h new file mode 100644 index 0000000..78ee1bd --- /dev/null +++ b/src/prc/PRC.h @@ -0,0 +1,514 @@ +#ifndef __PRC_H +#define __PRC_H + +#ifdef _MSC_VER +#if _MSC_VER >= 1600 +#include +#else +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +#endif // _MSC_VER >= 1600 +#elif defined __BORLANDC__ +#include +#else +#include +#endif // _MSC_VER + +//const uint32_t PRCVersion=7094; // For Adobe Reader 8 or later +const uint32_t PRCVersion=8137; // For Adobe Reader 9 or later + +// from Adobe's documentation + +#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, + KEPRCModellerAttributeTypeInt = 1, + KEPRCModellerAttributeTypeReal = 2, + KEPRCModellerAttributeTypeTime = 3, + KEPRCModellerAttributeTypeString = 4 +}; + +enum EPRCPictureDataFormat { + KEPRCPicture_PNG, + KEPRCPicture_JPG, + KEPRCPicture_BITMAP_RGB_BYTE, + KEPRCPicture_BITMAP_RGBA_BYTE, + KEPRCPicture_BITMAP_GREY_BYTE, + KEPRCPicture_BITMAP_GREYA_BYTE +}; + +enum EPRCProductLoadStatus { + KEPRCProductLoadStatus_Unknown = 0, + KEPRCProductLoadStatus_Error, + KEPRCProductLoadStatus_NotLoaded, + KEPRCProductLoadStatus_NotLoadable, + KEPRCProductLoadStatus_Loaded +}; + +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 { // 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, // 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 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 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 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 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. +}; + + +// 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/src/prc/PRCbitStream.cc b/src/prc/PRCbitStream.cc new file mode 100644 index 0000000..2781508 --- /dev/null +++ b/src/prc/PRCbitStream.cc @@ -0,0 +1,404 @@ +/************ +* +* This file is part of a tool for producing 3D content in the PRC format. +* Copyright (C) 2008 Orest Shardt +* +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#include +#include +#include +#include +#include +#include +#include "PRCbitStream.h" +#include "PRCdouble.h" + +using std::string; +using std::cerr; +using std::endl; + +void PRCbitStream::compress() +{ + const int CHUNK= 1024; // is this reasonable? + compressedDataSize = 0; + + z_stream strm; + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + if(deflateInit(&strm,Z_DEFAULT_COMPRESSION) != Z_OK) + { + cerr << "Compression initialization failed" << endl; + return; + } + unsigned int sizeAvailable = deflateBound(&strm,getSize()); + uint8_t *compressedData = (uint8_t*) malloc(sizeAvailable); + strm.avail_in = getSize(); + strm.next_in = (unsigned char*)data; + 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) + { + cerr << "Compression error" << endl; + deflateEnd(&strm); + free(compressedData); + return; + } + + compressed = true; + + free(data); + data = compressedData; + + deflateEnd(&strm); +} + +void PRCbitStream::write(std::ostream &out) const +{ + if(compressed) + { + out.write((char*)data,compressedDataSize); + } + else + { + cerr << "Attempt to write stream before compression." << endl; + exit(1); + } +} + +unsigned int PRCbitStream::getSize() const +{ + if(compressed) + return compressedDataSize; + else + return byteIndex+1; +} + +uint8_t* PRCbitStream::getData() +{ + return data; +} + +PRCbitStream& PRCbitStream::operator <<(bool b) +{ + writeBit(b); + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(uint32_t u) +{ + while(u != 0) + { + writeBit(1); + writeByte(u & 0xFF); + u >>= 8; + } + writeBit(0); + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(uint8_t u) +{ + writeByte(u); + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(int32_t i) +{ + uint8_t lastByte = 0; + //while(!((current value is 0 and last byte was positive) OR (current value is -1 and last value was negative))) + while(!(((i == 0)&&((lastByte & 0x80)==0))||((i == -1)&&((lastByte & 0x80) != 0)))) + { + writeBit(1); + lastByte = i & 0xFF; + writeByte(lastByte); + i >>= 8; + } + writeBit(0); + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(double value) +{ + // write a double + if(compressed) + { + cerr << "Cannot write to a stream that has been compressed." << endl; + return *this; + } + union ieee754_double *pid=(union ieee754_double *)&value; + int + i, + fSaveAtEnd; + PRCbyte + *pb, + *pbStart, + *pbStop, + *pbEnd, + *pbResult, + bSaveAtEnd = 0; + struct sCodageOfFrequentDoubleOrExponent + cofdoe, + *pcofdoe; + + cofdoe.u2uod.Value=value; + pcofdoe = (struct sCodageOfFrequentDoubleOrExponent *)bsearch( + &cofdoe, + acofdoe, + sizeof(acofdoe)/sizeof(pcofdoe[0]), + sizeof(pcofdoe[0]), + stCOFDOECompare); + + while(pcofdoe>acofdoe && EXPONENT(pcofdoe->u2uod.Value)==EXPONENT((pcofdoe-1)->u2uod.Value)) + pcofdoe--; + + assert(pcofdoe); + while(pcofdoe->Type==VT_double) + { + if(fabs(value)==pcofdoe->u2uod.Value) + break; + pcofdoe++; + } + + for(i=1<<(pcofdoe->NumberOfBits-1);i>=1;i>>=1) + writeBit((pcofdoe->Bits&i)!=0); + + if + ( + !memcmp(&value,stadwZero,sizeof(value)) + || !memcmp(&value,stadwNegativeZero,sizeof(value)) + ) + return *this; + + writeBit(pid->ieee.negative); + + if(pcofdoe->Type==VT_double) + return *this; + + if(pid->ieee.mantissa0==0 && pid->ieee.mantissa1==0) + { + writeBit(0); + return *this; + } + + writeBit(1); + +#ifdef WORDS_BIGENDIAN + pb=((PRCbyte *)&value)+1; +#else + pb=((PRCbyte *)&value)+6; +#endif + //add_bits((*pb)&0x0f,4 STAT_V STAT_DOUBLE); + writeBits((*pb)&0x0F,4); + + NEXTBYTE(pb); + pbStart=pb; +#ifdef WORDS_BIGENDIAN + pbEnd= + pbStop= ((PRCbyte *)(&value+1))-1; +#else + pbEnd= + pbStop= ((PRCbyte *)&value); +#endif + + if((fSaveAtEnd=(*pbStop!=*BEFOREBYTE(pbStop)))!=0) + bSaveAtEnd=*pbEnd; + PREVIOUSBYTE(pbStop); + + while(*pbStop==*BEFOREBYTE(pbStop)) + PREVIOUSBYTE(pbStop); + + for(;MOREBYTE(pb,pbStop);NEXTBYTE(pb)) + { + if(pb!=pbStart && (pbResult=SEARCHBYTE(BEFOREBYTE(pb),*pb,DIFFPOINTERS(pb,pbStart)))!=NULL) + { + writeBit(0); + writeBits(DIFFPOINTERS(pb,pbResult),3); + } + else + { + writeBit(1); + writeByte(*pb); + } + } + + if(!MOREBYTE(BEFOREBYTE(pbEnd),pbStop)) + { + if(fSaveAtEnd) + { + writeBit(0); + writeBits(6,3); + writeByte(bSaveAtEnd); + } + else + { + writeBit(0); + writeBits(0,3); + } + } + else + { + if((pbResult=SEARCHBYTE(BEFOREBYTE(pb),*pb,DIFFPOINTERS(pb,pbStart)))!=NULL) + { + writeBit(0); + writeBits(DIFFPOINTERS(pb,pbResult),3); + } + else + { + writeBit(1); + writeByte(*pb); + } + } + + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(const char* s) +{ + if (s == NULL) + { + writeBit(false); // string is NULL + return *this; + } + string str(s); + *this << str; + return *this; +} + +PRCbitStream& PRCbitStream::operator <<(const string& s) +{ + if(s == "") + { + writeBit(false); // string is NULL + return *this; + } + writeBit(true); + size_t l = s.length(); + *this << static_cast(l); + for(size_t i = 0; i < l; ++i) + writeByte(s[i]); + return *this; +} + +void PRCbitStream::writeBit(bool b) +{ + if(compressed) + { + cerr << "Cannot write to a stream that has been compressed." << endl; + return; + } + + if(b) + { + data[byteIndex] |= (0x80 >> bitIndex); + } + nextBit(); +} + +void PRCbitStream::writeBits(uint32_t u, uint8_t bits) +{ + if(bits > 32) + return; + else + { + for(uint32_t mask = (1 << (bits-1)); mask != 0; mask >>= 1) + { + writeBit((u&mask) != 0); + } + } +} + +void PRCbitStream::writeByte(uint8_t u) +{ + if(compressed) + { + cerr << "Cannot write to a stream that has been compressed." << endl; + return; + } + + if(bitIndex == 0) + { + data[byteIndex] = u; + nextByte(); + } + else + { + data[byteIndex] |= (u >> bitIndex); + unsigned int obi = bitIndex; + nextByte(); + data[byteIndex] |= (u << (8-obi)); + bitIndex = obi; // bit index is not changed by writing 8 bits + } +} + +void PRCbitStream::nextBit() +{ + ++bitIndex; + if(bitIndex == 8) + { + nextByte(); + } +} + +void PRCbitStream::nextByte() +{ + ++byteIndex; + if(byteIndex >= allocatedLength) + getAChunk(); + data[byteIndex] = 0; // clear the garbage data + bitIndex = 0; +} + +void PRCbitStream::getAChunk() +{ + if(allocatedLength==0) + data = (uint8_t*)realloc((void*)data,CHUNK_SIZE); + else + data = (uint8_t*)realloc((void*)data,2*allocatedLength); + + if(data != NULL) + { + if(allocatedLength==0) + { + allocatedLength = CHUNK_SIZE; + *data = 0; // clear first byte + } + else + allocatedLength *= 2; + } + else + { + // warn about memory problem! + cerr << "Memory allocation error." << endl; + exit(1); + } +} diff --git a/src/prc/PRCbitStream.h b/src/prc/PRCbitStream.h new file mode 100644 index 0000000..f240baf --- /dev/null +++ b/src/prc/PRCbitStream.h @@ -0,0 +1,88 @@ +/************ +* +* This file is part of a tool for producing 3D content in the PRC format. +* Copyright (C) 2008 Orest Shardt +* +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#ifndef __PRC_BIT_STREAM_H +#define __PRC_BIT_STREAM_H + +#ifdef _MSC_VER +#include +#if _MSC_VER >= 1600 +#include +#else +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; +#endif // _MSC_VER >= 1600 +#elif defined __BORLANDC__ +#include +#else +#include +#endif // _MSC_VER +#include +#include +#include + +#define CHUNK_SIZE (1024) +// Is this a reasonable initial size? + +class PRCbitStream +{ + public: + PRCbitStream(uint8_t*& buff, unsigned int l) : byteIndex(0), bitIndex(0), + allocatedLength(l), data(buff), compressed(false) + { + if(data == 0) + { + getAChunk(); + } + } + + unsigned int getSize() const; + uint8_t* getData(); + + PRCbitStream& operator <<(const std::string&); + PRCbitStream& operator <<(bool); + PRCbitStream& operator <<(uint32_t); + PRCbitStream& operator <<(uint8_t); + PRCbitStream& operator <<(int32_t); + PRCbitStream& operator <<(double); + PRCbitStream& operator <<(const char*); + + void compress(); + void write(std::ostream &out) const; + private: + void writeBit(bool); + void writeBits(uint32_t,uint8_t); + void writeByte(uint8_t); + void nextByte(); + void nextBit(); + void getAChunk(); + // bitIndex is "big endian", zero based, location of next bit to write + unsigned int byteIndex,bitIndex; + unsigned int allocatedLength; + uint8_t*& data; + bool compressed; + uint32_t compressedDataSize; +}; + +#endif // __PRC_BIT_STREAM_H diff --git a/src/prc/PRCdouble.cc b/src/prc/PRCdouble.cc new file mode 100644 index 0000000..69d4b02 --- /dev/null +++ b/src/prc/PRCdouble.cc @@ -0,0 +1,2121 @@ +#include "PRCdouble.h" + +// from Adobe's documentation + +PRCdword stadwZero[2]={DOUBLEWITHTWODWORD(0x00000000,0x00000000)}; +PRCdword stadwNegativeZero[2]={DOUBLEWITHTWODWORD(0x80000000,0x00000000)}; + +struct sCodageOfFrequentDoubleOrExponent* getcofdoe(unsigned Bits, short NumberOfBits) +{ + struct sCodageOfFrequentDoubleOrExponent *pcofdoe; + for(pcofdoe=acofdoe; pcofdoe < acofdoe+NUMBEROFELEMENTINACOFDOE; ++pcofdoe) + { + if(pcofdoe->NumberOfBits == NumberOfBits && pcofdoe->Bits == Bits) + return pcofdoe; + } + return NULL; +} + +int stCOFDOECompare(const void* pcofdoe1,const void* pcofdoe2) +{ + return(EXPONENT(((const struct sCodageOfFrequentDoubleOrExponent *)pcofdoe1)->u2uod.Value)- + EXPONENT(((const struct sCodageOfFrequentDoubleOrExponent *)pcofdoe2)->u2uod.Value)); +} + +#ifdef WORDS_BIGENDIAN +#ifndef HAVE_MEMRCHR +void *memrchr(const void *buf,int c,size_t count) +{ + unsigned char + *pcBuffer=(unsigned char *)buf, + *pcBufferEnd=pcBuffer-count; + + for(;pcBuffer>pcBufferEnd;pcBuffer--) + if(*pcBuffer==c) + return(pcBuffer); + + return(NULL); +} +#endif +#endif + +sCodageOfFrequentDoubleOrExponent acofdoe[NUMBEROFELEMENTINACOFDOE] = +{ + {VT_double,2,0x1,{DOUBLEWITHTWODWORDINTREE(0x00000000,0x00000000)}}, + {VT_exponent,22,0xd1d32,{DOUBLEWITHTWODWORDINTREE(0x00000000,0x00000000)}}, + {VT_exponent,22,0xd1d33,{DOUBLEWITHTWODWORDINTREE(0x00100000,0x00000000)}}, + {VT_exponent,22,0xf78d8,{DOUBLEWITHTWODWORDINTREE(0x00200000,0x00000000)}}, + {VT_exponent,22,0xf78d9,{DOUBLEWITHTWODWORDINTREE(0x00300000,0x00000000)}}, + {VT_exponent,22,0xf78da,{DOUBLEWITHTWODWORDINTREE(0x00400000,0x00000000)}}, + {VT_exponent,22,0xf78db,{DOUBLEWITHTWODWORDINTREE(0x00500000,0x00000000)}}, + {VT_exponent,22,0xf78dc,{DOUBLEWITHTWODWORDINTREE(0x00600000,0x00000000)}}, + {VT_exponent,22,0xf78dd,{DOUBLEWITHTWODWORDINTREE(0x00700000,0x00000000)}}, + {VT_exponent,22,0xf78de,{DOUBLEWITHTWODWORDINTREE(0x00800000,0x00000000)}}, + {VT_exponent,22,0xf78df,{DOUBLEWITHTWODWORDINTREE(0x00900000,0x00000000)}}, + {VT_exponent,22,0xf78e0,{DOUBLEWITHTWODWORDINTREE(0x00a00000,0x00000000)}}, + {VT_exponent,22,0xf78e1,{DOUBLEWITHTWODWORDINTREE(0x00b00000,0x00000000)}}, + {VT_exponent,22,0xf78e2,{DOUBLEWITHTWODWORDINTREE(0x00c00000,0x00000000)}}, + {VT_exponent,22,0xf78e3,{DOUBLEWITHTWODWORDINTREE(0x00d00000,0x00000000)}}, + {VT_exponent,22,0xf78e4,{DOUBLEWITHTWODWORDINTREE(0x00e00000,0x00000000)}}, + {VT_exponent,22,0xf78e5,{DOUBLEWITHTWODWORDINTREE(0x00f00000,0x00000000)}}, + {VT_exponent,22,0xf78e6,{DOUBLEWITHTWODWORDINTREE(0x01000000,0x00000000)}}, + {VT_exponent,22,0xf78e7,{DOUBLEWITHTWODWORDINTREE(0x01100000,0x00000000)}}, + {VT_exponent,22,0xf78e8,{DOUBLEWITHTWODWORDINTREE(0x01200000,0x00000000)}}, + {VT_exponent,22,0xf78e9,{DOUBLEWITHTWODWORDINTREE(0x01300000,0x00000000)}}, + {VT_exponent,22,0xf78ea,{DOUBLEWITHTWODWORDINTREE(0x01400000,0x00000000)}}, + {VT_exponent,22,0xf78eb,{DOUBLEWITHTWODWORDINTREE(0x01500000,0x00000000)}}, + {VT_exponent,22,0xf78ec,{DOUBLEWITHTWODWORDINTREE(0x01600000,0x00000000)}}, + {VT_exponent,22,0xf78ed,{DOUBLEWITHTWODWORDINTREE(0x01700000,0x00000000)}}, + {VT_exponent,22,0xf78ee,{DOUBLEWITHTWODWORDINTREE(0x01800000,0x00000000)}}, + {VT_exponent,22,0xf78ef,{DOUBLEWITHTWODWORDINTREE(0x01900000,0x00000000)}}, + {VT_exponent,22,0xf78f0,{DOUBLEWITHTWODWORDINTREE(0x01a00000,0x00000000)}}, + {VT_exponent,22,0xf78f1,{DOUBLEWITHTWODWORDINTREE(0x01b00000,0x00000000)}}, + {VT_exponent,22,0xf78f2,{DOUBLEWITHTWODWORDINTREE(0x01c00000,0x00000000)}}, + {VT_exponent,22,0xf78f3,{DOUBLEWITHTWODWORDINTREE(0x01d00000,0x00000000)}}, + {VT_exponent,22,0xf78f4,{DOUBLEWITHTWODWORDINTREE(0x01e00000,0x00000000)}}, + {VT_exponent,22,0xf78f5,{DOUBLEWITHTWODWORDINTREE(0x01f00000,0x00000000)}}, + {VT_exponent,22,0xf78f6,{DOUBLEWITHTWODWORDINTREE(0x02000000,0x00000000)}}, + {VT_exponent,22,0xf78f7,{DOUBLEWITHTWODWORDINTREE(0x02100000,0x00000000)}}, + {VT_exponent,22,0xf78f8,{DOUBLEWITHTWODWORDINTREE(0x02200000,0x00000000)}}, + {VT_exponent,22,0xf78f9,{DOUBLEWITHTWODWORDINTREE(0x02300000,0x00000000)}}, + {VT_exponent,22,0xf78fa,{DOUBLEWITHTWODWORDINTREE(0x02400000,0x00000000)}}, + {VT_exponent,22,0xf78fb,{DOUBLEWITHTWODWORDINTREE(0x02500000,0x00000000)}}, + {VT_exponent,22,0xf78fc,{DOUBLEWITHTWODWORDINTREE(0x02600000,0x00000000)}}, + {VT_exponent,22,0xf78fd,{DOUBLEWITHTWODWORDINTREE(0x02700000,0x00000000)}}, + {VT_exponent,22,0xf78fe,{DOUBLEWITHTWODWORDINTREE(0x02800000,0x00000000)}}, + {VT_exponent,22,0xf78ff,{DOUBLEWITHTWODWORDINTREE(0x02900000,0x00000000)}}, + {VT_exponent,22,0x3a8300,{DOUBLEWITHTWODWORDINTREE(0x02a00000,0x00000000)}}, + {VT_exponent,22,0x3a8301,{DOUBLEWITHTWODWORDINTREE(0x02b00000,0x00000000)}}, + {VT_exponent,22,0x3a8302,{DOUBLEWITHTWODWORDINTREE(0x02c00000,0x00000000)}}, + {VT_exponent,22,0x3a8303,{DOUBLEWITHTWODWORDINTREE(0x02d00000,0x00000000)}}, + {VT_exponent,22,0x3a8304,{DOUBLEWITHTWODWORDINTREE(0x02e00000,0x00000000)}}, + {VT_exponent,22,0x3a8305,{DOUBLEWITHTWODWORDINTREE(0x02f00000,0x00000000)}}, + {VT_exponent,22,0x3a8306,{DOUBLEWITHTWODWORDINTREE(0x03000000,0x00000000)}}, + {VT_exponent,22,0x3a8307,{DOUBLEWITHTWODWORDINTREE(0x03100000,0x00000000)}}, + {VT_exponent,22,0x3a8308,{DOUBLEWITHTWODWORDINTREE(0x03200000,0x00000000)}}, + {VT_exponent,22,0x3a8309,{DOUBLEWITHTWODWORDINTREE(0x03300000,0x00000000)}}, + {VT_exponent,22,0x3a830a,{DOUBLEWITHTWODWORDINTREE(0x03400000,0x00000000)}}, + {VT_exponent,22,0x3a830b,{DOUBLEWITHTWODWORDINTREE(0x03500000,0x00000000)}}, + {VT_exponent,22,0x3a830c,{DOUBLEWITHTWODWORDINTREE(0x03600000,0x00000000)}}, + {VT_exponent,22,0x3a830d,{DOUBLEWITHTWODWORDINTREE(0x03700000,0x00000000)}}, + {VT_exponent,22,0x3a830e,{DOUBLEWITHTWODWORDINTREE(0x03800000,0x00000000)}}, + {VT_exponent,22,0x3a830f,{DOUBLEWITHTWODWORDINTREE(0x03900000,0x00000000)}}, + {VT_exponent,22,0x3a8310,{DOUBLEWITHTWODWORDINTREE(0x03a00000,0x00000000)}}, + {VT_exponent,22,0x3a8311,{DOUBLEWITHTWODWORDINTREE(0x03b00000,0x00000000)}}, + {VT_exponent,22,0x3a8312,{DOUBLEWITHTWODWORDINTREE(0x03c00000,0x00000000)}}, + {VT_exponent,22,0x3a8313,{DOUBLEWITHTWODWORDINTREE(0x03d00000,0x00000000)}}, + {VT_exponent,22,0x3a8314,{DOUBLEWITHTWODWORDINTREE(0x03e00000,0x00000000)}}, + {VT_exponent,22,0x3a8315,{DOUBLEWITHTWODWORDINTREE(0x03f00000,0x00000000)}}, + {VT_exponent,22,0x3a8316,{DOUBLEWITHTWODWORDINTREE(0x04000000,0x00000000)}}, + {VT_exponent,22,0x3a8317,{DOUBLEWITHTWODWORDINTREE(0x04100000,0x00000000)}}, + {VT_exponent,22,0x3a8318,{DOUBLEWITHTWODWORDINTREE(0x04200000,0x00000000)}}, + {VT_exponent,22,0x3a8319,{DOUBLEWITHTWODWORDINTREE(0x04300000,0x00000000)}}, + {VT_exponent,22,0x3a831a,{DOUBLEWITHTWODWORDINTREE(0x04400000,0x00000000)}}, + {VT_exponent,22,0x3a831b,{DOUBLEWITHTWODWORDINTREE(0x04500000,0x00000000)}}, + {VT_exponent,22,0x3a831c,{DOUBLEWITHTWODWORDINTREE(0x04600000,0x00000000)}}, + {VT_exponent,22,0x3a831d,{DOUBLEWITHTWODWORDINTREE(0x04700000,0x00000000)}}, + {VT_exponent,22,0x3a831e,{DOUBLEWITHTWODWORDINTREE(0x04800000,0x00000000)}}, + {VT_exponent,22,0x3a831f,{DOUBLEWITHTWODWORDINTREE(0x04900000,0x00000000)}}, + {VT_exponent,22,0x3a8320,{DOUBLEWITHTWODWORDINTREE(0x04a00000,0x00000000)}}, + {VT_exponent,22,0x3a8321,{DOUBLEWITHTWODWORDINTREE(0x04b00000,0x00000000)}}, + {VT_exponent,22,0x3a8322,{DOUBLEWITHTWODWORDINTREE(0x04c00000,0x00000000)}}, + {VT_exponent,22,0x3a8323,{DOUBLEWITHTWODWORDINTREE(0x04d00000,0x00000000)}}, + {VT_exponent,22,0x3a8324,{DOUBLEWITHTWODWORDINTREE(0x04e00000,0x00000000)}}, + {VT_exponent,22,0x3a8325,{DOUBLEWITHTWODWORDINTREE(0x04f00000,0x00000000)}}, + {VT_exponent,22,0x3a8326,{DOUBLEWITHTWODWORDINTREE(0x05000000,0x00000000)}}, + {VT_exponent,22,0x3a8327,{DOUBLEWITHTWODWORDINTREE(0x05100000,0x00000000)}}, + {VT_exponent,22,0x3a8328,{DOUBLEWITHTWODWORDINTREE(0x05200000,0x00000000)}}, + {VT_exponent,22,0x3a8329,{DOUBLEWITHTWODWORDINTREE(0x05300000,0x00000000)}}, + {VT_exponent,22,0x3a832a,{DOUBLEWITHTWODWORDINTREE(0x05400000,0x00000000)}}, + {VT_exponent,22,0x3a832b,{DOUBLEWITHTWODWORDINTREE(0x05500000,0x00000000)}}, + {VT_exponent,22,0x3a832c,{DOUBLEWITHTWODWORDINTREE(0x05600000,0x00000000)}}, + {VT_exponent,22,0x3a832d,{DOUBLEWITHTWODWORDINTREE(0x05700000,0x00000000)}}, + {VT_exponent,22,0x3a832e,{DOUBLEWITHTWODWORDINTREE(0x05800000,0x00000000)}}, + {VT_exponent,22,0x3a832f,{DOUBLEWITHTWODWORDINTREE(0x05900000,0x00000000)}}, + {VT_exponent,22,0x3a8330,{DOUBLEWITHTWODWORDINTREE(0x05a00000,0x00000000)}}, + {VT_exponent,22,0x3a8331,{DOUBLEWITHTWODWORDINTREE(0x05b00000,0x00000000)}}, + {VT_exponent,22,0x3a8332,{DOUBLEWITHTWODWORDINTREE(0x05c00000,0x00000000)}}, + {VT_exponent,22,0x3a8333,{DOUBLEWITHTWODWORDINTREE(0x05d00000,0x00000000)}}, + {VT_exponent,22,0x3a8334,{DOUBLEWITHTWODWORDINTREE(0x05e00000,0x00000000)}}, + {VT_exponent,22,0x3a8335,{DOUBLEWITHTWODWORDINTREE(0x05f00000,0x00000000)}}, + {VT_exponent,22,0x3a8336,{DOUBLEWITHTWODWORDINTREE(0x06000000,0x00000000)}}, + {VT_exponent,22,0x3a8337,{DOUBLEWITHTWODWORDINTREE(0x06100000,0x00000000)}}, + {VT_exponent,22,0x3a8338,{DOUBLEWITHTWODWORDINTREE(0x06200000,0x00000000)}}, + {VT_exponent,22,0x3a8339,{DOUBLEWITHTWODWORDINTREE(0x06300000,0x00000000)}}, + {VT_exponent,22,0x3a833a,{DOUBLEWITHTWODWORDINTREE(0x06400000,0x00000000)}}, + {VT_exponent,22,0x3a833b,{DOUBLEWITHTWODWORDINTREE(0x06500000,0x00000000)}}, + {VT_exponent,22,0x3a833c,{DOUBLEWITHTWODWORDINTREE(0x06600000,0x00000000)}}, + {VT_exponent,22,0x3a833d,{DOUBLEWITHTWODWORDINTREE(0x06700000,0x00000000)}}, + {VT_exponent,22,0x3a833e,{DOUBLEWITHTWODWORDINTREE(0x06800000,0x00000000)}}, + {VT_exponent,22,0x3a833f,{DOUBLEWITHTWODWORDINTREE(0x06900000,0x00000000)}}, + {VT_exponent,22,0x3a8340,{DOUBLEWITHTWODWORDINTREE(0x06a00000,0x00000000)}}, + {VT_exponent,22,0x3a8341,{DOUBLEWITHTWODWORDINTREE(0x06b00000,0x00000000)}}, + {VT_exponent,22,0x3a8342,{DOUBLEWITHTWODWORDINTREE(0x06c00000,0x00000000)}}, + {VT_exponent,22,0x3a8343,{DOUBLEWITHTWODWORDINTREE(0x06d00000,0x00000000)}}, + {VT_exponent,22,0x3a8344,{DOUBLEWITHTWODWORDINTREE(0x06e00000,0x00000000)}}, + {VT_exponent,22,0x3a8345,{DOUBLEWITHTWODWORDINTREE(0x06f00000,0x00000000)}}, + {VT_exponent,22,0x3a8346,{DOUBLEWITHTWODWORDINTREE(0x07000000,0x00000000)}}, + {VT_exponent,22,0x3a8347,{DOUBLEWITHTWODWORDINTREE(0x07100000,0x00000000)}}, + {VT_exponent,22,0x3a8348,{DOUBLEWITHTWODWORDINTREE(0x07200000,0x00000000)}}, + {VT_exponent,22,0x3a8349,{DOUBLEWITHTWODWORDINTREE(0x07300000,0x00000000)}}, + {VT_exponent,22,0x3a834a,{DOUBLEWITHTWODWORDINTREE(0x07400000,0x00000000)}}, + {VT_exponent,22,0x3a834b,{DOUBLEWITHTWODWORDINTREE(0x07500000,0x00000000)}}, + {VT_exponent,22,0x3a834c,{DOUBLEWITHTWODWORDINTREE(0x07600000,0x00000000)}}, + {VT_exponent,22,0x3a834d,{DOUBLEWITHTWODWORDINTREE(0x07700000,0x00000000)}}, + {VT_exponent,22,0x3a834e,{DOUBLEWITHTWODWORDINTREE(0x07800000,0x00000000)}}, + {VT_exponent,22,0x3a834f,{DOUBLEWITHTWODWORDINTREE(0x07900000,0x00000000)}}, + {VT_exponent,22,0x3a8350,{DOUBLEWITHTWODWORDINTREE(0x07a00000,0x00000000)}}, + {VT_exponent,22,0x3a8351,{DOUBLEWITHTWODWORDINTREE(0x07b00000,0x00000000)}}, + {VT_exponent,22,0x3a8352,{DOUBLEWITHTWODWORDINTREE(0x07c00000,0x00000000)}}, + {VT_exponent,22,0x3a8353,{DOUBLEWITHTWODWORDINTREE(0x07d00000,0x00000000)}}, + {VT_exponent,22,0x3a8354,{DOUBLEWITHTWODWORDINTREE(0x07e00000,0x00000000)}}, + {VT_exponent,22,0x3a8355,{DOUBLEWITHTWODWORDINTREE(0x07f00000,0x00000000)}}, + {VT_exponent,22,0x3a8356,{DOUBLEWITHTWODWORDINTREE(0x08000000,0x00000000)}}, + {VT_exponent,22,0x3a8357,{DOUBLEWITHTWODWORDINTREE(0x08100000,0x00000000)}}, + {VT_exponent,22,0x3a8358,{DOUBLEWITHTWODWORDINTREE(0x08200000,0x00000000)}}, + {VT_exponent,22,0x3a8359,{DOUBLEWITHTWODWORDINTREE(0x08300000,0x00000000)}}, + {VT_exponent,22,0x3a835a,{DOUBLEWITHTWODWORDINTREE(0x08400000,0x00000000)}}, + {VT_exponent,22,0x3a835b,{DOUBLEWITHTWODWORDINTREE(0x08500000,0x00000000)}}, + {VT_exponent,22,0x3a835c,{DOUBLEWITHTWODWORDINTREE(0x08600000,0x00000000)}}, + {VT_exponent,22,0x3a835d,{DOUBLEWITHTWODWORDINTREE(0x08700000,0x00000000)}}, + {VT_exponent,22,0x3a835e,{DOUBLEWITHTWODWORDINTREE(0x08800000,0x00000000)}}, + {VT_exponent,22,0x3a835f,{DOUBLEWITHTWODWORDINTREE(0x08900000,0x00000000)}}, + {VT_exponent,22,0x3a8360,{DOUBLEWITHTWODWORDINTREE(0x08a00000,0x00000000)}}, + {VT_exponent,22,0x3a8361,{DOUBLEWITHTWODWORDINTREE(0x08b00000,0x00000000)}}, + {VT_exponent,22,0x3a8362,{DOUBLEWITHTWODWORDINTREE(0x08c00000,0x00000000)}}, + {VT_exponent,22,0x3a8363,{DOUBLEWITHTWODWORDINTREE(0x08d00000,0x00000000)}}, + {VT_exponent,22,0x3a8364,{DOUBLEWITHTWODWORDINTREE(0x08e00000,0x00000000)}}, + {VT_exponent,22,0x3a8365,{DOUBLEWITHTWODWORDINTREE(0x08f00000,0x00000000)}}, + {VT_exponent,22,0x3a8366,{DOUBLEWITHTWODWORDINTREE(0x09000000,0x00000000)}}, + {VT_exponent,22,0x3a8367,{DOUBLEWITHTWODWORDINTREE(0x09100000,0x00000000)}}, + {VT_exponent,22,0x3a8368,{DOUBLEWITHTWODWORDINTREE(0x09200000,0x00000000)}}, + {VT_exponent,22,0x3a8369,{DOUBLEWITHTWODWORDINTREE(0x09300000,0x00000000)}}, + {VT_exponent,22,0x3a836a,{DOUBLEWITHTWODWORDINTREE(0x09400000,0x00000000)}}, + {VT_exponent,22,0x3a836b,{DOUBLEWITHTWODWORDINTREE(0x09500000,0x00000000)}}, + {VT_exponent,22,0x3a836c,{DOUBLEWITHTWODWORDINTREE(0x09600000,0x00000000)}}, + {VT_exponent,22,0x3a836d,{DOUBLEWITHTWODWORDINTREE(0x09700000,0x00000000)}}, + {VT_exponent,22,0x3a836e,{DOUBLEWITHTWODWORDINTREE(0x09800000,0x00000000)}}, + {VT_exponent,22,0x3a836f,{DOUBLEWITHTWODWORDINTREE(0x09900000,0x00000000)}}, + {VT_exponent,22,0x3a8370,{DOUBLEWITHTWODWORDINTREE(0x09a00000,0x00000000)}}, + {VT_exponent,22,0x3a8371,{DOUBLEWITHTWODWORDINTREE(0x09b00000,0x00000000)}}, + {VT_exponent,22,0x3a8372,{DOUBLEWITHTWODWORDINTREE(0x09c00000,0x00000000)}}, + {VT_exponent,22,0x3a8373,{DOUBLEWITHTWODWORDINTREE(0x09d00000,0x00000000)}}, + {VT_exponent,22,0x3a8374,{DOUBLEWITHTWODWORDINTREE(0x09e00000,0x00000000)}}, + {VT_exponent,22,0x3a8375,{DOUBLEWITHTWODWORDINTREE(0x09f00000,0x00000000)}}, + {VT_exponent,22,0x3a8376,{DOUBLEWITHTWODWORDINTREE(0x0a000000,0x00000000)}}, + {VT_exponent,22,0x3a8377,{DOUBLEWITHTWODWORDINTREE(0x0a100000,0x00000000)}}, + {VT_exponent,22,0x3a8378,{DOUBLEWITHTWODWORDINTREE(0x0a200000,0x00000000)}}, + {VT_exponent,22,0x3a8379,{DOUBLEWITHTWODWORDINTREE(0x0a300000,0x00000000)}}, + {VT_exponent,22,0x3a837a,{DOUBLEWITHTWODWORDINTREE(0x0a400000,0x00000000)}}, + {VT_exponent,22,0x3a837b,{DOUBLEWITHTWODWORDINTREE(0x0a500000,0x00000000)}}, + {VT_exponent,22,0x3a837c,{DOUBLEWITHTWODWORDINTREE(0x0a600000,0x00000000)}}, + {VT_exponent,22,0x3a837d,{DOUBLEWITHTWODWORDINTREE(0x0a700000,0x00000000)}}, + {VT_exponent,22,0x3a837e,{DOUBLEWITHTWODWORDINTREE(0x0a800000,0x00000000)}}, + {VT_exponent,22,0x3a837f,{DOUBLEWITHTWODWORDINTREE(0x0a900000,0x00000000)}}, + {VT_exponent,22,0x3a8380,{DOUBLEWITHTWODWORDINTREE(0x0aa00000,0x00000000)}}, + {VT_exponent,22,0x3a8381,{DOUBLEWITHTWODWORDINTREE(0x0ab00000,0x00000000)}}, + {VT_exponent,22,0x3a8382,{DOUBLEWITHTWODWORDINTREE(0x0ac00000,0x00000000)}}, + {VT_exponent,22,0x3a8383,{DOUBLEWITHTWODWORDINTREE(0x0ad00000,0x00000000)}}, + {VT_exponent,22,0x3a8384,{DOUBLEWITHTWODWORDINTREE(0x0ae00000,0x00000000)}}, + {VT_exponent,22,0x3a8385,{DOUBLEWITHTWODWORDINTREE(0x0af00000,0x00000000)}}, + {VT_exponent,22,0x3a8386,{DOUBLEWITHTWODWORDINTREE(0x0b000000,0x00000000)}}, + {VT_exponent,22,0x3a8387,{DOUBLEWITHTWODWORDINTREE(0x0b100000,0x00000000)}}, + {VT_exponent,22,0x3a8388,{DOUBLEWITHTWODWORDINTREE(0x0b200000,0x00000000)}}, + {VT_exponent,22,0x3a8389,{DOUBLEWITHTWODWORDINTREE(0x0b300000,0x00000000)}}, + {VT_exponent,22,0x3a838a,{DOUBLEWITHTWODWORDINTREE(0x0b400000,0x00000000)}}, + {VT_exponent,22,0x3a838b,{DOUBLEWITHTWODWORDINTREE(0x0b500000,0x00000000)}}, + {VT_exponent,22,0x3a838c,{DOUBLEWITHTWODWORDINTREE(0x0b600000,0x00000000)}}, + {VT_exponent,22,0x3a838d,{DOUBLEWITHTWODWORDINTREE(0x0b700000,0x00000000)}}, + {VT_exponent,22,0x3a838e,{DOUBLEWITHTWODWORDINTREE(0x0b800000,0x00000000)}}, + {VT_exponent,22,0x3a838f,{DOUBLEWITHTWODWORDINTREE(0x0b900000,0x00000000)}}, + {VT_exponent,22,0x3a8390,{DOUBLEWITHTWODWORDINTREE(0x0ba00000,0x00000000)}}, + {VT_exponent,22,0x3a8391,{DOUBLEWITHTWODWORDINTREE(0x0bb00000,0x00000000)}}, + {VT_exponent,22,0x3a8392,{DOUBLEWITHTWODWORDINTREE(0x0bc00000,0x00000000)}}, + {VT_exponent,22,0x3a8393,{DOUBLEWITHTWODWORDINTREE(0x0bd00000,0x00000000)}}, + {VT_exponent,22,0x3a8394,{DOUBLEWITHTWODWORDINTREE(0x0be00000,0x00000000)}}, + {VT_exponent,22,0x3a8395,{DOUBLEWITHTWODWORDINTREE(0x0bf00000,0x00000000)}}, + {VT_exponent,22,0x3a8396,{DOUBLEWITHTWODWORDINTREE(0x0c000000,0x00000000)}}, + {VT_exponent,22,0x3a8397,{DOUBLEWITHTWODWORDINTREE(0x0c100000,0x00000000)}}, + {VT_exponent,22,0x3a8398,{DOUBLEWITHTWODWORDINTREE(0x0c200000,0x00000000)}}, + {VT_exponent,22,0x3a8399,{DOUBLEWITHTWODWORDINTREE(0x0c300000,0x00000000)}}, + {VT_exponent,22,0x3a839a,{DOUBLEWITHTWODWORDINTREE(0x0c400000,0x00000000)}}, + {VT_exponent,22,0x3a839b,{DOUBLEWITHTWODWORDINTREE(0x0c500000,0x00000000)}}, + {VT_exponent,22,0x3a839c,{DOUBLEWITHTWODWORDINTREE(0x0c600000,0x00000000)}}, + {VT_exponent,22,0x3a839d,{DOUBLEWITHTWODWORDINTREE(0x0c700000,0x00000000)}}, + {VT_exponent,22,0x3a839e,{DOUBLEWITHTWODWORDINTREE(0x0c800000,0x00000000)}}, + {VT_exponent,22,0x3a839f,{DOUBLEWITHTWODWORDINTREE(0x0c900000,0x00000000)}}, + {VT_exponent,22,0x3a83a0,{DOUBLEWITHTWODWORDINTREE(0x0ca00000,0x00000000)}}, + {VT_exponent,22,0x3a83a1,{DOUBLEWITHTWODWORDINTREE(0x0cb00000,0x00000000)}}, + {VT_exponent,22,0x3a83a2,{DOUBLEWITHTWODWORDINTREE(0x0cc00000,0x00000000)}}, + {VT_exponent,22,0x3a83a3,{DOUBLEWITHTWODWORDINTREE(0x0cd00000,0x00000000)}}, + {VT_exponent,22,0x3a83a4,{DOUBLEWITHTWODWORDINTREE(0x0ce00000,0x00000000)}}, + {VT_exponent,22,0x3a83a5,{DOUBLEWITHTWODWORDINTREE(0x0cf00000,0x00000000)}}, + {VT_exponent,22,0x3a83a6,{DOUBLEWITHTWODWORDINTREE(0x0d000000,0x00000000)}}, + {VT_exponent,22,0x3a83a7,{DOUBLEWITHTWODWORDINTREE(0x0d100000,0x00000000)}}, + {VT_exponent,22,0x3a83a8,{DOUBLEWITHTWODWORDINTREE(0x0d200000,0x00000000)}}, + {VT_exponent,22,0x3a83a9,{DOUBLEWITHTWODWORDINTREE(0x0d300000,0x00000000)}}, + {VT_exponent,22,0x3a83aa,{DOUBLEWITHTWODWORDINTREE(0x0d400000,0x00000000)}}, + {VT_exponent,22,0x3a83ab,{DOUBLEWITHTWODWORDINTREE(0x0d500000,0x00000000)}}, + {VT_exponent,22,0x3a83ac,{DOUBLEWITHTWODWORDINTREE(0x0d600000,0x00000000)}}, + {VT_exponent,22,0x3a83ad,{DOUBLEWITHTWODWORDINTREE(0x0d700000,0x00000000)}}, + {VT_exponent,22,0x3a83ae,{DOUBLEWITHTWODWORDINTREE(0x0d800000,0x00000000)}}, + {VT_exponent,22,0x3a83af,{DOUBLEWITHTWODWORDINTREE(0x0d900000,0x00000000)}}, + {VT_exponent,22,0x3a83b0,{DOUBLEWITHTWODWORDINTREE(0x0da00000,0x00000000)}}, + {VT_exponent,22,0x3a83b1,{DOUBLEWITHTWODWORDINTREE(0x0db00000,0x00000000)}}, + {VT_exponent,22,0x3a83b2,{DOUBLEWITHTWODWORDINTREE(0x0dc00000,0x00000000)}}, + {VT_exponent,22,0x3a83b3,{DOUBLEWITHTWODWORDINTREE(0x0dd00000,0x00000000)}}, + {VT_exponent,22,0x3a83b4,{DOUBLEWITHTWODWORDINTREE(0x0de00000,0x00000000)}}, + {VT_exponent,22,0x3a83b5,{DOUBLEWITHTWODWORDINTREE(0x0df00000,0x00000000)}}, + {VT_exponent,22,0x3a83b6,{DOUBLEWITHTWODWORDINTREE(0x0e000000,0x00000000)}}, + {VT_exponent,22,0x3a83b7,{DOUBLEWITHTWODWORDINTREE(0x0e100000,0x00000000)}}, + {VT_exponent,22,0x3a83b8,{DOUBLEWITHTWODWORDINTREE(0x0e200000,0x00000000)}}, + {VT_exponent,22,0x3a83b9,{DOUBLEWITHTWODWORDINTREE(0x0e300000,0x00000000)}}, + {VT_exponent,22,0x3a83ba,{DOUBLEWITHTWODWORDINTREE(0x0e400000,0x00000000)}}, + {VT_exponent,22,0x3a83bb,{DOUBLEWITHTWODWORDINTREE(0x0e500000,0x00000000)}}, + {VT_exponent,22,0x3a83bc,{DOUBLEWITHTWODWORDINTREE(0x0e600000,0x00000000)}}, + {VT_exponent,22,0x3a83bd,{DOUBLEWITHTWODWORDINTREE(0x0e700000,0x00000000)}}, + {VT_exponent,22,0x3a83be,{DOUBLEWITHTWODWORDINTREE(0x0e800000,0x00000000)}}, + {VT_exponent,22,0x3a83bf,{DOUBLEWITHTWODWORDINTREE(0x0e900000,0x00000000)}}, + {VT_exponent,22,0x3a83c0,{DOUBLEWITHTWODWORDINTREE(0x0ea00000,0x00000000)}}, + {VT_exponent,22,0x3a83c1,{DOUBLEWITHTWODWORDINTREE(0x0eb00000,0x00000000)}}, + {VT_exponent,22,0x3a83c2,{DOUBLEWITHTWODWORDINTREE(0x0ec00000,0x00000000)}}, + {VT_exponent,22,0x3a83c3,{DOUBLEWITHTWODWORDINTREE(0x0ed00000,0x00000000)}}, + {VT_exponent,22,0x3a83c4,{DOUBLEWITHTWODWORDINTREE(0x0ee00000,0x00000000)}}, + {VT_exponent,22,0x3a83c5,{DOUBLEWITHTWODWORDINTREE(0x0ef00000,0x00000000)}}, + {VT_exponent,22,0x3a83c6,{DOUBLEWITHTWODWORDINTREE(0x0f000000,0x00000000)}}, + {VT_exponent,22,0x3a83c7,{DOUBLEWITHTWODWORDINTREE(0x0f100000,0x00000000)}}, + {VT_exponent,22,0x3a83c8,{DOUBLEWITHTWODWORDINTREE(0x0f200000,0x00000000)}}, + {VT_exponent,22,0x3a83c9,{DOUBLEWITHTWODWORDINTREE(0x0f300000,0x00000000)}}, + {VT_exponent,22,0x3a83ca,{DOUBLEWITHTWODWORDINTREE(0x0f400000,0x00000000)}}, + {VT_exponent,22,0x3a83cb,{DOUBLEWITHTWODWORDINTREE(0x0f500000,0x00000000)}}, + {VT_exponent,22,0x3a83cc,{DOUBLEWITHTWODWORDINTREE(0x0f600000,0x00000000)}}, + {VT_exponent,22,0x3a83cd,{DOUBLEWITHTWODWORDINTREE(0x0f700000,0x00000000)}}, + {VT_exponent,22,0x3a83ce,{DOUBLEWITHTWODWORDINTREE(0x0f800000,0x00000000)}}, + {VT_exponent,22,0x3a83cf,{DOUBLEWITHTWODWORDINTREE(0x0f900000,0x00000000)}}, + {VT_exponent,22,0x3a83d0,{DOUBLEWITHTWODWORDINTREE(0x0fa00000,0x00000000)}}, + {VT_exponent,22,0x3a83d1,{DOUBLEWITHTWODWORDINTREE(0x0fb00000,0x00000000)}}, + {VT_exponent,22,0x3a83d2,{DOUBLEWITHTWODWORDINTREE(0x0fc00000,0x00000000)}}, + {VT_exponent,22,0x3a83d3,{DOUBLEWITHTWODWORDINTREE(0x0fd00000,0x00000000)}}, + {VT_exponent,22,0x3a83d4,{DOUBLEWITHTWODWORDINTREE(0x0fe00000,0x00000000)}}, + {VT_exponent,22,0x3a83d5,{DOUBLEWITHTWODWORDINTREE(0x0ff00000,0x00000000)}}, + {VT_exponent,22,0x3a83d6,{DOUBLEWITHTWODWORDINTREE(0x10000000,0x00000000)}}, + {VT_exponent,22,0x3a83d7,{DOUBLEWITHTWODWORDINTREE(0x10100000,0x00000000)}}, + {VT_exponent,22,0x3a83d8,{DOUBLEWITHTWODWORDINTREE(0x10200000,0x00000000)}}, + {VT_exponent,22,0x3a83d9,{DOUBLEWITHTWODWORDINTREE(0x10300000,0x00000000)}}, + {VT_exponent,22,0x3a83da,{DOUBLEWITHTWODWORDINTREE(0x10400000,0x00000000)}}, + {VT_exponent,22,0x3a83db,{DOUBLEWITHTWODWORDINTREE(0x10500000,0x00000000)}}, + {VT_exponent,22,0x3a83dc,{DOUBLEWITHTWODWORDINTREE(0x10600000,0x00000000)}}, + {VT_exponent,22,0x3a83dd,{DOUBLEWITHTWODWORDINTREE(0x10700000,0x00000000)}}, + {VT_exponent,22,0x3a83de,{DOUBLEWITHTWODWORDINTREE(0x10800000,0x00000000)}}, + {VT_exponent,22,0x3a83df,{DOUBLEWITHTWODWORDINTREE(0x10900000,0x00000000)}}, + {VT_exponent,22,0x3a83e0,{DOUBLEWITHTWODWORDINTREE(0x10a00000,0x00000000)}}, + {VT_exponent,22,0x3a83e1,{DOUBLEWITHTWODWORDINTREE(0x10b00000,0x00000000)}}, + {VT_exponent,22,0x3a83e2,{DOUBLEWITHTWODWORDINTREE(0x10c00000,0x00000000)}}, + {VT_exponent,22,0x3a83e3,{DOUBLEWITHTWODWORDINTREE(0x10d00000,0x00000000)}}, + {VT_exponent,22,0x3a83e4,{DOUBLEWITHTWODWORDINTREE(0x10e00000,0x00000000)}}, + {VT_exponent,22,0x3a83e5,{DOUBLEWITHTWODWORDINTREE(0x10f00000,0x00000000)}}, + {VT_exponent,22,0x3a83e6,{DOUBLEWITHTWODWORDINTREE(0x11000000,0x00000000)}}, + {VT_exponent,22,0x3a83e7,{DOUBLEWITHTWODWORDINTREE(0x11100000,0x00000000)}}, + {VT_exponent,22,0x3a83e8,{DOUBLEWITHTWODWORDINTREE(0x11200000,0x00000000)}}, + {VT_exponent,22,0x3a83e9,{DOUBLEWITHTWODWORDINTREE(0x11300000,0x00000000)}}, + {VT_exponent,22,0x3a83ea,{DOUBLEWITHTWODWORDINTREE(0x11400000,0x00000000)}}, + {VT_exponent,22,0x3a83eb,{DOUBLEWITHTWODWORDINTREE(0x11500000,0x00000000)}}, + {VT_exponent,22,0x3a83ec,{DOUBLEWITHTWODWORDINTREE(0x11600000,0x00000000)}}, + {VT_exponent,22,0x3a83ed,{DOUBLEWITHTWODWORDINTREE(0x11700000,0x00000000)}}, + {VT_exponent,22,0x3a83ee,{DOUBLEWITHTWODWORDINTREE(0x11800000,0x00000000)}}, + {VT_exponent,22,0x3a83ef,{DOUBLEWITHTWODWORDINTREE(0x11900000,0x00000000)}}, + {VT_exponent,22,0x3a83f0,{DOUBLEWITHTWODWORDINTREE(0x11a00000,0x00000000)}}, + {VT_exponent,22,0x3a83f1,{DOUBLEWITHTWODWORDINTREE(0x11b00000,0x00000000)}}, + {VT_exponent,22,0x3a83f2,{DOUBLEWITHTWODWORDINTREE(0x11c00000,0x00000000)}}, + {VT_exponent,22,0x3a83f3,{DOUBLEWITHTWODWORDINTREE(0x11d00000,0x00000000)}}, + {VT_exponent,22,0x3a83f4,{DOUBLEWITHTWODWORDINTREE(0x11e00000,0x00000000)}}, + {VT_exponent,22,0x3a83f5,{DOUBLEWITHTWODWORDINTREE(0x11f00000,0x00000000)}}, + {VT_exponent,22,0x3a83f6,{DOUBLEWITHTWODWORDINTREE(0x12000000,0x00000000)}}, + {VT_exponent,22,0x3a83f7,{DOUBLEWITHTWODWORDINTREE(0x12100000,0x00000000)}}, + {VT_exponent,22,0x3a83f8,{DOUBLEWITHTWODWORDINTREE(0x12200000,0x00000000)}}, + {VT_exponent,22,0x3a83f9,{DOUBLEWITHTWODWORDINTREE(0x12300000,0x00000000)}}, + {VT_exponent,22,0x3a83fa,{DOUBLEWITHTWODWORDINTREE(0x12400000,0x00000000)}}, + {VT_exponent,22,0x3a83fb,{DOUBLEWITHTWODWORDINTREE(0x12500000,0x00000000)}}, + {VT_exponent,22,0x3a83fc,{DOUBLEWITHTWODWORDINTREE(0x12600000,0x00000000)}}, + {VT_exponent,22,0x3a83fd,{DOUBLEWITHTWODWORDINTREE(0x12700000,0x00000000)}}, + {VT_exponent,22,0x3a83fe,{DOUBLEWITHTWODWORDINTREE(0x12800000,0x00000000)}}, + {VT_exponent,22,0x3a83ff,{DOUBLEWITHTWODWORDINTREE(0x12900000,0x00000000)}}, + {VT_exponent,22,0x3a8400,{DOUBLEWITHTWODWORDINTREE(0x12a00000,0x00000000)}}, + {VT_exponent,22,0x3a8401,{DOUBLEWITHTWODWORDINTREE(0x12b00000,0x00000000)}}, + {VT_exponent,22,0x3a8402,{DOUBLEWITHTWODWORDINTREE(0x12c00000,0x00000000)}}, + {VT_exponent,22,0x3a8403,{DOUBLEWITHTWODWORDINTREE(0x12d00000,0x00000000)}}, + {VT_exponent,22,0x3a8404,{DOUBLEWITHTWODWORDINTREE(0x12e00000,0x00000000)}}, + {VT_exponent,22,0x3a8405,{DOUBLEWITHTWODWORDINTREE(0x12f00000,0x00000000)}}, + {VT_exponent,22,0x3a8406,{DOUBLEWITHTWODWORDINTREE(0x13000000,0x00000000)}}, + {VT_exponent,22,0x3a8407,{DOUBLEWITHTWODWORDINTREE(0x13100000,0x00000000)}}, + {VT_exponent,22,0x3a8408,{DOUBLEWITHTWODWORDINTREE(0x13200000,0x00000000)}}, + {VT_exponent,22,0x3a8409,{DOUBLEWITHTWODWORDINTREE(0x13300000,0x00000000)}}, + {VT_exponent,22,0x3a840a,{DOUBLEWITHTWODWORDINTREE(0x13400000,0x00000000)}}, + {VT_exponent,22,0x3a840b,{DOUBLEWITHTWODWORDINTREE(0x13500000,0x00000000)}}, + {VT_exponent,22,0x3a840c,{DOUBLEWITHTWODWORDINTREE(0x13600000,0x00000000)}}, + {VT_exponent,22,0x3a840d,{DOUBLEWITHTWODWORDINTREE(0x13700000,0x00000000)}}, + {VT_exponent,22,0x3a840e,{DOUBLEWITHTWODWORDINTREE(0x13800000,0x00000000)}}, + {VT_exponent,22,0x3a840f,{DOUBLEWITHTWODWORDINTREE(0x13900000,0x00000000)}}, + {VT_exponent,22,0x3a8410,{DOUBLEWITHTWODWORDINTREE(0x13a00000,0x00000000)}}, + {VT_exponent,22,0x3a8411,{DOUBLEWITHTWODWORDINTREE(0x13b00000,0x00000000)}}, + {VT_exponent,22,0x3a8412,{DOUBLEWITHTWODWORDINTREE(0x13c00000,0x00000000)}}, + {VT_exponent,22,0x3a8413,{DOUBLEWITHTWODWORDINTREE(0x13d00000,0x00000000)}}, + {VT_exponent,22,0x3a8414,{DOUBLEWITHTWODWORDINTREE(0x13e00000,0x00000000)}}, + {VT_exponent,22,0x3a8415,{DOUBLEWITHTWODWORDINTREE(0x13f00000,0x00000000)}}, + {VT_exponent,22,0x3a8416,{DOUBLEWITHTWODWORDINTREE(0x14000000,0x00000000)}}, + {VT_exponent,22,0x3a8417,{DOUBLEWITHTWODWORDINTREE(0x14100000,0x00000000)}}, + {VT_exponent,22,0x3a8418,{DOUBLEWITHTWODWORDINTREE(0x14200000,0x00000000)}}, + {VT_exponent,22,0x3a8419,{DOUBLEWITHTWODWORDINTREE(0x14300000,0x00000000)}}, + {VT_exponent,22,0x3a841a,{DOUBLEWITHTWODWORDINTREE(0x14400000,0x00000000)}}, + {VT_exponent,22,0x3a841b,{DOUBLEWITHTWODWORDINTREE(0x14500000,0x00000000)}}, + {VT_exponent,22,0x3a841c,{DOUBLEWITHTWODWORDINTREE(0x14600000,0x00000000)}}, + {VT_exponent,22,0x3a841d,{DOUBLEWITHTWODWORDINTREE(0x14700000,0x00000000)}}, + {VT_exponent,22,0x3a841e,{DOUBLEWITHTWODWORDINTREE(0x14800000,0x00000000)}}, + {VT_exponent,22,0x3a841f,{DOUBLEWITHTWODWORDINTREE(0x14900000,0x00000000)}}, + {VT_exponent,22,0x3a8420,{DOUBLEWITHTWODWORDINTREE(0x14a00000,0x00000000)}}, + {VT_exponent,22,0x3a8421,{DOUBLEWITHTWODWORDINTREE(0x14b00000,0x00000000)}}, + {VT_exponent,22,0x3a8422,{DOUBLEWITHTWODWORDINTREE(0x14c00000,0x00000000)}}, + {VT_exponent,22,0x3a8423,{DOUBLEWITHTWODWORDINTREE(0x14d00000,0x00000000)}}, + {VT_exponent,22,0x3a8424,{DOUBLEWITHTWODWORDINTREE(0x14e00000,0x00000000)}}, + {VT_exponent,22,0x3a8425,{DOUBLEWITHTWODWORDINTREE(0x14f00000,0x00000000)}}, + {VT_exponent,22,0x3a8426,{DOUBLEWITHTWODWORDINTREE(0x15000000,0x00000000)}}, + {VT_exponent,22,0x3a8427,{DOUBLEWITHTWODWORDINTREE(0x15100000,0x00000000)}}, + {VT_exponent,22,0x3a8428,{DOUBLEWITHTWODWORDINTREE(0x15200000,0x00000000)}}, + {VT_exponent,22,0x3a8429,{DOUBLEWITHTWODWORDINTREE(0x15300000,0x00000000)}}, + {VT_exponent,22,0x3a842a,{DOUBLEWITHTWODWORDINTREE(0x15400000,0x00000000)}}, + {VT_exponent,22,0x3a842b,{DOUBLEWITHTWODWORDINTREE(0x15500000,0x00000000)}}, + {VT_exponent,22,0x3a842c,{DOUBLEWITHTWODWORDINTREE(0x15600000,0x00000000)}}, + {VT_exponent,22,0x3a842d,{DOUBLEWITHTWODWORDINTREE(0x15700000,0x00000000)}}, + {VT_exponent,22,0x3a842e,{DOUBLEWITHTWODWORDINTREE(0x15800000,0x00000000)}}, + {VT_exponent,22,0x3a842f,{DOUBLEWITHTWODWORDINTREE(0x15900000,0x00000000)}}, + {VT_exponent,22,0x3a8430,{DOUBLEWITHTWODWORDINTREE(0x15a00000,0x00000000)}}, + {VT_exponent,22,0x3a8431,{DOUBLEWITHTWODWORDINTREE(0x15b00000,0x00000000)}}, + {VT_exponent,22,0x3a8432,{DOUBLEWITHTWODWORDINTREE(0x15c00000,0x00000000)}}, + {VT_exponent,22,0x3a8433,{DOUBLEWITHTWODWORDINTREE(0x15d00000,0x00000000)}}, + {VT_exponent,22,0x3a8434,{DOUBLEWITHTWODWORDINTREE(0x15e00000,0x00000000)}}, + {VT_exponent,22,0x3a8435,{DOUBLEWITHTWODWORDINTREE(0x15f00000,0x00000000)}}, + {VT_exponent,22,0x3a8436,{DOUBLEWITHTWODWORDINTREE(0x16000000,0x00000000)}}, + {VT_exponent,22,0x3a8437,{DOUBLEWITHTWODWORDINTREE(0x16100000,0x00000000)}}, + {VT_exponent,22,0x3a8438,{DOUBLEWITHTWODWORDINTREE(0x16200000,0x00000000)}}, + {VT_exponent,22,0x3a8439,{DOUBLEWITHTWODWORDINTREE(0x16300000,0x00000000)}}, + {VT_exponent,22,0x3a843a,{DOUBLEWITHTWODWORDINTREE(0x16400000,0x00000000)}}, + {VT_exponent,22,0x3a843b,{DOUBLEWITHTWODWORDINTREE(0x16500000,0x00000000)}}, + {VT_exponent,22,0x3a843c,{DOUBLEWITHTWODWORDINTREE(0x16600000,0x00000000)}}, + {VT_exponent,22,0x3a843d,{DOUBLEWITHTWODWORDINTREE(0x16700000,0x00000000)}}, + {VT_exponent,22,0x3a843e,{DOUBLEWITHTWODWORDINTREE(0x16800000,0x00000000)}}, + {VT_exponent,22,0x3a843f,{DOUBLEWITHTWODWORDINTREE(0x16900000,0x00000000)}}, + {VT_exponent,22,0x3a8440,{DOUBLEWITHTWODWORDINTREE(0x16a00000,0x00000000)}}, + {VT_exponent,22,0x3a8441,{DOUBLEWITHTWODWORDINTREE(0x16b00000,0x00000000)}}, + {VT_exponent,22,0x3a8442,{DOUBLEWITHTWODWORDINTREE(0x16c00000,0x00000000)}}, + {VT_exponent,22,0x3a8443,{DOUBLEWITHTWODWORDINTREE(0x16d00000,0x00000000)}}, + {VT_exponent,22,0x3a8444,{DOUBLEWITHTWODWORDINTREE(0x16e00000,0x00000000)}}, + {VT_exponent,22,0x3a8445,{DOUBLEWITHTWODWORDINTREE(0x16f00000,0x00000000)}}, + {VT_exponent,22,0x3a8446,{DOUBLEWITHTWODWORDINTREE(0x17000000,0x00000000)}}, + {VT_exponent,22,0x3a8447,{DOUBLEWITHTWODWORDINTREE(0x17100000,0x00000000)}}, + {VT_exponent,22,0x3a8448,{DOUBLEWITHTWODWORDINTREE(0x17200000,0x00000000)}}, + {VT_exponent,22,0x3a8449,{DOUBLEWITHTWODWORDINTREE(0x17300000,0x00000000)}}, + {VT_exponent,22,0x3a844a,{DOUBLEWITHTWODWORDINTREE(0x17400000,0x00000000)}}, + {VT_exponent,22,0x3a844b,{DOUBLEWITHTWODWORDINTREE(0x17500000,0x00000000)}}, + {VT_exponent,22,0x3a844c,{DOUBLEWITHTWODWORDINTREE(0x17600000,0x00000000)}}, + {VT_exponent,22,0x3a844d,{DOUBLEWITHTWODWORDINTREE(0x17700000,0x00000000)}}, + {VT_exponent,22,0x3a844e,{DOUBLEWITHTWODWORDINTREE(0x17800000,0x00000000)}}, + {VT_exponent,22,0x3a844f,{DOUBLEWITHTWODWORDINTREE(0x17900000,0x00000000)}}, + {VT_exponent,22,0x3a8450,{DOUBLEWITHTWODWORDINTREE(0x17a00000,0x00000000)}}, + {VT_exponent,22,0x3a8451,{DOUBLEWITHTWODWORDINTREE(0x17b00000,0x00000000)}}, + {VT_exponent,22,0x3a8452,{DOUBLEWITHTWODWORDINTREE(0x17c00000,0x00000000)}}, + {VT_exponent,22,0x3a8453,{DOUBLEWITHTWODWORDINTREE(0x17d00000,0x00000000)}}, + {VT_exponent,22,0x3a8454,{DOUBLEWITHTWODWORDINTREE(0x17e00000,0x00000000)}}, + {VT_exponent,22,0x3a8455,{DOUBLEWITHTWODWORDINTREE(0x17f00000,0x00000000)}}, + {VT_exponent,22,0x3a8456,{DOUBLEWITHTWODWORDINTREE(0x18000000,0x00000000)}}, + {VT_exponent,22,0x3a8457,{DOUBLEWITHTWODWORDINTREE(0x18100000,0x00000000)}}, + {VT_exponent,22,0x3a8458,{DOUBLEWITHTWODWORDINTREE(0x18200000,0x00000000)}}, + {VT_exponent,22,0x3a8459,{DOUBLEWITHTWODWORDINTREE(0x18300000,0x00000000)}}, + {VT_exponent,22,0x3a845a,{DOUBLEWITHTWODWORDINTREE(0x18400000,0x00000000)}}, + {VT_exponent,22,0x3a845b,{DOUBLEWITHTWODWORDINTREE(0x18500000,0x00000000)}}, + {VT_exponent,22,0x3a845c,{DOUBLEWITHTWODWORDINTREE(0x18600000,0x00000000)}}, + {VT_exponent,22,0x3a845d,{DOUBLEWITHTWODWORDINTREE(0x18700000,0x00000000)}}, + {VT_exponent,22,0x3a845e,{DOUBLEWITHTWODWORDINTREE(0x18800000,0x00000000)}}, + {VT_exponent,22,0x3a845f,{DOUBLEWITHTWODWORDINTREE(0x18900000,0x00000000)}}, + {VT_exponent,22,0x3a8460,{DOUBLEWITHTWODWORDINTREE(0x18a00000,0x00000000)}}, + {VT_exponent,22,0x3a8461,{DOUBLEWITHTWODWORDINTREE(0x18b00000,0x00000000)}}, + {VT_exponent,22,0x3a8462,{DOUBLEWITHTWODWORDINTREE(0x18c00000,0x00000000)}}, + {VT_exponent,22,0x3a8463,{DOUBLEWITHTWODWORDINTREE(0x18d00000,0x00000000)}}, + {VT_exponent,22,0x3a8464,{DOUBLEWITHTWODWORDINTREE(0x18e00000,0x00000000)}}, + {VT_exponent,22,0x3a8465,{DOUBLEWITHTWODWORDINTREE(0x18f00000,0x00000000)}}, + {VT_exponent,22,0x3a8466,{DOUBLEWITHTWODWORDINTREE(0x19000000,0x00000000)}}, + {VT_exponent,22,0x3a8467,{DOUBLEWITHTWODWORDINTREE(0x19100000,0x00000000)}}, + {VT_exponent,22,0x3a8468,{DOUBLEWITHTWODWORDINTREE(0x19200000,0x00000000)}}, + {VT_exponent,22,0x3a8469,{DOUBLEWITHTWODWORDINTREE(0x19300000,0x00000000)}}, + {VT_exponent,22,0x3a846a,{DOUBLEWITHTWODWORDINTREE(0x19400000,0x00000000)}}, + {VT_exponent,22,0x3a846b,{DOUBLEWITHTWODWORDINTREE(0x19500000,0x00000000)}}, + {VT_exponent,22,0x3a846c,{DOUBLEWITHTWODWORDINTREE(0x19600000,0x00000000)}}, + {VT_exponent,22,0x3a846d,{DOUBLEWITHTWODWORDINTREE(0x19700000,0x00000000)}}, + {VT_exponent,22,0x3a846e,{DOUBLEWITHTWODWORDINTREE(0x19800000,0x00000000)}}, + {VT_exponent,22,0x3a846f,{DOUBLEWITHTWODWORDINTREE(0x19900000,0x00000000)}}, + {VT_exponent,22,0x3a8470,{DOUBLEWITHTWODWORDINTREE(0x19a00000,0x00000000)}}, + {VT_exponent,22,0x3a8471,{DOUBLEWITHTWODWORDINTREE(0x19b00000,0x00000000)}}, + {VT_exponent,22,0x3a8472,{DOUBLEWITHTWODWORDINTREE(0x19c00000,0x00000000)}}, + {VT_exponent,22,0x3a8473,{DOUBLEWITHTWODWORDINTREE(0x19d00000,0x00000000)}}, + {VT_exponent,22,0x3a8474,{DOUBLEWITHTWODWORDINTREE(0x19e00000,0x00000000)}}, + {VT_exponent,22,0x3a8475,{DOUBLEWITHTWODWORDINTREE(0x19f00000,0x00000000)}}, + {VT_exponent,22,0x3a8476,{DOUBLEWITHTWODWORDINTREE(0x1a000000,0x00000000)}}, + {VT_exponent,22,0x3a8477,{DOUBLEWITHTWODWORDINTREE(0x1a100000,0x00000000)}}, + {VT_exponent,22,0x3a8478,{DOUBLEWITHTWODWORDINTREE(0x1a200000,0x00000000)}}, + {VT_exponent,22,0x3a8479,{DOUBLEWITHTWODWORDINTREE(0x1a300000,0x00000000)}}, + {VT_exponent,22,0x3a847a,{DOUBLEWITHTWODWORDINTREE(0x1a400000,0x00000000)}}, + {VT_exponent,22,0x3a847b,{DOUBLEWITHTWODWORDINTREE(0x1a500000,0x00000000)}}, + {VT_exponent,22,0x3a847c,{DOUBLEWITHTWODWORDINTREE(0x1a600000,0x00000000)}}, + {VT_exponent,22,0x3a847d,{DOUBLEWITHTWODWORDINTREE(0x1a700000,0x00000000)}}, + {VT_exponent,22,0x3a847e,{DOUBLEWITHTWODWORDINTREE(0x1a800000,0x00000000)}}, + {VT_exponent,22,0x3a847f,{DOUBLEWITHTWODWORDINTREE(0x1a900000,0x00000000)}}, + {VT_exponent,22,0x3a8480,{DOUBLEWITHTWODWORDINTREE(0x1aa00000,0x00000000)}}, + {VT_exponent,22,0x3a8481,{DOUBLEWITHTWODWORDINTREE(0x1ab00000,0x00000000)}}, + {VT_exponent,22,0x3a8482,{DOUBLEWITHTWODWORDINTREE(0x1ac00000,0x00000000)}}, + {VT_exponent,22,0x3a8483,{DOUBLEWITHTWODWORDINTREE(0x1ad00000,0x00000000)}}, + {VT_exponent,22,0x3a8484,{DOUBLEWITHTWODWORDINTREE(0x1ae00000,0x00000000)}}, + {VT_exponent,22,0x3a8485,{DOUBLEWITHTWODWORDINTREE(0x1af00000,0x00000000)}}, + {VT_exponent,22,0x3a8486,{DOUBLEWITHTWODWORDINTREE(0x1b000000,0x00000000)}}, + {VT_exponent,22,0x3a8487,{DOUBLEWITHTWODWORDINTREE(0x1b100000,0x00000000)}}, + {VT_exponent,22,0x3a8488,{DOUBLEWITHTWODWORDINTREE(0x1b200000,0x00000000)}}, + {VT_exponent,22,0x3a8489,{DOUBLEWITHTWODWORDINTREE(0x1b300000,0x00000000)}}, + {VT_exponent,22,0x3a848a,{DOUBLEWITHTWODWORDINTREE(0x1b400000,0x00000000)}}, + {VT_exponent,22,0x3a848b,{DOUBLEWITHTWODWORDINTREE(0x1b500000,0x00000000)}}, + {VT_exponent,22,0x3a848c,{DOUBLEWITHTWODWORDINTREE(0x1b600000,0x00000000)}}, + {VT_exponent,22,0x3a848d,{DOUBLEWITHTWODWORDINTREE(0x1b700000,0x00000000)}}, + {VT_exponent,22,0x3a848e,{DOUBLEWITHTWODWORDINTREE(0x1b800000,0x00000000)}}, + {VT_exponent,22,0x3a848f,{DOUBLEWITHTWODWORDINTREE(0x1b900000,0x00000000)}}, + {VT_exponent,22,0x3a8490,{DOUBLEWITHTWODWORDINTREE(0x1ba00000,0x00000000)}}, + {VT_exponent,22,0x3a8491,{DOUBLEWITHTWODWORDINTREE(0x1bb00000,0x00000000)}}, + {VT_exponent,22,0x3a8492,{DOUBLEWITHTWODWORDINTREE(0x1bc00000,0x00000000)}}, + {VT_exponent,22,0x3a8493,{DOUBLEWITHTWODWORDINTREE(0x1bd00000,0x00000000)}}, + {VT_exponent,22,0x3a8494,{DOUBLEWITHTWODWORDINTREE(0x1be00000,0x00000000)}}, + {VT_exponent,22,0x3a8495,{DOUBLEWITHTWODWORDINTREE(0x1bf00000,0x00000000)}}, + {VT_exponent,22,0x3a8496,{DOUBLEWITHTWODWORDINTREE(0x1c000000,0x00000000)}}, + {VT_exponent,22,0x3a8497,{DOUBLEWITHTWODWORDINTREE(0x1c100000,0x00000000)}}, + {VT_exponent,22,0x3a8498,{DOUBLEWITHTWODWORDINTREE(0x1c200000,0x00000000)}}, + {VT_exponent,22,0x3a8499,{DOUBLEWITHTWODWORDINTREE(0x1c300000,0x00000000)}}, + {VT_exponent,22,0x3a849a,{DOUBLEWITHTWODWORDINTREE(0x1c400000,0x00000000)}}, + {VT_exponent,22,0x3a849b,{DOUBLEWITHTWODWORDINTREE(0x1c500000,0x00000000)}}, + {VT_exponent,22,0x3a849c,{DOUBLEWITHTWODWORDINTREE(0x1c600000,0x00000000)}}, + {VT_exponent,22,0x3a849d,{DOUBLEWITHTWODWORDINTREE(0x1c700000,0x00000000)}}, + {VT_exponent,22,0x3a849e,{DOUBLEWITHTWODWORDINTREE(0x1c800000,0x00000000)}}, + {VT_exponent,22,0x3a849f,{DOUBLEWITHTWODWORDINTREE(0x1c900000,0x00000000)}}, + {VT_exponent,22,0x3a84a0,{DOUBLEWITHTWODWORDINTREE(0x1ca00000,0x00000000)}}, + {VT_exponent,22,0x3a84a1,{DOUBLEWITHTWODWORDINTREE(0x1cb00000,0x00000000)}}, + {VT_exponent,22,0x3a84a2,{DOUBLEWITHTWODWORDINTREE(0x1cc00000,0x00000000)}}, + {VT_exponent,22,0x3a84a3,{DOUBLEWITHTWODWORDINTREE(0x1cd00000,0x00000000)}}, + {VT_exponent,22,0x3a84a4,{DOUBLEWITHTWODWORDINTREE(0x1ce00000,0x00000000)}}, + {VT_exponent,22,0x3a84a5,{DOUBLEWITHTWODWORDINTREE(0x1cf00000,0x00000000)}}, + {VT_exponent,22,0x3a84a6,{DOUBLEWITHTWODWORDINTREE(0x1d000000,0x00000000)}}, + {VT_exponent,22,0x3a84a7,{DOUBLEWITHTWODWORDINTREE(0x1d100000,0x00000000)}}, + {VT_exponent,22,0x3a84a8,{DOUBLEWITHTWODWORDINTREE(0x1d200000,0x00000000)}}, + {VT_exponent,22,0x3a84a9,{DOUBLEWITHTWODWORDINTREE(0x1d300000,0x00000000)}}, + {VT_exponent,22,0x3a84aa,{DOUBLEWITHTWODWORDINTREE(0x1d400000,0x00000000)}}, + {VT_exponent,22,0x3a84ab,{DOUBLEWITHTWODWORDINTREE(0x1d500000,0x00000000)}}, + {VT_exponent,22,0x3a84ac,{DOUBLEWITHTWODWORDINTREE(0x1d600000,0x00000000)}}, + {VT_exponent,22,0x3a84ad,{DOUBLEWITHTWODWORDINTREE(0x1d700000,0x00000000)}}, + {VT_exponent,22,0x3a84ae,{DOUBLEWITHTWODWORDINTREE(0x1d800000,0x00000000)}}, + {VT_exponent,22,0x3a84af,{DOUBLEWITHTWODWORDINTREE(0x1d900000,0x00000000)}}, + {VT_exponent,22,0x3a84b0,{DOUBLEWITHTWODWORDINTREE(0x1da00000,0x00000000)}}, + {VT_exponent,22,0x3a84b1,{DOUBLEWITHTWODWORDINTREE(0x1db00000,0x00000000)}}, + {VT_exponent,22,0x3a84b2,{DOUBLEWITHTWODWORDINTREE(0x1dc00000,0x00000000)}}, + {VT_exponent,22,0x3a84b3,{DOUBLEWITHTWODWORDINTREE(0x1dd00000,0x00000000)}}, + {VT_exponent,22,0x3a84b4,{DOUBLEWITHTWODWORDINTREE(0x1de00000,0x00000000)}}, + {VT_exponent,22,0x3a84b5,{DOUBLEWITHTWODWORDINTREE(0x1df00000,0x00000000)}}, + {VT_exponent,22,0x3a84b6,{DOUBLEWITHTWODWORDINTREE(0x1e000000,0x00000000)}}, + {VT_exponent,22,0x3a84b7,{DOUBLEWITHTWODWORDINTREE(0x1e100000,0x00000000)}}, + {VT_exponent,22,0x3a84b8,{DOUBLEWITHTWODWORDINTREE(0x1e200000,0x00000000)}}, + {VT_exponent,22,0x3a84b9,{DOUBLEWITHTWODWORDINTREE(0x1e300000,0x00000000)}}, + {VT_exponent,22,0x3a84ba,{DOUBLEWITHTWODWORDINTREE(0x1e400000,0x00000000)}}, + {VT_exponent,22,0x3a84bb,{DOUBLEWITHTWODWORDINTREE(0x1e500000,0x00000000)}}, + {VT_exponent,22,0x3a84bc,{DOUBLEWITHTWODWORDINTREE(0x1e600000,0x00000000)}}, + {VT_exponent,22,0x3a84bd,{DOUBLEWITHTWODWORDINTREE(0x1e700000,0x00000000)}}, + {VT_exponent,22,0x3a84be,{DOUBLEWITHTWODWORDINTREE(0x1e800000,0x00000000)}}, + {VT_exponent,22,0x3a84bf,{DOUBLEWITHTWODWORDINTREE(0x1e900000,0x00000000)}}, + {VT_exponent,22,0x3a84c0,{DOUBLEWITHTWODWORDINTREE(0x1ea00000,0x00000000)}}, + {VT_exponent,22,0x3a84c1,{DOUBLEWITHTWODWORDINTREE(0x1eb00000,0x00000000)}}, + {VT_exponent,22,0x3a84c2,{DOUBLEWITHTWODWORDINTREE(0x1ec00000,0x00000000)}}, + {VT_exponent,22,0x3a84c3,{DOUBLEWITHTWODWORDINTREE(0x1ed00000,0x00000000)}}, + {VT_exponent,22,0x3a84c4,{DOUBLEWITHTWODWORDINTREE(0x1ee00000,0x00000000)}}, + {VT_exponent,22,0x3a84c5,{DOUBLEWITHTWODWORDINTREE(0x1ef00000,0x00000000)}}, + {VT_exponent,22,0x3a84c6,{DOUBLEWITHTWODWORDINTREE(0x1f000000,0x00000000)}}, + {VT_exponent,22,0x3a84c7,{DOUBLEWITHTWODWORDINTREE(0x1f100000,0x00000000)}}, + {VT_exponent,22,0x3a84c8,{DOUBLEWITHTWODWORDINTREE(0x1f200000,0x00000000)}}, + {VT_exponent,22,0x3a84c9,{DOUBLEWITHTWODWORDINTREE(0x1f300000,0x00000000)}}, + {VT_exponent,22,0x3a84ca,{DOUBLEWITHTWODWORDINTREE(0x1f400000,0x00000000)}}, + {VT_exponent,22,0x3a84cb,{DOUBLEWITHTWODWORDINTREE(0x1f500000,0x00000000)}}, + {VT_exponent,22,0x3a84cc,{DOUBLEWITHTWODWORDINTREE(0x1f600000,0x00000000)}}, + {VT_exponent,22,0x3a84cd,{DOUBLEWITHTWODWORDINTREE(0x1f700000,0x00000000)}}, + {VT_exponent,22,0x3a84ce,{DOUBLEWITHTWODWORDINTREE(0x1f800000,0x00000000)}}, + {VT_exponent,22,0x3a84cf,{DOUBLEWITHTWODWORDINTREE(0x1f900000,0x00000000)}}, + {VT_exponent,22,0x3a84d0,{DOUBLEWITHTWODWORDINTREE(0x1fa00000,0x00000000)}}, + {VT_exponent,22,0x3a84d1,{DOUBLEWITHTWODWORDINTREE(0x1fb00000,0x00000000)}}, + {VT_exponent,22,0x3a84d2,{DOUBLEWITHTWODWORDINTREE(0x1fc00000,0x00000000)}}, + {VT_exponent,22,0x3a84d3,{DOUBLEWITHTWODWORDINTREE(0x1fd00000,0x00000000)}}, + {VT_exponent,22,0x3a84d4,{DOUBLEWITHTWODWORDINTREE(0x1fe00000,0x00000000)}}, + {VT_exponent,22,0x3a84d5,{DOUBLEWITHTWODWORDINTREE(0x1ff00000,0x00000000)}}, + {VT_exponent,22,0x3a84d6,{DOUBLEWITHTWODWORDINTREE(0x20000000,0x00000000)}}, + {VT_exponent,22,0x3a84d7,{DOUBLEWITHTWODWORDINTREE(0x20100000,0x00000000)}}, + {VT_exponent,22,0x3a84d8,{DOUBLEWITHTWODWORDINTREE(0x20200000,0x00000000)}}, + {VT_exponent,22,0x3a84d9,{DOUBLEWITHTWODWORDINTREE(0x20300000,0x00000000)}}, + {VT_exponent,22,0x3a84da,{DOUBLEWITHTWODWORDINTREE(0x20400000,0x00000000)}}, + {VT_exponent,22,0x3a84db,{DOUBLEWITHTWODWORDINTREE(0x20500000,0x00000000)}}, + {VT_exponent,22,0x3a84dc,{DOUBLEWITHTWODWORDINTREE(0x20600000,0x00000000)}}, + {VT_exponent,22,0x3a84dd,{DOUBLEWITHTWODWORDINTREE(0x20700000,0x00000000)}}, + {VT_exponent,22,0x3a84de,{DOUBLEWITHTWODWORDINTREE(0x20800000,0x00000000)}}, + {VT_exponent,22,0x3a84df,{DOUBLEWITHTWODWORDINTREE(0x20900000,0x00000000)}}, + {VT_exponent,22,0x3a84e0,{DOUBLEWITHTWODWORDINTREE(0x20a00000,0x00000000)}}, + {VT_exponent,22,0x3a84e1,{DOUBLEWITHTWODWORDINTREE(0x20b00000,0x00000000)}}, + {VT_exponent,22,0x3a84e2,{DOUBLEWITHTWODWORDINTREE(0x20c00000,0x00000000)}}, + {VT_exponent,22,0x3a84e3,{DOUBLEWITHTWODWORDINTREE(0x20d00000,0x00000000)}}, + {VT_exponent,22,0x3a84e4,{DOUBLEWITHTWODWORDINTREE(0x20e00000,0x00000000)}}, + {VT_exponent,22,0x3a84e5,{DOUBLEWITHTWODWORDINTREE(0x20f00000,0x00000000)}}, + {VT_exponent,22,0x3a84e6,{DOUBLEWITHTWODWORDINTREE(0x21000000,0x00000000)}}, + {VT_exponent,22,0x3a84e7,{DOUBLEWITHTWODWORDINTREE(0x21100000,0x00000000)}}, + {VT_exponent,22,0x3a84e8,{DOUBLEWITHTWODWORDINTREE(0x21200000,0x00000000)}}, + {VT_exponent,22,0x3a84e9,{DOUBLEWITHTWODWORDINTREE(0x21300000,0x00000000)}}, + {VT_exponent,22,0x3a84ea,{DOUBLEWITHTWODWORDINTREE(0x21400000,0x00000000)}}, + {VT_exponent,22,0x3a84eb,{DOUBLEWITHTWODWORDINTREE(0x21500000,0x00000000)}}, + {VT_exponent,22,0x3a84ec,{DOUBLEWITHTWODWORDINTREE(0x21600000,0x00000000)}}, + {VT_exponent,22,0x3a84ed,{DOUBLEWITHTWODWORDINTREE(0x21700000,0x00000000)}}, + {VT_exponent,22,0x3a84ee,{DOUBLEWITHTWODWORDINTREE(0x21800000,0x00000000)}}, + {VT_exponent,22,0x3a84ef,{DOUBLEWITHTWODWORDINTREE(0x21900000,0x00000000)}}, + {VT_exponent,22,0x3a84f0,{DOUBLEWITHTWODWORDINTREE(0x21a00000,0x00000000)}}, + {VT_exponent,22,0x3a84f1,{DOUBLEWITHTWODWORDINTREE(0x21b00000,0x00000000)}}, + {VT_exponent,22,0x3a84f2,{DOUBLEWITHTWODWORDINTREE(0x21c00000,0x00000000)}}, + {VT_exponent,22,0x3a84f3,{DOUBLEWITHTWODWORDINTREE(0x21d00000,0x00000000)}}, + {VT_exponent,22,0x3a84f4,{DOUBLEWITHTWODWORDINTREE(0x21e00000,0x00000000)}}, + {VT_exponent,22,0x3a84f5,{DOUBLEWITHTWODWORDINTREE(0x21f00000,0x00000000)}}, + {VT_exponent,22,0x3a84f6,{DOUBLEWITHTWODWORDINTREE(0x22000000,0x00000000)}}, + {VT_exponent,22,0x3a84f7,{DOUBLEWITHTWODWORDINTREE(0x22100000,0x00000000)}}, + {VT_exponent,22,0x3a84f8,{DOUBLEWITHTWODWORDINTREE(0x22200000,0x00000000)}}, + {VT_exponent,22,0x3a84f9,{DOUBLEWITHTWODWORDINTREE(0x22300000,0x00000000)}}, + {VT_exponent,22,0x3a84fa,{DOUBLEWITHTWODWORDINTREE(0x22400000,0x00000000)}}, + {VT_exponent,22,0x3a84fb,{DOUBLEWITHTWODWORDINTREE(0x22500000,0x00000000)}}, + {VT_exponent,22,0x3a84fc,{DOUBLEWITHTWODWORDINTREE(0x22600000,0x00000000)}}, + {VT_exponent,22,0x3a84fd,{DOUBLEWITHTWODWORDINTREE(0x22700000,0x00000000)}}, + {VT_exponent,22,0x3a84fe,{DOUBLEWITHTWODWORDINTREE(0x22800000,0x00000000)}}, + {VT_exponent,22,0x3a84ff,{DOUBLEWITHTWODWORDINTREE(0x22900000,0x00000000)}}, + {VT_exponent,22,0x3a8500,{DOUBLEWITHTWODWORDINTREE(0x22a00000,0x00000000)}}, + {VT_exponent,22,0x3a8501,{DOUBLEWITHTWODWORDINTREE(0x22b00000,0x00000000)}}, + {VT_exponent,22,0x3a8502,{DOUBLEWITHTWODWORDINTREE(0x22c00000,0x00000000)}}, + {VT_exponent,22,0x3a8503,{DOUBLEWITHTWODWORDINTREE(0x22d00000,0x00000000)}}, + {VT_exponent,22,0x3a8504,{DOUBLEWITHTWODWORDINTREE(0x22e00000,0x00000000)}}, + {VT_exponent,22,0x3a8505,{DOUBLEWITHTWODWORDINTREE(0x22f00000,0x00000000)}}, + {VT_exponent,22,0x3a8506,{DOUBLEWITHTWODWORDINTREE(0x23000000,0x00000000)}}, + {VT_exponent,22,0x3a8507,{DOUBLEWITHTWODWORDINTREE(0x23100000,0x00000000)}}, + {VT_exponent,22,0x3a8508,{DOUBLEWITHTWODWORDINTREE(0x23200000,0x00000000)}}, + {VT_exponent,22,0x3a8509,{DOUBLEWITHTWODWORDINTREE(0x23300000,0x00000000)}}, + {VT_exponent,22,0x3a850a,{DOUBLEWITHTWODWORDINTREE(0x23400000,0x00000000)}}, + {VT_exponent,22,0x3a850b,{DOUBLEWITHTWODWORDINTREE(0x23500000,0x00000000)}}, + {VT_exponent,22,0x3a850c,{DOUBLEWITHTWODWORDINTREE(0x23600000,0x00000000)}}, + {VT_exponent,22,0x3a850d,{DOUBLEWITHTWODWORDINTREE(0x23700000,0x00000000)}}, + {VT_exponent,22,0x3a850e,{DOUBLEWITHTWODWORDINTREE(0x23800000,0x00000000)}}, + {VT_exponent,22,0x3a850f,{DOUBLEWITHTWODWORDINTREE(0x23900000,0x00000000)}}, + {VT_exponent,22,0x3a8510,{DOUBLEWITHTWODWORDINTREE(0x23a00000,0x00000000)}}, + {VT_exponent,22,0x3a8511,{DOUBLEWITHTWODWORDINTREE(0x23b00000,0x00000000)}}, + {VT_exponent,22,0x3a8512,{DOUBLEWITHTWODWORDINTREE(0x23c00000,0x00000000)}}, + {VT_exponent,22,0x3a8513,{DOUBLEWITHTWODWORDINTREE(0x23d00000,0x00000000)}}, + {VT_exponent,22,0x3a8514,{DOUBLEWITHTWODWORDINTREE(0x23e00000,0x00000000)}}, + {VT_exponent,22,0x3a8515,{DOUBLEWITHTWODWORDINTREE(0x23f00000,0x00000000)}}, + {VT_exponent,22,0x3a8516,{DOUBLEWITHTWODWORDINTREE(0x24000000,0x00000000)}}, + {VT_exponent,22,0x3a8517,{DOUBLEWITHTWODWORDINTREE(0x24100000,0x00000000)}}, + {VT_exponent,22,0x3a8518,{DOUBLEWITHTWODWORDINTREE(0x24200000,0x00000000)}}, + {VT_exponent,22,0x3a8519,{DOUBLEWITHTWODWORDINTREE(0x24300000,0x00000000)}}, + {VT_exponent,22,0x3a851a,{DOUBLEWITHTWODWORDINTREE(0x24400000,0x00000000)}}, + {VT_exponent,22,0x3a851b,{DOUBLEWITHTWODWORDINTREE(0x24500000,0x00000000)}}, + {VT_exponent,22,0x3a851c,{DOUBLEWITHTWODWORDINTREE(0x24600000,0x00000000)}}, + {VT_exponent,22,0x3a851d,{DOUBLEWITHTWODWORDINTREE(0x24700000,0x00000000)}}, + {VT_exponent,22,0x3a851e,{DOUBLEWITHTWODWORDINTREE(0x24800000,0x00000000)}}, + {VT_exponent,22,0x3a851f,{DOUBLEWITHTWODWORDINTREE(0x24900000,0x00000000)}}, + {VT_exponent,22,0x3a8520,{DOUBLEWITHTWODWORDINTREE(0x24a00000,0x00000000)}}, + {VT_exponent,22,0x3a8521,{DOUBLEWITHTWODWORDINTREE(0x24b00000,0x00000000)}}, + {VT_exponent,22,0x3a8522,{DOUBLEWITHTWODWORDINTREE(0x24c00000,0x00000000)}}, + {VT_exponent,22,0x3a8523,{DOUBLEWITHTWODWORDINTREE(0x24d00000,0x00000000)}}, + {VT_exponent,22,0x3a8524,{DOUBLEWITHTWODWORDINTREE(0x24e00000,0x00000000)}}, + {VT_exponent,22,0x3a8525,{DOUBLEWITHTWODWORDINTREE(0x24f00000,0x00000000)}}, + {VT_exponent,22,0x3a8526,{DOUBLEWITHTWODWORDINTREE(0x25000000,0x00000000)}}, + {VT_exponent,22,0x3a8527,{DOUBLEWITHTWODWORDINTREE(0x25100000,0x00000000)}}, + {VT_exponent,22,0x3a8528,{DOUBLEWITHTWODWORDINTREE(0x25200000,0x00000000)}}, + {VT_exponent,22,0x3a8529,{DOUBLEWITHTWODWORDINTREE(0x25300000,0x00000000)}}, + {VT_exponent,22,0x3a852a,{DOUBLEWITHTWODWORDINTREE(0x25400000,0x00000000)}}, + {VT_exponent,22,0x3a852b,{DOUBLEWITHTWODWORDINTREE(0x25500000,0x00000000)}}, + {VT_exponent,22,0x3a852c,{DOUBLEWITHTWODWORDINTREE(0x25600000,0x00000000)}}, + {VT_exponent,22,0x3a852d,{DOUBLEWITHTWODWORDINTREE(0x25700000,0x00000000)}}, + {VT_exponent,22,0x3a852e,{DOUBLEWITHTWODWORDINTREE(0x25800000,0x00000000)}}, + {VT_exponent,22,0x3a852f,{DOUBLEWITHTWODWORDINTREE(0x25900000,0x00000000)}}, + {VT_exponent,22,0x3a8530,{DOUBLEWITHTWODWORDINTREE(0x25a00000,0x00000000)}}, + {VT_exponent,22,0x3a8531,{DOUBLEWITHTWODWORDINTREE(0x25b00000,0x00000000)}}, + {VT_exponent,22,0x3a8532,{DOUBLEWITHTWODWORDINTREE(0x25c00000,0x00000000)}}, + {VT_exponent,22,0x3a8533,{DOUBLEWITHTWODWORDINTREE(0x25d00000,0x00000000)}}, + {VT_exponent,22,0x3a8534,{DOUBLEWITHTWODWORDINTREE(0x25e00000,0x00000000)}}, + {VT_exponent,22,0x3a8535,{DOUBLEWITHTWODWORDINTREE(0x25f00000,0x00000000)}}, + {VT_exponent,22,0x3a8536,{DOUBLEWITHTWODWORDINTREE(0x26000000,0x00000000)}}, + {VT_exponent,22,0x3a8537,{DOUBLEWITHTWODWORDINTREE(0x26100000,0x00000000)}}, + {VT_exponent,22,0x3a8538,{DOUBLEWITHTWODWORDINTREE(0x26200000,0x00000000)}}, + {VT_exponent,22,0x3a8539,{DOUBLEWITHTWODWORDINTREE(0x26300000,0x00000000)}}, + {VT_exponent,22,0x3a853a,{DOUBLEWITHTWODWORDINTREE(0x26400000,0x00000000)}}, + {VT_exponent,22,0x3a853b,{DOUBLEWITHTWODWORDINTREE(0x26500000,0x00000000)}}, + {VT_exponent,22,0x3a853c,{DOUBLEWITHTWODWORDINTREE(0x26600000,0x00000000)}}, + {VT_exponent,22,0x3a853d,{DOUBLEWITHTWODWORDINTREE(0x26700000,0x00000000)}}, + {VT_exponent,22,0x3a853e,{DOUBLEWITHTWODWORDINTREE(0x26800000,0x00000000)}}, + {VT_exponent,22,0x3a853f,{DOUBLEWITHTWODWORDINTREE(0x26900000,0x00000000)}}, + {VT_exponent,22,0x3a8540,{DOUBLEWITHTWODWORDINTREE(0x26a00000,0x00000000)}}, + {VT_exponent,22,0x3a8541,{DOUBLEWITHTWODWORDINTREE(0x26b00000,0x00000000)}}, + {VT_exponent,22,0x3a8542,{DOUBLEWITHTWODWORDINTREE(0x26c00000,0x00000000)}}, + {VT_exponent,22,0x3a8543,{DOUBLEWITHTWODWORDINTREE(0x26d00000,0x00000000)}}, + {VT_exponent,22,0x3a8544,{DOUBLEWITHTWODWORDINTREE(0x26e00000,0x00000000)}}, + {VT_exponent,22,0x3a8545,{DOUBLEWITHTWODWORDINTREE(0x26f00000,0x00000000)}}, + {VT_exponent,22,0x3a8546,{DOUBLEWITHTWODWORDINTREE(0x27000000,0x00000000)}}, + {VT_exponent,22,0x3a8547,{DOUBLEWITHTWODWORDINTREE(0x27100000,0x00000000)}}, + {VT_exponent,22,0x3a8548,{DOUBLEWITHTWODWORDINTREE(0x27200000,0x00000000)}}, + {VT_exponent,22,0x3a8549,{DOUBLEWITHTWODWORDINTREE(0x27300000,0x00000000)}}, + {VT_exponent,22,0x3a854a,{DOUBLEWITHTWODWORDINTREE(0x27400000,0x00000000)}}, + {VT_exponent,22,0x3a854b,{DOUBLEWITHTWODWORDINTREE(0x27500000,0x00000000)}}, + {VT_exponent,22,0x3a854c,{DOUBLEWITHTWODWORDINTREE(0x27600000,0x00000000)}}, + {VT_exponent,22,0x3a854d,{DOUBLEWITHTWODWORDINTREE(0x27700000,0x00000000)}}, + {VT_exponent,22,0x3a854e,{DOUBLEWITHTWODWORDINTREE(0x27800000,0x00000000)}}, + {VT_exponent,22,0x3a854f,{DOUBLEWITHTWODWORDINTREE(0x27900000,0x00000000)}}, + {VT_exponent,22,0x3a8550,{DOUBLEWITHTWODWORDINTREE(0x27a00000,0x00000000)}}, + {VT_exponent,22,0x3a8551,{DOUBLEWITHTWODWORDINTREE(0x27b00000,0x00000000)}}, + {VT_exponent,22,0x3a8552,{DOUBLEWITHTWODWORDINTREE(0x27c00000,0x00000000)}}, + {VT_exponent,22,0x3a8553,{DOUBLEWITHTWODWORDINTREE(0x27d00000,0x00000000)}}, + {VT_exponent,22,0x3a8554,{DOUBLEWITHTWODWORDINTREE(0x27e00000,0x00000000)}}, + {VT_exponent,22,0x3a8555,{DOUBLEWITHTWODWORDINTREE(0x27f00000,0x00000000)}}, + {VT_exponent,22,0x3a8556,{DOUBLEWITHTWODWORDINTREE(0x28000000,0x00000000)}}, + {VT_exponent,22,0x3a8557,{DOUBLEWITHTWODWORDINTREE(0x28100000,0x00000000)}}, + {VT_exponent,22,0x3a8558,{DOUBLEWITHTWODWORDINTREE(0x28200000,0x00000000)}}, + {VT_exponent,22,0x3a8559,{DOUBLEWITHTWODWORDINTREE(0x28300000,0x00000000)}}, + {VT_exponent,22,0x3a855a,{DOUBLEWITHTWODWORDINTREE(0x28400000,0x00000000)}}, + {VT_exponent,22,0x3a855b,{DOUBLEWITHTWODWORDINTREE(0x28500000,0x00000000)}}, + {VT_exponent,22,0x3a855c,{DOUBLEWITHTWODWORDINTREE(0x28600000,0x00000000)}}, + {VT_exponent,22,0x3a855d,{DOUBLEWITHTWODWORDINTREE(0x28700000,0x00000000)}}, + {VT_exponent,22,0x3a855e,{DOUBLEWITHTWODWORDINTREE(0x28800000,0x00000000)}}, + {VT_exponent,22,0x3a855f,{DOUBLEWITHTWODWORDINTREE(0x28900000,0x00000000)}}, + {VT_exponent,22,0x3a8560,{DOUBLEWITHTWODWORDINTREE(0x28a00000,0x00000000)}}, + {VT_exponent,22,0x3a8561,{DOUBLEWITHTWODWORDINTREE(0x28b00000,0x00000000)}}, + {VT_exponent,22,0x3a8562,{DOUBLEWITHTWODWORDINTREE(0x28c00000,0x00000000)}}, + {VT_exponent,22,0x3a8563,{DOUBLEWITHTWODWORDINTREE(0x28d00000,0x00000000)}}, + {VT_exponent,22,0x3a8564,{DOUBLEWITHTWODWORDINTREE(0x28e00000,0x00000000)}}, + {VT_exponent,22,0x3a8565,{DOUBLEWITHTWODWORDINTREE(0x28f00000,0x00000000)}}, + {VT_exponent,22,0x3a8566,{DOUBLEWITHTWODWORDINTREE(0x29000000,0x00000000)}}, + {VT_exponent,22,0x3a8567,{DOUBLEWITHTWODWORDINTREE(0x29100000,0x00000000)}}, + {VT_exponent,22,0x3a8568,{DOUBLEWITHTWODWORDINTREE(0x29200000,0x00000000)}}, + {VT_exponent,22,0x3a8569,{DOUBLEWITHTWODWORDINTREE(0x29300000,0x00000000)}}, + {VT_exponent,22,0x3a856a,{DOUBLEWITHTWODWORDINTREE(0x29400000,0x00000000)}}, + {VT_exponent,22,0x3a856b,{DOUBLEWITHTWODWORDINTREE(0x29500000,0x00000000)}}, + {VT_exponent,22,0x3a856c,{DOUBLEWITHTWODWORDINTREE(0x29600000,0x00000000)}}, + {VT_exponent,22,0x3a856d,{DOUBLEWITHTWODWORDINTREE(0x29700000,0x00000000)}}, + {VT_exponent,22,0x3a856e,{DOUBLEWITHTWODWORDINTREE(0x29800000,0x00000000)}}, + {VT_exponent,22,0x3a856f,{DOUBLEWITHTWODWORDINTREE(0x29900000,0x00000000)}}, + {VT_exponent,22,0x3a8570,{DOUBLEWITHTWODWORDINTREE(0x29a00000,0x00000000)}}, + {VT_exponent,22,0x3a8571,{DOUBLEWITHTWODWORDINTREE(0x29b00000,0x00000000)}}, + {VT_exponent,22,0x3a8572,{DOUBLEWITHTWODWORDINTREE(0x29c00000,0x00000000)}}, + {VT_exponent,22,0x3a8573,{DOUBLEWITHTWODWORDINTREE(0x29d00000,0x00000000)}}, + {VT_exponent,22,0x3a8574,{DOUBLEWITHTWODWORDINTREE(0x29e00000,0x00000000)}}, + {VT_exponent,22,0x3a8575,{DOUBLEWITHTWODWORDINTREE(0x29f00000,0x00000000)}}, + {VT_exponent,22,0x3a8576,{DOUBLEWITHTWODWORDINTREE(0x2a000000,0x00000000)}}, + {VT_exponent,22,0x3a8577,{DOUBLEWITHTWODWORDINTREE(0x2a100000,0x00000000)}}, + {VT_exponent,22,0x3a8578,{DOUBLEWITHTWODWORDINTREE(0x2a200000,0x00000000)}}, + {VT_exponent,22,0x3a8579,{DOUBLEWITHTWODWORDINTREE(0x2a300000,0x00000000)}}, + {VT_exponent,22,0x3a857a,{DOUBLEWITHTWODWORDINTREE(0x2a400000,0x00000000)}}, + {VT_exponent,22,0x3a857b,{DOUBLEWITHTWODWORDINTREE(0x2a500000,0x00000000)}}, + {VT_exponent,22,0x3a857c,{DOUBLEWITHTWODWORDINTREE(0x2a600000,0x00000000)}}, + {VT_exponent,22,0x3a857d,{DOUBLEWITHTWODWORDINTREE(0x2a700000,0x00000000)}}, + {VT_exponent,22,0x3a857e,{DOUBLEWITHTWODWORDINTREE(0x2a800000,0x00000000)}}, + {VT_exponent,22,0x3a857f,{DOUBLEWITHTWODWORDINTREE(0x2a900000,0x00000000)}}, + {VT_exponent,22,0x3a8580,{DOUBLEWITHTWODWORDINTREE(0x2aa00000,0x00000000)}}, + {VT_exponent,22,0x3a8581,{DOUBLEWITHTWODWORDINTREE(0x2ab00000,0x00000000)}}, + {VT_exponent,22,0x3a8582,{DOUBLEWITHTWODWORDINTREE(0x2ac00000,0x00000000)}}, + {VT_exponent,22,0x3a8583,{DOUBLEWITHTWODWORDINTREE(0x2ad00000,0x00000000)}}, + {VT_exponent,22,0x3a8584,{DOUBLEWITHTWODWORDINTREE(0x2ae00000,0x00000000)}}, + {VT_exponent,22,0x3a8585,{DOUBLEWITHTWODWORDINTREE(0x2af00000,0x00000000)}}, + {VT_exponent,22,0x3a8586,{DOUBLEWITHTWODWORDINTREE(0x2b000000,0x00000000)}}, + {VT_exponent,22,0x3a8587,{DOUBLEWITHTWODWORDINTREE(0x2b100000,0x00000000)}}, + {VT_exponent,22,0x3a8588,{DOUBLEWITHTWODWORDINTREE(0x2b200000,0x00000000)}}, + {VT_exponent,22,0x3a8589,{DOUBLEWITHTWODWORDINTREE(0x2b300000,0x00000000)}}, + {VT_exponent,22,0x3a858a,{DOUBLEWITHTWODWORDINTREE(0x2b400000,0x00000000)}}, + {VT_exponent,22,0x3a858b,{DOUBLEWITHTWODWORDINTREE(0x2b500000,0x00000000)}}, + {VT_exponent,22,0x3a858c,{DOUBLEWITHTWODWORDINTREE(0x2b600000,0x00000000)}}, + {VT_exponent,22,0x3a858d,{DOUBLEWITHTWODWORDINTREE(0x2b700000,0x00000000)}}, + {VT_exponent,22,0x3a858e,{DOUBLEWITHTWODWORDINTREE(0x2b800000,0x00000000)}}, + {VT_exponent,22,0x3a858f,{DOUBLEWITHTWODWORDINTREE(0x2b900000,0x00000000)}}, + {VT_exponent,22,0x3a8590,{DOUBLEWITHTWODWORDINTREE(0x2ba00000,0x00000000)}}, + {VT_exponent,22,0x3a8591,{DOUBLEWITHTWODWORDINTREE(0x2bb00000,0x00000000)}}, + {VT_exponent,22,0x3a8592,{DOUBLEWITHTWODWORDINTREE(0x2bc00000,0x00000000)}}, + {VT_exponent,22,0x3a8593,{DOUBLEWITHTWODWORDINTREE(0x2bd00000,0x00000000)}}, + {VT_exponent,22,0x3a8594,{DOUBLEWITHTWODWORDINTREE(0x2be00000,0x00000000)}}, + {VT_exponent,22,0x3a8595,{DOUBLEWITHTWODWORDINTREE(0x2bf00000,0x00000000)}}, + {VT_exponent,22,0x3a8596,{DOUBLEWITHTWODWORDINTREE(0x2c000000,0x00000000)}}, + {VT_exponent,22,0x3a8597,{DOUBLEWITHTWODWORDINTREE(0x2c100000,0x00000000)}}, + {VT_exponent,22,0x3a8598,{DOUBLEWITHTWODWORDINTREE(0x2c200000,0x00000000)}}, + {VT_exponent,22,0x3a8599,{DOUBLEWITHTWODWORDINTREE(0x2c300000,0x00000000)}}, + {VT_exponent,22,0x3a859a,{DOUBLEWITHTWODWORDINTREE(0x2c400000,0x00000000)}}, + {VT_exponent,22,0x3a859b,{DOUBLEWITHTWODWORDINTREE(0x2c500000,0x00000000)}}, + {VT_exponent,22,0x3a859c,{DOUBLEWITHTWODWORDINTREE(0x2c600000,0x00000000)}}, + {VT_exponent,22,0x3a859d,{DOUBLEWITHTWODWORDINTREE(0x2c700000,0x00000000)}}, + {VT_exponent,22,0x3a859e,{DOUBLEWITHTWODWORDINTREE(0x2c800000,0x00000000)}}, + {VT_exponent,22,0x3a859f,{DOUBLEWITHTWODWORDINTREE(0x2c900000,0x00000000)}}, + {VT_exponent,22,0x3a85a0,{DOUBLEWITHTWODWORDINTREE(0x2ca00000,0x00000000)}}, + {VT_exponent,22,0x3a85a1,{DOUBLEWITHTWODWORDINTREE(0x2cb00000,0x00000000)}}, + {VT_exponent,22,0x3a85a2,{DOUBLEWITHTWODWORDINTREE(0x2cc00000,0x00000000)}}, + {VT_exponent,22,0x3a85a3,{DOUBLEWITHTWODWORDINTREE(0x2cd00000,0x00000000)}}, + {VT_exponent,22,0x3a85a4,{DOUBLEWITHTWODWORDINTREE(0x2ce00000,0x00000000)}}, + {VT_exponent,22,0x3a85a5,{DOUBLEWITHTWODWORDINTREE(0x2cf00000,0x00000000)}}, + {VT_exponent,22,0x3a85a6,{DOUBLEWITHTWODWORDINTREE(0x2d000000,0x00000000)}}, + {VT_exponent,22,0x3a85a7,{DOUBLEWITHTWODWORDINTREE(0x2d100000,0x00000000)}}, + {VT_exponent,22,0x3a85a8,{DOUBLEWITHTWODWORDINTREE(0x2d200000,0x00000000)}}, + {VT_exponent,22,0x3a85a9,{DOUBLEWITHTWODWORDINTREE(0x2d300000,0x00000000)}}, + {VT_exponent,22,0x3a85aa,{DOUBLEWITHTWODWORDINTREE(0x2d400000,0x00000000)}}, + {VT_exponent,22,0x3a85ab,{DOUBLEWITHTWODWORDINTREE(0x2d500000,0x00000000)}}, + {VT_exponent,22,0x3a85ac,{DOUBLEWITHTWODWORDINTREE(0x2d600000,0x00000000)}}, + {VT_exponent,22,0x3a85ad,{DOUBLEWITHTWODWORDINTREE(0x2d700000,0x00000000)}}, + {VT_exponent,22,0x3a85ae,{DOUBLEWITHTWODWORDINTREE(0x2d800000,0x00000000)}}, + {VT_exponent,22,0x3a85af,{DOUBLEWITHTWODWORDINTREE(0x2d900000,0x00000000)}}, + {VT_exponent,22,0x3a85b0,{DOUBLEWITHTWODWORDINTREE(0x2da00000,0x00000000)}}, + {VT_exponent,22,0x3a85b1,{DOUBLEWITHTWODWORDINTREE(0x2db00000,0x00000000)}}, + {VT_exponent,22,0x3a85b2,{DOUBLEWITHTWODWORDINTREE(0x2dc00000,0x00000000)}}, + {VT_exponent,22,0x3a85b3,{DOUBLEWITHTWODWORDINTREE(0x2dd00000,0x00000000)}}, + {VT_exponent,22,0x3a85b4,{DOUBLEWITHTWODWORDINTREE(0x2de00000,0x00000000)}}, + {VT_exponent,22,0x3a85b5,{DOUBLEWITHTWODWORDINTREE(0x2df00000,0x00000000)}}, + {VT_exponent,22,0x3a85b6,{DOUBLEWITHTWODWORDINTREE(0x2e000000,0x00000000)}}, + {VT_exponent,22,0x3a85b7,{DOUBLEWITHTWODWORDINTREE(0x2e100000,0x00000000)}}, + {VT_exponent,22,0x3a85b8,{DOUBLEWITHTWODWORDINTREE(0x2e200000,0x00000000)}}, + {VT_exponent,22,0x3a85b9,{DOUBLEWITHTWODWORDINTREE(0x2e300000,0x00000000)}}, + {VT_exponent,22,0x3a85ba,{DOUBLEWITHTWODWORDINTREE(0x2e400000,0x00000000)}}, + {VT_exponent,22,0x3a85bb,{DOUBLEWITHTWODWORDINTREE(0x2e500000,0x00000000)}}, + {VT_exponent,22,0x3a85bc,{DOUBLEWITHTWODWORDINTREE(0x2e600000,0x00000000)}}, + {VT_exponent,22,0x3a85bd,{DOUBLEWITHTWODWORDINTREE(0x2e700000,0x00000000)}}, + {VT_exponent,22,0x3a85be,{DOUBLEWITHTWODWORDINTREE(0x2e800000,0x00000000)}}, + {VT_exponent,22,0x3a85bf,{DOUBLEWITHTWODWORDINTREE(0x2e900000,0x00000000)}}, + {VT_exponent,22,0x3a85c0,{DOUBLEWITHTWODWORDINTREE(0x2ea00000,0x00000000)}}, + {VT_exponent,22,0x3a85c1,{DOUBLEWITHTWODWORDINTREE(0x2eb00000,0x00000000)}}, + {VT_exponent,22,0x3a85c2,{DOUBLEWITHTWODWORDINTREE(0x2ec00000,0x00000000)}}, + {VT_exponent,22,0x3a85c3,{DOUBLEWITHTWODWORDINTREE(0x2ed00000,0x00000000)}}, + {VT_exponent,22,0x3a85c4,{DOUBLEWITHTWODWORDINTREE(0x2ee00000,0x00000000)}}, + {VT_exponent,22,0x3a85c5,{DOUBLEWITHTWODWORDINTREE(0x2ef00000,0x00000000)}}, + {VT_exponent,22,0x3a85c6,{DOUBLEWITHTWODWORDINTREE(0x2f000000,0x00000000)}}, + {VT_exponent,22,0x3a85c7,{DOUBLEWITHTWODWORDINTREE(0x2f100000,0x00000000)}}, + {VT_exponent,22,0x3a85c8,{DOUBLEWITHTWODWORDINTREE(0x2f200000,0x00000000)}}, + {VT_exponent,22,0x3a85c9,{DOUBLEWITHTWODWORDINTREE(0x2f300000,0x00000000)}}, + {VT_exponent,22,0x3a85ca,{DOUBLEWITHTWODWORDINTREE(0x2f400000,0x00000000)}}, + {VT_exponent,22,0x3a85cb,{DOUBLEWITHTWODWORDINTREE(0x2f500000,0x00000000)}}, + {VT_exponent,22,0x3a85cc,{DOUBLEWITHTWODWORDINTREE(0x2f600000,0x00000000)}}, + {VT_exponent,22,0x3a85cd,{DOUBLEWITHTWODWORDINTREE(0x2f700000,0x00000000)}}, + {VT_exponent,22,0x3a85ce,{DOUBLEWITHTWODWORDINTREE(0x2f800000,0x00000000)}}, + {VT_exponent,22,0x3a85cf,{DOUBLEWITHTWODWORDINTREE(0x2f900000,0x00000000)}}, + {VT_exponent,22,0x3a85d0,{DOUBLEWITHTWODWORDINTREE(0x2fa00000,0x00000000)}}, + {VT_exponent,22,0x3a85d1,{DOUBLEWITHTWODWORDINTREE(0x2fb00000,0x00000000)}}, + {VT_exponent,22,0x3a85d2,{DOUBLEWITHTWODWORDINTREE(0x2fc00000,0x00000000)}}, + {VT_exponent,22,0x3a85d3,{DOUBLEWITHTWODWORDINTREE(0x2fd00000,0x00000000)}}, + {VT_exponent,22,0x3a85d4,{DOUBLEWITHTWODWORDINTREE(0x2fe00000,0x00000000)}}, + {VT_exponent,22,0x3a85d5,{DOUBLEWITHTWODWORDINTREE(0x2ff00000,0x00000000)}}, + {VT_exponent,22,0x3a85d6,{DOUBLEWITHTWODWORDINTREE(0x30000000,0x00000000)}}, + {VT_exponent,22,0x3a85d7,{DOUBLEWITHTWODWORDINTREE(0x30100000,0x00000000)}}, + {VT_exponent,22,0x3a85d8,{DOUBLEWITHTWODWORDINTREE(0x30200000,0x00000000)}}, + {VT_exponent,22,0x3a85d9,{DOUBLEWITHTWODWORDINTREE(0x30300000,0x00000000)}}, + {VT_exponent,22,0x3a85da,{DOUBLEWITHTWODWORDINTREE(0x30400000,0x00000000)}}, + {VT_exponent,22,0x3a85db,{DOUBLEWITHTWODWORDINTREE(0x30500000,0x00000000)}}, + {VT_exponent,22,0x3a85dc,{DOUBLEWITHTWODWORDINTREE(0x30600000,0x00000000)}}, + {VT_exponent,22,0x3a85dd,{DOUBLEWITHTWODWORDINTREE(0x30700000,0x00000000)}}, + {VT_exponent,22,0x3a85de,{DOUBLEWITHTWODWORDINTREE(0x30800000,0x00000000)}}, + {VT_exponent,22,0x3a85df,{DOUBLEWITHTWODWORDINTREE(0x30900000,0x00000000)}}, + {VT_exponent,22,0x3a85e0,{DOUBLEWITHTWODWORDINTREE(0x30a00000,0x00000000)}}, + {VT_exponent,22,0x3a85e1,{DOUBLEWITHTWODWORDINTREE(0x30b00000,0x00000000)}}, + {VT_exponent,22,0x3a85e2,{DOUBLEWITHTWODWORDINTREE(0x30c00000,0x00000000)}}, + {VT_exponent,22,0x3a85e3,{DOUBLEWITHTWODWORDINTREE(0x30d00000,0x00000000)}}, + {VT_exponent,22,0x3a85e4,{DOUBLEWITHTWODWORDINTREE(0x30e00000,0x00000000)}}, + {VT_exponent,22,0x3a85e5,{DOUBLEWITHTWODWORDINTREE(0x30f00000,0x00000000)}}, + {VT_exponent,22,0x3a85e6,{DOUBLEWITHTWODWORDINTREE(0x31000000,0x00000000)}}, + {VT_exponent,22,0x3a85e7,{DOUBLEWITHTWODWORDINTREE(0x31100000,0x00000000)}}, + {VT_exponent,22,0x3a85e8,{DOUBLEWITHTWODWORDINTREE(0x31200000,0x00000000)}}, + {VT_exponent,22,0x3a85e9,{DOUBLEWITHTWODWORDINTREE(0x31300000,0x00000000)}}, + {VT_exponent,22,0x3a85ea,{DOUBLEWITHTWODWORDINTREE(0x31400000,0x00000000)}}, + {VT_exponent,22,0x3a85eb,{DOUBLEWITHTWODWORDINTREE(0x31500000,0x00000000)}}, + {VT_exponent,22,0x3a85ec,{DOUBLEWITHTWODWORDINTREE(0x31600000,0x00000000)}}, + {VT_exponent,22,0x3a85ed,{DOUBLEWITHTWODWORDINTREE(0x31700000,0x00000000)}}, + {VT_exponent,22,0x3a85ee,{DOUBLEWITHTWODWORDINTREE(0x31800000,0x00000000)}}, + {VT_exponent,22,0x3a85ef,{DOUBLEWITHTWODWORDINTREE(0x31900000,0x00000000)}}, + {VT_exponent,22,0x3a85f0,{DOUBLEWITHTWODWORDINTREE(0x31a00000,0x00000000)}}, + {VT_exponent,22,0x3a85f1,{DOUBLEWITHTWODWORDINTREE(0x31b00000,0x00000000)}}, + {VT_exponent,22,0x3a85f2,{DOUBLEWITHTWODWORDINTREE(0x31c00000,0x00000000)}}, + {VT_exponent,22,0x3a85f3,{DOUBLEWITHTWODWORDINTREE(0x31d00000,0x00000000)}}, + {VT_exponent,22,0x3a85f4,{DOUBLEWITHTWODWORDINTREE(0x31e00000,0x00000000)}}, + {VT_exponent,22,0x3a85f5,{DOUBLEWITHTWODWORDINTREE(0x31f00000,0x00000000)}}, + {VT_exponent,22,0x3a85f6,{DOUBLEWITHTWODWORDINTREE(0x32000000,0x00000000)}}, + {VT_exponent,22,0x3a85f7,{DOUBLEWITHTWODWORDINTREE(0x32100000,0x00000000)}}, + {VT_exponent,22,0x3a85f8,{DOUBLEWITHTWODWORDINTREE(0x32200000,0x00000000)}}, + {VT_exponent,22,0x3a85f9,{DOUBLEWITHTWODWORDINTREE(0x32300000,0x00000000)}}, + {VT_exponent,22,0x3a85fa,{DOUBLEWITHTWODWORDINTREE(0x32400000,0x00000000)}}, + {VT_exponent,22,0x3a85fb,{DOUBLEWITHTWODWORDINTREE(0x32500000,0x00000000)}}, + {VT_exponent,22,0x3a85fc,{DOUBLEWITHTWODWORDINTREE(0x32600000,0x00000000)}}, + {VT_exponent,22,0x3a85fd,{DOUBLEWITHTWODWORDINTREE(0x32700000,0x00000000)}}, + {VT_exponent,22,0x3a85fe,{DOUBLEWITHTWODWORDINTREE(0x32800000,0x00000000)}}, + {VT_exponent,22,0x3a85ff,{DOUBLEWITHTWODWORDINTREE(0x32900000,0x00000000)}}, + {VT_exponent,22,0x3a8600,{DOUBLEWITHTWODWORDINTREE(0x32a00000,0x00000000)}}, + {VT_exponent,22,0x3a8601,{DOUBLEWITHTWODWORDINTREE(0x32b00000,0x00000000)}}, + {VT_exponent,22,0x3a8602,{DOUBLEWITHTWODWORDINTREE(0x32c00000,0x00000000)}}, + {VT_exponent,22,0x3a8603,{DOUBLEWITHTWODWORDINTREE(0x32d00000,0x00000000)}}, + {VT_exponent,22,0x3a8604,{DOUBLEWITHTWODWORDINTREE(0x32e00000,0x00000000)}}, + {VT_exponent,22,0x3a8605,{DOUBLEWITHTWODWORDINTREE(0x32f00000,0x00000000)}}, + {VT_exponent,22,0x3a8606,{DOUBLEWITHTWODWORDINTREE(0x33000000,0x00000000)}}, + {VT_exponent,22,0x3a8607,{DOUBLEWITHTWODWORDINTREE(0x33100000,0x00000000)}}, + {VT_exponent,22,0x3a8608,{DOUBLEWITHTWODWORDINTREE(0x33200000,0x00000000)}}, + {VT_exponent,22,0x3a8609,{DOUBLEWITHTWODWORDINTREE(0x33300000,0x00000000)}}, + {VT_exponent,22,0x3a860a,{DOUBLEWITHTWODWORDINTREE(0x33400000,0x00000000)}}, + {VT_exponent,22,0x3a860b,{DOUBLEWITHTWODWORDINTREE(0x33500000,0x00000000)}}, + {VT_exponent,22,0x3a860c,{DOUBLEWITHTWODWORDINTREE(0x33600000,0x00000000)}}, + {VT_exponent,22,0x3a860d,{DOUBLEWITHTWODWORDINTREE(0x33700000,0x00000000)}}, + {VT_exponent,22,0x3a860e,{DOUBLEWITHTWODWORDINTREE(0x33800000,0x00000000)}}, + {VT_exponent,22,0x3a860f,{DOUBLEWITHTWODWORDINTREE(0x33900000,0x00000000)}}, + {VT_exponent,22,0x3a8610,{DOUBLEWITHTWODWORDINTREE(0x33a00000,0x00000000)}}, + {VT_exponent,22,0x3a8611,{DOUBLEWITHTWODWORDINTREE(0x33b00000,0x00000000)}}, + {VT_exponent,22,0x3a8612,{DOUBLEWITHTWODWORDINTREE(0x33c00000,0x00000000)}}, + {VT_exponent,22,0x3a8613,{DOUBLEWITHTWODWORDINTREE(0x33d00000,0x00000000)}}, + {VT_exponent,22,0x3a8614,{DOUBLEWITHTWODWORDINTREE(0x33e00000,0x00000000)}}, + {VT_exponent,22,0x3a8615,{DOUBLEWITHTWODWORDINTREE(0x33f00000,0x00000000)}}, + {VT_exponent,22,0x3a8616,{DOUBLEWITHTWODWORDINTREE(0x34000000,0x00000000)}}, + {VT_exponent,22,0x3a8617,{DOUBLEWITHTWODWORDINTREE(0x34100000,0x00000000)}}, + {VT_exponent,22,0x3a8618,{DOUBLEWITHTWODWORDINTREE(0x34200000,0x00000000)}}, + {VT_exponent,22,0x3a8619,{DOUBLEWITHTWODWORDINTREE(0x34300000,0x00000000)}}, + {VT_exponent,22,0x3a861a,{DOUBLEWITHTWODWORDINTREE(0x34400000,0x00000000)}}, + {VT_exponent,22,0x3a861b,{DOUBLEWITHTWODWORDINTREE(0x34500000,0x00000000)}}, + {VT_exponent,22,0x3a861c,{DOUBLEWITHTWODWORDINTREE(0x34600000,0x00000000)}}, + {VT_exponent,22,0x3a861d,{DOUBLEWITHTWODWORDINTREE(0x34700000,0x00000000)}}, + {VT_exponent,22,0x3a861e,{DOUBLEWITHTWODWORDINTREE(0x34800000,0x00000000)}}, + {VT_exponent,22,0x3a861f,{DOUBLEWITHTWODWORDINTREE(0x34900000,0x00000000)}}, + {VT_exponent,22,0x3a8620,{DOUBLEWITHTWODWORDINTREE(0x34a00000,0x00000000)}}, + {VT_exponent,22,0x3a8621,{DOUBLEWITHTWODWORDINTREE(0x34b00000,0x00000000)}}, + {VT_exponent,22,0x3a8622,{DOUBLEWITHTWODWORDINTREE(0x34c00000,0x00000000)}}, + {VT_exponent,22,0x3a8623,{DOUBLEWITHTWODWORDINTREE(0x34d00000,0x00000000)}}, + {VT_exponent,22,0x3a8624,{DOUBLEWITHTWODWORDINTREE(0x34e00000,0x00000000)}}, + {VT_exponent,22,0x3a8625,{DOUBLEWITHTWODWORDINTREE(0x34f00000,0x00000000)}}, + {VT_exponent,22,0x3a8626,{DOUBLEWITHTWODWORDINTREE(0x35000000,0x00000000)}}, + {VT_exponent,22,0x3a8627,{DOUBLEWITHTWODWORDINTREE(0x35100000,0x00000000)}}, + {VT_exponent,22,0x3a8628,{DOUBLEWITHTWODWORDINTREE(0x35200000,0x00000000)}}, + {VT_exponent,22,0x3a8629,{DOUBLEWITHTWODWORDINTREE(0x35300000,0x00000000)}}, + {VT_exponent,18,0xf787,{DOUBLEWITHTWODWORDINTREE(0x35400000,0x00000000)}}, + {VT_exponent,18,0xd1d4,{DOUBLEWITHTWODWORDINTREE(0x35500000,0x00000000)}}, + {VT_exponent,19,0x77f9f,{DOUBLEWITHTWODWORDINTREE(0x35600000,0x00000000)}}, + {VT_exponent,18,0x3b8fb,{DOUBLEWITHTWODWORDINTREE(0x35700000,0x00000000)}}, + {VT_exponent,19,0x1ef1a,{DOUBLEWITHTWODWORDINTREE(0x35800000,0x00000000)}}, + {VT_exponent,21,0x1d4315,{DOUBLEWITHTWODWORDINTREE(0x35900000,0x00000000)}}, + {VT_exponent,16,0x3de2,{DOUBLEWITHTWODWORDINTREE(0x35a00000,0x00000000)}}, + {VT_exponent,22,0x3a862c,{DOUBLEWITHTWODWORDINTREE(0x35b00000,0x00000000)}}, + {VT_exponent,22,0x3a862d,{DOUBLEWITHTWODWORDINTREE(0x35c00000,0x00000000)}}, + {VT_exponent,22,0x3a862e,{DOUBLEWITHTWODWORDINTREE(0x35d00000,0x00000000)}}, + {VT_exponent,22,0x3a862f,{DOUBLEWITHTWODWORDINTREE(0x35e00000,0x00000000)}}, + {VT_exponent,22,0x3a8630,{DOUBLEWITHTWODWORDINTREE(0x35f00000,0x00000000)}}, + {VT_exponent,22,0x3a8631,{DOUBLEWITHTWODWORDINTREE(0x36000000,0x00000000)}}, + {VT_exponent,22,0x3a8632,{DOUBLEWITHTWODWORDINTREE(0x36100000,0x00000000)}}, + {VT_exponent,22,0x3a8633,{DOUBLEWITHTWODWORDINTREE(0x36200000,0x00000000)}}, + {VT_exponent,22,0x3a8634,{DOUBLEWITHTWODWORDINTREE(0x36300000,0x00000000)}}, + {VT_exponent,22,0x3a8635,{DOUBLEWITHTWODWORDINTREE(0x36400000,0x00000000)}}, + {VT_exponent,22,0x3a8636,{DOUBLEWITHTWODWORDINTREE(0x36500000,0x00000000)}}, + {VT_exponent,22,0x3a8637,{DOUBLEWITHTWODWORDINTREE(0x36600000,0x00000000)}}, + {VT_exponent,22,0x3a8638,{DOUBLEWITHTWODWORDINTREE(0x36700000,0x00000000)}}, + {VT_exponent,21,0x1d431d,{DOUBLEWITHTWODWORDINTREE(0x36800000,0x00000000)}}, + {VT_exponent,22,0x3a8639,{DOUBLEWITHTWODWORDINTREE(0x36900000,0x00000000)}}, + {VT_exponent,22,0x3a863c,{DOUBLEWITHTWODWORDINTREE(0x36a00000,0x00000000)}}, + {VT_exponent,16,0x3de0,{DOUBLEWITHTWODWORDINTREE(0x36b00000,0x00000000)}}, + {VT_exponent,18,0x3a95e,{DOUBLEWITHTWODWORDINTREE(0x36c00000,0x00000000)}}, + {VT_exponent,21,0x1d431f,{DOUBLEWITHTWODWORDINTREE(0x36d00000,0x00000000)}}, + {VT_exponent,22,0x3a863d,{DOUBLEWITHTWODWORDINTREE(0x36e00000,0x00000000)}}, + {VT_exponent,22,0x3a8640,{DOUBLEWITHTWODWORDINTREE(0x36f00000,0x00000000)}}, + {VT_exponent,20,0x34749,{DOUBLEWITHTWODWORDINTREE(0x37000000,0x00000000)}}, + {VT_exponent,20,0x3474d,{DOUBLEWITHTWODWORDINTREE(0x37100000,0x00000000)}}, + {VT_exponent,22,0x3a8641,{DOUBLEWITHTWODWORDINTREE(0x37200000,0x00000000)}}, + {VT_exponent,22,0x3a8642,{DOUBLEWITHTWODWORDINTREE(0x37300000,0x00000000)}}, + {VT_exponent,22,0x3a8643,{DOUBLEWITHTWODWORDINTREE(0x37400000,0x00000000)}}, + {VT_exponent,22,0x3a8644,{DOUBLEWITHTWODWORDINTREE(0x37500000,0x00000000)}}, + {VT_exponent,22,0x3a8645,{DOUBLEWITHTWODWORDINTREE(0x37600000,0x00000000)}}, + {VT_exponent,22,0x3a8646,{DOUBLEWITHTWODWORDINTREE(0x37700000,0x00000000)}}, + {VT_exponent,22,0x3a8647,{DOUBLEWITHTWODWORDINTREE(0x37800000,0x00000000)}}, + {VT_exponent,22,0x3a8648,{DOUBLEWITHTWODWORDINTREE(0x37900000,0x00000000)}}, + {VT_exponent,22,0x3a8649,{DOUBLEWITHTWODWORDINTREE(0x37a00000,0x00000000)}}, + {VT_exponent,22,0x3a864a,{DOUBLEWITHTWODWORDINTREE(0x37b00000,0x00000000)}}, + {VT_exponent,22,0x3a864b,{DOUBLEWITHTWODWORDINTREE(0x37c00000,0x00000000)}}, + {VT_exponent,22,0x3a864c,{DOUBLEWITHTWODWORDINTREE(0x37d00000,0x00000000)}}, + {VT_exponent,22,0x3a864d,{DOUBLEWITHTWODWORDINTREE(0x37e00000,0x00000000)}}, + {VT_exponent,22,0x3a864e,{DOUBLEWITHTWODWORDINTREE(0x37f00000,0x00000000)}}, + {VT_exponent,22,0x3a864f,{DOUBLEWITHTWODWORDINTREE(0x38000000,0x00000000)}}, + {VT_exponent,22,0x3a8650,{DOUBLEWITHTWODWORDINTREE(0x38100000,0x00000000)}}, + {VT_exponent,22,0x3a8651,{DOUBLEWITHTWODWORDINTREE(0x38200000,0x00000000)}}, + {VT_exponent,22,0x3a8652,{DOUBLEWITHTWODWORDINTREE(0x38300000,0x00000000)}}, + {VT_exponent,22,0x3a8653,{DOUBLEWITHTWODWORDINTREE(0x38400000,0x00000000)}}, + {VT_exponent,22,0x3a8654,{DOUBLEWITHTWODWORDINTREE(0x38500000,0x00000000)}}, + {VT_exponent,22,0x3a8655,{DOUBLEWITHTWODWORDINTREE(0x38600000,0x00000000)}}, + {VT_exponent,22,0x3a8656,{DOUBLEWITHTWODWORDINTREE(0x38700000,0x00000000)}}, + {VT_exponent,22,0x3a8657,{DOUBLEWITHTWODWORDINTREE(0x38800000,0x00000000)}}, + {VT_exponent,22,0x3a8658,{DOUBLEWITHTWODWORDINTREE(0x38900000,0x00000000)}}, + {VT_exponent,22,0x3a8659,{DOUBLEWITHTWODWORDINTREE(0x38a00000,0x00000000)}}, + {VT_exponent,22,0x3a865a,{DOUBLEWITHTWODWORDINTREE(0x38b00000,0x00000000)}}, + {VT_exponent,22,0x3a865b,{DOUBLEWITHTWODWORDINTREE(0x38c00000,0x00000000)}}, + {VT_exponent,22,0x3a865c,{DOUBLEWITHTWODWORDINTREE(0x38d00000,0x00000000)}}, + {VT_exponent,22,0x3a865d,{DOUBLEWITHTWODWORDINTREE(0x38e00000,0x00000000)}}, + {VT_exponent,21,0x1d432f,{DOUBLEWITHTWODWORDINTREE(0x38f00000,0x00000000)}}, + {VT_exponent,22,0x3a8660,{DOUBLEWITHTWODWORDINTREE(0x39000000,0x00000000)}}, + {VT_exponent,22,0x3a8661,{DOUBLEWITHTWODWORDINTREE(0x39100000,0x00000000)}}, + {VT_exponent,22,0x3a8662,{DOUBLEWITHTWODWORDINTREE(0x39200000,0x00000000)}}, + {VT_exponent,21,0x1d4332,{DOUBLEWITHTWODWORDINTREE(0x39300000,0x00000000)}}, + {VT_exponent,18,0xd1d5,{DOUBLEWITHTWODWORDINTREE(0x39400000,0x00000000)}}, + {VT_exponent,18,0x3bfda,{DOUBLEWITHTWODWORDINTREE(0x39500000,0x00000000)}}, + {VT_exponent,15,0x7528,{DOUBLEWITHTWODWORDINTREE(0x39600000,0x00000000)}}, + {VT_exponent,15,0x7529,{DOUBLEWITHTWODWORDINTREE(0x39700000,0x00000000)}}, + {VT_exponent,18,0x3a95f,{DOUBLEWITHTWODWORDINTREE(0x39800000,0x00000000)}}, + {VT_exponent,17,0x1d434,{DOUBLEWITHTWODWORDINTREE(0x39900000,0x00000000)}}, + {VT_exponent,19,0x750cd,{DOUBLEWITHTWODWORDINTREE(0x39a00000,0x00000000)}}, + {VT_exponent,18,0x3a867,{DOUBLEWITHTWODWORDINTREE(0x39b00000,0x00000000)}}, + {VT_exponent,19,0x771fd,{DOUBLEWITHTWODWORDINTREE(0x39c00000,0x00000000)}}, + {VT_exponent,15,0x7764,{DOUBLEWITHTWODWORDINTREE(0x39d00000,0x00000000)}}, + {VT_exponent,20,0xee3f9,{DOUBLEWITHTWODWORDINTREE(0x39e00000,0x00000000)}}, + {VT_exponent,18,0x3bfdb,{DOUBLEWITHTWODWORDINTREE(0x39f00000,0x00000000)}}, + {VT_exponent,16,0xeff7,{DOUBLEWITHTWODWORDINTREE(0x3a000000,0x00000000)}}, + {VT_exponent,18,0xd1d6,{DOUBLEWITHTWODWORDINTREE(0x3a100000,0x00000000)}}, + {VT_exponent,22,0x3a8663,{DOUBLEWITHTWODWORDINTREE(0x3a200000,0x00000000)}}, + {VT_exponent,22,0x3a8666,{DOUBLEWITHTWODWORDINTREE(0x3a300000,0x00000000)}}, + {VT_exponent,18,0x3b8fa,{DOUBLEWITHTWODWORDINTREE(0x3a400000,0x00000000)}}, + {VT_exponent,17,0x1d435,{DOUBLEWITHTWODWORDINTREE(0x3a500000,0x00000000)}}, + {VT_exponent,17,0x1dfe4,{DOUBLEWITHTWODWORDINTREE(0x3a600000,0x00000000)}}, + {VT_exponent,19,0x750d8,{DOUBLEWITHTWODWORDINTREE(0x3a700000,0x00000000)}}, + {VT_exponent,18,0x3a95b,{DOUBLEWITHTWODWORDINTREE(0x3a800000,0x00000000)}}, + {VT_exponent,19,0x77f9e,{DOUBLEWITHTWODWORDINTREE(0x3a900000,0x00000000)}}, + {VT_exponent,19,0x750d9,{DOUBLEWITHTWODWORDINTREE(0x3aa00000,0x00000000)}}, + {VT_exponent,18,0xd1d7,{DOUBLEWITHTWODWORDINTREE(0x3ab00000,0x00000000)}}, + {VT_exponent,18,0x3b8ff,{DOUBLEWITHTWODWORDINTREE(0x3ac00000,0x00000000)}}, + {VT_exponent,17,0x1dc7c,{DOUBLEWITHTWODWORDINTREE(0x3ad00000,0x00000000)}}, + {VT_exponent,19,0x750da,{DOUBLEWITHTWODWORDINTREE(0x3ae00000,0x00000000)}}, + {VT_exponent,17,0x7bc2,{DOUBLEWITHTWODWORDINTREE(0x3af00000,0x00000000)}}, + {VT_exponent,18,0x3bfca,{DOUBLEWITHTWODWORDINTREE(0x3b000000,0x00000000)}}, + {VT_exponent,19,0x1a3a5,{DOUBLEWITHTWODWORDINTREE(0x3b100000,0x00000000)}}, + {VT_exponent,17,0x1d4ac,{DOUBLEWITHTWODWORDINTREE(0x3b200000,0x00000000)}}, + {VT_exponent,18,0x3a86e,{DOUBLEWITHTWODWORDINTREE(0x3b300000,0x00000000)}}, + {VT_exponent,17,0x1d438,{DOUBLEWITHTWODWORDINTREE(0x3b400000,0x00000000)}}, + {VT_exponent,18,0x3bfcb,{DOUBLEWITHTWODWORDINTREE(0x3b500000,0x00000000)}}, + {VT_exponent,19,0x1a3a7,{DOUBLEWITHTWODWORDINTREE(0x3b600000,0x00000000)}}, + {VT_exponent,17,0x1d4ae,{DOUBLEWITHTWODWORDINTREE(0x3b700000,0x00000000)}}, + {VT_exponent,18,0x3bfce,{DOUBLEWITHTWODWORDINTREE(0x3b800000,0x00000000)}}, + {VT_exponent,18,0xf78c,{DOUBLEWITHTWODWORDINTREE(0x3b900000,0x00000000)}}, + {VT_exponent,17,0x1dfec,{DOUBLEWITHTWODWORDINTREE(0x3ba00000,0x00000000)}}, + {VT_exponent,17,0x1d439,{DOUBLEWITHTWODWORDINTREE(0x3bb00000,0x00000000)}}, + {VT_exponent,17,0x68e8,{DOUBLEWITHTWODWORDINTREE(0x3bc00000,0x00000000)}}, + {VT_exponent,18,0xf786,{DOUBLEWITHTWODWORDINTREE(0x3bd00000,0x00000000)}}, + {VT_exponent,15,0x771e,{DOUBLEWITHTWODWORDINTREE(0x3be00000,0x00000000)}}, + {VT_exponent,17,0x1dfe6,{DOUBLEWITHTWODWORDINTREE(0x3bf00000,0x00000000)}}, + {VT_exponent,15,0x77f8,{DOUBLEWITHTWODWORDINTREE(0x3c000000,0x00000000)}}, + {VT_exponent,14,0x3bb3,{DOUBLEWITHTWODWORDINTREE(0x3c100000,0x00000000)}}, + {VT_exponent,14,0x3b8e,{DOUBLEWITHTWODWORDINTREE(0x3c200000,0x00000000)}}, + {VT_exponent,14,0x3a82,{DOUBLEWITHTWODWORDINTREE(0x3c300000,0x00000000)}}, + {VT_exponent,14,0x3b96,{DOUBLEWITHTWODWORDINTREE(0x3c400000,0x00000000)}}, + {VT_exponent,13,0x68f,{DOUBLEWITHTWODWORDINTREE(0x3c500000,0x00000000)}}, + {VT_exponent,12,0x3d4,{DOUBLEWITHTWODWORDINTREE(0x3c600000,0x00000000)}}, + {VT_exponent,13,0x1dca,{DOUBLEWITHTWODWORDINTREE(0x3c700000,0x00000000)}}, + {VT_exponent,12,0x346,{DOUBLEWITHTWODWORDINTREE(0x3c800000,0x00000000)}}, + {VT_exponent,12,0xee7,{DOUBLEWITHTWODWORDINTREE(0x3c900000,0x00000000)}}, + {VT_exponent,12,0xeea,{DOUBLEWITHTWODWORDINTREE(0x3ca00000,0x00000000)}}, + {VT_exponent,11,0x1ed,{DOUBLEWITHTWODWORDINTREE(0x3cb00000,0x00000000)}}, + {VT_exponent,12,0x3df,{DOUBLEWITHTWODWORDINTREE(0x3cc00000,0x00000000)}}, + {VT_exponent,11,0x1a2,{DOUBLEWITHTWODWORDINTREE(0x3cd00000,0x00000000)}}, + {VT_exponent,11,0x56f,{DOUBLEWITHTWODWORDINTREE(0x3ce00000,0x00000000)}}, + {VT_exponent,11,0xb9,{DOUBLEWITHTWODWORDINTREE(0x3cf00000,0x00000000)}}, + {VT_exponent,13,0x7b2,{DOUBLEWITHTWODWORDINTREE(0x3d000000,0x00000000)}}, + {VT_exponent,13,0x1dd8,{DOUBLEWITHTWODWORDINTREE(0x3d100000,0x00000000)}}, + {VT_exponent,13,0x15ba,{DOUBLEWITHTWODWORDINTREE(0x3d200000,0x00000000)}}, + {VT_exponent,12,0xee6,{DOUBLEWITHTWODWORDINTREE(0x3d300000,0x00000000)}}, + {VT_exponent,13,0x15b8,{DOUBLEWITHTWODWORDINTREE(0x3d400000,0x00000000)}}, + {VT_exponent,14,0xf79,{DOUBLEWITHTWODWORDINTREE(0x3d500000,0x00000000)}}, + {VT_exponent,14,0x3a81,{DOUBLEWITHTWODWORDINTREE(0x3d600000,0x00000000)}}, + {VT_exponent,14,0xd1c,{DOUBLEWITHTWODWORDINTREE(0x3d700000,0x00000000)}}, + {VT_exponent,15,0x7765,{DOUBLEWITHTWODWORDINTREE(0x3d800000,0x00000000)}}, + {VT_exponent,14,0xf54,{DOUBLEWITHTWODWORDINTREE(0x3d900000,0x00000000)}}, + {VT_exponent,13,0x15b9,{DOUBLEWITHTWODWORDINTREE(0x3da00000,0x00000000)}}, + {VT_exponent,13,0x7ab,{DOUBLEWITHTWODWORDINTREE(0x3db00000,0x00000000)}}, + {VT_exponent,15,0x7500,{DOUBLEWITHTWODWORDINTREE(0x3dc00000,0x00000000)}}, + {VT_exponent,15,0x1eaa,{DOUBLEWITHTWODWORDINTREE(0x3dd00000,0x00000000)}}, + {VT_exponent,15,0x7501,{DOUBLEWITHTWODWORDINTREE(0x3de00000,0x00000000)}}, + {VT_exponent,15,0x1eab,{DOUBLEWITHTWODWORDINTREE(0x3df00000,0x00000000)}}, + {VT_exponent,14,0x3b97,{DOUBLEWITHTWODWORDINTREE(0x3e000000,0x00000000)}}, + {VT_exponent,15,0x752a,{DOUBLEWITHTWODWORDINTREE(0x3e100000,0x00000000)}}, + {VT_exponent,15,0x77fa,{DOUBLEWITHTWODWORDINTREE(0x3e200000,0x00000000)}}, + {VT_double,10,0xf4,{DOUBLEWITHTWODWORDINTREE(0x3e35798e,0xe2308c3a)}}, + {VT_exponent,14,0x3a93,{DOUBLEWITHTWODWORDINTREE(0x3e300000,0x00000000)}}, + {VT_double,11,0x77c,{DOUBLEWITHTWODWORDINTREE(0x3e45798e,0xe2308c3a)}}, + {VT_exponent,13,0x1dc6,{DOUBLEWITHTWODWORDINTREE(0x3e400000,0x00000000)}}, + {VT_exponent,13,0x7bd,{DOUBLEWITHTWODWORDINTREE(0x3e500000,0x00000000)}}, + {VT_exponent,13,0x1dff,{DOUBLEWITHTWODWORDINTREE(0x3e600000,0x00000000)}}, + {VT_exponent,12,0xefe,{DOUBLEWITHTWODWORDINTREE(0x3e700000,0x00000000)}}, + {VT_double,8,0xaf,{DOUBLEWITHTWODWORDINTREE(0x3e8ad7f2,0x9abcaf4a)}}, + {VT_exponent,12,0xeed,{DOUBLEWITHTWODWORDINTREE(0x3e800000,0x00000000)}}, + {VT_exponent,11,0xb8,{DOUBLEWITHTWODWORDINTREE(0x3e900000,0x00000000)}}, + {VT_exponent,12,0x3d8,{DOUBLEWITHTWODWORDINTREE(0x3ea00000,0x00000000)}}, + {VT_exponent,11,0x1eb,{DOUBLEWITHTWODWORDINTREE(0x3eb00000,0x00000000)}}, + {VT_double,9,0x1d2,{DOUBLEWITHTWODWORDINTREE(0x3ec0c6f7,0xa0b5ed8e)}}, + {VT_exponent,13,0x1d4b,{DOUBLEWITHTWODWORDINTREE(0x3ec00000,0x00000000)}}, + {VT_exponent,13,0x7b3,{DOUBLEWITHTWODWORDINTREE(0x3ed00000,0x00000000)}}, + {VT_exponent,10,0x5d,{DOUBLEWITHTWODWORDINTREE(0x3ee00000,0x00000000)}}, + {VT_exponent,12,0xeeb,{DOUBLEWITHTWODWORDINTREE(0x3ef00000,0x00000000)}}, + {VT_exponent,11,0x1ee,{DOUBLEWITHTWODWORDINTREE(0x3f000000,0x00000000)}}, + {VT_exponent,10,0x5f,{DOUBLEWITHTWODWORDINTREE(0x3f100000,0x00000000)}}, + {VT_exponent,10,0x2b6,{DOUBLEWITHTWODWORDINTREE(0x3f200000,0x00000000)}}, + {VT_exponent,9,0x1de,{DOUBLEWITHTWODWORDINTREE(0x3f300000,0x00000000)}}, + {VT_double,10,0xd0,{DOUBLEWITHTWODWORDINTREE(0x3f454c98,0x5f06f694)}}, + {VT_double,6,0x9,{DOUBLEWITHTWODWORDINTREE(0x3f4a36e2,0xeb1c432d)}}, + {VT_exponent,8,0xe8,{DOUBLEWITHTWODWORDINTREE(0x3f400000,0x00000000)}}, + {VT_double,4,0xf,{DOUBLEWITHTWODWORDINTREE(0x3f50624d,0xd2f1a9fc)}}, + {VT_exponent,8,0xae,{DOUBLEWITHTWODWORDINTREE(0x3f500000,0x00000000)}}, + {VT_double,5,0x16,{DOUBLEWITHTWODWORDINTREE(0x3f60624d,0xd2f1a9fc)}}, + {VT_exponent,7,0x1b,{DOUBLEWITHTWODWORDINTREE(0x3f600000,0x00000000)}}, + {VT_exponent,7,0x76,{DOUBLEWITHTWODWORDINTREE(0x3f700000,0x00000000)}}, + {VT_exponent,7,0xa,{DOUBLEWITHTWODWORDINTREE(0x3f800000,0x00000000)}}, + {VT_exponent,6,0x8,{DOUBLEWITHTWODWORDINTREE(0x3f900000,0x00000000)}}, + {VT_exponent,6,0xe,{DOUBLEWITHTWODWORDINTREE(0x3fa00000,0x00000000)}}, + {VT_double,11,0x751,{DOUBLEWITHTWODWORDINTREE(0x3fbe69ad,0x42c3c9ee)}}, + {VT_exponent,6,0x4,{DOUBLEWITHTWODWORDINTREE(0x3fb00000,0x00000000)}}, + {VT_exponent,6,0xc,{DOUBLEWITHTWODWORDINTREE(0x3fc00000,0x00000000)}}, + {VT_exponent,5,0x3,{DOUBLEWITHTWODWORDINTREE(0x3fd00000,0x00000000)}}, + {VT_double,11,0x777,{DOUBLEWITHTWODWORDINTREE(0x3fe00000,0x00000000)}}, + {VT_double,9,0x1d6,{DOUBLEWITHTWODWORDINTREE(0x3fefffff,0xf8000002)}}, + {VT_exponent,4,0x8,{DOUBLEWITHTWODWORDINTREE(0x3fe00000,0x00000000)}}, + {VT_double,4,0x0,{DOUBLEWITHTWODWORDINTREE(0x3ff00000,0x00000000)}}, + {VT_exponent,5,0x13,{DOUBLEWITHTWODWORDINTREE(0x3ff00000,0x00000000)}}, + {VT_exponent,5,0x1b,{DOUBLEWITHTWODWORDINTREE(0x40000000,0x00000000)}}, + {VT_double,9,0x15a,{DOUBLEWITHTWODWORDINTREE(0x401921fb,0x54442d18)}}, + {VT_exponent,5,0x17,{DOUBLEWITHTWODWORDINTREE(0x40100000,0x00000000)}}, + {VT_exponent,5,0x12,{DOUBLEWITHTWODWORDINTREE(0x40200000,0x00000000)}}, + {VT_double,11,0x774,{DOUBLEWITHTWODWORDINTREE(0x4035ee14,0x80000000)}}, + {VT_exponent,5,0x19,{DOUBLEWITHTWODWORDINTREE(0x40300000,0x00000000)}}, + {VT_double,9,0x1d3,{DOUBLEWITHTWODWORDINTREE(0x404ca5dc,0x1a63c1f8)}}, + {VT_exponent,5,0x1a,{DOUBLEWITHTWODWORDINTREE(0x40400000,0x00000000)}}, + {VT_double,11,0x77e,{DOUBLEWITHTWODWORDINTREE(0x405bb32f,0xe0000000)}}, + {VT_double,10,0x5e,{DOUBLEWITHTWODWORDINTREE(0x405c332f,0xe0000000)}}, + {VT_exponent,5,0x18,{DOUBLEWITHTWODWORDINTREE(0x40500000,0x00000000)}}, + {VT_double,9,0x1d7,{DOUBLEWITHTWODWORDINTREE(0x40668000,0x00000000)}}, + {VT_exponent,5,0x1c,{DOUBLEWITHTWODWORDINTREE(0x40600000,0x00000000)}}, + {VT_double,9,0x1d5,{DOUBLEWITHTWODWORDINTREE(0x40768000,0x00000000)}}, + {VT_exponent,5,0x14,{DOUBLEWITHTWODWORDINTREE(0x40700000,0x00000000)}}, + {VT_double,11,0x77d,{DOUBLEWITHTWODWORDINTREE(0x408f4000,0x00000000)}}, + {VT_exponent,5,0x5,{DOUBLEWITHTWODWORDINTREE(0x40800000,0x00000000)}}, + {VT_double,10,0xd2,{DOUBLEWITHTWODWORDINTREE(0x409233ff,0xffffffff)}}, + {VT_double,8,0x3c,{DOUBLEWITHTWODWORDINTREE(0x40923400,0x00000000)}}, + {VT_double,11,0x753,{DOUBLEWITHTWODWORDINTREE(0x40923400,0x00000001)}}, + {VT_double,10,0xd3,{DOUBLEWITHTWODWORDINTREE(0x4092abff,0xffffffff)}}, + {VT_double,8,0x35,{DOUBLEWITHTWODWORDINTREE(0x4092ac00,0x00000000)}}, + {VT_double,11,0x770,{DOUBLEWITHTWODWORDINTREE(0x4092ac00,0x00000001)}}, + {VT_exponent,8,0x16,{DOUBLEWITHTWODWORDINTREE(0x40900000,0x00000000)}}, + {VT_exponent,12,0xee2,{DOUBLEWITHTWODWORDINTREE(0x40a00000,0x00000000)}}, + {VT_exponent,12,0xee4,{DOUBLEWITHTWODWORDINTREE(0x40b00000,0x00000000)}}, + {VT_double,7,0x1f,{DOUBLEWITHTWODWORDINTREE(0x40c81c80,0x00000000)}}, + {VT_exponent,8,0xac,{DOUBLEWITHTWODWORDINTREE(0x40c00000,0x00000000)}}, + {VT_exponent,13,0x15bb,{DOUBLEWITHTWODWORDINTREE(0x40d00000,0x00000000)}}, + {VT_exponent,22,0x3a8667,{DOUBLEWITHTWODWORDINTREE(0x40e00000,0x00000000)}}, + {VT_exponent,22,0x3a86d8,{DOUBLEWITHTWODWORDINTREE(0x40f00000,0x00000000)}}, + {VT_exponent,22,0x3a86d9,{DOUBLEWITHTWODWORDINTREE(0x41000000,0x00000000)}}, + {VT_exponent,22,0x3a86da,{DOUBLEWITHTWODWORDINTREE(0x41100000,0x00000000)}}, + {VT_exponent,17,0x1dc7e,{DOUBLEWITHTWODWORDINTREE(0x41200000,0x00000000)}}, + {VT_exponent,22,0x3a86db,{DOUBLEWITHTWODWORDINTREE(0x41300000,0x00000000)}}, + {VT_exponent,22,0x3a86dc,{DOUBLEWITHTWODWORDINTREE(0x41400000,0x00000000)}}, + {VT_exponent,22,0x3a86dd,{DOUBLEWITHTWODWORDINTREE(0x41500000,0x00000000)}}, + {VT_exponent,22,0x3a86de,{DOUBLEWITHTWODWORDINTREE(0x41600000,0x00000000)}}, + {VT_exponent,22,0x3a86df,{DOUBLEWITHTWODWORDINTREE(0x41700000,0x00000000)}}, + {VT_exponent,22,0x3a86f0,{DOUBLEWITHTWODWORDINTREE(0x41800000,0x00000000)}}, + {VT_exponent,22,0x3a86f1,{DOUBLEWITHTWODWORDINTREE(0x41900000,0x00000000)}}, + {VT_exponent,22,0x3a86f2,{DOUBLEWITHTWODWORDINTREE(0x41a00000,0x00000000)}}, + {VT_exponent,22,0x3a86f3,{DOUBLEWITHTWODWORDINTREE(0x41b00000,0x00000000)}}, + {VT_double,6,0x2a,{DOUBLEWITHTWODWORDINTREE(0x41cdcd64,0xff800000)}}, + {VT_exponent,22,0x3a86f4,{DOUBLEWITHTWODWORDINTREE(0x41c00000,0x00000000)}}, + {VT_exponent,22,0x3a86f5,{DOUBLEWITHTWODWORDINTREE(0x41d00000,0x00000000)}}, + {VT_exponent,22,0x3a86f6,{DOUBLEWITHTWODWORDINTREE(0x41e00000,0x00000000)}}, + {VT_exponent,22,0x3a86f7,{DOUBLEWITHTWODWORDINTREE(0x41f00000,0x00000000)}}, + {VT_exponent,22,0x3a86f8,{DOUBLEWITHTWODWORDINTREE(0x42000000,0x00000000)}}, + {VT_exponent,22,0x3a86f9,{DOUBLEWITHTWODWORDINTREE(0x42100000,0x00000000)}}, + {VT_exponent,22,0x3a86fa,{DOUBLEWITHTWODWORDINTREE(0x42200000,0x00000000)}}, + {VT_exponent,22,0x3a86fb,{DOUBLEWITHTWODWORDINTREE(0x42300000,0x00000000)}}, + {VT_exponent,22,0x3a86fc,{DOUBLEWITHTWODWORDINTREE(0x42400000,0x00000000)}}, + {VT_exponent,22,0x3a86fd,{DOUBLEWITHTWODWORDINTREE(0x42500000,0x00000000)}}, + {VT_exponent,22,0x3a86fe,{DOUBLEWITHTWODWORDINTREE(0x42600000,0x00000000)}}, + {VT_exponent,22,0x3a86ff,{DOUBLEWITHTWODWORDINTREE(0x42700000,0x00000000)}}, + {VT_exponent,22,0x3a8740,{DOUBLEWITHTWODWORDINTREE(0x42800000,0x00000000)}}, + {VT_exponent,22,0x3a8741,{DOUBLEWITHTWODWORDINTREE(0x42900000,0x00000000)}}, + {VT_exponent,22,0x3a8742,{DOUBLEWITHTWODWORDINTREE(0x42a00000,0x00000000)}}, + {VT_exponent,22,0x3a8743,{DOUBLEWITHTWODWORDINTREE(0x42b00000,0x00000000)}}, + {VT_exponent,22,0x3a8744,{DOUBLEWITHTWODWORDINTREE(0x42c00000,0x00000000)}}, + {VT_exponent,22,0x3a8745,{DOUBLEWITHTWODWORDINTREE(0x42d00000,0x00000000)}}, + {VT_exponent,22,0x3a8746,{DOUBLEWITHTWODWORDINTREE(0x42e00000,0x00000000)}}, + {VT_exponent,22,0x3a8747,{DOUBLEWITHTWODWORDINTREE(0x42f00000,0x00000000)}}, + {VT_exponent,22,0x3a8748,{DOUBLEWITHTWODWORDINTREE(0x43000000,0x00000000)}}, + {VT_exponent,22,0x3a8749,{DOUBLEWITHTWODWORDINTREE(0x43100000,0x00000000)}}, + {VT_exponent,22,0x3a874a,{DOUBLEWITHTWODWORDINTREE(0x43200000,0x00000000)}}, + {VT_exponent,22,0x3a874b,{DOUBLEWITHTWODWORDINTREE(0x43300000,0x00000000)}}, + {VT_exponent,22,0x3a874c,{DOUBLEWITHTWODWORDINTREE(0x43400000,0x00000000)}}, + {VT_exponent,22,0x3a874d,{DOUBLEWITHTWODWORDINTREE(0x43500000,0x00000000)}}, + {VT_exponent,22,0x3a874e,{DOUBLEWITHTWODWORDINTREE(0x43600000,0x00000000)}}, + {VT_exponent,22,0x3a874f,{DOUBLEWITHTWODWORDINTREE(0x43700000,0x00000000)}}, + {VT_exponent,22,0x3a8750,{DOUBLEWITHTWODWORDINTREE(0x43800000,0x00000000)}}, + {VT_exponent,22,0x3a8751,{DOUBLEWITHTWODWORDINTREE(0x43900000,0x00000000)}}, + {VT_exponent,22,0x3a8752,{DOUBLEWITHTWODWORDINTREE(0x43a00000,0x00000000)}}, + {VT_exponent,22,0x3a8753,{DOUBLEWITHTWODWORDINTREE(0x43b00000,0x00000000)}}, + {VT_exponent,22,0x3a8754,{DOUBLEWITHTWODWORDINTREE(0x43c00000,0x00000000)}}, + {VT_exponent,22,0x3a8755,{DOUBLEWITHTWODWORDINTREE(0x43d00000,0x00000000)}}, + {VT_exponent,22,0x3a8756,{DOUBLEWITHTWODWORDINTREE(0x43e00000,0x00000000)}}, + {VT_exponent,22,0x3a8757,{DOUBLEWITHTWODWORDINTREE(0x43f00000,0x00000000)}}, + {VT_exponent,22,0x3a8758,{DOUBLEWITHTWODWORDINTREE(0x44000000,0x00000000)}}, + {VT_exponent,15,0x1a3b,{DOUBLEWITHTWODWORDINTREE(0x44100000,0x00000000)}}, + {VT_exponent,22,0x3a8759,{DOUBLEWITHTWODWORDINTREE(0x44200000,0x00000000)}}, + {VT_exponent,22,0x3a875a,{DOUBLEWITHTWODWORDINTREE(0x44300000,0x00000000)}}, + {VT_exponent,22,0x3a875b,{DOUBLEWITHTWODWORDINTREE(0x44400000,0x00000000)}}, + {VT_exponent,22,0x3a875c,{DOUBLEWITHTWODWORDINTREE(0x44500000,0x00000000)}}, + {VT_exponent,22,0x3a875d,{DOUBLEWITHTWODWORDINTREE(0x44600000,0x00000000)}}, + {VT_exponent,22,0x3a875e,{DOUBLEWITHTWODWORDINTREE(0x44700000,0x00000000)}}, + {VT_exponent,22,0x3a875f,{DOUBLEWITHTWODWORDINTREE(0x44800000,0x00000000)}}, + {VT_exponent,22,0x3a8760,{DOUBLEWITHTWODWORDINTREE(0x44900000,0x00000000)}}, + {VT_exponent,22,0x3a8761,{DOUBLEWITHTWODWORDINTREE(0x44a00000,0x00000000)}}, + {VT_exponent,22,0x3a8762,{DOUBLEWITHTWODWORDINTREE(0x44b00000,0x00000000)}}, + {VT_exponent,22,0x3a8763,{DOUBLEWITHTWODWORDINTREE(0x44c00000,0x00000000)}}, + {VT_exponent,22,0x3a8764,{DOUBLEWITHTWODWORDINTREE(0x44d00000,0x00000000)}}, + {VT_exponent,22,0x3a8765,{DOUBLEWITHTWODWORDINTREE(0x44e00000,0x00000000)}}, + {VT_exponent,22,0x3a8766,{DOUBLEWITHTWODWORDINTREE(0x44f00000,0x00000000)}}, + {VT_exponent,22,0x3a8767,{DOUBLEWITHTWODWORDINTREE(0x45000000,0x00000000)}}, + {VT_exponent,22,0x3a8768,{DOUBLEWITHTWODWORDINTREE(0x45100000,0x00000000)}}, + {VT_exponent,22,0x3a8769,{DOUBLEWITHTWODWORDINTREE(0x45200000,0x00000000)}}, + {VT_exponent,22,0x3a876a,{DOUBLEWITHTWODWORDINTREE(0x45300000,0x00000000)}}, + {VT_exponent,22,0x3a876b,{DOUBLEWITHTWODWORDINTREE(0x45400000,0x00000000)}}, + {VT_exponent,22,0x3a876c,{DOUBLEWITHTWODWORDINTREE(0x45500000,0x00000000)}}, + {VT_exponent,22,0x3a876d,{DOUBLEWITHTWODWORDINTREE(0x45600000,0x00000000)}}, + {VT_exponent,22,0x3a876e,{DOUBLEWITHTWODWORDINTREE(0x45700000,0x00000000)}}, + {VT_exponent,22,0x3a876f,{DOUBLEWITHTWODWORDINTREE(0x45800000,0x00000000)}}, + {VT_exponent,22,0x3a8770,{DOUBLEWITHTWODWORDINTREE(0x45900000,0x00000000)}}, + {VT_exponent,22,0x3a8771,{DOUBLEWITHTWODWORDINTREE(0x45a00000,0x00000000)}}, + {VT_exponent,22,0x3a8772,{DOUBLEWITHTWODWORDINTREE(0x45b00000,0x00000000)}}, + {VT_exponent,22,0x3a8773,{DOUBLEWITHTWODWORDINTREE(0x45c00000,0x00000000)}}, + {VT_exponent,22,0x3a8774,{DOUBLEWITHTWODWORDINTREE(0x45d00000,0x00000000)}}, + {VT_exponent,22,0x3a8775,{DOUBLEWITHTWODWORDINTREE(0x45e00000,0x00000000)}}, + {VT_exponent,22,0x3a8776,{DOUBLEWITHTWODWORDINTREE(0x45f00000,0x00000000)}}, + {VT_exponent,22,0x3a8777,{DOUBLEWITHTWODWORDINTREE(0x46000000,0x00000000)}}, + {VT_exponent,22,0x3a8778,{DOUBLEWITHTWODWORDINTREE(0x46100000,0x00000000)}}, + {VT_exponent,22,0x3a8779,{DOUBLEWITHTWODWORDINTREE(0x46200000,0x00000000)}}, + {VT_exponent,22,0x3a877a,{DOUBLEWITHTWODWORDINTREE(0x46300000,0x00000000)}}, + {VT_exponent,22,0x3a877b,{DOUBLEWITHTWODWORDINTREE(0x46400000,0x00000000)}}, + {VT_exponent,22,0x3a877c,{DOUBLEWITHTWODWORDINTREE(0x46500000,0x00000000)}}, + {VT_exponent,22,0x3a877d,{DOUBLEWITHTWODWORDINTREE(0x46600000,0x00000000)}}, + {VT_exponent,22,0x3a877e,{DOUBLEWITHTWODWORDINTREE(0x46700000,0x00000000)}}, + {VT_exponent,22,0x3a877f,{DOUBLEWITHTWODWORDINTREE(0x46800000,0x00000000)}}, + {VT_exponent,22,0x3a8780,{DOUBLEWITHTWODWORDINTREE(0x46900000,0x00000000)}}, + {VT_exponent,22,0x3a8781,{DOUBLEWITHTWODWORDINTREE(0x46a00000,0x00000000)}}, + {VT_exponent,22,0x3a8782,{DOUBLEWITHTWODWORDINTREE(0x46b00000,0x00000000)}}, + {VT_exponent,22,0x3a8783,{DOUBLEWITHTWODWORDINTREE(0x46c00000,0x00000000)}}, + {VT_exponent,22,0x3a8784,{DOUBLEWITHTWODWORDINTREE(0x46d00000,0x00000000)}}, + {VT_exponent,22,0x3a8785,{DOUBLEWITHTWODWORDINTREE(0x46e00000,0x00000000)}}, + {VT_exponent,22,0x3a8786,{DOUBLEWITHTWODWORDINTREE(0x46f00000,0x00000000)}}, + {VT_exponent,22,0x3a8787,{DOUBLEWITHTWODWORDINTREE(0x47000000,0x00000000)}}, + {VT_exponent,22,0x3a8788,{DOUBLEWITHTWODWORDINTREE(0x47100000,0x00000000)}}, + {VT_exponent,22,0x3a8789,{DOUBLEWITHTWODWORDINTREE(0x47200000,0x00000000)}}, + {VT_exponent,22,0x3a878a,{DOUBLEWITHTWODWORDINTREE(0x47300000,0x00000000)}}, + {VT_exponent,22,0x3a878b,{DOUBLEWITHTWODWORDINTREE(0x47400000,0x00000000)}}, + {VT_exponent,22,0x3a878c,{DOUBLEWITHTWODWORDINTREE(0x47500000,0x00000000)}}, + {VT_exponent,22,0x3a878d,{DOUBLEWITHTWODWORDINTREE(0x47600000,0x00000000)}}, + {VT_exponent,22,0x3a878e,{DOUBLEWITHTWODWORDINTREE(0x47700000,0x00000000)}}, + {VT_exponent,22,0x3a878f,{DOUBLEWITHTWODWORDINTREE(0x47800000,0x00000000)}}, + {VT_exponent,22,0x3a8790,{DOUBLEWITHTWODWORDINTREE(0x47900000,0x00000000)}}, + {VT_exponent,22,0x3a8791,{DOUBLEWITHTWODWORDINTREE(0x47a00000,0x00000000)}}, + {VT_exponent,22,0x3a8792,{DOUBLEWITHTWODWORDINTREE(0x47b00000,0x00000000)}}, + {VT_exponent,22,0x3a8793,{DOUBLEWITHTWODWORDINTREE(0x47c00000,0x00000000)}}, + {VT_exponent,22,0x3a8794,{DOUBLEWITHTWODWORDINTREE(0x47d00000,0x00000000)}}, + {VT_exponent,22,0x3a8795,{DOUBLEWITHTWODWORDINTREE(0x47e00000,0x00000000)}}, + {VT_exponent,22,0x3a8796,{DOUBLEWITHTWODWORDINTREE(0x47f00000,0x00000000)}}, + {VT_exponent,22,0x3a8797,{DOUBLEWITHTWODWORDINTREE(0x48000000,0x00000000)}}, + {VT_exponent,22,0x3a8798,{DOUBLEWITHTWODWORDINTREE(0x48100000,0x00000000)}}, + {VT_exponent,22,0x3a8799,{DOUBLEWITHTWODWORDINTREE(0x48200000,0x00000000)}}, + {VT_exponent,22,0x3a879a,{DOUBLEWITHTWODWORDINTREE(0x48300000,0x00000000)}}, + {VT_exponent,22,0x3a879b,{DOUBLEWITHTWODWORDINTREE(0x48400000,0x00000000)}}, + {VT_exponent,22,0x3a879c,{DOUBLEWITHTWODWORDINTREE(0x48500000,0x00000000)}}, + {VT_exponent,22,0x3a879d,{DOUBLEWITHTWODWORDINTREE(0x48600000,0x00000000)}}, + {VT_exponent,22,0x3a879e,{DOUBLEWITHTWODWORDINTREE(0x48700000,0x00000000)}}, + {VT_exponent,22,0x3a879f,{DOUBLEWITHTWODWORDINTREE(0x48800000,0x00000000)}}, + {VT_exponent,22,0x3a87a0,{DOUBLEWITHTWODWORDINTREE(0x48900000,0x00000000)}}, + {VT_exponent,22,0x3a87a1,{DOUBLEWITHTWODWORDINTREE(0x48a00000,0x00000000)}}, + {VT_exponent,22,0x3a87a2,{DOUBLEWITHTWODWORDINTREE(0x48b00000,0x00000000)}}, + {VT_exponent,22,0x3a87a3,{DOUBLEWITHTWODWORDINTREE(0x48c00000,0x00000000)}}, + {VT_exponent,22,0x3a87a4,{DOUBLEWITHTWODWORDINTREE(0x48d00000,0x00000000)}}, + {VT_exponent,22,0x3a87a5,{DOUBLEWITHTWODWORDINTREE(0x48e00000,0x00000000)}}, + {VT_exponent,22,0x3a87a6,{DOUBLEWITHTWODWORDINTREE(0x48f00000,0x00000000)}}, + {VT_exponent,22,0x3a87a7,{DOUBLEWITHTWODWORDINTREE(0x49000000,0x00000000)}}, + {VT_exponent,22,0x3a87a8,{DOUBLEWITHTWODWORDINTREE(0x49100000,0x00000000)}}, + {VT_exponent,22,0x3a87a9,{DOUBLEWITHTWODWORDINTREE(0x49200000,0x00000000)}}, + {VT_exponent,22,0x3a87aa,{DOUBLEWITHTWODWORDINTREE(0x49300000,0x00000000)}}, + {VT_exponent,22,0x3a87ab,{DOUBLEWITHTWODWORDINTREE(0x49400000,0x00000000)}}, + {VT_exponent,22,0x3a87ac,{DOUBLEWITHTWODWORDINTREE(0x49500000,0x00000000)}}, + {VT_exponent,22,0x3a87ad,{DOUBLEWITHTWODWORDINTREE(0x49600000,0x00000000)}}, + {VT_exponent,22,0x3a87ae,{DOUBLEWITHTWODWORDINTREE(0x49700000,0x00000000)}}, + {VT_exponent,22,0x3a87af,{DOUBLEWITHTWODWORDINTREE(0x49800000,0x00000000)}}, + {VT_exponent,22,0x3a87b0,{DOUBLEWITHTWODWORDINTREE(0x49900000,0x00000000)}}, + {VT_exponent,22,0x3a87b1,{DOUBLEWITHTWODWORDINTREE(0x49a00000,0x00000000)}}, + {VT_exponent,22,0x3a87b2,{DOUBLEWITHTWODWORDINTREE(0x49b00000,0x00000000)}}, + {VT_exponent,22,0x3a87b3,{DOUBLEWITHTWODWORDINTREE(0x49c00000,0x00000000)}}, + {VT_exponent,22,0x3a87b4,{DOUBLEWITHTWODWORDINTREE(0x49d00000,0x00000000)}}, + {VT_exponent,22,0x3a87b5,{DOUBLEWITHTWODWORDINTREE(0x49e00000,0x00000000)}}, + {VT_exponent,22,0x3a87b6,{DOUBLEWITHTWODWORDINTREE(0x49f00000,0x00000000)}}, + {VT_exponent,22,0x3a87b7,{DOUBLEWITHTWODWORDINTREE(0x4a000000,0x00000000)}}, + {VT_exponent,22,0x3a87b8,{DOUBLEWITHTWODWORDINTREE(0x4a100000,0x00000000)}}, + {VT_exponent,22,0x3a87b9,{DOUBLEWITHTWODWORDINTREE(0x4a200000,0x00000000)}}, + {VT_exponent,22,0x3a87ba,{DOUBLEWITHTWODWORDINTREE(0x4a300000,0x00000000)}}, + {VT_exponent,22,0x3a87bb,{DOUBLEWITHTWODWORDINTREE(0x4a400000,0x00000000)}}, + {VT_exponent,22,0x3a87bc,{DOUBLEWITHTWODWORDINTREE(0x4a500000,0x00000000)}}, + {VT_exponent,22,0x3a87bd,{DOUBLEWITHTWODWORDINTREE(0x4a600000,0x00000000)}}, + {VT_exponent,22,0x3a87be,{DOUBLEWITHTWODWORDINTREE(0x4a700000,0x00000000)}}, + {VT_exponent,22,0x3a87bf,{DOUBLEWITHTWODWORDINTREE(0x4a800000,0x00000000)}}, + {VT_exponent,22,0x3a87c0,{DOUBLEWITHTWODWORDINTREE(0x4a900000,0x00000000)}}, + {VT_exponent,22,0x3a87c1,{DOUBLEWITHTWODWORDINTREE(0x4aa00000,0x00000000)}}, + {VT_exponent,22,0x3a87c2,{DOUBLEWITHTWODWORDINTREE(0x4ab00000,0x00000000)}}, + {VT_exponent,22,0x3a87c3,{DOUBLEWITHTWODWORDINTREE(0x4ac00000,0x00000000)}}, + {VT_exponent,22,0x3a87c4,{DOUBLEWITHTWODWORDINTREE(0x4ad00000,0x00000000)}}, + {VT_exponent,22,0x3a87c5,{DOUBLEWITHTWODWORDINTREE(0x4ae00000,0x00000000)}}, + {VT_exponent,22,0x3a87c6,{DOUBLEWITHTWODWORDINTREE(0x4af00000,0x00000000)}}, + {VT_exponent,22,0x3a87c7,{DOUBLEWITHTWODWORDINTREE(0x4b000000,0x00000000)}}, + {VT_exponent,22,0x3a87c8,{DOUBLEWITHTWODWORDINTREE(0x4b100000,0x00000000)}}, + {VT_exponent,22,0x3a87c9,{DOUBLEWITHTWODWORDINTREE(0x4b200000,0x00000000)}}, + {VT_exponent,22,0x3a87ca,{DOUBLEWITHTWODWORDINTREE(0x4b300000,0x00000000)}}, + {VT_exponent,22,0x3a87cb,{DOUBLEWITHTWODWORDINTREE(0x4b400000,0x00000000)}}, + {VT_exponent,22,0x3a87cc,{DOUBLEWITHTWODWORDINTREE(0x4b500000,0x00000000)}}, + {VT_exponent,22,0x3a87cd,{DOUBLEWITHTWODWORDINTREE(0x4b600000,0x00000000)}}, + {VT_exponent,22,0x3a87ce,{DOUBLEWITHTWODWORDINTREE(0x4b700000,0x00000000)}}, + {VT_exponent,22,0x3a87cf,{DOUBLEWITHTWODWORDINTREE(0x4b800000,0x00000000)}}, + {VT_exponent,22,0x3a87d0,{DOUBLEWITHTWODWORDINTREE(0x4b900000,0x00000000)}}, + {VT_exponent,22,0x3a87d1,{DOUBLEWITHTWODWORDINTREE(0x4ba00000,0x00000000)}}, + {VT_exponent,22,0x3a87d2,{DOUBLEWITHTWODWORDINTREE(0x4bb00000,0x00000000)}}, + {VT_exponent,22,0x3a87d3,{DOUBLEWITHTWODWORDINTREE(0x4bc00000,0x00000000)}}, + {VT_exponent,22,0x3a87d4,{DOUBLEWITHTWODWORDINTREE(0x4bd00000,0x00000000)}}, + {VT_exponent,22,0x3a87d5,{DOUBLEWITHTWODWORDINTREE(0x4be00000,0x00000000)}}, + {VT_exponent,22,0x3a87d6,{DOUBLEWITHTWODWORDINTREE(0x4bf00000,0x00000000)}}, + {VT_exponent,22,0x3a87d7,{DOUBLEWITHTWODWORDINTREE(0x4c000000,0x00000000)}}, + {VT_exponent,22,0x3a87d8,{DOUBLEWITHTWODWORDINTREE(0x4c100000,0x00000000)}}, + {VT_exponent,22,0x3a87d9,{DOUBLEWITHTWODWORDINTREE(0x4c200000,0x00000000)}}, + {VT_exponent,22,0x3a87da,{DOUBLEWITHTWODWORDINTREE(0x4c300000,0x00000000)}}, + {VT_exponent,22,0x3a87db,{DOUBLEWITHTWODWORDINTREE(0x4c400000,0x00000000)}}, + {VT_exponent,22,0x3a87dc,{DOUBLEWITHTWODWORDINTREE(0x4c500000,0x00000000)}}, + {VT_exponent,22,0x3a87dd,{DOUBLEWITHTWODWORDINTREE(0x4c600000,0x00000000)}}, + {VT_exponent,22,0x3a87de,{DOUBLEWITHTWODWORDINTREE(0x4c700000,0x00000000)}}, + {VT_exponent,22,0x3a87df,{DOUBLEWITHTWODWORDINTREE(0x4c800000,0x00000000)}}, + {VT_exponent,22,0x3a87e0,{DOUBLEWITHTWODWORDINTREE(0x4c900000,0x00000000)}}, + {VT_exponent,22,0x3a87e1,{DOUBLEWITHTWODWORDINTREE(0x4ca00000,0x00000000)}}, + {VT_exponent,22,0x3a87e2,{DOUBLEWITHTWODWORDINTREE(0x4cb00000,0x00000000)}}, + {VT_exponent,22,0x3a87e3,{DOUBLEWITHTWODWORDINTREE(0x4cc00000,0x00000000)}}, + {VT_exponent,22,0x3a87e4,{DOUBLEWITHTWODWORDINTREE(0x4cd00000,0x00000000)}}, + {VT_exponent,22,0x3a87e5,{DOUBLEWITHTWODWORDINTREE(0x4ce00000,0x00000000)}}, + {VT_exponent,22,0x3a87e6,{DOUBLEWITHTWODWORDINTREE(0x4cf00000,0x00000000)}}, + {VT_exponent,22,0x3a87e7,{DOUBLEWITHTWODWORDINTREE(0x4d000000,0x00000000)}}, + {VT_exponent,22,0x3a87e8,{DOUBLEWITHTWODWORDINTREE(0x4d100000,0x00000000)}}, + {VT_exponent,22,0x3a87e9,{DOUBLEWITHTWODWORDINTREE(0x4d200000,0x00000000)}}, + {VT_exponent,22,0x3a87ea,{DOUBLEWITHTWODWORDINTREE(0x4d300000,0x00000000)}}, + {VT_exponent,22,0x3a87eb,{DOUBLEWITHTWODWORDINTREE(0x4d400000,0x00000000)}}, + {VT_exponent,22,0x3a87ec,{DOUBLEWITHTWODWORDINTREE(0x4d500000,0x00000000)}}, + {VT_exponent,22,0x3a87ed,{DOUBLEWITHTWODWORDINTREE(0x4d600000,0x00000000)}}, + {VT_exponent,22,0x3a87ee,{DOUBLEWITHTWODWORDINTREE(0x4d700000,0x00000000)}}, + {VT_exponent,22,0x3a87ef,{DOUBLEWITHTWODWORDINTREE(0x4d800000,0x00000000)}}, + {VT_exponent,22,0x3a87f0,{DOUBLEWITHTWODWORDINTREE(0x4d900000,0x00000000)}}, + {VT_exponent,22,0x3a87f1,{DOUBLEWITHTWODWORDINTREE(0x4da00000,0x00000000)}}, + {VT_exponent,22,0x3a87f2,{DOUBLEWITHTWODWORDINTREE(0x4db00000,0x00000000)}}, + {VT_exponent,22,0x3a87f3,{DOUBLEWITHTWODWORDINTREE(0x4dc00000,0x00000000)}}, + {VT_exponent,22,0x3a87f4,{DOUBLEWITHTWODWORDINTREE(0x4dd00000,0x00000000)}}, + {VT_exponent,22,0x3a87f5,{DOUBLEWITHTWODWORDINTREE(0x4de00000,0x00000000)}}, + {VT_exponent,22,0x3a87f6,{DOUBLEWITHTWODWORDINTREE(0x4df00000,0x00000000)}}, + {VT_exponent,22,0x3a87f7,{DOUBLEWITHTWODWORDINTREE(0x4e000000,0x00000000)}}, + {VT_exponent,22,0x3a87f8,{DOUBLEWITHTWODWORDINTREE(0x4e100000,0x00000000)}}, + {VT_exponent,22,0x3a87f9,{DOUBLEWITHTWODWORDINTREE(0x4e200000,0x00000000)}}, + {VT_exponent,22,0x3a87fa,{DOUBLEWITHTWODWORDINTREE(0x4e300000,0x00000000)}}, + {VT_exponent,22,0x3a87fb,{DOUBLEWITHTWODWORDINTREE(0x4e400000,0x00000000)}}, + {VT_exponent,22,0x3a87fc,{DOUBLEWITHTWODWORDINTREE(0x4e500000,0x00000000)}}, + {VT_exponent,22,0x3a87fd,{DOUBLEWITHTWODWORDINTREE(0x4e600000,0x00000000)}}, + {VT_exponent,22,0x3a87fe,{DOUBLEWITHTWODWORDINTREE(0x4e700000,0x00000000)}}, + {VT_exponent,22,0x3a87ff,{DOUBLEWITHTWODWORDINTREE(0x4e800000,0x00000000)}}, + {VT_exponent,22,0x3a9000,{DOUBLEWITHTWODWORDINTREE(0x4e900000,0x00000000)}}, + {VT_exponent,22,0x3a9001,{DOUBLEWITHTWODWORDINTREE(0x4ea00000,0x00000000)}}, + {VT_exponent,22,0x3a9002,{DOUBLEWITHTWODWORDINTREE(0x4eb00000,0x00000000)}}, + {VT_exponent,22,0x3a9003,{DOUBLEWITHTWODWORDINTREE(0x4ec00000,0x00000000)}}, + {VT_exponent,22,0x3a9004,{DOUBLEWITHTWODWORDINTREE(0x4ed00000,0x00000000)}}, + {VT_exponent,22,0x3a9005,{DOUBLEWITHTWODWORDINTREE(0x4ee00000,0x00000000)}}, + {VT_exponent,22,0x3a9006,{DOUBLEWITHTWODWORDINTREE(0x4ef00000,0x00000000)}}, + {VT_exponent,22,0x3a9007,{DOUBLEWITHTWODWORDINTREE(0x4f000000,0x00000000)}}, + {VT_exponent,22,0x3a9008,{DOUBLEWITHTWODWORDINTREE(0x4f100000,0x00000000)}}, + {VT_exponent,22,0x3a9009,{DOUBLEWITHTWODWORDINTREE(0x4f200000,0x00000000)}}, + {VT_exponent,22,0x3a900a,{DOUBLEWITHTWODWORDINTREE(0x4f300000,0x00000000)}}, + {VT_exponent,22,0x3a900b,{DOUBLEWITHTWODWORDINTREE(0x4f400000,0x00000000)}}, + {VT_exponent,22,0x3a900c,{DOUBLEWITHTWODWORDINTREE(0x4f500000,0x00000000)}}, + {VT_exponent,22,0x3a900d,{DOUBLEWITHTWODWORDINTREE(0x4f600000,0x00000000)}}, + {VT_exponent,22,0x3a900e,{DOUBLEWITHTWODWORDINTREE(0x4f700000,0x00000000)}}, + {VT_exponent,22,0x3a900f,{DOUBLEWITHTWODWORDINTREE(0x4f800000,0x00000000)}}, + {VT_exponent,22,0x3a9010,{DOUBLEWITHTWODWORDINTREE(0x4f900000,0x00000000)}}, + {VT_exponent,22,0x3a9011,{DOUBLEWITHTWODWORDINTREE(0x4fa00000,0x00000000)}}, + {VT_exponent,22,0x3a9012,{DOUBLEWITHTWODWORDINTREE(0x4fb00000,0x00000000)}}, + {VT_exponent,22,0x3a9013,{DOUBLEWITHTWODWORDINTREE(0x4fc00000,0x00000000)}}, + {VT_exponent,22,0x3a9014,{DOUBLEWITHTWODWORDINTREE(0x4fd00000,0x00000000)}}, + {VT_exponent,22,0x3a9015,{DOUBLEWITHTWODWORDINTREE(0x4fe00000,0x00000000)}}, + {VT_exponent,22,0x3a9016,{DOUBLEWITHTWODWORDINTREE(0x4ff00000,0x00000000)}}, + {VT_exponent,22,0x3a9017,{DOUBLEWITHTWODWORDINTREE(0x50000000,0x00000000)}}, + {VT_exponent,22,0x3a9018,{DOUBLEWITHTWODWORDINTREE(0x50100000,0x00000000)}}, + {VT_exponent,22,0x3a9019,{DOUBLEWITHTWODWORDINTREE(0x50200000,0x00000000)}}, + {VT_exponent,22,0x3a901a,{DOUBLEWITHTWODWORDINTREE(0x50300000,0x00000000)}}, + {VT_exponent,22,0x3a901b,{DOUBLEWITHTWODWORDINTREE(0x50400000,0x00000000)}}, + {VT_exponent,22,0x3a901c,{DOUBLEWITHTWODWORDINTREE(0x50500000,0x00000000)}}, + {VT_exponent,22,0x3a901d,{DOUBLEWITHTWODWORDINTREE(0x50600000,0x00000000)}}, + {VT_exponent,22,0x3a901e,{DOUBLEWITHTWODWORDINTREE(0x50700000,0x00000000)}}, + {VT_exponent,22,0x3a901f,{DOUBLEWITHTWODWORDINTREE(0x50800000,0x00000000)}}, + {VT_exponent,22,0x3a9020,{DOUBLEWITHTWODWORDINTREE(0x50900000,0x00000000)}}, + {VT_exponent,22,0x3a9021,{DOUBLEWITHTWODWORDINTREE(0x50a00000,0x00000000)}}, + {VT_exponent,22,0x3a9022,{DOUBLEWITHTWODWORDINTREE(0x50b00000,0x00000000)}}, + {VT_exponent,22,0x3a9023,{DOUBLEWITHTWODWORDINTREE(0x50c00000,0x00000000)}}, + {VT_exponent,22,0x3a9024,{DOUBLEWITHTWODWORDINTREE(0x50d00000,0x00000000)}}, + {VT_exponent,22,0x3a9025,{DOUBLEWITHTWODWORDINTREE(0x50e00000,0x00000000)}}, + {VT_exponent,22,0x3a9026,{DOUBLEWITHTWODWORDINTREE(0x50f00000,0x00000000)}}, + {VT_exponent,22,0x3a9027,{DOUBLEWITHTWODWORDINTREE(0x51000000,0x00000000)}}, + {VT_exponent,22,0x3a9028,{DOUBLEWITHTWODWORDINTREE(0x51100000,0x00000000)}}, + {VT_exponent,22,0x3a9029,{DOUBLEWITHTWODWORDINTREE(0x51200000,0x00000000)}}, + {VT_exponent,22,0x3a902a,{DOUBLEWITHTWODWORDINTREE(0x51300000,0x00000000)}}, + {VT_exponent,22,0x3a902b,{DOUBLEWITHTWODWORDINTREE(0x51400000,0x00000000)}}, + {VT_exponent,22,0x3a902c,{DOUBLEWITHTWODWORDINTREE(0x51500000,0x00000000)}}, + {VT_exponent,22,0x3a902d,{DOUBLEWITHTWODWORDINTREE(0x51600000,0x00000000)}}, + {VT_exponent,22,0x3a902e,{DOUBLEWITHTWODWORDINTREE(0x51700000,0x00000000)}}, + {VT_exponent,22,0x3a902f,{DOUBLEWITHTWODWORDINTREE(0x51800000,0x00000000)}}, + {VT_exponent,22,0x3a9030,{DOUBLEWITHTWODWORDINTREE(0x51900000,0x00000000)}}, + {VT_exponent,22,0x3a9031,{DOUBLEWITHTWODWORDINTREE(0x51a00000,0x00000000)}}, + {VT_exponent,22,0x3a9032,{DOUBLEWITHTWODWORDINTREE(0x51b00000,0x00000000)}}, + {VT_exponent,22,0x3a9033,{DOUBLEWITHTWODWORDINTREE(0x51c00000,0x00000000)}}, + {VT_exponent,22,0x3a9034,{DOUBLEWITHTWODWORDINTREE(0x51d00000,0x00000000)}}, + {VT_exponent,22,0x3a9035,{DOUBLEWITHTWODWORDINTREE(0x51e00000,0x00000000)}}, + {VT_exponent,22,0x3a9036,{DOUBLEWITHTWODWORDINTREE(0x51f00000,0x00000000)}}, + {VT_exponent,22,0x3a9037,{DOUBLEWITHTWODWORDINTREE(0x52000000,0x00000000)}}, + {VT_exponent,22,0x3a9038,{DOUBLEWITHTWODWORDINTREE(0x52100000,0x00000000)}}, + {VT_exponent,22,0x3a9039,{DOUBLEWITHTWODWORDINTREE(0x52200000,0x00000000)}}, + {VT_exponent,22,0x3a903a,{DOUBLEWITHTWODWORDINTREE(0x52300000,0x00000000)}}, + {VT_exponent,22,0x3a903b,{DOUBLEWITHTWODWORDINTREE(0x52400000,0x00000000)}}, + {VT_exponent,22,0x3a903c,{DOUBLEWITHTWODWORDINTREE(0x52500000,0x00000000)}}, + {VT_exponent,22,0x3a903d,{DOUBLEWITHTWODWORDINTREE(0x52600000,0x00000000)}}, + {VT_exponent,22,0x3a903e,{DOUBLEWITHTWODWORDINTREE(0x52700000,0x00000000)}}, + {VT_exponent,22,0x3a903f,{DOUBLEWITHTWODWORDINTREE(0x52800000,0x00000000)}}, + {VT_exponent,22,0x3a9040,{DOUBLEWITHTWODWORDINTREE(0x52900000,0x00000000)}}, + {VT_exponent,22,0x3a9041,{DOUBLEWITHTWODWORDINTREE(0x52a00000,0x00000000)}}, + {VT_exponent,22,0x3a9042,{DOUBLEWITHTWODWORDINTREE(0x52b00000,0x00000000)}}, + {VT_exponent,22,0x3a9043,{DOUBLEWITHTWODWORDINTREE(0x52c00000,0x00000000)}}, + {VT_exponent,22,0x3a9044,{DOUBLEWITHTWODWORDINTREE(0x52d00000,0x00000000)}}, + {VT_exponent,22,0x3a9045,{DOUBLEWITHTWODWORDINTREE(0x52e00000,0x00000000)}}, + {VT_exponent,22,0x3a9046,{DOUBLEWITHTWODWORDINTREE(0x52f00000,0x00000000)}}, + {VT_exponent,22,0x3a9047,{DOUBLEWITHTWODWORDINTREE(0x53000000,0x00000000)}}, + {VT_exponent,22,0x3a9048,{DOUBLEWITHTWODWORDINTREE(0x53100000,0x00000000)}}, + {VT_exponent,22,0x3a9049,{DOUBLEWITHTWODWORDINTREE(0x53200000,0x00000000)}}, + {VT_exponent,22,0x3a904a,{DOUBLEWITHTWODWORDINTREE(0x53300000,0x00000000)}}, + {VT_exponent,22,0x3a904b,{DOUBLEWITHTWODWORDINTREE(0x53400000,0x00000000)}}, + {VT_exponent,22,0x3a904c,{DOUBLEWITHTWODWORDINTREE(0x53500000,0x00000000)}}, + {VT_exponent,22,0x3a904d,{DOUBLEWITHTWODWORDINTREE(0x53600000,0x00000000)}}, + {VT_exponent,22,0x3a904e,{DOUBLEWITHTWODWORDINTREE(0x53700000,0x00000000)}}, + {VT_exponent,22,0x3a904f,{DOUBLEWITHTWODWORDINTREE(0x53800000,0x00000000)}}, + {VT_exponent,22,0x3a9050,{DOUBLEWITHTWODWORDINTREE(0x53900000,0x00000000)}}, + {VT_exponent,22,0x3a9051,{DOUBLEWITHTWODWORDINTREE(0x53a00000,0x00000000)}}, + {VT_exponent,22,0x3a9052,{DOUBLEWITHTWODWORDINTREE(0x53b00000,0x00000000)}}, + {VT_exponent,22,0x3a9053,{DOUBLEWITHTWODWORDINTREE(0x53c00000,0x00000000)}}, + {VT_exponent,22,0x3a9054,{DOUBLEWITHTWODWORDINTREE(0x53d00000,0x00000000)}}, + {VT_exponent,22,0x3a9055,{DOUBLEWITHTWODWORDINTREE(0x53e00000,0x00000000)}}, + {VT_exponent,22,0x3a9056,{DOUBLEWITHTWODWORDINTREE(0x53f00000,0x00000000)}}, + {VT_exponent,22,0x3a9057,{DOUBLEWITHTWODWORDINTREE(0x54000000,0x00000000)}}, + {VT_exponent,22,0x3a9058,{DOUBLEWITHTWODWORDINTREE(0x54100000,0x00000000)}}, + {VT_exponent,22,0x3a9059,{DOUBLEWITHTWODWORDINTREE(0x54200000,0x00000000)}}, + {VT_exponent,22,0x3a905a,{DOUBLEWITHTWODWORDINTREE(0x54300000,0x00000000)}}, + {VT_exponent,22,0x3a905b,{DOUBLEWITHTWODWORDINTREE(0x54400000,0x00000000)}}, + {VT_exponent,22,0x3a905c,{DOUBLEWITHTWODWORDINTREE(0x54500000,0x00000000)}}, + {VT_exponent,22,0x3a905d,{DOUBLEWITHTWODWORDINTREE(0x54600000,0x00000000)}}, + {VT_exponent,22,0x3a905e,{DOUBLEWITHTWODWORDINTREE(0x54700000,0x00000000)}}, + {VT_exponent,22,0x3a905f,{DOUBLEWITHTWODWORDINTREE(0x54800000,0x00000000)}}, + {VT_exponent,22,0x3a9060,{DOUBLEWITHTWODWORDINTREE(0x54900000,0x00000000)}}, + {VT_exponent,22,0x3a9061,{DOUBLEWITHTWODWORDINTREE(0x54a00000,0x00000000)}}, + {VT_exponent,22,0x3a9062,{DOUBLEWITHTWODWORDINTREE(0x54b00000,0x00000000)}}, + {VT_exponent,22,0x3a9063,{DOUBLEWITHTWODWORDINTREE(0x54c00000,0x00000000)}}, + {VT_exponent,22,0x3a9064,{DOUBLEWITHTWODWORDINTREE(0x54d00000,0x00000000)}}, + {VT_exponent,22,0x3a9065,{DOUBLEWITHTWODWORDINTREE(0x54e00000,0x00000000)}}, + {VT_exponent,22,0x3a9066,{DOUBLEWITHTWODWORDINTREE(0x54f00000,0x00000000)}}, + {VT_exponent,22,0x3a9067,{DOUBLEWITHTWODWORDINTREE(0x55000000,0x00000000)}}, + {VT_exponent,22,0x3a9068,{DOUBLEWITHTWODWORDINTREE(0x55100000,0x00000000)}}, + {VT_exponent,22,0x3a9069,{DOUBLEWITHTWODWORDINTREE(0x55200000,0x00000000)}}, + {VT_exponent,22,0x3a906a,{DOUBLEWITHTWODWORDINTREE(0x55300000,0x00000000)}}, + {VT_exponent,22,0x3a906b,{DOUBLEWITHTWODWORDINTREE(0x55400000,0x00000000)}}, + {VT_exponent,22,0x3a906c,{DOUBLEWITHTWODWORDINTREE(0x55500000,0x00000000)}}, + {VT_exponent,22,0x3a906d,{DOUBLEWITHTWODWORDINTREE(0x55600000,0x00000000)}}, + {VT_exponent,22,0x3a906e,{DOUBLEWITHTWODWORDINTREE(0x55700000,0x00000000)}}, + {VT_exponent,22,0x3a906f,{DOUBLEWITHTWODWORDINTREE(0x55800000,0x00000000)}}, + {VT_exponent,22,0x3a9070,{DOUBLEWITHTWODWORDINTREE(0x55900000,0x00000000)}}, + {VT_exponent,22,0x3a9071,{DOUBLEWITHTWODWORDINTREE(0x55a00000,0x00000000)}}, + {VT_exponent,22,0x3a9072,{DOUBLEWITHTWODWORDINTREE(0x55b00000,0x00000000)}}, + {VT_exponent,22,0x3a9073,{DOUBLEWITHTWODWORDINTREE(0x55c00000,0x00000000)}}, + {VT_exponent,22,0x3a9074,{DOUBLEWITHTWODWORDINTREE(0x55d00000,0x00000000)}}, + {VT_exponent,22,0x3a9075,{DOUBLEWITHTWODWORDINTREE(0x55e00000,0x00000000)}}, + {VT_exponent,22,0x3a9076,{DOUBLEWITHTWODWORDINTREE(0x55f00000,0x00000000)}}, + {VT_exponent,22,0x3a9077,{DOUBLEWITHTWODWORDINTREE(0x56000000,0x00000000)}}, + {VT_exponent,22,0x3a9078,{DOUBLEWITHTWODWORDINTREE(0x56100000,0x00000000)}}, + {VT_exponent,22,0x3a9079,{DOUBLEWITHTWODWORDINTREE(0x56200000,0x00000000)}}, + {VT_exponent,22,0x3a907a,{DOUBLEWITHTWODWORDINTREE(0x56300000,0x00000000)}}, + {VT_exponent,22,0x3a907b,{DOUBLEWITHTWODWORDINTREE(0x56400000,0x00000000)}}, + {VT_exponent,22,0x3a907c,{DOUBLEWITHTWODWORDINTREE(0x56500000,0x00000000)}}, + {VT_exponent,22,0x3a907d,{DOUBLEWITHTWODWORDINTREE(0x56600000,0x00000000)}}, + {VT_exponent,22,0x3a907e,{DOUBLEWITHTWODWORDINTREE(0x56700000,0x00000000)}}, + {VT_exponent,22,0x3a907f,{DOUBLEWITHTWODWORDINTREE(0x56800000,0x00000000)}}, + {VT_exponent,22,0x3a9080,{DOUBLEWITHTWODWORDINTREE(0x56900000,0x00000000)}}, + {VT_exponent,22,0x3a9081,{DOUBLEWITHTWODWORDINTREE(0x56a00000,0x00000000)}}, + {VT_exponent,22,0x3a9082,{DOUBLEWITHTWODWORDINTREE(0x56b00000,0x00000000)}}, + {VT_exponent,22,0x3a9083,{DOUBLEWITHTWODWORDINTREE(0x56c00000,0x00000000)}}, + {VT_exponent,22,0x3a9084,{DOUBLEWITHTWODWORDINTREE(0x56d00000,0x00000000)}}, + {VT_exponent,22,0x3a9085,{DOUBLEWITHTWODWORDINTREE(0x56e00000,0x00000000)}}, + {VT_exponent,22,0x3a9086,{DOUBLEWITHTWODWORDINTREE(0x56f00000,0x00000000)}}, + {VT_exponent,22,0x3a9087,{DOUBLEWITHTWODWORDINTREE(0x57000000,0x00000000)}}, + {VT_exponent,22,0x3a9088,{DOUBLEWITHTWODWORDINTREE(0x57100000,0x00000000)}}, + {VT_exponent,22,0x3a9089,{DOUBLEWITHTWODWORDINTREE(0x57200000,0x00000000)}}, + {VT_exponent,22,0x3a908a,{DOUBLEWITHTWODWORDINTREE(0x57300000,0x00000000)}}, + {VT_exponent,22,0x3a908b,{DOUBLEWITHTWODWORDINTREE(0x57400000,0x00000000)}}, + {VT_exponent,22,0x3a908c,{DOUBLEWITHTWODWORDINTREE(0x57500000,0x00000000)}}, + {VT_exponent,22,0x3a908d,{DOUBLEWITHTWODWORDINTREE(0x57600000,0x00000000)}}, + {VT_exponent,22,0x3a908e,{DOUBLEWITHTWODWORDINTREE(0x57700000,0x00000000)}}, + {VT_exponent,22,0x3a908f,{DOUBLEWITHTWODWORDINTREE(0x57800000,0x00000000)}}, + {VT_exponent,22,0x3a9090,{DOUBLEWITHTWODWORDINTREE(0x57900000,0x00000000)}}, + {VT_exponent,22,0x3a9091,{DOUBLEWITHTWODWORDINTREE(0x57a00000,0x00000000)}}, + {VT_exponent,22,0x3a9092,{DOUBLEWITHTWODWORDINTREE(0x57b00000,0x00000000)}}, + {VT_exponent,22,0x3a9093,{DOUBLEWITHTWODWORDINTREE(0x57c00000,0x00000000)}}, + {VT_exponent,22,0x3a9094,{DOUBLEWITHTWODWORDINTREE(0x57d00000,0x00000000)}}, + {VT_exponent,22,0x3a9095,{DOUBLEWITHTWODWORDINTREE(0x57e00000,0x00000000)}}, + {VT_exponent,22,0x3a9096,{DOUBLEWITHTWODWORDINTREE(0x57f00000,0x00000000)}}, + {VT_exponent,22,0x3a9097,{DOUBLEWITHTWODWORDINTREE(0x58000000,0x00000000)}}, + {VT_exponent,22,0x3a9098,{DOUBLEWITHTWODWORDINTREE(0x58100000,0x00000000)}}, + {VT_exponent,22,0x3a9099,{DOUBLEWITHTWODWORDINTREE(0x58200000,0x00000000)}}, + {VT_exponent,22,0x3a909a,{DOUBLEWITHTWODWORDINTREE(0x58300000,0x00000000)}}, + {VT_exponent,22,0x3a909b,{DOUBLEWITHTWODWORDINTREE(0x58400000,0x00000000)}}, + {VT_exponent,22,0x3a909c,{DOUBLEWITHTWODWORDINTREE(0x58500000,0x00000000)}}, + {VT_exponent,22,0x3a909d,{DOUBLEWITHTWODWORDINTREE(0x58600000,0x00000000)}}, + {VT_exponent,22,0x3a909e,{DOUBLEWITHTWODWORDINTREE(0x58700000,0x00000000)}}, + {VT_exponent,22,0x3a909f,{DOUBLEWITHTWODWORDINTREE(0x58800000,0x00000000)}}, + {VT_exponent,22,0x3a90a0,{DOUBLEWITHTWODWORDINTREE(0x58900000,0x00000000)}}, + {VT_exponent,22,0x3a90a1,{DOUBLEWITHTWODWORDINTREE(0x58a00000,0x00000000)}}, + {VT_exponent,22,0x3a90a2,{DOUBLEWITHTWODWORDINTREE(0x58b00000,0x00000000)}}, + {VT_exponent,22,0x3a90a3,{DOUBLEWITHTWODWORDINTREE(0x58c00000,0x00000000)}}, + {VT_exponent,22,0x3a90a4,{DOUBLEWITHTWODWORDINTREE(0x58d00000,0x00000000)}}, + {VT_exponent,22,0x3a90a5,{DOUBLEWITHTWODWORDINTREE(0x58e00000,0x00000000)}}, + {VT_exponent,22,0x3a90a6,{DOUBLEWITHTWODWORDINTREE(0x58f00000,0x00000000)}}, + {VT_exponent,22,0x3a90a7,{DOUBLEWITHTWODWORDINTREE(0x59000000,0x00000000)}}, + {VT_exponent,22,0x3a90a8,{DOUBLEWITHTWODWORDINTREE(0x59100000,0x00000000)}}, + {VT_exponent,22,0x3a90a9,{DOUBLEWITHTWODWORDINTREE(0x59200000,0x00000000)}}, + {VT_exponent,22,0x3a90aa,{DOUBLEWITHTWODWORDINTREE(0x59300000,0x00000000)}}, + {VT_exponent,22,0x3a90ab,{DOUBLEWITHTWODWORDINTREE(0x59400000,0x00000000)}}, + {VT_exponent,22,0x3a90ac,{DOUBLEWITHTWODWORDINTREE(0x59500000,0x00000000)}}, + {VT_exponent,22,0x3a90ad,{DOUBLEWITHTWODWORDINTREE(0x59600000,0x00000000)}}, + {VT_exponent,22,0x3a90ae,{DOUBLEWITHTWODWORDINTREE(0x59700000,0x00000000)}}, + {VT_exponent,22,0x3a90af,{DOUBLEWITHTWODWORDINTREE(0x59800000,0x00000000)}}, + {VT_exponent,22,0x3a90b0,{DOUBLEWITHTWODWORDINTREE(0x59900000,0x00000000)}}, + {VT_exponent,22,0x3a90b1,{DOUBLEWITHTWODWORDINTREE(0x59a00000,0x00000000)}}, + {VT_exponent,22,0x3a90b2,{DOUBLEWITHTWODWORDINTREE(0x59b00000,0x00000000)}}, + {VT_exponent,22,0x3a90b3,{DOUBLEWITHTWODWORDINTREE(0x59c00000,0x00000000)}}, + {VT_exponent,22,0x3a90b4,{DOUBLEWITHTWODWORDINTREE(0x59d00000,0x00000000)}}, + {VT_exponent,22,0x3a90b5,{DOUBLEWITHTWODWORDINTREE(0x59e00000,0x00000000)}}, + {VT_exponent,22,0x3a90b6,{DOUBLEWITHTWODWORDINTREE(0x59f00000,0x00000000)}}, + {VT_exponent,22,0x3a90b7,{DOUBLEWITHTWODWORDINTREE(0x5a000000,0x00000000)}}, + {VT_exponent,22,0x3a90b8,{DOUBLEWITHTWODWORDINTREE(0x5a100000,0x00000000)}}, + {VT_exponent,22,0x3a90b9,{DOUBLEWITHTWODWORDINTREE(0x5a200000,0x00000000)}}, + {VT_exponent,22,0x3a90ba,{DOUBLEWITHTWODWORDINTREE(0x5a300000,0x00000000)}}, + {VT_exponent,22,0x3a90bb,{DOUBLEWITHTWODWORDINTREE(0x5a400000,0x00000000)}}, + {VT_exponent,22,0x3a90bc,{DOUBLEWITHTWODWORDINTREE(0x5a500000,0x00000000)}}, + {VT_exponent,22,0x3a90bd,{DOUBLEWITHTWODWORDINTREE(0x5a600000,0x00000000)}}, + {VT_exponent,22,0x3a90be,{DOUBLEWITHTWODWORDINTREE(0x5a700000,0x00000000)}}, + {VT_exponent,22,0x3a90bf,{DOUBLEWITHTWODWORDINTREE(0x5a800000,0x00000000)}}, + {VT_exponent,22,0x3a90c0,{DOUBLEWITHTWODWORDINTREE(0x5a900000,0x00000000)}}, + {VT_exponent,22,0x3a90c1,{DOUBLEWITHTWODWORDINTREE(0x5aa00000,0x00000000)}}, + {VT_exponent,22,0x3a90c2,{DOUBLEWITHTWODWORDINTREE(0x5ab00000,0x00000000)}}, + {VT_exponent,22,0x3a90c3,{DOUBLEWITHTWODWORDINTREE(0x5ac00000,0x00000000)}}, + {VT_exponent,22,0x3a90c4,{DOUBLEWITHTWODWORDINTREE(0x5ad00000,0x00000000)}}, + {VT_exponent,22,0x3a90c5,{DOUBLEWITHTWODWORDINTREE(0x5ae00000,0x00000000)}}, + {VT_exponent,22,0x3a90c6,{DOUBLEWITHTWODWORDINTREE(0x5af00000,0x00000000)}}, + {VT_exponent,22,0x3a90c7,{DOUBLEWITHTWODWORDINTREE(0x5b000000,0x00000000)}}, + {VT_exponent,22,0x3a90c8,{DOUBLEWITHTWODWORDINTREE(0x5b100000,0x00000000)}}, + {VT_exponent,22,0x3a90c9,{DOUBLEWITHTWODWORDINTREE(0x5b200000,0x00000000)}}, + {VT_exponent,22,0x3a90ca,{DOUBLEWITHTWODWORDINTREE(0x5b300000,0x00000000)}}, + {VT_exponent,22,0x3a90cb,{DOUBLEWITHTWODWORDINTREE(0x5b400000,0x00000000)}}, + {VT_exponent,22,0x3a90cc,{DOUBLEWITHTWODWORDINTREE(0x5b500000,0x00000000)}}, + {VT_exponent,22,0x3a90cd,{DOUBLEWITHTWODWORDINTREE(0x5b600000,0x00000000)}}, + {VT_exponent,22,0x3a90ce,{DOUBLEWITHTWODWORDINTREE(0x5b700000,0x00000000)}}, + {VT_exponent,22,0x3a90cf,{DOUBLEWITHTWODWORDINTREE(0x5b800000,0x00000000)}}, + {VT_exponent,22,0x3a90d0,{DOUBLEWITHTWODWORDINTREE(0x5b900000,0x00000000)}}, + {VT_exponent,22,0x3a90d1,{DOUBLEWITHTWODWORDINTREE(0x5ba00000,0x00000000)}}, + {VT_exponent,22,0x3a90d2,{DOUBLEWITHTWODWORDINTREE(0x5bb00000,0x00000000)}}, + {VT_exponent,22,0x3a90d3,{DOUBLEWITHTWODWORDINTREE(0x5bc00000,0x00000000)}}, + {VT_exponent,22,0x3a90d4,{DOUBLEWITHTWODWORDINTREE(0x5bd00000,0x00000000)}}, + {VT_exponent,22,0x3a90d5,{DOUBLEWITHTWODWORDINTREE(0x5be00000,0x00000000)}}, + {VT_exponent,22,0x3a90d6,{DOUBLEWITHTWODWORDINTREE(0x5bf00000,0x00000000)}}, + {VT_exponent,22,0x3a90d7,{DOUBLEWITHTWODWORDINTREE(0x5c000000,0x00000000)}}, + {VT_exponent,22,0x3a90d8,{DOUBLEWITHTWODWORDINTREE(0x5c100000,0x00000000)}}, + {VT_exponent,22,0x3a90d9,{DOUBLEWITHTWODWORDINTREE(0x5c200000,0x00000000)}}, + {VT_exponent,22,0x3a90da,{DOUBLEWITHTWODWORDINTREE(0x5c300000,0x00000000)}}, + {VT_exponent,22,0x3a90db,{DOUBLEWITHTWODWORDINTREE(0x5c400000,0x00000000)}}, + {VT_exponent,22,0x3a90dc,{DOUBLEWITHTWODWORDINTREE(0x5c500000,0x00000000)}}, + {VT_exponent,22,0x3a90dd,{DOUBLEWITHTWODWORDINTREE(0x5c600000,0x00000000)}}, + {VT_exponent,22,0x3a90de,{DOUBLEWITHTWODWORDINTREE(0x5c700000,0x00000000)}}, + {VT_exponent,22,0x3a90df,{DOUBLEWITHTWODWORDINTREE(0x5c800000,0x00000000)}}, + {VT_exponent,22,0x3a90e0,{DOUBLEWITHTWODWORDINTREE(0x5c900000,0x00000000)}}, + {VT_exponent,22,0x3a90e1,{DOUBLEWITHTWODWORDINTREE(0x5ca00000,0x00000000)}}, + {VT_exponent,22,0x3a90e2,{DOUBLEWITHTWODWORDINTREE(0x5cb00000,0x00000000)}}, + {VT_exponent,22,0x3a90e3,{DOUBLEWITHTWODWORDINTREE(0x5cc00000,0x00000000)}}, + {VT_exponent,22,0x3a90e4,{DOUBLEWITHTWODWORDINTREE(0x5cd00000,0x00000000)}}, + {VT_exponent,22,0x3a90e5,{DOUBLEWITHTWODWORDINTREE(0x5ce00000,0x00000000)}}, + {VT_exponent,22,0x3a90e6,{DOUBLEWITHTWODWORDINTREE(0x5cf00000,0x00000000)}}, + {VT_exponent,22,0x3a90e7,{DOUBLEWITHTWODWORDINTREE(0x5d000000,0x00000000)}}, + {VT_exponent,22,0x3a90e8,{DOUBLEWITHTWODWORDINTREE(0x5d100000,0x00000000)}}, + {VT_exponent,22,0x3a90e9,{DOUBLEWITHTWODWORDINTREE(0x5d200000,0x00000000)}}, + {VT_exponent,22,0x3a90ea,{DOUBLEWITHTWODWORDINTREE(0x5d300000,0x00000000)}}, + {VT_exponent,22,0x3a90eb,{DOUBLEWITHTWODWORDINTREE(0x5d400000,0x00000000)}}, + {VT_exponent,22,0x3a90ec,{DOUBLEWITHTWODWORDINTREE(0x5d500000,0x00000000)}}, + {VT_exponent,22,0x3a90ed,{DOUBLEWITHTWODWORDINTREE(0x5d600000,0x00000000)}}, + {VT_exponent,22,0x3a90ee,{DOUBLEWITHTWODWORDINTREE(0x5d700000,0x00000000)}}, + {VT_exponent,22,0x3a90ef,{DOUBLEWITHTWODWORDINTREE(0x5d800000,0x00000000)}}, + {VT_exponent,22,0x3a90f0,{DOUBLEWITHTWODWORDINTREE(0x5d900000,0x00000000)}}, + {VT_exponent,22,0x3a90f1,{DOUBLEWITHTWODWORDINTREE(0x5da00000,0x00000000)}}, + {VT_exponent,22,0x3a90f2,{DOUBLEWITHTWODWORDINTREE(0x5db00000,0x00000000)}}, + {VT_exponent,22,0x3a90f3,{DOUBLEWITHTWODWORDINTREE(0x5dc00000,0x00000000)}}, + {VT_exponent,22,0x3a90f4,{DOUBLEWITHTWODWORDINTREE(0x5dd00000,0x00000000)}}, + {VT_exponent,22,0x3a90f5,{DOUBLEWITHTWODWORDINTREE(0x5de00000,0x00000000)}}, + {VT_exponent,22,0x3a90f6,{DOUBLEWITHTWODWORDINTREE(0x5df00000,0x00000000)}}, + {VT_exponent,22,0x3a90f7,{DOUBLEWITHTWODWORDINTREE(0x5e000000,0x00000000)}}, + {VT_exponent,22,0x3a90f8,{DOUBLEWITHTWODWORDINTREE(0x5e100000,0x00000000)}}, + {VT_exponent,22,0x3a90f9,{DOUBLEWITHTWODWORDINTREE(0x5e200000,0x00000000)}}, + {VT_exponent,22,0x3a90fa,{DOUBLEWITHTWODWORDINTREE(0x5e300000,0x00000000)}}, + {VT_exponent,22,0x3a90fb,{DOUBLEWITHTWODWORDINTREE(0x5e400000,0x00000000)}}, + {VT_exponent,22,0x3a90fc,{DOUBLEWITHTWODWORDINTREE(0x5e500000,0x00000000)}}, + {VT_exponent,22,0x3a90fd,{DOUBLEWITHTWODWORDINTREE(0x5e600000,0x00000000)}}, + {VT_exponent,22,0x3a90fe,{DOUBLEWITHTWODWORDINTREE(0x5e700000,0x00000000)}}, + {VT_exponent,22,0x3a90ff,{DOUBLEWITHTWODWORDINTREE(0x5e800000,0x00000000)}}, + {VT_exponent,22,0x3a9100,{DOUBLEWITHTWODWORDINTREE(0x5e900000,0x00000000)}}, + {VT_exponent,22,0x3a9101,{DOUBLEWITHTWODWORDINTREE(0x5ea00000,0x00000000)}}, + {VT_exponent,22,0x3a9102,{DOUBLEWITHTWODWORDINTREE(0x5eb00000,0x00000000)}}, + {VT_exponent,22,0x3a9103,{DOUBLEWITHTWODWORDINTREE(0x5ec00000,0x00000000)}}, + {VT_exponent,22,0x3a9104,{DOUBLEWITHTWODWORDINTREE(0x5ed00000,0x00000000)}}, + {VT_exponent,22,0x3a9105,{DOUBLEWITHTWODWORDINTREE(0x5ee00000,0x00000000)}}, + {VT_exponent,22,0x3a9106,{DOUBLEWITHTWODWORDINTREE(0x5ef00000,0x00000000)}}, + {VT_exponent,22,0x3a9107,{DOUBLEWITHTWODWORDINTREE(0x5f000000,0x00000000)}}, + {VT_exponent,22,0x3a9108,{DOUBLEWITHTWODWORDINTREE(0x5f100000,0x00000000)}}, + {VT_exponent,22,0x3a9109,{DOUBLEWITHTWODWORDINTREE(0x5f200000,0x00000000)}}, + {VT_exponent,22,0x3a910a,{DOUBLEWITHTWODWORDINTREE(0x5f300000,0x00000000)}}, + {VT_exponent,22,0x3a910b,{DOUBLEWITHTWODWORDINTREE(0x5f400000,0x00000000)}}, + {VT_exponent,22,0x3a910c,{DOUBLEWITHTWODWORDINTREE(0x5f500000,0x00000000)}}, + {VT_exponent,22,0x3a910d,{DOUBLEWITHTWODWORDINTREE(0x5f600000,0x00000000)}}, + {VT_exponent,22,0x3a910e,{DOUBLEWITHTWODWORDINTREE(0x5f700000,0x00000000)}}, + {VT_exponent,22,0x3a910f,{DOUBLEWITHTWODWORDINTREE(0x5f800000,0x00000000)}}, + {VT_exponent,22,0x3a9110,{DOUBLEWITHTWODWORDINTREE(0x5f900000,0x00000000)}}, + {VT_exponent,22,0x3a9111,{DOUBLEWITHTWODWORDINTREE(0x5fa00000,0x00000000)}}, + {VT_exponent,22,0x3a9112,{DOUBLEWITHTWODWORDINTREE(0x5fb00000,0x00000000)}}, + {VT_exponent,22,0x3a9113,{DOUBLEWITHTWODWORDINTREE(0x5fc00000,0x00000000)}}, + {VT_exponent,22,0x3a9114,{DOUBLEWITHTWODWORDINTREE(0x5fd00000,0x00000000)}}, + {VT_exponent,22,0x3a9115,{DOUBLEWITHTWODWORDINTREE(0x5fe00000,0x00000000)}}, + {VT_exponent,22,0x3a9116,{DOUBLEWITHTWODWORDINTREE(0x5ff00000,0x00000000)}}, + {VT_exponent,22,0x3a9117,{DOUBLEWITHTWODWORDINTREE(0x60000000,0x00000000)}}, + {VT_exponent,22,0x3a9118,{DOUBLEWITHTWODWORDINTREE(0x60100000,0x00000000)}}, + {VT_exponent,22,0x3a9119,{DOUBLEWITHTWODWORDINTREE(0x60200000,0x00000000)}}, + {VT_exponent,22,0x3a911a,{DOUBLEWITHTWODWORDINTREE(0x60300000,0x00000000)}}, + {VT_exponent,22,0x3a911b,{DOUBLEWITHTWODWORDINTREE(0x60400000,0x00000000)}}, + {VT_exponent,22,0x3a911c,{DOUBLEWITHTWODWORDINTREE(0x60500000,0x00000000)}}, + {VT_exponent,22,0x3a911d,{DOUBLEWITHTWODWORDINTREE(0x60600000,0x00000000)}}, + {VT_exponent,22,0x3a911e,{DOUBLEWITHTWODWORDINTREE(0x60700000,0x00000000)}}, + {VT_exponent,22,0x3a911f,{DOUBLEWITHTWODWORDINTREE(0x60800000,0x00000000)}}, + {VT_exponent,22,0x3a9120,{DOUBLEWITHTWODWORDINTREE(0x60900000,0x00000000)}}, + {VT_exponent,22,0x3a9121,{DOUBLEWITHTWODWORDINTREE(0x60a00000,0x00000000)}}, + {VT_exponent,22,0x3a9122,{DOUBLEWITHTWODWORDINTREE(0x60b00000,0x00000000)}}, + {VT_exponent,22,0x3a9123,{DOUBLEWITHTWODWORDINTREE(0x60c00000,0x00000000)}}, + {VT_exponent,22,0x3a9124,{DOUBLEWITHTWODWORDINTREE(0x60d00000,0x00000000)}}, + {VT_exponent,22,0x3a9125,{DOUBLEWITHTWODWORDINTREE(0x60e00000,0x00000000)}}, + {VT_exponent,22,0x3a9126,{DOUBLEWITHTWODWORDINTREE(0x60f00000,0x00000000)}}, + {VT_exponent,22,0x3a9127,{DOUBLEWITHTWODWORDINTREE(0x61000000,0x00000000)}}, + {VT_exponent,22,0x3a9128,{DOUBLEWITHTWODWORDINTREE(0x61100000,0x00000000)}}, + {VT_exponent,22,0x3a9129,{DOUBLEWITHTWODWORDINTREE(0x61200000,0x00000000)}}, + {VT_exponent,22,0x3a912a,{DOUBLEWITHTWODWORDINTREE(0x61300000,0x00000000)}}, + {VT_exponent,22,0x3a912b,{DOUBLEWITHTWODWORDINTREE(0x61400000,0x00000000)}}, + {VT_exponent,22,0x3a912c,{DOUBLEWITHTWODWORDINTREE(0x61500000,0x00000000)}}, + {VT_exponent,22,0x3a912d,{DOUBLEWITHTWODWORDINTREE(0x61600000,0x00000000)}}, + {VT_exponent,22,0x3a912e,{DOUBLEWITHTWODWORDINTREE(0x61700000,0x00000000)}}, + {VT_exponent,22,0x3a912f,{DOUBLEWITHTWODWORDINTREE(0x61800000,0x00000000)}}, + {VT_exponent,22,0x3a9130,{DOUBLEWITHTWODWORDINTREE(0x61900000,0x00000000)}}, + {VT_exponent,22,0x3a9131,{DOUBLEWITHTWODWORDINTREE(0x61a00000,0x00000000)}}, + {VT_exponent,22,0x3a9132,{DOUBLEWITHTWODWORDINTREE(0x61b00000,0x00000000)}}, + {VT_exponent,22,0x3a9133,{DOUBLEWITHTWODWORDINTREE(0x61c00000,0x00000000)}}, + {VT_exponent,22,0x3a9134,{DOUBLEWITHTWODWORDINTREE(0x61d00000,0x00000000)}}, + {VT_exponent,22,0x3a9135,{DOUBLEWITHTWODWORDINTREE(0x61e00000,0x00000000)}}, + {VT_exponent,22,0x3a9136,{DOUBLEWITHTWODWORDINTREE(0x61f00000,0x00000000)}}, + {VT_exponent,22,0x3a9137,{DOUBLEWITHTWODWORDINTREE(0x62000000,0x00000000)}}, + {VT_exponent,22,0x3a9138,{DOUBLEWITHTWODWORDINTREE(0x62100000,0x00000000)}}, + {VT_exponent,22,0x3a9139,{DOUBLEWITHTWODWORDINTREE(0x62200000,0x00000000)}}, + {VT_exponent,22,0x3a913a,{DOUBLEWITHTWODWORDINTREE(0x62300000,0x00000000)}}, + {VT_exponent,22,0x3a913b,{DOUBLEWITHTWODWORDINTREE(0x62400000,0x00000000)}}, + {VT_exponent,22,0x3a913c,{DOUBLEWITHTWODWORDINTREE(0x62500000,0x00000000)}}, + {VT_exponent,22,0x3a913d,{DOUBLEWITHTWODWORDINTREE(0x62600000,0x00000000)}}, + {VT_exponent,22,0x3a913e,{DOUBLEWITHTWODWORDINTREE(0x62700000,0x00000000)}}, + {VT_exponent,22,0x3a913f,{DOUBLEWITHTWODWORDINTREE(0x62800000,0x00000000)}}, + {VT_exponent,22,0x3a9140,{DOUBLEWITHTWODWORDINTREE(0x62900000,0x00000000)}}, + {VT_exponent,22,0x3a9141,{DOUBLEWITHTWODWORDINTREE(0x62a00000,0x00000000)}}, + {VT_exponent,22,0x3a9142,{DOUBLEWITHTWODWORDINTREE(0x62b00000,0x00000000)}}, + {VT_exponent,22,0x3a9143,{DOUBLEWITHTWODWORDINTREE(0x62c00000,0x00000000)}}, + {VT_exponent,22,0x3a9144,{DOUBLEWITHTWODWORDINTREE(0x62d00000,0x00000000)}}, + {VT_exponent,22,0x3a9145,{DOUBLEWITHTWODWORDINTREE(0x62e00000,0x00000000)}}, + {VT_exponent,22,0x3a9146,{DOUBLEWITHTWODWORDINTREE(0x62f00000,0x00000000)}}, + {VT_exponent,22,0x3a9147,{DOUBLEWITHTWODWORDINTREE(0x63000000,0x00000000)}}, + {VT_exponent,22,0x3a9148,{DOUBLEWITHTWODWORDINTREE(0x63100000,0x00000000)}}, + {VT_exponent,22,0x3a9149,{DOUBLEWITHTWODWORDINTREE(0x63200000,0x00000000)}}, + {VT_exponent,22,0x3a914a,{DOUBLEWITHTWODWORDINTREE(0x63300000,0x00000000)}}, + {VT_exponent,22,0x3a914b,{DOUBLEWITHTWODWORDINTREE(0x63400000,0x00000000)}}, + {VT_exponent,22,0x3a914c,{DOUBLEWITHTWODWORDINTREE(0x63500000,0x00000000)}}, + {VT_exponent,22,0x3a914d,{DOUBLEWITHTWODWORDINTREE(0x63600000,0x00000000)}}, + {VT_exponent,22,0x3a914e,{DOUBLEWITHTWODWORDINTREE(0x63700000,0x00000000)}}, + {VT_exponent,22,0x3a914f,{DOUBLEWITHTWODWORDINTREE(0x63800000,0x00000000)}}, + {VT_exponent,22,0x3a9150,{DOUBLEWITHTWODWORDINTREE(0x63900000,0x00000000)}}, + {VT_exponent,22,0x3a9151,{DOUBLEWITHTWODWORDINTREE(0x63a00000,0x00000000)}}, + {VT_exponent,22,0x3a9152,{DOUBLEWITHTWODWORDINTREE(0x63b00000,0x00000000)}}, + {VT_exponent,22,0x3a9153,{DOUBLEWITHTWODWORDINTREE(0x63c00000,0x00000000)}}, + {VT_exponent,22,0x3a9154,{DOUBLEWITHTWODWORDINTREE(0x63d00000,0x00000000)}}, + {VT_exponent,22,0x3a9155,{DOUBLEWITHTWODWORDINTREE(0x63e00000,0x00000000)}}, + {VT_exponent,22,0x3a9156,{DOUBLEWITHTWODWORDINTREE(0x63f00000,0x00000000)}}, + {VT_exponent,22,0x3a9157,{DOUBLEWITHTWODWORDINTREE(0x64000000,0x00000000)}}, + {VT_exponent,22,0x3a9158,{DOUBLEWITHTWODWORDINTREE(0x64100000,0x00000000)}}, + {VT_exponent,22,0x3a9159,{DOUBLEWITHTWODWORDINTREE(0x64200000,0x00000000)}}, + {VT_exponent,22,0x3a915a,{DOUBLEWITHTWODWORDINTREE(0x64300000,0x00000000)}}, + {VT_exponent,22,0x3a915b,{DOUBLEWITHTWODWORDINTREE(0x64400000,0x00000000)}}, + {VT_exponent,22,0x3a915c,{DOUBLEWITHTWODWORDINTREE(0x64500000,0x00000000)}}, + {VT_exponent,22,0x3a915d,{DOUBLEWITHTWODWORDINTREE(0x64600000,0x00000000)}}, + {VT_exponent,22,0x3a915e,{DOUBLEWITHTWODWORDINTREE(0x64700000,0x00000000)}}, + {VT_exponent,22,0x3a915f,{DOUBLEWITHTWODWORDINTREE(0x64800000,0x00000000)}}, + {VT_exponent,22,0x3a9160,{DOUBLEWITHTWODWORDINTREE(0x64900000,0x00000000)}}, + {VT_exponent,22,0x3a9161,{DOUBLEWITHTWODWORDINTREE(0x64a00000,0x00000000)}}, + {VT_exponent,22,0x3a9162,{DOUBLEWITHTWODWORDINTREE(0x64b00000,0x00000000)}}, + {VT_exponent,22,0x3a9163,{DOUBLEWITHTWODWORDINTREE(0x64c00000,0x00000000)}}, + {VT_exponent,22,0x3a9164,{DOUBLEWITHTWODWORDINTREE(0x64d00000,0x00000000)}}, + {VT_exponent,22,0x3a9165,{DOUBLEWITHTWODWORDINTREE(0x64e00000,0x00000000)}}, + {VT_exponent,22,0x3a9166,{DOUBLEWITHTWODWORDINTREE(0x64f00000,0x00000000)}}, + {VT_exponent,22,0x3a9167,{DOUBLEWITHTWODWORDINTREE(0x65000000,0x00000000)}}, + {VT_exponent,22,0x3a9168,{DOUBLEWITHTWODWORDINTREE(0x65100000,0x00000000)}}, + {VT_exponent,22,0x3a9169,{DOUBLEWITHTWODWORDINTREE(0x65200000,0x00000000)}}, + {VT_exponent,22,0x3a916a,{DOUBLEWITHTWODWORDINTREE(0x65300000,0x00000000)}}, + {VT_exponent,22,0x3a916b,{DOUBLEWITHTWODWORDINTREE(0x65400000,0x00000000)}}, + {VT_exponent,22,0x3a916c,{DOUBLEWITHTWODWORDINTREE(0x65500000,0x00000000)}}, + {VT_exponent,22,0x3a916d,{DOUBLEWITHTWODWORDINTREE(0x65600000,0x00000000)}}, + {VT_exponent,22,0x3a916e,{DOUBLEWITHTWODWORDINTREE(0x65700000,0x00000000)}}, + {VT_exponent,22,0x3a916f,{DOUBLEWITHTWODWORDINTREE(0x65800000,0x00000000)}}, + {VT_exponent,22,0x3a9170,{DOUBLEWITHTWODWORDINTREE(0x65900000,0x00000000)}}, + {VT_exponent,22,0x3a9171,{DOUBLEWITHTWODWORDINTREE(0x65a00000,0x00000000)}}, + {VT_exponent,22,0x3a9172,{DOUBLEWITHTWODWORDINTREE(0x65b00000,0x00000000)}}, + {VT_exponent,22,0x3a9173,{DOUBLEWITHTWODWORDINTREE(0x65c00000,0x00000000)}}, + {VT_exponent,22,0x3a9174,{DOUBLEWITHTWODWORDINTREE(0x65d00000,0x00000000)}}, + {VT_exponent,22,0x3a9175,{DOUBLEWITHTWODWORDINTREE(0x65e00000,0x00000000)}}, + {VT_exponent,22,0x3a9176,{DOUBLEWITHTWODWORDINTREE(0x65f00000,0x00000000)}}, + {VT_exponent,22,0x3a9177,{DOUBLEWITHTWODWORDINTREE(0x66000000,0x00000000)}}, + {VT_exponent,22,0x3a9178,{DOUBLEWITHTWODWORDINTREE(0x66100000,0x00000000)}}, + {VT_exponent,22,0x3a9179,{DOUBLEWITHTWODWORDINTREE(0x66200000,0x00000000)}}, + {VT_exponent,22,0x3a917a,{DOUBLEWITHTWODWORDINTREE(0x66300000,0x00000000)}}, + {VT_exponent,22,0x3a917b,{DOUBLEWITHTWODWORDINTREE(0x66400000,0x00000000)}}, + {VT_exponent,22,0x3a917c,{DOUBLEWITHTWODWORDINTREE(0x66500000,0x00000000)}}, + {VT_exponent,22,0x3a917d,{DOUBLEWITHTWODWORDINTREE(0x66600000,0x00000000)}}, + {VT_exponent,22,0x3a917e,{DOUBLEWITHTWODWORDINTREE(0x66700000,0x00000000)}}, + {VT_exponent,22,0x3a917f,{DOUBLEWITHTWODWORDINTREE(0x66800000,0x00000000)}}, + {VT_exponent,22,0x3a9180,{DOUBLEWITHTWODWORDINTREE(0x66900000,0x00000000)}}, + {VT_exponent,22,0x3a9181,{DOUBLEWITHTWODWORDINTREE(0x66a00000,0x00000000)}}, + {VT_exponent,22,0x3a9182,{DOUBLEWITHTWODWORDINTREE(0x66b00000,0x00000000)}}, + {VT_exponent,22,0x3a9183,{DOUBLEWITHTWODWORDINTREE(0x66c00000,0x00000000)}}, + {VT_exponent,22,0x3a9184,{DOUBLEWITHTWODWORDINTREE(0x66d00000,0x00000000)}}, + {VT_exponent,22,0x3a9185,{DOUBLEWITHTWODWORDINTREE(0x66e00000,0x00000000)}}, + {VT_exponent,22,0x3a9186,{DOUBLEWITHTWODWORDINTREE(0x66f00000,0x00000000)}}, + {VT_exponent,22,0x3a9187,{DOUBLEWITHTWODWORDINTREE(0x67000000,0x00000000)}}, + {VT_exponent,22,0x3a9188,{DOUBLEWITHTWODWORDINTREE(0x67100000,0x00000000)}}, + {VT_exponent,22,0x3a9189,{DOUBLEWITHTWODWORDINTREE(0x67200000,0x00000000)}}, + {VT_exponent,22,0x3a918a,{DOUBLEWITHTWODWORDINTREE(0x67300000,0x00000000)}}, + {VT_exponent,22,0x3a918b,{DOUBLEWITHTWODWORDINTREE(0x67400000,0x00000000)}}, + {VT_exponent,22,0x3a918c,{DOUBLEWITHTWODWORDINTREE(0x67500000,0x00000000)}}, + {VT_exponent,22,0x3a918d,{DOUBLEWITHTWODWORDINTREE(0x67600000,0x00000000)}}, + {VT_exponent,22,0x3a918e,{DOUBLEWITHTWODWORDINTREE(0x67700000,0x00000000)}}, + {VT_exponent,22,0x3a918f,{DOUBLEWITHTWODWORDINTREE(0x67800000,0x00000000)}}, + {VT_exponent,22,0x3a9190,{DOUBLEWITHTWODWORDINTREE(0x67900000,0x00000000)}}, + {VT_exponent,22,0x3a9191,{DOUBLEWITHTWODWORDINTREE(0x67a00000,0x00000000)}}, + {VT_exponent,22,0x3a9192,{DOUBLEWITHTWODWORDINTREE(0x67b00000,0x00000000)}}, + {VT_exponent,22,0x3a9193,{DOUBLEWITHTWODWORDINTREE(0x67c00000,0x00000000)}}, + {VT_exponent,22,0x3a9194,{DOUBLEWITHTWODWORDINTREE(0x67d00000,0x00000000)}}, + {VT_exponent,22,0x3a9195,{DOUBLEWITHTWODWORDINTREE(0x67e00000,0x00000000)}}, + {VT_exponent,22,0x3a9196,{DOUBLEWITHTWODWORDINTREE(0x67f00000,0x00000000)}}, + {VT_exponent,22,0x3a9197,{DOUBLEWITHTWODWORDINTREE(0x68000000,0x00000000)}}, + {VT_exponent,22,0x3a9198,{DOUBLEWITHTWODWORDINTREE(0x68100000,0x00000000)}}, + {VT_exponent,22,0x3a9199,{DOUBLEWITHTWODWORDINTREE(0x68200000,0x00000000)}}, + {VT_exponent,22,0x3a919a,{DOUBLEWITHTWODWORDINTREE(0x68300000,0x00000000)}}, + {VT_exponent,22,0x3a919b,{DOUBLEWITHTWODWORDINTREE(0x68400000,0x00000000)}}, + {VT_exponent,22,0x3a919c,{DOUBLEWITHTWODWORDINTREE(0x68500000,0x00000000)}}, + {VT_exponent,22,0x3a919d,{DOUBLEWITHTWODWORDINTREE(0x68600000,0x00000000)}}, + {VT_exponent,22,0x3a919e,{DOUBLEWITHTWODWORDINTREE(0x68700000,0x00000000)}}, + {VT_exponent,22,0x3a919f,{DOUBLEWITHTWODWORDINTREE(0x68800000,0x00000000)}}, + {VT_exponent,22,0x3a91a0,{DOUBLEWITHTWODWORDINTREE(0x68900000,0x00000000)}}, + {VT_exponent,22,0x3a91a1,{DOUBLEWITHTWODWORDINTREE(0x68a00000,0x00000000)}}, + {VT_exponent,22,0x3a91a2,{DOUBLEWITHTWODWORDINTREE(0x68b00000,0x00000000)}}, + {VT_exponent,22,0x3a91a3,{DOUBLEWITHTWODWORDINTREE(0x68c00000,0x00000000)}}, + {VT_exponent,22,0x3a91a4,{DOUBLEWITHTWODWORDINTREE(0x68d00000,0x00000000)}}, + {VT_exponent,22,0x3a91a5,{DOUBLEWITHTWODWORDINTREE(0x68e00000,0x00000000)}}, + {VT_exponent,22,0x3a91a6,{DOUBLEWITHTWODWORDINTREE(0x68f00000,0x00000000)}}, + {VT_exponent,22,0x3a91a7,{DOUBLEWITHTWODWORDINTREE(0x69000000,0x00000000)}}, + {VT_exponent,22,0x3a91a8,{DOUBLEWITHTWODWORDINTREE(0x69100000,0x00000000)}}, + {VT_exponent,22,0x3a91a9,{DOUBLEWITHTWODWORDINTREE(0x69200000,0x00000000)}}, + {VT_exponent,22,0x3a91aa,{DOUBLEWITHTWODWORDINTREE(0x69300000,0x00000000)}}, + {VT_exponent,22,0x3a91ab,{DOUBLEWITHTWODWORDINTREE(0x69400000,0x00000000)}}, + {VT_exponent,22,0x3a91ac,{DOUBLEWITHTWODWORDINTREE(0x69500000,0x00000000)}}, + {VT_exponent,22,0x3a91ad,{DOUBLEWITHTWODWORDINTREE(0x69600000,0x00000000)}}, + {VT_exponent,22,0x3a91ae,{DOUBLEWITHTWODWORDINTREE(0x69700000,0x00000000)}}, + {VT_exponent,22,0x3a91af,{DOUBLEWITHTWODWORDINTREE(0x69800000,0x00000000)}}, + {VT_exponent,22,0x3a91b0,{DOUBLEWITHTWODWORDINTREE(0x69900000,0x00000000)}}, + {VT_exponent,22,0x3a91b1,{DOUBLEWITHTWODWORDINTREE(0x69a00000,0x00000000)}}, + {VT_exponent,22,0x3a91b2,{DOUBLEWITHTWODWORDINTREE(0x69b00000,0x00000000)}}, + {VT_exponent,22,0x3a91b3,{DOUBLEWITHTWODWORDINTREE(0x69c00000,0x00000000)}}, + {VT_exponent,22,0x3a91b4,{DOUBLEWITHTWODWORDINTREE(0x69d00000,0x00000000)}}, + {VT_exponent,22,0x3a91b5,{DOUBLEWITHTWODWORDINTREE(0x69e00000,0x00000000)}}, + {VT_exponent,22,0x3a91b6,{DOUBLEWITHTWODWORDINTREE(0x69f00000,0x00000000)}}, + {VT_exponent,22,0x3a91b7,{DOUBLEWITHTWODWORDINTREE(0x6a000000,0x00000000)}}, + {VT_exponent,22,0x3a91b8,{DOUBLEWITHTWODWORDINTREE(0x6a100000,0x00000000)}}, + {VT_exponent,22,0x3a91b9,{DOUBLEWITHTWODWORDINTREE(0x6a200000,0x00000000)}}, + {VT_exponent,22,0x3a91ba,{DOUBLEWITHTWODWORDINTREE(0x6a300000,0x00000000)}}, + {VT_exponent,22,0x3a91bb,{DOUBLEWITHTWODWORDINTREE(0x6a400000,0x00000000)}}, + {VT_exponent,22,0x3a91bc,{DOUBLEWITHTWODWORDINTREE(0x6a500000,0x00000000)}}, + {VT_exponent,22,0x3a91bd,{DOUBLEWITHTWODWORDINTREE(0x6a600000,0x00000000)}}, + {VT_exponent,22,0x3a91be,{DOUBLEWITHTWODWORDINTREE(0x6a700000,0x00000000)}}, + {VT_exponent,22,0x3a91bf,{DOUBLEWITHTWODWORDINTREE(0x6a800000,0x00000000)}}, + {VT_exponent,22,0x3a91c0,{DOUBLEWITHTWODWORDINTREE(0x6a900000,0x00000000)}}, + {VT_exponent,22,0x3a91c1,{DOUBLEWITHTWODWORDINTREE(0x6aa00000,0x00000000)}}, + {VT_exponent,22,0x3a91c2,{DOUBLEWITHTWODWORDINTREE(0x6ab00000,0x00000000)}}, + {VT_exponent,22,0x3a91c3,{DOUBLEWITHTWODWORDINTREE(0x6ac00000,0x00000000)}}, + {VT_exponent,22,0x3a91c4,{DOUBLEWITHTWODWORDINTREE(0x6ad00000,0x00000000)}}, + {VT_exponent,22,0x3a91c5,{DOUBLEWITHTWODWORDINTREE(0x6ae00000,0x00000000)}}, + {VT_exponent,22,0x3a91c6,{DOUBLEWITHTWODWORDINTREE(0x6af00000,0x00000000)}}, + {VT_exponent,22,0x3a91c7,{DOUBLEWITHTWODWORDINTREE(0x6b000000,0x00000000)}}, + {VT_exponent,22,0x3a91c8,{DOUBLEWITHTWODWORDINTREE(0x6b100000,0x00000000)}}, + {VT_exponent,22,0x3a91c9,{DOUBLEWITHTWODWORDINTREE(0x6b200000,0x00000000)}}, + {VT_exponent,22,0x3a91ca,{DOUBLEWITHTWODWORDINTREE(0x6b300000,0x00000000)}}, + {VT_exponent,22,0x3a91cb,{DOUBLEWITHTWODWORDINTREE(0x6b400000,0x00000000)}}, + {VT_exponent,22,0x3a91cc,{DOUBLEWITHTWODWORDINTREE(0x6b500000,0x00000000)}}, + {VT_exponent,22,0x3a91cd,{DOUBLEWITHTWODWORDINTREE(0x6b600000,0x00000000)}}, + {VT_exponent,22,0x3a91ce,{DOUBLEWITHTWODWORDINTREE(0x6b700000,0x00000000)}}, + {VT_exponent,22,0x3a91cf,{DOUBLEWITHTWODWORDINTREE(0x6b800000,0x00000000)}}, + {VT_exponent,22,0x3a91d0,{DOUBLEWITHTWODWORDINTREE(0x6b900000,0x00000000)}}, + {VT_exponent,22,0x3a91d1,{DOUBLEWITHTWODWORDINTREE(0x6ba00000,0x00000000)}}, + {VT_exponent,22,0x3a91d2,{DOUBLEWITHTWODWORDINTREE(0x6bb00000,0x00000000)}}, + {VT_exponent,22,0x3a91d3,{DOUBLEWITHTWODWORDINTREE(0x6bc00000,0x00000000)}}, + {VT_exponent,22,0x3a91d4,{DOUBLEWITHTWODWORDINTREE(0x6bd00000,0x00000000)}}, + {VT_exponent,22,0x3a91d5,{DOUBLEWITHTWODWORDINTREE(0x6be00000,0x00000000)}}, + {VT_exponent,22,0x3a91d6,{DOUBLEWITHTWODWORDINTREE(0x6bf00000,0x00000000)}}, + {VT_exponent,22,0x3a91d7,{DOUBLEWITHTWODWORDINTREE(0x6c000000,0x00000000)}}, + {VT_exponent,22,0x3a91d8,{DOUBLEWITHTWODWORDINTREE(0x6c100000,0x00000000)}}, + {VT_exponent,22,0x3a91d9,{DOUBLEWITHTWODWORDINTREE(0x6c200000,0x00000000)}}, + {VT_exponent,22,0x3a91da,{DOUBLEWITHTWODWORDINTREE(0x6c300000,0x00000000)}}, + {VT_exponent,22,0x3a91db,{DOUBLEWITHTWODWORDINTREE(0x6c400000,0x00000000)}}, + {VT_exponent,22,0x3a91dc,{DOUBLEWITHTWODWORDINTREE(0x6c500000,0x00000000)}}, + {VT_exponent,22,0x3a91dd,{DOUBLEWITHTWODWORDINTREE(0x6c600000,0x00000000)}}, + {VT_exponent,22,0x3a91de,{DOUBLEWITHTWODWORDINTREE(0x6c700000,0x00000000)}}, + {VT_exponent,22,0x3a91df,{DOUBLEWITHTWODWORDINTREE(0x6c800000,0x00000000)}}, + {VT_exponent,22,0x3a91e0,{DOUBLEWITHTWODWORDINTREE(0x6c900000,0x00000000)}}, + {VT_exponent,22,0x3a91e1,{DOUBLEWITHTWODWORDINTREE(0x6ca00000,0x00000000)}}, + {VT_exponent,22,0x3a91e2,{DOUBLEWITHTWODWORDINTREE(0x6cb00000,0x00000000)}}, + {VT_exponent,22,0x3a91e3,{DOUBLEWITHTWODWORDINTREE(0x6cc00000,0x00000000)}}, + {VT_exponent,22,0x3a91e4,{DOUBLEWITHTWODWORDINTREE(0x6cd00000,0x00000000)}}, + {VT_exponent,22,0x3a91e5,{DOUBLEWITHTWODWORDINTREE(0x6ce00000,0x00000000)}}, + {VT_exponent,22,0x3a91e6,{DOUBLEWITHTWODWORDINTREE(0x6cf00000,0x00000000)}}, + {VT_exponent,22,0x3a91e7,{DOUBLEWITHTWODWORDINTREE(0x6d000000,0x00000000)}}, + {VT_exponent,22,0x3a91e8,{DOUBLEWITHTWODWORDINTREE(0x6d100000,0x00000000)}}, + {VT_exponent,22,0x3a91e9,{DOUBLEWITHTWODWORDINTREE(0x6d200000,0x00000000)}}, + {VT_exponent,22,0x3a91ea,{DOUBLEWITHTWODWORDINTREE(0x6d300000,0x00000000)}}, + {VT_exponent,22,0x3a91eb,{DOUBLEWITHTWODWORDINTREE(0x6d400000,0x00000000)}}, + {VT_exponent,22,0x3a91ec,{DOUBLEWITHTWODWORDINTREE(0x6d500000,0x00000000)}}, + {VT_exponent,22,0x3a91ed,{DOUBLEWITHTWODWORDINTREE(0x6d600000,0x00000000)}}, + {VT_exponent,22,0x3a91ee,{DOUBLEWITHTWODWORDINTREE(0x6d700000,0x00000000)}}, + {VT_exponent,22,0x3a91ef,{DOUBLEWITHTWODWORDINTREE(0x6d800000,0x00000000)}}, + {VT_exponent,22,0x3a91f0,{DOUBLEWITHTWODWORDINTREE(0x6d900000,0x00000000)}}, + {VT_exponent,22,0x3a91f1,{DOUBLEWITHTWODWORDINTREE(0x6da00000,0x00000000)}}, + {VT_exponent,22,0x3a91f2,{DOUBLEWITHTWODWORDINTREE(0x6db00000,0x00000000)}}, + {VT_exponent,22,0x3a91f3,{DOUBLEWITHTWODWORDINTREE(0x6dc00000,0x00000000)}}, + {VT_exponent,22,0x3a91f4,{DOUBLEWITHTWODWORDINTREE(0x6dd00000,0x00000000)}}, + {VT_exponent,22,0x3a91f5,{DOUBLEWITHTWODWORDINTREE(0x6de00000,0x00000000)}}, + {VT_exponent,22,0x3a91f6,{DOUBLEWITHTWODWORDINTREE(0x6df00000,0x00000000)}}, + {VT_exponent,22,0x3a91f7,{DOUBLEWITHTWODWORDINTREE(0x6e000000,0x00000000)}}, + {VT_exponent,22,0x3a91f8,{DOUBLEWITHTWODWORDINTREE(0x6e100000,0x00000000)}}, + {VT_exponent,22,0x3a91f9,{DOUBLEWITHTWODWORDINTREE(0x6e200000,0x00000000)}}, + {VT_exponent,22,0x3a91fa,{DOUBLEWITHTWODWORDINTREE(0x6e300000,0x00000000)}}, + {VT_exponent,22,0x3a91fb,{DOUBLEWITHTWODWORDINTREE(0x6e400000,0x00000000)}}, + {VT_exponent,22,0x3a91fc,{DOUBLEWITHTWODWORDINTREE(0x6e500000,0x00000000)}}, + {VT_exponent,22,0x3a91fd,{DOUBLEWITHTWODWORDINTREE(0x6e600000,0x00000000)}}, + {VT_exponent,22,0x3a91fe,{DOUBLEWITHTWODWORDINTREE(0x6e700000,0x00000000)}}, + {VT_exponent,22,0x3a91ff,{DOUBLEWITHTWODWORDINTREE(0x6e800000,0x00000000)}}, + {VT_exponent,22,0x3a9200,{DOUBLEWITHTWODWORDINTREE(0x6e900000,0x00000000)}}, + {VT_exponent,22,0x3a9201,{DOUBLEWITHTWODWORDINTREE(0x6ea00000,0x00000000)}}, + {VT_exponent,22,0x3a9202,{DOUBLEWITHTWODWORDINTREE(0x6eb00000,0x00000000)}}, + {VT_exponent,22,0x3a9203,{DOUBLEWITHTWODWORDINTREE(0x6ec00000,0x00000000)}}, + {VT_exponent,22,0x3a9204,{DOUBLEWITHTWODWORDINTREE(0x6ed00000,0x00000000)}}, + {VT_exponent,22,0x3a9205,{DOUBLEWITHTWODWORDINTREE(0x6ee00000,0x00000000)}}, + {VT_exponent,22,0x3a9206,{DOUBLEWITHTWODWORDINTREE(0x6ef00000,0x00000000)}}, + {VT_exponent,22,0x3a9207,{DOUBLEWITHTWODWORDINTREE(0x6f000000,0x00000000)}}, + {VT_exponent,22,0x3a9208,{DOUBLEWITHTWODWORDINTREE(0x6f100000,0x00000000)}}, + {VT_exponent,22,0x3a9209,{DOUBLEWITHTWODWORDINTREE(0x6f200000,0x00000000)}}, + {VT_exponent,22,0x3a920a,{DOUBLEWITHTWODWORDINTREE(0x6f300000,0x00000000)}}, + {VT_exponent,22,0x3a920b,{DOUBLEWITHTWODWORDINTREE(0x6f400000,0x00000000)}}, + {VT_exponent,22,0x3a920c,{DOUBLEWITHTWODWORDINTREE(0x6f500000,0x00000000)}}, + {VT_exponent,22,0x3a920d,{DOUBLEWITHTWODWORDINTREE(0x6f600000,0x00000000)}}, + {VT_exponent,22,0x3a920e,{DOUBLEWITHTWODWORDINTREE(0x6f700000,0x00000000)}}, + {VT_exponent,22,0x3a920f,{DOUBLEWITHTWODWORDINTREE(0x6f800000,0x00000000)}}, + {VT_exponent,22,0x3a9210,{DOUBLEWITHTWODWORDINTREE(0x6f900000,0x00000000)}}, + {VT_exponent,22,0x3a9211,{DOUBLEWITHTWODWORDINTREE(0x6fa00000,0x00000000)}}, + {VT_exponent,22,0x3a9212,{DOUBLEWITHTWODWORDINTREE(0x6fb00000,0x00000000)}}, + {VT_exponent,22,0x3a9213,{DOUBLEWITHTWODWORDINTREE(0x6fc00000,0x00000000)}}, + {VT_exponent,22,0x3a9214,{DOUBLEWITHTWODWORDINTREE(0x6fd00000,0x00000000)}}, + {VT_exponent,22,0x3a9215,{DOUBLEWITHTWODWORDINTREE(0x6fe00000,0x00000000)}}, + {VT_exponent,22,0x3a9216,{DOUBLEWITHTWODWORDINTREE(0x6ff00000,0x00000000)}}, + {VT_exponent,22,0x3a9217,{DOUBLEWITHTWODWORDINTREE(0x70000000,0x00000000)}}, + {VT_exponent,22,0x3a9218,{DOUBLEWITHTWODWORDINTREE(0x70100000,0x00000000)}}, + {VT_exponent,22,0x3a9219,{DOUBLEWITHTWODWORDINTREE(0x70200000,0x00000000)}}, + {VT_exponent,22,0x3a921a,{DOUBLEWITHTWODWORDINTREE(0x70300000,0x00000000)}}, + {VT_exponent,22,0x3a921b,{DOUBLEWITHTWODWORDINTREE(0x70400000,0x00000000)}}, + {VT_exponent,22,0x3a921c,{DOUBLEWITHTWODWORDINTREE(0x70500000,0x00000000)}}, + {VT_exponent,22,0x3a921d,{DOUBLEWITHTWODWORDINTREE(0x70600000,0x00000000)}}, + {VT_exponent,22,0x3a921e,{DOUBLEWITHTWODWORDINTREE(0x70700000,0x00000000)}}, + {VT_exponent,22,0x3a921f,{DOUBLEWITHTWODWORDINTREE(0x70800000,0x00000000)}}, + {VT_exponent,22,0x3a9220,{DOUBLEWITHTWODWORDINTREE(0x70900000,0x00000000)}}, + {VT_exponent,22,0x3a9221,{DOUBLEWITHTWODWORDINTREE(0x70a00000,0x00000000)}}, + {VT_exponent,22,0x3a9222,{DOUBLEWITHTWODWORDINTREE(0x70b00000,0x00000000)}}, + {VT_exponent,22,0x3a9223,{DOUBLEWITHTWODWORDINTREE(0x70c00000,0x00000000)}}, + {VT_exponent,22,0x3a9224,{DOUBLEWITHTWODWORDINTREE(0x70d00000,0x00000000)}}, + {VT_exponent,22,0x3a9225,{DOUBLEWITHTWODWORDINTREE(0x70e00000,0x00000000)}}, + {VT_exponent,22,0x3a9226,{DOUBLEWITHTWODWORDINTREE(0x70f00000,0x00000000)}}, + {VT_exponent,22,0x3a9227,{DOUBLEWITHTWODWORDINTREE(0x71000000,0x00000000)}}, + {VT_exponent,22,0x3a9228,{DOUBLEWITHTWODWORDINTREE(0x71100000,0x00000000)}}, + {VT_exponent,22,0x3a9229,{DOUBLEWITHTWODWORDINTREE(0x71200000,0x00000000)}}, + {VT_exponent,22,0x3a922a,{DOUBLEWITHTWODWORDINTREE(0x71300000,0x00000000)}}, + {VT_exponent,22,0x3a922b,{DOUBLEWITHTWODWORDINTREE(0x71400000,0x00000000)}}, + {VT_exponent,22,0x3a922c,{DOUBLEWITHTWODWORDINTREE(0x71500000,0x00000000)}}, + {VT_exponent,22,0x3a922d,{DOUBLEWITHTWODWORDINTREE(0x71600000,0x00000000)}}, + {VT_exponent,22,0x3a922e,{DOUBLEWITHTWODWORDINTREE(0x71700000,0x00000000)}}, + {VT_exponent,22,0x3a922f,{DOUBLEWITHTWODWORDINTREE(0x71800000,0x00000000)}}, + {VT_exponent,22,0x3a9230,{DOUBLEWITHTWODWORDINTREE(0x71900000,0x00000000)}}, + {VT_exponent,22,0x3a9231,{DOUBLEWITHTWODWORDINTREE(0x71a00000,0x00000000)}}, + {VT_exponent,22,0x3a9232,{DOUBLEWITHTWODWORDINTREE(0x71b00000,0x00000000)}}, + {VT_exponent,22,0x3a9233,{DOUBLEWITHTWODWORDINTREE(0x71c00000,0x00000000)}}, + {VT_exponent,22,0x3a9234,{DOUBLEWITHTWODWORDINTREE(0x71d00000,0x00000000)}}, + {VT_exponent,22,0x3a9235,{DOUBLEWITHTWODWORDINTREE(0x71e00000,0x00000000)}}, + {VT_exponent,22,0x3a9236,{DOUBLEWITHTWODWORDINTREE(0x71f00000,0x00000000)}}, + {VT_exponent,22,0x3a9237,{DOUBLEWITHTWODWORDINTREE(0x72000000,0x00000000)}}, + {VT_exponent,22,0x3a9238,{DOUBLEWITHTWODWORDINTREE(0x72100000,0x00000000)}}, + {VT_exponent,22,0x3a9239,{DOUBLEWITHTWODWORDINTREE(0x72200000,0x00000000)}}, + {VT_exponent,22,0x3a923a,{DOUBLEWITHTWODWORDINTREE(0x72300000,0x00000000)}}, + {VT_exponent,22,0x3a923b,{DOUBLEWITHTWODWORDINTREE(0x72400000,0x00000000)}}, + {VT_exponent,22,0x3a923c,{DOUBLEWITHTWODWORDINTREE(0x72500000,0x00000000)}}, + {VT_exponent,22,0x3a923d,{DOUBLEWITHTWODWORDINTREE(0x72600000,0x00000000)}}, + {VT_exponent,22,0x3a923e,{DOUBLEWITHTWODWORDINTREE(0x72700000,0x00000000)}}, + {VT_exponent,22,0x3a923f,{DOUBLEWITHTWODWORDINTREE(0x72800000,0x00000000)}}, + {VT_exponent,22,0x3a9240,{DOUBLEWITHTWODWORDINTREE(0x72900000,0x00000000)}}, + {VT_exponent,22,0x3a9241,{DOUBLEWITHTWODWORDINTREE(0x72a00000,0x00000000)}}, + {VT_exponent,22,0x3a9242,{DOUBLEWITHTWODWORDINTREE(0x72b00000,0x00000000)}}, + {VT_exponent,22,0x3a9243,{DOUBLEWITHTWODWORDINTREE(0x72c00000,0x00000000)}}, + {VT_exponent,22,0x3a9244,{DOUBLEWITHTWODWORDINTREE(0x72d00000,0x00000000)}}, + {VT_exponent,22,0x3a9245,{DOUBLEWITHTWODWORDINTREE(0x72e00000,0x00000000)}}, + {VT_exponent,22,0x3a9246,{DOUBLEWITHTWODWORDINTREE(0x72f00000,0x00000000)}}, + {VT_exponent,22,0x3a9247,{DOUBLEWITHTWODWORDINTREE(0x73000000,0x00000000)}}, + {VT_exponent,22,0x3a9248,{DOUBLEWITHTWODWORDINTREE(0x73100000,0x00000000)}}, + {VT_exponent,22,0x3a9249,{DOUBLEWITHTWODWORDINTREE(0x73200000,0x00000000)}}, + {VT_exponent,22,0x3a924a,{DOUBLEWITHTWODWORDINTREE(0x73300000,0x00000000)}}, + {VT_exponent,22,0x3a924b,{DOUBLEWITHTWODWORDINTREE(0x73400000,0x00000000)}}, + {VT_exponent,22,0x3a924c,{DOUBLEWITHTWODWORDINTREE(0x73500000,0x00000000)}}, + {VT_exponent,22,0x3a924d,{DOUBLEWITHTWODWORDINTREE(0x73600000,0x00000000)}}, + {VT_exponent,22,0x3a924e,{DOUBLEWITHTWODWORDINTREE(0x73700000,0x00000000)}}, + {VT_exponent,22,0x3a924f,{DOUBLEWITHTWODWORDINTREE(0x73800000,0x00000000)}}, + {VT_exponent,22,0x3a9250,{DOUBLEWITHTWODWORDINTREE(0x73900000,0x00000000)}}, + {VT_exponent,22,0x3a9251,{DOUBLEWITHTWODWORDINTREE(0x73a00000,0x00000000)}}, + {VT_exponent,22,0x3a9252,{DOUBLEWITHTWODWORDINTREE(0x73b00000,0x00000000)}}, + {VT_exponent,22,0x3a9253,{DOUBLEWITHTWODWORDINTREE(0x73c00000,0x00000000)}}, + {VT_exponent,22,0x3a9254,{DOUBLEWITHTWODWORDINTREE(0x73d00000,0x00000000)}}, + {VT_exponent,22,0x3a9255,{DOUBLEWITHTWODWORDINTREE(0x73e00000,0x00000000)}}, + {VT_exponent,22,0x3a9256,{DOUBLEWITHTWODWORDINTREE(0x73f00000,0x00000000)}}, + {VT_exponent,22,0x3a9257,{DOUBLEWITHTWODWORDINTREE(0x74000000,0x00000000)}}, + {VT_exponent,22,0x3a9258,{DOUBLEWITHTWODWORDINTREE(0x74100000,0x00000000)}}, + {VT_exponent,22,0x3a9259,{DOUBLEWITHTWODWORDINTREE(0x74200000,0x00000000)}}, + {VT_exponent,22,0x3a925a,{DOUBLEWITHTWODWORDINTREE(0x74300000,0x00000000)}}, + {VT_exponent,22,0x3a925b,{DOUBLEWITHTWODWORDINTREE(0x74400000,0x00000000)}}, + {VT_exponent,22,0x3a925c,{DOUBLEWITHTWODWORDINTREE(0x74500000,0x00000000)}}, + {VT_exponent,22,0x3a925d,{DOUBLEWITHTWODWORDINTREE(0x74600000,0x00000000)}}, + {VT_exponent,22,0x3a925e,{DOUBLEWITHTWODWORDINTREE(0x74700000,0x00000000)}}, + {VT_exponent,22,0x3a925f,{DOUBLEWITHTWODWORDINTREE(0x74800000,0x00000000)}}, + {VT_exponent,22,0x3a9260,{DOUBLEWITHTWODWORDINTREE(0x74900000,0x00000000)}}, + {VT_exponent,22,0x3a9261,{DOUBLEWITHTWODWORDINTREE(0x74a00000,0x00000000)}}, + {VT_exponent,22,0x3a9262,{DOUBLEWITHTWODWORDINTREE(0x74b00000,0x00000000)}}, + {VT_exponent,22,0x3a9263,{DOUBLEWITHTWODWORDINTREE(0x74c00000,0x00000000)}}, + {VT_exponent,22,0x3a9264,{DOUBLEWITHTWODWORDINTREE(0x74d00000,0x00000000)}}, + {VT_exponent,22,0x3a9265,{DOUBLEWITHTWODWORDINTREE(0x74e00000,0x00000000)}}, + {VT_exponent,22,0x3a9266,{DOUBLEWITHTWODWORDINTREE(0x74f00000,0x00000000)}}, + {VT_exponent,22,0x3a9267,{DOUBLEWITHTWODWORDINTREE(0x75000000,0x00000000)}}, + {VT_exponent,22,0x3a9268,{DOUBLEWITHTWODWORDINTREE(0x75100000,0x00000000)}}, + {VT_exponent,22,0x3a9269,{DOUBLEWITHTWODWORDINTREE(0x75200000,0x00000000)}}, + {VT_exponent,22,0x3a926a,{DOUBLEWITHTWODWORDINTREE(0x75300000,0x00000000)}}, + {VT_exponent,22,0x3a926b,{DOUBLEWITHTWODWORDINTREE(0x75400000,0x00000000)}}, + {VT_exponent,22,0x3a926c,{DOUBLEWITHTWODWORDINTREE(0x75500000,0x00000000)}}, + {VT_exponent,22,0x3a926d,{DOUBLEWITHTWODWORDINTREE(0x75600000,0x00000000)}}, + {VT_exponent,22,0x3a926e,{DOUBLEWITHTWODWORDINTREE(0x75700000,0x00000000)}}, + {VT_exponent,22,0x3a926f,{DOUBLEWITHTWODWORDINTREE(0x75800000,0x00000000)}}, + {VT_exponent,22,0x3a9270,{DOUBLEWITHTWODWORDINTREE(0x75900000,0x00000000)}}, + {VT_exponent,22,0x3a9271,{DOUBLEWITHTWODWORDINTREE(0x75a00000,0x00000000)}}, + {VT_exponent,22,0x3a9272,{DOUBLEWITHTWODWORDINTREE(0x75b00000,0x00000000)}}, + {VT_exponent,22,0x3a9273,{DOUBLEWITHTWODWORDINTREE(0x75c00000,0x00000000)}}, + {VT_exponent,22,0x3a9274,{DOUBLEWITHTWODWORDINTREE(0x75d00000,0x00000000)}}, + {VT_exponent,22,0x3a9275,{DOUBLEWITHTWODWORDINTREE(0x75e00000,0x00000000)}}, + {VT_exponent,22,0x3a9276,{DOUBLEWITHTWODWORDINTREE(0x75f00000,0x00000000)}}, + {VT_exponent,22,0x3a9277,{DOUBLEWITHTWODWORDINTREE(0x76000000,0x00000000)}}, + {VT_exponent,22,0x3a9278,{DOUBLEWITHTWODWORDINTREE(0x76100000,0x00000000)}}, + {VT_exponent,22,0x3a9279,{DOUBLEWITHTWODWORDINTREE(0x76200000,0x00000000)}}, + {VT_exponent,22,0x3a927a,{DOUBLEWITHTWODWORDINTREE(0x76300000,0x00000000)}}, + {VT_exponent,22,0x3a927b,{DOUBLEWITHTWODWORDINTREE(0x76400000,0x00000000)}}, + {VT_exponent,22,0x3a927c,{DOUBLEWITHTWODWORDINTREE(0x76500000,0x00000000)}}, + {VT_exponent,22,0x3a927d,{DOUBLEWITHTWODWORDINTREE(0x76600000,0x00000000)}}, + {VT_exponent,22,0x3a927e,{DOUBLEWITHTWODWORDINTREE(0x76700000,0x00000000)}}, + {VT_exponent,22,0x3a927f,{DOUBLEWITHTWODWORDINTREE(0x76800000,0x00000000)}}, + {VT_exponent,22,0x3a9280,{DOUBLEWITHTWODWORDINTREE(0x76900000,0x00000000)}}, + {VT_exponent,22,0x3a9281,{DOUBLEWITHTWODWORDINTREE(0x76a00000,0x00000000)}}, + {VT_exponent,22,0x3a9282,{DOUBLEWITHTWODWORDINTREE(0x76b00000,0x00000000)}}, + {VT_exponent,22,0x3a9283,{DOUBLEWITHTWODWORDINTREE(0x76c00000,0x00000000)}}, + {VT_exponent,22,0x3a9284,{DOUBLEWITHTWODWORDINTREE(0x76d00000,0x00000000)}}, + {VT_exponent,22,0x3a9285,{DOUBLEWITHTWODWORDINTREE(0x76e00000,0x00000000)}}, + {VT_exponent,22,0x3a9286,{DOUBLEWITHTWODWORDINTREE(0x76f00000,0x00000000)}}, + {VT_exponent,22,0x3a9287,{DOUBLEWITHTWODWORDINTREE(0x77000000,0x00000000)}}, + {VT_exponent,22,0x3a9288,{DOUBLEWITHTWODWORDINTREE(0x77100000,0x00000000)}}, + {VT_exponent,22,0x3a9289,{DOUBLEWITHTWODWORDINTREE(0x77200000,0x00000000)}}, + {VT_exponent,22,0x3a928a,{DOUBLEWITHTWODWORDINTREE(0x77300000,0x00000000)}}, + {VT_exponent,22,0x3a928b,{DOUBLEWITHTWODWORDINTREE(0x77400000,0x00000000)}}, + {VT_exponent,22,0x3a928c,{DOUBLEWITHTWODWORDINTREE(0x77500000,0x00000000)}}, + {VT_exponent,22,0x3a928d,{DOUBLEWITHTWODWORDINTREE(0x77600000,0x00000000)}}, + {VT_exponent,22,0x3a928e,{DOUBLEWITHTWODWORDINTREE(0x77700000,0x00000000)}}, + {VT_exponent,22,0x3a928f,{DOUBLEWITHTWODWORDINTREE(0x77800000,0x00000000)}}, + {VT_exponent,22,0x3a9290,{DOUBLEWITHTWODWORDINTREE(0x77900000,0x00000000)}}, + {VT_exponent,22,0x3a9291,{DOUBLEWITHTWODWORDINTREE(0x77a00000,0x00000000)}}, + {VT_exponent,22,0x3a9292,{DOUBLEWITHTWODWORDINTREE(0x77b00000,0x00000000)}}, + {VT_exponent,22,0x3a9293,{DOUBLEWITHTWODWORDINTREE(0x77c00000,0x00000000)}}, + {VT_exponent,22,0x3a9294,{DOUBLEWITHTWODWORDINTREE(0x77d00000,0x00000000)}}, + {VT_exponent,22,0x3a9295,{DOUBLEWITHTWODWORDINTREE(0x77e00000,0x00000000)}}, + {VT_exponent,22,0x3a9296,{DOUBLEWITHTWODWORDINTREE(0x77f00000,0x00000000)}}, + {VT_exponent,22,0x3a9297,{DOUBLEWITHTWODWORDINTREE(0x78000000,0x00000000)}}, + {VT_exponent,22,0x3a9298,{DOUBLEWITHTWODWORDINTREE(0x78100000,0x00000000)}}, + {VT_exponent,22,0x3a9299,{DOUBLEWITHTWODWORDINTREE(0x78200000,0x00000000)}}, + {VT_exponent,22,0x3a929a,{DOUBLEWITHTWODWORDINTREE(0x78300000,0x00000000)}}, + {VT_exponent,22,0x3a929b,{DOUBLEWITHTWODWORDINTREE(0x78400000,0x00000000)}}, + {VT_exponent,22,0x3a929c,{DOUBLEWITHTWODWORDINTREE(0x78500000,0x00000000)}}, + {VT_exponent,22,0x3a929d,{DOUBLEWITHTWODWORDINTREE(0x78600000,0x00000000)}}, + {VT_exponent,22,0x3a929e,{DOUBLEWITHTWODWORDINTREE(0x78700000,0x00000000)}}, + {VT_exponent,22,0x3a929f,{DOUBLEWITHTWODWORDINTREE(0x78800000,0x00000000)}}, + {VT_exponent,22,0x3a92a0,{DOUBLEWITHTWODWORDINTREE(0x78900000,0x00000000)}}, + {VT_exponent,22,0x3a92a1,{DOUBLEWITHTWODWORDINTREE(0x78a00000,0x00000000)}}, + {VT_exponent,22,0x3a92a2,{DOUBLEWITHTWODWORDINTREE(0x78b00000,0x00000000)}}, + {VT_exponent,22,0x3a92a3,{DOUBLEWITHTWODWORDINTREE(0x78c00000,0x00000000)}}, + {VT_exponent,22,0x3a92a4,{DOUBLEWITHTWODWORDINTREE(0x78d00000,0x00000000)}}, + {VT_exponent,22,0x3a92a5,{DOUBLEWITHTWODWORDINTREE(0x78e00000,0x00000000)}}, + {VT_exponent,22,0x3a92a6,{DOUBLEWITHTWODWORDINTREE(0x78f00000,0x00000000)}}, + {VT_exponent,22,0x3a92a7,{DOUBLEWITHTWODWORDINTREE(0x79000000,0x00000000)}}, + {VT_exponent,22,0x3a92a8,{DOUBLEWITHTWODWORDINTREE(0x79100000,0x00000000)}}, + {VT_exponent,22,0x3a92a9,{DOUBLEWITHTWODWORDINTREE(0x79200000,0x00000000)}}, + {VT_exponent,22,0x3a92aa,{DOUBLEWITHTWODWORDINTREE(0x79300000,0x00000000)}}, + {VT_exponent,22,0x3a92ab,{DOUBLEWITHTWODWORDINTREE(0x79400000,0x00000000)}}, + {VT_exponent,22,0x3a92ac,{DOUBLEWITHTWODWORDINTREE(0x79500000,0x00000000)}}, + {VT_exponent,22,0x3a92ad,{DOUBLEWITHTWODWORDINTREE(0x79600000,0x00000000)}}, + {VT_exponent,22,0x3a92ae,{DOUBLEWITHTWODWORDINTREE(0x79700000,0x00000000)}}, + {VT_exponent,22,0x3a92af,{DOUBLEWITHTWODWORDINTREE(0x79800000,0x00000000)}}, + {VT_exponent,22,0x3a92b0,{DOUBLEWITHTWODWORDINTREE(0x79900000,0x00000000)}}, + {VT_exponent,22,0x3a92b1,{DOUBLEWITHTWODWORDINTREE(0x79a00000,0x00000000)}}, + {VT_exponent,22,0x3a92b2,{DOUBLEWITHTWODWORDINTREE(0x79b00000,0x00000000)}}, + {VT_exponent,22,0x3a92b3,{DOUBLEWITHTWODWORDINTREE(0x79c00000,0x00000000)}}, + {VT_exponent,22,0x3a92b4,{DOUBLEWITHTWODWORDINTREE(0x79d00000,0x00000000)}}, + {VT_exponent,22,0x3a92b5,{DOUBLEWITHTWODWORDINTREE(0x79e00000,0x00000000)}}, + {VT_exponent,22,0x3a92b6,{DOUBLEWITHTWODWORDINTREE(0x79f00000,0x00000000)}}, + {VT_exponent,22,0x3a92b7,{DOUBLEWITHTWODWORDINTREE(0x7a000000,0x00000000)}}, + {VT_exponent,22,0x3a92b8,{DOUBLEWITHTWODWORDINTREE(0x7a100000,0x00000000)}}, + {VT_exponent,22,0x3a92b9,{DOUBLEWITHTWODWORDINTREE(0x7a200000,0x00000000)}}, + {VT_exponent,22,0x3a92ba,{DOUBLEWITHTWODWORDINTREE(0x7a300000,0x00000000)}}, + {VT_exponent,22,0x3a92bb,{DOUBLEWITHTWODWORDINTREE(0x7a400000,0x00000000)}}, + {VT_exponent,22,0x3a92bc,{DOUBLEWITHTWODWORDINTREE(0x7a500000,0x00000000)}}, + {VT_exponent,22,0x3a92bd,{DOUBLEWITHTWODWORDINTREE(0x7a600000,0x00000000)}}, + {VT_exponent,22,0x3a92be,{DOUBLEWITHTWODWORDINTREE(0x7a700000,0x00000000)}}, + {VT_exponent,22,0x3a92bf,{DOUBLEWITHTWODWORDINTREE(0x7a800000,0x00000000)}}, + {VT_exponent,22,0x3a92c0,{DOUBLEWITHTWODWORDINTREE(0x7a900000,0x00000000)}}, + {VT_exponent,22,0x3a92c1,{DOUBLEWITHTWODWORDINTREE(0x7aa00000,0x00000000)}}, + {VT_exponent,22,0x3a92c2,{DOUBLEWITHTWODWORDINTREE(0x7ab00000,0x00000000)}}, + {VT_exponent,22,0x3a92c3,{DOUBLEWITHTWODWORDINTREE(0x7ac00000,0x00000000)}}, + {VT_exponent,22,0x3a92c4,{DOUBLEWITHTWODWORDINTREE(0x7ad00000,0x00000000)}}, + {VT_exponent,22,0x3a92c5,{DOUBLEWITHTWODWORDINTREE(0x7ae00000,0x00000000)}}, + {VT_exponent,22,0x3a92c6,{DOUBLEWITHTWODWORDINTREE(0x7af00000,0x00000000)}}, + {VT_exponent,22,0x3a92c7,{DOUBLEWITHTWODWORDINTREE(0x7b000000,0x00000000)}}, + {VT_exponent,22,0x3a92c8,{DOUBLEWITHTWODWORDINTREE(0x7b100000,0x00000000)}}, + {VT_exponent,22,0x3a92c9,{DOUBLEWITHTWODWORDINTREE(0x7b200000,0x00000000)}}, + {VT_exponent,22,0x3a92ca,{DOUBLEWITHTWODWORDINTREE(0x7b300000,0x00000000)}}, + {VT_exponent,22,0x3a92cb,{DOUBLEWITHTWODWORDINTREE(0x7b400000,0x00000000)}}, + {VT_exponent,22,0x3a92cc,{DOUBLEWITHTWODWORDINTREE(0x7b500000,0x00000000)}}, + {VT_exponent,22,0x3a92cd,{DOUBLEWITHTWODWORDINTREE(0x7b600000,0x00000000)}}, + {VT_exponent,22,0x3a92ce,{DOUBLEWITHTWODWORDINTREE(0x7b700000,0x00000000)}}, + {VT_exponent,22,0x3a92cf,{DOUBLEWITHTWODWORDINTREE(0x7b800000,0x00000000)}}, + {VT_exponent,22,0x3a92d0,{DOUBLEWITHTWODWORDINTREE(0x7b900000,0x00000000)}}, + {VT_exponent,22,0x3a92d1,{DOUBLEWITHTWODWORDINTREE(0x7ba00000,0x00000000)}}, + {VT_exponent,22,0x3a92d2,{DOUBLEWITHTWODWORDINTREE(0x7bb00000,0x00000000)}}, + {VT_exponent,22,0x3a92d3,{DOUBLEWITHTWODWORDINTREE(0x7bc00000,0x00000000)}}, + {VT_exponent,22,0x3a92d4,{DOUBLEWITHTWODWORDINTREE(0x7bd00000,0x00000000)}}, + {VT_exponent,22,0x3a92d5,{DOUBLEWITHTWODWORDINTREE(0x7be00000,0x00000000)}}, + {VT_exponent,22,0x3a92d6,{DOUBLEWITHTWODWORDINTREE(0x7bf00000,0x00000000)}}, + {VT_exponent,22,0x3a92d7,{DOUBLEWITHTWODWORDINTREE(0x7c000000,0x00000000)}}, + {VT_exponent,22,0x3a92d8,{DOUBLEWITHTWODWORDINTREE(0x7c100000,0x00000000)}}, + {VT_exponent,22,0x3a92d9,{DOUBLEWITHTWODWORDINTREE(0x7c200000,0x00000000)}}, + {VT_exponent,22,0x3a92da,{DOUBLEWITHTWODWORDINTREE(0x7c300000,0x00000000)}}, + {VT_exponent,22,0x3a92db,{DOUBLEWITHTWODWORDINTREE(0x7c400000,0x00000000)}}, + {VT_exponent,22,0x3a92dc,{DOUBLEWITHTWODWORDINTREE(0x7c500000,0x00000000)}}, + {VT_exponent,22,0x3a92dd,{DOUBLEWITHTWODWORDINTREE(0x7c600000,0x00000000)}}, + {VT_exponent,22,0x3a92de,{DOUBLEWITHTWODWORDINTREE(0x7c700000,0x00000000)}}, + {VT_exponent,22,0x3a92df,{DOUBLEWITHTWODWORDINTREE(0x7c800000,0x00000000)}}, + {VT_exponent,22,0x3a92e0,{DOUBLEWITHTWODWORDINTREE(0x7c900000,0x00000000)}}, + {VT_exponent,22,0x3a92e1,{DOUBLEWITHTWODWORDINTREE(0x7ca00000,0x00000000)}}, + {VT_exponent,22,0x3a92e2,{DOUBLEWITHTWODWORDINTREE(0x7cb00000,0x00000000)}}, + {VT_exponent,22,0x3a92e3,{DOUBLEWITHTWODWORDINTREE(0x7cc00000,0x00000000)}}, + {VT_exponent,22,0x3a92e4,{DOUBLEWITHTWODWORDINTREE(0x7cd00000,0x00000000)}}, + {VT_exponent,22,0x3a92e5,{DOUBLEWITHTWODWORDINTREE(0x7ce00000,0x00000000)}}, + {VT_exponent,22,0x3a92e6,{DOUBLEWITHTWODWORDINTREE(0x7cf00000,0x00000000)}}, + {VT_exponent,22,0x3a92e7,{DOUBLEWITHTWODWORDINTREE(0x7d000000,0x00000000)}}, + {VT_exponent,22,0x3a92e8,{DOUBLEWITHTWODWORDINTREE(0x7d100000,0x00000000)}}, + {VT_exponent,22,0x3a92e9,{DOUBLEWITHTWODWORDINTREE(0x7d200000,0x00000000)}}, + {VT_exponent,22,0x3a92ea,{DOUBLEWITHTWODWORDINTREE(0x7d300000,0x00000000)}}, + {VT_exponent,22,0x3a92eb,{DOUBLEWITHTWODWORDINTREE(0x7d400000,0x00000000)}}, + {VT_exponent,22,0x3a92ec,{DOUBLEWITHTWODWORDINTREE(0x7d500000,0x00000000)}}, + {VT_exponent,22,0x3a92ed,{DOUBLEWITHTWODWORDINTREE(0x7d600000,0x00000000)}}, + {VT_exponent,22,0x3a92ee,{DOUBLEWITHTWODWORDINTREE(0x7d700000,0x00000000)}}, + {VT_exponent,22,0x3a92ef,{DOUBLEWITHTWODWORDINTREE(0x7d800000,0x00000000)}}, + {VT_exponent,22,0x3a92f0,{DOUBLEWITHTWODWORDINTREE(0x7d900000,0x00000000)}}, + {VT_exponent,22,0x3a92f1,{DOUBLEWITHTWODWORDINTREE(0x7da00000,0x00000000)}}, + {VT_exponent,22,0x3a92f2,{DOUBLEWITHTWODWORDINTREE(0x7db00000,0x00000000)}}, + {VT_exponent,22,0x3a92f3,{DOUBLEWITHTWODWORDINTREE(0x7dc00000,0x00000000)}}, + {VT_exponent,22,0x3a92f4,{DOUBLEWITHTWODWORDINTREE(0x7dd00000,0x00000000)}}, + {VT_exponent,22,0x3a92f5,{DOUBLEWITHTWODWORDINTREE(0x7de00000,0x00000000)}}, + {VT_exponent,22,0x3a92f6,{DOUBLEWITHTWODWORDINTREE(0x7df00000,0x00000000)}}, + {VT_exponent,22,0x3a92f7,{DOUBLEWITHTWODWORDINTREE(0x7e000000,0x00000000)}}, + {VT_exponent,22,0x3a92f8,{DOUBLEWITHTWODWORDINTREE(0x7e100000,0x00000000)}}, + {VT_exponent,22,0x3a92f9,{DOUBLEWITHTWODWORDINTREE(0x7e200000,0x00000000)}}, + {VT_exponent,22,0x3a92fa,{DOUBLEWITHTWODWORDINTREE(0x7e300000,0x00000000)}}, + {VT_exponent,22,0x3a92fb,{DOUBLEWITHTWODWORDINTREE(0x7e400000,0x00000000)}}, + {VT_exponent,22,0x3a92fc,{DOUBLEWITHTWODWORDINTREE(0x7e500000,0x00000000)}}, + {VT_exponent,22,0x3a92fd,{DOUBLEWITHTWODWORDINTREE(0x7e600000,0x00000000)}}, + {VT_exponent,22,0x3a92fe,{DOUBLEWITHTWODWORDINTREE(0x7e700000,0x00000000)}}, + {VT_exponent,22,0x3a92ff,{DOUBLEWITHTWODWORDINTREE(0x7e800000,0x00000000)}}, + {VT_exponent,22,0x3a95a0,{DOUBLEWITHTWODWORDINTREE(0x7e900000,0x00000000)}}, + {VT_exponent,22,0x3a95a1,{DOUBLEWITHTWODWORDINTREE(0x7ea00000,0x00000000)}}, + {VT_exponent,22,0x3a95a2,{DOUBLEWITHTWODWORDINTREE(0x7eb00000,0x00000000)}}, + {VT_exponent,22,0x3a95a3,{DOUBLEWITHTWODWORDINTREE(0x7ec00000,0x00000000)}}, + {VT_exponent,22,0x3a95a4,{DOUBLEWITHTWODWORDINTREE(0x7ed00000,0x00000000)}}, + {VT_exponent,22,0x3a95a5,{DOUBLEWITHTWODWORDINTREE(0x7ee00000,0x00000000)}}, + {VT_exponent,22,0x3a95a6,{DOUBLEWITHTWODWORDINTREE(0x7ef00000,0x00000000)}}, + {VT_exponent,22,0x3a95a7,{DOUBLEWITHTWODWORDINTREE(0x7f000000,0x00000000)}}, + {VT_exponent,22,0x3a95a8,{DOUBLEWITHTWODWORDINTREE(0x7f100000,0x00000000)}}, + {VT_exponent,22,0x3a95a9,{DOUBLEWITHTWODWORDINTREE(0x7f200000,0x00000000)}}, + {VT_exponent,22,0x3a95aa,{DOUBLEWITHTWODWORDINTREE(0x7f300000,0x00000000)}}, + {VT_exponent,22,0x3a95ab,{DOUBLEWITHTWODWORDINTREE(0x7f400000,0x00000000)}}, + {VT_exponent,22,0x3a95ac,{DOUBLEWITHTWODWORDINTREE(0x7f500000,0x00000000)}}, + {VT_exponent,22,0x3a95ad,{DOUBLEWITHTWODWORDINTREE(0x7f600000,0x00000000)}}, + {VT_exponent,22,0x3a95ae,{DOUBLEWITHTWODWORDINTREE(0x7f700000,0x00000000)}}, + {VT_exponent,22,0x3a95af,{DOUBLEWITHTWODWORDINTREE(0x7f800000,0x00000000)}}, + {VT_exponent,22,0x3b8fe0,{DOUBLEWITHTWODWORDINTREE(0x7f900000,0x00000000)}}, + {VT_exponent,22,0x3b8fe1,{DOUBLEWITHTWODWORDINTREE(0x7fa00000,0x00000000)}}, + {VT_exponent,22,0x3b8fe2,{DOUBLEWITHTWODWORDINTREE(0x7fb00000,0x00000000)}}, + {VT_exponent,22,0x3b8fe3,{DOUBLEWITHTWODWORDINTREE(0x7fc00000,0x00000000)}}, + {VT_exponent,21,0x68e90,{DOUBLEWITHTWODWORDINTREE(0x7fd00000,0x00000000)}}, + {VT_exponent,21,0x68e91,{DOUBLEWITHTWODWORDINTREE(0x7fe00000,0x00000000)}}, + {VT_exponent,21,0x68e98,{DOUBLEWITHTWODWORDINTREE(0x7ff80000,0x00000000)}}, +}; // End of acofdoe array diff --git a/src/prc/PRCdouble.h b/src/prc/PRCdouble.h new file mode 100644 index 0000000..4a3a79d --- /dev/null +++ b/src/prc/PRCdouble.h @@ -0,0 +1,140 @@ +#ifndef __PRC_DOUBLE_H +#define __PRC_DOUBLE_H + +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#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 +{ + double d; + /* This is the IEEE 754 double-precision format. */ + struct + { +#ifdef WORDS_BIGENDIAN + unsigned int negative:1; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; +#else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; +#endif + } 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}; + +struct sCodageOfFrequentDoubleOrExponent +{ + short Type; + short NumberOfBits; + unsigned Bits; + union { + unsigned ul[2]; + double Value; + } u2uod; +}; + +#ifdef WORDS_BIGENDIAN +# define DOUBLEWITHTWODWORD(upper,lower) upper,lower +# define UPPERPOWER (0) +# define LOWERPOWER (!UPPERPOWER) + +# define NEXTBYTE(pbd) ((pbd)++) +# define PREVIOUSBYTE(pbd) ((pbd)--) +# define MOREBYTE(pbd,pbend) ((pbd)<=(pbend)) +# define OFFSETBYTE(pbd,offset) ((pbd)+=offset) +# define BEFOREBYTE(pbd) ((pbd)-1) +# define DIFFPOINTERS(p1,p2) ((p1)-(p2)) +# define SEARCHBYTE(pbstart,b,nb) (unsigned char *)memrchr((pbstart),(b),(nb)) +# define BYTEAT(pb,i) *((pb)-(i)) +#else +# define DOUBLEWITHTWODWORD(upper,lower) lower,upper +# define UPPERPOWER (1) +# define LOWERPOWER (!UPPERPOWER) + +# define NEXTBYTE(pbd) ((pbd)--) +# define PREVIOUSBYTE(pbd) ((pbd)++) +# define MOREBYTE(pbd,pbend) ((pbd)>=(pbend)) +# define OFFSETBYTE(pbd,offset) ((pbd)-=offset) +# define BEFOREBYTE(pbd) ((pbd)+1) +# define DIFFPOINTERS(p1,p2) ((unsigned)((p2)-(p1))) +# define SEARCHBYTE(pbstart,b,nb) (unsigned char *)memchr((pbstart),(b),(nb)) +# define BYTEAT(pb,i) *((pb)+(i)) +#endif + +#define MAXLENGTHFORCOMPRESSEDTYPE ((22+1+1+4+6*(1+8))+7)/8 + +#define NEGATIVE(d) (((union ieee754_double *)&(d))->ieee.negative) +#define EXPONENT(d) (((union ieee754_double *)&(d))->ieee.exponent) +#define MANTISSA0(d) (((union ieee754_double *)&(d))->ieee.mantissa0) +#define MANTISSA1(d) (((union ieee754_double *)&(d))->ieee.mantissa1) + +typedef unsigned char PRCbyte; +typedef unsigned short PRCword; +typedef unsigned PRCdword; + +extern PRCdword stadwZero[2],stadwNegativeZero[2]; + +#define NUMBEROFELEMENTINACOFDOE (2077) + +#ifdef WORDS_BIGENDIAN +# define DOUBLEWITHTWODWORDINTREE(upper,lower) {upper,lower} +#else +# define DOUBLEWITHTWODWORDINTREE(upper,lower) {lower,upper} +#endif +extern sCodageOfFrequentDoubleOrExponent acofdoe[NUMBEROFELEMENTINACOFDOE]; + +struct sCodageOfFrequentDoubleOrExponent* getcofdoe(unsigned,short); + +#define STAT_V +#define STAT_DOUBLE + +int stCOFDOECompare(const void*,const void*); + +#ifdef WORDS_BIGENDIAN +#ifndef HAVE_MEMRCHR +void *memrchr(const void *,int,size_t); +#endif +#endif + +#endif // __PRC_DOUBLE_H diff --git a/src/prc/oPRCFile.cc b/src/prc/oPRCFile.cc new file mode 100644 index 0000000..b090f8a --- /dev/null +++ b/src/prc/oPRCFile.cc @@ -0,0 +1,2461 @@ +/************ +* +* This file is part of a tool for producing 3D content in the PRC format. +* Copyright (C) 2008 Orest Shardt +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#include "oPRCFile.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define WriteUnsignedInteger( value ) out << (uint32_t)(value); +#define WriteInteger( value ) out << (int32_t)(value); +#define WriteDouble( value ) out << (double)(value); +#define WriteString( value ) out << (value); +#define WriteUncompressedUnsignedInteger( value ) writeUncompressedUnsignedInteger(out, (uint32_t)(value)); +#define WriteUncompressedBlock( value, count ) out.write((char *)(value),(count)); +#define SerializeFileStructureUncompressedUniqueId( value ) (value).serializeFileStructureUncompressedUniqueId(out); +#define SerializeCompressedUniqueId( value ) (value).serializeCompressedUniqueId(out); +#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 SerializeUserData UserData(0,0).write(out); +#define SerializeEmptyContentPRCBase ContentPRCBase(PRC_TYPE_ROOT_PRCBase).serializeContentPRCBase(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 ) (value)->serializeContextAndBodies(out); +#define SerializeGeometrySummary( value ) (value)->serializeGeometrySummary(out); +#define SerializeContextGraphics( value ) (value)->serializeContextGraphics(out); +#define SerializeStartHeader serializeStartHeader(out); +#define SerializeUncompressedFile( value ) (value)->serializeUncompressedFile(out); +#define SerializeUncompressedFiles serializeUncompressedFiles(out); + +#define SerializeModelFileData serializeModelFileData(modelFile_out); modelFile_out.compress(); +#define SerializeUnit( value ) (value).serializeUnit(out); + +using std::string; +using namespace std; + +// Map [0,1] to [0,255] +inline uint8_t byte(double r) +{ + if(r < 0.0) r=0.0; + else if(r > 1.0) r=1.0; + int a=(int)(256.0*r); + if(a == 256) a=255; + return a; +} + +void PRCFileStructure::serializeFileStructureGlobals(PRCbitStream &out) +{ + // even though this is technically not part of this section, + // it is handled here for convenience + const uint32_t number_of_schema = 0; + WriteUnsignedInteger (number_of_schema) + + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureGlobals) + + PRCSingleAttribute sa((int32_t)PRCVersion); + PRCAttribute a("__PRC_RESERVED_ATTRIBUTE_PRCInternalVersion"); + a.addKey(sa); + ContentPRCBase cb(PRC_TYPE_ROOT_PRCBase); + cb.addAttribute(a); + cb.serializeContentPRCBase(out); + WriteUnsignedInteger (number_of_referenced_file_structures) + // SerializeFileStructureInternalGlobalData + WriteDouble (tessellation_chord_height_ratio) + WriteDouble (tessellation_angle_degree) + + // SerializeMarkupSerializationHelper + WriteString (default_font_family_name) + + const uint32_t number_of_fonts = font_keys_of_font.size(); + WriteUnsignedInteger (number_of_fonts) + for (uint32_t i=0;iunit_information.unit_from_CAD_file = true; + product_occurrences[i]->unit_information.unit = unit; + SerializeProductOccurrence (product_occurrences[i]) + } + + // SerializeFileStructureInternalData + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructure) + SerializeEmptyContentPRCBase + const uint32_t next_available_index = makePRCID(); + WriteUnsignedInteger (next_available_index) + const uint32_t index_product_occurence = number_of_product_occurrences; // Asymptote (oPRCFile) specific - we write the root product last + WriteUnsignedInteger (index_product_occurence) + + SerializeUserData +} + +void PRCFileStructure::serializeFileStructureTessellation(PRCbitStream &out) +{ + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureTessellation) + + SerializeEmptyContentPRCBase + const uint32_t number_of_tessellations = tessellations.size(); + WriteUnsignedInteger (number_of_tessellations) + for (uint32_t i=0;iserializeBaseTessData(out); + + SerializeUserData +} + +void PRCFileStructure::serializeFileStructureGeometry(PRCbitStream &out) +{ + WriteUnsignedInteger (PRC_TYPE_ASM_FileStructureGeometry) + + SerializeEmptyContentPRCBase + const uint32_t number_of_contexts = contexts.size(); + WriteUnsignedInteger (number_of_contexts) + for (uint32_t i=0;ifile_structure_uuid ) + // index+1 + out << (uint32_t)fileStructures[0]->product_occurrences.size(); + // active + out << true; + out << (uint32_t)0; // index in model file + + SerializeUserData +} + +void makeFileUUID(PRCUniqueId& UUID) +{ + // make a UUID + static uint32_t count = 0; + ++count; + // the minimum requirement on UUIDs is that all must be unique in the file + UUID.id0 = 0x33595341; // some constant + UUID.id1 = (uint32_t)time(NULL); // the time + UUID.id2 = count; + UUID.id3 = 0xa5a55a5a; // Something random, not seeded by the time, would be nice. But for now, a constant + // maybe add something else to make it more unique + // so multiple files can be combined + // a hash of some data perhaps? +} + +void makeAppUUID(PRCUniqueId& UUID) +{ + UUID.id0 = UUID.id1 = UUID.id2 = UUID.id3 = 0; +} + +void PRCStartHeader::serializeStartHeader(ostream &out) const +{ + WriteUncompressedBlock ("PRC",3) + WriteUncompressedUnsignedInteger (minimal_version_for_read) + WriteUncompressedUnsignedInteger (authoring_version) + SerializeFileStructureUncompressedUniqueId( file_structure_uuid ); + SerializeFileStructureUncompressedUniqueId( application_uuid ); +} + +void PRCStartHeader::serializeUncompressedFiles(ostream &out) const +{ + const uint32_t number_of_uncompressed_files = uncompressed_files.size(); + WriteUncompressedUnsignedInteger (number_of_uncompressed_files) + for (uint32_t i=0; igetSize(); + return size; +} + +void PRCFileStructure::write(ostream &out) +{ + // SerializeFileStructureHeader + SerializeStartHeader + SerializeUncompressedFiles + globals_out.write(out); + tree_out.write(out); + tessellations_out.write(out); + geometry_out.write(out); + extraGeometry_out.write(out); +} + +#define SerializeFileStructureGlobals serializeFileStructureGlobals(globals_out); globals_out.compress(); sizes[1]=globals_out.getSize(); +#define SerializeFileStructureTree serializeFileStructureTree(tree_out); tree_out.compress(); sizes[2]=tree_out.getSize(); +#define SerializeFileStructureTessellation serializeFileStructureTessellation(tessellations_out); tessellations_out.compress(); sizes[3]=tessellations_out.getSize(); +#define SerializeFileStructureGeometry serializeFileStructureGeometry(geometry_out); geometry_out.compress(); sizes[4]=geometry_out.getSize(); +#define SerializeFileStructureExtraGeometry serializeFileStructureExtraGeometry(extraGeometry_out); extraGeometry_out.compress(); sizes[5]=extraGeometry_out.getSize(); +#define FlushSerialization resetGraphicsAndName(); +void PRCFileStructure::prepare() +{ + uint32_t size = 0; + size += getStartHeaderSize(); + size += sizeof(uint32_t); + size += getUncompressedFilesSize(); + sizes[0]=size; + + SerializeFileStructureGlobals + FlushSerialization + + SerializeFileStructureTree + FlushSerialization + + SerializeFileStructureTessellation + FlushSerialization + + SerializeFileStructureGeometry + FlushSerialization + + SerializeFileStructureExtraGeometry + FlushSerialization +} + +uint32_t PRCFileStructure::getSize() +{ + uint32_t size = 0; + for(size_t i=0; i<6; i++) + size += sizes[i]; + return size; +} + + +void PRCFileStructureInformation::write(ostream &out) +{ + SerializeFileStructureUncompressedUniqueId( UUID ); + + WriteUncompressedUnsignedInteger (reserved) + WriteUncompressedUnsignedInteger (number_of_offsets) + for(uint32_t i = 0; i < number_of_offsets; ++i) + { + WriteUncompressedUnsignedInteger (offsets[i]) + } +} + +uint32_t PRCFileStructureInformation::getSize() +{ + return (4+2+number_of_offsets)*sizeof(uint32_t); +} + +void PRCHeader::write(ostream &out) +{ + SerializeStartHeader + WriteUncompressedUnsignedInteger (number_of_file_structures) + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructureInformation[i].write(out); + } + WriteUncompressedUnsignedInteger (model_file_offset) + WriteUncompressedUnsignedInteger (file_size) + SerializeUncompressedFiles +} + +uint32_t PRCHeader::getSize() +{ + uint32_t size = getStartHeaderSize() + sizeof(uint32_t); + for(uint32_t i = 0; i < number_of_file_structures; ++i) + size += fileStructureInformation[i].getSize(); + size += 3*sizeof(uint32_t); + size += getUncompressedFilesSize(); + return size; +} + +void oPRCFile::doGroup(PRCgroup& group) +{ + const string& name = group.name; + + PRCProductOccurrence*& product_occurrence = group.product_occurrence; + PRCProductOccurrence*& parent_product_occurrence = group.parent_product_occurrence; + PRCPartDefinition*& part_definition = group.part_definition; + PRCPartDefinition*& parent_part_definition = group.parent_part_definition; + + if(group.options.tess) + { + if(!group.lines.empty()) + { + for(PRCtesslineMap::const_iterator wit=group.lines.begin(); wit!=group.lines.end(); wit++) + { + bool same_color = true; + const PRCtesslineList& lines = wit->second; + const PRCRgbColor &color = lines.front().color; + for(PRCtesslineList::const_iterator lit=lines.begin(); lit!=lines.end(); lit++) + if(color!=lit->color) + { + same_color = false; + break; + } + map points; + PRC3DWireTess *tess = new PRC3DWireTess(); + if(!same_color) + { + tess->is_segment_color = true; + tess->is_rgba = false; + } + for(PRCtesslineList::const_iterator lit=lines.begin(); lit!=lines.end(); lit++) + { + tess->wire_indexes.push_back(lit->point.size()); + for(uint32_t i=0; ipoint.size(); i++) + { + map::iterator pPoint = points.find(lit->point[i]); + if(pPoint!=points.end()) + tess->wire_indexes.push_back(pPoint->second); + else + { + const uint32_t point_index = tess->coordinates.size(); + points.insert(make_pair(lit->point[i],point_index)); + 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(byte(lit->color.red)); + tess->rgba_vertices.push_back(byte(lit->color.green)); + tess->rgba_vertices.push_back(byte(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 = addColourWidth(RGBAColour(color.red,color.green,color.blue),wit->first); + else + polyWire->index_of_line_style = addColourWidth(RGBAColour(1,1,1),wit->first); + 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 points; + PRC3DTess *tess = new PRC3DTess(); + tess->crease_angle = group.options.crease_angle; + 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::const_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.quads.empty()) + { + map points; + PRC3DTess *tess = new PRC3DTess(); + tess->crease_angle = group.options.crease_angle; + PRCTessFace *tessFace = new PRCTessFace(); + tessFace->used_entities_flag=PRC_FACETESSDATA_Triangle; + uint32_t triangles = 0; + + tessFace->is_rgba = false; + for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++) + { + const RGBAColour* C = qit->colours; + if(C[0].A != 1.0 || C[1].A != 1.0 || C[2].A != 1.0 || C[3].A != 1.0) + { + tessFace->is_rgba = true; + break; + } + } + bool same_colour = true; + const RGBAColour& colour = group.quads.front().colours[0]; + for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++) + { + const RGBAColour* C = qit->colours; + if(colour!=C[0] || colour!=C[1] || colour!=C[2] || colour!=C[3]) + { + same_colour = false; + break; + } + } + + for(PRCtessquadList::const_iterator qit=group.quads.begin(); qit!=group.quads.end(); qit++) + { + const RGBAColour* C = qit->colours; + const bool degenerate = (qit->vertices[0]==qit->vertices[1]); + uint32_t vertex_indices[4]; + for(size_t i = (degenerate?1:0); i < 4; ++i) + { + map::const_iterator pPoint = points.find(qit->vertices[i]); + if(pPoint!=points.end()) + vertex_indices[i] = pPoint->second; + else + { + points.insert(make_pair(qit->vertices[i],(vertex_indices[i] = tess->coordinates.size()))); + tess->coordinates.push_back(qit->vertices[i].x); + tess->coordinates.push_back(qit->vertices[i].y); + tess->coordinates.push_back(qit->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_colour) + { + tessFace->rgba_vertices.push_back(byte(C[1].R)); + tessFace->rgba_vertices.push_back(byte(C[1].G)); + tessFace->rgba_vertices.push_back(byte(C[1].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[1].A)); + + tessFace->rgba_vertices.push_back(byte(C[2].R)); + tessFace->rgba_vertices.push_back(byte(C[2].G)); + tessFace->rgba_vertices.push_back(byte(C[2].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[2].A)); + + tessFace->rgba_vertices.push_back(byte(C[3].R)); + tessFace->rgba_vertices.push_back(byte(C[3].G)); + tessFace->rgba_vertices.push_back(byte(C[3].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[3].A)); + } + } + 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_colour) + { + tessFace->rgba_vertices.push_back(byte(C[0].R)); + tessFace->rgba_vertices.push_back(byte(C[0].G)); + tessFace->rgba_vertices.push_back(byte(C[0].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[0].A)); + + tessFace->rgba_vertices.push_back(byte(C[2].R)); + tessFace->rgba_vertices.push_back(byte(C[2].G)); + tessFace->rgba_vertices.push_back(byte(C[2].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[2].A)); + + tessFace->rgba_vertices.push_back(byte(C[3].R)); + tessFace->rgba_vertices.push_back(byte(C[3].G)); + tessFace->rgba_vertices.push_back(byte(C[3].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[3].A)); + } + 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_colour) + { + tessFace->rgba_vertices.push_back(byte(C[3].R)); + tessFace->rgba_vertices.push_back(byte(C[3].G)); + tessFace->rgba_vertices.push_back(byte(C[3].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[3].A)); + + tessFace->rgba_vertices.push_back(byte(C[1].R)); + tessFace->rgba_vertices.push_back(byte(C[1].G)); + tessFace->rgba_vertices.push_back(byte(C[1].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[1].A)); + + tessFace->rgba_vertices.push_back(byte(C[0].R)); + tessFace->rgba_vertices.push_back(byte(C[0].G)); + tessFace->rgba_vertices.push_back(byte(C[0].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[0].A)); + } + } + } + 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_colour) + polyBrepModel->index_of_line_style = addColour(colour); + 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.pointsets.empty()) + { + for(std::vector::iterator pit=group.pointsets.begin(); pit!=group.pointsets.end(); pit++) + { + part_definition->addPointSet(*pit); + } + } + + if(!group.polymodels.empty()) + { + for(std::vector::iterator pit=group.polymodels.begin(); pit!=group.polymodels.end(); pit++) + { + (*pit)->is_closed = group.options.closed; + part_definition->addPolyBrepModel(*pit); + } + } + + if(!group.polywires.empty()) + { + for(std::vector::iterator pit=group.polywires.begin(); pit!=group.polywires.end(); pit++) + { + part_definition->addPolyWire(*pit); + } + } + + if(!group.wires.empty()) + { + PRCTopoContext *wireContext = NULL; + const uint32_t context_index = getTopoContext(wireContext); + for(PRCwireList::iterator wit=group.wires.begin(); wit!=group.wires.end(); wit++) + { + PRCWireEdge *wireEdge = new PRCWireEdge; + wireEdge->curve_3d = wit->curve; + PRCSingleWireBody *wireBody = new PRCSingleWireBody; + wireBody->setWireEdge(wireEdge); + const uint32_t wire_body_index = wireContext->addSingleWireBody(wireBody); + 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); + } + } + + PRCfaceList &faces = group.faces; + if(!faces.empty()) + { + bool same_color = true; + const 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 = NULL; + const uint32_t context_index = getTopoContext(context); + context->granularity = group.options.granularity; + // Acrobat 9 also does the following: + // context->tolerance = group.options.granularity; + // context->have_smallest_face_thickness = true; + // context->smallest_thickness = group.options.granularity; + PRCShell *shell = new PRCShell; + + for(PRCfaceList::iterator fit=faces.begin(); fit!=faces.end(); fit++) + { + if(fit->transform || group.options.do_break || + (fit->transparent && !group.options.no_break)) + { + PRCShell *shell = new PRCShell; + shell->addFace(fit->face); + PRCConnex *connex = new PRCConnex; + connex->addShell(shell); + PRCBrepData *body = new PRCBrepData; + body->addConnex(connex); + const uint32_t body_index = context->addBrepData(body); + + 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 + { + PRCConnex *connex = new PRCConnex; + connex->addShell(shell); + PRCBrepData *body = new PRCBrepData; + body->addConnex(connex); + const uint32_t body_index = context->addBrepData(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); + } + } + + PRCcompfaceList &compfaces = group.compfaces; + if(!compfaces.empty()) + { + bool same_color = true; + const 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 = NULL; + const uint32_t context_index = getTopoContext(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; + body->face.push_back(fit->face); + + body->serial_tolerance=group.options.compression; + body->brep_data_compressed_tolerance=2.8346456* + group.options.compression; + const uint32_t body_index = context->addCompressedBrepData(body); + + 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); + } + } + + // Simplify and reduce to as simple entities as possible + // products with named representation items can not be reduced to sets, since + // outside references are already set + bool nonamedparts = true; + for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++) + { + if (!(*it)->name.empty()) + { + nonamedparts = false; + break; + } + } + lastgroupname.clear(); + lastgroupnames.clear(); + // 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) ) + { + 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); + lastgroupname = calculate_unique_name(part_definition->representation_item.front(), parent_product_occurrence); + parent_part_definition->addRepresentationItem(part_definition->representation_item.front()); + part_definition->representation_item.clear(); + delete product_occurrence; product_occurrence = NULL; + delete part_definition; part_definition = NULL; + } + // 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 && nonamedparts) + { + PRCSet *set = new PRCSet(name); + set->index_local_coordinate_system = addTransform(group.transform); + lastgroupname = calculate_unique_name(set, parent_product_occurrence); + for(PRCRepresentationItemList::iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++) + { + lastgroupnames.push_back(calculate_unique_name(*it, parent_product_occurrence)); + set->addRepresentationItem(*it); + } + part_definition->representation_item.clear(); + parent_part_definition->addSet(set); + delete product_occurrence; product_occurrence = NULL; + delete part_definition; part_definition = NULL; + } + // Third option - create product + else if ( !product_occurrence->index_son_occurrence.empty() || !part_definition->representation_item.empty()) + { + // if everything is enclosed in one group - drop the root group + if (parent_product_occurrence == NULL && group.transform == NULL && + part_definition->representation_item.empty() && product_occurrence->index_son_occurrence.size()==1) { + delete part_definition; part_definition = NULL; + delete product_occurrence; product_occurrence = NULL; + } + else + { + lastgroupname = calculate_unique_name(product_occurrence, NULL); + if (part_definition->representation_item.empty()) { + delete part_definition; part_definition = NULL; + } + else + { + for(PRCRepresentationItemList::const_iterator it=part_definition->representation_item.begin(); it!=part_definition->representation_item.end(); it++) + if ((*it)->name.empty()) + lastgroupnames.push_back(calculate_unique_name(*it, product_occurrence)); + product_occurrence->index_part = addPartDefinition(part_definition); + } + if (group.transform) { + product_occurrence->location = group.transform; + group.transform = NULL; + } + if (parent_product_occurrence) { + parent_product_occurrence->index_son_occurrence.push_back(addProductOccurrence(product_occurrence)); + } + else { + addProductOccurrence(product_occurrence); + } + } + } + // Last case - absolutely nothing to do + else + { + delete product_occurrence; product_occurrence = NULL; + delete part_definition; part_definition = NULL; + } + +} + +std::string oPRCFile::calculate_unique_name(const ContentPRCBase *prc_entity,const ContentPRCBase *prc_occurence) +{ + std::stringstream ss (std::stringstream::in | std::stringstream::out); + uint8_t *serialization_buffer = NULL; + PRCbitStream serialization(serialization_buffer,0u); + const PRCFileStructure *pfile_structure = fileStructures[0]; + const PRCUniqueId& uuid = pfile_structure->file_structure_uuid; +// ConvertUniqueIdentifierToString (prc_entity) +// SerializeCompressedUniqueId (file_structure) + serialization << uuid.id0 << uuid.id1 << uuid.id2 << uuid.id3; +// WriteUnsignedInteger (type) + serialization << prc_entity->getType(); +// WriteUnsignedInteger (unique_identifier) + serialization << prc_entity->getPRCID(); + if (prc_occurence) + { +// serialization_buffer = Flush serialization (serialization) + { + const uint32_t size_serialization = serialization.getSize(); + while(size_serialization == serialization.getSize()) + serialization << false; + } +// ConvertUniqueIdentifierToString (prc_occurrence_unique_id) +// SerializeCompressedUniqueId (file_structure) + serialization << uuid.id0 << uuid.id1 << uuid.id2 << uuid.id3; +// WriteUnsignedInteger (type) + serialization << (uint32_t)PRC_TYPE_ASM_ProductOccurence; +// WriteUnsignedInteger (unique_identifier) + serialization << prc_occurence->getPRCID(); + } + ss << (prc_entity->name.empty()?"node":prc_entity->name.c_str()) << '.'; + const uint32_t size_serialization = serialization.getSize(); + for(size_t j=0; jprepare(); + SerializeModelFileData + + // create the header + + // fill out enough info so that sizes can be computed correctly + 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) + { + header.fileStructureInformation[i].UUID = fileStructures[i]->file_structure_uuid; + header.fileStructureInformation[i].reserved = 0; + header.fileStructureInformation[i].number_of_offsets = 6; + header.fileStructureInformation[i].offsets = new uint32_t[6]; + } + + header.minimal_version_for_read = PRCVersion; + header.authoring_version = PRCVersion; + makeFileUUID(header.file_structure_uuid); + makeAppUUID(header.application_uuid); + + header.file_size = getSize(); + header.model_file_offset = header.file_size - modelFile_out.getSize(); + + uint32_t currentOffset = header.getSize(); + + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + for(size_t j=0; j<6; j++) + { + header.fileStructureInformation[i].offsets[j] = currentOffset; + currentOffset += fileStructures[i]->sizes[j]; + } + } + + // write the data + header.write(output); + + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructures[i]->write(output); + } + + modelFile_out.write(output); + output.flush(); + + for(uint32_t i = 0; i < number_of_file_structures; ++i) + delete[] header.fileStructureInformation[i].offsets; + delete[] header.fileStructureInformation; + + return true; +} + +uint32_t oPRCFile::getSize() +{ + uint32_t size = header.getSize(); + + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + size += fileStructures[i]->getSize(); + } + + size += modelFile_out.getSize(); + return size; +} + +uint32_t PRCFileStructure::addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *p, uint32_t width, uint32_t height, string name) +{ + uint8_t *data = NULL; + if(size==0 || p==NULL) + { cerr << "image not set" << endl; return m1; } + if(format==KEPRCPicture_PNG || format==KEPRCPicture_JPG) + { + width = 0; // width and height are ignored for JPG and PNG pictures - but let us keep things clean + height = 0; + data = new uint8_t[size]; + memcpy(data, p, size); + } + else + { + uint32_t components=0; + switch(format) + { + case KEPRCPicture_BITMAP_RGB_BYTE: + components = 3; break; + case KEPRCPicture_BITMAP_RGBA_BYTE: + components = 4; break; + case KEPRCPicture_BITMAP_GREY_BYTE: + components = 1; break; + case KEPRCPicture_BITMAP_GREYA_BYTE: + components = 2; break; + default: + { cerr << "unknown picture format" << endl; return m1; } + } + if(width==0 || height==0) + { cerr << "width or height parameter not set" << endl; return m1; } + if (size < width*height*components) + { cerr << "image too small" << endl; return m1; } + { + 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) + { cerr << "Compression initialization failed" << endl; return m1; } + 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); + { cerr << "Compression error" << endl; return m1; } + } + + deflateEnd(&strm); + size = compressedDataSize; + data = new uint8_t[compressedDataSize]; + memcpy(data, compressedData, compressedDataSize); + free(compressedData); + } + } + + uint32_t uncompressed_file_index = m1; + { + PRCUncompressedFile* uncompressed_file = new PRCUncompressedFile(size, data); + uncompressed_file_index = addUncompressedFileUnique(uncompressed_file); + delete[] data; + } + uint32_t picture_index = m1; + { + PRCPicture* picture = new PRCPicture(name); + picture->format = format; + picture->uncompressed_file_index = uncompressed_file_index; + picture->pixel_width = width; + picture->pixel_height = height; + picture_index = addPictureUnique(picture); + } + return picture_index; +} + +uint32_t oPRCFile::addColour(const RGBAColour &colour) +{ + PRCcolourMap::const_iterator pColour = colourMap.find(colour); + if(pColour!=colourMap.end()) + return pColour->second; + const uint32_t color_index = addRgbColorUnique(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 = addStyle(style); + colourMap.insert(make_pair(colour,style_index)); + return style_index; +} + +uint32_t oPRCFile::addColourWidth(const RGBAColour &colour, double width) +{ + const RGBAColourWidth colourwidth(colour.R, colour.G, colour.B, colour.A, width); + PRCcolourwidthMap::const_iterator pColour = colourwidthMap.find(colourwidth); + if(pColour!=colourwidthMap.end()) + return pColour->second; + const uint32_t color_index = addRgbColorUnique(colour.R, colour.G, colour.B); + PRCStyle *style = new PRCStyle(); + style->line_width = width; + 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 = addStyle(style); + colourwidthMap.insert(make_pair(colourwidth,style_index)); + return style_index; +} + +uint32_t oPRCFile::addTransform(PRCGeneralTransformation3d*& transform) +{ + if(!transform) + return m1; + PRCtransformMap::const_iterator pTransform = transformMap.find(*transform); + if(pTransform!=transformMap.end()) + return pTransform->second; + PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem(); + bool transform_replaced = false; + if( transform->M(0,1)==0 && transform->M(0,2)==0 && + transform->M(1,0)==0 && transform->M(1,2)==0 && + transform->M(2,0)==0 && transform->M(2,1)==0 && + transform->M(3,0)==0 && transform->M(3,1)==0 && transform->M(3,2)==0 && transform->M(3,3)==1 ) + { + transform_replaced = true; + PRCCartesianTransformation3d *carttransform = new PRCCartesianTransformation3d; +// if(transform->M(0,3)==0 && transform->M(1,3)==0 && transform->M(1,3)==0 && +// transform->M(0,0)==1 && transform->M(1,1)==1 && transform->M(2,2)==1 ) +// carttransform->behaviour = PRC_TRANSFORMATION_Identity; + if(transform->M(0,3)!=0 || transform->M(1,3)!=0 || transform->M(2,3)!=0) + { + carttransform->behaviour |= PRC_TRANSFORMATION_Translate; + carttransform->origin.Set(transform->M(0,3),transform->M(1,3),transform->M(2,3)); + } + if(transform->M(0,0)!=transform->M(1,1) || transform->M(0,0)!=transform->M(2,2)) + { + carttransform->behaviour |= PRC_TRANSFORMATION_NonUniformScale; + carttransform->scale.Set(transform->M(0,0),transform->M(1,1),transform->M(2,2)); + } + else + if(transform->M(0,0)!=1) + { + carttransform->behaviour |= PRC_TRANSFORMATION_Scale; + carttransform->uniform_scale=transform->M(0,0); + } + coordinateSystem->axis_set = carttransform; + } + else + coordinateSystem->axis_set = transform; + + const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem); + transformMap.insert(make_pair(*transform,coordinate_system_index)); + if(transform_replaced) + delete transform; + transform = NULL; + return coordinate_system_index; +} + +uint32_t oPRCFile::addTransform(const double* t) +{ + if(!t) + return m1; + PRCGeneralTransformation3d* transform = new PRCGeneralTransformation3d(t); + return addTransform(transform); +} + +uint32_t oPRCFile::addTransform(const double origin[3], const double x_axis[3], const double y_axis[3], double scale) +{ + PRCCartesianTransformation3d* transform = new PRCCartesianTransformation3d(origin, x_axis, y_axis, scale); + if(transform->behaviour==PRC_TRANSFORMATION_Identity) + return m1; + PRCCoordinateSystem *coordinateSystem = new PRCCoordinateSystem(); + coordinateSystem->axis_set = transform; + const uint32_t coordinate_system_index = fileStructures[0]->addCoordinateSystem(coordinateSystem); + return coordinate_system_index; +} + +uint32_t oPRCFile::addMaterial(const PRCmaterial& m) +{ + PRCmaterialMap::const_iterator pMaterial = materialMap.find(m); + if(pMaterial!=materialMap.end()) + return pMaterial->second; + + uint32_t material_index = m1; + { + PRCMaterialGeneric *materialGeneric = new PRCMaterialGeneric; + materialGeneric->ambient = addRgbColorUnique(m.ambient.R, m.ambient.G, m.ambient.B); + materialGeneric->diffuse = addRgbColorUnique(m.diffuse.R, m.diffuse.G, m.diffuse.B); + materialGeneric->emissive = addRgbColorUnique(m.emissive.R, m.emissive.G, m.emissive.B); + materialGeneric->specular = addRgbColorUnique(m.specular.R, m.specular.G, m.specular.B); + materialGeneric->shininess = m.shininess; + materialGeneric->ambient_alpha = m.ambient.A; + materialGeneric->diffuse_alpha = m.diffuse.A; + materialGeneric->emissive_alpha = m.emissive.A; + materialGeneric->specular_alpha = m.specular.A; + material_index = addMaterialGenericUnique(materialGeneric); + } + + uint32_t style_index = m1; + { + PRCStyle *style = new PRCStyle; + style->line_width = m.width; + style->is_vpicture = false; + style->line_pattern_vpicture_index = 0; + style->is_material = true; + style->is_transparency_defined = (m.alpha < 1.0); + style->transparency = (uint8_t)(m.alpha * 256); + style->additional = 0; + style->color_material_index = material_index; + style_index = addStyleUnique(style); + } + materialMap.insert(make_pair(m,style_index)); + return style_index; +} + +uint32_t oPRCFile::addTexturedMaterial(const PRCmaterial& m, uint32_t n, const PRCtexture* const tt[]) +{ + uint32_t material_generic_index = m1; + { + PRCMaterialGeneric *materialGeneric = new PRCMaterialGeneric; + materialGeneric->ambient = addRgbColorUnique(m.ambient.R, m.ambient.G, m.ambient.B); + materialGeneric->diffuse = addRgbColorUnique(m.diffuse.R, m.diffuse.G, m.diffuse.B); + materialGeneric->emissive = addRgbColorUnique(m.emissive.R, m.emissive.G, m.emissive.B); + materialGeneric->specular = addRgbColorUnique(m.specular.R, m.specular.G, m.specular.B); + materialGeneric->shininess = m.shininess; + materialGeneric->ambient_alpha = m.ambient.A; + materialGeneric->diffuse_alpha = m.diffuse.A; + materialGeneric->emissive_alpha = m.emissive.A; + materialGeneric->specular_alpha = m.specular.A; + material_generic_index = addMaterialGenericUnique(materialGeneric); + } + + uint32_t color_material_index = material_generic_index; + + uint32_t texture_application_index = m1; + for (uint32_t i=n; i>0; i--) { + const PRCtexture* t = tt[i-1]; + if (t == NULL) { + continue; + } + const uint32_t picture_index = addPicture(t->format, t->size, t->data, t->height, t->width); + + uint32_t texture_definition_index = m1; + { + PRCTextureDefinition *textureDefinition = new PRCTextureDefinition; + textureDefinition->picture_index = picture_index; + textureDefinition->texture_mapping_attribute = t->mapping; + textureDefinition->texture_mapping_attribute_components = t->components; + textureDefinition->texture_function = t->function; + textureDefinition->texture_wrapping_mode_S = t->wrapping_mode_S; + textureDefinition->texture_wrapping_mode_T = t->wrapping_mode_T; + texture_definition_index = addTextureDefinitionUnique(textureDefinition); + } + { + PRCTextureApplication *textureApplication = new PRCTextureApplication; + textureApplication->material_generic_index=material_generic_index; + textureApplication->texture_definition_index=texture_definition_index; + textureApplication->next_texture_index = texture_application_index; + texture_application_index = addTextureApplicationUnique(textureApplication); + } + color_material_index = texture_application_index; + } + + uint32_t style_index = m1; + { + PRCStyle *style = new PRCStyle; + style->line_width = 0.0; + style->is_vpicture = false; + style->line_pattern_vpicture_index = 0; + style->is_material = true; + style->is_transparency_defined = (m.alpha < 1.0); + style->transparency = (uint8_t)(m.alpha * 256); + style->additional = 0; + style->color_material_index = color_material_index; + style_index = addStyleUnique(style); + } + return style_index; +} + +bool isid(const double* t) +{ + return( + t[0]==1 && t[4]==0 && t[ 8]==0 && t[12]==0 && + t[1]==0 && t[5]==1 && t[ 9]==0 && t[13]==0 && + t[2]==0 && t[6]==0 && t[10]==1 && t[14]==0 && + t[3]==0 && t[7]==0 && t[11]==0 && t[15]==1 ); +} + + +void oPRCFile::begingroup(const char *name, const PRCoptions *options, + const double* t) +{ + const PRCgroup &parent_group = groups.top(); + groups.push(PRCgroup()); + PRCgroup &group = groups.top(); + group.name=name; + if(options) group.options=*options; + if(t&&!isid(t)) + group.transform = new PRCGeneralTransformation3d(t); + group.product_occurrence = new PRCProductOccurrence(name); + group.parent_product_occurrence = parent_group.product_occurrence; + group.part_definition = new PRCPartDefinition; + group.parent_part_definition = parent_group.part_definition; +} + +void oPRCFile::endgroup() +{ + if(groups.size()<2) { + fputs("begingroup without matching endgroup",stderr); + exit(1); + } + + doGroup(groups.top()); + groups.pop(); + +// std::cout << lastgroupname << std::endl; +// for(std::vector::const_iterator it=lastgroupnames.begin(); it!=lastgroupnames.end(); it++) +// std::cout << " " << *it << std::endl; + +} + +PRCgroup& oPRCFile::findGroup() +{ + return groups.top(); +} + +#define ADDWIRE(curvtype) \ + PRCgroup &group = findGroup(); \ + group.wires.push_back(PRCwire()); \ + PRCwire &wire = group.wires.back(); \ + curvtype *curve = new curvtype; \ + wire.curve = 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 = new PRCFace; \ + face.face->base_surface = 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 = compface; \ + face.transparent = m.alpha < 1.0; \ + face.style = addMaterial(m); + +void oPRCFile::addPoint(const double P[3], const RGBAColour &c, double w) +{ + PRCgroup &group = findGroup(); + group.points[addColourWidth(c,w)].push_back(PRCVector3d(P[0],P[1],P[2])); +} + +void oPRCFile::addPoint(double x, double y, double z, const RGBAColour &c, double w) +{ + PRCgroup &group = findGroup(); + group.points[addColourWidth(c,w)].push_back(PRCVector3d(x,y,z)); +} + + +void oPRCFile::addPoints(uint32_t n, const double P[][3], const RGBAColour &c, double w) +{ + if(n==0 || P==NULL) + return; + PRCgroup &group = findGroup(); + PRCPointSet *pointset = new PRCPointSet(); + group.pointsets.push_back(pointset); + pointset->index_of_line_style = addColourWidth(c,w); + pointset->point.reserve(n); + for(uint32_t i=0; ipoint.push_back(PRCVector3d(P[i][0],P[i][1],P[i][2])); +} + +void oPRCFile::addPoints(uint32_t n, const double P[][3], uint32_t style_index) +{ + if(n==0 || P==NULL) + return; + PRCgroup &group = findGroup(); + PRCPointSet *pointset = new PRCPointSet(); + group.pointsets.push_back(pointset); + pointset->index_of_line_style = style_index; + pointset->point.reserve(n); + for(uint32_t i=0; ipoint.push_back(PRCVector3d(P[i][0],P[i][1],P[i][2])); +} + +void oPRCFile::useMesh(uint32_t tess_index, uint32_t style_index, const double origin[3], const double x_axis[3], const double y_axis[3], double scale) +{ + PRCgroup &group = findGroup(); + PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel(); + polyBrepModel->index_local_coordinate_system = addTransform(origin, x_axis, y_axis, scale); + polyBrepModel->index_tessellation = tess_index; + polyBrepModel->is_closed = group.options.closed; + polyBrepModel->index_of_line_style = style_index; + group.polymodels.push_back(polyBrepModel); +} + +void oPRCFile::useMesh(uint32_t tess_index, uint32_t style_index, const double* t) +{ + PRCgroup &group = findGroup(); + PRCPolyBrepModel *polyBrepModel = new PRCPolyBrepModel(); + polyBrepModel->index_local_coordinate_system = addTransform(t); + polyBrepModel->index_tessellation = tess_index; + polyBrepModel->is_closed = group.options.closed; + polyBrepModel->index_of_line_style = style_index; + group.polymodels.push_back(polyBrepModel); +} + +void oPRCFile::useLines(uint32_t tess_index, uint32_t style_index, const double origin[3], const double x_axis[3], const double y_axis[3], double scale) +{ + PRCgroup &group = findGroup(); + PRCPolyWire *polyWire = new PRCPolyWire(); + polyWire->index_local_coordinate_system = addTransform(origin, x_axis, y_axis, scale); + polyWire->index_tessellation = tess_index; + polyWire->index_of_line_style = style_index; + group.polywires.push_back(polyWire); +} + +void oPRCFile::useLines(uint32_t tess_index, uint32_t style_index, const double* t) +{ + PRCgroup &group = findGroup(); + PRCPolyWire *polyWire = new PRCPolyWire(); + polyWire->index_local_coordinate_system = addTransform(t); + polyWire->index_tessellation = tess_index; + polyWire->index_of_line_style = style_index; + group.polywires.push_back(polyWire); +} + +void oPRCFile::addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial& m, + uint32_t nN, const double N[][3], const uint32_t NI[][3], + uint32_t nT, const double T[][2], const uint32_t TI[][3], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][3], + uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return; + const uint32_t tess_index = createTriangleMesh(nP, P, nI, PI, m, nN, N, NI, nT, T, TI, nC, C, CI, nM, M, MI, ca); + useMesh(tess_index,m1); +} + +uint32_t oPRCFile::createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const uint32_t style_index, + uint32_t nN, const double N[][3], const uint32_t NI[][3], + uint32_t nT, const double T[][2], const uint32_t TI[][3], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][3], + uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return m1; + + const bool triangle_color = (nS != 0 && S != NULL && SI != NULL); + const bool vertex_color = (nC != 0 && C != NULL && CI != NULL); + const bool has_normals = (nN != 0 && N != NULL && NI != NULL); + const bool textured = (nT != 0 && T != NULL && TI != NULL); + + PRC3DTess *tess = new PRC3DTess(); + PRCTessFace *tessFace = new PRCTessFace(); + tessFace->used_entities_flag = textured ? PRC_FACETESSDATA_TriangleTextured : PRC_FACETESSDATA_Triangle; + tessFace->number_of_texture_coordinate_indexes = textured ? 1 : 0; + tess->coordinates.reserve(3*nP); + for(uint32_t i=0; icoordinates.push_back(P[i][0]); + tess->coordinates.push_back(P[i][1]); + tess->coordinates.push_back(P[i][2]); + } + if(has_normals) + { + tess->normal_coordinate.reserve(3*nN); + for(uint32_t i=0; inormal_coordinate.push_back(N[i][0]); + tess->normal_coordinate.push_back(N[i][1]); + tess->normal_coordinate.push_back(N[i][2]); + } + } + else + tess->crease_angle = ca; + if(textured) + { + tess->texture_coordinate.reserve(2*nT); + for(uint32_t i=0; itexture_coordinate.push_back(T[i][0]); + tess->texture_coordinate.push_back(T[i][1]); + } + } + tess->triangulated_index.reserve(3*nI+(has_normals?3:0)*nI+(textured?3:0)*nI); + for(uint32_t i=0; itriangulated_index.push_back(3*NI[i][0]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][0]); + tess->triangulated_index.push_back(3*PI[i][0]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][1]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][1]); + tess->triangulated_index.push_back(3*PI[i][1]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][2]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][2]); + tess->triangulated_index.push_back(3*PI[i][2]); + } + tessFace->sizes_triangulated.push_back(nI); + if(triangle_color) + { + tessFace->line_attributes.reserve(nI); + for(uint32_t i=0; iline_attributes.push_back(SI[i]); + } + else if (style_index != m1 ) + { + tessFace->line_attributes.push_back(style_index); + } + if(vertex_color) + { + tessFace->is_rgba=false; + for(uint32_t i=0; iis_rgba=true; + break; + } + + tessFace->rgba_vertices.reserve((tessFace->is_rgba?4:3)*3*nI); + for(uint32_t i=0; irgba_vertices.push_back(byte(C[CI[i][0]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].A)); + } + } + tess->addTessFace(tessFace); + const uint32_t tess_index = add3DTess(tess); + return tess_index; +} + +void oPRCFile::addQuads(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], const PRCmaterial& m, + uint32_t nN, const double N[][3], const uint32_t NI[][4], + uint32_t nT, const double T[][2], const uint32_t TI[][4], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][4], + uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return; + const uint32_t tess_index = createQuadMesh(nP, P, nI, PI, m, nN, N, NI, nT, T, TI, nC, C, CI, nM, M, MI, ca); + useMesh(tess_index,m1); +} + +uint32_t oPRCFile::createQuadMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][4], uint32_t style_index, + uint32_t nN, const double N[][3], const uint32_t NI[][4], + uint32_t nT, const double T[][2], const uint32_t TI[][4], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][4], + uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return m1; + + const bool triangle_color = (nS != 0 && S != NULL && SI != NULL); + const bool vertex_color = (nC != 0 && C != NULL && CI != NULL); + const bool has_normals = (nN != 0 && N != NULL && NI != NULL); + const bool textured = (nT != 0 && T != NULL && TI != NULL); + + PRC3DTess *tess = new PRC3DTess(); + PRCTessFace *tessFace = new PRCTessFace(); + tessFace->used_entities_flag = textured ? PRC_FACETESSDATA_TriangleTextured : PRC_FACETESSDATA_Triangle; + tessFace->number_of_texture_coordinate_indexes = textured ? 1 : 0; + tess->coordinates.reserve(3*nP); + for(uint32_t i=0; icoordinates.push_back(P[i][0]); + tess->coordinates.push_back(P[i][1]); + tess->coordinates.push_back(P[i][2]); + } + if(has_normals) + { + tess->normal_coordinate.reserve(3*nN); + for(uint32_t i=0; inormal_coordinate.push_back(N[i][0]); + tess->normal_coordinate.push_back(N[i][1]); + tess->normal_coordinate.push_back(N[i][2]); + } + } + else + tess->crease_angle = ca; + if(textured) + { + tess->texture_coordinate.reserve(2*nT); + for(uint32_t i=0; itexture_coordinate.push_back(T[i][0]); + tess->texture_coordinate.push_back(T[i][1]); + } + } + tess->triangulated_index.reserve(2*(3*nI+(has_normals?3:0)*nI+(textured?3:0)*nI)); + for(uint32_t i=0; itriangulated_index.push_back(3*NI[i][0]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][0]); + tess->triangulated_index.push_back(3*PI[i][0]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][1]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][1]); + tess->triangulated_index.push_back(3*PI[i][1]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][3]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][3]); + tess->triangulated_index.push_back(3*PI[i][3]); + // second triangle + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][1]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][1]); + tess->triangulated_index.push_back(3*PI[i][1]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][2]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][2]); + tess->triangulated_index.push_back(3*PI[i][2]); + if(has_normals) + tess->triangulated_index.push_back(3*NI[i][3]); + if(textured) + tess->triangulated_index.push_back(2*TI[i][3]); + tess->triangulated_index.push_back(3*PI[i][3]); + } + tessFace->sizes_triangulated.push_back(2*nI); + if(triangle_color) + { + tessFace->line_attributes.reserve(2*nI); + for(uint32_t i=0; iline_attributes.push_back(SI[i]); + tessFace->line_attributes.push_back(SI[i]); + } + } + else + { + tessFace->line_attributes.push_back(style_index); + } + if(vertex_color) + { + tessFace->is_rgba=false; + for(uint32_t i=0; iis_rgba=true; + break; + } + + tessFace->rgba_vertices.reserve(2*(tessFace->is_rgba?4:3)*3*nI); + for(uint32_t i=0; irgba_vertices.push_back(byte(C[CI[i][0]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][0]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].A)); + // second triangle + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][1]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][2]].A)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].R)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].G)); + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].B)); + if(tessFace->is_rgba) + tessFace->rgba_vertices.push_back(byte(C[CI[i][3]].A)); + } + } + tess->addTessFace(tessFace); + const uint32_t tess_index = add3DTess(tess); + return tess_index; +} + +void oPRCFile::addQuad(const double P[][3], const RGBAColour C[]) +{ + PRCgroup &group = findGroup(); + + group.quads.push_back(PRCtessquad()); + PRCtessquad &quad = group.quads.back(); + for(size_t i = 0; i < 4; i++) + { + quad.vertices[i].x = P[i][0]; + quad.vertices[i].y = P[i][1]; + quad.vertices[i].z = P[i][2]; + quad.colours[i] = C[i]; + } +} +/* +void oPRCFile::addTriangle(const double P[][3], const double T[][2], uint32_t style_index) +{ + PRCgroup &group = findGroup(); + + group.triangles.push_back(PRCtesstriangle()); + PRCtesstriangle &triangle = group.triangles.back(); + for(size_t i = 0; i < 3; i++) + { + triangle.vertices[i].x = P[i][0]; + triangle.vertices[i].y = P[i][1]; + triangle.vertices[i].z = P[i][2]; + triangle.texcoords[i].x = T[i][0]; + triangle.texcoords[i].y = T[i][1]; + } + triangle.style = style_index; +} +*/ + +void oPRCFile::addLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[], + const RGBAColour& c, double w, + bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return; + const uint32_t tess_index = createLines(nP, P, nI, PI, segment_color, nC, C, nCI, CI); + useLines(tess_index, c, w); +} + +uint32_t oPRCFile::createLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[], + bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return m1; + + const bool vertex_color = (nC != 0 && C != NULL && CI != NULL); + + PRC3DWireTess *tess = new PRC3DWireTess(); + tess->coordinates.reserve(3*nP); + for(uint32_t i=0; icoordinates.push_back(P[i][0]); + tess->coordinates.push_back(P[i][1]); + tess->coordinates.push_back(P[i][2]); + } + tess->wire_indexes.reserve(nI); + for(uint32_t i=0; iwire_indexes.push_back(PI[i]); + const uint32_t ni = i+PI[i]+1; + for(i++; iwire_indexes.push_back(3*PI[i]); + } + if(vertex_color) + { + tess->is_segment_color = segment_color; + tess->is_rgba=false; + for(uint32_t i=0; iis_rgba=true; + break; + } + tess->rgba_vertices.reserve((tess->is_rgba?4:3)*nCI); + for(uint32_t i=0; irgba_vertices.push_back(byte(C[CI[i]].R)); + tess->rgba_vertices.push_back(byte(C[CI[i]].G)); + tess->rgba_vertices.push_back(byte(C[CI[i]].B)); + if(tess->is_rgba) + tess->rgba_vertices.push_back(byte(C[CI[i]].A)); + } + } + const uint32_t tess_index = add3DWireTess(tess); + return tess_index; +} + +uint32_t oPRCFile::createSegments(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][2], + bool segment_color, uint32_t nC, const RGBAColour C[], const uint32_t CI[][2]) +{ + if(nP==0 || P==NULL || nI==0 || PI==NULL) + return m1; + + const bool vertex_color = (nC != 0 && C != NULL && CI != NULL); + + PRC3DWireTess *tess = new PRC3DWireTess(); + tess->coordinates.reserve(3*nP); + for(uint32_t i=0; icoordinates.push_back(P[i][0]); + tess->coordinates.push_back(P[i][1]); + tess->coordinates.push_back(P[i][2]); + } + tess->wire_indexes.reserve(3*nI); + for(uint32_t i=0; iwire_indexes.push_back(2); + tess->wire_indexes.push_back(3*PI[i][0]); + tess->wire_indexes.push_back(3*PI[i][1]); + } + if(vertex_color) + { + tess->is_segment_color = segment_color; + tess->is_rgba=false; + for(uint32_t i=0; iis_rgba=true; + break; + } + tess->rgba_vertices.reserve((tess->is_rgba?4:3)*(segment_color?1:2)*nI); + for(uint32_t i=0; irgba_vertices.push_back(byte(0.5*C[CI[i][0]].R+0.5*C[CI[i][1]].R)); + tess->rgba_vertices.push_back(byte(0.5*C[CI[i][0]].G+0.5*C[CI[i][1]].G)); + tess->rgba_vertices.push_back(byte(0.5*C[CI[i][0]].B+0.5*C[CI[i][1]].B)); + if(tess->is_rgba) + tess->rgba_vertices.push_back(byte(0.5*C[CI[i][0]].A+0.5*C[CI[i][1]].A)); + } else { + tess->rgba_vertices.push_back(byte(C[CI[i][0]].R)); + tess->rgba_vertices.push_back(byte(C[CI[i][0]].G)); + tess->rgba_vertices.push_back(byte(C[CI[i][0]].B)); + if(tess->is_rgba) + tess->rgba_vertices.push_back(byte(C[CI[i][0]].A)); + tess->rgba_vertices.push_back(byte(C[CI[i][1]].R)); + tess->rgba_vertices.push_back(byte(C[CI[i][1]].G)); + tess->rgba_vertices.push_back(byte(C[CI[i][1]].B)); + if(tess->is_rgba) + tess->rgba_vertices.push_back(byte(C[CI[i][1]].A)); + } + } + } + const uint32_t tess_index = add3DWireTess(tess); + return tess_index; +} + +void oPRCFile::addLine(uint32_t n, const double P[][3], const RGBAColour &c, double w) +{ + PRCgroup &group = findGroup(); + if(group.options.tess) + { + group.lines[w].push_back(PRCtessline()); + PRCtessline& line = group.lines[w].back(); + line.color.red = c.R; + line.color.green = c.G; + line.color.blue = c.B; + for(uint32_t i=0; ipoint.resize(n); + for(uint32_t i=0; ipoint[i].Set(P[i][0],P[i][1],P[i][2]); + curve->interval.min = 0; + curve->interval.max = curve->point.size()-1; + } +} + +void oPRCFile::addSegment(const double P1[3], const double P2[3], const RGBAColour &c, double w) +{ + PRCgroup &group = findGroup(); + if(group.options.tess) + { + group.lines[w].push_back(PRCtessline()); + PRCtessline& line = group.lines[w].back(); + line.color.red = c.R; + line.color.green = c.G; + line.color.blue = c.B; + line.point.push_back(PRCVector3d(P1[0],P1[1],P1[2])); + line.point.push_back(PRCVector3d(P2[0],P2[1],P2[2])); + } + else + { + ADDWIRE(PRCPolyLine) + curve->point.resize(2); + curve->point[0].Set(P1[0],P1[1],P1[2]); + curve->point[1].Set(P2[0],P2[1],P2[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!=NULL); + 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) + { + 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!=NULL); + 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 = 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.0,0.0)) \ + surface->behaviour = surface->behaviour | PRC_TRANSFORMATION_Translate; \ + if(surface->x_axis!=PRCVector3d(1.0,0.0,0.0)||surface->y_axis!=PRCVector3d(0.0,1.0,0.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 + +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; ipoint[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->center_curve = center_curve; + + PRCPolyLine *origin_curve = new PRCPolyLine; + origin_curve->point.resize(n); + for(uint32_t i=0; ipoint[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->origin_curve = origin_curve; + + surface->uv_domain.min.x = 0; + surface->uv_domain.max.x = 2*pi; + surface->uv_domain.min.y = 0; + surface->uv_domain.max.y = n-1; + } + 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->center_curve = 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->origin_curve = 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->first_curve = first_curve; + PRCCircle *second_curve = new PRCCircle; + second_curve->radius = 0; + surface->second_curve = 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::addCone(double radius, double height, const PRCmaterial &m, PRCFACETRANSFORM) +{ + ADDFACE(PRCCone) + 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->bottom_radius = radius; + surface->semi_angle = -atan(radius/height);; +} + +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::addRgbColor(double r, double g, double b) +{ + const PRCRgbColor color(r, g, b); + colors.push_back(color); + return 3*(colors.size()-1); +} + +uint32_t PRCFileStructure::addRgbColorUnique(double r, double g, double b) +{ + const PRCRgbColor color(r, g, b); + uint32_t color_index = m1; + PRCRgbColorMap::const_iterator iRgbColor = colorMap.find(color); + if(iRgbColor!=colorMap.end()) + { + color_index = iRgbColor->second; + } + else + { + color_index = 3*colors.size(); + colors.push_back(color); + colorMap.insert(make_pair(color,color_index)); + } + return color_index; +} + +#define ADD_ADDUNIQ( prctype, prcmap, prclist) \ +uint32_t PRCFileStructure::add##prctype(PRC##prctype *& p##prctype) \ +{ \ + prclist.push_back(p##prctype); \ + p##prctype = NULL; \ + return prclist.size()-1; \ +} \ + \ +uint32_t PRCFileStructure::add##prctype##Unique(PRC##prctype*& p##prctype) \ +{ \ + uint32_t prc_index = m1; \ + PRC##prctype##Map::const_iterator i##prctype = prcmap.find(p##prctype); \ + if(i##prctype!=prcmap.end()) \ + { \ + delete p##prctype; \ + prc_index = i##prctype->second; \ + } \ + else \ + { \ + prc_index = prclist.size(); \ + prclist.push_back(p##prctype); \ + prcmap.insert(make_pair(p##prctype,prc_index)); \ + } \ + p##prctype = NULL; \ + return prc_index; \ +} + +ADD_ADDUNIQ(UncompressedFile, uncompressedfileMap, uncompressed_files ) +ADD_ADDUNIQ(Picture, pictureMap, pictures ) +ADD_ADDUNIQ(TextureDefinition, texturedefinitionMap, texture_definitions ) +ADD_ADDUNIQ(MaterialGeneric, materialgenericMap, materials ) +ADD_ADDUNIQ(TextureApplication, textureapplicationMap, materials ) +ADD_ADDUNIQ(Style, styleMap, styles ) + +#undef ADD_ADDUNIQ + +uint32_t PRCFileStructure::addPartDefinition(PRCPartDefinition*& pPartDefinition) +{ + part_definitions.push_back(pPartDefinition); + pPartDefinition = NULL; + return part_definitions.size()-1; +} + +uint32_t PRCFileStructure::addProductOccurrence(PRCProductOccurrence*& pProductOccurrence) +{ + product_occurrences.push_back(pProductOccurrence); + pProductOccurrence = NULL; + return product_occurrences.size()-1; +} + +uint32_t PRCFileStructure::addTopoContext(PRCTopoContext*& pTopoContext) +{ + contexts.push_back(pTopoContext); + pTopoContext = NULL; + return contexts.size()-1; +} + +uint32_t PRCFileStructure::getTopoContext(PRCTopoContext*& pTopoContext) +{ + pTopoContext = new PRCTopoContext; + contexts.push_back(pTopoContext); + return contexts.size()-1; +} + +uint32_t PRCFileStructure::add3DTess(PRC3DTess*& p3DTess) +{ + tessellations.push_back(p3DTess); + p3DTess = NULL; + return tessellations.size()-1; +} + +uint32_t PRCFileStructure::add3DWireTess(PRC3DWireTess*& p3DWireTess) +{ + tessellations.push_back(p3DWireTess); + p3DWireTess = NULL; + return tessellations.size()-1; +} +/* +uint32_t PRCFileStructure::addMarkupTess(PRCMarkupTess*& pMarkupTess) +{ + tessellations.push_back(pMarkupTess); + pMarkupTess = NULL; + return tessellations.size()-1; +} + +uint32_t PRCFileStructure::addMarkup(PRCMarkup*& pMarkup) +{ + markups.push_back(pMarkup); + pMarkup = NULL; + return markups.size()-1; +} + +uint32_t PRCFileStructure::addAnnotationItem(PRCAnnotationItem*& pAnnotationItem) +{ + annotation_entities.push_back(pAnnotationItem); + pAnnotationItem = NULL; + return annotation_entities.size()-1; +} +*/ +uint32_t PRCFileStructure::addCoordinateSystem(PRCCoordinateSystem*& pCoordinateSystem) +{ + reference_coordinate_systems.push_back(pCoordinateSystem); + pCoordinateSystem = NULL; + return reference_coordinate_systems.size()-1; +} + +uint32_t PRCFileStructure::addCoordinateSystemUnique(PRCCoordinateSystem*& pCoordinateSystem) +{ + for(uint32_t i = 0; i < reference_coordinate_systems.size(); ++i) + { + if(*(reference_coordinate_systems[i])==*pCoordinateSystem) { + pCoordinateSystem = NULL; + return i; + } + } + reference_coordinate_systems.push_back(pCoordinateSystem); + pCoordinateSystem = NULL; + return reference_coordinate_systems.size()-1; +} diff --git a/src/prc/oPRCFile.h b/src/prc/oPRCFile.h new file mode 100644 index 0000000..33f97db --- /dev/null +++ b/src/prc/oPRCFile.h @@ -0,0 +1,850 @@ +/************ +* +* This file is part of a tool for producing 3D content in the PRC format. +* Copyright (C) 2008 Orest Shardt +* +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#ifndef __O_PRC_FILE_H +#define __O_PRC_FILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "PRC.h" +#include "PRCbitStream.h" +#include "writePRC.h" + +class oPRCFile; +class PRCFileStructure; + +#define EQFLD(fld) fld==c.fld +#define COMPFLD(fld) \ +if(fld != c.fld) \ +return (fld < c.fld); + +struct RGBAColour +{ + RGBAColour(double r=0.0, double g=0.0, double b=0.0, double a=1.0) : + R(r), G(g), B(b), A(a) {} + double R,G,B,A; + + void Set(double r, double g, double b, double a=1.0) + { + R = r; G = g; B = b; A = a; + } + bool operator==(const RGBAColour &c) const + { + return (EQFLD(R) && EQFLD(G) && EQFLD(B) && EQFLD(A)); + } + bool operator!=(const RGBAColour &c) const + { + return !(EQFLD(R) && EQFLD(G) && EQFLD(B) && EQFLD(A)); + } + bool operator<(const RGBAColour &c) const + { + COMPFLD(R) + COMPFLD(G) + COMPFLD(B) + COMPFLD(A) + return false; + } + friend RGBAColour operator * (const RGBAColour& a, const double d) + { return RGBAColour(a.R*d,a.G*d,a.B*d,a.A*d); } + friend RGBAColour operator * (const double d, const RGBAColour& a) + { return RGBAColour(a.R*d,a.G*d,a.B*d,a.A*d); } +}; +typedef std::map PRCcolourMap; + +struct RGBAColourWidth +{ + RGBAColourWidth(double r=0.0, double g=0.0, double b=0.0, double a=1.0, double w=1.0) : + R(r), G(g), B(b), A(a), W(w) {} + double R,G,B,A,W; + + bool operator==(const RGBAColourWidth &c) const + { + return (EQFLD(R) && EQFLD(G) && EQFLD(B) && EQFLD(A) && EQFLD(W)); + } + bool operator!=(const RGBAColourWidth &c) const + { + return !(EQFLD(R) && EQFLD(G) && EQFLD(B) && EQFLD(A) && EQFLD(W)); + } + bool operator<(const RGBAColourWidth &c) const + { + COMPFLD(R) + COMPFLD(G) + COMPFLD(B) + COMPFLD(A) + COMPFLD(W) + return false; + } +}; +typedef std::map PRCcolourwidthMap; + +struct PRCmaterial +{ + PRCmaterial() : alpha(1.0),shininess(1.0),width(1.0) {} + PRCmaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e, + const RGBAColour &s, double p, double h, double w=1.0) : + ambient(a), diffuse(d), emissive(e), specular(s), alpha(p), shininess(h), width(w) {} + + RGBAColour ambient,diffuse,emissive,specular; + double alpha,shininess,width; + + bool operator==(const PRCmaterial &c) const + { + return (EQFLD(ambient) && + EQFLD(diffuse) && + EQFLD(emissive) && + EQFLD(specular) && + EQFLD(alpha) && + EQFLD(shininess) && + EQFLD(width)); + } + bool operator<(const PRCmaterial &c) const + { + COMPFLD(ambient) + COMPFLD(diffuse) + COMPFLD(emissive) + COMPFLD(specular) + COMPFLD(alpha) + COMPFLD(shininess) + COMPFLD(width) + return false; + } +}; +typedef std::map PRCmaterialMap; + +#undef EQFLD +#undef COMPFLD + +struct PRCtexture +{ + PRCtexture() : + data(NULL), format(KEPRCPicture_BITMAP_RGBA_BYTE), width(0), height(0), size(0), + mapping(0), components(PRC_TEXTURE_MAPPING_COMPONENTS_RGBA), + function(KEPRCTextureFunction_Modulate), + wrapping_mode_S(KEPRCTextureWrappingMode_Repeat), wrapping_mode_T(KEPRCTextureWrappingMode_Repeat) {} + + const uint8_t* data; + EPRCPictureDataFormat format; + /* + KEPRCPicture_PNG + KEPRCPicture_JPG + KEPRCPicture_BITMAP_RGB_BYTE + KEPRCPicture_BITMAP_RGBA_BYTE + KEPRCPicture_BITMAP_GREY_BYTE + KEPRCPicture_BITMAP_GREYA_BYTE + */ + uint32_t width; // may be omitted for PNG and JPEG + uint32_t height; // too + uint32_t size; + + uint32_t mapping; + /* + PRC_TEXTURE_MAPPING_DIFFUSE + PRC_TEXTURE_MAPPING_BUMP + PRC_TEXTURE_MAPPING_OPACITY + PRC_TEXTURE_MAPPING_SPHERICAL_REFLECTION + */ + + uint8_t components; + /* + PRC_TEXTURE_MAPPING_COMPONENTS_RED + PRC_TEXTURE_MAPPING_COMPONENTS_GREEN + PRC_TEXTURE_MAPPING_COMPONENTS_BLUE + PRC_TEXTURE_MAPPING_COMPONENTS_RGB + PRC_TEXTURE_MAPPING_COMPONENTS_ALPHA + PRC_TEXTURE_MAPPING_COMPONENTS_RGBA + */ + + EPRCTextureFunction function; + /* + 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. + }; + */ + + EPRCTextureWrappingMode wrapping_mode_S; + EPRCTextureWrappingMode wrapping_mode_T; + /* + 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. + }; + */ + +}; + +/* +struct PRCmaterial +{ + PRCmaterial() : alpha(1.0),shininess(1.0), + picture_data(NULL), picture_format(KEPRCPicture_BITMAP_RGB_BYTE), picture_width(0), picture_height(0), picture_size(0), + picture_replace(false), picture_repeat(false) {} + PRCmaterial(const RGBAColour &a, const RGBAColour &d, const RGBAColour &e, + const RGBAColour &s, double p, double h, + const uint8_t* pic=NULL, EPRCPictureDataFormat picf=KEPRCPicture_BITMAP_RGB_BYTE, + uint32_t picw=0, uint32_t pich=0, uint32_t pics=0, bool picreplace=false, bool picrepeat=false) : + ambient(a), diffuse(d), emissive(e), specular(s), alpha(p), shininess(h), + picture_data(pic), picture_format(picf), picture_width(picw), picture_height(pich), picture_size(pics), + picture_replace(picreplace), picture_repeat(picrepeat) { + if(picture_size==0) + { + if (picture_format==KEPRCPicture_BITMAP_RGB_BYTE) + picture_size = picture_width*picture_height*3; + if (picture_format==KEPRCPicture_BITMAP_RGBA_BYTE) + picture_size = picture_width*picture_height*4; + if (picture_format==KEPRCPicture_BITMAP_GREY_BYTE) + picture_size = picture_width*picture_height*1; + if (picture_format==KEPRCPicture_BITMAP_GREYA_BYTE) + picture_size = picture_width*picture_height*2; + } + } + RGBAColour ambient,diffuse,emissive,specular; + double alpha,shininess; + const uint8_t* picture_data; + EPRCPictureDataFormat picture_format; + uint32_t picture_width; + uint32_t picture_height; + uint32_t picture_size; + bool picture_replace; // replace material color with texture color? if false - just modify + bool picture_repeat; // repeat texture? if false - clamp to edge + + bool operator==(const PRCmaterial &m) const + { + return (ambient==m.ambient && diffuse==m.diffuse && emissive==m.emissive + && specular==m.specular && alpha==m.alpha && shininess==m.shininess + && picture_replace==m.picture_replace && picture_repeat==m.picture_repeat + && picture_format==m.picture_format + && picture_width==m.picture_width && picture_height==m.picture_height && picture_size==m.picture_size + && (picture_data==m.picture_data || memcmp(picture_data,m.picture_data,picture_size)==0) ); + } + bool operator<(const PRCmaterial &m) const + { + if(ambient!=m.ambient) + return (ambient PRCmaterialMap; +*/ + +struct PRCtessrectangle // rectangle +{ + PRCVector3d vertices[4]; + uint32_t style; +}; +typedef std::vector PRCtessrectangleList; + +struct PRCtessquad // rectangle +{ + PRCVector3d vertices[4]; + RGBAColour colours[4]; +}; +typedef std::vector PRCtessquadList; +/* +struct PRCtesstriangle // textured triangle +{ + PRCtesstriangle() : + style(m1) {} + PRCVector3d vertices[3]; +// PRCVector3d normals[3]; +// RGBAColour colors[3]; + PRCVector2d texcoords[3]; + uint32_t style; +}; +typedef std::vector PRCtesstriangleList; +*/ +struct PRCtessline // polyline +{ + std::vector point; + PRCRgbColor color; +}; +typedef std::list PRCtesslineList; +typedef std::map PRCtesslineMap; + +struct PRCface +{ + PRCface() : transform(NULL), face(NULL) {} + uint32_t style; + bool transparent; + PRCGeneralTransformation3d* transform; + PRCFace* face; +}; +typedef std::vector PRCfaceList; + +struct PRCcompface +{ + PRCcompface() : face(NULL) {} + uint32_t style; + bool transparent; + PRCCompressedFace* face; +}; +typedef std::vector PRCcompfaceList; + +struct PRCwire +{ + PRCwire() : style(m1), transform(NULL), curve(NULL) {} + uint32_t style; + PRCGeneralTransformation3d* transform; + PRCCurve* curve; +}; +typedef std::vector PRCwireList; + +typedef std::map > 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 + double crease_angle; // crease angle for meshes + + PRCoptions(double compression=0.0, double granularity=0.0, bool closed=false, + bool tess=false, bool do_break=true, bool no_break=false, double crease_angle=25.8419) + : compression(compression), granularity(granularity), closed(closed), + tess(tess), do_break(do_break), no_break(no_break), crease_angle(crease_angle) {} +}; + +class PRCgroup +{ + public: + PRCgroup() : + product_occurrence(NULL), parent_product_occurrence(NULL), part_definition(NULL), parent_part_definition(NULL), transform(NULL) {} + PRCgroup(const std::string& name) : + product_occurrence(NULL), parent_product_occurrence(NULL), part_definition(NULL), parent_part_definition(NULL), transform(NULL), name(name) {} + PRCProductOccurrence *product_occurrence, *parent_product_occurrence; + PRCPartDefinition *part_definition, *parent_part_definition; + PRCfaceList faces; + PRCcompfaceList compfaces; + PRCtessrectangleList rectangles; +// PRCtesstriangleList triangles; + PRCtessquadList quads; + PRCtesslineMap lines; + PRCwireList wires; + PRCpointsetMap points; + std::vector pointsets; + std::vector polymodels; + std::vector polywires; + PRCGeneralTransformation3d* transform; + std::string name; + PRCoptions options; +}; + +void makeFileUUID(PRCUniqueId&); +void makeAppUUID(PRCUniqueId&); + +class PRCStartHeader +{ + public: + uint32_t minimal_version_for_read; // PRCVersion + uint32_t authoring_version; // PRCVersion + PRCUniqueId file_structure_uuid; + PRCUniqueId application_uuid; // should be 0 + + PRCStartHeader() : + minimal_version_for_read(PRCVersion), authoring_version(PRCVersion) {} + void serializeStartHeader(std::ostream&) const; + void serializeUncompressedFiles(std::ostream&) const; + + PRCUncompressedFileList uncompressed_files; + uint32_t getStartHeaderSize() const; + uint32_t getUncompressedFilesSize() const; +}; + +class PRCFileStructure : public PRCStartHeader +{ + public: + uint32_t number_of_referenced_file_structures; + double tessellation_chord_height_ratio; + double tessellation_angle_degree; + std::string default_font_family_name; + PRCRgbColorList colors; + PRCRgbColorMap colorMap; + PRCPictureList pictures; + PRCPictureMap pictureMap; + PRCUncompressedFileMap uncompressedfileMap; + PRCTextureDefinitionList texture_definitions; + PRCTextureDefinitionMap texturedefinitionMap; + PRCMaterialList materials; + PRCMaterialGenericMap materialgenericMap; + PRCTextureApplicationMap textureapplicationMap; + PRCStyleList styles; + PRCStyleMap styleMap; + + PRCCoordinateSystemList reference_coordinate_systems; + std::vector font_keys_of_font; + PRCPartDefinitionList part_definitions; + PRCProductOccurrenceList product_occurrences; +// PRCMarkupList markups; +// PRCAnnotationItemList annotation_entities; + double unit; + PRCTopoContextList contexts; + PRCTessList tessellations; + + uint32_t sizes[6]; + uint8_t *globals_data; + PRCbitStream globals_out; // order matters: PRCbitStream must be initialized last + uint8_t *tree_data; + PRCbitStream tree_out; + uint8_t *tessellations_data; + PRCbitStream tessellations_out; + uint8_t *geometry_data; + PRCbitStream geometry_out; + uint8_t *extraGeometry_data; + PRCbitStream extraGeometry_out; + + ~PRCFileStructure () { + for(PRCUncompressedFileList::iterator it=uncompressed_files.begin(); it!=uncompressed_files.end(); ++it) delete *it; + for(PRCPictureList::iterator it=pictures.begin(); it!=pictures.end(); ++it) delete *it; + for(PRCTextureDefinitionList::iterator it=texture_definitions.begin(); it!=texture_definitions.end(); ++it) delete *it; + for(PRCMaterialList::iterator it=materials.begin(); it!=materials.end(); ++it) delete *it; + for(PRCStyleList::iterator it=styles.begin(); it!=styles.end(); ++it) delete *it; + for(PRCTopoContextList::iterator it=contexts.begin(); it!=contexts.end(); ++it) delete *it; + for(PRCTessList::iterator it=tessellations.begin(); it!=tessellations.end(); ++it) delete *it; + for(PRCPartDefinitionList::iterator it=part_definitions.begin(); it!=part_definitions.end(); ++it) delete *it; + for(PRCProductOccurrenceList::iterator it=product_occurrences.begin(); it!=product_occurrences.end(); ++it) delete *it; + for(PRCCoordinateSystemList::iterator it=reference_coordinate_systems.begin(); it!=reference_coordinate_systems.end(); it++) + delete *it; + + free(globals_data); + free(tree_data); + free(tessellations_data); + free(geometry_data); + free(extraGeometry_data); + } + + PRCFileStructure() : + number_of_referenced_file_structures(0), + tessellation_chord_height_ratio(2000.0),tessellation_angle_degree(40.0), + default_font_family_name(""), + unit(1), + globals_data(NULL),globals_out(globals_data,0), + tree_data(NULL),tree_out(tree_data,0), + tessellations_data(NULL),tessellations_out(tessellations_data,0), + geometry_data(NULL),geometry_out(geometry_data,0), + extraGeometry_data(NULL),extraGeometry_out(extraGeometry_data,0) {} + void write(std::ostream&); + void prepare(); + uint32_t getSize(); + void serializeFileStructureGlobals(PRCbitStream&); + void serializeFileStructureTree(PRCbitStream&); + void serializeFileStructureTessellation(PRCbitStream&); + void serializeFileStructureGeometry(PRCbitStream&); + void serializeFileStructureExtraGeometry(PRCbitStream&); + uint32_t addPicture(EPRCPictureDataFormat format, uint32_t size, const uint8_t *picture, uint32_t width=0, uint32_t height=0, std::string name=""); +#define ADD_ADDUNIQ( prctype ) \ +uint32_t add##prctype( PRC##prctype*& p##prctype ); \ +uint32_t add##prctype##Unique( PRC##prctype*& p##prctype); + + ADD_ADDUNIQ( UncompressedFile ) + ADD_ADDUNIQ( Picture ) + ADD_ADDUNIQ( TextureDefinition ) + ADD_ADDUNIQ( TextureApplication ) + ADD_ADDUNIQ( MaterialGeneric ) + ADD_ADDUNIQ( Style ) + +#undef ADD_ADDUNIQ + + uint32_t addRgbColor(double r, double g, double b); + uint32_t addRgbColorUnique(double r, double g, double b); + uint32_t addPartDefinition(PRCPartDefinition*& pPartDefinition); + uint32_t addProductOccurrence(PRCProductOccurrence*& pProductOccurrence); + uint32_t addTopoContext(PRCTopoContext*& pTopoContext); + uint32_t getTopoContext(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 +{ + public: + PRCUniqueId UUID; + uint32_t reserved; // 0 + uint32_t number_of_offsets; + uint32_t *offsets; + + void write(std::ostream&); + + uint32_t getSize(); +}; + +class PRCHeader : public PRCStartHeader +{ + public : + uint32_t number_of_file_structures; + PRCFileStructureInformation *fileStructureInformation; + uint32_t model_file_offset; + uint32_t file_size; // not documented + + void write(std::ostream&); + uint32_t getSize(); +}; + +typedef std::map PRCtransformMap; + +class oPRCFile +{ + public: + oPRCFile(std::ostream &os, double u=1, uint32_t n=1) : + number_of_file_structures(n), + fileStructures(new PRCFileStructure*[n]), + unit(u), + modelFile_data(NULL),modelFile_out(modelFile_data,0), + fout(NULL),output(os) + { + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructures[i] = new PRCFileStructure(); + fileStructures[i]->minimal_version_for_read = PRCVersion; + fileStructures[i]->authoring_version = PRCVersion; + makeFileUUID(fileStructures[i]->file_structure_uuid); + makeAppUUID(fileStructures[i]->application_uuid); + fileStructures[i]->unit = u; + } + + groups.push(PRCgroup()); + PRCgroup &group = groups.top(); + group.name="root"; + group.transform = NULL; + group.product_occurrence = new PRCProductOccurrence(group.name); + group.parent_product_occurrence = NULL; + group.part_definition = new PRCPartDefinition; + group.parent_part_definition = NULL; + } + + oPRCFile(const std::string &name, double u=1, uint32_t n=1) : + number_of_file_structures(n), + fileStructures(new PRCFileStructure*[n]), + unit(u), + modelFile_data(NULL),modelFile_out(modelFile_data,0), + fout(new std::ofstream(name.c_str(), + std::ios::out|std::ios::binary|std::ios::trunc)), + output(*fout) + { + for(uint32_t i = 0; i < number_of_file_structures; ++i) + { + fileStructures[i] = new PRCFileStructure(); + fileStructures[i]->minimal_version_for_read = PRCVersion; + fileStructures[i]->authoring_version = PRCVersion; + makeFileUUID(fileStructures[i]->file_structure_uuid); + makeAppUUID(fileStructures[i]->application_uuid); + fileStructures[i]->unit = u; + } + + groups.push(PRCgroup()); + PRCgroup &group = groups.top(); + group.name="root"; + group.transform = NULL; + group.product_occurrence = new PRCProductOccurrence(group.name); + group.parent_product_occurrence = NULL; + group.part_definition = new PRCPartDefinition; + group.parent_part_definition = NULL; + } + + ~oPRCFile() + { + for(uint32_t i = 0; i < number_of_file_structures; ++i) + delete fileStructures[i]; + delete[] fileStructures; + if(fout != NULL) + delete fout; + free(modelFile_data); + } + + void begingroup(const char *name, const PRCoptions *options=NULL, + const double* t=NULL); + void endgroup(); + + std::string lastgroupname; + std::vector lastgroupnames; + std::string calculate_unique_name(const ContentPRCBase *prc_entity,const ContentPRCBase *prc_occurence); + + bool finish(); + uint32_t getSize(); + + const uint32_t number_of_file_structures; + PRCFileStructure **fileStructures; + PRCHeader header; + PRCUnit unit; + uint8_t *modelFile_data; + PRCbitStream modelFile_out; // order matters: PRCbitStream must be initialized last + PRCmaterialMap materialMap; + PRCcolourMap colourMap; + PRCcolourwidthMap colourwidthMap; + PRCgroup rootGroup; + PRCtransformMap transformMap; + std::stack groups; + PRCgroup& findGroup(); + void doGroup(PRCgroup& group); + uint32_t addColour(const RGBAColour &colour); + uint32_t addColourWidth(const RGBAColour &colour, double width); + uint32_t addLineMaterial(const RGBAColour& c, double width) + { return addColourWidth(c,width); } + uint32_t addMaterial(const PRCmaterial &material); + uint32_t addTexturedMaterial(const PRCmaterial &material, uint32_t n=0, const PRCtexture* const* tt=NULL); + uint32_t addTransform(PRCGeneralTransformation3d*& transform); + uint32_t addTransform(const double* t); + uint32_t addTransform(const double origin[3], const double x_axis[3], const double y_axis[3], double scale); + void addPoint(const double P[3], const RGBAColour &c, double w=1.0); + void addPoint(double x, double y, double z, const RGBAColour &c, double w); + void addPoints(uint32_t n, const double P[][3], const RGBAColour &c, double w=1.0); + void addPoints(uint32_t n, const double P[][3], uint32_t style_index); + void addLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[], + const RGBAColour& c, double w, + bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]); + uint32_t createLines(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[], + bool segment_color, uint32_t nC, const RGBAColour C[], uint32_t nCI, const uint32_t CI[]); + uint32_t createSegments(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][2], + bool segment_color, uint32_t nC, const RGBAColour C[], const uint32_t CI[][2]); + + void addTriangles(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial& m, + uint32_t nN, const double N[][3], const uint32_t NI[][3], + uint32_t nT, const double T[][2], const uint32_t TI[][3], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][3], + uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca); + uint32_t createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], uint32_t style_index, + uint32_t nN, const double N[][3], const uint32_t NI[][3], + uint32_t nT, const double T[][2], const uint32_t TI[][3], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][3], + uint32_t nS, const uint32_t S[], const uint32_t SI[], double ca); + uint32_t createTriangleMesh(uint32_t nP, const double P[][3], uint32_t nI, const uint32_t PI[][3], const PRCmaterial& m, + uint32_t nN, const double N[][3], const uint32_t NI[][3], + uint32_t nT, const double T[][2], const uint32_t TI[][3], + uint32_t nC, const RGBAColour C[], const uint32_t CI[][3], + uint32_t nM, const PRCmaterial M[], const uint32_t MI[], double ca) + { + const uint32_t style = addMaterial(m); + if(M!=NULL && nM>0) + { + uint32_t* const styles = new uint32_t[nM]; + for(uint32_t i=0; i0) + { + uint32_t* const styles = new uint32_t[nM]; + for(uint32_t i=0; iaddPicture(format, size, picture, width, height, name); } + +#define ADD_ADDUNIQ( prctype ) \ + uint32_t add##prctype(PRC##prctype*& p##prctype, uint32_t fileStructure=0) \ + { return fileStructures[fileStructure]->add##prctype( p##prctype ); } \ + uint32_t add##prctype##Unique(PRC##prctype*& p##prctype, uint32_t fileStructure=0) \ + { return fileStructures[fileStructure]->add##prctype##Unique(p##prctype); } + + ADD_ADDUNIQ( TextureDefinition ) + ADD_ADDUNIQ( TextureApplication ) + ADD_ADDUNIQ( MaterialGeneric ) + ADD_ADDUNIQ( Style ) +#undef ADD_ADDUNIQ + uint32_t addRgbColor(double r, double g, double b, + uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addRgbColor(r, g, b); + } + uint32_t addRgbColorUnique(double r, double g, double b, + uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->addRgbColorUnique(r, g, b); + } + 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 getTopoContext(PRCTopoContext*& pTopoContext, uint32_t fileStructure=0) + { + return fileStructures[fileStructure]->getTopoContext(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: + void serializeModelFileData(PRCbitStream&); + std::ofstream *fout; + std::ostream &output; +}; + +#endif // __O_PRC_FILE_H diff --git a/src/prc/writePRC.cc b/src/prc/writePRC.cc new file mode 100644 index 0000000..098b4b7 --- /dev/null +++ b/src/prc/writePRC.cc @@ -0,0 +1,2097 @@ +/************ +* +* This file is part of a tool for producing 3D content in the PRC format. +* Copyright (C) 2008 Orest Shardt +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#include "writePRC.h" +#include +#include + +// debug print includes +#include +#include +#include +#include + +#if !defined(__GNUC__) || defined(__clang__) +#include +#endif + +#include + +using namespace std; + +#ifndef __GNUC_PREREQ +#define __GNUC_PREREQ(maj, min) (0) +#endif + +// Count leading zeros. +uint32_t CLZ(uint32_t a) +{ +#if __GNUC_PREREQ(3,4) + return __builtin_clz(a); +#else +// find the log base 2 of a 32-bit integer + static const int MultiplyDeBruijnBitPosition[32] = { + 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, + 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 + }; + + a |= a >> 1; // first round down to one less than a power of 2 + a |= a >> 2; + a |= a >> 4; + a |= a >> 8; + a |= a >> 16; + + return 31-MultiplyDeBruijnBitPosition[(uint32_t)(a * 0x07C4ACDDU) >> 27]; +#endif +} + +// Portable integer implementation of ceil(log2(x)). +uint32_t Log2(uint32_t x) +{ + assert(x != 0); + uint32_t L=31-CLZ(x); + return ((uint32_t) 1 << L == x) ? L : L+1; +} + +#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 serializeContentPRCBase(pbs); +#define SerializeGraphics serializeGraphics(pbs); +#define SerializePRCBaseWithGraphics { serializeContentPRCBase(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 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); +#define SerializeAttributeEntry serializeAttributeEntry(pbs); +#define SerializeContentSingleAttribute( value ) (value).serializeSingleAttribute(pbs); +#define SerializeAttribute( value ) (value).serializeAttribute(pbs); +#define SerializeAttributeData serializeAttributes(pbs); +#define WriteUncompressedUnsignedInteger( value ) writeUncompressedUnsignedInteger(out, (uint32_t)(value)); +#define SerializeFileStructureUncompressedUniqueId( value ) (value).serializeFileStructureUncompressedUniqueId(out); + +void writeUncompressedUnsignedInteger(ostream &out, uint32_t data) +{ +#ifdef WORDS_BIGENDIAN + out.write(((char*)&data)+3,1); + out.write(((char*)&data)+2,1); + out.write(((char*)&data)+1,1); + out.write(((char*)&data)+0,1); +#else + out.write(((char*)&data)+0,1); + out.write(((char*)&data)+1,1); + out.write(((char*)&data)+2,1); + out.write(((char*)&data)+3,1); +#endif +} + +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; +} + +double PRCVector2d::Length() +{ + return sqrt(x*x+y*y); +} + +bool PRCVector2d::Normalize() +{ + double fLength=Length(); + if(fLength < FLT_EPSILON) return false; + double factor=1.0/fLength; + x *= factor; + y *= factor; + + return true; +} + +void PRCVector2d::serializeVector2d(PRCbitStream &pbs) +{ + WriteDouble (x) + WriteDouble (y) +} + +uint32_t makeCADID() +{ + static uint32_t ID = 1; + return ID++; +} + +uint32_t makePRCID() +{ + static uint32_t ID = 1; + return ID++; +} + +bool type_eligible_for_reference(uint32_t type) +{ + if( + type == PRC_TYPE_MISC_EntityReference || + type == PRC_TYPE_MISC_MarkupLinkedItem || + type == PRC_TYPE_RI_BrepModel || + type == PRC_TYPE_RI_Curve || + type == PRC_TYPE_RI_Direction || + type == PRC_TYPE_RI_Plane || + type == PRC_TYPE_RI_PointSet || + type == PRC_TYPE_RI_PolyBrepModel || + type == PRC_TYPE_RI_PolyWire || + type == PRC_TYPE_RI_Set || + type == PRC_TYPE_RI_CoordinateSystem || + type == PRC_TYPE_ASM_ProductOccurence || + type == PRC_TYPE_ASM_PartDefinition || + type == PRC_TYPE_ASM_Filter || + type == PRC_TYPE_MKP_View || + type == PRC_TYPE_MKP_Markup || + type == PRC_TYPE_MKP_Leader || + type == PRC_TYPE_MKP_AnnotationItem || + type == PRC_TYPE_MKP_AnnotationSet || + type == PRC_TYPE_MKP_AnnotationReference || + type == PRC_TYPE_GRAPH_Style || + type == PRC_TYPE_GRAPH_Material || + type == PRC_TYPE_GRAPH_TextureApplication || + type == PRC_TYPE_GRAPH_TextureDefinition || + type == PRC_TYPE_GRAPH_LinePattern || + type == PRC_TYPE_GRAPH_DottingPattern || + type == PRC_TYPE_GRAPH_HatchingPattern || + type == PRC_TYPE_GRAPH_SolidPattern || + type == PRC_TYPE_GRAPH_VPicturePattern || + type == PRC_TYPE_GRAPH_AmbientLight || + type == PRC_TYPE_GRAPH_PointLight || + type == PRC_TYPE_GRAPH_DirectionalLight || + type == PRC_TYPE_GRAPH_SpotLight || + type == PRC_TYPE_GRAPH_SceneDisplayParameters || + type == PRC_TYPE_GRAPH_Camera + ) + return true; + else + return false; +} + +void UserData::write(PRCbitStream &pbs) +{ + pbs << size; + 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]; + for(uint32_t j = 0; j < rem; ++j) // 0-based, big endian bit counting + pbs << (bool)((data[quot] & (0x80 >> j))!=0); + } +} + +void PRCAttributeEntry::serializeAttributeEntry(PRCbitStream &pbs) const +{ + WriteBoolean (title_is_integer) + if (title_is_integer) + WriteUnsignedInteger (title_integer) + else + WriteString (title_text) +} + +void PRCSingleAttribute::serializeSingleAttribute(PRCbitStream &pbs) const +{ + SerializeAttributeEntry + WriteUnsignedInteger (type) + switch (type) + { + case KEPRCModellerAttributeTypeInt: + WriteInteger (value.integer) + break; + case KEPRCModellerAttributeTypeReal: + WriteDouble (value.real) + break; + case KEPRCModellerAttributeTypeTime: + WriteUnsignedInteger (value.time) + break; + case KEPRCModellerAttributeTypeString: + WriteString (value_text) + break; + default: + break; + } +} + +void PRCAttribute::serializeAttribute(PRCbitStream &pbs) const +{ + WriteUnsignedInteger (PRC_TYPE_MISC_Attribute) + + SerializeAttributeEntry + const uint32_t size_of_attribute_keys = attribute_keys.size(); + WriteUnsignedInteger (size_of_attribute_keys) + for(uint32_t i=0;i out_it (out); + copy ( file_contents.begin(), file_contents.end(), out_it ); +} + +uint32_t PRCUncompressedFile::getSize() const +{ + return sizeof(uint32_t)+file_contents.size(); +} + +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 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 PRCLinePattern::serializeLinePattern(PRCbitStream &pbs) +{ + uint32_t i = 0; + WriteUnsignedInteger (PRC_TYPE_GRAPH_LinePattern) + SerializeContentPRCBase + + const uint32_t size_lengths = lengths.size(); + WriteUnsignedInteger (size_lengths) + for (i=0;i>8)&0xFF); + 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() +{ + current_layer_index = m1; + current_index_of_line_style = m1; + current_behaviour_bit_field = 1; +} + +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;iserializeTransformation3d(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 &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 &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= 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 ? 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 ? 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; + +#if defined( __GNUC__ ) && !defined( __clang__ ) + PRCVector3d P[number_of_control_point_in_u][number_of_control_point_in_v]; +#else + vector > P(number_of_control_point_in_u, vector(number_of_control_point_in_v)); +#endif + for(uint32_t i=0;i > compressed_control_point(number_of_control_point_in_u, vector(number_of_control_point_in_v)); + vector > control_point_type(number_of_control_point_in_u, vector(number_of_control_point_in_v)); +#endif + + 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_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 PRCCone::serializeCone(PRCbitStream &pbs) +{ + WriteUnsignedInteger (PRC_TYPE_SURF_Cone) + + SerializeContentSurface + SerializeTransformation + SerializeUVParameterization + WriteDouble ( bottom_radius ) + WriteDouble ( semi_angle ) +} + +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;iserialType() ) + 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;itopo_item_type == PRC_TYPE_TOPO_BrepData && dynamic_cast(body[i])) + { + PRCBrepData *body_i = dynamic_cast(body[i]); + for (j=0;jconnex.size();j++) + { + for(k=0;kconnex[j]->shell.size();k++) + { + for( l=0;lconnex[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(body[i])) + { + PRCCompressedBrepData *body_i = dynamic_cast(body[i]); + for( l=0;lface.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;ihas_graphics() ) + if (element[j]->has_graphics()) + { + element[j]->serializeGraphics(pbs); + } + } + } +} + +uint32_t PRCTopoContext::addSingleWireBody(PRCSingleWireBody*& pSingleWireBody) +{ + body.push_back(pSingleWireBody); + pSingleWireBody = NULL; + return body.size()-1; +} + +uint32_t PRCTopoContext::addBrepData(PRCBrepData*& pBrepData) +{ + body.push_back(pBrepData); + pBrepData = NULL; + return body.size()-1; +} + +uint32_t PRCTopoContext::addCompressedBrepData(PRCCompressedBrepData*& pCompressedBrepData) +{ + body.push_back(pCompressedBrepData); + pCompressedBrepData = NULL; + return body.size()-1; +} + +void PRCSingleWireBody::serializeSingleWireBody(PRCbitStream &pbs) +{ + WriteUnsignedInteger ( PRC_TYPE_TOPO_SingleWireBody) + + SerializeContentBody + SerializePtrTopology ( wire_edge ) +} + +void PRCUniqueId::serializeCompressedUniqueId(PRCbitStream &pbs) const +{ + WriteUnsignedInteger (id0) + WriteUnsignedInteger (id1) + WriteUnsignedInteger (id2) + WriteUnsignedInteger (id3) +} + +void PRCUniqueId::serializeFileStructureUncompressedUniqueId(std::ostream& out) const +{ + WriteUncompressedUnsignedInteger (id0) + WriteUncompressedUnsignedInteger (id1) + WriteUncompressedUnsignedInteger (id2) + WriteUncompressedUnsignedInteger (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;iserializeTransformation3d (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(pBrepModel); + pBrepModel = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPolyBrepModel(PRCPolyBrepModel*& pPolyBrepModel) +{ + representation_item.push_back(pPolyBrepModel); + pPolyBrepModel = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPointSet(PRCPointSet*& pPointSet) +{ + representation_item.push_back(pPointSet); + pPointSet = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addSet(PRCSet*& pSet) +{ + representation_item.push_back(pSet); + pSet = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addWire(PRCWire*& pWire) +{ + representation_item.push_back(pWire); + pWire = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addPolyWire(PRCPolyWire*& pPolyWire) +{ + representation_item.push_back(pPolyWire); + pPolyWire = NULL; + return representation_item.size()-1; +} + +uint32_t PRCPartDefinition::addRepresentationItem(PRCRepresentationItem*& pRepresentationItem) +{ + representation_item.push_back(pRepresentationItem); + pRepresentationItem = NULL; + 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 +* +* 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 +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see . +* +*************/ + +#ifndef __WRITE_PRC_H +#define __WRITE_PRC_H +#include +#include +#include +#include +#include +#include +#include +#include "PRCbitStream.h" +#include "PRC.h" +#include +#include + +static const uint32_t m1=(uint32_t)-1; +static const double pi=acos(-1.0); + +class PRCVector3d +{ +public : + double x; + double y; + double z; + PRCVector3d() : + x(0), y(0), z(0) {} + PRCVector3d(double fx, double fy, double fz) : + x(fx), y(fy), z(fz) {} + PRCVector3d(const double c[], double fx=0, double fy=0, double fz=0) : + x(c?c[0]:fx), y(c?c[1]:fy), z(c?c[2]:fz) {} + 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 attribute_keys; +}; +typedef std::list PRCAttributeList; + +class PRCAttributes +{ + public: + void serializeAttributes(PRCbitStream&) const; + PRCAttribute& newAttribute() { attributes.push_front(PRCAttribute()); return attributes.front(); } + void addAttribute(const PRCAttribute &attribute) { attributes.push_front(attribute); } + PRCAttributeList attributes; +}; + +bool type_eligible_for_reference(uint32_t type); +uint32_t makeCADID(); +uint32_t makePRCID(); + +class ContentPRCBase : public PRCAttributes +{ + public: + ContentPRCBase(uint32_t t, std::string n="") : + type(t),name(n),CAD_identifier(0), CAD_persistent_identifier(0), PRC_unique_identifier(0) + { + if(type_eligible_for_reference(type)) + { + CAD_identifier = makeCADID(); + PRC_unique_identifier = makePRCID(); + } + } + void serializeContentPRCBase(PRCbitStream&) const; + uint32_t getPRCID() const { return PRC_unique_identifier; } + uint32_t getType() const { return type; } + uint32_t type; + std::string name; + uint32_t CAD_identifier, CAD_persistent_identifier, PRC_unique_identifier; +}; + +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 std::string currentName; +void writeName(PRCbitStream&,const std::string&); +void resetName(); + +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,uint16_t=1,bool=false); +void resetGraphics(); + +void resetGraphicsAndName(); + +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; + PRCVector2d(const double c[], double fx=0, double fy=0) : + x(c?c[0]:fx), y(c?c[1]:fy) {} + PRCVector2d(const PRCVector2d& sVector2d) : + x(sVector2d.x), y(sVector2d.y) {} + + void Set(double fx, double fy) + { x = fx; y = fy; } + double Dot(const PRCVector2d & sPt) const + { return(x*sPt.x)+(y*sPt.y); } + double LengthSquared() + { return(x*x+y*y); } + + friend PRCVector2d operator + (const PRCVector2d& a, const PRCVector2d& b) + { return PRCVector2d(a.x+b.x,a.y+b.y); } + friend PRCVector2d operator - (const PRCVector2d& a) + { return PRCVector2d(-a.x,-a.y); } + friend PRCVector2d operator - (const PRCVector2d& a, const PRCVector2d& b) + { return PRCVector2d(a.x-b.x,a.y-b.y); } + friend PRCVector2d operator * (const PRCVector2d& a, const double d) + { return PRCVector2d(a.x*d,a.y*d); } + friend PRCVector2d operator * (const double d, const PRCVector2d& a) + { return PRCVector2d(a.x*d,a.y*d); } + friend PRCVector2d operator / (const PRCVector2d& a, const double d) + { return PRCVector2d(a.x/d,a.y/d); } + + double Length(); + bool Normalize(); + + bool operator==(const PRCVector2d &v) const + { + return x==v.x && y==v.y; + } + bool operator!=(const PRCVector2d &v) const + { + return !(x==v.x && y==v.y); + } + bool operator<(const PRCVector2d &v) const + { + if(x!=v.x) + return (x \ +{ bool operator()(const PRCtype* Left, const PRCtype* Right) const { return (*Left < *Right); } }; \ +typedef std::map PRCtype##Map; +#define PRCLIST(PRCtype) \ +typedef std::deque PRCtype##List; + + +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 (EQFLD(red) && + EQFLD(green) && + EQFLD(blue) + ); + } + bool operator!=(const PRCRgbColor &c) const + { + return !(EQFLD(red) && + EQFLD(green) && + EQFLD(blue) + ); + } + bool operator<(const PRCRgbColor &c) const + { + COMPFLD(red) + COMPFLD(green) + COMPFLD(blue) + return false; + } +}; +typedef std::map PRCRgbColorMap; +typedef std::deque PRCRgbColorList; + +class PRCUncompressedFile +{ +public: + PRCUncompressedFile() {} + PRCUncompressedFile(uint32_t fs, uint8_t *d) { + file_contents.assign( d, d + fs ); + } + + std::vector file_contents; + + void serializeUncompressedFile(std::ostream&) const; + + uint32_t getSize() const; + + bool operator==(const PRCUncompressedFile& c) const + { + return file_contents==c.file_contents; + } + bool operator<(const PRCUncompressedFile& c) const + { + return file_contents lengths; + double phase; + bool is_real_length; +}; +typedef std::deque PRCLinePatternList; + +class PRCStyle : public ContentPRCBase +{ +public: + PRCStyle(std::string n="") : + ContentPRCBase(PRC_TYPE_GRAPH_Style,n), 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; + bool operator==(const PRCStyle& c) const + { + return (EQFLD(line_width) && + EQFLD(is_vpicture) && + EQFLD(line_pattern_vpicture_index) && + EQFLD(is_material) && + EQFLD(color_material_index) && + EQFLD(is_transparency_defined) && + EQFLD(transparency) && + EQFLD(additional) && + EQFLD(name) + ); + } + bool operator<(const PRCStyle& c) const + { + COMPFLD(line_width) + COMPFLD(is_vpicture) + COMPFLD(line_pattern_vpicture_index) + COMPFLD(is_material) + COMPFLD(color_material_index) + COMPFLD(is_transparency_defined) + COMPFLD(transparency) + COMPFLD(additional) + COMPFLD(name) + return false; + } + +}; +PRCLIST(PRCStyle) +PRCMAP(PRCStyle) + +#undef EQFLD +#undef COMPFLD +#undef PRCMAP + + +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 line_attributes; + uint32_t start_wire; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2 + std::vector 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 sizes_triangulated; + uint32_t number_of_texture_coordinate_indexes; + bool is_rgba; + std::vector rgba_vertices; + uint32_t behaviour; +}; +typedef std::deque PRCTessFaceList; + +class PRCContentBaseTessData +{ +public: + PRCContentBaseTessData() : + is_calculated(false) {} + void serializeContentBaseTessData(PRCbitStream&); + bool is_calculated; + std::vector coordinates; +}; + +class PRCTess : public PRCContentBaseTessData +{ +public: + virtual ~PRCTess() {} + virtual void serializeBaseTessData(PRCbitStream &pbs) = 0; +}; +typedef std::deque PRCTessList; + +class PRC3DTess : public PRCTess +{ +public: + PRC3DTess() : + has_faces(false), has_loops(false), + crease_angle(25.8419) // arccos(0.9), default found in Acrobat output + {} + ~PRC3DTess() { for(PRCTessFaceList::iterator it=face_tessellation.begin(); it!=face_tessellation.end(); ++it) delete *it; } + void serialize3DTess(PRCbitStream&); + void serializeBaseTessData(PRCbitStream &pbs) { serialize3DTess(pbs); } + void addTessFace(PRCTessFace*& pTessFace); + + bool has_faces; + bool has_loops; + double crease_angle; + std::vector normal_coordinate; + std::vector wire_index; // specifing bounding wire seems not to work as of Acrobat/Reader 9.2 + std::vector triangulated_index; + PRCTessFaceList face_tessellation; + std::vector 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 wire_indexes; + std::vector rgba_vertices; +}; + +class PRCMarkupTess : public PRCTess +{ +public: + PRCMarkupTess() : + behaviour(0) + {} + void serializeMarkupTess(PRCbitStream&); + void serializeBaseTessData(PRCbitStream &pbs) { serializeMarkupTess(pbs); } + + std::vector codes; + std::vector 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::deque PRCGraphicsList; + +void writeGraphics(PRCbitStream&,const PRCGraphics&,bool=false); + +class PRCMarkup: public PRCGraphics, public ContentPRCBase +{ +public: + PRCMarkup(std::string n="") : + ContentPRCBase(PRC_TYPE_MKP_Markup,n), + type(KEPRCMarkupType_Unknown), sub_type(KEPRCMarkupSubType_Unknown), index_tessellation(m1) {} + void serializeMarkup(PRCbitStream&); + EPRCMarkupType type; + EPRCMarkupSubType sub_type; +// vector linked_items; +// vector leaders; + uint32_t index_tessellation; +}; +typedef std::deque PRCMarkupList; + +class PRCAnnotationItem: public PRCGraphics, public ContentPRCBase +{ +public: + PRCAnnotationItem(std::string n="") : + ContentPRCBase(PRC_TYPE_MKP_AnnotationItem,n) {} + void serializeAnnotationItem(PRCbitStream&); + void serializeAnnotationEntity(PRCbitStream &pbs) { serializeAnnotationItem(pbs); } + PRCReferenceUniqueIdentifier markup; +}; +typedef std::deque PRCAnnotationItemList; + +class PRCRepresentationItemContent: public PRCGraphics, public ContentPRCBase +{ +public: + PRCRepresentationItemContent(uint32_t t, std::string n="") : + ContentPRCBase(t,n), + 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(uint32_t t, std::string n="") : + PRCRepresentationItemContent(t,n) {} + virtual ~PRCRepresentationItem() {} + virtual void serializeRepresentationItem(PRCbitStream &pbs) = 0; +}; +typedef std::deque PRCRepresentationItemList; + +class PRCBrepModel : public PRCRepresentationItem +{ +public: + PRCBrepModel(std::string n="") : + PRCRepresentationItem(PRC_TYPE_RI_BrepModel,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(PRC_TYPE_RI_PolyBrepModel,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(PRC_TYPE_RI_PointSet,n) {} + void serializePointSet(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializePointSet(pbs); } + std::vector point; +}; + +class PRCWire : public PRCRepresentationItem +{ +public: + PRCWire(std::string n="") : + PRCRepresentationItem(PRC_TYPE_RI_Curve,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(PRC_TYPE_RI_PolyWire,n) {} + void serializePolyWire(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializePolyWire(pbs); } +}; + +class PRCSet : public PRCRepresentationItem +{ +public: + PRCSet(std::string n="") : + PRCRepresentationItem(PRC_TYPE_RI_Set,n) {} + ~PRCSet() { for(PRCRepresentationItemList::iterator it=elements.begin(); it!=elements.end(); ++it) delete *it; } + 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); + PRCRepresentationItemList elements; +}; + +class PRCTransformation3d +{ +public: + virtual ~PRCTransformation3d() {} + virtual void serializeTransformation3d(PRCbitStream&) const =0; +}; +typedef std::deque PRCTransformation3dList; + +class PRCGeneralTransformation3d : public PRCTransformation3d +{ +public: + PRCGeneralTransformation3d() + { + setidentity(); + } + PRCGeneralTransformation3d(const double t[]) + { + set(t); + } + + void serializeGeneralTransformation3d(PRCbitStream&) const; + void serializeTransformation3d(PRCbitStream& pbs) const { serializeGeneralTransformation3d(pbs); } + double m_coef[16]; + bool operator==(const PRCGeneralTransformation3d &t) const + { + for (size_t i=0;i<16;i++) + if(m_coef[i]!=t.m_coef[i]) + return false; + return true; + } + bool operator<(const PRCGeneralTransformation3d &t) const + { + for (size_t i=0;i<16;i++) + if(m_coef[i]!=t.m_coef[i]) + { + return (m_coef[i] 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) {} + PRCCartesianTransformation3d(const double o[3], const double x[3], const double y[3], double sc) : + behaviour(PRC_TRANSFORMATION_Identity), origin(o,0.0,0.0,0.0), X(x,1.0,0.0,0.0), Y(y,0.0,1.0,0.0), Z(0.0,0.0,1.0), + scale(1.0,1.0,1.0), uniform_scale(sc), + X_homogeneous_coord(0.0), Y_homogeneous_coord(0.0), Z_homogeneous_coord(0.0), origin_homogeneous_coord(1.0) + { + if(origin!=PRCVector3d(0.0,0.0,0.0)) + behaviour = behaviour | PRC_TRANSFORMATION_Translate; + if(X!=PRCVector3d(1.0,0.0,0.0) || Y!=PRCVector3d(0.0,1.0,0.0)) + behaviour = behaviour | PRC_TRANSFORMATION_Rotate; + if(uniform_scale!=1) + behaviour = behaviour | PRC_TRANSFORMATION_Scale; + } + 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.0,0.0), x_axis(1.0,0.0,0.0), y_axis(0.0,1.0,0.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(PRC_TYPE_RI_CoordinateSystem,n), axis_set(NULL) {} + ~PRCCoordinateSystem() { delete axis_set; } + void serializeCoordinateSystem(PRCbitStream&); + void serializeRepresentationItem(PRCbitStream &pbs) { serializeCoordinateSystem(pbs); } + void setAxisSet(PRCGeneralTransformation3d*& transform) { axis_set = transform; transform = NULL; } + void setAxisSet(PRCCartesianTransformation3d*& transform) { axis_set = transform; transform = NULL; } + PRCTransformation3d *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(axis_set); + PRCGeneralTransformation3d* t_axis_set_general = dynamic_cast(t.axis_set); + PRCCartesianTransformation3d* axis_set_cartesian = dynamic_cast(axis_set); + PRCCartesianTransformation3d* t_axis_set_cartesian = dynamic_cast(t.axis_set); + 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::deque 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 font_keys; + +}; + +// Topology +class PRCBaseGeometry : public PRCAttributes +{ +public: + PRCBaseGeometry() : + base_information(false), identifier(0) {} + PRCBaseGeometry(std::string n, uint32_t id = 0) : + base_information(true),name(n),identifier(id) {} + void serializeBaseGeometry(PRCbitStream&); + bool base_information; + std::string name; + uint32_t identifier; +}; + +class PRCBoundingBox +{ +public: + PRCBoundingBox() : min(0.0,0.0,0.0), max(0.0,0.0,0.0) {} + PRCBoundingBox(const PRCVector3d &m, const PRCVector3d& M) : min(m),max(M) {} + 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(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 ~PRCSurface() {} + virtual void serializeSurface(PRCbitStream &pbs) = 0; +}; + +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 control_point; + std::vector knot_u; + std::vector 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(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 ~PRCCurve() {} + virtual void serializeCurve(PRCbitStream &pbs) = 0; +}; +typedef std::deque 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 control_point; + std::vector 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 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 base_sense; + bool is_closed; +}; + +class PRCBlend01 : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCBlend01() : + PRCSurface(), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {} + PRCBlend01(std::string n) : + PRCSurface(n), center_curve(NULL), origin_curve(NULL), tangent_curve(NULL) {} + ~PRCBlend01() { delete center_curve; delete origin_curve; delete tangent_curve; } + void serializeBlend01(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeBlend01(pbs); } +// void setCenterCurve (PRCCurve*& curve) { center_curve = curve; curve = NULL; } +// void setOriginCurve (PRCCurve*& curve) { origin_curve = curve; curve = NULL; } +// void setTangentCurve(PRCCurve*& curve) { tangent_curve = curve; curve = NULL; } + PRCCurve* center_curve; + PRCCurve* origin_curve; + PRCCurve* tangent_curve; +}; + +class PRCRuled : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCRuled() : + PRCSurface(), first_curve(NULL), second_curve(NULL) {} + PRCRuled(std::string n) : + PRCSurface(n) {} + ~PRCRuled() { delete first_curve; delete second_curve; } + void serializeRuled(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeRuled(pbs); } +// void setFirstCurve(PRCCurve*& curve) { first_curve = curve; curve = NULL; } +// void setSecondCurve(PRCCurve*& curve) { second_curve = curve; curve = NULL; } + PRCCurve* first_curve; + PRCCurve* 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 PRCCone : public PRCSurface, public PRCTransformation, public PRCUVParameterization +{ +public: + PRCCone() : + PRCSurface() {} + PRCCone(std::string n) : + PRCSurface(n) {} + void serializeCone(PRCbitStream &pbs); + void serializeSurface(PRCbitStream &pbs) { serializeCone(pbs); } + double bottom_radius; + double semi_angle; +}; + +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 PRCAttributes +{ +public: + PRCBaseTopology() : + base_information(false),identifier(0) {} + PRCBaseTopology(std::string n, uint32_t id = 0) : + base_information(true),name(n),identifier(id) {} + void serializeBaseTopology(PRCbitStream&); + bool base_information; + std::string name; + uint32_t identifier; +}; + +class PRCTopoItem +{ +public: + virtual ~PRCTopoItem() {} + virtual void serializeTopoItem(PRCbitStream&)=0; +}; + +class PRCContentBody: public PRCBaseTopology +{ +public: + PRCContentBody() : + PRCBaseTopology(), behavior(0) {} + PRCContentBody(std::string n) : + PRCBaseTopology(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 ~PRCBody() {} + 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::deque PRCBodyList; + +class PRCContentWireEdge : public PRCBaseTopology +{ +public: + PRCContentWireEdge() : + PRCBaseTopology(), curve_3d(NULL), has_curve_trim_interval(false) {} + PRCContentWireEdge(std::string n) : + PRCBaseTopology(n,makeCADID()), curve_3d(NULL), has_curve_trim_interval(false) {} + ~PRCContentWireEdge() { delete curve_3d; } + void serializeContentWireEdge(PRCbitStream &pbs); +// void setCurve(PRCCurve*& curve) { curve_3d = curve; curve = NULL; } + PRCCurve* 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), wire_edge(NULL) {} + PRCSingleWireBody(std::string n) : + PRCBody(PRC_TYPE_TOPO_SingleWireBody, n), wire_edge(NULL) {} + ~PRCSingleWireBody() { delete wire_edge; } + void serializeSingleWireBody(PRCbitStream &pbs); + void serializeBody(PRCbitStream &pbs) { serializeSingleWireBody(pbs); } + void setWireEdge(PRCWireEdge*& wireEdge) { wire_edge = wireEdge; wireEdge = NULL; } + PRCWireEdge* wire_edge; +}; + +class PRCFace : public PRCBaseTopology, public PRCTopoItem, public PRCGraphics +{ +public: + PRCFace() : + PRCBaseTopology(), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {} + PRCFace(std::string n) : + PRCBaseTopology(n,makeCADID()), base_surface(NULL), have_surface_trim_domain(false), have_tolerance(false), tolerance(0), number_of_loop(0), outer_loop_index(-1) {} + ~PRCFace() { delete base_surface; } + void serializeFace(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeFace(pbs); } + void setBaseSurface(PRCSurface*& surface) { base_surface = surface; surface = NULL; } + PRCSurface *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::deque PRCFaceList; + +class PRCShell : public PRCBaseTopology, public PRCTopoItem +{ +public: + PRCShell() : + PRCBaseTopology(), shell_is_closed(false) {} + PRCShell(std::string n) : + PRCBaseTopology(n,makeCADID()), shell_is_closed(false) {} + ~PRCShell() { for(PRCFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; } + void serializeShell(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeShell(pbs); } + void addFace(PRCFace*& pFace, uint8_t orientation=2); + bool shell_is_closed; + PRCFaceList face; + std::vector orientation_surface_with_shell; +}; +typedef std::deque PRCShellList; + +class PRCConnex : public PRCBaseTopology, public PRCTopoItem +{ +public: + PRCConnex() : + PRCBaseTopology() {} + PRCConnex(std::string n) : + PRCBaseTopology(n,makeCADID()) {} + ~PRCConnex() { for(PRCShellList::iterator it=shell.begin(); it!=shell.end(); ++it) delete *it; } + void serializeConnex(PRCbitStream &pbs); + void serializeTopoItem(PRCbitStream &pbs) { serializeConnex(pbs); } + void addShell(PRCShell*& pShell); + PRCShellList shell; +}; +typedef std::deque PRCConnexList; + +class PRCBrepData : public PRCBody, public PRCBoundingBox +{ +public: + PRCBrepData() : + PRCBody(PRC_TYPE_TOPO_BrepData) {} + PRCBrepData(std::string n) : + PRCBody(PRC_TYPE_TOPO_BrepData, n) {} + ~PRCBrepData() { for(PRCConnexList::iterator it=connex.begin(); it!=connex.end(); ++it) delete *it; } + 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(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 control_point; +}; +typedef std::deque 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) {} + ~PRCCompressedBrepData() { for(PRCCompressedFaceList::iterator it=face.begin(); it!=face.end(); ++it) delete *it; } + 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(PRC_TYPE_TOPO_Context,n), behaviour(0), granularity(1), tolerance(0), + have_smallest_face_thickness(false), smallest_thickness(0), have_scale(false), scale(1) {} + ~PRCTopoContext() { for(PRCBodyList::iterator it=body.begin(); it!=body.end(); ++it) delete *it; } + 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::deque PRCTopoContextList; + +class PRCUniqueId +{ +public: + PRCUniqueId() : id0(0), id1(0), id2(0), id3(0) {} + void serializeCompressedUniqueId(PRCbitStream&) const; + void serializeFileStructureUncompressedUniqueId(std::ostream& out) const; + uint32_t id0; + uint32_t id1; + uint32_t id2; + uint32_t id3; +}; + +class PRCUnit +{ +public: + PRCUnit() : unit_from_CAD_file(false), unit(1) {} + PRCUnit(double u, bool ufcf=true) : unit_from_CAD_file(ufcf), unit(u) {} + void serializeUnit(PRCbitStream&); + bool unit_from_CAD_file; + double unit; +}; + +class PRCProductOccurrence: public PRCGraphics, public ContentPRCBase +{ +public: + PRCProductOccurrence(std::string n="") : + ContentPRCBase(PRC_TYPE_ASM_ProductOccurence,n), + 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), + location(NULL) {} + ~PRCProductOccurrence() { delete location; } + void setLocation(PRCGeneralTransformation3d*& transform) { location = transform; transform = NULL; } + 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 index_son_occurrence; + uint8_t product_behaviour; + PRCUnit unit_information; + uint8_t product_information_flags; + EPRCProductLoadStatus product_load_status; + PRCGeneralTransformation3d *location; +}; +typedef std::deque PRCProductOccurrenceList; + +class PRCPartDefinition: public PRCGraphics, public ContentPRCBase, public PRCBoundingBox +{ +public: + PRCPartDefinition(std::string n="") : + ContentPRCBase(PRC_TYPE_ASM_PartDefinition,n) {} + ~PRCPartDefinition() { for(PRCRepresentationItemList::iterator it=representation_item.begin(); it!=representation_item.end(); ++it) delete *it; } + 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); + PRCRepresentationItemList representation_item; +}; +typedef std::deque PRCPartDefinitionList; + +#endif //__WRITE_PRC_H diff --git a/src/prim.cpp b/src/prim.cpp new file mode 100644 index 0000000..20f97e5 --- /dev/null +++ b/src/prim.cpp @@ -0,0 +1,833 @@ +/*************************************************************************** + * prim.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/canvas.h" +#include "mgl2/prim.h" +#include "mgl2/data.h" +//----------------------------------------------------------------------------- +// +// Mark & Curve series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark(HMGL gr, double x, double y, double z,const char *mark) +{ + char mk = gr->SetPenPal(mark); + if(!mk) mk = '.'; + if(mgl_isnan(z)) z=2*gr->Max.z-gr->Min.z; + static int cgid=1; gr->StartGroup("MarkS",cgid++); + long k = gr->AddPnt(mglPoint(x,y,z),gr->CDef,mglPoint(NAN),-1,3); + gr->mark_plot(k,mk,gr->GetPenWidth()); gr->AddActive(k); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mark_(uintptr_t *gr, mreal *x, mreal *y, mreal *z, const char *pen,int l) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + mgl_mark(_GR_, *x,*y,*z,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ball(HMGL gr, double x, double y, double z) +{ + static int cgid=1; gr->StartGroup("Ball",cgid++); + if(mgl_isnan(z)) z=2*gr->Max.z-gr->Min.z; + long k = gr->AddPnt(mglPoint(x,y,z),gr->AddTexture('r'),mglPoint(NAN),-1,3); + gr->mark_plot(k,'.'); gr->AddActive(k); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ball_(uintptr_t *gr, mreal *x, mreal *y, mreal *z) +{ mgl_ball(_GR_, *x,*y,*z); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_line(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, const char *pen,int n) +{ + static int cgid=1; gr->StartGroup("Line",cgid++); + if(mgl_isnan(z1) || mgl_isnan(z2)) z1=z2=2*gr->Max.z-gr->Min.z; + mglPoint p1(x1,y1,z1), p2(x2,y2,z2), p=p1,nn=mglPoint(NAN); + gr->SetPenPal(pen); + n = (n<2) ? 2 : n; + + register long i,k1,k2; + register mreal s; + gr->Reserve(n); + k1 = gr->AddPnt(p,gr->CDef,nn,-1,3); gr->AddActive(k1); + for(i=1;iStop) return; + s = i/mreal(n-1); p = p1*(1-s)+p2*s; k2 = k1; + k1 = gr->AddPnt(p,gr->CDef,nn,-1,3); + gr->line_plot(k2,k1); + if(i==1) gr->arrow_plot(k2,k1,gr->Arrow1); + if(i==n-1) gr->arrow_plot(k1,k2,gr->Arrow2); + } + gr->AddActive(k1,1); gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_line_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, const char *pen,int *n,int l) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + mgl_line(_GR_, *x1,*y1,*z1, *x2,*y2,*z2,s,*n); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_curve(HMGL gr, double x1, double y1, double z1, double dx1, double dy1, double dz1, double x2, double y2, double z2, double dx2, double dy2, double dz2, const char *pen,int n) +{ + static int cgid=1; gr->StartGroup("Curve",cgid++); + if(mgl_isnan(z1) || mgl_isnan(z2)) z1=z2=2*gr->Max.z-gr->Min.z; + mglPoint p1(x1,y1,z1), p2(x2,y2,z2), d1(dx1,dy1,dz1), d2(dx2,dy2,dz2), a,b,p=p1,nn=mglPoint(NAN); + a = 3*(p2-p1)-d2-2*d1; b = d1+d2-2*(p2-p1); + n = (n<2) ? 2 : n; + gr->SetPenPal(pen); + + register long i,k1,k2; + register mreal s; + gr->Reserve(n); + k1=gr->AddPnt(p,gr->CDef,nn,-1,3); gr->AddActive(k1); + for(i=1;iStop) return; + s = i/(n-1.); p = p1+s*(d1+s*(a+s*b)); k2 = k1; + k1 = gr->AddPnt(p,gr->CDef,nn,-1,3); + gr->line_plot(k2,k1); + if(i==1) gr->arrow_plot(k2,k1,gr->Arrow1); + if(i==n-1) gr->arrow_plot(k1,k2,gr->Arrow2); + } + gr->AddActive(gr->AddPnt(p1+d1,gr->CDef,nn,-1,3),1); + gr->AddActive(gr->AddPnt(p2-d2,gr->CDef,nn,-1,3),3); + gr->AddActive(k1,2); gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_curve_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *dx1, mreal *dy1, mreal *dz1, mreal *x2, mreal *y2, mreal *z2, mreal *dx2, mreal *dy2, mreal *dz2, const char *pen,int *n, int l) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + mgl_curve(_GR_, *x1,*y1,*z1, *dx1,*dy1,*dz1, *x2,*y2,*z2, *dx2,*dy2,*dz2, s, *n); delete []s;} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_box(HMGL gr, double x, double y, double z, double ex, double ey, double ez, const char *pen) +{ + static int cgid=1; gr->StartGroup("ErBox",cgid++); + char mk=gr->SetPenPal(pen); + mglPoint p(x,y,z), q,nn=mglPoint(NAN); + gr->Reserve(7); + long k1,k2; + q = p; q.x += ex; k1 = gr->AddPnt(q,gr->CDef,nn,0,3); + q = p; q.x -= ex; k2 = gr->AddPnt(q,gr->CDef,nn,0,3); + gr->line_plot(k1,k2); gr->arrow_plot(k1,k2,'I'); gr->arrow_plot(k2,k1,'I'); + q = p; q.y += ey; k1 = gr->AddPnt(q,gr->CDef,nn,0,3); + q = p; q.y -= ey; k2 = gr->AddPnt(q,gr->CDef,nn,0,3); + gr->line_plot(k1,k2); gr->arrow_plot(k1,k2,'I'); gr->arrow_plot(k2,k1,'I'); + q = p; q.z += ez; k1 = gr->AddPnt(q,gr->CDef,nn,0,3); + q = p; q.z -= ez; k2 = gr->AddPnt(q,gr->CDef,nn,0,3); + gr->line_plot(k1,k2); gr->arrow_plot(k1,k2,'I'); gr->arrow_plot(k2,k1,'I'); + if(mk) gr->mark_plot(gr->AddPnt(p,gr->CDef,nn,0,3),mk); + gr->AddActive(gr->AddPnt(p,gr->CDef,nn,-1,3),0); + gr->AddActive(gr->AddPnt(p+mglPoint(ex,ey),gr->CDef,nn,-1,3),1); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_error_box_(uintptr_t *gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, const char *pen,int l) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + mgl_error_box(_GR_, *x1,*y1,*z1, *x2,*y2,*z2,s); delete []s; } +//----------------------------------------------------------------------------- +// +// Face series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_face(HMGL gr, double x0, double y0, double z0, double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, const char *stl) +{ + static int cgid=1; gr->StartGroup("Face",cgid++); + long pal; + gr->SetPenPal(stl,&pal); +// mreal c1,c2,c3,c4,zz=(gr->Min.z+gr->Max.z)/2; + mreal c1,c2,c3,c4,zz=2*gr->Max.z-gr->Min.z; + c1=c2=c3=c4=gr->CDef; + if(mgl_isnan(z0)) z0 = zz; if(mgl_isnan(z1)) z1 = zz; + if(mgl_isnan(z2)) z2 = zz; if(mgl_isnan(z3)) z3 = zz; + mglPoint p1(x0,y0,z0), p2(x1,y1,z1), p3(x2,y2,z2), p4(x3,y3,z3); + if(gr->GetNumPal(pal)>=4) + { c2=gr->NextColor(pal,1); c3=gr->NextColor(pal,2); c4=gr->NextColor(pal,3); } + mglPoint q1,q2,q3,q4; + q1 = (p2-p1)^(p3-p1); q4 = (p2-p4)^(p3-p4); + q2 = (p1-p2)^(p4-p2); q3 = (p1-p3)^(p4-p3); + gr->Reserve(4); + long k1,k2,k3,k4; + double a = gr->get(MGL_ENABLE_ALPHA)?-1:1; + k1 = gr->AddPnt(p1,c1,q1,a,11); gr->AddActive(k1,0); + k2 = gr->AddPnt(p2,c2,q2,a,11); gr->AddActive(k2,1); + k3 = gr->AddPnt(p3,c3,q3,a,11); gr->AddActive(k3,2); + k4 = gr->AddPnt(p4,c4,q4,a,11); gr->AddActive(k4,3); + gr->quad_plot(k1,k2,k3,k4); + if(mglchr(stl,'#')) + { + gr->Reserve(4); + pal = gr->AddTexture('k'); + k1=gr->CopyNtoC(k1,pal); k2=gr->CopyNtoC(k2,pal); + k3=gr->CopyNtoC(k3,pal); k4=gr->CopyNtoC(k4,pal); + gr->line_plot(k1,k2); gr->line_plot(k1,k3); + gr->line_plot(k3,k4); gr->line_plot(k2,k4); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facex(HMGL gr, double x0, double y0, double z0, double wy, double wz, const char *stl, double d1, double d2) +{ mgl_face(gr, x0,y0,z0, x0,y0+wy,z0, x0,y0,z0+wz, x0,y0+wy+d1,z0+wz+d2, stl); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facey(HMGL gr, double x0, double y0, double z0, double wx, double wz, const char *stl, double d1, double d2) +{ mgl_face(gr, x0,y0,z0, x0+wx,y0,z0, x0,y0,z0+wz, x0+wx+d1,y0,z0+wz+d2, stl); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facez(HMGL gr, double x0, double y0, double z0, double wx, double wy, const char *stl, double d1, double d2) +{ mgl_face(gr, x0,y0,z0, x0,y0+wy,z0, x0+wx,y0,z0, x0+wx+d1,y0+wy+d2,z0, stl); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facex_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wy, mreal *wz, const char *stl, mreal *dx, mreal *dy, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_facex(_GR_, *x0,*y0,*z0,*wy,*wz,s,*dx,*dy); delete []s; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facey_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wx, mreal *wz, const char *stl, mreal *dx, mreal *dy, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_facey(_GR_, *x0,*y0,*z0,*wx,*wz,s,*dx,*dy); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_facez_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *wx, mreal *wy, const char *stl, mreal *dx, mreal *dy, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_facez(_GR_, *x0,*y0,*z0,*wx,*wy,s,*dx,*dy); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_face_(uintptr_t* gr, mreal *x0, mreal *y0, mreal *z0, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *x3, mreal *y3, mreal *z3, const char *stl, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_face(_GR_, *x0,*y0,*z0, *x1,*y1,*z1, *x2,*y2,*z2, *x3,*y3,*z3, stl); delete []s; } +//----------------------------------------------------------------------------- +// +// Cone +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cone(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r1, double r2, const char *stl) +{ + if(r2<0) r2=r1; + if(r1==0 && r2==0) return; + + static int cgid=1; gr->StartGroup("Cone",cgid++); + mglPoint p1(x1,y1,z1), p2(x2,y2,z2), p,q(NAN,NAN),t(NAN,NAN), d=p2-p1,a,b; + a=!d; a.Normalize(); b=d^a; b.Normalize(); + long ss=gr->AddTexture(stl); + mreal c1=gr->GetC(ss,p1.z), c2=gr->GetC(ss,p2.z), dr=r2-r1; + long *kk=new long[164],k1=-1,k2=-1; + bool edge = mglchr(stl,'@'); + bool wire = mglchr(stl,'#'); + gr->Reserve(edge?166:82); + if(edge && !wire) + { + k1=gr->AddPnt(p1,c1,d,-1,3); + k2=gr->AddPnt(p2,c2,d,-1,3); + } + long n=wire?6:18; //wire?6:18; + if(mglchr(stl,'4')) n=2; + else if(mglchr(stl,'6')) n=3; + else if(mglchr(stl,'8')) n=4; + bool refr = n>6; + if(refr) t=d; + +#pragma omp parallel for firstprivate(p,q) + for(long i=0;i<2*n+1;i++) + { + if(gr->Stop) continue; + register int f = n!=4?(2*i+1)*90/n:45*i; + register mreal co = mgl_cos[f%360], si = mgl_cos[(f+270)%360]; + p = p1+(r1*co)*a+(r1*si)*b; + if(refr) q = (si*a-co*b)^(d + (dr*co)*a + (dr*si)*b); + kk[i] = gr->AddPnt(p,c1,q,-1,3); + if(edge && !wire) kk[i+82] = gr->AddPnt(p,c1,t,-1,3); + p = p2+(r2*co)*a+(r2*si)*b; + kk[i+2*n+1] = gr->AddPnt(p,c2,q,-1,3); + if(edge && !wire) kk[i+123] = gr->AddPnt(p,c2,t,-1,3); + } + if(wire) +//#pragma omp parallel for // useless + for(long i=0;i<2*n;i++) + { + gr->line_plot(kk[i],kk[i+1]); + gr->line_plot(kk[i],kk[i+2*n+1]); + gr->line_plot(kk[i+2*n+2],kk[i+1]); + gr->line_plot(kk[i+2*n+2],kk[i+2*n+1]); + } + else +#pragma omp parallel for + for(long i=0;i<2*n;i++) + { + gr->quad_plot(kk[i],kk[i+1],kk[i+2*n+1],kk[i+2*n+2]); + if(edge) + { + gr->trig_plot(k1,kk[i+82],kk[i+83]); + gr->trig_plot(k2,kk[i+123],kk[i+124]); + } + } + gr->EndGroup(); delete []kk; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cone_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r1, mreal *r2, const char *stl, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_cone(_GR_, *x1,*y1,*z1, *x2,*y2,*z2,*r1,*r2,s); delete []s; } +//----------------------------------------------------------------------------- +// +// Bars series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *pen, const char *opt) +{ + long i=5,j,m,mx,my,mz,n=z->GetNx(),nx=x->GetNx(), nz=z->GetNy(), pal; + if(mgl_check_dim1(gr,x,z,y,0,"Cones",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Cones",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = nz > m ? nz : m; + + bool above= mglchr(pen,'a'); + bool wire = mglchr(pen,'#'); + bool tube = mglchr(pen,'t'); + mreal *dd=new mreal[2*n], x1,z0,zz,d, vx,vy,vz,v0,v1,dv=nx>n?1:0; + if(mglchr(pen,'<')) dv = 1; + if(mglchr(pen,'^')) dv = 0; + if(mglchr(pen,'>')) dv = -1; + + gr->SetPenPal(pen,&pal); + char c1[8]; memset(c1,0,8); c1[0] ='@'; + char c2[8]; memset(c2,0,8); c2[0] ='@'; + if(wire) { c1[5]=c2[5]='#'; i++; } + if(mglchr(pen,'&')) c1[i]=c2[i]='4'; + else if(mglchr(pen,'4')) c1[i]=c2[i]='4'; + else if(mglchr(pen,'6')) c1[i]=c2[i]='6'; + else if(mglchr(pen,'8')) c1[i]=c2[i]='8'; + memset(dd,0,2*n*sizeof(mreal)); + z0 = gr->GetOrgZ('x'); + for(i=0;iv(i, jNextColor(pal); memcpy(c1+1,gr->last_line(),4); + if(gr->GetNumPal(pal)==2*m) + { gr->NextColor(pal); memcpy(c2+1,gr->last_line(),4); } + else memcpy(c2,c1,8); + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jStop) { delete []dd; return; } + vx=x->v(i,mx); vy=y->v(i,my); vz=z->v(i,mz); + v0=y->v(i,0); v1=iv(i+1,mx):x->v(i-1,mx); + d = iBarWidth); // TODO + d *= 0.7*gr->BarWidth; + if(above) + { + zz = j>0?dd[i+n]:z0; dd[i+n] += vz; + mgl_cone(gr, x1,v0,zz, x1,v0,dd[i+n], + tube?d:d*(dd[i]-zz)/(dd[i]-z0), + tube?d:d*(dd[i]-dd[i+n])/(dd[i]-z0), c1); + } + else mgl_cone(gr, x1,vy,z0, x1,vy,vz, d,tube?d:0, vz<0?c1:c2); + } + } + gr->EndGroup(); delete []dd; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones_xz(HMGL gr, HCDT x, HCDT z, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData y(z); + y.Fill(gr->Min.y,gr->Max.y,'y'); + mgl_cones_xyz(gr,x,&y,z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones(HMGL gr, HCDT z, const char *pen, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()+1); + x.Fill(gr->Min.x,gr->Max.x); + mgl_cones_xz(gr,&x,z,pen,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cones_xyz(_GR_,_DA_(x),_DA_(y),_DA_(z),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones_xz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cones_xz(_GR_,_DA_(x),_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cones_(uintptr_t *gr, uintptr_t *y, const char *pen, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,pen,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cones(_GR_,_DA_(y),s,o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Ellipse & Rhomb +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ellipse(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r, const char *stl) +{ + const int n = 41; + long pal=0,n0,n1=-1,n2,m1=-1,m2; + static int cgid=1; gr->StartGroup("Ellipse",cgid++); + gr->SetPenPal(stl,&pal); + mreal c=gr->NextColor(pal), d; + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); + bool fill = !mglchr(stl,'#'), box = mglchr(stl,'@') || !fill; + if(!fill) k=c; + + gr->Reserve(2*n+1); + if(mgl_isnan(z1) || mgl_isnan(z2)) z1=z2=2*gr->Max.z-gr->Min.z; + mglPoint p1(x1,y1,z1), p2(x2,y2,z2), v=p2-p1; + d = v.norm(); + if(d==0) v = mglPoint(1); else v /= d; + mglPoint u=mglPoint(0,0,1)^v, q=u^v, p, s=(p1+p2)/2.; + u *= r; v *= sqrt(d*d/4+r*r); + // central point first + n0 = gr->AddPnt(p1,c,q,-1,11); gr->AddActive(n0); + gr->AddActive(gr->AddPnt(p2,c,q,-1,11),1); + for(long i=0;iStop) return; + register int t=i*360/(n-1); + p = s+v*mgl_cos[t%360]+u*mgl_cos[(270+t)%360]; + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,11); + if(i==n/4) gr->AddActive(n1,2); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(i>0) + { + if(fill) gr->trig_plot(n0,n1,n2); + if(box) gr->line_plot(m1,m2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_rhomb(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r, const char *stl) +{ + long pal=0, n1,n2,n3,n4; + static int cgid=1; gr->StartGroup("Rhomb",cgid++); + gr->SetPenPal(stl,&pal); + mreal c=gr->NextColor(pal); + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); + mreal b=(gr->GetNumPal(pal)>2)?gr->NextColor(pal):c; + bool fill = !mglchr(stl,'#'), box = mglchr(stl,'@') || !fill; + if(!fill) k=c; + gr->Reserve(8); + if(mgl_isnan(z1) || mgl_isnan(z2)) z1=z2=2*gr->Max.z-gr->Min.z; + mglPoint p1(x1,y1,z1), p2(x2,y2,z2), u=mglPoint(0,0,1)^(p1-p2), q=u^(p1-p2), p, s,qq; + u = (r/u.norm())*u; s = (p1+p2)/2.; + p = p1; q = qq; n1 = gr->AddPnt(p,c,qq,-1,11); + p = s+u;q = qq; n2 = gr->AddPnt(p,b==c?c:k,qq,-1,11); + p = p2; q = qq; n3 = gr->AddPnt(p,b,qq,-1,11); + p = s-u;q = qq; n4 = gr->AddPnt(p,b==c?c:k,qq,-1,11); + gr->AddActive(n1,0); gr->AddActive(n2,2); gr->AddActive(n3,1); + if(fill) gr->quad_plot(n1,n2,n4,n3); + n1 = gr->CopyNtoC(n1,k); n2 = gr->CopyNtoC(n2,k); + n3 = gr->CopyNtoC(n3,k); n4 = gr->CopyNtoC(n4,k); + if(box) + { gr->line_plot(n1,n2); gr->line_plot(n2,n3); + gr->line_plot(n3,n4); gr->line_plot(n4,n1); } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ellipse_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl,int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_ellipse(_GR_,*x1,*y1,*z1,*x2,*y2,*z2,*r,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_rhomb_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl,int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_rhomb(_GR_,*x1,*y1,*z1,*x2,*y2,*z2,*r,s); delete []s; } +//----------------------------------------------------------------------------- +// +// Sphere & Drop +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_sphere(HMGL gr, double x, double y, double z, double r, const char *stl) +{ mgl_drop(gr,x,y,z,1,0,0,2*r,stl,0,1); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_sphere_(uintptr_t* gr, mreal *x, mreal *y, mreal *z, mreal *r, const char *stl,int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_sphere(_GR_, *x,*y,*z,*r,s); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_drop(HMGL gr, mglPoint p, mglPoint q, double r, double c, double sh, double a) +{ + mglPoint p1,p2,pp,qq; + if(q.norm()==0) { q = mglPoint(1,0,0); sh=0; } + q.Normalize(); p1 = !q; p2 = q^p1; r /= 2; + + static int cgid=1; gr->StartGroup("Drop",cgid++); + const int m=12, n=2*m+1; + gr->Reserve(n*m); + long *nn=new long[2*n],n1,n2; + mreal x,y,z,rr,dr; + + z = r*(1+sh)*(1+sh); n1 = gr->AddPnt(p + q*z,c,q,-1,3); + z = r*(1+sh)*(sh-1); n2 = gr->AddPnt(p + q*z,c,q,-1,3); + + for(long i=0;i<=m;i++) for(long j=0;j not for omp + { + if(gr->Stop) continue; + if(i>0 && iAddPnt(pp,c,qq,-1,3); + } + else if(i==0) nn[j] = n1; + else if(i==m) { nn[j+n]=nn[j]; nn[j]=n2; } + if(i*j>0) gr->quad_plot(nn[j-1], nn[j], nn[j+n-1], nn[j+n]); + } + delete []nn; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_drop(HMGL gr, double x1, double y1, double z1, double x2, double y2, double z2, double r, const char *stl, double sh, double a) +{ + mreal c=gr->AddTexture((stl && stl[0]) ? stl[0]:'r'); + mgl_drop(gr,mglPoint(x1,y1,z1), mglPoint(x2,y2,z2), r, c, sh, a); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_drop_(uintptr_t* gr, mreal *x1, mreal *y1, mreal *z1, mreal *x2, mreal *y2, mreal *z2, mreal *r, const char *stl, mreal *shift, mreal *ap, int l) +{ char *s=new char[l+1]; memcpy(s,stl,l); s[l]=0; + mgl_drop(_GR_, *x1,*y1,*z1, *x2,*y2,*z2, *r,s,*shift,*ap); delete []s; } +//----------------------------------------------------------------------------- +// +// Dew series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dew_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + long n=ax->GetNx(),m=ax->GetNy(); + if(mgl_check_dim2(gr,x,y,ax,ay,"Dew")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("DewXY",cgid++); + + long ss = gr->AddTexture(sch); + bool inv = mglchr(sch,'i'); + mreal zVal = gr->Min.z, xm=0; + long tx=1,ty=1; + if(gr->MeshNum>1) { tx=(n-1)/(gr->MeshNum-1); ty=(m-1)/(gr->MeshNum-1); } + if(tx<1) tx=1; if(ty<1) ty=1; + +#pragma omp parallel + { + register mreal xm1=0,ym; +#pragma omp for nowait collapse(3) + for(long k=0;kGetNz();k++) for(long j=0;jv(i,j,k)*ax->v(i,j,k)+ay->v(i,j,k)*ay->v(i,j,k)); + xm1 = xm1>ym ? xm1 : ym; + } +#pragma omp critical(max_vec) + {xm = xm>xm1 ? xm:xm1;} + } + xm = 1./MGL_FEPSILON/(xm==0 ? 1:xm); + + for(long k=0;kGetNz();k++) + { + if(ax->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); +//#pragma omp parallel for collapse(2) // gain looks negligible?!? + for(long i=0;iStop) continue; + register mreal xx=GetX(x,i,j,k).x, yy=GetY(y,i,j,k).x, dd; + register mreal dx = iv(i,j,k),ay->v(i,j,k)); dd = q.norm(); + if(inv) q = -q; + mgl_drop(gr,mglPoint(xx, yy, zVal),q,(dxGetC(ss,dd*xm,false),dd*xm,1); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dew_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_dew_xy(gr,&x,&y,ax,ay,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dew_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dew_xy(_GR_, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dew_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dew_2d(_GR_, _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Puts series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_puts(HMGL gr, double x, double y, double z,const char *text, const char *font, double size) +{ mgl_puts_dir(gr, x, y, z, NAN, NAN, 0, text, font, size); } +void MGL_EXPORT mgl_putsw(HMGL gr, double x, double y, double z,const wchar_t *text, const char *font, double size) +{ mgl_putsw_dir(gr, x, y, z, NAN, NAN, 0, text, font, size); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_puts_dir(HMGL gr, double x, double y, double z, double dx, double dy, double dz, const char *text, const char *font, double size) +{ + MGL_TO_WCS(text,mgl_putsw_dir(gr, x, y, z, dx, dy, dz, wcs, font, size)); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_putsw_dir(HMGL gr, double x, double y, double z, double dx, double dy, double dz, const wchar_t *text, const char *font, double size) +{ + bool a=mglchr(font,'a'), A=mglchr(font,'A'); + static int cgid=1; gr->StartGroup("Puts",cgid++); + mglCanvas *g = dynamic_cast(gr); + if(g && (a||A)) + { + g->Push(); g->Identity(a); + gr->set(MGL_DISABLE_SCALE); + register mreal s=a?1:g->GetPlotFactor(); + x = (2*x-1)*s; y = (2*y-1)*s; + dx= (2*dx-1)*s; dy= (2*dy-1)*s; + } + if(mgl_isnan(z)) z=2*gr->Max.z-gr->Min.z; + mglPoint p(x,y,z), d(dx-x,dy-y,dz-z); + long k = gr->AddPnt(p,-1,d,-1,7); + gr->AddActive(k,0); + gr->AddActive(gr->AddPnt(mglPoint(dx,dy,dz),-1,d,-1,7),1); + if(g && (a||A)) { g->Pop(); gr->clr(MGL_DISABLE_SCALE); } + gr->text_plot(k,text,font,size); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_puts_(uintptr_t *gr, mreal *x, mreal *y, mreal *z,const char *text, const char *font, mreal *size, int l, int n) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,font,n); f[n]=0; + mgl_putsw_dir(_GR_, *x, *y, *z, NAN, NAN, 0, s, f, *size); + delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_puts_dir_(uintptr_t *gr, mreal *x, mreal *y, mreal *z, mreal *dx, mreal *dy, mreal *dz, const char *text, const char *font, mreal *size, int l, int n) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,font,n); f[n]=0; + mgl_putsw_dir(_GR_, *x, *y, *z, *dx, *dy, *dz, s, f, *size); + delete []s; delete []f; } +//----------------------------------------------------------------------------- +// +// TextMark series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmarkw_xyzr(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const wchar_t *text, const char *fnt, const char *opt) +{ + long m,mx,my,mz,mr,n=y->GetNx(); + if(mgl_check_dim0(gr,x,y,z,r,"TextMark")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("TextMark",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); + m = z->GetNy() > m ? z->GetNy() : m; + m = r->GetNy() > m ? r->GetNy() : m; + gr->Reserve(n*m); + + mglPoint p,q(NAN); + for(long j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; + mz = jGetNy() ? j:0; mr = jGetNy() ? j:0; +#pragma omp parallel for private(p) // NOTE this should be useless ?!? + for(long i=0;iStop) continue; + p = mglPoint(x->v(i,mx), y->v(i,my), z->v(i,mz)); + register long k = gr->AddPnt(p,-1,q); + gr->text_plot(k, text, fnt, -0.5*fabs(r->v(i,mr))); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmarkw_xyr(HMGL gr, HCDT x, HCDT y, HCDT r, const wchar_t *text, const char *fnt, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); z.Fill(gr->Min.z,gr->Min.z); + mgl_textmarkw_xyzr(gr,x,y,&z,r,text,fnt,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmarkw_yr(HMGL gr, HCDT y, HCDT r, const wchar_t *text, const char *fnt, const char *opt) +{ + register long n=y->GetNx(); + gr->SaveState(opt); + mglData x(n); x.Fill(gr->Min.x,gr->Max.x); + mglData z(n); z.Fill(gr->Min.z,gr->Min.z); + mgl_textmarkw_xyzr(gr,&x,y,&z,r,text,fnt,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmarkw(HMGL gr, HCDT y, const wchar_t *text, const char *fnt, const char *opt) +{ + register long n=y->GetNx(); + gr->SaveState(opt); + mglData r(n); r.Fill(1,1); + mglData x(n); x.Fill(gr->Min.x,gr->Max.x); + mglData z(n); z.Fill(gr->Min.z,gr->Min.z); + mgl_textmarkw_xyzr(gr,&x,y,&z,&r,text,fnt,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_xyzr(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT r, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_textmarkw_xyzr(gr, x, y, z, r, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_xyr(HMGL gr, HCDT x, HCDT y, HCDT r, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_textmarkw_xyr(gr, x, y, r, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_yr(HMGL gr, HCDT y, HCDT r, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_textmarkw_yr(gr, y, r, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark(HMGL gr, HCDT y, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_textmarkw(gr, y, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_xyzr_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *r, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; memcpy(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_textmarkw_xyzr(_GR_, _DA_(x),_DA_(y),_DA_(z),_DA_(r),s,f, o); + delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_xyr_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *r, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_textmarkw_xyr(_GR_, _DA_(x),_DA_(y),_DA_(r),s,f, o); + delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_yr_(uintptr_t *gr, uintptr_t *y, uintptr_t *r, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_textmarkw_yr(_GR_, _DA_(y),_DA_(r),s,f, o); delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_textmark_(uintptr_t *gr, uintptr_t *y, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_textmarkw(_GR_, _DA_(y),s,f, o); delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +// +// Label series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_labelw_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const wchar_t *text, const char *fnt, const char *opt) +{ + long m,mx,my,mz,n=y->GetNx(); + if(mgl_check_dim1(gr,x,y,z,0,"Label")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Label",cgid++); + m = x->GetNy() > y->GetNy() ? x->GetNy() : y->GetNy(); m = z->GetNy() > m ? z->GetNy() : m; + + mglPoint q(NAN); + wchar_t tmp[32]; + for(long j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; +#pragma omp parallel for private(tmp) + for(long i=0;iStop) continue; + mreal xx=x->v(i,mx), yy=y->v(i,my), zz=z->v(i,mz); + register long kk = gr->AddPnt(mglPoint(xx,yy,zz),-1,q),k,l; + std::wstring buf; + for(k=l=0;text[k];k++) + { + if(text[k]!='%' || (k>0 && text[k-1]=='\\')) + { buf += text[k]; continue; } + else if(text[k+1]=='%') { buf+='%'; k++; continue; } + else if(text[k+1]=='n') mglprintf(tmp,32,L"%ld",i); + else if(text[k+1]=='x') mglprintf(tmp,32,L"%.2g",xx); + else if(text[k+1]=='y') mglprintf(tmp,32,L"%.2g",yy); + else if(text[k+1]=='z') mglprintf(tmp,32,L"%.2g",zz); + else { buf+='%'; continue; } + buf += tmp; k++; + } + gr->text_plot(kk, buf.c_str(), fnt, -0.7, 0.05); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_labelw_xy(HMGL gr, HCDT x, HCDT y, const wchar_t *text, const char *fnt, const char *opt) +{ + gr->SaveState(opt); + mglData z(y->GetNx()); z.Fill(gr->Min.z,gr->Min.z); + mgl_labelw_xyz(gr,x,y,&z,text,fnt,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_labelw_y(HMGL gr, HCDT y, const wchar_t *text, const char *fnt, const char *opt) +{ + register long n=y->GetNx(); + if(n<2) { gr->SetWarn(mglWarnLow,"TextMark"); return; } + gr->SaveState(opt); + mglData x(n); x.Fill(gr->Min.x,gr->Max.x); + mglData z(n); z.Fill(gr->Min.z,gr->Min.z); + mgl_labelw_xyz(gr,&x,y,&z,text,fnt,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_labelw_xyz(gr, x, y, z, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_xy(HMGL gr, HCDT x, HCDT y, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_labelw_xy(gr, x, y, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_y(HMGL gr, HCDT y, const char *str, const char *fnt, const char *opt) +{ MGL_TO_WCS(str,mgl_labelw_y(gr, y, wcs, fnt, opt)); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_labelw_xyz(_GR_, _DA_(x),_DA_(y),_DA_(z),s,f, o); + delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_labelw_xy(_GR_, _DA_(x),_DA_(y),s,f, o); + delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_label_y_(uintptr_t *gr, uintptr_t *y, const char *text, const char *fnt, const char *opt, int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_labelw_y(_GR_, _DA_(y),s,f, o); delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- +// +// Table series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tablew(HMGL gr, double x, double y, HCDT val, const wchar_t *text, const char *fnt, const char *opt) +{ + mglCanvas *g = dynamic_cast(gr); + if(g) g->Table(x,y,val,text,fnt,opt); +} +void MGL_EXPORT mgl_table(HMGL gr, double x, double y, HCDT val, const char *text, const char *fnt, const char *opt) +{ + if(!text) mgl_tablew(gr,x,y,val,L"",fnt,opt); + else MGL_TO_WCS(text,mgl_tablew(gr, x, y, val, wcs, fnt, opt)); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_table_(uintptr_t *gr, mreal *x, mreal *y, uintptr_t *val, const char *text, const char *fnt, const char *opt,int l,int n,int lo) +{ wchar_t *s=new wchar_t[l+1]; mbstowcs(s,text,l); s[l]=0; + char *f=new char[n+1]; memcpy(f,fnt,n); f[n]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tablew(_GR_, *x, *y, _DA_(val),s,f, o); + delete []o; delete []s; delete []f; } +//----------------------------------------------------------------------------- diff --git a/src/s_hull/COPYING.txt b/src/s_hull/COPYING.txt new file mode 100644 index 0000000..e11e9cf --- /dev/null +++ b/src/s_hull/COPYING.txt @@ -0,0 +1,49 @@ +S-hull, Copyright (c) 2010 +Dr David SInclair +Cambridge, UK + +email david@s-hull.org + +The software includes the S-hull programs. +S-hull is copyrighted as above. +S-hull is free software and may be obtained from www.s-hull.org. +It may be freely copied, modified, +and redistributed under the following conditions: +S-hull is free software and may be obtained from www.s-hull.org. +It may be freely copied, modified, +and redistributed under the following conditions which might loosely be termed a contribtors beerware license: +1. All copyright notices must remain intact in all files. +2. A copy of this text file must be distributed along with any copies + of S-hull that you redistribute; this includes copies that you have + modified, or copies of programs or other software products that + include S-hull where distributed as source. + +3. If you modify S-hull, you must include a notice giving the + name of the person performing the modification, the date of + modification, and the reason for such modification. + +4. If you are distributing a binary or compiled version of s-hull it + is not necessary to include any acknowledgement or reference + to s-hull. +5. There is no warranty or other guarantee of fitness for S-hull, it is + provided solely "as is". Bug reports or fixes may be sent to + bugs@s-hull.org; the authors may or may not act on them as + they desire. +6. By copying or compliing the code for S-hull you explicitly indemnify +the copyright holder against any liability he may incur as a result of you +copying the code. + +7. If you meet any of the contributors to the code you used from s-hull.org + in a pub or a bar, and you think the source code they contributed to is worth it, + you can buy them a beer. + + If your principles run against beer a bacon-double-cheeseburger would do just as nicely + or you could email david@s-hull.org and arrange to make a donation of 10 of your local currancy units + to support s-hull.org. + +------------------- + +This is permission to use s-hull-pro mathgl as long as the routines retain +my copyright notice. I an happy for it to be included in an LGPL product and +I am happy for the source to be bundled with mathgl under whatever license you +use for that. diff --git a/src/s_hull/s_hull_pro.cpp b/src/s_hull/s_hull_pro.cpp new file mode 100644 index 0000000..4a11f51 --- /dev/null +++ b/src/s_hull/s_hull_pro.cpp @@ -0,0 +1,1678 @@ +#include +//#include +//#include +#include +#include +#include +#include +#include +#include +#include + + +#include "s_hull_pro.h" + +using namespace std; + + +/* copyright 2012 Dr David Sinclair + david@s-hull.org + + program to compute Delaunay triangulation of a set of points. + + this code may not be published or distributed without the concent of the copyright holder. + + */ + + +// Global replace int->long by A.Balakin 7 August 2012 -- 64bit version can handle huge data arrays + + +void circle_cent2(float r1,float c1, float r2,float c2, float r3,float c3, + float &r,float &c, float &ro2) +{ + /* + * function to return the center of a circle and its radius + * degenerate case should never be passed to this routine!!!!!!!!!!!!! + * but will return r0 = -1 if it is. + */ + + float v1 = 2*(r2-r1), v2 = 2*(c2-c1), v3 = r2*r2 - r1*r1 + c2*c2 - c1*c1; + float v4 = 2*(r3-r1), + v5 = 2*(c3-c1), + v6 = r3*r3 - r1*r1 + c3*c3 - c1*c1, + + v7 = v2*v4 - v1*v5; + if( v7 == 0 ) + { + r=0; + c=0; + ro2 = -1; + return; + } + + c = (v4*v3 - v1*v6)/v7; + if( v1 != 0 ) + r = (v3 - c*v2)/v1; + else + r = (v6 - c*v5)/v4; + + ro2 = ( (r-r1)*(r-r1) + (c-c1)*(c-c1) ); + + return; +} + + +/* + read an ascii file of (r,c) point pairs. + + the first line of the points file should contain + "NUMP 2 points" + + if it does not have the word points in it the first line is + interpretted as a point pair. + + */ + +long read_Shx(std::vector &pts, char * fname) +{ + char s0[513]; + long nump =0; + float p1,p2; + + Shx pt; + + std::string line; + std::string points_str("points"); + + std::ifstream myfile; + myfile.open(fname); + + if (myfile.is_open()) + { + + getline (myfile,line); + //long numc = line.length(); + + // check string for the string "points" + long n = (long) line.find( points_str); + if( n > 0) + { + while ( myfile.good() ) + { + getline (myfile,line); + if( line.length() <= 512) + { + copy( line.begin(), line.end(), s0); + s0[line.length()] = 0; + long v = sscanf( s0, "%g %g", &p1,&p2); + if( v>0 ) + { + pt.id = nump; + nump++; + pt.r = p1; + pt.c = p2; + pts.push_back(pt); + } + } + } + } + else // assume all number pairs on a line are points + { + if( line.length() <= 512) + { + copy( line.begin(), line.end(), s0); + s0[line.length()] = 0; + long v = sscanf( s0, "%g %g", &p1,&p2); + if( v>0 ) + { + pt.id = nump; + nump++; + pt.r = p1; + pt.c = p2; + pts.push_back(pt); + } + } + + while ( myfile.good() ) + { + getline (myfile,line); + if( line.length() <= 512) + { + copy( line.begin(), line.end(), s0); + s0[line.length()] = 0; + long v = sscanf( s0, "%g %g", &p1,&p2); + if( v>0 ) + { + pt.id = nump; + nump++; + pt.r = p1; + pt.c = p2; + pts.push_back(pt); + } + } + } + } + myfile.close(); + } + + nump = (long) pts.size(); + + return(nump); +} + +/* + write out a set of points to disk + + +*/ + +void write_Shx(std::vector &pts, char * fname) +{ + std::ofstream out(fname, ios::out); + + long nr = (long) pts.size(); + out << nr << " 2 points" << endl; + + for (long r = 0; r < nr; r++) + { + out << pts[r].r << ' ' << pts[r].c << endl; + } + out.close(); + + return; +} + + + +/* + write out triangle ids to be compatible with matlab/octave array numbering. + + */ +void write_Triads(std::vector &ts, char * fname) +{ + std::ofstream out(fname, ios::out); + + long nr = (long) ts.size(); + out << nr << " 6 point-ids (1,2,3) adjacent triangle-ids ( limbs ab ac bc )" << endl; + + for (long r = 0; r < nr; r++) + { + out << ts[r].a+1 << ' ' << ts[r].b+1 <<' ' << ts[r].c+1 <<' ' + << ts[r].ab+1 <<' ' << ts[r].ac+1 <<' ' << ts[r].bc+1 << endl; //" " << ts[r].ro << endl; + } + out.close(); + + return; +} + + + + + +/* version in which the ids of the triangles associated with the sides of the hull are tracked. + + + */ + +long s_hull_pro( std::vector &pts, std::vector &triads) +{ + + long nump = (long) pts.size(); + + if( nump < 3 ) + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "less than 3 points, aborting " << endl; + return(-1); + } + + + float r = pts[0].r; + float c = pts[0].c; + for( long k=0; k 0 ) + { + mid = k; + romin2 = ro2; + R = r; + C = c; + + } + else if( romin2 *4 < pts[k].ro ) + k=nump; + + k++; + } + + if( mid < 0 ) + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "linear structure, aborting " << endl; + return(-2); + } + + + Shx pt0 = pts[0]; + Shx pt1 = pts[1]; + Shx pt2 = pts[mid]; + + pts.erase(pts.begin() + mid); // necessary for round off reasons:(((((( + pts.erase(pts.begin() ); + pts.erase(pts.begin() ); + + for( long k=0; k slump; + slump.resize(nump); + + for( long k=0; k hull; + + + r = (pts[0].r + pts[1].r + pts[2].r )/(float) 3.0; + c = (pts[0].c + pts[1].c + pts[2].c )/(float) 3.0; + + float dr0 = pts[0].r - r, dc0 = pts[0].c - c; + float tr01 = pts[1].r - pts[0].r, tc01 = pts[1].c - pts[0].c; + + float df = -tr01* dc0 + tc01*dr0; + if( df < 0 ) // [ 0 1 2 ] + { + pt0.tr = pt1.r-pt0.r; + pt0.tc = pt1.c-pt0.c; + pt0.trid = 0; + hull.push_back( pt0 ); + + pt1.tr = pt2.r-pt1.r; + pt1.tc = pt2.c-pt1.c; + pt1.trid = 0; + hull.push_back( pt1 ); + + pt2.tr = pt0.r-pt2.r; + pt2.tc = pt0.c-pt2.c; + pt2.trid = 0; + hull.push_back( pt2 ); + + + Triad tri(pt0.id,pt1.id,pt2.id); + tri.ro = romin2; + tri.R = R; + tri.C = C; + + triads.push_back(tri); + + } + else // [ 0 2 1 ] as anti-clockwise turning is the work of the devil.... + { + pt0.tr = pt2.r-pt0.r; + pt0.tc = pt2.c-pt0.c; + pt0.trid = 0; + hull.push_back( pt0 ); + + pt2.tr = pt1.r-pt2.r; + pt2.tc = pt1.c-pt2.c; + pt2.trid = 0; + hull.push_back( pt2 ); + + pt1.tr = pt0.r-pt1.r; + pt1.tc = pt0.c-pt1.c; + pt1.trid = 0; + hull.push_back( pt1 ); + + Triad tri(pt0.id,pt2.id,pt1.id); + tri.ro = romin2; + tri.R = R; + tri.C = C; + triads.push_back(tri); + } + + // add new points into hull (removing obscured ones from the chain) + // and creating triangles.... + // that will need to be flipped. + + float dr, dc, rx,cx; + Shx ptx; + long numt=0; // added by A.Balakin 6 July 2012 -- uninitialised variable + + for( long k=3; k pidx, tridx; + long hidx; // new hull point location within hull..... + + + float df = -dc* hull[0].tr + dr*hull[0].tc; // visibility test vector. + if( df < 0 ) // starting with a visible hull facet !!! + { +// long e1 = 1, e2 = numh; // commented by A.Balakin 6 July 2012 -- unused variable + hidx = 0; + + // check to see if segment numh is also visible + df = -dc* hull[numh-1].tr + dr*hull[numh-1].tc; + //cerr << df << ' ' ; + if( df < 0 ) // visible. + { + pidx.push_back(hull[numh-1].id); + tridx.push_back(hull[numh-1].trid); + + + for( long h=0; h0; h--) + { + // if segment h is visible delete h + 1 + dr = rx- hull[h].r; + dc = cx- hull[h].c; + df = -dc* hull[h].tr + dr*hull[h].tc; + + if( df < 0 ) // h is visible + { + pidx.insert(pidx.begin(), hull[h].id); + tridx.insert(tridx.begin(), hull[h].trid); + hull.erase(hull.begin() + h+1); // erase end of chain + + } + else + { + + h = (long) hull.size()-1; + hull[h].tr = -hull[h].r + ptx.r; // points at start of chain. + hull[h].tc = -hull[h].c + ptx.c; + break; + } + } + + df = 9; + + } + else + { + // cerr << df << ' ' << endl; + hidx = 1; // keep pt hull[0] + tridx.push_back(hull[0].trid); + pidx.push_back(hull[0].id); + + for( long h=1; h 0 ) // first invisible segment. + { + e2 = h; + break; + } + } + + } + + + // triangle pidx starts at e1 and ends at e2 (inclusive). + if( e2 < numh ) + { + for( long e=e1; e<=e2; e++) + { + pidx.push_back(hull[e].id); + tridx.push_back(hull[e].trid); + } + } + else + { + for( long e=e1; e 0 ) + hull[hidx-1].trid = numt; + else + { + numh = (long) hull.size(); + hull[numh-1].trid = numt; + } + triads.push_back( trx ); + numt++; + } + + else + { + trx.ab = -1; + for(long p=0; p 0 ) + trx.ab = numt-1; + trx.ac = numt+1; + + // index back into the triads. + Triad &txx = triads[tridx[p]]; + if( ( trx.b == txx.a && trx.c == txx.b) |( trx.b == txx.b && trx.c == txx.a)) + { + txx.ab = numt; + } + else if( ( trx.b == txx.a && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.a)) + { + txx.ac = numt; + } + else if( ( trx.b == txx.b && trx.c == txx.c) |( trx.b == txx.c && trx.c == txx.b)) + { + txx.bc = numt; + } + + triads.push_back( trx ); + numt++; + } + triads[numt-1].ac=-1; + + hull[hidx].trid = numt-1; + if( hidx > 0 ) + hull[hidx-1].trid = T0; + else + { + numh = (long) hull.size(); + hull[numh-1].trid = T0; + } + + + } + + } + +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "of triangles " << triads.size() << " to be flipped. "<< endl; + + // write_Triads(triads, "tris0.mat"); + + std::set ids, ids2; + + long tf = T_flip_pro( pts, triads, slump, numt, 0, ids); + if( tf < 0 ) + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "cannot triangualte this set " << endl; + return(-3); + } + + // write_Triads(triads, "tris1.mat"); + + long nits = (long) ids.size(), nit=1; + while( nits > 0 && nit < 50) + { + + tf = T_flip_pro_idx( pts, triads, slump, ids); + nits = (long) ids.size(); + nit ++; + if( tf < 0 ) + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "cannot triangualte this set " << endl; + return(-4); + } + } + return(1); +} + + +void circle_cent4(float r1,float c1, float r2,float c2, float r3,float c3, + float &r,float &c, float &ro2) +{ + /* + * function to return the center of a circle and its radius + * degenerate case should never be passed to this routine!!!!!!!!!!!!! + * but will return r0 = -1 if it is. + */ + + double rd, cd; + double v1 = 2*(r2-r1), v2 = 2*(c2-c1), v3 = r2*r2 - r1*r1 + c2*c2 - c1*c1; + double v4 = 2*(r3-r1), + v5 = 2*(c3-c1), + v6 = r3*r3 - r1*r1 + c3*c3 - c1*c1, + + v7 = v2*v4 - v1*v5; + if( v7 == 0 ) + { + r=0; + c=0; + ro2 = -1; + return; + } + + cd = (v4*v3 - v1*v6)/v7; + if( v1 != 0 ) + rd = (v3 - c*v2)/v1; + else + rd = (v6 - c*v5)/v4; + + ro2 = (float) ( (rd-r1)*(rd-r1) + (cd-c1)*(cd-c1) ); + r = (float) rd; + c = (float) cd; + + return; +} + + +/* test a set of points for duplicates. + + erase duplicate points, do not change point ids. + +*/ +// Change return type to size_t to be 64 bit compatible -- by A.Balakin 7 August 2012 + +size_t de_duplicate( std::vector &pts, std::vector &outx ) +{ + + size_t nump = pts.size(); + std::vector dpx; + Dupex d; + for( size_t k=0; k0; k--) + { + pts.erase(pts.begin()+outx[k-1]); + } + + return(nx); +} + + + + +/* + flip pairs of triangles that are not valid delaunay triangles + the Cline-Renka test is used rather than the less stable circum + circle center computation test of s-hull. + + or the more expensive determinant test. + + */ + + +long T_flip_pro( std::vector &pts, std::vector &triads, std::vector &slump, long numt, long start, std::set &ids) +{ + + float r3,c3; + long pa,pb,pc, pd, D, L1, L2, L3, L4, T2; + + Triad tx, tx2; + + + for( long t=start; t= 0 ) + { + + pa = slump[tri.a]; + pb = slump[tri.b]; + pc = slump[tri.c]; + + T2 = tri.bc; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.b == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.b == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.b == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << endl; + return(-5); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pa].r, pts[pa].c, pts[pb].r, pts[pb].c, + pts[pc].r, pts[pc].c, r3, c3 ); + + if( XX < 0 ) + { + + L1 = tri.ab; + L2 = tri.ac; + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + tx.a = tri.a; + tx.b = tri.b; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.a; + tx2.b = tri.c; + tx2.c = D; + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + + ids.insert(t); + ids.insert(T2); + + t2 = tx2; + tri = tx; + flipped = 1; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + } + } + } + + + if( flipped == 0 && tri.ab >= 0 ) + { + + pc = slump[tri.c]; + pb = slump[tri.b]; + pa = slump[tri.a]; + + T2 = tri.ab; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.a == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.a == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.a == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << endl; + return(-5); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pc].r, pts[pc].c, pts[pb].r, pts[pb].c, + pts[pa].r, pts[pa].c,r3, c3); + + if( XX < 0) + { + + + L1 = tri.ac; + L2 = tri.bc; + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + tx.a = tri.c; + tx.b = tri.a; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.c; + tx2.b = tri.b; + tx2.c = D; + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + + ids.insert(t); + ids.insert(T2); + + t2 = tx2; + tri = tx; + flipped = 1; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + + } + + } + } + + + if( flipped == 0 && tri.ac >= 0 ) + { + + pc = slump[tri.c]; + pb = slump[tri.b]; + pa = slump[tri.a]; + + T2 = tri.ac; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.a == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.a == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.a == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << endl; + return(-5); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pb].r, pts[pb].c, pts[pa].r, pts[pa].c, + pts[pc].r, pts[pc].c,r3, c3); + + if( XX < 0 ) + { + + L1 = tri.ab; // .ac shared limb + L2 = tri.bc; + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + tx.a = tri.b; + tx.b = tri.a; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.b; + tx2.b = tri.c; + tx2.c = D; + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + ids.insert(t); + ids.insert(T2); + + t2 = tx2; + tri = tx; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + + } + } + } + + + } + + + return(1); +} + +/* minimum angle cnatraint for circum circle test. + due to Cline & Renka + + A -- B + + | / | + + C -- D + + + */ + +long Cline_Renka_test(float &Ax, float &Ay, + float &Bx, float &By, + float &Cx, float &Cy, + float &Dx, float &Dy) +{ + + float v1x = Bx-Ax, v1y = By-Ay, v2x = Cx-Ax, v2y = Cy-Ay, + v3x = Bx-Dx, v3y = By-Dy, v4x = Cx-Dx, v4y = Cy-Dy; + float cosA = v1x*v2x + v1y*v2y; + float cosD = v3x*v4x + v3y*v4y; + + if( cosA < 0 && cosD < 0 ) // two obtuse angles + return(-1); + +// float ADX = Ax-Dx, ADy = Ay-Dy; // commented by A.Balakin 6 July 2012 -- unused variable + + + if( cosA > 0 && cosD > 0 ) // two acute angles + return(1); + + + float sinA = fabs(v1x*v2y - v1y*v2x); + float sinD = fabs(v3x*v4y - v3y*v4x); + + if( cosA*sinD + sinA*cosD < 0 ) + return(-1); + + return(1); + +} + + + + +// same again but with set of triangle ids to be iterated over. + + +long T_flip_pro_idx( std::vector &pts, std::vector &triads, std::vector &slump, std::set &ids) +{ + + float r3,c3; + long pa,pb,pc, pd, D, L1, L2, L3, L4, T2; + + Triad tx, tx2; + std::set ids2; + ids2.clear(); + + std::set :: const_iterator x=ids.begin(); + while(x != ids.end() ) + { + long t = *x; + x++; + + + Triad &tri = triads[t]; + // test all 3 neighbours of tri + long flipped = 0; + + + + if( tri.bc >= 0 ) + { + + pa = slump[tri.a]; + pb = slump[tri.b]; + pc = slump[tri.c]; + + T2 = tri.bc; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.b == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.b == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.b == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << " T2: " << T2<< endl; + return(-6); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pa].r, pts[pa].c, pts[pb].r, pts[pb].c, + pts[pc].r, pts[pc].c,r3, c3); + + if( XX < 0 ) + { + L1 = tri.ab; + L2 = tri.ac; + + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + + tx.a = tri.a; + tx.b = tri.b; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.a; + tx2.b = tri.c; + tx2.c = D; + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + ids2.insert(t); + ids2.insert(T2); + + t2 = tx2; + tri = tx; + flipped = 1; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + + } + } + } + + + if( flipped == 0 && tri.ab >= 0 ) + { + + pc = slump[tri.c]; + pb = slump[tri.b]; + pa = slump[tri.a]; + + T2 = tri.ab; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.a == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.a == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.a == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << endl; + return(-6); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pc].r, pts[pc].c, pts[pb].r, pts[pb].c, + pts[pa].r, pts[pa].c,r3, c3); + + if( XX < 0 ) + { + L1 = tri.ac; + L2 = tri.bc; + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + tx.a = tri.c; + tx.b = tri.a; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.c; + tx2.b = tri.b; + tx2.c = D; + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + + ids2.insert(t); + ids2.insert(T2); + + t2 = tx2; + tri = tx; + flipped = 1; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + + } + } + } + + + if( flipped == 0 && tri.ac >= 0 ) + { + + pc = slump[tri.c]; + pb = slump[tri.b]; + pa = slump[tri.a]; + + T2 = tri.ac; + Triad &t2 = triads[T2]; + // find relative orientation (shared limb). + if( t2.ab == t ) + { + D = t2.c; + pd = slump[t2.c]; + + if( tri.a == t2.a) + { + L3 = t2.ac; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ac; + } + } + else if( t2.ac == t ) + { + D = t2.b; + pd = slump[t2.b]; + + if( tri.a == t2.a) + { + L3 = t2.ab; + L4 = t2.bc; + } + else + { + L3 = t2.bc; + L4 = t2.ab; + } + } + else if( t2.bc == t ) + { + D = t2.a; + pd = slump[t2.a]; + + if( tri.a == t2.b) + { + L3 = t2.ab; + L4 = t2.ac; + } + else + { + L3 = t2.ac; + L4 = t2.ab; + } + } + else + { +// Commented by A.Balakin 2 July 2012 -- library shouldn't print anything +// cerr << "triangle flipping error. " << t << endl; + return(-6); + } + + r3 = pts[pd].r; + c3 = pts[pd].c; + + long XX = Cline_Renka_test( pts[pb].r, pts[pb].c, pts[pc].r, pts[pc].c, + pts[pa].r, pts[pa].c,r3, c3); + + if( XX < 0 ) + { + L1 = tri.ab; // .ac shared limb + L2 = tri.bc; + if( L1 != L3 && L2 != L4 ) // need this check for stability. + { + + + tx.a = tri.b; + tx.b = tri.a; + tx.c = D; + + tx.ab = L1; + tx.ac = T2; + tx.bc = L3; + + + // triangle 2; + tx2.a = tri.b; + tx2.b = tri.c; + tx2.c = D; + + + + tx2.ab = L2; + tx2.ac = t; + tx2.bc = L4; + + + ids2.insert(t); + ids2.insert(T2); + + t2 = tx2; + tri = tx; + + // change knock on triangle labels. + if( L3 >= 0 ) + { + Triad &t3 = triads[L3]; + if( t3.ab == T2 ) t3.ab = t; + else if( t3.bc == T2 ) t3.bc = t; + else if( t3.ac == T2 ) t3.ac = t; + } + + if(L2 >= 0 ) + { + Triad &t4 = triads[L2]; + if( t4.ab == t ) t4.ab = T2; + else if( t4.bc == t ) t4.bc = T2; + else if( t4.ac == t ) t4.ac = T2; + } + + + } + } + } + + + } + + ids.clear(); + ids.insert(ids2.begin(), ids2.end()); + + return(1); +} + diff --git a/src/s_hull/s_hull_pro.h b/src/s_hull/s_hull_pro.h new file mode 100644 index 0000000..7d4979a --- /dev/null +++ b/src/s_hull/s_hull_pro.h @@ -0,0 +1,151 @@ +#ifndef _structures_h +#define _structures_h + + + + +// for FILE + +#include +#include +#include + + + +/* + for use in s_hull_pro.cpp + +S-hull-pro, Copyright (c) 2012 +Dr David SInclair +Cambridge, UK + +email david@s-hull.org + + +*/ + +// Global replace int->long by A.Balakin 7 August 2012 -- 64bit version can handle huge data arrays + +struct Triad +{ + long a,b, c; + long ab, bc, ac; // adjacent edges index to neighbouring triangle. + float ro, R,C; + //std::set idx; + Triad() {a=b=c=ab=bc=ac=0; ro=R=C=0;} // added by A.Balakin 6 July 2012 -- uninitialised variable + Triad(long x, long y) : a(x), b(y),c(0), ab(-1), bc(-1), ac(-1), ro(-1), R(0), C(0) {} + Triad(long x, long y, long z) : a(x), b(y), c(z), ab(-1), bc(-1), ac(-1), ro(-1), R(0), C(0) {} + Triad(const Triad &p) : a(p.a), b(p.b), c(p.c), ab(p.ab), bc(p.bc), ac(p.ac), ro(p.ro), R(p.R), C(p.C) {} + + Triad &operator=(const Triad &p) + { + a = p.a; + b = p.b; + c = p.c; + + ab = p.ab; + bc = p.bc; + ac = p.ac; + + ro = p.ro; + R = p.R; + C = p.C; + + return *this; + } +}; + + + +/* point structure for s_hull only. + has to keep track of triangle ids as hull evolves. +*/ + + +struct Shx +{ + long id, trid; + float r,c, tr,tc ; + float ro; + Shx() {r=c=tr=tc=ro=0; id=trid=0;} // added by A.Balakin 6 July 2012 -- uninitialised variable + Shx(float a, float b) : id(-1), r(a), c(b), tr(0.0), tc(0.0), ro(0.0) + { trid=0; } // added by A.Balakin 6 July 2012 -- uninitialised variable + Shx(float a, float b, float x) : id(-1), r(a), c(b), tr(0), tc(0), ro(x) + { trid=0; } // added by A.Balakin 6 July 2012 -- uninitialised variable + Shx(const Shx &p) : id(p.id), trid(p.trid), r(p.r), c(p.c), tr(p.tr), tc(p.tc), ro(p.ro) {} + + Shx &operator=(const Shx &p) + { + id = p.id; + trid = p.trid; + r = p.r; + c = p.c; + tr = p.tr; + tc = p.tc; + ro = p.ro; + return *this; + } + +}; + + +// sort into descending order (for use in corner responce ranking). +inline bool operator<(const Shx &a, const Shx &b) +{ + if( a.ro == b.ro) + return a.r < b.r; + return a.ro < b.ro; +} + + +struct Dupex +{ + long id; + float r,c; + + Dupex() {} + Dupex(float a, float b) : id(-1), r(a), c(b) {} + Dupex(float a, float b, long x) : id(x), r(a), c(b) {} + Dupex(const Dupex &p) : id(p.id), r(p.r), c(p.c) {} + + Dupex &operator=(const Dupex &p) + { + id = p.id; + r = p.r; + c = p.c; + return *this; + } +}; + + + +// sort into descending order (for use in corner responce ranking). +inline bool operator<(const Dupex &a, const Dupex &b) +{ + if( a.r == b.r) + return a.c < b.c; + return a.r < b.r; +} + + + + + +// from s_hull.C + + +long s_hull_pro( std::vector &pts, std::vector &triads); +void circle_cent2(float r1,float c1, float r2,float c2, float r3,float c3,float &r,float &c, float &ro2); +void circle_cent4(float r1,float c1, float r2,float c2, float r3,float c3,float &r,float &c, float &ro2); +void write_Shx(std::vector &pts, char * fname); +void write_Triads(std::vector &ts, char * fname); +long Cline_Renka_test(float &Ax, float &Ay, float &Bx, float &By, float &Cx, float &Cy, float &Dx, float &Dy); +long T_flip_pro( std::vector &pts, std::vector &triads, std::vector &slump, long numt, long start, std::set &ids); +long T_flip_pro_idx( std::vector &pts, std::vector &triads, std::vector &slump, std::set &ids); + +long read_Shx(std::vector &pts, char * fname); + + +size_t de_duplicate( std::vector &pts, std::vector &outx ); + +#endif diff --git a/src/surf.cpp b/src/surf.cpp new file mode 100644 index 0000000..f847657 --- /dev/null +++ b/src/surf.cpp @@ -0,0 +1,940 @@ +/*************************************************************************** + * surf.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/define.h" +#include "mgl2/surf.h" +#include "mgl2/data.h" +#include "mgl2/eval.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_mesh_plot(mglBase *gr, long *pos, long n, long m, int how) +{ + int d = gr->MeshNum>0 ? gr->MeshNum+1 : n*m, dx = n>d?n/d:1, dy = m>d?m/d:1; + // NOTE: number of lines in each direction can be reduced too + if(how&1) +#pragma omp parallel for + for(long j=0;j=0 && pos[n*j+i+1]>=0) s++; + d = gr->FaceNum>0 ? gr->FaceNum+1 : n; s = s>d?s/d:1; + for(i=0;iline_plot(pos[n*j+i],pos[n*j+i+s]); + + } + if(how&2) +#pragma omp parallel for + for(long i=0;i=0 && pos[n*j+i+n]>=0) s++; + d = gr->FaceNum>0 ? gr->FaceNum+1 : n; s = s>d?s/d:1; + for(j=0;jline_plot(pos[n*j+i],pos[n*j+i+s*n]); + } +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_surf_plot(mglBase *gr, long *pos, long n, long m) +{ + long s=0; + for(long j=0;j=0 && pos[n*j+i+1]>=0 && pos[n*j+i+n]>=0 && pos[n*j+i+n+1]>=0) + s++; + long dx=1,dy=1; + if(gr->FaceNum && s>gr->FaceNum*gr->FaceNum) + { + int d = gr->FaceNum+1,ns=n*s/((n-1)*(m-1)),ms=m*s/((n-1)*(m-1)); + dx = ns>d?ns/d:1; dy = ms>d?ms/d:1; + } +#pragma omp parallel for collapse(2) + for(long j=0;jquad_plot(pos[n*j+i],pos[n*j+i+dx],pos[n*j+i+n*dy],pos[n*j+i+n*dy+dx]); +} +//----------------------------------------------------------------------------- +// +// Plot by formulas series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fsurf(HMGL gr, const char *eqZ, const char *sch, const char *opt) +{ // TODO: Add strong function variation analysis ??? + if(eqZ==0 || eqZ[0]==0) return; // nothing to plot + mreal r = gr->SaveState(opt); + long n = (mgl_isnan(r) || r<=0) ? 100:long(r+0.5); + mglData z(n,n); + mglFormula *eq = new mglFormula(eqZ); + mreal dx = (gr->Max.x - gr->Min.x)/(n-1.), dy = (gr->Max.y - gr->Min.y)/(n-1.); +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + z.a[i+n*j] = eq->Calc(gr->Min.x+i*dx, gr->Min.y+j*dy); + } + mgl_surf(gr, &z, sch,0); + delete eq; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fsurf_xyz(HMGL gr, const char *eqX, const char *eqY, const char *eqZ, const char *sch, const char *opt) +{ // TODO: Add strong function variation analisys ??? + if(eqZ==0 || eqZ[0]==0) return; // nothing to plot + mreal r = gr->SaveState(opt); + long n = (mgl_isnan(r) || r<=0) ? 100:long(r+0.5); + mglData x(n,n), y(n,n), z(n,n); + if(n<=0) n=100; + mglFormula *ex, *ey, *ez; + ex = new mglFormula(eqX ? eqX : "u"); + ey = new mglFormula(eqY ? eqY : "v"); + ez = new mglFormula(eqZ); +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + register mreal u = j/(n-1.), v = i/(n-1.); + x.a[i+n*j] = ex->Calc(0,v,0,u); + y.a[i+n*j] = ey->Calc(0,v,0,u); + z.a[i+n*j] = ez->Calc(0,v,0,u); + } + mgl_surf_xy(gr,&x,&y,&z,sch,0); + delete ex; delete ey; delete ez; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fsurf_(uintptr_t *gr, const char *fy, const char *stl, const char *opt, int ly, int ls, int lo) +{ char *s=new char[ly+1]; memcpy(s,fy,ly); s[ly]=0; + char *p=new char[ls+1]; memcpy(p,stl,ls); p[ls]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_fsurf(_GR_, s, p, o); delete []o; delete []s; delete []p; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fsurf_xyz_(uintptr_t *gr, const char *fx, const char *fy, const char *fz, const char *stl, const char *opt, int lx, int ly, int lz, int ls, int lo) +{ + char *sx=new char[lx+1]; memcpy(sx,fx,lx); sx[lx]=0; + char *sy=new char[ly+1]; memcpy(sy,fy,ly); sy[ly]=0; + char *sz=new char[lz+1]; memcpy(sz,fz,lz); sz[lz]=0; + char *p=new char[ls+1]; memcpy(p,stl,ls); p[ls]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_fsurf_xyz(_GR_, sx, sy, sz, p, o); delete []o; + delete []sx; delete []sy; delete []sz; delete []p; +} +//----------------------------------------------------------------------------- +// +// Mesh series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mesh_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Mesh")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Mesh",cgid++); + gr->SetPenPal(sch,0,false); + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; memset(pos,-1L,n*m*sizeof(long)); + gr->Reserve(n*m*z->GetNz()); + + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + register mreal zz = z->v(i,j,k); + pos[i+n*j] = gr->AddPnt(mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, zz),gr->GetC(ss,zz)); + } + mgl_mesh_plot(gr,pos,n,m,3); + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mesh(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_mesh_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mesh_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_mesh_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_mesh_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_mesh(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Fall series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fall_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Fall")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Fall",cgid++); + gr->SetPenPal(sch,0,false); + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; + gr->Reserve(n*m*z->GetNz()); + + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + register mreal zz = z->v(i,j,k); + pos[i+n*j] = gr->AddPnt(mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, zz),gr->GetC(ss,zz)); + } + mgl_mesh_plot(gr,pos,n,m, (mglchr(sch,'x')) ? 2:1); + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fall(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_fall_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fall_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_fall_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_fall_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_fall(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Grid series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Grid")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Grid",cgid++); + mreal zVal = gr->Min.z; + gr->SetPenPal(sch?sch:"k-"); + long *pos = new long[n*m]; + gr->Reserve(n*m*z->GetNz()); + + for(long k=0;kGetNz();k++) + { + if(z->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(z->GetNz()-1); +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + pos[i+n*j] = gr->AddPnt(mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, zVal),gr->CDef); + } + mgl_mesh_plot(gr,pos,n,m,3); + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid(HMGL gr, HCDT z,const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_grid_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_grid_xy(_GR_,_DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grid_(uintptr_t *gr, uintptr_t *a,const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_grid(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Surf series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Surf")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Surf",cgid++); + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; + bool wire = (mglchr(sch,'#')); + gr->Reserve((n+1)*(m+1)*z->GetNz()*(wire?2:1)); + + mglPoint p,q,s,xx,yy; + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for private(p,q,s,xx,yy) collapse(2) + for(long j=0;jStop) continue; + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + p = mglPoint(xx.x, yy.x, z->v(i,j,k)); + q = mglPoint(xx.y, yy.y, z->dvx(i,j,k)); + s = mglPoint(xx.z, yy.z, z->dvy(i,j,k)); + pos[i+n*j] = gr->AddPnt(p,gr->GetC(ss,p.z),q^s); + } + if(sch && mglchr(sch,'.')) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else mgl_surf_plot(gr,pos,n,m); + if(wire && !gr->Stop) + { + gr->SetPenPal("k-"); +#pragma omp parallel for + for(long i=0;iCopyNtoC(pos[i],gr->CDef); + mgl_mesh_plot(gr,pos,n,m,3); + } + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_surf_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Belt series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_belt_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Belt")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Belt",cgid++); + int d = gr->MeshNum>0 ? gr->MeshNum+1 : n*m, dx = n>d?n/d:1, dy = m>d?m/d:1; + long ss = gr->AddTexture(sch); + long *pos = new long[2*(n>m?n:m)]; + gr->Reserve(2*n*m*z->GetNz()); + bool how = !mglchr(sch,'x'); + + mglPoint p1,p2,q,s,xx,yy; + for(long k=0;kGetNz();k++) + { + if(how) for(long i=0;iStop) continue; + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + p1 = mglPoint(xx.x, yy.x, z->v(i,j,k)); + s = mglPoint(xx.z, yy.z, z->dvy(i,j,k)); + q = mglPoint(xx.y, yy.y, 0); s = q^s; + register mreal c = gr->GetC(ss,p1.z); + p2 = mglPoint(GetX(x,i+dx,j,k).x,GetY(y,i+dx,j,k).x,p1.z); + pos[2*j] = gr->AddPnt(p1,c,s); + pos[2*j+1]=gr->AddPnt(p2,c,s); + } + mgl_surf_plot(gr,pos,2,m); + } + else for(long j=0;jStop) continue; + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + p1 = mglPoint(xx.x, yy.x, z->v(i,j,k)); + q = mglPoint(xx.y, yy.y, z->dvx(i,j,k)); + s = mglPoint(xx.z, yy.z, 0); s = q^s; + register mreal c = gr->GetC(ss,p1.z); + p2 = mglPoint(GetX(x,i,j+dy,k).x,GetY(y,i,j+dy,k).x,p1.z); + pos[2*i] = gr->AddPnt(p1,c,s); + pos[2*i+1]=gr->AddPnt(p2,c,s); + } + mgl_surf_plot(gr,pos,2,n); + } + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_belt(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_belt_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_belt_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_belt_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_belt_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_belt(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Dens series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Dens")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Dens",cgid++); + mreal zVal = gr->Min.z; + + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; + bool wire = (mglchr(sch,'#')); + gr->Reserve((n+1)*(m+1)*z->GetNz()*(wire?2:1)); + + mglPoint p,s=mglPoint(0,0,1); + mreal zz, c; + for(long k=0;kGetNz();k++) + { + if(z->GetNz()>1) + zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(z->GetNz()-1); +#pragma omp parallel for private(p,c,zz) collapse(2) + for(long j=0;jStop) continue; + p = mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, zVal); + zz = z->v(i,j,k); c = gr->GetC(ss,zz); + if(mgl_isnan(zz)) p.x = NAN; + pos[i+n*j] = gr->AddPnt(p,c,s); + } + if(sch && mglchr(sch,'.')) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else mgl_surf_plot(gr,pos,n,m); + if(wire && !gr->Stop) + { + gr->SetPenPal("k-"); +#pragma omp parallel for + for(long i=0;iCopyNtoC(pos[i],gr->CDef); + mgl_mesh_plot(gr,pos,n,m,3); + } + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x, gr->Max.x); + y.Fill(gr->Min.y, gr->Max.y); + mgl_dens_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dens_xy(_GR_,_DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_dens_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_dens(_GR_,_DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// STFA series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stfa_xy(HMGL gr, HCDT x, HCDT y, HCDT re, HCDT im, int dn, const char *sch, const char *opt) +{ mglData tmp(mglSTFA(*re,*im,dn,'x')); mgl_dens_xy(gr,x,y,&tmp,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stfa(HMGL gr, HCDT re, HCDT im, int dn, const char *sch, const char *opt) +{ mglData tmp(mglSTFA(*re,*im,dn,'x')); mgl_dens(gr,&tmp,sch,opt); } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stfa_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *re, uintptr_t *im, int *dn, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_stfa_xy(_GR_,_DA_(x), _DA_(y), _DA_(re), _DA_(im), *dn, s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_stfa_(uintptr_t *gr, uintptr_t *re, uintptr_t *im, int *dn, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_stfa(_GR_,_DA_(re), _DA_(im), *dn, s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// SurfC series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfc_xy(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,c,"SurfC")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("SurfC",cgid++); + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; + bool wire = (mglchr(sch,'#')); + gr->Reserve((n+1)*(m+1)*z->GetNz()*(wire?2:1)); + + mglPoint p,q,s,xx,yy; + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for private(p,xx,yy,q,s) collapse(2) + for(long j=0;jStop) continue; + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + p = mglPoint(xx.x, yy.x, z->v(i,j,k)); + q = mglPoint(xx.y, yy.y, z->dvx(i,j,k)); + s = mglPoint(xx.z, yy.z, z->dvy(i,j,k)); + pos[i+n*j] = gr->AddPnt(p,gr->GetC(ss,c->v(i,j,k)),q^s); + } + if(sch && mglchr(sch,'.')) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else mgl_surf_plot(gr,pos,n,m); + if(wire && !gr->Stop) + { + gr->SetPenPal("k-"); +#pragma omp parallel for + for(long i=0;iCopyNtoC(pos[i],gr->CDef); + mgl_mesh_plot(gr,pos,n,m,3); + } + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfc(HMGL gr, HCDT z, HCDT c, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_surfc_xy(gr,&x,&y,z,c,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfc_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surfc_xy(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfc_(uintptr_t *gr, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surfc(_GR_, _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// SurfA series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfa_xy(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT c, const char *sch, const char *opt) +{ + long k,n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,c,"SurfA")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("SurfA",cgid++); + long ss = gr->AddTexture(sch); + long *pos = new long[n*m]; + bool wire = (mglchr(sch,'#')); + gr->Reserve((n+1)*(m+1)*z->GetNz()*(wire?2:1)); + + mglPoint p,q,s,xx,yy; + for(k=0;kGetNz();k++) + { +#pragma omp parallel for private(p,xx,yy,q,s) collapse(2) + for(long j=0;jStop) continue; + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + mreal vv = z->v(i,j,k); p = mglPoint(xx.x, yy.x, vv); + q = mglPoint(xx.y, yy.y, z->dvx(i,j,k)); + s = mglPoint(xx.z, yy.z, z->dvy(i,j,k)); + pos[i+n*j] = gr->AddPnt(p,gr->GetC(ss,vv),q^s,gr->GetA(c->v(i,j,k))); + } + if(sch && mglchr(sch,'.')) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else mgl_surf_plot(gr,pos,n,m); + if(wire && !gr->Stop) + { + gr->SetPenPal("k-"); +#pragma omp parallel for + for(long i=0;iCopyNtoC(pos[i],gr->CDef); + mgl_mesh_plot(gr,pos,n,m,3); + } + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfa(HMGL gr, HCDT z, HCDT c, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()), y(z->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_surfa_xy(gr,&x,&y,z,c,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfa_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surfa_xy(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surfa_(uintptr_t *gr, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surfa(_GR_, _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Boxs series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxs_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + register long i,j,k,n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Boxs",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Boxs",cgid++); + long ly = y->GetNy()>=m ? y->GetNy() : y->GetNx(), lx = x->GetNx(); + int d = gr->MeshNum>0 ? gr->MeshNum+1 : n*m, dx = n>d?n/d:1, dy = m>d?m/d:1; + + long ss = gr->AddTexture(sch); + bool wire = mglchr(sch,'#'); + bool full = mglchr(sch,'@'); + gr->Reserve(8*n*m*z->GetNz()); + + mglPoint p1,p2,p3,p4,q,s,t(wire||full?NAN:0,0,1),xx,yy; + mreal zz,z1,z2,x1,y1,x2,y2,x3,y3,c,z0=gr->GetOrgZ('x'); + long k1,k2,k3,k4,k5,k6,k7,k8; + for(k=0;kGetNz();k++) + { + for(i=0;iStop) continue; + zz = z->v(i,j,k); c = gr->GetC(ss,zz); + xx = GetX(x,i,j,k); yy = GetY(y,i,j,k); + x1 = iv(i+dx,j,k):NAN; + z2 = jv(i,j+dy,k):NAN; + q = mglPoint(xx.y,yy.y,0); + s = mglPoint(xx.z,yy.z,0); + p1 = mglPoint(xx.x,yy.x,zz); k1 = gr->AddPnt(p1,c,t); + p2 = mglPoint(x1,y1,zz); k2 = gr->AddPnt(p2,c,t); + p3 = mglPoint(x2,y2,zz); k3 = gr->AddPnt(p3,c,t); + p4 = mglPoint(x3,y3,zz); k4 = gr->AddPnt(p4,c,t); + if(wire) + { + gr->line_plot(k1,k2); gr->line_plot(k1,k3); + gr->line_plot(k4,k2); gr->line_plot(k4,k3); + } + else gr->quad_plot(k1,k2,k3,k4); + + if(full) + { + p1 = mglPoint(xx.x,yy.x,z0); k5 = gr->AddPnt(p1,c,t); + p2 = mglPoint(x1,y1,z0); k6 = gr->AddPnt(p2,c,t); + p3 = mglPoint(x2,y2,z0); k7 = gr->AddPnt(p3,c,t); + p4 = mglPoint(x3,y3,z0); k8 = gr->AddPnt(p4,c,t); + if(wire) + { + gr->line_plot(k5,k6); gr->line_plot(k5,k7); + gr->line_plot(k8,k6); gr->line_plot(k8,k7); + gr->line_plot(k1,k5); gr->line_plot(k3,k7); + gr->line_plot(k2,k6); gr->line_plot(k4,k8); + } + else + { + gr->quad_plot(k1,k2,k5,k6); gr->quad_plot(k1,k3,k5,k7); + gr->quad_plot(k4,k2,k8,k6); gr->quad_plot(k4,k3,k8,k7); + gr->quad_plot(k5,k6,k7,k8); + } + } + else + { + p3 = mglPoint(x1,y1,z1); k5 = gr->AddPnt(p3,c,wire?t:q); + p4 = mglPoint(x3,y3,z1); k6 = gr->AddPnt(p4,c,wire?t:q); + if(wire) + { gr->line_plot(k2,k5); gr->line_plot(k6,k5); gr->line_plot(k6,k4); } + else gr->quad_plot(k2,k4,k5,k6); + p3 = mglPoint(x2,y2,z2); k7 = gr->AddPnt(p3,c,wire?t:s); + p4 = mglPoint(x3,y3,z2); k8 = gr->AddPnt(p4,c,wire?t:s); + if(wire) + { gr->line_plot(k3,k7); gr->line_plot(k4,k8); gr->line_plot(k7,k8); } + else gr->quad_plot(k3,k4,k7,k8); + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxs(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()+1), y(z->GetNy()+1); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_boxs_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxs_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_boxs_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_boxs_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_boxs(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Tile series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tile_xy(HMGL gr, HCDT x, HCDT y, HCDT z, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,0,"Tile",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Tile",cgid++); + long ly = x->GetNy()>=z->GetNy() ? y->GetNy() : y->GetNx(), lx = x->GetNx(); + int d = gr->MeshNum>0 ? gr->MeshNum+1 : n*m, dx = n>d?n/d:1, dy = m>d?m/d:1; + + long ss = gr->AddTexture(sch); + gr->Reserve(4*n*m*z->GetNz()); + + mglPoint s=mglPoint(0,0,1); + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + register mreal zz = z->v(i,j,k), c = gr->GetC(ss,zz); + register mreal xx = GetX(x,i,j,k).x, yy = GetY(y,i,j,k).x; + register long k1 = gr->AddPnt(mglPoint(xx,yy,zz),c,s); + xx = iAddPnt(mglPoint(xx,yy,zz),c,s); + xx = jAddPnt(mglPoint(xx,yy,zz),c,s); + xx = iAddPnt(mglPoint(xx,yy,zz),c,s); + gr->quad_plot(k1,k2,k3,k4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tile(HMGL gr, HCDT z, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()+1), y(z->GetNy()+1); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_tile_xy(gr,&x,&y,z,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tile_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tile_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tile_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tile(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// TileS series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tiles_xy(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT s, const char *sch, const char *opt) +{ + long n=z->GetNx(),m=z->GetNy(); + if(mgl_check_dim2(gr,x,y,z,s,"TileS",true)) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("TileS",cgid++); + long ly = x->GetNy()>=z->GetNy() ? y->GetNy() : y->GetNx(), lx = x->GetNx(); + int d = gr->MeshNum>0 ? gr->MeshNum+1 : n*m, dx = n>d?n/d:1, dy = m>d?m/d:1; + + long cc = gr->AddTexture(sch); + gr->Reserve(4*n*m*z->GetNz()); + + mglPoint t=mglPoint(0,0,1); + mreal x1,x2,x3,x4,y1,y2,y3,y4; + for(long k=0;kGetNz();k++) + { +#pragma omp parallel for private(x1,x2,x3,x4,y1,y2,y3,y4) collapse(2) + for(long j=0;jStop) continue; + register mreal zz = z->v(i,j,k), c = gr->GetC(cc,zz); + register mreal ss = (1-gr->GetA(s->v(i,j,k)))/2, sm = 1-ss; + + x1 = GetX(x,i,j,k).x; y1 = GetY(y,i,j,k).x; + x2 = x3 = x4 = y2 = y3 = y4 = NAN; + if(iAddPnt(mglPoint(x1+x2*ss+x4*ss+x3*ss*ss, y1+y2*ss+y4*ss+y3*ss*ss, zz),c,t); + register long k2 = gr->AddPnt(mglPoint(x1+x2*sm+x4*ss+x3*ss*sm, y1+y2*sm+y4*ss+y3*ss*sm, zz),c,t); + register long k3 = gr->AddPnt(mglPoint(x1+x2*ss+x4*sm+x3*ss*sm, y1+y2*ss+y4*sm+y3*ss*sm, zz),c,t); + register long k4 = gr->AddPnt(mglPoint(x1+x2*sm+x4*sm+x3*sm*sm, y1+y2*sm+y4*sm+y3*sm*sm, zz),c,t); + gr->quad_plot(k1,k2,k3,k4); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tiles(HMGL gr, HCDT z, HCDT s, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(z->GetNx()+1), y(z->GetNy()+1); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_tiles_xy(gr,&x,&y,z,s,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tiles_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, uintptr_t *r, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tiles_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), _DA_(r), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_tiles_(uintptr_t *gr, uintptr_t *a, uintptr_t *r, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_tiles(_GR_, _DA_(a), _DA_(r), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Map series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_map_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + long n=ax->GetNx(),m=ax->GetNy(); + if(mgl_check_dim2(gr,x,y,ax,ay,"Map")) return; + + bool both = x->GetNx()==n && y->GetNx()==n && x->GetNy()==m && y->GetNy()==m; + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Map",cgid++); + + long ss = gr->AddTexture(mgl_have_color(sch)?sch:"rgb",2); + long s = both ? n:1; + + mglPoint t=mglPoint(NAN); + long *pos = new long[n*m]; + gr->Reserve(n*m); + +#pragma omp parallel for collapse(2) + for(long j=0;jStop) continue; + register long s1 = i>0 ? 1:0, s2 = iv(i+s2,j)-ax->v(i-s1,j))/(GetX(x,i+s2,j).x-GetX(x,i-s1,j).x); + register mreal ydx = (ay->v(i+s2,j)-ay->v(i-s1,j))/(GetX(x,i+s2,j).x-GetX(x,i-s1,j).x); + s1 = j>0 ? s:0; s2 = jv(i,j+s2)-ax->v(i,j-s1))/(GetY(y,i,j+s2).x-GetY(y,i,j-s1).x); + register mreal ydy = (ay->v(i,j+s2)-ay->v(i,j-s1))/(GetY(y,i,j+s2).x-GetY(y,i,j-s1).x); + xdx = xdx*ydy - xdy*ydx; // Jacobian + register mreal xx,yy; + + if(both) + { + xx = (x->v(i,j) - gr->Min.x)/(gr->Max.x - gr->Min.x); + yy = (y->v(i,j) - gr->Min.y)/(gr->Max.y - gr->Min.y); + } + else + { + xx = (x->v(i) - gr->Min.x)/(gr->Max.x - gr->Min.x); + yy = (y->v(j) - gr->Min.y)/(gr->Max.y - gr->Min.y); + } + if(xx<0) xx=0; if(xx>=1) xx=1/MGL_FEPSILON; + if(yy<0) yy=0; if(yy>=1) yy=1/MGL_FEPSILON; + pos[i+n*j] = gr->AddPnt(mglPoint(ax->v(i,j), ay->v(i,j), xdx),gr->GetC(ss,xx,false),t,yy); + } + if(sch && mglchr(sch,'.')) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else mgl_surf_plot(gr,pos,n,m); + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_map(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_map_xy(gr,&x,&y,ax,ay,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_map_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_map_xy(_GR_, _DA_(x), _DA_(y), _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_map_(uintptr_t *gr, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_map(_GR_, _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/tex_table.cpp b/src/tex_table.cpp new file mode 100644 index 0000000..40483f5 --- /dev/null +++ b/src/tex_table.cpp @@ -0,0 +1,1880 @@ +/*************************************************************************** + * tex_table.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/font.h" + +/// Table of LaTeX symbols and its UTF8 codes. This array MUST BE sorted!!! +MGL_EXPORT mglTeXsymb mgl_tex_symb[] = { + {0x23, L"#"}, + {0x25, L"%"}, + {0x26, L"&"}, + {0xc5, L"AA"}, + {0xc6, L"AE"}, + {0x2370, L"APLboxquestion"}, + {0x2353, L"APLboxupcaret"}, + {0x2340, L"APLnotbackslash"}, + {0x233f, L"APLnotslash"}, + {0x391, L"Alpha"}, + {0x26, L"And"}, + {0x212b, L"Angstrom"}, + {0x2ae7, L"Barv"}, + {0x2102, L"BbbC"}, + {0x213e, L"BbbGamma"}, + {0x210d, L"BbbH"}, + {0x2115, L"BbbN"}, + {0x2119, L"BbbP"}, + {0x213f, L"BbbPi"}, + {0x211a, L"BbbQ"}, + {0x211d, L"BbbR"}, + {0x2124, L"BbbZ"}, + {0x213d, L"Bbbgamma"}, + {0x213c, L"Bbbpi"}, + {0x2140, L"Bbbsum"}, + {0x392, L"Beta"}, + {0x224e, L"Bumpeq"}, + {0x22d2, L"Cap"}, + {0x3a7, L"Chi"}, + {0x2237, L"Colon"}, + {0x2a74, L"Coloneq"}, + {0x22d3, L"Cup"}, + {0x27f1, L"DDownarrow"}, + {0xd0, L"DH"}, + {0x110, L"DJ"}, + {0x2ae5, L"DashV"}, + {0x27da, L"DashVDash"}, + {0x2ae4, L"Dashv"}, + {0x290b, L"Ddownarrow"}, + {0x394, L"Delta"}, + {0x3dc, L"Digamma"}, + {0x2251, L"Doteq"}, + {0x21d3, L"Downarrow"}, + {0x395, L"Epsilon"}, + {0x2263, L"Equiv"}, + {0x397, L"Eta"}, + {0x2107, L"Eulerconst"}, + {0x203c, L"Exclam"}, + {0x2132, L"Finv"}, + {0x2141, L"Game"}, + {0x393, L"Gamma"}, + {0x2aa2, L"Gt"}, + {0x26a5, L"Hermaphrodite"}, + {0x2111, L"Im"}, + {0x399, L"Iota"}, + {0x39a, L"Kappa"}, + {0x3de, L"Koppa"}, + {0x141, L"L"}, + {0x2b45, L"LLeftarrow"}, + {0x39b, L"Lambda"}, + {0x27ec, L"Lbrbrak"}, + {0x21b2, L"Ldsh"}, + {0x21d0, L"Leftarrow"}, + {0x21d4, L"Leftrightarrow"}, + {0x21da, L"Lleftarrow"}, + {0x27f8, L"Longleftarrow"}, + {0x27fa, L"Longleftrightarrow"}, + {0x27fd, L"Longmapsfrom"}, + {0x27fe, L"Longmapsto"}, + {0x27f9, L"Longrightarrow"}, + {0x2995, L"Lparengtr"}, + {0x21b0, L"Lsh"}, + {0x2aa1, L"Lt"}, + {0x29da, L"Lvzigzag"}, + {0x2906, L"Mapsfrom"}, + {0x2907, L"Mapsto"}, + {0x39c, L"Mu"}, + {0x14a, L"NG"}, + {0x21d7, L"Nearrow"}, + {0x2aec, L"Not"}, + {0x39d, L"Nu"}, + {0x21d6, L"Nwarrow"}, + {0xd8, L"O"}, + {0x152, L"OE"}, + {0x1a0, L"Ohorn"}, + {0x3a9, L"Omega"}, + {0x39f, L"Omicron"}, + {0x2a37, L"Otimes"}, + {0xb6, L"P"}, + {0x3a6, L"Phi"}, + {0x3a0, L"Pi"}, + {0x210e, L"Planckconst"}, + {0x2abb, L"Prec"}, + {0x214a, L"PropertyLine"}, + {0x3a8, L"Psi"}, + {0x220e, L"QED"}, + {0x2047, L"Question"}, + {0x2b46, L"RRightarrow"}, + {0x27ed, L"Rbrbrak"}, + {0x21b3, L"Rdsh"}, + {0x211c, L"Re"}, + {0x3a1, L"Rho"}, + {0x21d2, L"Rightarrow"}, + {0x2996, L"Rparenless"}, + {0x21db, L"Rrightarrow"}, + {0x21b1, L"Rsh"}, + {0x29db, L"Rvzigzag"}, + {0xa7, L"S"}, + {0x2abc, L"Sc"}, + {0x21d8, L"Searrow"}, + {0x3a3, L"Sigma"}, + {0x2a4e, L"Sqcap"}, + {0x2a4f, L"Sqcup"}, + {0x3da, L"Stigma"}, + {0x22d0, L"Subset"}, + {0x22d1, L"Supset"}, + {0x21d9, L"Swarrow"}, + {0xde, L"TH"}, + {0x3a4, L"Tau"}, + {0x398, L"Theta"}, + {0x27f0, L"UUparrow"}, + {0x1af, L"Uhorn"}, + {0x21d1, L"Uparrow"}, + {0x21d5, L"Updownarrow"}, + {0x290a, L"Uuparrow"}, + {0x22ab, L"VDash"}, + {0x2aeb, L"Vbar"}, + {0x22a9, L"Vdash"}, + {0x2a54, L"Vee"}, + {0x2016, L"Vert"}, + {0x22aa, L"Vvdash"}, + {0x2980, L"Vvert"}, + {0x2a53, L"Wedge"}, + {0x2612, L"XBox"}, + {0x39e, L"Xi"}, + {0x2144, L"Yup"}, + {0x1b5, L"Zbar"}, + {0x396, L"Zeta"}, + {0x5e, L"^"}, + {0xe5, L"aa"}, + {0x223e, L"ac"}, + {0x23e6, L"accurrent"}, + {0x267e, L"acidfree"}, + {0x2940, L"acwcirclearrow"}, + {0x27f2, L"acwgapcirclearrow"}, + {0x2939, L"acwleftarcarrow"}, + {0x21ba, L"acwopencirclearrow"}, + {0x293a, L"acwoverarcarrow"}, + {0x293b, L"acwundercurvearrow"}, + {0x22f0, L"adots"}, + {0xe6, L"ae"}, + {0x2135, L"aleph"}, + {0x3b1, L"alpha"}, +// {0x2210, L"amalg"}, + {0x2a3f, L"amalg"}, + {0x299f, L"angdnr"}, + {0x2220, L"angle"}, + {0x299e, L"angles"}, + {0x29a4, L"angleubar"}, + {0x2248, L"approx"}, + {0x224a, L"approxeq"}, + {0x2a70, L"approxeqq"}, + {0x224b, L"approxident"}, + {0x2258, L"arceq"}, + {0x2648, L"aries"}, + {0x22a6, L"assert"}, + {0x2217, L"ast"}, + {0x2a6e, L"asteq"}, + {0x2609, L"astrosun"}, + {0x224d, L"asymp"}, + {0x2a11, L"awint"}, + {0x2aed, L"bNot"}, + {0x224c, L"backcong"}, + {0x2036, L"backdprime"}, + {0x3f6, L"backepsilon"}, + {0x2035, L"backprime"}, + {0x223d, L"backsim"}, + {0x22cd, L"backsimeq"}, + {0x5c, L"backslash"}, + {0x2037, L"backtrprime"}, + {0x22ff, L"bagmember"}, + {0x2aea, L"barV"}, + {0x2a43, L"barcap"}, + {0x2a42, L"barcup"}, + {0x2961, L"bardownharpoonleft"}, + {0x295d, L"bardownharpoonright"}, + {0x21e4, L"barleftarrow"}, + {0x21b9, L"barleftarrowrightarrowbar"}, + {0x2956, L"barleftharpoondown"}, + {0x2952, L"barleftharpoonup"}, + {0x21b8, L"barovernorthwestarrow"}, + {0x2920, L"barrightarrowdiamond"}, + {0x295f, L"barrightharpoondown"}, + {0x295b, L"barrightharpoonup"}, + {0x2912, L"baruparrow"}, + {0x2958, L"barupharpoonleft"}, + {0x2954, L"barupharpoonright"}, + {0x22bd, L"barvee"}, + {0x22bc, L"barwedge"}, + {0x23b6, L"bbrktbrk"}, + {0x2550, L"bdHrule"}, + {0x2551, L"bdVrule"}, + {0x256c, L"bdbVbH"}, + {0x256b, L"bdbVbh"}, + {0x2563, L"bdbVlH"}, + {0x2562, L"bdbVlh"}, + {0x2560, L"bdbVrH"}, + {0x255f, L"bdbVrh"}, + {0x256a, L"bdbvbH"}, + {0x253c, L"bdbvbh"}, + {0x2561, L"bdbvlH"}, + {0x2524, L"bdbvlh"}, + {0x255e, L"bdbvrH"}, + {0x251c, L"bdbvrh"}, + {0x2566, L"bddVbH"}, + {0x2565, L"bddVbh"}, + {0x2557, L"bddVlH"}, + {0x2556, L"bddVlh"}, + {0x2554, L"bddVrH"}, + {0x2553, L"bddVrh"}, + {0x2564, L"bddvbH"}, + {0x252c, L"bddvbh"}, + {0x2555, L"bddvlH"}, + {0x2510, L"bddvlh"}, + {0x2552, L"bddvrH"}, + {0x250c, L"bddvrh"}, + {0x2500, L"bdhrule"}, + {0x2571, L"bdnesw"}, + {0x2572, L"bdnwse"}, + {0x2508, L"bdquadhdash"}, + {0x250a, L"bdquadvdash"}, + {0x2506, L"bdtriplevdash"}, + {0x2569, L"bduVbH"}, + {0x2568, L"bduVbh"}, + {0x255d, L"bduVlH"}, + {0x255c, L"bduVlh"}, + {0x255a, L"bduVrH"}, + {0x2559, L"bduVrh"}, + {0x2567, L"bduvbH"}, + {0x2534, L"bduvbh"}, + {0x255b, L"bduvlH"}, + {0x2518, L"bduvlh"}, + {0x2558, L"bduvrH"}, + {0x2514, L"bduvrh"}, + {0x2502, L"bdvrule"}, + {0x2235, L"because"}, + {0x23e3, L"benzenr"}, + {0x3b2, L"beta"}, + {0x2136, L"beth"}, + {0x226c, L"between"}, + {0x25bc, L"bigblacktriangledown"}, + {0x25b2, L"bigblacktriangleup"}, + {0x27d8, L"bigbot"}, + {0x22c2, L"bigcap"}, + {0x22c3, L"bigcup"}, + {0x2a57, L"bigslopedvee"}, + {0x2a58, L"bigslopedwedge"}, + {0x2605, L"bigstar"}, + {0x27d9, L"bigtop"}, + {0x25bd, L"bigtriangledown"}, + {0x25b3, L"bigtriangleup"}, + {0x22c1, L"bigvee"}, + {0x22c0, L"bigwedge"}, + {0x2606, L"bigwhitestar"}, + {0x29ed, L"blackcircledownarrow"}, + {0x2688, L"blackcircledrightdot"}, + {0x2791, L"blackcircledsanseight"}, + {0x278e, L"blackcircledsansfive"}, + {0x278d, L"blackcircledsansfour"}, + {0x2792, L"blackcircledsansnine"}, + {0x278a, L"blackcircledsansone"}, + {0x2790, L"blackcircledsansseven"}, + {0x278f, L"blackcircledsanssix"}, + {0x2793, L"blackcircledsansten"}, + {0x278c, L"blackcircledsansthree"}, + {0x278b, L"blackcircledsanstwo"}, + {0x2689, L"blackcircledtwodots"}, + {0x25d5, L"blackcircleulquadwhite"}, + {0x29ea, L"blackdiamonddownarrow"}, + {0x29d7, L"blackhourglass"}, + {0x25c8, L"blackinwhitediamond"}, + {0x25a3, L"blackinwhitesquare"}, + {0x25d6, L"blacklefthalfcircle"}, + {0x25c4, L"blackpointerleft"}, + {0x25ba, L"blackpointerright"}, + {0x25d7, L"blackrighthalfcircle"}, + {0x263b, L"blacksmiley"}, + {0x25b4, L"blacktriangle"}, + {0x25be, L"blacktriangledown"}, + {0x25c0, L"blacktriangleleft"}, + {0x25b6, L"blacktriangleright"}, + {0x2b2c, L"blkhorzoval"}, + {0x2b2e, L"blkvertoval"}, + {0x2588, L"blockfull"}, + {0x2592, L"blockhalfshaded"}, + {0x258c, L"blocklefthalf"}, + {0x2584, L"blocklowhalf"}, + {0x2591, L"blockqtrshaded"}, + {0x2590, L"blockrighthalf"}, + {0x2593, L"blockthreeqtrshaded"}, + {0x2580, L"blockuphalf"}, + {0x22a5, L"bot"}, + {0x25e1, L"botsemicircle"}, + {0x22c8, L"bowtie"}, + {0x25fb, L"box"}, + {0x29c6, L"boxast"}, + {0x25eb, L"boxbar"}, + {0x29c8, L"boxbox"}, + {0x29c5, L"boxbslash"}, + {0x29c7, L"boxcircle"}, + {0x29c4, L"boxdiag"}, + {0x22a1, L"boxdot"}, + {0x229f, L"boxminus"}, + {0x29c9, L"boxonbox"}, + {0x229e, L"boxplus"}, + {0x22a0, L"boxtimes"}, + {0x2b41, L"bsimilarleftarrow"}, + {0x2b47, L"bsimilarrightarrow"}, + {0x27c8, L"bsolhsub"}, + {0x2a32, L"btimes"}, + {0x2219, L"bullet"}, + {0x25ce, L"bullseye"}, + {0x224f, L"bumpeq"}, + {0x2aae, L"bumpeqq"}, + {0x212c, L"calB"}, + {0x2130, L"calE"}, + {0x2131, L"calF"}, + {0x210b, L"calH"}, + {0x2133, L"calM"}, + {0x211b, L"calR"}, + {0x2229, L"cap"}, + {0x2a40, L"capdot"}, + {0x2a44, L"capwedge"}, + {0x2038, L"caretinsert"}, + {0x23ce, L"carreturn"}, + {0x21b5, L"carriagereturn"}, + {0x293f, L"ccwundercurvearrow"}, + {0x22c5, L"cdot"}, + {0xb7, L"cdotp"}, + {0x22ef, L"cdots"}, + {0x2ba, L"cdprime"}, + {0x2713, L"checkmark"}, + {0x3c7, L"chi"}, + {0x29c3, L"cirE"}, + {0x27df, L"cirbot"}, + {0x2218, L"circ"}, + {0x2257, L"circeq"}, + {0x2a10, L"circfint"}, + {0x25d2, L"circlebottomhalfblack"}, + {0x24b6, L"circledA"}, + {0x24b7, L"circledB"}, + {0x24b8, L"circledC"}, + {0x24b9, L"circledD"}, + {0x24ba, L"circledE"}, + {0x24bb, L"circledF"}, + {0x24bc, L"circledG"}, + {0x24bd, L"circledH"}, + {0x24be, L"circledI"}, + {0x24bf, L"circledJ"}, + {0x24c0, L"circledK"}, + {0x24c1, L"circledL"}, + {0x24c2, L"circledM"}, + {0x24c3, L"circledN"}, + {0x24c4, L"circledO"}, + {0x24c5, L"circledP"}, + {0x24c6, L"circledQ"}, + {0x24c7, L"circledR"}, + {0x24c8, L"circledS"}, + {0x24c9, L"circledT"}, + {0x24ca, L"circledU"}, + {0x24cb, L"circledV"}, + {0x24cc, L"circledW"}, + {0x24cd, L"circledX"}, + {0x24ce, L"circledY"}, + {0x24cf, L"circledZ"}, + {0x24d0, L"circleda"}, + {0x229b, L"circledast"}, + {0x24d1, L"circledb"}, + {0x29bf, L"circledbullet"}, + {0x24d2, L"circledc"}, + {0x229a, L"circledcirc"}, + {0x24d3, L"circledd"}, + {0x229d, L"circleddash"}, + {0x24d4, L"circlede"}, + {0x2467, L"circledeight"}, + {0x229c, L"circledequal"}, + {0x24d5, L"circledf"}, + {0x2464, L"circledfive"}, + {0x2463, L"circledfour"}, + {0x24d6, L"circledg"}, + {0x24d7, L"circledh"}, + {0x24d8, L"circledi"}, + {0x24d9, L"circledj"}, + {0x24da, L"circledk"}, + {0x24db, L"circledl"}, + {0x24dc, L"circledm"}, + {0x24dd, L"circledn"}, + {0x2468, L"circlednine"}, + {0x24de, L"circledo"}, + {0x2460, L"circledone"}, + {0x29ec, L"circledownarrow"}, + {0x24df, L"circledp"}, + {0x29b7, L"circledparallel"}, + {0x24e0, L"circledq"}, + {0x24e1, L"circledr"}, + {0x2686, L"circledrightdot"}, + {0x24e2, L"circleds"}, + {0x2787, L"circledsanseight"}, + {0x2784, L"circledsansfive"}, + {0x2783, L"circledsansfour"}, + {0x2788, L"circledsansnine"}, + {0x2780, L"circledsansone"}, + {0x2786, L"circledsansseven"}, + {0x2785, L"circledsanssix"}, + {0x2789, L"circledsansten"}, + {0x2782, L"circledsansthree"}, + {0x2781, L"circledsanstwo"}, + {0x2466, L"circledseven"}, + {0x2465, L"circledsix"}, + {0x272a, L"circledstar"}, + {0x24e3, L"circledt"}, + {0x2462, L"circledthree"}, + {0x2461, L"circledtwo"}, + {0x2687, L"circledtwodots"}, + {0x24e4, L"circledu"}, + {0x24e5, L"circledv"}, + {0x29b6, L"circledvert"}, + {0x24e6, L"circledw"}, + {0x29be, L"circledwhitebullet"}, + {0x24e7, L"circledx"}, + {0x24e8, L"circledy"}, + {0x24e9, L"circledz"}, + {0x24ea, L"circledzero"}, + {0x29b5, L"circlehbar"}, + {0x25d0, L"circlelefthalfblack"}, + {0x25f5, L"circlellquad"}, + {0x25f6, L"circlelrquad"}, + {0x2b30, L"circleonleftarrow"}, + {0x21f4, L"circleonrightarrow"}, + {0x25d1, L"circlerighthalfblack"}, + {0x25d3, L"circletophalfblack"}, + {0x25f4, L"circleulquad"}, + {0x25f7, L"circleurquad"}, + {0x25d4, L"circleurquadblack"}, + {0x25cd, L"circlevertfill"}, + {0x2aef, L"cirmid"}, + {0x29c2, L"cirscir"}, + {0x2329, L"clangle"}, + {0x2a4d, L"closedvarcap"}, + {0x2a4c, L"closedvarcup"}, + {0x2a50, L"closedvarcupsmashprod"}, + {0x2050, L"closure"}, + {0x2318, L"cloverleaf"}, + {0x2663, L"clubsuit"}, + {0x3a, L"colon"}, + {0x2236, L"colon"}, + {0x2254, L"coloneq"}, + {0x2a29, L"commaminus"}, + {0x2201, L"complement"}, + {0x27e1, L"concavediamond"}, + {0x27e2, L"concavediamondtickleft"}, + {0x27e3, L"concavediamondtickright"}, + {0x2245, L"cong"}, + {0x2a6d, L"congdot"}, + {0x2332, L"conictaper"}, + {0x260c, L"conjunction"}, + {0x2210, L"coprod"}, + {0x2b9, L"cprime"}, + {0x232a, L"crangle"}, + {0x2acf, L"csub"}, + {0x2ad1, L"csube"}, + {0x2ad0, L"csup"}, + {0x2ad2, L"csupe"}, + {0x221b, L"cuberoot"}, + {0x222a, L"cup"}, + {0x228d, L"cupdot"}, + {0x228c, L"cupleftarrow"}, + {0x2a45, L"cupvee"}, + {0x22de, L"curlyeqprec"}, + {0x22df, L"curlyeqsucc"}, + {0x22ce, L"curlyvee"}, + {0x22cf, L"curlywedge"}, + {0x21b6, L"curvearrowleft"}, + {0x293d, L"curvearrowleftplus"}, + {0x21b7, L"curvearrowright"}, + {0x293c, L"curvearrowrightminus"}, + {0x2941, L"cwcirclearrow"}, + {0x27f3, L"cwgapcirclearrow"}, + {0x21bb, L"cwopencirclearrow"}, + {0x2938, L"cwrightarcarrow"}, + {0x293e, L"cwundercurvearrow"}, + {0x232d, L"cylcty"}, + {0x2020, L"dag"}, + {0x2020, L"dagger"}, + {0x2138, L"daleth"}, + {0x2621, L"danger"}, + {0x2ae3, L"dashV"}, + {0x27db, L"dashVdash"}, + {0x2239, L"dashcolon"}, + {0x296b, L"dashleftharpoondown"}, + {0x296d, L"dashrightharpoondown"}, + {0x22a3, L"dashv"}, + {0x290f, L"dbkarow"}, + {0x2021, L"ddag"}, + {0x2021, L"ddagger"}, + {0x22f1, L"ddots"}, + {0x2a77, L"ddotseq"}, + {0xb0, L"degree"}, + {0x3b4, L"delta"}, + {0xf0, L"dh"}, + {0x2300, L"diameter"}, + {0x25c7, L"diamond"}, + {0x2b19, L"diamondbotblack"}, + {0x27d0, L"diamondcdot"}, + {0x291d, L"diamondleftarrow"}, + {0x291f, L"diamondleftarrowbar"}, + {0x2b16, L"diamondleftblack"}, + {0x2b17, L"diamondrightblack"}, + {0x2662, L"diamondsuit"}, + {0x2b18, L"diamondtopblack"}, + {0x2680, L"dicei"}, + {0x2681, L"diceii"}, + {0x2682, L"diceiii"}, + {0x2683, L"diceiv"}, + {0x2684, L"dicev"}, + {0x2685, L"dicevi"}, + {0x3dd, L"digamma"}, + {0x273d, L"dingasterisk"}, + {0x2393, L"dircurrent"}, + {0x22f2, L"disin"}, + {0xf7, L"div"}, + {0x22c7, L"divideontimes"}, + {0x111, L"dj"}, + {0x230d, L"dlcrop"}, + {0x2250, L"doteq"}, + {0x2a67, L"dotequiv"}, + {0x2238, L"dotminus"}, + {0x2214, L"dotplus"}, + {0x2026, L"dots"}, + {0x2a6a, L"dotsim"}, + {0x223a, L"dotsminusdots"}, + {0x25cc, L"dottedcircle"}, + {0x2b1a, L"dottedsquare"}, + {0x2a30, L"dottimes"}, + {0x2a62, L"doublebarvee"}, + {0x2a5e, L"doublebarwedge"}, + {0x29fa, L"doubleplus"}, + {0x2193, L"downarrow"}, + {0x2913, L"downarrowbar"}, + {0x2908, L"downarrowbarred"}, + {0x21e3, L"downdasharrow"}, + {0x21ca, L"downdownarrows"}, + {0x297f, L"downfishtail"}, + {0x21c3, L"downharpoonleft"}, + {0x2959, L"downharpoonleftbar"}, + {0x21c2, L"downharpoonright"}, + {0x2955, L"downharpoonrightbar"}, + {0x2965, L"downharpoonsleftright"}, + {0x2935, L"downrightcurvedarrow"}, + {0x29e8, L"downtriangleleftblack"}, + {0x29e9, L"downtrianglerightblack"}, + {0x21f5, L"downuparrows"}, + {0x296f, L"downupharpoonsleftright"}, + {0x21e9, L"downwhitearrow"}, + {0x21af, L"downzigzagarrow"}, + {0x2033, L"dprime"}, + {0x279b, L"draftingarrow"}, + {0x2910, L"drbkarow"}, + {0x230c, L"drcrop"}, + {0x29f6, L"dsol"}, + {0x2a64, L"dsub"}, + {0x29df, L"dualmap"}, + {0x2641, L"earth"}, + {0x2a98, L"egsdot"}, + {0x266a, L"eighthnote"}, + {0x23e7, L"elinters"}, + {0x2113, L"ell"}, + {0x2a97, L"elsdot"}, + {0x2014, L"emdash"}, + {0x2205, L"emptyset"}, + {0x29b3, L"emptysetoarr"}, + {0x29b4, L"emptysetoarrl"}, + {0x29b1, L"emptysetobar"}, + {0x29b2, L"emptysetocirc"}, + {0x2013, L"endash"}, + {0x2025, L"enleadertwodots"}, + {0x2709, L"envelope"}, + {0x29e3, L"eparsl"}, + {0x3f5, L"epsilon"}, + {0x2256, L"eqcirc"}, + {0x2255, L"eqcolon"}, + {0x225d, L"eqdef"}, + {0x2a66, L"eqdot"}, + {0x2a75, L"eqeq"}, + {0x2a76, L"eqeqeq"}, + {0x22dd, L"eqgtr"}, + {0x22dc, L"eqless"}, + {0x2a9a, L"eqqgtr"}, + {0x2a99, L"eqqless"}, + {0x2a71, L"eqqplus"}, + {0x2a73, L"eqqsim"}, + {0x2a9c, L"eqqslantgtr"}, + {0x2a9b, L"eqqslantless"}, + {0x2242, L"eqsim"}, + {0x2a96, L"eqslantgtr"}, + {0x2a95, L"eqslantless"}, + {0x2b40, L"equalleftarrow"}, + {0x22d5, L"equalparallel"}, + {0x2971, L"equalrightarrow"}, + {0x2261, L"equiv"}, + {0x2a78, L"equivDD"}, + {0x2a68, L"equivVert"}, + {0x2a69, L"equivVvert"}, + {0x29e5, L"eqvparsl"}, + {0x29f3, L"errbarblackcircle"}, + {0x29f1, L"errbarblackdiamond"}, + {0x29ef, L"errbarblacksquare"}, + {0x29f2, L"errbarcircle"}, + {0x29f0, L"errbardiamond"}, + {0x29ee, L"errbarsquare"}, + {0x3b7, L"eta"}, + {0x20ac, L"euro"}, + {0x2203, L"exists"}, + {0x2252, L"fallingdotseq"}, + {0x29d3, L"fbowtie"}, + {0x2a3e, L"fcmp"}, + {0x292f, L"fdiagovnearrow"}, + {0x292c, L"fdiagovrdiag"}, + {0x2640, L"female"}, + {0x2012, L"figdash"}, + {0x2a0f, L"fint"}, + {0x25c9, L"fisheye"}, + {0x266d, L"flat"}, + {0x23e5, L"fltns"}, + {0x2200, L"forall"}, + {0x2adc, L"forks"}, + {0x2add, L"forksnot"}, + {0x2ad9, L"forkv"}, + {0x221c, L"fourthroot"}, + {0x2999, L"fourvdots"}, + {0x215d, L"fracfiveeighths"}, + {0x215a, L"fracfivesixths"}, + {0x2158, L"fracfourfifths"}, + {0x215b, L"fraconeeighth"}, + {0x2155, L"fraconefifth"}, + {0x2159, L"fraconesixth"}, + {0x2153, L"fraconethird"}, + {0x215e, L"fracseveneights"}, + {0x2044, L"fracslash"}, + {0x215c, L"fracthreeeighths"}, + {0x2157, L"fracthreefifths"}, + {0x2156, L"fractwofifths"}, + {0x2154, L"fractwothirds"}, + {0x212d, L"frakC"}, + {0x210c, L"frakH"}, + {0x2128, L"frakZ"}, + {0x2322, L"frown"}, + {0x2639, L"frownie"}, + {0x27d7, L"fullouterjoin"}, + {0x3b3, L"gamma"}, + {0x2265, L"ge"}, + {0x2265, L"geq"}, + {0x2267, L"geqq"}, + {0x2a7e, L"geqslant"}, + {0x2aa9, L"gescc"}, + {0x2a80, L"gesdot"}, + {0x2a82, L"gesdoto"}, + {0x2a84, L"gesdotol"}, + {0x2a94, L"gesles"}, + {0x2190, L"gets"}, + {0x226b, L"gg"}, + {0x22d9, L"ggg"}, + {0x2af8, L"gggnest"}, + {0x2137, L"gimel"}, + {0x2a92, L"glE"}, + {0x2aa5, L"gla"}, + {0x29e6, L"gleichstark"}, + {0x2aa4, L"glj"}, + {0x2a8a, L"gnapprox"}, + {0x2a88, L"gneq"}, + {0x2269, L"gneqq"}, + {0x22e7, L"gnsim"}, + {0x3e, L"greater"}, + {0x2a8e, L"gsime"}, + {0x2a90, L"gsiml"}, + {0x2aa7, L"gtcc"}, + {0x2a7a, L"gtcir"}, + {0x29a0, L"gtlpar"}, + {0x2a7c, L"gtquest"}, + {0x2a86, L"gtrapprox"}, + {0x2978, L"gtrarr"}, + {0x22d7, L"gtrdot"}, + {0x22db, L"gtreqless"}, + {0x2a8c, L"gtreqqless"}, + {0x2277, L"gtrless"}, + {0x2273, L"gtrsim"}, + {0xab, L"guillemotleft"}, + {0xbb, L"guillemotright"}, + {0x2039, L"guilsinglleft"}, + {0x203a, L"guilsinglright"}, + {0x23af, L"harrowextender"}, + {0x2a6f, L"hatapprox"}, + {0x210f, L"hbar"}, + {0x2661, L"heartsuit"}, + {0x22b9, L"hermitmatrix"}, + {0x2394, L"hexagon"}, + {0x2b23, L"hexagonblack"}, + {0x306e, L"hiraganano"}, + {0x2924, L"hknearrow"}, + {0x2923, L"hknwarrow"}, + {0x2925, L"hksearow"}, + {0x2926, L"hkswarow"}, + {0x21a9, L"hookleftarrow"}, + {0x21aa, L"hookrightarrow"}, + {0x2015, L"horizbar"}, + {0x29d6, L"hourglass"}, + {0x2302, L"house"}, + {0x25ad, L"hrectangle"}, + {0x25ac, L"hrectangleblack"}, + {0x210f, L"hslash"}, + {0x2043, L"hyphenbullet"}, + {0x3030, L"hzigzag"}, + {0x2a0c, L"iiiint"}, + {0x222d, L"iiint"}, + {0x29dc, L"iinfin"}, + {0x222c, L"iint"}, + {0x22b7, L"imageof"}, + {0x2208, L"in"}, + {0x2105, L"incare"}, + {0x2206, L"increment"}, + {0x221e, L"infty"}, + {0x222b, L"int"}, + {0x2a0e, L"intBar"}, + {0x2a0d, L"intbar"}, + {0x2321, L"intbottom"}, + {0x2a19, L"intcap"}, + {0x2231, L"intclockwise"}, + {0x2a1a, L"intcup"}, + {0x22ba, L"intercal"}, + {0x2af4, L"interleave"}, + {0x23ae, L"intextender"}, + {0x2a17, L"intlharhk"}, + {0x2a3c, L"intprod"}, + {0x2a3d, L"intprodr"}, + {0x2320, L"inttop"}, + {0x2a18, L"intx"}, + {0x25d8, L"inversebullet"}, + {0x25d9, L"inversewhitecircle"}, + {0x2310, L"invnot"}, + {0x25db, L"invwhitelowerhalfcircle"}, + {0x25da, L"invwhiteupperhalfcircle"}, + {0x3b9, L"iota"}, + {0x2e0, L"ipasupgamma"}, + {0x2e1, L"ipasupl"}, + {0x2e4, L"ipasuprerglotstpp"}, + {0x2e2, L"ipasups"}, + {0x2e3, L"ipasupx"}, + {0x2ed, L"ipaunaspirated"}, + {0x2ec, L"ipavoicing"}, + {0x22f9, L"isinE"}, + {0x22f5, L"isindot"}, + {0x22f7, L"isinobar"}, + {0x22f4, L"isins"}, + {0x22f8, L"isinvb"}, + {0x2145, L"itBbbD"}, + {0x2146, L"itBbbd"}, + {0x2147, L"itBbbe"}, + {0x2148, L"itBbbi"}, + {0x2149, L"itBbbj"}, + {0x2643, L"jupiter"}, + {0x3ba, L"kappa"}, + {0x223b, L"kernelcontraction"}, + {0x3df, L"koppa"}, + {0x142, L"l"}, + {0x27ea, L"lAngle"}, + {0x2983, L"lBrace"}, + {0x27e6, L"lBrack"}, + {0x2985, L"lParen"}, + {0x3bb, L"lambda"}, + {0x19b, L"lambdabar"}, + {0x27e8, L"langle"}, + {0x2991, L"langledot"}, + {0x29e0, L"laplac"}, + {0x2bd, L"lasp"}, + {0x2aab, L"lat"}, + {0x2aad, L"late"}, + {0x27c5, L"lbag"}, + {0x2997, L"lblkbrbrak"}, + {0x7b, L"lbrace"}, + {0x23a9, L"lbracelend"}, + {0x23a8, L"lbracemid"}, + {0x23a7, L"lbraceuend"}, + {0x5b, L"lbrack"}, + {0x23a2, L"lbrackextender"}, + {0x23a3, L"lbracklend"}, + {0x298f, L"lbracklltick"}, + {0x298b, L"lbrackubar"}, + {0x23a1, L"lbrackuend"}, + {0x298d, L"lbrackultick"}, + {0x2772, L"lbrbrak"}, + {0x2308, L"lceil"}, + {0x29fc, L"lcurvyangle"}, + {0x21e0, L"ldasharrhead"}, + {0x2264, L"le"}, + {0x219d, L"leadsto"}, + {0x2190, L"leftarrow"}, + {0x2b4a, L"leftarrowapprox"}, + {0x2b42, L"leftarrowbackapprox"}, + {0x2b4b, L"leftarrowbsimilar"}, + {0x2977, L"leftarrowless"}, + {0x2b32, L"leftarrowonoplus"}, + {0x2946, L"leftarrowplus"}, + {0x2943, L"leftarrowshortrightarrow"}, + {0x2973, L"leftarrowsimilar"}, + {0x297a, L"leftarrowsubset"}, + {0x21a2, L"leftarrowtail"}, + {0x21fd, L"leftarrowtriangle"}, + {0x2b3e, L"leftarrowx"}, + {0x290c, L"leftbkarrow"}, + {0x2b3f, L"leftcurvedarrow"}, + {0x21e0, L"leftdasharrow"}, + {0x21e1, L"leftdasharrowhead"}, + {0x290e, L"leftdbkarrow"}, + {0x291b, L"leftdbltail"}, + {0x2b38, L"leftdotarrow"}, + {0x2936, L"leftdowncurvedarrow"}, + {0x297c, L"leftfishtail"}, + {0x21bd, L"leftharpoondown"}, + {0x295e, L"leftharpoondownbar"}, + {0x2962, L"leftharpoonsupdown"}, + {0x21bc, L"leftharpoonup"}, + {0x295a, L"leftharpoonupbar"}, + {0x296a, L"leftharpoonupdash"}, + {0x21c7, L"leftleftarrows"}, + {0x263e, L"leftmoon"}, + {0x27d5, L"leftouterjoin"}, + {0x2194, L"leftrightarrow"}, + {0x2948, L"leftrightarrowcircle"}, + {0x21c6, L"leftrightarrows"}, + {0x21ff, L"leftrightarrowtriangle"}, + {0x2950, L"leftrightharpoondowndown"}, + {0x294b, L"leftrightharpoondownup"}, + {0x21cb, L"leftrightharpoons"}, + {0x2967, L"leftrightharpoonsdown"}, + {0x2966, L"leftrightharpoonsup"}, + {0x294a, L"leftrightharpoonupdown"}, + {0x294e, L"leftrightharpoonupup"}, + {0x21ad, L"leftrightsquigarrow"}, + {0x219c, L"leftsquigarrow"}, + {0x21dc, L"leftsquigarrow"}, + {0x2919, L"lefttail"}, + {0x2b31, L"leftthreearrows"}, + {0x22cb, L"leftthreetimes"}, + {0x21e6, L"leftwhitearrow"}, + {0x2264, L"leq"}, + {0x2266, L"leqq"}, + {0x2af9, L"leqqslant"}, + {0x2afa, L"leqqslant"}, + {0x2a7d, L"leqslant"}, + {0x2aa8, L"lescc"}, + {0x2a7f, L"lesdot"}, + {0x2a81, L"lesdoto"}, + {0x2a83, L"lesdotor"}, + {0x2a93, L"lesges"}, + {0x3c, L"less"}, + {0x2a85, L"lessapprox"}, + {0x22d6, L"lessdot"}, + {0x22da, L"lesseqgtr"}, + {0x2a8b, L"lesseqqgtr"}, + {0x2276, L"lessgtr"}, + {0x2272, L"lesssim"}, + {0x29d1, L"lfbowtie"}, + {0x230a, L"lfloor"}, + {0x29d4, L"lftimes"}, + {0x2a91, L"lgE"}, + {0x2b24, L"lgblkcircle"}, + {0x2b1b, L"lgblksquare"}, + {0x25ef, L"lgwhtcircle"}, + {0x2b1c, L"lgwhtsquare"}, + {0x22b2, L"lhd"}, + {0x21b4, L"linefeed"}, + {0x226a, L"ll"}, + {0x2989, L"llangle"}, + {0x25df, L"llarc"}, + {0x25e3, L"llblacktriangle"}, + {0x231e, L"llcorner"}, + {0x22d8, L"lll"}, + {0x2af7, L"lllnest"}, + {0x2987, L"llparenthesis"}, + {0x25fa, L"lltriangle"}, + {0x23b0, L"lmoustache"}, + {0x2a89, L"lnapprox"}, + {0x2a87, L"lneq"}, + {0x2268, L"lneqq"}, + {0x22e6, L"lnsim"}, + {0x27de, L"longdashv"}, + {0x27cc, L"longdivision"}, + {0x27f5, L"longleftarrow"}, + {0x27f7, L"longleftrightarrow"}, + {0x2b33, L"longleftsquigarrow"}, + {0x27fb, L"longmapsfrom"}, + {0x27fc, L"longmapsto"}, + {0x27f6, L"longrightarrow"}, + {0x27ff, L"longrightsquigarrow"}, + {0x21ab, L"looparrowleft"}, + {0x21ac, L"looparrowright"}, + {0x2a1c, L"lowint"}, + {0x25ca, L"lozenge"}, + {0x27e0, L"lozengeminus"}, + {0x239c, L"lparenextender"}, + {0x239d, L"lparenlend"}, + {0x2993, L"lparenless"}, + {0x239b, L"lparenuend"}, + {0x2018, L"lq"}, + {0x25de, L"lrarc"}, + {0x25e2, L"lrblacktriangle"}, + {0x231f, L"lrcorner"}, + {0x25ff, L"lrtriangle"}, + {0x29e1, L"lrtriangleeq"}, + {0x2a8d, L"lsime"}, + {0x2a8f, L"lsimg"}, + {0x2acd, L"lsqhook"}, + {0x2aa6, L"ltcc"}, + {0x2a79, L"ltcir"}, + {0x22c9, L"ltimes"}, + {0x2976, L"ltlarr"}, + {0x2a7b, L"ltquest"}, + {0x29cf, L"ltrivb"}, + {0x23b8, L"lvboxline"}, + {0x29d8, L"lvzigzag"}, + {0x2642, L"male"}, + {0x2720, L"maltese"}, + {0x21a7, L"mapsdown"}, + {0x21a4, L"mapsfrom"}, + {0x21a6, L"mapsto"}, + {0x21a5, L"mapsup"}, + {0x2b25, L"mdblkdiamond"}, + {0x2b27, L"mdblklozenge"}, + {0x26ab, L"mdblkrcl"}, + {0x25fc, L"mdblksquare"}, + {0x25cf, L"mdlgblkcircle"}, + {0x25c6, L"mdlgblkdiamond"}, + {0x29eb, L"mdlgblklozenge"}, + {0x25a0, L"mdlgblksquare"}, + {0x25cb, L"mdlgwhtcircle"}, + {0x25c7, L"mdlgwhtdiamond"}, + {0x25a1, L"mdlgwhtsquare"}, + {0x2981, L"mdsmblkcircle"}, + {0x25fe, L"mdsmblksquare"}, + {0x26ac, L"mdsmwhtcircl"}, + {0x25fd, L"mdsmwhtsquare"}, + {0x26aa, L"mdwhtcircl"}, + {0x2b26, L"mdwhtdiamond"}, + {0x2b28, L"mdwhtlozenge"}, + {0x25fb, L"mdwhtsquare"}, + {0x29af, L"measangledltosw"}, + {0x29ae, L"measangledrtose"}, + {0x29ab, L"measangleldtosw"}, + {0x29a9, L"measanglelutonw"}, + {0x29aa, L"measanglerdtose"}, + {0x29a8, L"measanglerutone"}, + {0x29ad, L"measangleultonw"}, + {0x29ac, L"measangleurtone"}, + {0x225e, L"measeq"}, + {0x2221, L"measuredangle"}, + {0x299b, L"measuredangleleft"}, + {0x22be, L"measuredrightangle"}, + {0x2b51, L"medblackstar"}, + {0x205f, L"medmathspace"}, + {0x2b50, L"medwhitestar"}, + {0x263f, L"mercury"}, + {0x2127, L"mho"}, + {0x2223, L"mid"}, + {0x2a5d, L"midbarvee"}, + {0x2a5c, L"midbarwedge"}, + {0x2af0, L"midcir"}, + {0x2212, L"minus"}, + {0x2a2a, L"minusdot"}, + {0x2a2b, L"minusfdots"}, + {0x2a2c, L"minusrdots"}, + {0x2adb, L"mlcp"}, + {0x22a7, L"models"}, + {0x2213, L"mp"}, + {0x3bc, L"mu"}, + {0x22b8, L"multimap"}, + {0x27dc, L"multimapinv"}, + {0x21df, L"nHdownarrow"}, + {0x21de, L"nHuparrow"}, + {0x21cd, L"nLeftarrow"}, + {0x21ce, L"nLeftrightarrow"}, + {0x21cf, L"nRightarrow"}, + {0x22af, L"nVDash"}, + {0x22ae, L"nVdash"}, + {0x21fa, L"nVleftarrow"}, + {0x2b3a, L"nVleftarrowtail"}, + {0x21fc, L"nVleftrightarrow"}, + {0x21fb, L"nVrightarrow"}, + {0x2915, L"nVrightarrowtail"}, + {0x2b35, L"nVtwoheadleftarrow"}, + {0x2b3d, L"nVtwoheadleftarrowtail"}, + {0x2901, L"nVtwoheadrightarrow"}, + {0x2918, L"nVtwoheadrightarrowtail"}, + {0x2207, L"nabla"}, + {0x2249, L"napprox"}, + {0x226d, L"nasymp"}, + {0x266e, L"natural"}, + {0x2247, L"ncong"}, + {0x2260, L"ne"}, + {0x2197, L"nearrow"}, + {0xac, L"neg"}, + {0x2931, L"neovnwarrow"}, + {0x292e, L"neovsearrow"}, + {0x2646, L"neptune"}, + {0x2260, L"neq"}, + {0x2262, L"nequiv"}, + {0x2922, L"neswarrow"}, + {0x26b2, L"neuter"}, + {0x2204, L"nexists"}, + {0x14b, L"ng"}, + {0x2271, L"ngeq"}, + {0x226f, L"ngtr"}, + {0x2279, L"ngtrless"}, + {0x2275, L"ngtrsim"}, + {0x2af5, L"nhVvert"}, + {0x2af2, L"nhpar"}, + {0x220b, L"ni"}, + {0x22fe, L"niobar"}, + {0x22fc, L"nis"}, + {0x22fa, L"nisd"}, + {0x219a, L"nleftarrow"}, + {0x21ae, L"nleftrightarrow"}, + {0x2270, L"nleq"}, + {0x226e, L"nless"}, + {0x2278, L"nlessgtr"}, + {0x2274, L"nlesssim"}, + {0x2224, L"nmid"}, + {0x220c, L"nni"}, + {0x2011, L"nobreakhyphen"}, + {0x2209, L"notin"}, + {0x2226, L"nparallel"}, + {0x2a14, L"npolint"}, + {0x2280, L"nprec"}, + {0x22e0, L"npreccurlyeq"}, + {0x219b, L"nrightarrow"}, + {0x2241, L"nsim"}, + {0x2244, L"nsime"}, + {0x22e2, L"nsqsubseteq"}, + {0x22e3, L"nsqsupseteq"}, + {0x2284, L"nsubset"}, + {0x2288, L"nsubseteq"}, + {0x2281, L"nsucc"}, + {0x22e1, L"nsucccurlyeq"}, + {0x2285, L"nsupset"}, + {0x2289, L"nsupseteq"}, + {0x22ea, L"ntriangleleft"}, + {0x22ec, L"ntrianglelefteq"}, + {0x22eb, L"ntriangleright"}, + {0x22ed, L"ntrianglerighteq"}, + {0x3bd, L"nu"}, + {0x22ad, L"nvDash"}, + {0x2902, L"nvLeftarrow"}, + {0x2904, L"nvLeftrightarrow"}, + {0x2903, L"nvRightarrow"}, + {0x22ac, L"nvdash"}, + {0x29de, L"nvinfty"}, + {0x21f7, L"nvleftarrow"}, + {0x2b39, L"nvleftarrowtail"}, + {0x21f9, L"nvleftrightarrow"}, + {0x21f8, L"nvrightarrow"}, + {0x2914, L"nvrightarrowtail"}, + {0x2b34, L"nvtwoheadleftarrow"}, + {0x2b3c, L"nvtwoheadleftarrowtail"}, + {0x2900, L"nvtwoheadrightarrow"}, + {0x2917, L"nvtwoheadrightarrowtail"}, + {0x2196, L"nwarrow"}, + {0x2932, L"nwovnearrow"}, + {0x2921, L"nwsearrow"}, + {0xf8, L"o"}, + {0x233d, L"obar"}, + {0x29ba, L"obot"}, + {0x23e0, L"obrbrak"}, + {0x29b8, L"obslash"}, + {0x2a38, L"odiv"}, + {0x2299, L"odot"}, + {0x29bc, L"odotslashdot"}, + {0x153, L"oe"}, + {0x29c1, L"ogreaterthan"}, + {0x1a1, L"ohorn"}, + {0x2230, L"oiiint"}, + {0x222f, L"oiint"}, + {0x222e, L"oint"}, + {0x2233, L"ointctrclockwise"}, + {0x29bb, L"olcross"}, + {0x3d8, L"oldKoppa"}, + {0x3d9, L"oldkoppa"}, + {0x29c0, L"olessthan"}, + {0x3c9, L"omega"}, + {0x3bf, L"omicron"}, + {0x2296, L"ominus"}, + {0x29b9, L"operp"}, + {0x2295, L"oplus"}, + {0x2a2d, L"opluslhrim"}, + {0x2a2e, L"oplusrhrim"}, + {0x22b6, L"origof"}, + {0x2298, L"oslash"}, + {0x2297, L"otimes"}, + {0x2a36, L"otimeshat"}, + {0x2a34, L"otimeslhrim"}, + {0x2a35, L"otimesrhrim"}, + {0x23de, L"overbrace"}, + {0x23b4, L"overbracket"}, + {0x203e, L"overline"}, + {0x23dc, L"overparen"}, + {0x220b, L"owns"}, + {0x2225, L"parallel"}, + {0x25b1, L"parallelogram"}, + {0x25b0, L"parallelogramblack"}, + {0x2af3, L"parsim"}, + {0x2202, L"partial"}, + {0x2aa3, L"partialmeetcontraction"}, + {0x2b20, L"pentagon"}, + {0x2b1f, L"pentagonblack"}, + {0x27c2, L"perp"}, + {0x2ae1, L"perps"}, + {0x3d5, L"phi"}, + {0x260e, L"phone"}, + {0x3c0, L"pi"}, + {0x22d4, L"pitchfork"}, + {0x2a25, L"plusdot"}, + {0x2a72, L"pluseqq"}, + {0x2a23, L"plushat"}, + {0x2a26, L"plussim"}, + {0x2a27, L"plussubtwo"}, + {0x2a28, L"plustrif"}, + {0x2647, L"pluto"}, + {0xb1, L"pm"}, + {0x2a15, L"pointnt"}, + {0x3012, L"postalmark"}, + {0x227a, L"prec"}, + {0x2ab7, L"precapprox"}, + {0x227c, L"preccurlyeq"}, + {0x2aaf, L"preceq"}, + {0x2ab3, L"preceqq"}, + {0x2ab9, L"precnapprox"}, + {0x2ab1, L"precneq"}, + {0x2ab5, L"precneqq"}, + {0x22e8, L"precnsim"}, + {0x227e, L"precsim"}, + {0x2032, L"prime"}, + {0x220f, L"prod"}, + {0x232e, L"profalar"}, + {0x2312, L"profline"}, + {0x2313, L"profsurf"}, + {0x221d, L"propto"}, + {0x22b0, L"prurel"}, + {0x3c8, L"psi"}, + {0x27d3, L"pullback"}, + {0x27d4, L"pushout"}, + {0x2057, L"qprime"}, + {0x2669, L"quarternote"}, + {0x225f, L"questeq"}, + {0x201e, L"quotdblbase"}, + {0x201f, L"quotdblright"}, + {0x201a, L"quotsinglbase"}, + {0x201b, L"quotsinglright"}, + {0x27eb, L"rAngle"}, + {0x2984, L"rBrace"}, + {0x27e7, L"rBrack"}, + {0x2986, L"rParen"}, + {0x27e9, L"rangle"}, + {0x2992, L"rangledot"}, + {0x237c, L"rangledownzigzagarrow"}, + {0x2bc, L"rasp"}, + {0x27c6, L"rbag"}, + {0x2998, L"rblkbrbrak"}, + {0x7d, L"rbrace"}, + {0x23ad, L"rbracelend"}, + {0x23ac, L"rbracemid"}, + {0x23ab, L"rbraceuend"}, + {0x5d, L"rbrack"}, + {0x23a5, L"rbrackextender"}, + {0x23a6, L"rbracklend"}, + {0x298e, L"rbracklrtick"}, + {0x298c, L"rbrackubar"}, + {0x23a4, L"rbrackuend"}, + {0x2990, L"rbrackurtick"}, + {0x2773, L"rbrbrak"}, + {0x2309, L"rceil"}, + {0x29fd, L"rcurvyangle"}, + {0x292b, L"rdiagovfdiag"}, + {0x2930, L"rdiagovsearrow"}, + {0x2315, L"recorder"}, + {0x29a3, L"revangle"}, + {0x29a5, L"revangleubar"}, + {0x29b0, L"revemptyset"}, + {0x2aee, L"revnmid"}, + {0x29d2, L"rfbowtie"}, + {0x230b, L"rfloor"}, + {0x29d5, L"rftimes"}, + {0x22b3, L"rhd"}, + {0x3c1, L"rho"}, + {0x2b4c, L"righarrowbsimilar"}, + {0x221f, L"rightangle"}, + {0x299d, L"rightanglemdot"}, + {0x299c, L"rightanglesqr"}, + {0x2192, L"rightarrow"}, + {0x2975, L"rightarrowapprox"}, + {0x2b48, L"rightarrowbackapprox"}, + {0x21e5, L"rightarrowbar"}, + {0x291e, L"rightarrowdiamond"}, + {0x2b43, L"rightarrowgtr"}, + {0x27f4, L"rightarrowonoplus"}, + {0x2945, L"rightarrowplus"}, + {0x2942, L"rightarrowshortleftarrow"}, + {0x2974, L"rightarrowsimilar"}, + {0x2b44, L"rightarrowsupset"}, + {0x21a3, L"rightarrowtail"}, + {0x21fe, L"rightarrowtriangle"}, + {0x2947, L"rightarrowx"}, + {0x290d, L"rightbkarrow"}, + {0x2933, L"rightcurvedarrow"}, + {0x21e2, L"rightdasharrow"}, + {0x291c, L"rightdbltail"}, + {0x2911, L"rightdotarrow"}, + {0x2937, L"rightdowncurvedarrow"}, + {0x297d, L"rightfishtail"}, + {0x21c1, L"rightharpoondown"}, + {0x2957, L"rightharpoondownbar"}, + {0x2964, L"rightharpoonsupdown"}, + {0x21c0, L"rightharpoonup"}, + {0x2953, L"rightharpoonupbar"}, + {0x296c, L"rightharpoonupdash"}, + {0x2970, L"rightimply"}, + {0x21c4, L"rightleftarrows"}, + {0x21cc, L"rightleftharpoons"}, + {0x2969, L"rightleftharpoonsdown"}, + {0x2968, L"rightleftharpoonsup"}, + {0x263d, L"rightmoon"}, + {0x27d6, L"rightouterjoin"}, + {0x2b54, L"rightpentagon"}, + {0x2b53, L"rightpentagonblack"}, + {0x21c9, L"rightrightarrows"}, + {0x219d, L"rightsquigarrow"}, + {0x21dd, L"rightsquigarrow"}, + {0x291a, L"righttail"}, + {0x21f6, L"rightthreearrows"}, + {0x22cc, L"rightthreetimes"}, + {0x21e8, L"rightwhitearrow"}, + {0x2a22, L"ringplus"}, + {0x2253, L"risingdotseq"}, + {0x23b1, L"rmoustache"}, + {0x239f, L"rparenextender"}, + {0x2994, L"rparengtr"}, + {0x23a0, L"rparenlend"}, + {0x239e, L"rparenuend"}, + {0x2a12, L"rppolint"}, + {0x2019, L"rq"}, + {0x298a, L"rrangle"}, + {0x2988, L"rrparenthesis"}, + {0x29f7, L"rsolbar"}, + {0x2ace, L"rsqhook"}, + {0x2a65, L"rsub"}, + {0x22ca, L"rtimes"}, + {0x29ce, L"rtriltri"}, + {0x29f4, L"ruledelayed"}, + {0x23b9, L"rvboxline"}, + {0x29d9, L"rvzigzag"}, + {0x3e1, L"sampi"}, + {0x2143, L"sansLmirrored"}, + {0x2142, L"sansLturned"}, + {0x2644, L"saturn"}, + {0x2702, L"scissors"}, + {0x2a13, L"scpolint"}, + {0x212c, L"scrB"}, + {0x2130, L"scrE"}, + {0x2131, L"scrF"}, + {0x210b, L"scrH"}, + {0x2110, L"scrI"}, + {0x2112, L"scrL"}, + {0x2133, L"scrM"}, + {0x211b, L"scrR"}, + {0x212f, L"scre"}, + {0x210a, L"scrg"}, + {0x2134, L"scro"}, + {0x22b1, L"scurel"}, + {0x2198, L"searrow"}, + {0x292d, L"seovnearrow"}, + {0x2216, L"setminus"}, + {0x29f5, L"setminus"}, + {0x266f, L"sharp"}, + {0x2adf, L"shortdowntack"}, + {0x2190, L"shortleftarrow"}, + {0x2ade, L"shortlefttack"}, + {0x2192, L"shortrightarrow"}, + {0x2944, L"shortrightarrowleftarrow"}, + {0x2ae0, L"shortuptack"}, + {0x29e2, L"shuffle"}, + {0x3c3, L"sigma"}, + {0x3c5, L"silon"}, + {0x3d2, L"silon"}, + {0x223c, L"sim"}, + {0x2243, L"simeq"}, + {0x2aa0, L"simgE"}, + {0x2a9e, L"simgtr"}, + {0x2b49, L"similarleftarrow"}, + {0x2972, L"similarrightarrow"}, + {0x2a9f, L"simlE"}, + {0x2a9d, L"simless"}, + {0x2a6c, L"simminussim"}, + {0x2246, L"simneqq"}, + {0x2a24, L"simplus"}, + {0x2a6b, L"simrdots"}, + {0x223f, L"sinewave"}, + {0x2215, L"slash"}, + {0x25c2, L"smallblacktriangleleft"}, + {0x25b8, L"smallblacktriangleright"}, + {0x22c4, L"smalldiamond"}, + {0x220a, L"smallin"}, + {0x222b, L"smallint"}, + {0x220d, L"smallni"}, + {0x2216, L"smallsetminus"}, + {0x25c3, L"smalltriangleleft"}, + {0x25b9, L"smalltriangleright"}, + {0x2a33, L"smashtimes"}, + {0x2b29, L"smblkdiamond"}, + {0x2b2a, L"smblklozenge"}, + {0x25aa, L"smblksquare"}, + {0x29e4, L"smeparsl"}, + {0x2323, L"smile"}, + {0x263a, L"smiley"}, + {0x2aaa, L"smt"}, + {0x2aac, L"smte"}, + {0x2b52, L"smwhitestar"}, + {0x25e6, L"smwhtcircle"}, + {0x2b2b, L"smwhtlozenge"}, + {0x25ab, L"smwhtsquare"}, + {0x2660, L"spadesuit"}, + {0x2222, L"sphericalangle"}, + {0x29a1, L"sphericalangleup"}, + {0x2293, L"sqcap"}, + {0x2294, L"sqcup"}, + {0x2a16, L"sqint"}, + {0x2311, L"sqlozenge"}, + {0x800221a, L"sqrt"}, + {0x800221b, L"sqrt3"}, + {0x800221c, L"sqrt4"}, + {0x23b7, L"sqrtbottom"}, + {0x228f, L"sqsubset"}, + {0x2291, L"sqsubseteq"}, + {0x22e4, L"sqsubsetneq"}, + {0x2290, L"sqsupset"}, + {0x2292, L"sqsupseteq"}, + {0x22e5, L"sqsupsetneq"}, + {0x25a9, L"squarecrossfill"}, + {0x25a9, L"squaregrayfill"}, + {0x25a4, L"squarehfill"}, + {0x25a6, L"squarehvfill"}, + {0x25e7, L"squareleftblack"}, + {0x25e8, L"squareleftblack"}, + {0x2b15, L"squarellblack"}, + {0x25f1, L"squarellquad"}, + {0x25ea, L"squarelrblack"}, + {0x25f2, L"squarelrquad"}, + {0x25a8, L"squareneswfill"}, + {0x25a7, L"squarenwsefill"}, + {0x25e9, L"squareulblack"}, + {0x25f0, L"squareulquad"}, + {0x2b14, L"squareurblack"}, + {0x25f3, L"squareurquad"}, + {0x25a5, L"squarevfill"}, + {0x25a2, L"squoval"}, + {0xdf, L"ss"}, + {0x22c6, L"star"}, + {0x225b, L"stareq"}, + {0xa3, L"sterling"}, + {0x3db, L"stigma"}, + {0x23e4, L"strns"}, + {0x2ac3, L"subedot"}, + {0x2ac1, L"submult"}, + {0x2979, L"subrarr"}, + {0x2282, L"subset"}, + {0x2ac9, L"subsetapprox"}, + {0x27c3, L"subsetcirc"}, + {0x2abd, L"subsetdot"}, + {0x2286, L"subseteq"}, + {0x2ac5, L"subseteqq"}, + {0x228a, L"subsetneq"}, + {0x2acb, L"subsetneqq"}, + {0x2abf, L"subsetplus"}, + {0x2ac7, L"subsim"}, + {0x2ad5, L"subsub"}, + {0x2ad3, L"subsup"}, + {0x227b, L"succ"}, + {0x2ab8, L"succapprox"}, + {0x227d, L"succcurlyeq"}, + {0x2ab0, L"succeq"}, + {0x2ab4, L"succeqq"}, + {0x2aba, L"succnapprox"}, + {0x2ab2, L"succneq"}, + {0x2ab6, L"succneqq"}, + {0x22e9, L"succnsim"}, + {0x227f, L"succsim"}, + {0x2211, L"sum"}, + {0x23b3, L"sumbottom"}, + {0x2a0b, L"sumint"}, + {0x23b2, L"sumtop"}, + {0x263c, L"sun"}, + {0x2ad8, L"supdsub"}, + {0x2ac4, L"supedot"}, + {0x27c9, L"suphsol"}, + {0x2ad7, L"suphsub"}, + {0x297b, L"suplarr"}, + {0x2ac2, L"supmult"}, + {0x207f, L"supn"}, + {0x2283, L"supset"}, + {0x2aca, L"supsetapprox"}, + {0x27c4, L"supsetcirc"}, + {0x2abe, L"supsetdot"}, + {0x2287, L"supseteq"}, + {0x2ac6, L"supseteqq"}, + {0x228b, L"supsetneq"}, + {0x2acc, L"supsetneqq"}, + {0x2ac0, L"supsetplus"}, + {0x2ac8, L"supsim"}, + {0x2ad4, L"supsub"}, + {0x2ad6, L"supsup"}, + {0x221a, L"surd"}, + {0x2199, L"swarrow"}, + {0x2afe, L"talloblong"}, + {0x2316, L"target"}, + {0x3c4, L"tau"}, + {0x2649, L"taurus"}, + {0x1d8d, L"testhookx"}, + {0x2051, L"textAsterisks"}, + {0x2ca, L"textacute"}, + {0x2d6, L"textadvanced"}, + {0x2bf, L"textain"}, + {0xb4, L"textasciiacute"}, + {0x5e, L"textasciicircum"}, + {0xa8, L"textasciidieresis"}, + {0x60, L"textasciigrave"}, + {0xaf, L"textasciimacron"}, + {0x7e, L"textasciitilde"}, + {0x204e, L"textasterisklow"}, + {0x2036, L"textbackdprime"}, + {0x2035, L"textbackprime"}, + {0x2037, L"textbacktrprime"}, + {0x25f, L"textbardotlessj"}, + {0x284, L"textbardotlessjvar"}, + {0x2a1, L"textbarglotstop"}, + {0x268, L"textbari"}, + {0x19a, L"textbarl"}, + {0x275, L"textbaro"}, + {0x2a2, L"textbarrevglotstop"}, + {0x289, L"textbaru"}, + {0x26c, L"textbeltl"}, + {0x1ba, L"textbenttailyogh"}, + {0x2d8, L"textbreve"}, + {0xa6, L"textbrokenbar"}, + {0x2022, L"textbullet"}, + {0x298, L"textbullseye"}, + {0xa2, L"textcent"}, + {0x2117, L"textcircledP"}, + {0x29a, L"textcloseepsilon"}, + {0x277, L"textcloseomega"}, + {0x25e, L"textcloserevepsilon"}, + {0xa9, L"textcopyright"}, + {0x180, L"textcrb"}, + {0x127, L"textcrh"}, + {0x1be, L"textcrinvglotstop"}, + {0x19b, L"textcrlambda"}, + {0x1bb, L"textcrtwo"}, + {0x255, L"textctc"}, + {0x221, L"textctd"}, + {0x286, L"textctesh"}, + {0x29d, L"textctj"}, + {0x234, L"textctl"}, + {0x235, L"textctn"}, + {0x236, L"textctt"}, + {0x293, L"textctyogh"}, + {0x291, L"textctz"}, + {0xa4, L"textcurrency"}, + {0x2a5, L"textdctzlig"}, + {0xb0, L"textdegree"}, + {0x2052, L"textdiscount"}, + {0x24, L"textdollar"}, + {0x2d9, L"textdotaccent"}, + {0x237, L"textdotlessj"}, + {0x2dd, L"textdoubleacute"}, + {0x1c2, L"textdoublebarpipe"}, + {0x1c1, L"textdoublepipe"}, + {0x2033, L"textdprime"}, + {0x2c5, L"textdptr"}, + {0x2a4, L"textdyoghlig"}, + {0x2a3, L"textdzlig"}, + {0x25b, L"textepsilon"}, + {0x283, L"textesh"}, + {0x212e, L"textestimated"}, + {0x1c3, L"textexclam"}, + {0xa1, L"textexclamdown"}, + {0x27e, L"textfishhookr"}, + {0x192, L"textflorin"}, + {0x20a3, L"textfranc"}, + {0x263, L"textgamma"}, + {0x294, L"textglotstop"}, + {0x2cb, L"textgrave"}, + {0x2d1, L"texthalflength"}, + {0x2be, L"texthamza"}, + {0xa727, L"texthen"}, + {0xa727, L"textheng"}, + {0x1d8a, L"texthooks"}, + {0x1d8e, L"texthookz"}, + {0x253, L"texthtb"}, + {0x188, L"texthtc"}, + {0x257, L"texthtd"}, + {0x260, L"texthtg"}, + {0x266, L"texthth"}, + {0x267, L"texththeng"}, + {0x199, L"texthtk"}, + {0x1a5, L"texthtp"}, + {0x2a0, L"texthtq"}, + {0x29b, L"texthtscg"}, + {0x1ad, L"texthtt"}, + {0x195, L"texthvlig"}, + {0x2010, L"texthyphen"}, + {0x296, L"textinvglotstop"}, + {0x281, L"textinvscr"}, + {0x269, L"textiota"}, + {0x2d0, L"textlengthmark"}, + {0x2d3, L"textlhalfring"}, + {0x1d81, L"textlhookd"}, + {0x1d84, L"textlhookk"}, + {0x1d85, L"textlhookl"}, + {0x1ab, L"textlhookt"}, + {0x27f, L"textlhti"}, + {0x20a4, L"textlira"}, + {0x27c, L"textlonglegr"}, + {0x2ae, L"textlongy"}, + {0x2af, L"textlongy"}, + {0x1aa, L"textlooptoprevesh"}, + {0x2cf, L"textlowacute"}, + {0x2d5, L"textlowered"}, + {0x2ce, L"textlowgrave"}, + {0x2cd, L"textlowmacron"}, + {0x2c2, L"textlptr"}, + {0x271, L"textltailm"}, + {0x272, L"textltailn"}, + {0x26b, L"textltilde"}, + {0x26e, L"textlyoghlig"}, + {0x2c9, L"textmacron"}, + {0xb5, L"textmu"}, + {0x2116, L"textnumero"}, + {0x2db, L"textogonek"}, + {0x2126, L"textohm"}, + {0xbd, L"textonehalf"}, + {0xbc, L"textonequarter"}, + {0xb9, L"textonesuperior"}, + {0x254, L"textopeno"}, + {0xaa, L"textordfeminine"}, + {0xba, L"textordmasculine"}, + {0x2df, L"textovercross"}, + {0x2125, L"textoz"}, + {0x2031, L"textpertenthousand"}, + {0x2030, L"textperthousand"}, + {0x20a7, L"textpesetas"}, + {0x278, L"textphi"}, + {0x1c0, L"textpipe"}, + {0x2032, L"textprime"}, + {0x2c8, L"textprimstress"}, + {0x2057, L"textqprime"}, + {0xbf, L"textquestiondown"}, + {0x22, L"textquotedbl"}, + {0x201c, L"textquotedblleft"}, + {0x201d, L"textquotedblright"}, + {0x2d4, L"textraised"}, + {0x2c0, L"textraiseglotstop"}, + {0x2c1, L"textraiserevglotstop"}, + {0x264, L"textramshorns"}, + {0x211e, L"textrecipe"}, + {0x203b, L"textreferencemark"}, + {0xae, L"textregistered"}, + {0x2d7, L"textretracted"}, + {0x258, L"textreve"}, + {0x25c, L"textrevepsilon"}, + {0x295, L"textrevglotstop"}, + {0x2d2, L"textrhalfring"}, + {0x25d, L"textrhookrevepsilon"}, + {0x25a, L"textrhookschwa"}, + {0x2de, L"textrhoticity"}, + {0x2da, L"textringaccent"}, + {0x2c3, L"textrptr"}, + {0x256, L"textrtaild"}, + {0x26d, L"textrtaill"}, + {0x273, L"textrtailn"}, + {0x27d, L"textrtailr"}, + {0x282, L"textrtails"}, + {0x288, L"textrtailt"}, + {0x290, L"textrtailz"}, + {0x1d00, L"textsca"}, + {0x299, L"textscb"}, + {0x1d07, L"textsce"}, + {0x262, L"textscg"}, + {0x29c, L"textsch"}, + {0x259, L"textschwa"}, + {0x26a, L"textsci"}, + {0x29f, L"textscl"}, + {0x274, L"textscn"}, + {0x276, L"textscoelig"}, + {0x280, L"textscr"}, + {0x251, L"textscripta"}, + {0x261, L"textscriptg"}, + {0x28b, L"textscriptv"}, + {0x1d1c, L"textscu"}, + {0x28f, L"textscy"}, + {0x2cc, L"textsecstress"}, + {0x204f, L"textsemicolonreversed"}, + {0x3a5, L"textsilon"}, + {0x2dc, L"textsmalltilde"}, + {0x297, L"textstretchcvar"}, + {0x77, L"textsubw"}, + {0x2b0, L"textsuph"}, + {0x2b1, L"textsuphth"}, + {0x2b6, L"textsupinvscr"}, + {0x2b2, L"textsupj"}, + {0x2b3, L"textsupr"}, + {0x2b4, L"textsupturnr"}, + {0x2b5, L"textsupturnrrtail"}, + {0x2b7, L"textsupw"}, + {0x2b8, L"textsupy"}, + {0x2a7, L"texttctctlig"}, + {0x2a8, L"texttctctlig"}, + {0xbe, L"textthreequarters"}, + {0xb3, L"textthreesuperior"}, + {0x2122, L"texttrademark"}, + {0x2034, L"texttrprime"}, + {0x2a6, L"texttslig"}, + {0x250, L"textturna"}, + {0x2bb, L"textturncomma"}, + {0x265, L"textturnh"}, + {0x29e, L"textturnk"}, + {0x27a, L"textturnlonglegr"}, + {0x26f, L"textturnm"}, + {0x270, L"textturnmrleg"}, + {0x279, L"textturnr"}, + {0x27b, L"textturnrrtail"}, + {0x252, L"textturnscripta"}, + {0x287, L"textturnt"}, + {0x28c, L"textturnv"}, + {0x28d, L"textturnw"}, + {0x28e, L"textturny"}, + {0xb2, L"texttwosuperior"}, + {0x28a, L"textupsilon"}, + {0x2c4, L"textuptr"}, + {0x285, L"textvibyi"}, + {0x2423, L"textvisiblespace"}, + {0x292, L"textyogh"}, + {0xfe, L"th"}, + {0x2234, L"therefore"}, + {0x29e7, L"thermod"}, + {0x3b8, L"theta"}, + {0x2248, L"thickapprox"}, + {0x223c, L"thicksim"}, + {0x27c0, L"threedangle"}, + {0x2af6, L"threedotcolon"}, + {0x2040, L"tieconcat"}, + {0x29dd, L"tieinfty"}, + {0xd7, L"times"}, + {0x2a31, L"timesbar"}, + {0x29ff, L"tminus"}, + {0x2192, L"to"}, + {0x2928, L"toea"}, + {0x2927, L"tona"}, + {0x2e5, L"tonebarextrahigh"}, + {0x2e9, L"tonebarextralow"}, + {0x2e6, L"tonebarhigh"}, + {0x2e8, L"tonebarlow"}, + {0x2e7, L"tonebarmid"}, + {0x22a4, L"top"}, + {0x2336, L"topbot"}, + {0x2af1, L"topcir"}, + {0x2ada, L"topfork"}, + {0x25e0, L"topsemicircle"}, + {0x2929, L"tosa"}, + {0x292a, L"towa"}, + {0x29fe, L"tplus"}, + {0x23e2, L"trapezium"}, + {0x25ec, L"trianglecdot"}, + {0x25bf, L"triangledown"}, + {0x26a0, L"triangleexclam"}, + {0x25c1, L"triangleleft"}, + {0x25ed, L"triangleleftblack"}, + {0x22b4, L"trianglelefteq"}, + {0x2a3a, L"triangleminus"}, + {0x29ca, L"triangleodot"}, + {0x2a39, L"triangleplus"}, + {0x225c, L"triangleq"}, + {0x25b7, L"triangleright"}, + {0x25ee, L"trianglerightblack"}, + {0x22b5, L"trianglerighteq"}, + {0x29cc, L"triangles"}, + {0x29cd, L"triangleserifs"}, + {0x2a3b, L"triangletimes"}, + {0x29cb, L"triangleubar"}, + {0x29fb, L"tripleplus"}, + {0x2034, L"trprime"}, + {0x29a2, L"turnangle"}, + {0x2129, L"turnediota"}, + {0x2319, L"turnednot"}, + {0x2a4b, L"twocaps"}, + {0x2a4a, L"twocups"}, + {0x21a1, L"twoheaddownarrow"}, + {0x219e, L"twoheadleftarrow"}, + {0x2b3b, L"twoheadleftarrowtail"}, + {0x2b37, L"twoheadleftdbkarrow"}, + {0x2b36, L"twoheadmapsfrom"}, + {0x2905, L"twoheadmapsto"}, + {0x21a0, L"twoheadrightarrow"}, + {0x2916, L"twoheadrightarrowtail"}, + {0x219f, L"twoheaduparrow"}, + {0x2949, L"twoheaduparrowcircle"}, + {0x2017, L"twolowline"}, + {0x266b, L"twonotes"}, + {0x2982, L"typecolon"}, + {0x23e1, L"ubrbrak"}, + {0x1b0, L"uhorn"}, + {0x25dc, L"ularc"}, + {0x25e4, L"ulblacktriangle"}, + {0x231c, L"ulcorner"}, + {0x230f, L"ulcrop"}, + {0x25f8, L"ultriangle"}, + {0x2a41, L"uminus"}, + {0x23df, L"underbrace"}, + {0x23b5, L"underbracket"}, + {0x23dd, L"underparen"}, + {0x22b4, L"unlhd"}, + {0x22b5, L"unrhd"}, + {0x214b, L"upand"}, + {0x2191, L"uparrow"}, + {0x2909, L"uparrowbarred"}, + {0x29bd, L"uparrowoncircle"}, + {0x21e2, L"updasharrow"}, + {0x2195, L"updownarrow"}, + {0x21a8, L"updownarrowbar"}, + {0x21c5, L"updownarrows"}, + {0x2951, L"updownharpoonleftleft"}, + {0x294d, L"updownharpoonleftright"}, + {0x294c, L"updownharpoonrightleft"}, + {0x294f, L"updownharpoonrightright"}, + {0x296e, L"updownharpoonsleftright"}, + {0x297e, L"upfishtail"}, + {0x21bf, L"upharpoonleft"}, + {0x2960, L"upharpoonleftbar"}, + {0x21be, L"upharpoonright"}, + {0x295c, L"upharpoonrightbar"}, + {0x2963, L"upharpoonsleftright"}, + {0x27d2, L"upin"}, + {0x2a1b, L"upint"}, + {0x228e, L"uplus"}, + {0x2934, L"uprightcurvearrow"}, + {0x21c8, L"upuparrows"}, + {0x21e7, L"upwhitearrow"}, + {0x25dd, L"urarc"}, + {0x25e5, L"urblacktriangle"}, + {0x231d, L"urcorner"}, + {0x230e, L"urcrop"}, + {0x25f9, L"urtriangle"}, + {0x2c7, L"v"}, + {0x2ae8, L"vBar"}, + {0x2ae9, L"vBarv"}, + {0x22a8, L"vDash"}, + {0x2ae2, L"vDdash"}, + {0x3f4, L"varTheta"}, + {0x2ae6, L"varVdash"}, + {0x2305, L"varbarwedge"}, + {0x3d0, L"varbeta"}, + {0x2667, L"varclubsuit"}, + {0x2666, L"vardiamondsuit"}, + {0x2306, L"vardoublebarwedge"}, + {0x3b5, L"varepsilon"}, + {0x2665, L"varheartsuit"}, + {0x2b21, L"varhexagon"}, + {0x2b22, L"varhexagonblack"}, + {0x232c, L"varhexagonlrbonds"}, + {0x2208, L"varin"}, + {0x22f6, L"varisinobar"}, + {0x22f3, L"varisins"}, + {0x3f0, L"varkappa"}, + {0x22bf, L"varlrtriangle"}, + {0x220b, L"varni"}, + {0x22fd, L"varniobar"}, + {0x22fb, L"varnis"}, + {0x2205, L"varnothing"}, + {0x2232, L"varointclockwise"}, + {0x3c6, L"varphi"}, + {0x3d6, L"varpi"}, + {0x221d, L"varpropto"}, + {0x3f1, L"varrho"}, + {0x23d0, L"varrowextender"}, + {0x3c2, L"varsigma"}, + {0x2664, L"varspadesuit"}, + {0x2736, L"varstar"}, + {0x3d1, L"vartheta"}, + {0x25b5, L"vartriangle"}, + {0x22b2, L"vartriangleleft"}, + {0x22b3, L"vartriangleright"}, + {0x2a61, L"varveebar"}, + {0x23aa, L"vbraceextender"}, + {0x29d0, L"vbrtri"}, + {0x22a2, L"vdash"}, + {0x22ee, L"vdots"}, + {0x2a2f, L"vectimes"}, + {0x2228, L"vee"}, + {0x22bb, L"veebar"}, + {0x27c7, L"veedot"}, + {0x2a63, L"veedoublebar"}, + {0x225a, L"veeeq"}, + {0x2a5b, L"veemidvert"}, + {0x2a52, L"veeodot"}, + {0x2a56, L"veeonvee"}, + {0x2a59, L"veeonwedge"}, + {0x7c, L"vert"}, + {0x2317, L"viewdata"}, + {0x27dd, L"vlongdash"}, + {0x25af, L"vrectangle"}, + {0x25ae, L"vrectangleblack"}, + {0x2b1d, L"vysmlblksquare"}, + {0x2b1e, L"vysmlwhtsquare"}, + {0x299a, L"vzigzag"}, + {0x231a, L"watchicon"}, + {0x2227, L"wedge"}, + {0x2a5f, L"wedgebar"}, + {0x27d1, L"wedgedot"}, + {0x2a60, L"wedgedoublebar"}, + {0x2a5a, L"wedgemidvert"}, + {0x2a51, L"wedgeodot"}, + {0x2a55, L"wedgeonwedge"}, + {0x2259, L"wedgeq"}, + {0x21ea, L"whitearrowupfrombar"}, + {0x27c1, L"whiteinwhitetriangle"}, + {0x25c5, L"whitepointerleft"}, + {0x25bb, L"whitepointerright"}, + {0x27e4, L"whitesquaretickleft"}, + {0x27e5, L"whitesquaretickright"}, + {0x2b2d, L"whthorzoval"}, + {0x2b2f, L"whtvertoval"}, + {0x29a6, L"wideangledown"}, + {0x29a7, L"wideangleup"}, + {0x2118, L"wp"}, + {0x2240, L"wr"}, + {0x29f9, L"xbsol"}, + {0x3be, L"xi"}, + {0x29f8, L"xsol"}, + {0xa5, L"yen"}, + {0x3b6, L"zeta"}, + {0x2a20, L"zpipe"}, +{0, L""}}; +//----------------------------------------------------------------------------- diff --git a/src/vect.cpp b/src/vect.cpp new file mode 100644 index 0000000..5b46c57 --- /dev/null +++ b/src/vect.cpp @@ -0,0 +1,1378 @@ +/*************************************************************************** + * vect.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/vect.h" +#include "mgl2/eval.h" +#include "mgl2/data.h" +#include "mgl2/base.h" +//----------------------------------------------------------------------------- +// +// Traj series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_traj_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + long m,mx,my,mz,nx,ny,nz,n=ax->GetNx(),pal; + if(mgl_check_dim1(gr,x,z,y,ax,"Traj")) return; + if(mgl_check_dim1(gr,ax,az,ay,0,"Traj")) return; + + mreal len=gr->SaveState(opt); if(mgl_isnan(len)) len = 0; + static int cgid=1; gr->StartGroup("Traj",cgid++); + + register long i, j; + // find maximum + i = ax->GetNy()>ay->GetNy() ? ax->GetNy():ay->GetNy(); j = z->GetNy()>az->GetNy() ? z->GetNy():az->GetNy(); + m = x->GetNy()>y->GetNy() ? x->GetNy():y->GetNy(); if(i>m) m=i; if(j>m) m=j; + gr->SetPenPal(sch,&pal); gr->Reserve(4*n*m); + + mglPoint p1,p2; +/* for(j=0;jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; + da = sqrt(ax->v(i,mx)*ax->v(i,mx)+ay->v(i,my)*ay->v(i,my)+az->v(i,mz)*az->v(i,mz)); + xm = xm>da ? xm : da; + } + xm = 1./(xm ? sqrt(xm):1);*/ + for(j=0;jNextColor(pal); + nx = jGetNy() ? j:0; ny = jGetNy() ? j:0; nz = jGetNy() ? j:0; + mx = jGetNy() ? j:0; my = jGetNy() ? j:0; mz = jGetNy() ? j:0; +#pragma omp parallel for private(p1,p2) + for(long i=0;iStop) continue; + p1 = mglPoint(x->v(i,nx), y->v(i,ny), z->v(i,nz)); + p2 = mglPoint(ax->v(i,mx),ay->v(i,my),az->v(i,mz)); + mreal dd = p2.norm(); + if(len==0) + { + register mreal dx,dy,dz; + if(iv(i+1,nx)-p1.x; dy=y->v(i+1,ny)-p1.y; dz=z->v(i+1,nz)-p1.z; } + else + { dx=p1.x-x->v(i-1,nx); dy=p1.y-y->v(i-1,ny); dz=p1.z-z->v(i-1,nz); } + dd = dd ? sqrt(dx*dx+dy*dy+dz*dz)/dd : 0; + } + else dd = len; + gr->vect_plot(gr->AddPnt(p1), gr->AddPnt(p1+dd*p2,-1,mglPoint(NAN),-1,2)); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_traj_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData z(x->GetNx()), az(x->GetNx()); z.Fill(gr->Min.z,gr->Min.z); + mgl_traj_xyz(gr,x,y,&z,ax,ay,&az,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_traj_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_traj_xy(_GR_, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_traj_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_traj_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Vect series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + long n=ax->GetNx(),m=ax->GetNy(),l=ax->GetNz(); + if(mgl_check_dim2(gr,x,y,ax,ay,"Vect")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Vect",cgid++); + bool dot = sch && mglchr(sch,'.'); + bool fix = mglchr(sch,'f'); + bool end = mglchr(sch,'>'); + bool beg = mglchr(sch,'<'); + bool grd = mglchr(sch,'='); + + long ss = gr->AddTexture(sch); + gr->Reserve(4*n*m); + mreal zVal = gr->Min.z; + + long tx=1,ty=1; + if(gr->MeshNum>1) { tx=(n-1)/(gr->MeshNum-1); ty=(m-1)/(gr->MeshNum-1); } + if(tx<1) tx=1; if(ty<1) ty=1; + + mreal xm=0,cm=0,ca=0; + mreal dm=(fabs(gr->Max.c)+fabs(gr->Min.c))*1e-5; + // use whole array for determining maximal vectors length + mglPoint p1,p2,v,d; + +#pragma omp parallel private(p1,p2,v,d) + { + mreal xm1=0,cm1=0,xx,c1,c2; +#pragma omp for nowait collapse(3) reduction(+:ca) + for(long k=0;kv(i,j,k),ay->v(i,j,k)); + c1 = v.norm(); xm1 = xm1GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); +#pragma omp parallel for private(d,v,p1,p2) collapse(2) + for(long j=0;jStop) continue; + d = mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, zVal); + v = mglPoint(ax->v(i,j,k),ay->v(i,j,k)); + mreal dd = v.norm(), c1, c2; + v *= cm*(fix?(dd>dm ? 1./dd : 0) : xm); + + if(end) { p1 = d-v; p2 = d; } + else if(beg) { p1 = d; p2 = d+v; } + else { p1=d-v/2.; p2=d+v/2.; } + if(grd) { c1=gr->GetC(ss,dd*xm-0.5,false); c2=gr->GetC(ss,dd*xm,false);} + else c1 = c2 = gr->GetC(ss,dd*xm,false); + long n1=gr->AddPnt(p1,c1), n2=gr->AddPnt(p2,c2); + // allow vectors outside bounding box + if(n1<0 && n2>=0) n1=gr->AddPnt(p1,c1,mglPoint(NAN),-1,2); + if(n2<0 && n1>=0) n2=gr->AddPnt(p2,c2,mglPoint(NAN),-1,2); + if(dot) { gr->line_plot(n1,n2); gr->mark_plot(n1,'.'); } + else gr->vect_plot(n1,n2); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_vect_xy(gr,&x,&y,ax,ay,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect_xy(_GR_, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect_2d(_GR_, _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Vect3 series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + register long n=ax->GetNx(),m=ax->GetNy(),l=ax->GetNz(); + if(mgl_check_vec3(gr,x,y,z,ax,ay,az,"Vect_3d")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Vect_3d",cgid++); + bool dot = mglchr(sch,'.'); + bool fix = mglchr(sch,'f'); + bool end = mglchr(sch,'>'); + bool beg = mglchr(sch,'<'); + bool grd = mglchr(sch,'='); + + long ss = gr->AddTexture(sch); + gr->Reserve(2*n*m*l); + long tx=1,ty=1,tz=1; + if(gr->MeshNum>1) + { tx=(n-1)/(gr->MeshNum-1); ty=(m-1)/(gr->MeshNum-1); tz=(l-1)/(gr->MeshNum-1);} + if(tx<1) tx=1; if(ty<1) ty=1; if(tz<1) tz=1; + + mreal xm=0,cm=0,ca=0; + mreal dm=(fabs(gr->Max.c)+fabs(gr->Min.c))*1e-5; + // use whole array for determining maximal vectors length + mglPoint p1,p2, v, d; + +#pragma omp parallel private(p1,p2,v,d) + { + mreal c1,c2,c3, xm1=0,cm1=0,xx; +#pragma omp for nowait collapse(3) reduction(+:ca) + for(long k=0;kv(i,j,k),ay->v(i,j,k),az->v(i,j,k)); + c1 = v.norm(); xm1 = xm1Stop) continue; + d=mglPoint(GetX(x,i,j,k).x, GetY(y,i,j,k).x, GetZ(z,i,j,k).x); + v = mglPoint(ax->v(i,j,k),ay->v(i,j,k),az->v(i,j,k)); + mreal dd = v.norm(),c1,c2; + v *= cm*(fix?(dd>dm ? 1./dd : 0) : xm); + + if(end) { p1 = d-v; p2 = d; } + else if(beg) { p1 = d; p2 = d+v; } + else { p1=d-v/2.; p2=d+v/2.; } + if(grd) { c1=gr->GetC(ss,dd*xm-0.5,false); c2=gr->GetC(ss,dd*xm,false); } + else c1 = c2 = gr->GetC(ss,dd*xm,false); + long n1=gr->AddPnt(p1,c1), n2=gr->AddPnt(p2,c2); + // allow vectors outside bounding box + if(n1<0 && n2>=0) n1=gr->AddPnt(p1,c1,mglPoint(NAN),-1,2); + if(n2<0 && n1>=0) n2=gr->AddPnt(p2,c2,mglPoint(NAN),-1,2); + if(dot) { gr->line_plot(n1,n2); gr->mark_plot(n1,'.'); } + else gr->vect_plot(n1,n2); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()), z(ax->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_vect_xyz(gr,&x,&y,&z,ax,ay,az,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect_3d(_GR_, _DA_(ax), _DA_(ay), _DA_(az), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Vect3 series +// +//----------------------------------------------------------------------------- +struct _mgl_vec_slice { mglData x,y,z,ax,ay,az; }; +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_get_slice(_mgl_vec_slice &s, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, char dir, mreal d, bool both) +{ + long n=ax->GetNx(),m=ax->GetNy(),l=ax->GetNz(), nx=1,ny=1,p; + + if(dir=='x') { nx = m; ny = l; if(d<0) d = n/2.; } + if(dir=='y') { nx = n; ny = l; if(d<0) d = m/2.; } + if(dir=='z') { nx = n; ny = m; if(d<0) d = l/2.; } + s.x.Create(nx,ny); s.y.Create(nx,ny); s.z.Create(nx,ny); + s.ax.Create(nx,ny); s.ay.Create(nx,ny); s.az.Create(nx,ny); + p = long(d); d -= p; + if(dir=='x' && p>=n-1) { d+=p-n+2; p=n-2; } + if(dir=='y' && p>=m-1) { d+=p-m+2.; p=m-2; } + if(dir=='z' && p>=l-1) { d+=p-l+2; p=l-2; } + + if(both) + { + if(dir=='x') +#pragma omp parallel for collapse(2) + for(long j=0;jv(p,i,j)*(1-d) + x->v(p+1,i,j)*d; + s.y.a[i0] = y->v(p,i,j)*(1-d) + y->v(p+1,i,j)*d; + s.z.a[i0] = z->v(p,i,j)*(1-d) + z->v(p+1,i,j)*d; + s.ax.a[i0] = ax->v(p,i,j)*(1-d) + ax->v(p+1,i,j)*d; + s.ay.a[i0] = ay->v(p,i,j)*(1-d) + ay->v(p+1,i,j)*d; + s.az.a[i0] = az->v(p,i,j)*(1-d) + az->v(p+1,i,j)*d; + } + if(dir=='y') +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,p,j)*(1-d) + x->v(i,p+1,j)*d; + s.y.a[i0] = y->v(i,p,j)*(1-d) + y->v(i,p+1,j)*d; + s.z.a[i0] = z->v(i,p,j)*(1-d) + z->v(i,p+1,j)*d; + s.ax.a[i0] = ax->v(i,p,j)*(1-d) + ax->v(i,p+1,j)*d; + s.ay.a[i0] = ay->v(i,p,j)*(1-d) + ay->v(i,p+1,j)*d; + s.az.a[i0] = az->v(i,p,j)*(1-d) + az->v(i,p+1,j)*d; + } + if(dir=='z') +#pragma omp parallel for collapse(2) + for(long j=0;jv(i,j,p)*(1-d) + x->v(i,j,p+1)*d; + s.y.a[i0] = y->v(i,j,p)*(1-d) + y->v(i,j,p+1)*d; + s.z.a[i0] = z->v(i,j,p)*(1-d) + z->v(i,j,p+1)*d; + s.ax.a[i0] = ax->v(i,j,p)*(1-d) + ax->v(i,j,p+1)*d; + s.ay.a[i0] = ay->v(i,j,p)*(1-d) + ay->v(i,j,p+1)*d; + s.az.a[i0] = az->v(i,j,p)*(1-d) + az->v(i,j,p+1)*d; + } + } + else // x, y, z -- vectors + { + if(dir=='x') + { + mreal v = x->v(p)*(1-d)+x->v(p+1)*d; +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); s.z.a[i0] = z->v(j); + s.ax.a[i0] = ax->v(p,i,j)*(1-d) + ax->v(p+1,i,j)*d; + s.ay.a[i0] = ay->v(p,i,j)*(1-d) + ay->v(p+1,i,j)*d; + s.az.a[i0] = az->v(p,i,j)*(1-d) + az->v(p+1,i,j)*d; + } + } + if(dir=='y') + { + mreal v = y->v(p)*(1-d)+y->v(p+1)*d; +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); s.z.a[i0] = z->v(j); + s.ax.a[i0] = ax->v(i,p,j)*(1-d) + ax->v(i,p+1,j)*d; + s.ay.a[i0] = ay->v(i,p,j)*(1-d) + ay->v(i,p+1,j)*d; + s.az.a[i0] = az->v(i,p,j)*(1-d) + az->v(i,p+1,j)*d; + } + } + if(dir=='z') + { + mreal v = z->v(p)*(1-d)+z->v(p+1)*d; +#pragma omp parallel for collapse(2) + for(long j=0;jv(i); s.y.a[i0] = y->v(j); + s.ax.a[i0] = ax->v(i,j,p)*(1-d) + ax->v(i,j,p+1)*d; + s.ay.a[i0] = ay->v(i,j,p)*(1-d) + ay->v(i,j,p+1)*d; + s.az.a[i0] = az->v(i,j,p)*(1-d) + az->v(i,j,p+1)*d; + } + } + } +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_get_slice_md(_mgl_vec_slice &s, const mglData *x, const mglData *y, const mglData *z, const mglData *ax, const mglData *ay, const mglData *az, char dir, mreal d, bool both) +{ + long n=ax->nx,m=ax->ny,l=ax->nz, nx=1,ny=1,p; + + if(dir=='x') { nx = m; ny = l; if(d<0) d = n/2.; } + if(dir=='y') { nx = n; ny = l; if(d<0) d = m/2.; } + if(dir=='z') { nx = n; ny = m; if(d<0) d = l/2.; } + s.x.Create(nx,ny); s.y.Create(nx,ny); s.z.Create(nx,ny); + s.ax.Create(nx,ny); s.ay.Create(nx,ny); s.az.Create(nx,ny); + p = long(d); d -= p; + if(dir=='x' && p>=n-1) { d+=p-n+2; p=n-2; } + if(dir=='y' && p>=m-1) { d+=p-m+2.; p=m-2; } + if(dir=='z' && p>=l-1) { d+=p-l+2; p=l-2; } + + if(both) + { + if(dir=='x') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+1]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+1]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+1]*d; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+1]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+1]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+1]*d; + } + if(dir=='y') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+n]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+n]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+n]*d; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+n]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+n]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+n]*d; + } + if(dir=='z') +#pragma omp parallel for collapse(2) + for(long j=0;ja[i1]*(1-d) + x->a[i1+n*m]*d; + s.y.a[i0] = y->a[i1]*(1-d) + y->a[i1+n*m]*d; + s.z.a[i0] = z->a[i1]*(1-d) + z->a[i1+n*m]*d; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+n*m]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+n*m]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+n*m]*d; + } + } + else // x, y, z -- vectors + { + if(dir=='x') + { + mreal v = x->a[p]*(1-d)+x->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.z.a[i0] = z->a[j]; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+1]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+1]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+1]*d; + } + } + if(dir=='y') + { + mreal v = y->a[p]*(1-d)+y->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.z.a[i0] = z->a[j]; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+n]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+n]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+n]*d; + } + } + if(dir=='z') + { + mreal v = z->a[p]*(1-d)+z->a[p+1]*d; +#pragma omp parallel for collapse(2) + for(long j=0;ja[i]; s.y.a[i0] = y->a[j]; + s.ax.a[i0] = ax->a[i1]*(1-d) + ax->a[i1+n*m]*d; + s.ay.a[i0] = ay->a[i1]*(1-d) + ay->a[i1+n*m]*d; + s.az.a[i0] = az->a[i1]*(1-d) + az->a[i1+n*m]*d; + } + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt) +{ + bool both = mgl_isboth(x,y,z,ax); + if(mgl_check_vec3(gr,x,y,z,ax,ay,az,"Vect3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Vect3",cgid++); + char dir='y'; + if(mglchr(sch,'x')) dir='x'; + if(mglchr(sch,'z')) dir='z'; + + bool dot = mglchr(sch,'.'); + bool fix = mglchr(sch,'f'); + bool end = mglchr(sch,'>'); + bool beg = mglchr(sch,'<'); + bool grd = mglchr(sch,'='); + long ss = gr->AddTexture(sch); + + _mgl_vec_slice s; + const mglData *mx = dynamic_cast(x); + const mglData *my = dynamic_cast(y); + const mglData *mz = dynamic_cast(z); + const mglData *max = dynamic_cast(ax); + const mglData *may = dynamic_cast(ay); + const mglData *maz = dynamic_cast(az); + if(mx&&my&&mz&&max&&may&&maz) + mgl_get_slice_md(s,mx,my,mz,max,may,maz,dir,sVal,both); + else + mgl_get_slice(s,x,y,z,ax,ay,az,dir,sVal,both); + + long n=s.ax.nx,m=s.ax.ny, tx=1,ty=1; + if(gr->MeshNum>1) { tx=(n-1)/(gr->MeshNum-1); ty=(m-1)/(gr->MeshNum-1); } + if(tx<1) tx=1; if(ty<1) ty=1; + mreal xm=0,cm=0,ca=0; + mreal dm=(fabs(gr->Max.c)+fabs(gr->Min.c))*1e-5; + // use whole array for determining maximal vectors length + mglPoint p1,p2, v, d=(gr->Max-gr->Min)/mglPoint(1./ax->GetNx(),1./ax->GetNy(),1./ax->GetNz()); + + long tn=ty*n; +#pragma omp parallel private(p1,p2,v) + { + mreal xm1=0,cm1=0, xx,yy,zz, c1,c2; +#pragma omp for nowait collapse(2) reduction(+:ca) + for(long i=0;iStop) continue; + register long i0 = i+n*j; + d = mglPoint(s.x.a[i0], s.y.a[i0], s.z.a[i0]); + v = mglPoint(s.ax.a[i0], s.ay.a[i0], s.az.a[i0]); + mreal dd = v.norm(),c1,c2; + v *= cm*(fix?(dd>dm ? 1./dd : 0) : xm); + + if(end) { p1 = d-v; p2 = d; } + else if(beg) { p1 = d; p2 = d+v; } + else { p1=d-v/2.; p2=d+v/2.; } + if(grd) { c1=gr->GetC(ss,dd*xm-0.5,false); c2=gr->GetC(ss,dd*xm,false);} + else c1 = c2 = gr->GetC(ss,dd*xm,false); + long n1=gr->AddPnt(p1,c1), n2=gr->AddPnt(p2,c2); + // allow vectors outside bounding box + if(n1<0 && n2>=0) n1=gr->AddPnt(p1,c1,mglPoint(NAN),-1,2); + if(n2<0 && n1>=0) n2=gr->AddPnt(p2,c2,mglPoint(NAN),-1,2); + if(dot) { gr->line_plot(n1,n2); gr->mark_plot(n1,'.'); } + else gr->vect_plot(n1,n2); + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect3(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, double sVal, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()),z(ax->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_vect3_xyz(gr,&x,&y,&z,ax,ay,az,sch,sVal,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, *sVal, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_vect3_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *sVal, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_vect3(_GR_, _DA_(ax), _DA_(ay), _DA_(az), s, *sVal, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Flow 2d series +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT flow(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, long ss, bool vv) +{ + long n=10*(ax.nx+ax.ny); + bool both = x.nx==ax.nx && y.nx==ax.nx && x.ny==ax.ny && y.ny==ax.ny; + + mglPoint *pp = new mglPoint[n], dp; + mreal *cc = new mreal[n]; + mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); + + mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=1; + if(u<0 || v<0) { dt = -dt; u = -u; v = -v; s = -1;} + register long k=0,m; + bool end = false; + do{ + if(gr->Stop) { delete []pp; delete []cc; return; } + pp[k].x = both ? x.Spline1(u,v,0):x.Spline1(u,0,0); + pp[k].y = both ? y.Spline1(u,v,0):y.Spline1(v,0,0); + pp[k].z = zVal; + for(m=0;mGetC(ss,s*h); + if(h<1e-5) break; // stationary point + k++; + // find next point by midpoint method + h+=1; ff[0]=f*dt/h; gg[0]=g*dt/h; + e = u+ff[0]/2; h = v+gg[0]/2; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); + h = 1+hypot(f,g); ff[1]=f*dt/h; gg[1]=g*dt/h; + e = u+ff[1]/2; h = v+gg[1]/2; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); + h = 1+hypot(f,g); ff[2]=f*dt/h; gg[2]=g*dt/h; + e = u+ff[2]; h = v+gg[2]; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); + h = 1+hypot(f,g); ff[3]=f*dt/h; gg[3]=g*dt/h; + u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; + v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; + // condition of end + end = end || k>=n || u<0 || v<0 || u>1 || v>1; + } while(!end); + if(k>1) + { + long i,j,jj,a=long(1./fabs(dt)); + gr->Reserve(k); j = gr->AddPnt(pp[0],cc[0]); + for(i=1;iAddPnt(pp[i],cc[i]); + if(vv && i%a==0) + { + if(dt<0) gr->vect_plot(j,jj,a/5); + else gr->vect_plot(jj,j,a/5); + } + else gr->line_plot(jj,j); + } + } + delete []pp; delete []cc; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + mreal u,v; + if(mgl_check_dim2(gr,x,y,ax,ay,"Flow")) return; + + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?5:long(r+0.5); + static int cgid=1; gr->StartGroup("Flow",cgid++); + + long ss = gr->AddTexture(sch); + bool vv = mglchr(sch,'v'); + // allocate memory + mreal zVal = gr->Min.z; + bool cnt=!mglchr(sch,'#'); + mglData xx(x), yy(y), bx(ax), by(ay); + + for(long k=0;kGetNz();k++) + { + if(ax->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); +#pragma omp parallel for private(u,v) collapse(2) + for(long i=0;iStop) continue; + u = 0; v = (i+1.)/(num+1.); + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + u = 1; v = (i+1.)/(num+1.); + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + u = (i+1.)/(num+1.); v = 0; + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + u = (i+1.)/(num+1.); v = 1; + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + if(cnt) + { + u = 0.5; v = (i+1.)/(num+1.); + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + u = (i+1.)/(num+1.); v = 0.5; + flow(gr, zVal, s*u, s*v, xx, yy, bx, by,ss,vv); + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_flow_xy(gr,&x,&y,ax,ay,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flow_xy(_GR_, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +void MGL_EXPORT mgl_flow_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flow_2d(_GR_, _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_xy(HMGL gr, double x0, double y0, double z0, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + mglPoint p(x0,y0,z0); + mreal u,v; + long n=ax->GetNx(), m=ax->GetNy(); + bool both = x->GetNx()==n && y->GetNx()==n && x->GetNy()==m && y->GetNy()==m; + if(mgl_check_dim2(gr,x,y,ax,ay,"FlowP")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("FlowP",cgid++); + + long ss = gr->AddTexture(sch); + bool vv = mglchr(sch,'v'); + // find coordinates u, v + register long i,j; + register mreal d, dm=INFINITY; + long i0=0,j0=0; + for(i=0;iv(i,j)-p.x,y->v(i,j)-p.y) : hypot(x->v(i)-p.x,y->v(j)-p.y); + if(dv(i0,j0)-p.x; dy = y->v(i0,j0)-p.y; + dxu= x->dvx(i0,j0); dyu= y->dvx(i0,j0); + dxv= x->dvy(i0,j0); dyv= y->dvy(i0,j0); + d = dxv*dyu-dxu*dyv; + u = (i0+(dxv*dy-dx*dyv)/d)/n; + v = (j0-(dxu*dy-dx*dyu)/d)/m; + } + else + { + dx = x->v(i0)-p.x; dy = y->v(j0)-p.y; + dxu= x->dvx(i0); dyv= y->dvx(j0); + u = (i0+dx/dxu)/n; v = (j0+dy/dyv)/m; + } + } + mglData xx(x), yy(y), bx(ax), by(ay); + flow(gr, p.z, u, v, xx, yy, bx, by,ss,vv); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_2d(HMGL gr, double x0, double y0, double z0, HCDT ax, HCDT ay, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_flowp_xy(gr,x0,y0,z0,&x,&y,ax,ay,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_xy_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flowp_xy(_GR_, *x0,*y0,*z0, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; +} +void MGL_EXPORT mgl_flowp_2d_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *ax, uintptr_t *ay, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flowp_2d(_GR_, *x0,*y0,*z0, _DA_(ax), _DA_(ay), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Flow 3d series +// +//----------------------------------------------------------------------------- +void flow(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az,long ss,bool vv, bool xo, bool zo) +{ + static long n=10*(ax.nx+ax.ny); + long nn = ax.nx*ax.ny*ax.nz; + bool both = x.nx*x.ny*x.nz==nn && y.nx*y.ny*y.nz==nn && z.nx*z.ny*z.nz==nn; + mglPoint *pp = new mglPoint[n], dp; + mreal *cc = new mreal[n]; + mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); + + nn = (ax.nx > ax.ny ? ax.nx : ax.ny); + nn = (nn > ax.nz ? nn : ax.nz); + mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=1,u1,v1,w1; + if(u<0 || v<0 || w<0) + { dt = -dt; u = -u; v = -v; w = -w; s = -1;} + register long k=0,m; + bool end = false; + do{ + if(gr->Stop) { delete []pp; delete []cc; return; } + pp[k].x = both ? x.Spline1(u,v,w):x.Spline1(u,0,0); + pp[k].y = both ? y.Spline1(u,v,w):y.Spline1(v,0,0); + pp[k].z = both ? z.Spline1(u,v,w):z.Spline1(w,0,0); + for(m=0;mGetC(ss,s*h); + if(h<1e-5) break; // stationary point + k++; + // find next point by midpoint method + h+=1; ee[0]=e*dt/h; ff[0]=f*dt/h; gg[0]=g*dt/h; + u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; + u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; + u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[3]=e*dt/h; ff[3]=f*dt/h; gg[3]=g*dt/h; + u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6; + v += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; + w += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; + // condition of end + end = end || k>=n || u<0 || v<0 || u>1 || v>1 || w<0 || w>1; + } while(!end); + if(k>1) + { + long i,j,jj,a=long(1./fabs(dt)); + mreal rr = mgl_norm(gr->Max-gr->Min)*gr->BarWidth/25, ll; + mglPoint q1,q2,l; + long n1=-1,n2=-1,n3=-1,n4=-1, m1=-1,m2=-1,m3=-1,m4=-1; + + gr->Reserve(4*k); j = gr->AddPnt(pp[0],cc[0]); + l = pp[1] - pp[0]; l /= mgl_norm(l); + q1 = mglPoint(l.y,-l.x,0); ll = mgl_norm(q1); + if(ll) q1 /= ll; else q1 = mglPoint(0,1,0); + q2 = q1^l; + if(xo) { n1 = gr->AddPnt(pp[0],-1,q2); n2 = gr->AddPnt(pp[0]+rr*q1,-1,q2); } + if(zo) { n3 = gr->AddPnt(pp[0],-1,q1); n4 = gr->AddPnt(pp[0]+rr*q2,-1,q1); } + for(i=1;iAddPnt(pp[i],cc[i]); + if(vv && i%a==0) + { + if(dt<0) gr->vect_plot(j,jj,a/5); + else gr->vect_plot(jj,j,a/5); + } + else gr->line_plot(jj,j); + l = pp[i]-pp[i-1]; l /= mgl_norm(l); + q1 -= l*(l*q1); q1/= mgl_norm(q1); q2 = q1^l; + m1 = n1; m2 = n2; m3 = n3; m4 = n4; + if(xo) + { n1 = gr->AddPnt(pp[i],-1,q2); n2 = gr->AddPnt(pp[i]+rr*q1,-1,q2); gr->quad_plot(n1,n2,m1,m2); } + if(zo) + { n3 = gr->AddPnt(pp[i],-1,q1); n4 = gr->AddPnt(pp[i]+rr*q2,-1,q1); gr->quad_plot(n3,n4,m3,m4); } + } + } + delete []pp; delete []cc; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + mreal u,v,w; + if(mgl_check_vec3(gr,x,y,z,ax,ay,az,"Flow3")) return; + + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?3:long(r+0.5); + static int cgid=1; gr->StartGroup("Flow3",cgid++); + bool cnt=!mglchr(sch,'#'); + long ss = gr->AddTexture(sch); + bool vv = mglchr(sch,'v'), xo = mglchr(sch,'x'), zo = mglchr(sch,'z'); + + mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); +#pragma omp parallel for private(u,v,w) collapse(3) + for(long i=0;iStop) continue; + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0; + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 1; + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = 0; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = 1; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = (i+1.)/(num+1.); v = 0; w = (j+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = (i+1.)/(num+1.); v = 1; w = (j+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + if(cnt) + { + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0.5; + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = 0.5; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + u = (i+1.)/(num+1.); v = 0.5; w = (j+1.)/(num+1.); + flow(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()), z(ax->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_flow_xyz(gr,&x,&y,&z,ax,ay,az,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flow_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flow_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, o); delete []o; delete []s; } +void MGL_EXPORT mgl_flow_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flow_3d(_GR_, _DA_(ax), _DA_(ay), _DA_(az), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_xyz(HMGL gr, double x0, double y0, double z0, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + mglPoint p(x0,y0,z0); + mreal u,v,w; + long n=ax->GetNx(),m=ax->GetNy(),l=ax->GetNz(); + bool both = x->GetNx()*x->GetNy()*x->GetNz()==n*m*l && y->GetNx()*y->GetNy()*y->GetNz()==n*m*l && z->GetNx()*z->GetNy()*z->GetNz()==n*m*l; + if(mgl_check_vec3(gr,x,y,z,ax,ay,az,"FlowP3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("FlowP3",cgid++); + long ss = gr->AddTexture(sch); + bool vv = mglchr(sch,'v'), xo = mglchr(sch,'x'), zo = mglchr(sch,'z'); + + // find coordinates u, v, w + register long i,j,k; + register mreal d, dm=INFINITY; + long i0=0,j0=0,k0=0; + mreal dx,dy,dz; + for(i=0;iv(i,j,k)-p.x; dy = y->v(i,j,k)-p.y; dz = x->v(i,j,k)-p.z; } + else + { dx = x->v(i)-p.x; dy = y->v(j)-p.y; dz = x->v(k)-p.z; } + d = sqrt(dx*dx+dy*dy+dz*dz); + if(dv(i0,j0,k0)-p.x; dy = y->v(i0,j0,k0)-p.y; dz = z->v(i0,j0,k0)-p.z; + dxu= x->dvx(i0,j0,k0); dyu= y->dvx(i0,j0,k0); dzu= z->dvx(i0,j0,k0); + dxv= x->dvy(i0,j0,k0); dyv= y->dvy(i0,j0,k0); dzv= z->dvy(i0,j0,k0); + dxw= x->dvz(i0,j0,k0); dyw= y->dvz(i0,j0,k0); dzw= z->dvz(i0,j0,k0); + d = dxu*(dyw*dzv-dyv*dzw)+dxv*(dyu*dzw-dyw*dzu)+dxw*(dyv*dzu-dyu*dzv); + u = (i0+(dx*(dyw*dzv-dyv*dzw)+dxv*(dy*dzw-dyw*dz)+dxw*(dyv*dz-dy*dzv))/d)/n; + v = (j0-(dx*(dyw*dzu-dyu*dzw)+dxu*(dy*dzw-dyw*dz)+dxw*(dyu*dz-dy*dzu))/d)/m; + w = (i0+(dx*(dyv*dzu-dyu*dzv)+dxu*(dy*dzv-dyv*dz)+dxv*(dyu*dz-dy*dzu))/d)/l; + } + else + { + dx = x->v(i0)-p.x; dy = y->v(j0)-p.y; dz = z->v(k0)-p.z; + dxu= x->dvx(i0); dyv= y->dvx(j0); dzw= z->dvx(k0); + u = (i0+dx/dxu)/n; v = (j0+dy/dyv)/m; w = (k0+dz/dzw)/m; + } + } + mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); + flow(gr, u, v, w, xx, yy, zz, bx, by, bz,ss,vv,xo,zo); + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_3d(HMGL gr, double x0, double y0, double z0, HCDT ax, HCDT ay, HCDT az, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()), z(ax->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_flowp_xyz(gr, x0,y0,z0, &x,&y,&z,ax,ay,az,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_flowp_xyz_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flowp_xyz(_GR_, *x0,*y0,*z0, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, o); + delete []o; delete []s; } +void MGL_EXPORT mgl_flowp_3d_(uintptr_t *gr, mreal *x0, mreal *y0, mreal *z0, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_flowp_3d(_GR_, *x0,*y0,*z0, _DA_(ax), _DA_(ay), _DA_(az), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Grad series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT phi, const char *sch, const char *opt) +{ + mglData ax(phi), ay,az,xx,yy,zz; + ay.Set(ax); az.Set(ax); xx.Set(ax); yy.Set(ax); zz.Set(ax); + long n=xx.nx, m=xx.ny, l=xx.nz, nn = n*m*l; + if(x->GetNx()*x->GetNy()*x->GetNz()==nn && y->GetNx()*y->GetNy()*y->GetNz()==nn && z->GetNx()*z->GetNy()*z->GetNz()==nn) + { xx.Set(x); yy.Set(y); zz.Set(z); } // nothing to do + else if(x->GetNx()==n && y->GetNx()==m && z->GetNx()==l) +#pragma omp parallel for collapse(3) + for(long i=0;iv(i); yy.a[i0] = y->v(j); zz.a[i0] = z->v(k); + } + else { gr->SetWarn(mglWarnDim,"Grad"); return; } + ax.Diff(xx,yy,zz); ay.Diff(yy,xx,zz); az.Diff(zz,xx,yy); + mgl_flow_xyz(gr,&xx,&yy,&zz,&ax,&ay,&az,sch,opt); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad_xy(HMGL gr, HCDT x, HCDT y, HCDT phi, const char *sch, const char *opt) +{ + mglData ax(phi), ay,xx,yy; + ay.Set(ax); xx.Set(ax); yy.Set(ax); + long n = phi->GetNx(), m=phi->GetNy(), nn=n*m; + if(x->GetNx()*x->GetNy()==nn && y->GetNx()*y->GetNy()==nn) { xx.Set(x); yy.Set(y); } + else if(x->GetNx()==n && y->GetNx()==m) +#pragma omp parallel for collapse(2) + for(long i=0;iv(i); yy.a[i0] = y->v(j); } + else { gr->SetWarn(mglWarnDim,"Grad"); return; } + ax.Diff(xx,yy); ay.Diff(yy,xx); + mgl_flow_xy(gr,&xx,&yy,&ax,&ay,sch,opt); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad(HMGL gr, HCDT phi, const char *sch, const char *opt) +{ + mglData x(phi->GetNx()), y(phi->GetNy()), z(phi->GetNz()); + gr->SaveState(opt); + x.Fill(gr->Min.x,gr->Max.x); y.Fill(gr->Min.y,gr->Max.y); z.Fill(gr->Min.z,gr->Max.z); + if(phi->GetNz()==1) mgl_grad_xy(gr,&x,&y,phi,sch,0); + else mgl_grad_xyz(gr,&x,&y,&z,phi,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ph, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_grad_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ph), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ph, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_grad_xy(_GR_, _DA_(x), _DA_(y), _DA_(ph), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_grad_(uintptr_t *gr, uintptr_t *ph, const char *sch, const char *opt, int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_grad(_GR_, _DA_(ph), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Pipe 2d series +// +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT flowr(mglBase *gr, double zVal, double u, double v, const mglData &x, const mglData &y, const mglData &ax, const mglData &ay, double r0,long sc) +{ + long n=10*(ax.nx+ax.ny); + bool both = x.nx==ax.nx && y.nx==ax.nx && x.ny==ax.ny && y.ny==ax.ny; + + mglPoint *pp = new mglPoint[n], dp; + mreal *cc = new mreal[n]; + mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); + + mreal dt = 0.5/(ax.nx > ax.ny ? ax.nx : ax.ny),e,f,g,ff[4],gg[4],h,s=1; + mreal ss = 4./mgl_ipow(gr->Max.c - gr->Min.c,2); + if(u<0 || v<0) { dt = -dt; u = -u; v = -v; s = -1;} + register long k=0,m; + bool end = false; + do{ + if(gr->Stop) { delete []pp; delete []cc; return; } + pp[k].x = both ? x.Spline1(u,v,0):x.Spline1(u,0,0); + pp[k].y = both ? y.Spline1(u,v,0):y.Spline1(v,0,0); + pp[k].z = zVal; + for(m=0;mGetC(sc,s*h); + pp[k].c = r0>0 ? r0*sqrt(1e-2+ss*h*h)/2 : -r0/sqrt(1e-2+ss*h*h)/5; + if(h<1e-5) break; // stationary point + k++; + // find next point by midpoint method + h+=1; ff[0]=f*dt/h; gg[0]=g*dt/h; + e = u+ff[0]/2; h = v+gg[0]/2; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); h = 1+hypot(f,g); + ff[1]=f*dt/h; gg[1]=g*dt/h; + e = u+ff[1]/2; h = v+gg[1]/2; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); h = 1+hypot(f,g); + ff[2]=f*dt/h; gg[2]=g*dt/h; + e = u+ff[2]; h = v+gg[2]; + f = ax.Linear1(e,h,0); g = ay.Linear1(e,h,0); h = 1+hypot(f,g); + ff[3]=f*dt/h; gg[3]=g*dt/h; + u += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; + v += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; + // condition of end + end = end || k>=n || u<0 || v<0 || u>1 || v>1; + } while(!end); + if(k>1) + { + int num=!(gr->GetQuality()&3)?13:25; + long *id=new long[2*num]; + mglPoint p,l=pp[1]-pp[0],t,q,d; + t = !l; t.Normalize(); q = t^l; q.Normalize(); + mreal rr=pp[0].c,dr=l.c; + gr->Reserve(num*k); + + for(long j=0;jAddPnt(p,cc[0],d); + } + for(long i=1;iAddPnt(p,cc[i],d); + if(j>0) gr->quad_plot(id[j-1],id[j],id[j+num-1],id[j+num]); + } + } + delete []id; + } + delete []pp; delete []cc; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_xy(HMGL gr, HCDT x, HCDT y, HCDT ax, HCDT ay, const char *sch, double r0, const char *opt) +{ + mreal u,v; + if(mgl_check_dim2(gr,x,y,ax,ay,"Pipe")) return; + + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?5:long(r+0.5); + static int cgid=1; gr->StartGroup("Pipe",cgid++); + + long ss = gr->AddTexture(sch); + // allocate memory + mreal zVal = gr->Min.z; + bool cnt=!mglchr(sch,'#'); + if(mglchr(sch,'i')) r0 = -fabs(r0); + + mglData xx(x), yy(y), bx(ax), by(ay); + for(long k=0;kGetNz();k++) + { + if(ax->GetNz()>1) zVal = gr->Min.z+(gr->Max.z-gr->Min.z)*mreal(k)/(ax->GetNz()-1); +#pragma omp parallel for private(u,v) collapse(2) + for(long i=0;iStop) continue; + u = 0; v = (i+1.)/(num+1.); + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + u = 1; v = (i+1.)/(num+1.); + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + u = (i+1.)/(num+1.); v = 0; + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + u = (i+1.)/(num+1.); v = 1; + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + if(cnt) + { + u = 0.5; v = (i+1.)/(num+1.); + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + u = (i+1.)/(num+1.); v = 0.5; + flowr(gr, zVal, s*u, s*v, xx, yy, bx, by,r0,ss); + } + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_2d(HMGL gr, HCDT ax, HCDT ay, const char *sch, double r0, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + mgl_pipe_xy(gr,&x,&y,ax,ay,sch,r0,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_xy_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *ax, uintptr_t *ay, const char *sch, mreal *r0, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_pipe_xy(_GR_, _DA_(x), _DA_(y), _DA_(ax), _DA_(ay), s, *r0, o); delete []o; delete []s; } +void MGL_EXPORT mgl_pipe_2d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, const char *sch, mreal *r0, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_pipe_2d(_GR_, _DA_(ax), _DA_(ay), s, *r0, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Pipe 3d series +// +//----------------------------------------------------------------------------- +void flowr(mglBase *gr, double u, double v, double w, const mglData &x, const mglData &y, const mglData &z, const mglData &ax, const mglData &ay, const mglData &az, double r0,long sc) +{ + static long n=10*(ax.nx+ax.ny); + long nn = ax.nx*ax.ny*ax.nz; + bool both = x.nx*x.ny*x.nz==nn && y.nx*y.ny*y.nz==nn && z.nx*z.ny*z.nz==nn; + mglPoint *pp = new mglPoint[n], dp; + mreal *cc = new mreal[n]; + mglPoint dx(1/fabs(gr->Max.x-gr->Min.x),1/fabs(gr->Max.y-gr->Min.y),1/fabs(gr->Max.z-gr->Min.z)); + + nn = (ax.nx > ax.ny ? ax.nx : ax.ny); + nn = (nn > ax.nz ? nn : ax.nz); + mreal dt = 0.2/nn, e,f,g,ee[4],ff[4],gg[4],h,s=1,u1,v1,w1; + mreal ss = 4./mgl_ipow(gr->Max.c - gr->Min.c,2); + + if(u<0 || v<0 || w<0) + { dt = -dt; u = -u; v = -v; w = -w; s = -1;} + register long k=0,m; + bool end = false; + do{ + if(gr->Stop) { delete []pp; delete []cc; return; } + pp[k].x = both ? x.Spline1(u,v,w):x.Spline1(u,0,0); + pp[k].y = both ? y.Spline1(u,v,w):y.Spline1(v,0,0); + pp[k].z = both ? z.Spline1(u,v,w):z.Spline1(w,0,0); + for(m=0;mGetC(sc,s*h); + pp[k].c = r0>0 ? r0*sqrt(1e-2+ss*h*h)/2 : -r0/sqrt(1e-2+ss*h*h)/5; + if(h<1e-5) break; // stationary point + k++; + // find next point by midpoint method + h+=1; ee[0]=e*dt/h; ff[0]=f*dt/h; gg[0]=g*dt/h; + u1 = u+ee[0]/2; v1 = v+ff[0]/2; w1 = w+gg[0]/2; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[1]=e*dt/h; ff[1]=f*dt/h; gg[1]=g*dt/h; + u1 = u+ee[1]/2; v1 = v+ff[1]/2; w1 = w+gg[1]/2; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[2]=e*dt/h; ff[2]=f*dt/h; gg[2]=g*dt/h; + u1 = u+ee[2]; v1 = v+ff[2]; w1 = w+gg[2]; + e = ax.Linear1(u1,v1,w1); f = ay.Linear1(u1,v1,w1); + g = az.Linear1(u1,v1,w1); h = 1+sqrt(e*e+f*f+g*g); + ee[3]=e*dt/h; ff[3]=f*dt/h; gg[3]=g*dt/h; + u += ee[0]/6+ee[1]/3+ee[2]/3+ee[3]/6; + v += ff[0]/6+ff[1]/3+ff[2]/3+ff[3]/6; + w += gg[0]/6+gg[1]/3+gg[2]/3+gg[3]/6; + // condition of end + end = end || k>=n || u<0 || v<0 || u>1 || v>1 || w<0 || w>1; + } while(!end); + if(k>1) + { + const int num=24; + long *id=new long[2*num]; + mglPoint p,l=pp[1]-pp[0],t,q,d; + t = !l; t.Normalize(); q = t^l; q.Normalize(); + mreal rr=pp[0].c,dr=l.c; + gr->Reserve(num*k); + + for(long j=0;jAddPnt(p,cc[0],d); + } + for(long i=1;iAddPnt(p,cc[i],d); + if(j>0) gr->quad_plot(id[j-1],id[j],id[j+num-1],id[j+num]); + } + } + delete []id; + } + delete []pp; delete []cc; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT ax, HCDT ay, HCDT az, const char *sch, double r0, const char *opt) +{ + mreal u,v,w; + if(mgl_check_vec3(gr,x,y,z,ax,ay,az,"Vect")) return; + + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?3:long(r+0.5); + static int cgid=1; gr->StartGroup("Pipe3",cgid++); + if(mglchr(sch,'i')) r0 = -fabs(r0); + + long ss = gr->AddTexture(sch); + bool cnt=!mglchr(sch,'#'); + + mglData xx(x), yy(y), zz(z), bx(ax), by(ay), bz(az); +#pragma omp parallel for private(u,v,w) collapse(3) + for(long i=0;iStop) continue; + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0; + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 1; + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = 0; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = 1; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = (i+1.)/(num+1.); v = 0; w = (j+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = (i+1.)/(num+1.); v = 1; w = (j+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + if(cnt) + { + u = (i+1.)/(num+1.); v = (j+1.)/(num+1.); w = 0.5; + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = 0.5; v = (j+1.)/(num+1.); w = (i+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + u = (i+1.)/(num+1.); v = 0.5; w = (j+1.)/(num+1.); + flowr(gr, s*u, s*v, s*w, xx, yy, zz, bx, by, bz,r0,ss); + } + } + gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_3d(HMGL gr, HCDT ax, HCDT ay, HCDT az, const char *sch, double r0, const char *opt) +{ + gr->SaveState(opt); + mglData x(ax->GetNx()), y(ax->GetNy()), z(ax->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_pipe_xyz(gr,&x,&y,&z,ax,ay,az,sch,r0,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_pipe_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *r0, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_pipe_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(ax), _DA_(ay), _DA_(az), s, *r0, o); + delete []o; delete []s; } +void MGL_EXPORT mgl_pipe_3d_(uintptr_t *gr, uintptr_t *ax, uintptr_t *ay, uintptr_t *az, const char *sch, mreal *r0, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_pipe_3d(_GR_, _DA_(ax), _DA_(ay), _DA_(az), s, *r0, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/volume.cpp b/src/volume.cpp new file mode 100644 index 0000000..2a83031 --- /dev/null +++ b/src/volume.cpp @@ -0,0 +1,838 @@ +/*************************************************************************** + * surf.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/define.h" +#include "mgl2/volume.h" +#include "mgl2/data.h" +#include "mgl2/eval.h" +#include "mgl2/base.h" +//#include +//----------------------------------------------------------------------------- +// +// CloudQ series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cloud_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + if(!(gr->GetQuality()&3)) return; // do nothing in fast_draw + long n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + bool both = mgl_isboth(x,y,z,a); + if(mgl_check_dim3(gr,both,x,y,z,a,0,"Cloud")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Cloud",cgid++); + + long tx=1,ty=1,tz=1; + if(gr->MeshNum>1) + { + tx=(n-1)/(gr->MeshNum-1); if(tx<1) tx=1; + ty=(m-1)/(gr->MeshNum-1); if(ty<1) ty=1; + tz=(l-1)/(gr->MeshNum-1); if(tz<1) tz=1; + } + + mreal alpha = gr->AlphaDef; + bool inv = mglchr(sch,'i'); + bool dot = mglchr(sch,'.'); + alpha /= pow(n/tx*m/ty*l/tz,1./3)/20; + if(alpha>1) alpha = 1; + long ss = gr->AddTexture(sch); + + // x, y, z -- have the same size as a + n /= tx; m /= ty; l /= tz; + long *pos=new long[n*m*l]; + gr->Reserve(n*m*l); + mglPoint q=mglPoint(NAN); +#pragma omp parallel for collapse(3) + for(long k=0;kStop) continue; + mglPoint p = both ? mglPoint(x->v(i*tx,j*ty,k*tz),y->v(i*tx,j*ty,k*tz),z->v(i*tx,j*ty,k*tz)) : mglPoint(x->v(i*tx),y->v(j*ty),z->v(k*tz)); + mreal aa = gr->GetA(a->v(i*tx,j*ty,k*tz)); + mreal bb = inv ? (1-aa)*(1-aa)*alpha : aa*aa*alpha; + pos[i+n*(j+m*k)] = gr->AddPnt(p,gr->GetC(ss,aa,false),q,bb); + } + if(dot) +#pragma omp parallel for + for(long i=0;imark_plot(pos[i],'.'); + else +#pragma omp parallel for collapse(3) + for(long k=0;kStop) continue; + register long i0 = i+n*(j+m*k); + if(iquad_plot(pos[i0],pos[i0+1],pos[i0+n],pos[i0+n+1]); + if(iquad_plot(pos[i0],pos[i0+1],pos[i0+n*m],pos[i0+n*m+1]); + if(kquad_plot(pos[i0],pos[i0+n],pos[i0+n*m],pos[i0+n+n*m]); + } + delete []pos; gr->EndGroup(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cloud(HMGL gr, HCDT a, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_cloud_xyz(gr,&x,&y,&z,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cloud_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cloud_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_cloud_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_cloud(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Surf3 series +// +//----------------------------------------------------------------------------- +mglPoint MGL_NO_EXPORT mgl_normal_3d(HCDT a, mglPoint p, bool inv, long n,long m,long l) +{ + register long i,j,k; + register mreal x=p.x, y=p.y, z=p.z; + mreal nx=0, ny=0, nz=0; + i=long(x); j=long(y); k=long(z); + i = idvx(i,j,k)*(1-x) + a->dvx(i+1,j,k)*x; + ny = a->dvy(i,j,k)*(1-y) + a->dvy(i,j+1,k)*y; + nz = a->dvz(i,j,k)*(1-z) + a->dvz(i,j,k+1)*z; + return inv ? mglPoint(nx,ny,nz) : mglPoint(-nx,-ny,-nz); +} +//----------------------------------------------------------------------------- +mreal MGL_NO_EXPORT mgl_normal_1d(HCDT a, mreal x, bool inv, long n) +{ + register long i=long(x); x-=i; + mreal nx = a->dvx(i); + if(idvx(i+1)*x; + return inv ? nx : -nx; +} +//----------------------------------------------------------------------------- +mglPoint MGL_NO_EXPORT mgl_find_norm(bool both, HCDT x, HCDT y, HCDT z, HCDT a, mglPoint u, bool inv, long n,long m,long l) +{ + mglPoint s = mgl_normal_3d(a,u,inv,n,m,l), t, q; + if(both) + { + t = mgl_normal_3d(x,u,true,n,m,l); q.x = (s*t)/(t*t); + t = mgl_normal_3d(y,u,true,n,m,l); q.y = (s*t)/(t*t); + t = mgl_normal_3d(z,u,true,n,m,l); q.z = (s*t)/(t*t); + } + else + { + q.x = s.x/mgl_normal_1d(x,u.x,true,n); + q.y = s.y/mgl_normal_1d(y,u.y,true,m); + q.z = s.z/mgl_normal_1d(z,u.z,true,l); + } + return q; +} +//----------------------------------------------------------------------------- +inline mreal MGL_NO_EXPORT mgl_cos_pp(const mglPoint *kk,long i0,long i1,long i2) +{ + mglPoint dp1 = kk[i1]-kk[i0], dp2 = kk[i2]-kk[i0]; + mreal p1=dp1*dp1,p2=dp2*dp2,pc=dp1*dp2; + return p1*p2>1e-10 ? pc/sqrt(p1*p2) : NAN; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_plot(HMGL gr, long n,long m,long *kx1,long *kx2,long *ky1,long *ky2, long *kz, std::vector kk, int wire) +{ + long id[12],us[12],pd[12],ni; + mglPoint pp[12]; + mreal d,d0; + +#pragma omp parallel for private(id,us,pd,pp,ni,d,d0) collapse(2) + for(long j=0;jStop) continue; + register long i0 = i+n*j,ii,jj,k; + // find ID of points of Surf3 intersection with cell i0 + memset(id,-1,12*sizeof(long)); ni = 0; + if(kx1[i0]>=0) id[ni++] = kx1[i0]; + if(ky1[i0]>=0) id[ni++] = ky1[i0]; + if(kx1[i0+n]>=0) id[ni++] = kx1[i0+n]; + if(ky1[i0+1]>=0) id[ni++] = ky1[i0+1]; + if(kz[i0]>=0) id[ni++] = kz[i0]; + if(kz[i0+1]>=0) id[ni++] = kz[i0+1]; + if(kz[i0+n+1]>=0) id[ni++] = kz[i0+n+1]; + if(kz[i0+n]>=0) id[ni++] = kz[i0+n]; + if(kx2[i0]>=0) id[ni++] = kx2[i0]; + if(ky2[i0]>=0) id[ni++] = ky2[i0]; + if(kx2[i0+n]>=0) id[ni++] = kx2[i0+n]; + if(ky2[i0+1]>=0) id[ni++] = ky2[i0+1]; + if(ni<3) continue; + + for(jj=0;jj1e-5) jj++; + else + { ni--; for(ii=jj;iid0) { d0=d; i0=ii; } + } + if(i0<0) break; // no more triangles. NOTE: should be never here + jj = i0; us[jj]=1; p3 = pd[jj]; + if(wire==1) + { + gr->line_plot(p1, p2); + gr->line_plot(p1, p3); + gr->line_plot(p2, p3); + } + else if(wire==2) + { + gr->mark_plot(p1, '.'); + gr->mark_plot(p2, '.'); + gr->mark_plot(p3, '.'); + } + else gr->trig_plot(p1, p2, p3); + p2 = p3; + } + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_xyz_val(HMGL gr, double val, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + long i,j,k,i1,n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + long *kx1,*kx2,*ky1,*ky2,*kz; + bool both = mgl_isboth(x,y,z,a); + int wire = mglchr(sch,'#')?1:0; + if(mglchr(sch,'.')) wire = 2; + mreal d; + if(mgl_check_dim3(gr,both,x,y,z,a,0,"Surf3")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Surf3",cgid++); + + bool inv = (mglchr(sch,'-')); + long ss = gr->AddTexture(sch), pos; + + kx1 = new long[n*m]; kx2 = new long[n*m]; + ky1 = new long[n*m]; ky2 = new long[n*m]; + kz = new long[n*m]; + mreal c=gr->GetC(ss,val); + std::vector kk; +// kk.reserve(n*m*l); + + mglPoint p,q,u, p0; + mreal a0; + for(k=0;kReserve(n*m); gr->Reserve(n*m); +//#pragma omp parallel for collapse(2) // NOTE: this part require a lot of memory for OpenMP. Omit it. + for(j=0;jStop) continue; + i1 = i+n*j; a0 = a->v(i,j,k); + p0 = both?mglPoint(x->v(i,j,k), y->v(i,j,k), z->v(i,j,k)) : mglPoint(x->v(i), y->v(j), z->v(k)); + if(iv(i+1,j,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i+1,j,k)*d, + p0.y*(1-d)+y->v(i+1,j,k)*d, + p0.z*(1-d)+z->v(i+1,j,k)*d); + else p = mglPoint(p0.x*(1-d)+x->v(i+1)*d, p0.y, p0.z); + u = mglPoint(i+d,j,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + kx2[i1] = kk.size(); kk.push_back(u); + } + } + if(jv(i,j+1,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i,j+1,k)*d, + p0.y*(1-d)+y->v(i,j+1,k)*d, + p0.z*(1-d)+z->v(i,j+1,k)*d); + else p = mglPoint(p0.x, p0.y*(1-d)+y->v(j+1)*d, p0.z); + u = mglPoint(i,j+d,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + ky2[i1] = kk.size(); kk.push_back(u); + } + } + if(k>0) + { + d = mgl_d(val,a->v(i,j,k-1),a0); + if(d>=0 && d<1) + { + if(both) p = mglPoint(x->v(i,j,k-1)*(1-d)+p0.x*d, + y->v(i,j,k-1)*(1-d)+p0.y*d, + z->v(i,j,k-1)*(1-d)+p0.z*d); + else p = mglPoint(p0.x, p0.y, z->v(k-1)*(1-d)+p0.z*d); + u = mglPoint(i,j,k+d-1); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + kz[i1] = kk.size(); kk.push_back(u); + } + } + } + if(k>0) mgl_surf3_plot(gr,n,m,kx1,kx2,ky1,ky2,kz,kk,wire); + } + gr->EndGroup(); + delete []kx1; delete []kx2; delete []ky1; + delete []ky2; delete []kz; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_val(HMGL gr, double val, HCDT a, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()), z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3_xyz_val(gr,val,&x,&y,&z,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?3:long(r+0.5); + for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mgl_surf3_xyz_val(gr,v,x,y,z,a,sch,0); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3(HMGL gr, HCDT a, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()), z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3_xyz(gr,&x,&y,&z,a,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_xyz_val_(uintptr_t *gr, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3_xyz_val(_GR_, *Val, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_val_(uintptr_t *gr, mreal *Val, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3_val(_GR_, *Val, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3_(uintptr_t *gr, uintptr_t *a, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3(_GR_, _DA_(a), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Surf3A series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_xyz_val(HMGL gr, double val, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *sch, const char *opt) +{ + long i,j,k,i1,n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + long *kx1,*kx2,*ky1,*ky2,*kz; + bool both = mgl_isboth(x,y,z,a); + int wire = mglchr(sch,'#')?1:0; + if(mglchr(sch,'.')) wire = 2; + mreal d; + if(mgl_check_dim3(gr,both,x,y,z,a,b,"Surf3A")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Surf3A",cgid++); + + bool inv = (mglchr(sch,'-')); + long ss = gr->AddTexture(sch), pos; + + kx1 = new long[n*m]; kx2 = new long[n*m]; + ky1 = new long[n*m]; ky2 = new long[n*m]; + kz = new long[n*m]; + mreal c=gr->GetC(ss,val),aa; + std::vector kk; + kk.reserve(n*m*l); + + mglPoint p,q,u, p0; + mreal a0,b0; + for(k=0;kReserve(n*m); gr->Reserve(n*m); +//#pragma omp parallel for collapse(2) // NOTE: this part require a lot of memory for OpenMP. Omit it. + for(j=0;jStop) { delete []kx1; delete []kx2; delete []ky1; + delete []ky2; delete []kz; return; } + i1 = i+n*j; + a0 = a->v(i,j,k); b0 = b->v(i,j,k); + p0 = both?mglPoint(x->v(i,j,k), y->v(i,j,k), z->v(i,j,k)) : mglPoint(x->v(i), y->v(j), z->v(k)); + if(iv(i+1,j,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i+1,j,k)*d, + p0.y*(1-d)+y->v(i+1,j,k)*d, + p0.z*(1-d)+z->v(i+1,j,k)*d); + else p = mglPoint(p0.x*(1-d)+x->v(i+1)*d, p0.y, p0.z); + aa = gr->GetA(b0*(1-d)+b->v(i+1,j,k)*d); + u = mglPoint(i+d,j,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q,aa); u.c=pos; + if(pos<0) continue; + kx2[i1] = kk.size(); kk.push_back(u); + } + } + if(jv(i,j+1,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i,j+1,k)*d, + p0.y*(1-d)+y->v(i,j+1,k)*d, + p0.z*(1-d)+z->v(i,j+1,k)*d); + else p = mglPoint(p0.x, p0.y*(1-d)+y->v(j+1)*d, p0.z); + aa = gr->GetA(b0*(1-d)+b->v(i,j+1,k)*d); + u = mglPoint(i,j+d,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q,aa); u.c=pos; + if(pos<0) continue; + ky2[i1] = kk.size(); kk.push_back(u); + } + } + if(k>0) + { + d = mgl_d(val,a->v(i,j,k-1),a0); + if(d>=0 && d<1) + { + if(both) p = mglPoint(x->v(i,j,k-1)*(1-d)+p0.x*d, + y->v(i,j,k-1)*(1-d)+p0.y*d, + z->v(i,j,k-1)*(1-d)+p0.z*d); + else p = mglPoint(p0.x, p0.y, z->v(k-1)*(1-d)+p0.z*d); + aa = gr->GetA(b->v(i,j,k-1)*(1-d)+b0*d); + u = mglPoint(i,j,k+d-1); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q,aa); u.c=pos; + if(pos<0) continue; + kz[i1] = kk.size(); kk.push_back(u); + } + } + } + if(k>0) mgl_surf3_plot(gr,n,m,kx1,kx2,ky1,ky2,kz,kk,wire); + } + gr->EndGroup(); + delete []kx1; delete []kx2; delete []ky1; + delete []ky2; delete []kz; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_val(HMGL gr, double val, HCDT a, HCDT b, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3a_xyz_val(gr,val,&x,&y,&z,a,b,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?3:long(r+0.5); + if(b->GetNx()==num && b->GetNy()==1 && b->GetNz()==1) + { + mreal v,a0=gr->AlphaDef; + for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + gr->AlphaDef = gr->GetA(b->v(i)); + mgl_surf3_xyz_val(gr,v,x,y,z,a,sch,0); + } + gr->AlphaDef = a0; + } + else for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mgl_surf3a_xyz_val(gr,v,x,y,z,a,b,sch,0); + } + gr->LoadState(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a(HMGL gr, HCDT a, HCDT b, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3a_xyz(gr,&x,&y,&z,a,b,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_xyz_val_(uintptr_t *gr, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3a_xyz_val(_GR_, *Val, _DA_(x), _DA_(y), _DA_(z), _DA_(a), _DA_(b), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_val_(uintptr_t *gr, mreal *Val, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3a_val(_GR_, *Val, _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3a_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), _DA_(b), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3a_(uintptr_t *gr, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3a(_GR_, _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Surf3C series +// +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_xyz_val(HMGL gr, double val, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *sch, const char *opt) +{ + long i,j,k,i1,n=a->GetNx(),m=a->GetNy(),l=a->GetNz(); + long *kx1,*kx2,*ky1,*ky2,*kz; + bool both = mgl_isboth(x,y,z,a); + int wire = mglchr(sch,'#')?1:0; + if(mglchr(sch,'.')) wire = 2; + mreal d; + if(mgl_check_dim3(gr,both,x,y,z,a,b,"Surf3C")) return; + + gr->SaveState(opt); + static int cgid=1; gr->StartGroup("Surf3C",cgid++); + + bool inv = (mglchr(sch,'-')); + long ss = gr->AddTexture(sch), pos; + + kx1 = new long[n*m]; kx2 = new long[n*m]; + ky1 = new long[n*m]; ky2 = new long[n*m]; + kz = new long[n*m]; + mreal c; + std::vector kk; + kk.reserve(n*m*l); + + mglPoint p,q,u, p0; + mreal a0,b0; + for(k=0;kReserve(n*m); gr->Reserve(n*m); +//#pragma omp parallel for collapse(2) // NOTE: this part require a lot of memory for OpenMP. Omit it. + for(j=0;jStop) { delete []kx1; delete []kx2; delete []ky1; + delete []ky2; delete []kz; return; } + i1 = i+n*j; + a0 = a->v(i,j,k); b0 = b->v(i,j,k); + p0 = both?mglPoint(x->v(i,j,k), y->v(i,j,k), z->v(i,j,k)) : mglPoint(x->v(i), y->v(j), z->v(k)); + if(iv(i+1,j,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i+1,j,k)*d, + p0.y*(1-d)+y->v(i+1,j,k)*d, + p0.z*(1-d)+z->v(i+1,j,k)*d); + else p = mglPoint(p0.x*(1-d)+x->v(i+1)*d, p0.y, p0.z); + c = gr->GetC(ss,b0*(1-d)+b->v(i+1,j,k)*d); + u = mglPoint(i+d,j,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + kx2[i1] = kk.size(); kk.push_back(u); + } + } + if(jv(i,j+1,k)); + if(d>=0 && d<1) + { + if(both) p = mglPoint(p0.x*(1-d)+x->v(i,j+1,k)*d, + p0.y*(1-d)+y->v(i,j+1,k)*d, + p0.z*(1-d)+z->v(i,j+1,k)*d); + else p = mglPoint(p0.x, p0.y*(1-d)+y->v(j+1)*d, p0.z); + c = gr->GetC(ss,b0*(1-d)+b->v(i,j+1,k)*d); + u = mglPoint(i,j+d,k); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + ky2[i1] = kk.size(); kk.push_back(u); + } + } + if(k>0) + { + d = mgl_d(val,a->v(i,j,k-1),a0); + if(d>=0 && d<1) + { + if(both) p = mglPoint(x->v(i,j,k-1)*(1-d)+p0.x*d, + y->v(i,j,k-1)*(1-d)+p0.y*d, + z->v(i,j,k-1)*(1-d)+p0.z*d); + else p = mglPoint(p0.x, p0.y, z->v(k-1)*(1-d)+p0.z*d); + c = gr->GetC(ss,b->v(i,j,k-1)*(1-d)+b0*d); + u = mglPoint(i,j,k+d-1); + q = mgl_find_norm(both, x,y,z,a, u, inv,n,m,l); + pos = gr->AddPnt(p,c,q); u.c=pos; + if(pos<0) continue; + kz[i1] = kk.size(); kk.push_back(u); + } + } + } + if(k>0) mgl_surf3_plot(gr,n,m,kx1,kx2,ky1,ky2,kz,kk,wire); + } + gr->EndGroup(); + delete []kx1; delete []kx2; delete []ky1; + delete []ky2; delete []kz; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_val(HMGL gr, double val, HCDT a, HCDT b, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3c_xyz_val(gr,val,&x,&y,&z,a,b,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_xyz(HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, HCDT b, const char *sch, const char *opt) +{ + mreal r = gr->SaveState(opt); + long num = mgl_isnan(r)?3:long(r+0.5); + for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mgl_surf3c_xyz_val(gr,v,x,y,z,a,b,sch,0); + } + gr->LoadState(); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c(HMGL gr, HCDT a, HCDT b, const char *sch, const char *opt) +{ + gr->SaveState(opt); + mglData x(a->GetNx()), y(a->GetNy()),z(a->GetNz()); + x.Fill(gr->Min.x,gr->Max.x); + y.Fill(gr->Min.y,gr->Max.y); + z.Fill(gr->Min.z,gr->Max.z); + mgl_surf3c_xyz(gr,&x,&y,&z,a,b,sch,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_xyz_val_(uintptr_t *gr, mreal *Val, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3c_xyz_val(_GR_, *Val, _DA_(x), _DA_(y), _DA_(z), _DA_(a), _DA_(b), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_val_(uintptr_t *gr, mreal *Val, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3c_val(_GR_, *Val, _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_xyz_(uintptr_t *gr, uintptr_t *x, uintptr_t *y, uintptr_t *z, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3c_xyz(_GR_, _DA_(x), _DA_(y), _DA_(z), _DA_(a), _DA_(b), s, o); + delete []o; delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_surf3c_(uintptr_t *gr, uintptr_t *a, uintptr_t *b, const char *sch, const char *opt,int l,int lo) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + char *o=new char[lo+1]; memcpy(o,opt,lo); o[lo]=0; + mgl_surf3c(_GR_, _DA_(a), _DA_(b), s, o); delete []o; delete []s; } +//----------------------------------------------------------------------------- +// +// Beam series +// +//----------------------------------------------------------------------------- +// flag & 0x1 -- accompanied coordinates +// flag & 0x2 -- project to r*z +// flag & 0x4 -- normalize field +void MGL_NO_EXPORT mgl_beam_md(HMGL gr, double val, const mglData *tr, const mglData *g1, const mglData *g2, const mglData *a, double r, const char *stl, int flag) +{ + long n = a->nz,m=a->nx,l=a->ny; + if(n<2 || m<2 || l<2) { gr->SetWarn(mglWarnLow,"Beam"); return; } + if(a->Minimal()<0) { gr->SetWarn(mglWarnNeg,"Beam"); return; } + if(tr->nx<3 || tr->nynx<3 || g1->nynx<3 || g2->nySetWarn(mglWarnDim,"Beam"); return; } + mglData x(a),y(a),z(a),b(a); + mreal asum=1, asum0=0, amax, aa; + r = fabs(r); + if(flag & 4) +#pragma omp parallel for reduction(+:asum0) + for(long j=0;ja[j]*a->a[j]; + if(asum0==0) { gr->SetWarn(mglWarnZero,"Beam"); return; } + for(long i=0;ia[j+m*l*i]; + asum += aa*aa; + amax = amax>aa ? amax : aa; + } + if(amax==0) { asum=0; amax=1; } +#pragma omp parallel for + for(long j=0;jStop) continue; + register long i0 = j+m*(k+l*i); + if(flag & 1) + { + x.a[i0] = 2*j/(m-1.)-1; + y.a[i0] = 2*k/(l-1.)-1; + z.a[i0] = gr->Max.z*i/(n-1.); + } + else + { + x.a[i0] = tr->a[3*i] + g1->a[3*i]*(2*j/(m-1.)-1)*r + g2->a[3*i]*(2*k/(l-1.)-1)*r; + y.a[i0] = tr->a[3*i+1] + g1->a[3*i+1]*(2*j/(m-1.)-1)*r + g2->a[3*i+1]*(2*k/(l-1.)-1)*r; + z.a[i0] = tr->a[3*i+2] + g1->a[3*i+2]*(2*j/(m-1.)-1)*r + g2->a[3*i+2]*(2*k/(l-1.)-1)*r; + } + if(flag & 2) x.a[i0] = hypot(x.a[i0],y.a[i0]); + } + } + mgl_surf3_xyz_val(gr,val,&x,&y,&z,&b,stl,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_beam_val(HMGL gr, double val, HCDT tr, HCDT g1, HCDT g2, HCDT a, double r, const char *stl, int flag) +{ + + const mglData *dtr=dynamic_cast(tr); + const mglData *dg2=dynamic_cast(g1); + const mglData *dg1=dynamic_cast(g2); + const mglData *da=dynamic_cast(a); + if(dtr&&dg1&&dg2&&da) + { mgl_beam_md(gr,val,dtr,dg1,dg2,da,r,stl,flag); return; } + + long n = a->GetNz(),m=a->GetNx(),l=a->GetNy(); + if(n<2 || m<2 || l<2) { gr->SetWarn(mglWarnLow,"Beam"); return; } + if(a->Minimal()<0) { gr->SetWarn(mglWarnNeg,"Beam"); return; } + if(tr->GetNx()<3 || tr->GetNy()GetNx()<3 || g1->GetNy()GetNx()<3 || g2->GetNy()SetWarn(mglWarnDim,"Beam"); return; } + mglData x(a),y(a),z(a),b(a); + register long i,j,k,i0; + mreal asum=1, asum0=1, amax, aa; + r = fabs(r); + if(flag & 4) for(j=0;jvthr(j)*a->vthr(j); + if(asum0==0) { gr->SetWarn(mglWarnZero,"Beam"); return; } + for(i=0;ivthr(j+m*l*i); + asum += aa*aa; + amax = amax>aa ? amax : aa; + } + if(amax==0) { asum=0; amax=1; } + for(j=0;jStop) return; + i0 = j+m*(k+l*i); + if(flag & 1) + { + x.a[i0] = 2*j/(m-1.)-1; + y.a[i0] = 2*k/(l-1.)-1; + z.a[i0] = gr->Max.z*i/(n-1.); + } + else + { + x.a[i0] = tr->v(0,i) + g1->v(0,i)*(2*j/(m-1.)-1)*r + g2->v(0,i)*(2*k/(l-1.)-1)*r; + y.a[i0] = tr->v(1,i) + g1->v(1,i)*(2*j/(m-1.)-1)*r + g2->v(1,i)*(2*k/(l-1.)-1)*r; + z.a[i0] = tr->v(2,i) + g1->v(2,i)*(2*j/(m-1.)-1)*r + g2->v(2,i)*(2*k/(l-1.)-1)*r; + } + if(flag & 2) x.a[i0] = hypot(x.a[i0],y.a[i0]); + } + } + mgl_surf3_xyz_val(gr,val,&x,&y,&z,&b,stl,0); +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_beam(HMGL gr, HCDT tr, HCDT g1, HCDT g2, HCDT a, double r, const char *stl, int flag, int num) +{ + num = num<=0 ? 1 : num; + for(long i=0;iMax.c + (gr->Min.c-gr->Max.c)*(i+1.)/(num+1); + mgl_beam_val(gr,v,tr,g1,g2,a,r,stl,flag); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_beam_val_(uintptr_t *gr, mreal *val, uintptr_t *tr, uintptr_t *g1, uintptr_t *g2, uintptr_t *a, mreal *r, const char *sch, int *norm,int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + mgl_beam_val(_GR_, *val,_DA_(tr),_DA_(g1),_DA_(g2),_DA_(a),*r,s,*norm); delete []s; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_beam_(uintptr_t *gr, uintptr_t *tr, uintptr_t *g1, uintptr_t *g2, uintptr_t *a, mreal *r, const char *sch, int *norm, int *num,int l) +{ char *s=new char[l+1]; memcpy(s,sch,l); s[l]=0; + mgl_beam(_GR_, _DA_(tr), _DA_(g1), _DA_(g2), _DA_(a), *r,s,*norm,*num); delete []s; } +//----------------------------------------------------------------------------- diff --git a/src/window.cpp b/src/window.cpp new file mode 100644 index 0000000..5ad2740 --- /dev/null +++ b/src/window.cpp @@ -0,0 +1,247 @@ +/*************************************************************************** + * window.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "mgl2/canvas_wnd.h" +//----------------------------------------------------------------------------- +mglCanvasWnd::mglCanvasWnd() : mglCanvas() +{ + Setup(); LoadFunc=0; FuncPar=0; DrawFunc=0; ClickFunc=0; + GG = 0; NumFig = 0; CurFig = -1; +} +//----------------------------------------------------------------------------- +mglCanvasWnd::~mglCanvasWnd() { if(GG) free(GG); } +//----------------------------------------------------------------------------- +void mglCanvasWnd::SetCurFig(int c) +{ + CurFig=c; + if(get(MGL_VECT_FRAME) && c>=0 && c<(long)DrwDat.size() && DrawFunc) + GetFrame(c); +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::ResetFrames() +{ + if(GG) free(GG); GG = 0; + NumFig = CurFig = 0; + mglCanvas::ResetFrames(); +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::SetSize(int w,int h) +{ + if(DrawFunc) ResetFrames(); + mglCanvas::SetSize(w,h); +// if(Wnd) Wnd->size(w,h); +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::EndFrame() +{ + CurFig = CurFrameId-1; + if(!GG) + { + GG = (unsigned char *)malloc(3*Width*Height); + NumFig = 1; CurFig = 0; + } + else if(CurFig>NumFig-1) + { + GG = (unsigned char *)realloc(GG,3*(CurFig+1)*Width*Height); + NumFig = CurFig+1; + } + mglCanvas::EndFrame(); + memcpy(GG + CurFig*Width*Height*3,G,3*Width*Height); + CurFig++; +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::SetFrame(long i) +{ + mglCanvas::SetFrame(i); + if(i>=0 && i=CurFrameId) return; + if(CurFig>=i) CurFig--; + long n = Width*Height*3; + if(CurFrameId-i>1) memmove(GG+i*n, GG+i*n+n, n*(CurFrameId-i-1)); + mglCanvas::DelFrame(i); +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::SetDrawFunc(int (*draw)(mglBase *gr, void *p), void *par, void (*reload)(void *p)) +{ + ResetFrames(); + if(get(MGL_CLF_ON_UPD)) DefaultPlotParam(); + setlocale(LC_NUMERIC, "C"); + // use frames for quickly redrawing while adding/changing primitives + if(mgl_is_frames(this)) NewFrame(); + + int n = draw ? draw(this,par) : 0; + if(n=0) NumFig = n; + DrawFunc = draw; FuncPar = par; + LoadFunc = reload; + + if(mgl_is_frames(this)) EndFrame(); + if(n>=0) SetCurFig(0); + setlocale(LC_NUMERIC, ""); +} +//----------------------------------------------------------------------------- +const unsigned char *mglCanvasWnd::GetBits() +{ + const unsigned char *g = mglCanvas::GetBits(); + if(GG && NumFig>0 && CurFig=0 && !get(MGL_VECT_FRAME)) + g = GG + CurFig*Width*Height*3; + return g; +} +//----------------------------------------------------------------------------- +void mglCanvasWnd::ReLoad() +{ + if(LoadFunc) + { + LoadFunc(FuncPar); + // update number of slides + ResetFrames(); + setlocale(LC_NUMERIC, "C"); + // use frames for quickly redrawing while adding/changing primitives + if(mgl_is_frames(this)) NewFrame(); + + int n = DrawFunc ? DrawFunc(this,FuncPar) : 0; + if(n=0) NumFig = n; + + if(mgl_is_frames(this)) EndFrame(); + setlocale(LC_NUMERIC, ""); + Update(); + } +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_wnd_toggle_alpha(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ToggleAlpha(); } +void MGL_EXPORT mgl_wnd_toggle_light(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ToggleLight(); } +void MGL_EXPORT mgl_wnd_toggle_zoom(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ToggleZoom(); } +void MGL_EXPORT mgl_wnd_toggle_rotate(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ToggleRotate(); } +void MGL_EXPORT mgl_wnd_toggle_no(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ToggleNo(); } +void MGL_EXPORT mgl_wnd_update(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->Update(); } +void MGL_EXPORT mgl_wnd_reload(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ReLoad(); } +void MGL_EXPORT mgl_wnd_adjust(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->Adjust(); } +void MGL_EXPORT mgl_wnd_next_frame(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->NextFrame(); } +void MGL_EXPORT mgl_wnd_prev_frame(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->PrevFrame(); } +void MGL_EXPORT mgl_wnd_animation(HMGL gr) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->Animation(); } +void MGL_EXPORT mgl_setup_window(HMGL gr, int clf_upd, int showpos) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->Setup(clf_upd, showpos); } +void MGL_EXPORT mgl_set_click_func(HMGL gr, void (*func)(void *p)) +{ mglCanvasWnd *g = dynamic_cast(gr); if(g) g->ClickFunc = func; } +void MGL_EXPORT mgl_get_last_mouse_pos(HMGL gr, mreal *x, mreal *y, mreal *z) +{ mglCanvasWnd *g = dynamic_cast(gr); + mglPoint p; if(g) p=g->GetMousePos(); + *x=p.x; *y=p.y; *z=p.z; } +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_wnd_toggle_alpha_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ToggleAlpha(); } +void MGL_EXPORT mgl_wnd_toggle_light_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ToggleLight(); } +void MGL_EXPORT mgl_wnd_toggle_zoom_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ToggleZoom(); } +void MGL_EXPORT mgl_wnd_toggle_rotate_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ToggleRotate(); } +void MGL_EXPORT mgl_wnd_toggle_no_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ToggleNo(); } +void MGL_EXPORT mgl_wnd_update_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->Update(); } +void MGL_EXPORT mgl_wnd_reload_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->ReLoad(); } +void MGL_EXPORT mgl_wnd_adjust_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->Adjust(); } +void MGL_EXPORT mgl_wnd_next_frame_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->NextFrame(); } +void MGL_EXPORT mgl_wnd_prev_frame_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->PrevFrame(); } +void MGL_EXPORT mgl_wnd_animation_(uintptr_t *gr) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->Animation(); } +void MGL_EXPORT mgl_setup_window_(uintptr_t *gr, int *clf_upd, int *showpos) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + if(g) g->Setup(*clf_upd, *showpos); } +void MGL_EXPORT mgl_get_last_mouse_pos_(uintptr_t *gr, mreal *x, mreal *y, mreal *z) +{ mglCanvasWnd *g = dynamic_cast((HMGL)(*gr)); + mglPoint p; if(g) p=g->GetMousePos(); + *x=p.x; *y=p.y; *z=p.z; } +//----------------------------------------------------------------------------- +// +// mglDraw class handling +// +//----------------------------------------------------------------------------- +/*int mgl_draw_class(HMGL gr, void *p) // so stupid way to save mglDraw class inheritance :( +{ + mglGraph g(gr); mglWindow *w = (mglWindow *)p; + return (w && w->dr) ? w->dr->Draw(&g) : 0; +} +void MGL_EXPORT mgl_reload_class(void *p) // so stupid way to save mglDraw class inheritance :( +{ mglWindow *w = (mglWindow *)p; if(w && w->dr) w->dr->Reload();} +void MGL_EXPORT mgl_click_class(void *p) // so stupid way to save mglDraw class inheritance :( +{ mglWindow *w = (mglWindow *)p; if(w && w->dr) w->dr->Click(); }*/ +int MGL_EXPORT mgl_draw_class(HMGL gr, void *p) +{ mglGraph g(gr); mglDraw *dr = (mglDraw *)p; return dr->Draw(&g); } +void MGL_EXPORT mgl_reload_class(void *p) +{ mglDraw *dr = (mglDraw *)p; dr->Reload(); } +void MGL_EXPORT mgl_click_class(void *p) +{ mglDraw *dr = (mglDraw *)p; dr->Click(); } +//----------------------------------------------------------------------------- +typedef int (*draw_func)(mglGraph *gr); +int MGL_EXPORT mgl_draw_graph(HMGL gr, void *p) +{ + mglGraph g(gr); + draw_func func = (draw_func)(p); + return func ? func(&g) : 0; +} +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_draw_calc(void *p) +{ +#if MGL_HAVE_PTHREAD + ((mglDraw *)p)->Calc(); +#endif + return 0; +} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_draw_thr(void *p) +{ +#if MGL_HAVE_PTHREAD + mglDraw *d = (mglDraw *)p; + if(!d || d->running) return; + pthread_create(&(d->thr),0,mgl_draw_calc,d); + pthread_detach(d->thr); +#endif +} +//----------------------------------------------------------------------------- diff --git a/texinfo/CMakeLists.txt b/texinfo/CMakeLists.txt new file mode 100644 index 0000000..20ad882 --- /dev/null +++ b/texinfo/CMakeLists.txt @@ -0,0 +1,199 @@ + set(MGL_EXTRA light) + set(MGL_PNG alpha area aspect axial axis barh bars belt boxplot + box boxs candle chart cloud colorbar combined cones conta contd + contfa contf contf_xyz cont contv cont_xyz curvcoor cut dat_diff + dat_extra densa dens dens_xyz dew dots error error2 fall fit flow fonts + fog grad hist inplot label legend loglog map mark mesh mirror + molecule parser pde pipe plot primitives projection qo2d radar region schemes + several_light solve stem step stereo stfa style surf3a surf3c surf3 + surfa surfc surf table tape tens ternary textmark text ticks tile tiles + torus traj triangulation triplot tube type0 type1 type2 vect vecta venn + projection5 mask correl refill ohlc ) + set(MGL_PNG_N ) + set(MGL_PNG_S ) + set(MGL_PNG_J ) + set(MGL_PNG_D ) + + set(MGL_OUT ${CMAKE_BINARY_DIR}/texinfo) + set(MGL_TEX ${CMAKE_SOURCE_DIR}/texinfo) + file(MAKE_DIRECTORY ${MGL_OUT}/udav) + file(MAKE_DIRECTORY ${MGL_OUT}/png) + file(MAKE_DIRECTORY ${MGL_OUT}/small) + file(MAKE_DIRECTORY ${MGL_OUT}/json) + file(MAKE_DIRECTORY ${MGL_OUT}/pdf) + file(COPY ${MGL_TEX}/qt.png ${MGL_TEX}/fltk.png ${MGL_TEX}/classes.png ${MGL_TEX}/emblem_sm.png ${MGL_TEX}/datadvance.png DESTINATION ${MGL_OUT}) + file(COPY ${MGL_TEX}/index.html ${MGL_TEX}/json.html ${MGL_TEX}/mathgl.js DESTINATION ${MGL_OUT}) + + set(UDAV_IMG udav_arg.png udav_calc.png udav_cmd.png udav_data.png + udav_gen_set.png udav_help.png udav_light.png udav_main.png udav_opt.png + udav_pen.png udav_prop.png udav_sch.png udav_txt.png udav_var.png) + foreach(SAMPLE ${UDAV_IMG}) + file(COPY ${MGL_TEX}/udav/${SAMPLE} DESTINATION ${MGL_OUT}/udav/) + endforeach(SAMPLE) + + foreach(SAMPLE ${MGL_PNG}) + set(MGL_PNG_N ${MGL_PNG_N} ${MGL_OUT}/png/${SAMPLE}.png) + add_custom_command(OUTPUT ${MGL_OUT}/png/${SAMPLE}.png + COMMAND mgl_example -kind=${SAMPLE} -web + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/png ) + set(MGL_PNG_S ${MGL_PNG_S} ${MGL_OUT}/small/${SAMPLE}-sm.png) + add_custom_command(OUTPUT ${MGL_OUT}/small/${SAMPLE}-sm.png + COMMAND mgl_example -kind=${SAMPLE} -mini + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/small ) +if(MGL_HAVE_DOC_JSON) + set(MGL_PNG_J ${MGL_PNG_J} ${MGL_OUT}/json/${SAMPLE}.json) + add_custom_command(OUTPUT ${MGL_OUT}/json/${SAMPLE}.json + COMMAND mgl_example -json -kind=${SAMPLE} +# COMMAND ${CMAKE_BINARY_DIR}/examples/mgl_example -json -kind=${SAMPLE} + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/json ) +endif(MGL_HAVE_DOC_JSON) +if(MGL_HAVE_DOC_PRC) + set(MGL_PNG_D ${MGL_PNG_D} ${MGL_OUT}/pdf/${SAMPLE}.pdf) + add_custom_command(OUTPUT ${MGL_OUT}/pdf/${SAMPLE}.pdf + COMMAND mgl_example -pdf -kind=${SAMPLE} + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/pdf ) +endif(MGL_HAVE_DOC_PRC) + endforeach(SAMPLE) + + foreach(SAMPLE ${MGL_EXTRA}) + set(MGL_PNG_N ${MGL_PNG_N} ${MGL_OUT}/png/${SAMPLE}.png) + add_custom_command(OUTPUT ${MGL_OUT}/png/${SAMPLE}.png + COMMAND mgl_example -kind=${SAMPLE} -web + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/png ) + set(MGL_PNG_S ${MGL_PNG_S} ${MGL_OUT}/small/${SAMPLE}-sm.png) + add_custom_command(OUTPUT ${MGL_OUT}/small/${SAMPLE}-sm.png + COMMAND mgl_example -kind=${SAMPLE} -mini + DEPENDS mgl_example + WORKING_DIRECTORY ${MGL_OUT}/small ) + endforeach(SAMPLE) + + set(list_texi_files_en overview_en.texi example_en.texi ex_mgl_en.texi parse_en.texi formats_en.texi udav_en.texi symbols_en.texi core_en.texi concept_en.texi widget_en.texi data_en.texi other_en.texi appendix_en.texi fdl.texi version.texi time.texi time_big.texi ) + set(list_texi_files_ru overview_ru.texi example_ru.texi ex_mgl_ru.texi parse_ru.texi formats_ru.texi udav_ru.texi symbols_ru.texi core_ru.texi concept_ru.texi widget_ru.texi data_ru.texi other_ru.texi appendix_ru.texi fdl.texi version.texi time.texi time_big.texi ) + + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_en.info + COMMAND ${findmi} ${MGL_TEX}/mathgl_en.texi + DEPENDS ${list_texi_files_en} mathgl_en.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_ru.info + COMMAND ${findmi} ${MGL_TEX}/mathgl_ru.texi + DEPENDS ${list_texi_files_ru} mathgl_ru.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_en.html + COMMAND ${findth} ${th_opt} -I ${MGL_OUT} --no-split ${MGL_TEX}/mathgl_en.texi + DEPENDS ${list_texi_files_en} mathgl_en.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mgl_en.html + COMMAND ${findth} ${th_opt} -I ${MGL_OUT} --no-split ${MGL_TEX}/mgl_en.texi + DEPENDS ${list_texi_files_en} mgl_en.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_ru.html + COMMAND ${findth} ${th_opt} -I=${MGL_OUT} --no-split ${MGL_TEX}/mathgl_ru.texi + DEPENDS ${list_texi_files_ru} mathgl_ru.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mgl_ru.html + COMMAND ${findth} ${th_opt} -I=${MGL_OUT} --no-split ${MGL_TEX}/mgl_ru.texi + DEPENDS ${list_texi_files_ru} mgl_ru.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + + add_custom_command(OUTPUT ${site_en} + COMMAND ${findth} ${th_opt} -I=${MGL_OUT}/png --split=node -o doc_en ${MGL_TEX}/doc_en.texi + DEPENDS ${list_texi_files_en} doc_en.texi ${MGL_PNG_N} web_en.texi ${MGL_PNG_S} ${MGL_PNG_J} ${MGL_PNG_D} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${site_ru} + COMMAND ${findth} ${th_opt} -I=${MGL_OUT}/png --split=node -o doc_ru ${MGL_TEX}/doc_ru.texi + DEPENDS ${list_texi_files_ru} doc_ru.texi ${MGL_PNG_N} web_ru.texi ${MGL_PNG_S} ${MGL_PNG_J} ${MGL_PNG_D} + WORKING_DIRECTORY ${MGL_OUT} + ) + + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_en.pdf + COMMAND ${findtp} ${MGL_TEX}/mathgl_en.texi + COMMAND ${findtp} ${MGL_TEX}/mathgl_en.texi + COMMAND ${findtp} ${MGL_TEX}/mathgl_en.texi + DEPENDS ${list_texi_files_en} mathgl_en.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mgl_en.pdf + COMMAND ${findtp} ${MGL_TEX}/mgl_en.texi + COMMAND ${findtp} ${MGL_TEX}/mgl_en.texi + COMMAND ${findtp} ${MGL_TEX}/mgl_en.texi + DEPENDS ${list_texi_files_en} mgl_en.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + + add_custom_command(OUTPUT ${MGL_OUT}/mathgl_ru.pdf + COMMAND ${findtp} ${MGL_TEX}/mathgl_ru.texi + COMMAND ${findtp} ${MGL_TEX}/mathgl_ru.texi + COMMAND ${findtp} ${MGL_TEX}/mathgl_ru.texi + DEPENDS ${list_texi_files_ru} mathgl_ru.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + add_custom_command(OUTPUT ${MGL_OUT}/mgl_ru.pdf + COMMAND ${findtp} ${MGL_TEX}/mgl_ru.texi + COMMAND ${findtp} ${MGL_TEX}/mgl_ru.texi + COMMAND ${findtp} ${MGL_TEX}/mgl_ru.texi + DEPENDS ${list_texi_files_en} mgl_ru.texi ${MGL_PNG_N} + WORKING_DIRECTORY ${MGL_OUT} + ) + + if(MGL_HAVE_DOC_INFO) + add_custom_target(doc_info ALL + DEPENDS ${MGL_OUT}/mathgl_en.info + DEPENDS ${MGL_OUT}/mathgl_ru.info + ) +# TODO: try to install all mathgl*.info* in future!!! + install(FILES ${MGL_OUT}/mathgl_en.info ${MGL_OUT}/mathgl_en.info-1 ${MGL_OUT}/mathgl_en.info-2 ${MGL_OUT}/mathgl_en.info-3 DESTINATION ${MGL_INFO_PATH}) + endif(MGL_HAVE_DOC_INFO) + + if(MGL_HAVE_DOC_HTML) + add_custom_target(doc_html ALL + DEPENDS ${MGL_OUT}/mgl_en.html + DEPENDS ${MGL_OUT}/mathgl_en.html + DEPENDS ${MGL_OUT}/mgl_ru.html + DEPENDS ${MGL_OUT}/mathgl_ru.html + ) + install(FILES ${MGL_TEX}/qt.png ${MGL_TEX}/fltk.png ${MGL_TEX}/classes.png ${MGL_TEX}/datadvance.png DESTINATION ${MGL_DOC_PATH}) + install(FILES ${MGL_OUT}/mathgl_en.html ${MGL_OUT}/mgl_en.html ${MGL_OUT}/mathgl_ru.html ${MGL_OUT}/mgl_ru.html DESTINATION ${MGL_DOC_PATH}) + install(DIRECTORY ${MGL_OUT}/png DESTINATION ${MGL_DOC_PATH}) + install(DIRECTORY ${MGL_OUT}/udav DESTINATION ${MGL_DOC_PATH}) + endif(MGL_HAVE_DOC_HTML) + + if(MGL_HAVE_DOC_SITE) + add_custom_target(doc_site ALL + DEPENDS ${site_en} + DEPENDS ${site_ru} + ) + endif(MGL_HAVE_DOC_SITE) + + if(MGL_HAVE_DOC_PDF_EN) + add_custom_target(doc_en ALL + DEPENDS ${MGL_OUT}/mgl_en.pdf + DEPENDS ${MGL_OUT}/mathgl_en.pdf + ) + install(FILES ${MGL_OUT}/mathgl_en.pdf DESTINATION ${MGL_DOC_PATH}) + endif(MGL_HAVE_DOC_PDF_EN) + + if(MGL_HAVE_DOC_PDF_RU) + add_custom_target(doc_ru ALL +# DEPENDS ${MGL_OUT}/mgl_ru.pdf +# DEPENDS ${MGL_OUT}/mathgl_ru.pdf + ) +# install(FILES ${MGL_OUT}/mathgl_ru.pdf DESTINATION ${MGL_DOC_PATH}) + endif(MGL_HAVE_DOC_PDF_RU) + + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc_en;doc_ru;./mathgl*.*;./mgl*.*") + + install(FILES ${MGL_TEX}/mglconv.1 ${MGL_TEX}/mglview.1 ${MGL_TEX}/udav.1 ${MGL_TEX}/mgl.cgi.1 DESTINATION ${MGL_MAN_PATH}/man1) + install(FILES ${MGL_TEX}/mgl.5 DESTINATION ${MGL_MAN_PATH}/man5) diff --git a/texinfo/appendix_en.texi b/texinfo/appendix_en.texi new file mode 100644 index 0000000..ed1cb27 --- /dev/null +++ b/texinfo/appendix_en.texi @@ -0,0 +1,69 @@ +@nav{} + +The full list of TeX-like commands recognizable by MathGL is shown below. If command is not recognized then it will be printed as is by ommitting @samp{\} symbol. For example, @samp{\#} produce ``#'', @samp{\\} produce ``\'', @samp{\qq} produce ``qq''. +@c All commands are typed without @samp{\} sign. + +@strong{Change case}: _, ^, @@. + +@strong{Text style}: \big, \b, \textbf, \i, \textit, \bi, \r, \textrm, \a, \overline, \u, \underline, \w, \wire, #, \color[wkrgbcymhRGBCYMHWlenupqLENUPQ] + +@strong{Roots}: \sqrt, \sqrt3, \sqrt4 + +@strong{Fractions}: \frac, \stack, \overset, \underset, \stackr, \stackl + +@strong{Accents}: \hat, \tilde, \dot, \ddot, \dddot, \ddddot, \acute, \check, \grave, \vec, \bar, \breve + +@strong{Special symbols}: + +\# (#), \% (%), \& (&), \^ (^). + +\AA (Å), \AE (Æ), \APLboxquestion (⍰), \APLboxupcaret (⍓), \APLnotbackslash (⍀), \APLnotslash (⌿), \Alpha (Α), \And (&), \Angstrom (Å), \Barv (⫧), \BbbC (ℂ), \BbbGamma (ℾ), \BbbH (ℍ), \BbbN (ℕ), \BbbP (ℙ), \BbbPi (ℿ), \BbbQ (ℚ), \BbbR (ℝ), \BbbZ (ℤ), \Bbbgamma (ℽ), \Bbbpi (ℼ), \Bbbsum (⅀), \Beta (Β), \Bumpeq (≎), \Cap (⋒), \Chi (Χ), \Colon (∷), \Coloneq (⩴), \Cup (⋓), \DDownarrow (⟱), \DH (Ð), \DJ (Đ), \DashV (⫥), \DashVDash (⟚), \Dashv (⫤), \Ddownarrow (⤋), \Delta (Δ), \Digamma (Ϝ), \Doteq (≑), \Downarrow (⇓), \Epsilon (Ε), \Equiv (≣), \Eta (Η), \Eulerconst (ℇ), \Exclam (‼), \Finv (Ⅎ), \Game (⅁), \Gamma (Γ), \Gt (⪢), \Hermaphrodite (⚥), \Im (ℑ), \Iota (Ι), \Kappa (Κ), \Koppa (Ϟ), \L (Ł), \LLeftarrow (⭅), \Lambda (Λ), \Lbrbrak (⟬), \Ldsh (↲), \Leftarrow (⇐), \Leftrightarrow (⇔), \Lleftarrow (⇚), \Longleftarrow (⟸), \Longleftrightarrow (⟺), \Longmapsfrom (⟽), \Longmapsto (⟾), \Longrightarrow (⟹), \Lparengtr (⦕), \Lsh (↰), \Lt (⪡), \Lvzigzag (⧚), \Mapsfrom (⤆), \Mapsto (⤇), \Mu (Μ), \NG (Ŋ), \Nearrow (⇗), \Not (⫬), \Nu (Ν), \Nwarrow (⇖), \O (Ø), \OE (Œ), \Ohorn (Ơ), \Omega (Ω), \Omicron (Ο), \Otimes (⨷), \P (¶), \Phi (Φ), \Pi (Π), \Planckconst (ℎ), \Prec (⪻), \PropertyLine (⅊), \Psi (Ψ), \QED (∎), \Question (⁇), \RRightarrow (⭆), \Rbrbrak (⟭), \Rdsh (↳), \Re (ℜ), \Rho (Ρ), \Rightarrow (⇒), \Rparenless (⦖), \Rrightarrow (⇛), \Rsh (↱), \Rvzigzag (⧛), \S (§), \Sc (⪼), \Searrow (⇘), \Sigma (Σ), \Sqcap (⩎), \Sqcup (⩏), \Stigma (Ϛ), \Subset (⋐), \Supset (⋑), \Swarrow (⇙), \TH (Þ), \Tau (Τ), \Theta (Θ), \UUparrow (⟰), \Uhorn (Ư), \Uparrow (⇑), \Updownarrow (⇕), \Uuparrow (⤊), \VDash (⊫), \Vbar (⫫), \Vdash (⊩), \Vee (⩔), \Vert (‖), \Vvdash (⊪), \Vvert (⦀), \Wedge (⩓), \XBox (☒), \Xi (Ξ), \Yup (⅄), \Zbar (Ƶ), \Zeta (Ζ). + +\aa (å), \ac (∾), \accurrent (⏦), \acidfree (♾), \acwcirclearrow (⥀), \acwgapcirclearrow (⟲), \acwleftarcarrow (⤹), \acwopencirclearrow (↺), \acwoverarcarrow (⤺), \acwundercurvearrow (⤻), \adots (⋰), \ae (æ), \aleph (ℵ), \alpha (α), \amalg (⨿), \angdnr (⦟), \angle (∠), \angles (⦞), \angleubar (⦤), \approx (≈), \approxeq (≊), \approxeqq (⩰), \approxident (≋), \arceq (≘), \aries (♈), \assert (⊦), \ast (∗), \asteq (⩮), \astrosun (☉), \asymp (≍), \awint (⨑). + +\bNot (⫭), \backcong (≌), \backdprime (‶), \backepsilon (϶), \backprime (‵), \backsim (∽), \backsimeq (⋍), \backslash (\), \backtrprime (‷), \bagmember (⋿), \barV (⫪), \barcap (⩃), \barcup (⩂), \bardownharpoonleft (⥡), \bardownharpoonright (⥝), \barleftarrow (⇤), \barleftarrowrightarrowbar (↹), \barleftharpoondown (⥖), \barleftharpoonup (⥒), \barovernorthwestarrow (↸), \barrightarrowdiamond (⤠), \barrightharpoondown (⥟), \barrightharpoonup (⥛), \baruparrow (⤒), \barupharpoonleft (⥘), \barupharpoonright (⥔), \barvee (⊽), \barwedge (⊼), \bbrktbrk (⎶), \bdHrule (═), \bdVrule (║), \bdbVbH (╬), \bdbVbh (╫), \bdbVlH (╣), \bdbVlh (╢), \bdbVrH (╠), \bdbVrh (╟), \bdbvbH (╪), \bdbvbh (┼), \bdbvlH (╡), \bdbvlh (┤), \bdbvrH (╞), \bdbvrh (├), \bddVbH (╦), \bddVbh (╥), \bddVlH (╗), \bddVlh (╖), \bddVrH (╔), \bddVrh (╓), \bddvbH (╤), \bddvbh (┬), \bddvlH (╕), \bddvlh (┐), \bddvrH (╒), \bddvrh (┌), \bdhrule (─), \bdnesw (╱), \bdnwse (╲), \bdquadhdash (┈), \bdquadvdash (┊), \bdtriplevdash (┆), \bduVbH (╩), \bduVbh (╨), \bduVlH (╝), \bduVlh (╜), \bduVrH (╚), \bduVrh (╙), \bduvbH (╧), \bduvbh (┴), \bduvlH (╛), \bduvlh (┘), \bduvrH (╘), \bduvrh (└), \bdvrule (│), \because (∵), \benzenr (⏣), \beta (β), \beth (ℶ), \between (≬), \bigblacktriangledown (▼), \bigblacktriangleup (▲), \bigbot (⟘), \bigcap (⋂), \bigcup (⋃), \bigslopedvee (⩗), \bigslopedwedge (⩘), \bigstar (★), \bigtop (⟙), \bigtriangledown (▽), \bigtriangleup (△), \bigvee (⋁), \bigwedge (⋀), \bigwhitestar (☆), \blackcircledownarrow (⧭), \blackcircledrightdot (⚈), \blackcircledsanseight (➑), \blackcircledsansfive (➎), \blackcircledsansfour (➍), \blackcircledsansnine (➒), \blackcircledsansone (➊), \blackcircledsansseven (➐), \blackcircledsanssix (➏), \blackcircledsansten (➓), \blackcircledsansthree (➌), \blackcircledsanstwo (➋), \blackcircledtwodots (⚉), \blackcircleulquadwhite (◕), \blackdiamonddownarrow (⧪), \blackhourglass (⧗), \blackinwhitediamond (◈), \blackinwhitesquare (▣), \blacklefthalfcircle (◖), \blackpointerleft (◄), \blackpointerright (►), \blackrighthalfcircle (◗), \blacksmiley (☻), \blacktriangle (▴), \blacktriangledown (▾), \blacktriangleleft (◀), \blacktriangleright (▶), \blkhorzoval (⬬), \blkvertoval (⬮), \blockfull (█), \blockhalfshaded (▒), \blocklefthalf (▌), \blocklowhalf (▄), \blockqtrshaded (░), \blockrighthalf (▐), \blockthreeqtrshaded (▓), \blockuphalf (▀), \bot (⊥), \botsemicircle (◡), \bowtie (⋈), \box (◻), \boxast (⧆), \boxbar (◫), \boxbox (⧈), \boxbslash (⧅), \boxcircle (⧇), \boxdiag (⧄), \boxdot (⊡), \boxminus (⊟), \boxonbox (⧉), \boxplus (⊞), \boxtimes (⊠), \bsimilarleftarrow (⭁), \bsimilarrightarrow (⭇), \bsolhsub (⟈), \btimes (⨲), \bullet (∙), \bullseye (◎), \bumpeq (≏), \bumpeqq (⪮). + +\calB (ℬ), \calE (ℰ), \calF (ℱ), \calH (ℋ), \calM (ℳ), \calR (ℛ), \cap (∩), \capdot (⩀), \capwedge (⩄), \caretinsert (‸), \carreturn (⏎), \carriagereturn (↵), \ccwundercurvearrow (⤿), \cdot (⋅), \cdotp (·), \cdots (⋯), \cdprime (ʺ), \checkmark (✓), \chi (χ), \cirE (⧃), \cirbot (⟟), \circ (∘), \circeq (≗), \circfint (⨐), \circlebottomhalfblack (◒), \circledA (Ⓐ), \circledB (Ⓑ), \circledC (Ⓒ), \circledD (Ⓓ), \circledE (Ⓔ), \circledF (Ⓕ), \circledG (Ⓖ), \circledH (Ⓗ), \circledI (Ⓘ), \circledJ (Ⓙ), \circledK (Ⓚ), \circledL (Ⓛ), \circledM (Ⓜ), \circledN (Ⓝ), \circledO (Ⓞ), \circledP (Ⓟ), \circledQ (Ⓠ), \circledR (Ⓡ), \circledS (Ⓢ), \circledT (Ⓣ), \circledU (Ⓤ), \circledV (Ⓥ), \circledW (Ⓦ), \circledX (Ⓧ), \circledY (Ⓨ), \circledZ (Ⓩ), \circleda (ⓐ), \circledast (⊛), \circledb (ⓑ), \circledbullet (⦿), \circledc (ⓒ), \circledcirc (⊚), \circledd (ⓓ), \circleddash (⊝), \circlede (ⓔ), \circledeight (⑧), \circledequal (⊜), \circledf (ⓕ), \circledfive (⑤), \circledfour (④), \circledg (ⓖ), \circledh (ⓗ), \circledi (ⓘ), \circledj (ⓙ), \circledk (ⓚ), \circledl (ⓛ), \circledm (ⓜ), \circledn (ⓝ), \circlednine (⑨), \circledo (ⓞ), \circledone (①), \circledownarrow (⧬), \circledp (ⓟ), \circledparallel (⦷), \circledq (ⓠ), \circledr (ⓡ), \circledrightdot (⚆), \circleds (ⓢ), \circledsanseight (➇), \circledsansfive (➄), \circledsansfour (➃), \circledsansnine (➈), \circledsansone (➀), \circledsansseven (➆), \circledsanssix (➅), \circledsansten (➉), \circledsansthree (➂), \circledsanstwo (➁), \circledseven (⑦), \circledsix (⑥), \circledstar (✪), \circledt (ⓣ), \circledthree (③), \circledtwo (②), \circledtwodots (⚇), \circledu (ⓤ), \circledv (ⓥ), \circledvert (⦶), \circledw (ⓦ), \circledwhitebullet (⦾), \circledx (ⓧ), \circledy (ⓨ), \circledz (ⓩ), \circledzero (⓪), \circlehbar (⦵), \circlelefthalfblack (◐), \circlellquad (◵), \circlelrquad (◶), \circleonleftarrow (⬰), \circleonrightarrow (⇴), \circlerighthalfblack (◑), \circletophalfblack (◓), \circleulquad (◴), \circleurquad (◷), \circleurquadblack (◔), \circlevertfill (◍), \cirmid (⫯), \cirscir (⧂), \clangle (〈), \closedvarcap (⩍), \closedvarcup (⩌), \closedvarcupsmashprod (⩐), \closure (⁐), \cloverleaf (⌘), \clubsuit (♣), \colon (:), \colon (∶), \coloneq (≔), \commaminus (⨩), \complement (∁), \concavediamond (⟡), \concavediamondtickleft (⟢), \concavediamondtickright (⟣), \cong (≅), \congdot (⩭), \conictaper (⌲), \conjunction (☌), \coprod (∐), \cprime (ʹ), \crangle (〉), \csub (⫏), \csube (⫑), \csup (⫐), \csupe (⫒), \cuberoot (∛), \cup (∪), \cupdot (⊍), \cupleftarrow (⊌), \cupvee (⩅), \curlyeqprec (⋞), \curlyeqsucc (⋟), \curlyvee (⋎), \curlywedge (⋏), \curvearrowleft (↶), \curvearrowleftplus (⤽), \curvearrowright (↷), \curvearrowrightminus (⤼), \cwcirclearrow (⥁), \cwgapcirclearrow (⟳), \cwopencirclearrow (↻), \cwrightarcarrow (⤸), \cwundercurvearrow (⤾), \cylcty (⌭). + +\dag (†), \dagger (†), \daleth (ℸ), \danger (☡), \dashV (⫣), \dashVdash (⟛), \dashcolon (∹), \dashleftharpoondown (⥫), \dashrightharpoondown (⥭), \dashv (⊣), \dbkarow (⤏), \ddag (‡), \ddagger (‡), \ddots (⋱), \ddotseq (⩷), \delta (δ), \dh (ð), \diameter (⌀), \diamond (◇), \diamondbotblack (⬙), \diamondcdot (⟐), \diamondleftarrow (⤝), \diamondleftarrowbar (⤟), \diamondleftblack (⬖), \diamondrightblack (⬗), \diamondsuit (♢), \diamondtopblack (⬘), \dicei (⚀), \diceii (⚁), \diceiii (⚂), \diceiv (⚃), \dicev (⚄), \dicevi (⚅), \digamma (ϝ), \dingasterisk (✽), \dircurrent (⎓), \disin (⋲), \div (÷), \divideontimes (⋇), \dj (đ), \dlcrop (⌍), \doteq (≐), \dotequiv (⩧), \dotminus (∸), \dotplus (∔), \dots (…), \dotsim (⩪), \dotsminusdots (∺), \dottedcircle (◌), \dottedsquare (⬚), \dottimes (⨰), \doublebarvee (⩢), \doublebarwedge (⩞), \doubleplus (⧺), \downarrow (↓), \downarrowbar (⤓), \downarrowbarred (⤈), \downdasharrow (⇣), \downdownarrows (⇊), \downfishtail (⥿), \downharpoonleft (⇃), \downharpoonleftbar (⥙), \downharpoonright (⇂), \downharpoonrightbar (⥕), \downharpoonsleftright (⥥), \downrightcurvedarrow (⤵), \downtriangleleftblack (⧨), \downtrianglerightblack (⧩), \downuparrows (⇵), \downupharpoonsleftright (⥯), \downwhitearrow (⇩), \downzigzagarrow (↯), \dprime (″), \draftingarrow (➛), \drbkarow (⤐), \drcrop (⌌), \dsol (⧶), \dsub (⩤), \dualmap (⧟). + +\earth (♁), \egsdot (⪘), \eighthnote (♪), \elinters (⏧), \ell (ℓ), \elsdot (⪗), \emdash (—), \emptyset (∅), \emptysetoarr (⦳), \emptysetoarrl (⦴), \emptysetobar (⦱), \emptysetocirc (⦲), \endash (–), \enleadertwodots (‥), \envelope (✉), \eparsl (⧣), \epsilon (ϵ), \eqcirc (≖), \eqcolon (≕), \eqdef (≝), \eqdot (⩦), \eqeq (⩵), \eqeqeq (⩶), \eqgtr (⋝), \eqless (⋜), \eqqgtr (⪚), \eqqless (⪙), \eqqplus (⩱), \eqqsim (⩳), \eqqslantgtr (⪜), \eqqslantless (⪛), \eqsim (≂), \eqslantgtr (⪖), \eqslantless (⪕), \equalleftarrow (⭀), \equalparallel (⋕), \equalrightarrow (⥱), \equiv (≡), \equivDD (⩸), \equivVert (⩨), \equivVvert (⩩), \eqvparsl (⧥), \errbarblackcircle (⧳), \errbarblackdiamond (⧱), \errbarblacksquare (⧯), \errbarcircle (⧲), \errbardiamond (⧰), \errbarsquare (⧮), \eta (η), \euro (€), \exists (∃). + +\fallingdotseq (≒), \fbowtie (⧓), \fcmp (⨾), \fdiagovnearrow (⤯), \fdiagovrdiag (⤬), \female (♀), \figdash (‒), \fint (⨏), \fisheye (◉), \flat (♭), \fltns (⏥), \forall (∀), \forks (⫝̸), \forksnot (⫝), \forkv (⫙), \fourthroot (∜), \fourvdots (⦙), \fracfiveeighths (⅝), \fracfivesixths (⅚), \fracfourfifths (⅘), \fraconeeighth (⅛), \fraconefifth (⅕), \fraconesixth (⅙), \fraconethird (⅓), \fracseveneights (⅞), \fracslash (⁄), \fracthreeeighths (⅜), \fracthreefifths (⅗), \fractwofifths (⅖), \fractwothirds (⅔), \frakC (ℭ), \frakH (ℌ), \frakZ (ℨ), \frown (⌢), \frownie (☹), \fullouterjoin (⟗). + +\gamma (γ), \ge (≥), \geq (≥), \geqq (≧), \geqslant (⩾), \gescc (⪩), \gesdot (⪀), \gesdoto (⪂), \gesdotol (⪄), \gesles (⪔), \gets (←), \gg (≫), \ggg (⋙), \gggnest (⫸), \gimel (ℷ), \glE (⪒), \gla (⪥), \gleichstark (⧦), \glj (⪤), \gnapprox (⪊), \gneq (⪈), \gneqq (≩), \gnsim (⋧), \greater (>), \gsime (⪎), \gsiml (⪐), \gtcc (⪧), \gtcir (⩺), \gtlpar (⦠), \gtquest (⩼), \gtrapprox (⪆), \gtrarr (⥸), \gtrdot (⋗), \gtreqless (⋛), \gtreqqless (⪌), \gtrless (≷), \gtrsim (≳), \guillemotleft («), \guillemotright (»), \guilsinglleft (‹), \guilsinglright (›). + +\harrowextender (⎯), \hatapprox (⩯), \hbar (ℏ), \heartsuit (♡), \hermitmatrix (⊹), \hexagon (⎔), \hexagonblack (⬣), \hiraganano (の), \hknearrow (⤤), \hknwarrow (⤣), \hksearow (⤥), \hkswarow (⤦), \hookleftarrow (↩), \hookrightarrow (↪), \horizbar (―), \hourglass (⧖), \house (⌂), \hrectangle (▭), \hrectangleblack (▬), \hslash (ℏ), \hyphenbullet (⁃), \hzigzag (〰). + +\iiiint (⨌), \iiint (∭), \iinfin (⧜), \iint (∬), \imageof (⊷), \in (∈), \incare (℅), \increment (∆), \infty (∞), \int (∫), \intBar (⨎), \intbar (⨍), \intbottom (⌡), \intcap (⨙), \intclockwise (∱), \intcup (⨚), \intercal (⊺), \interleave (⫴), \intextender (⎮), \intlharhk (⨗), \intprod (⨼), \intprodr (⨽), \inttop (⌠), \intx (⨘), \inversebullet (◘), \inversewhitecircle (◙), \invnot (⌐), \invwhitelowerhalfcircle (◛), \invwhiteupperhalfcircle (◚), \iota (ι), \ipasupgamma (ˠ), \ipasupl (ˡ), \ipasuprerglotstpp (ˤ), \ipasups (ˢ), \ipasupx (ˣ), \ipaunaspirated (˭), \ipavoicing (ˬ), \isinE (⋹), \isindot (⋵), \isinobar (⋷), \isins (⋴), \isinvb (⋸), \itBbbD (ⅅ), \itBbbd (ⅆ), \itBbbe (ⅇ), \itBbbi (ⅈ), \itBbbj (ⅉ). + +\jupiter (♃), \kappa (κ), \kernelcontraction (∻), \koppa (ϟ). + +\l (ł), \lAngle (⟪), \lBrace (⦃), \lBrack (⟦), \lParen (⦅), \lambda (λ), \lambdabar (ƛ), \langle (⟨), \langledot (⦑), \laplac (⧠), \lasp (ʽ), \lat (⪫), \late (⪭), \lbag (⟅), \lblkbrbrak (⦗), \lbrace (@{), \lbracelend (⎩), \lbracemid (⎨), \lbraceuend (⎧), \lbrack ([), \lbrackextender (⎢), \lbracklend (⎣), \lbracklltick (⦏), \lbrackubar (⦋), \lbrackuend (⎡), \lbrackultick (⦍), \lbrbrak (❲), \lceil (⌈), \lcurvyangle (⧼), \ldasharrhead (⇠), \le (≤), \leadsto (↝), \leftarrow (←), \leftarrowapprox (⭊), \leftarrowbackapprox (⭂), \leftarrowbsimilar (⭋), \leftarrowless (⥷), \leftarrowonoplus (⬲), \leftarrowplus (⥆), \leftarrowshortrightarrow (⥃), \leftarrowsimilar (⥳), \leftarrowsubset (⥺), \leftarrowtail (↢), \leftarrowtriangle (⇽), \leftarrowx (⬾), \leftbkarrow (⤌), \leftcurvedarrow (⬿), \leftdasharrow (⇠), \leftdasharrowhead (⇡), \leftdbkarrow (⤎), \leftdbltail (⤛), \leftdotarrow (⬸), \leftdowncurvedarrow (⤶), \leftfishtail (⥼), \leftharpoondown (↽), \leftharpoondownbar (⥞), \leftharpoonsupdown (⥢), \leftharpoonup (↼), \leftharpoonupbar (⥚), \leftharpoonupdash (⥪), \leftleftarrows (⇇), \leftmoon (☾), \leftouterjoin (⟕), \leftrightarrow (↔), \leftrightarrowcircle (⥈), \leftrightarrows (⇆), \leftrightarrowtriangle (⇿), \leftrightharpoondowndown (⥐), \leftrightharpoondownup (⥋), \leftrightharpoons (⇋), \leftrightharpoonsdown (⥧), \leftrightharpoonsup (⥦), \leftrightharpoonupdown (⥊), \leftrightharpoonupup (⥎), \leftrightsquigarrow (↭), \leftsquigarrow (↜), \leftsquigarrow (⇜), \lefttail (⤙), \leftthreearrows (⬱), \leftthreetimes (⋋), \leftwhitearrow (⇦), \leq (≤), \leqq (≦), \leqqslant (⫹), \leqqslant (⫺), \leqslant (⩽), \lescc (⪨), \lesdot (⩿), \lesdoto (⪁), \lesdotor (⪃), \lesges (⪓), \less (<), \lessapprox (⪅), \lessdot (⋖), \lesseqgtr (⋚), \lesseqqgtr (⪋), \lessgtr (≶), \lesssim (≲), \lfbowtie (⧑), \lfloor (⌊), \lftimes (⧔), \lgE (⪑), \lgblkcircle (⬤), \lgblksquare (⬛), \lgwhtcircle (◯), \lgwhtsquare (⬜), \lhd (⊲), \linefeed (↴), \ll (≪), \llangle (⦉), \llarc (◟), \llblacktriangle (◣), \llcorner (⌞), \lll (⋘), \lllnest (⫷), \llparenthesis (⦇), \lltriangle (◺), \lmoustache (⎰), \lnapprox (⪉), \lneq (⪇), \lneqq (≨), \lnsim (⋦), \longdashv (⟞), \longdivision (⟌), \longleftarrow (⟵), \longleftrightarrow (⟷), \longleftsquigarrow (⬳), \longmapsfrom (⟻), \longmapsto (⟼), \longrightarrow (⟶), \longrightsquigarrow (⟿), \looparrowleft (↫), \looparrowright (↬), \lowint (⨜), \lozenge (◊), \lozengeminus (⟠), \lparenextender (⎜), \lparenlend (⎝), \lparenless (⦓), \lparenuend (⎛), \lq (‘), \lrarc (◞), \lrblacktriangle (◢), \lrcorner (⌟), \lrtriangle (◿), \lrtriangleeq (⧡), \lsime (⪍), \lsimg (⪏), \lsqhook (⫍), \ltcc (⪦), \ltcir (⩹), \ltimes (⋉), \ltlarr (⥶), \ltquest (⩻), \ltrivb (⧏), \lvboxline (⎸), \lvzigzag (⧘). + +\male (♂), \maltese (✠), \mapsdown (↧), \mapsfrom (↤), \mapsto (↦), \mapsup (↥), \mdblkdiamond (⬥), \mdblklozenge (⬧), \mdblkrcl (⚫), \mdblksquare (◼), \mdlgblkcircle (●), \mdlgblkdiamond (◆), \mdlgblklozenge (⧫), \mdlgblksquare (■), \mdlgwhtcircle (○), \mdlgwhtdiamond (◇), \mdlgwhtsquare (□), \mdsmblkcircle (⦁), \mdsmblksquare (◾), \mdsmwhtcircl (⚬), \mdsmwhtsquare (◽), \mdwhtcircl (⚪), \mdwhtdiamond (⬦), \mdwhtlozenge (⬨), \mdwhtsquare (◻), \measangledltosw (⦯), \measangledrtose (⦮), \measangleldtosw (⦫), \measanglelutonw (⦩), \measanglerdtose (⦪), \measanglerutone (⦨), \measangleultonw (⦭), \measangleurtone (⦬), \measeq (≞), \measuredangle (∡), \measuredangleleft (⦛), \measuredrightangle (⊾), \medblackstar (⭑), \medmathspace ( ), \medwhitestar (⭐), \mercury (☿), \mho (℧), \mid (∣), \midbarvee (⩝), \midbarwedge (⩜), \midcir (⫰), \minus (−), \minusdot (⨪), \minusfdots (⨫), \minusrdots (⨬), \mlcp (⫛), \models (⊧), \mp (∓), \mu (μ), \multimap (⊸), \multimapinv (⟜). + +\nHdownarrow (⇟), \nHuparrow (⇞), \nLeftarrow (⇍), \nLeftrightarrow (⇎), \nRightarrow (⇏), \nVDash (⊯), \nVdash (⊮), \nVleftarrow (⇺), \nVleftarrowtail (⬺), \nVleftrightarrow (⇼), \nVrightarrow (⇻), \nVrightarrowtail (⤕), \nVtwoheadleftarrow (⬵), \nVtwoheadleftarrowtail (⬽), \nVtwoheadrightarrow (⤁), \nVtwoheadrightarrowtail (⤘), \nabla (∇), \napprox (≉), \nasymp (≭), \natural (♮), \ncong (≇), \ne (≠), \nearrow (↗), \neg (¬), \neovnwarrow (⤱), \neovsearrow (⤮), \neptune (♆), \neq (≠), \nequiv (≢), \neswarrow (⤢), \neuter (⚲), \nexists (∄), \ng (ŋ), \ngeq (≱), \ngtr (≯), \ngtrless (≹), \ngtrsim (≵), \nhVvert (⫵), \nhpar (⫲), \ni (∋), \niobar (⋾), \nis (⋼), \nisd (⋺), \nleftarrow (↚), \nleftrightarrow (↮), \nleq (≰), \nless (≮), \nlessgtr (≸), \nlesssim (≴), \nmid (∤), \nni (∌), \nobreakhyphen (‑), \notin (∉), \nparallel (∦), \npolint (⨔), \nprec (⊀), \npreccurlyeq (⋠), \nrightarrow (↛), \nsim (≁), \nsime (≄), \nsqsubseteq (⋢), \nsqsupseteq (⋣), \nsubset (⊄), \nsubseteq (⊈), \nsucc (⊁), \nsucccurlyeq (⋡), \nsupset (⊅), \nsupseteq (⊉), \ntriangleleft (⋪), \ntrianglelefteq (⋬), \ntriangleright (⋫), \ntrianglerighteq (⋭), \nu (ν), \nvDash (⊭), \nvLeftarrow (⤂), \nvLeftrightarrow (⤄), \nvRightarrow (⤃), \nvdash (⊬), \nvinfty (⧞), \nvleftarrow (⇷), \nvleftarrowtail (⬹), \nvleftrightarrow (⇹), \nvrightarrow (⇸), \nvrightarrowtail (⤔), \nvtwoheadleftarrow (⬴), \nvtwoheadleftarrowtail (⬼), \nvtwoheadrightarrow (⤀), \nvtwoheadrightarrowtail (⤗), \nwarrow (↖), \nwovnearrow (⤲), \nwsearrow (⤡). + +\o (ø), \obar (⌽), \obot (⦺), \obrbrak (⏠), \obslash (⦸), \odiv (⨸), \odot (⊙), \odotslashdot (⦼), \oe (œ), \ogreaterthan (⧁), \ohorn (ơ), \oiiint (∰), \oiint (∯), \oint (∮), \ointctrclockwise (∳), \olcross (⦻), \oldKoppa (Ϙ), \oldkoppa (ϙ), \olessthan (⧀), \omega (ω), \omicron (ο), \ominus (⊖), \operp (⦹), \oplus (⊕), \opluslhrim (⨭), \oplusrhrim (⨮), \origof (⊶), \oslash (⊘), \otimes (⊗), \otimeshat (⨶), \otimeslhrim (⨴), \otimesrhrim (⨵), \overbrace (⏞), \overbracket (⎴), \overline (‾), \overparen (⏜), \owns (∋). + +\parallel (∥), \parallelogram (▱), \parallelogramblack (▰), \parsim (⫳), \partial (∂), \partialmeetcontraction (⪣), \pentagon (⬠), \pentagonblack (⬟), \perp (⟂), \perps (⫡), \phi (ϕ), \phone (☎), \pi (π), \pitchfork (⋔), \plusdot (⨥), \pluseqq (⩲), \plushat (⨣), \plussim (⨦), \plussubtwo (⨧), \plustrif (⨨), \pluto (♇), \pm (±), \pointnt (⨕), \postalmark (〒), \prec (≺), \precapprox (⪷), \preccurlyeq (≼), \preceq (⪯), \preceqq (⪳), \precnapprox (⪹), \precneq (⪱), \precneqq (⪵), \precnsim (⋨), \precsim (≾), \prime (′), \prod (∏), \profalar (⌮), \profline (⌒), \profsurf (⌓), \propto (∝), \prurel (⊰), \psi (ψ), \pullback (⟓), \pushout (⟔). + +\qprime (⁗), \quarternote (♩), \questeq (≟), \quotdblbase („), \quotdblright (‟), \quotsinglbase (‚), \quotsinglright (‛). + +\rAngle (⟫), \rBrace (⦄), \rBrack (⟧), \rParen (⦆), \rangle (⟩), \rangledot (⦒), \rangledownzigzagarrow (⍼), \rasp (ʼ), \rbag (⟆), \rblkbrbrak (⦘), \rbrace (@}), \rbracelend (⎭), \rbracemid (⎬), \rbraceuend (⎫), \rbrack (]), \rbrackextender (⎥), \rbracklend (⎦), \rbracklrtick (⦎), \rbrackubar (⦌), \rbrackuend (⎤), \rbrackurtick (⦐), \rbrbrak (❳), \rceil (⌉), \rcurvyangle (⧽), \rdiagovfdiag (⤫), \rdiagovsearrow (⤰), \recorder (⌕), \revangle (⦣), \revangleubar (⦥), \revemptyset (⦰), \revnmid (⫮), \rfbowtie (⧒), \rfloor (⌋), \rftimes (⧕), \rhd (⊳), \rho (ρ), \righarrowbsimilar (⭌), \rightangle (∟), \rightanglemdot (⦝), \rightanglesqr (⦜), \rightarrow (→), \rightarrowapprox (⥵), \rightarrowbackapprox (⭈), \rightarrowbar (⇥), \rightarrowdiamond (⤞), \rightarrowgtr (⭃), \rightarrowonoplus (⟴), \rightarrowplus (⥅), \rightarrowshortleftarrow (⥂), \rightarrowsimilar (⥴), \rightarrowsupset (⭄), \rightarrowtail (↣), \rightarrowtriangle (⇾), \rightarrowx (⥇), \rightbkarrow (⤍), \rightcurvedarrow (⤳), \rightdasharrow (⇢), \rightdbltail (⤜), \rightdotarrow (⤑), \rightdowncurvedarrow (⤷), \rightfishtail (⥽), \rightharpoondown (⇁), \rightharpoondownbar (⥗), \rightharpoonsupdown (⥤), \rightharpoonup (⇀), \rightharpoonupbar (⥓), \rightharpoonupdash (⥬), \rightimply (⥰), \rightleftarrows (⇄), \rightleftharpoons (⇌), \rightleftharpoonsdown (⥩), \rightleftharpoonsup (⥨), \rightmoon (☽), \rightouterjoin (⟖), \rightpentagon (⭔), \rightpentagonblack (⭓), \rightrightarrows (⇉), \rightsquigarrow (↝), \rightsquigarrow (⇝), \righttail (⤚), \rightthreearrows (⇶), \rightthreetimes (⋌), \rightwhitearrow (⇨), \ringplus (⨢), \risingdotseq (≓), \rmoustache (⎱), \rparenextender (⎟), \rparengtr (⦔), \rparenlend (⎠), \rparenuend (⎞), \rppolint (⨒), \rq (’), \rrangle (⦊), \rrparenthesis (⦈), \rsolbar (⧷), \rsqhook (⫎), \rsub (⩥), \rtimes (⋊), \rtriltri (⧎), \ruledelayed (⧴), \rvboxline (⎹), \rvzigzag (⧙). + +\sampi (ϡ), \sansLmirrored (⅃), \sansLturned (⅂), \saturn (♄), \scissors (✂), \scpolint (⨓), \scrB (ℬ), \scrE (ℰ), \scrF (ℱ), \scrH (ℋ), \scrI (ℐ), \scrL (ℒ), \scrM (ℳ), \scrR (ℛ), \scre (ℯ), \scrg (ℊ), \scro (ℴ), \scurel (⊱), \searrow (↘), \seovnearrow (⤭), \setminus (∖), \setminus (⧵), \sharp (♯), \shortdowntack (⫟), \shortleftarrow (←), \shortlefttack (⫞), \shortrightarrow (→), \shortrightarrowleftarrow (⥄), \shortuptack (⫠), \shuffle (⧢), \sigma (σ), \silon (υ), \silon (ϒ), \sim (∼), \simeq (≃), \simgE (⪠), \simgtr (⪞), \similarleftarrow (⭉), \similarrightarrow (⥲), \simlE (⪟), \simless (⪝), \simminussim (⩬), \simneqq (≆), \simplus (⨤), \simrdots (⩫), \sinewave (∿), \slash (∕), \smallblacktriangleleft (◂), \smallblacktriangleright (▸), \smalldiamond (⋄), \smallin (∊), \smallint (∫), \smallni (∍), \smallsetminus (∖), \smalltriangleleft (◃), \smalltriangleright (▹), \smashtimes (⨳), \smblkdiamond (⬩), \smblklozenge (⬪), \smblksquare (▪), \smeparsl (⧤), \smile (⌣), \smiley (☺), \smt (⪪), \smte (⪬), \smwhitestar (⭒), \smwhtcircle (◦), \smwhtlozenge (⬫), \smwhtsquare (▫), \spadesuit (♠), \sphericalangle (∢), \sphericalangleup (⦡), \sqcap (⊓), \sqcup (⊔), \sqint (⨖), \sqlozenge (⌑), \sqrt (√), \sqrt3 (∛), \sqrt4 (∜), \sqrtbottom (⎷), \sqsubset (⊏), \sqsubseteq (⊑), \sqsubsetneq (⋤), \sqsupset (⊐), \sqsupseteq (⊒), \sqsupsetneq (⋥), \squarecrossfill (▩), \squaregrayfill (▩), \squarehfill (▤), \squarehvfill (▦), \squareleftblack (◧), \squareleftblack (◨), \squarellblack (⬕), \squarellquad (◱), \squarelrblack (◪), \squarelrquad (◲), \squareneswfill (▨), \squarenwsefill (▧), \squareulblack (◩), \squareulquad (◰), \squareurblack (⬔), \squareurquad (◳), \squarevfill (▥), \squoval (▢), \ss (ß), \star (⋆), \stareq (≛), \sterling (£), \stigma (ϛ), \strns (⏤), \subedot (⫃), \submult (⫁), \subrarr (⥹), \subset (⊂), \subsetapprox (⫉), \subsetcirc (⟃), \subsetdot (⪽), \subseteq (⊆), \subseteqq (⫅), \subsetneq (⊊), \subsetneqq (⫋), \subsetplus (⪿), \subsim (⫇), \subsub (⫕), \subsup (⫓), \succ (≻), \succapprox (⪸), \succcurlyeq (≽), \succeq (⪰), \succeqq (⪴), \succnapprox (⪺), \succneq (⪲), \succneqq (⪶), \succnsim (⋩), \succsim (≿), \sum (∑), \sumbottom (⎳), \sumint (⨋), \sumtop (⎲), \sun (☼), \supdsub (⫘), \supedot (⫄), \suphsol (⟉), \suphsub (⫗), \suplarr (⥻), \supmult (⫂), \supn (ⁿ), \supset (⊃), \supsetapprox (⫊), \supsetcirc (⟄), \supsetdot (⪾), \supseteq (⊇), \supseteqq (⫆), \supsetneq (⊋), \supsetneqq (⫌), \supsetplus (⫀), \supsim (⫈), \supsub (⫔), \supsup (⫖), \surd (√), \swarrow (↙). + +\talloblong (⫾), \target (⌖), \tau (τ), \taurus (♉), \testhookx (ᶍ), \textAsterisks (⁑), \textacute (ˊ), \textadvanced (˖), \textain (ʿ), \textasciiacute (´), \textasciicircum (^), \textasciidieresis (¨), \textasciigrave (`), \textasciimacron (¯), \textasciitilde (~), \textasterisklow (⁎), \textbackdprime (‶), \textbackprime (‵), \textbacktrprime (‷), \textbardotlessj (ɟ), \textbardotlessjvar (ʄ), \textbarglotstop (ʡ), \textbari (ɨ), \textbarl (ƚ), \textbaro (ɵ), \textbarrevglotstop (ʢ), \textbaru (ʉ), \textbeltl (ɬ), \textbenttailyogh (ƺ), \textbreve (˘), \textbrokenbar (¦), \textbullet (•), \textbullseye (ʘ), \textcent (¢), \textcircledP (℗), \textcloseepsilon (ʚ), \textcloseomega (ɷ), \textcloserevepsilon (ɞ), \textcopyright (©), \textcrb (ƀ), \textcrh (ħ), \textcrinvglotstop (ƾ), \textcrlambda (ƛ), \textcrtwo (ƻ), \textctc (ɕ), \textctd (ȡ), \textctesh (ʆ), \textctj (ʝ), \textctl (ȴ), \textctn (ȵ), \textctt (ȶ), \textctyogh (ʓ), \textctz (ʑ), \textcurrency (¤), \textdctzlig (ʥ), \textdegree (°), \textdiscount (⁒), \textdollar ($), \textdotaccent (˙), \textdotlessj (ȷ), \textdoubleacute (˝), \textdoublebarpipe (ǂ), \textdoublepipe (ǁ), \textdprime (″), \textdptr (˅), \textdyoghlig (ʤ), \textdzlig (ʣ), \textepsilon (ɛ), \textesh (ʃ), \textestimated (℮), \textexclam (ǃ), \textexclamdown (¡), \textfishhookr (ɾ), \textflorin (ƒ), \textfranc (₣), \textgamma (ɣ), \textglotstop (ʔ), \textgrave (ˋ), \texthalflength (ˑ), \texthamza (ʾ), \texthen (ꜧ), \textheng (ꜧ), \texthooks (ᶊ), \texthookz (ᶎ), \texthtb (ɓ), \texthtc (ƈ), \texthtd (ɗ), \texthtg (ɠ), \texthth (ɦ), \texththeng (ɧ), \texthtk (ƙ), \texthtp (ƥ), \texthtq (ʠ), \texthtscg (ʛ), \texthtt (ƭ), \texthvlig (ƕ), \texthyphen (‐), \textinvglotstop (ʖ), \textinvscr (ʁ), \textiota (ɩ), \textlengthmark (ː), \textlhalfring (˓), \textlhookd (ᶁ), \textlhookk (ᶄ), \textlhookl (ᶅ), \textlhookt (ƫ), \textlhti (ɿ), \textlira (₤), \textlonglegr (ɼ), \textlongy (ʮ), \textlongy (ʯ), \textlooptoprevesh (ƪ), \textlowacute (ˏ), \textlowered (˕), \textlowgrave (ˎ), \textlowmacron (ˍ), \textlptr (˂), \textltailm (ɱ), \textltailn (ɲ), \textltilde (ɫ), \textlyoghlig (ɮ), \textmacron (ˉ), \textmu (µ), \textnumero (№), \textogonek (˛), \textohm (Ω), \textonehalf (½), \textonequarter (¼), \textonesuperior (¹), \textopeno (ɔ), \textordfeminine (ª), \textordmasculine (º), \textovercross (˟), \textoz (℥), \textpertenthousand (‱), \textperthousand (‰), \textpesetas (₧), \textphi (ɸ), \textpipe (ǀ), \textprime (′), \textprimstress (ˈ), \textqprime (⁗), \textquestiondown (¿), \textquotedbl ("), \textquotedblleft (“), \textquotedblright (”), \textraised (˔), \textraiseglotstop (ˀ), \textraiserevglotstop (ˁ), \textramshorns (ɤ), \textrecipe (℞), \textreferencemark (※), \textregistered (®), \textretracted (˗), \textreve (ɘ), \textrevepsilon (ɜ), \textrevglotstop (ʕ), \textrhalfring (˒), \textrhookrevepsilon (ɝ), \textrhookschwa (ɚ), \textrhoticity (˞), \textringaccent (˚), \textrptr (˃), \textrtaild (ɖ), \textrtaill (ɭ), \textrtailn (ɳ), \textrtailr (ɽ), \textrtails (ʂ), \textrtailt (ʈ), \textrtailz (ʐ), \textsca (ᴀ), \textscb (ʙ), \textsce (ᴇ), \textscg (ɢ), \textsch (ʜ), \textschwa (ə), \textsci (ɪ), \textscl (ʟ), \textscn (ɴ), \textscoelig (ɶ), \textscr (ʀ), \textscripta (ɑ), \textscriptg (ɡ), \textscriptv (ʋ), \textscu (ᴜ), \textscy (ʏ), \textsecstress (ˌ), \textsemicolonreversed (⁏), \textsilon (Υ), \textsmalltilde (˜), \textstretchcvar (ʗ), \textsubw (w), \textsuph (ʰ), \textsuphth (ʱ), \textsupinvscr (ʶ), \textsupj (ʲ), \textsupr (ʳ), \textsupturnr (ʴ), \textsupturnrrtail (ʵ), \textsupw (ʷ), \textsupy (ʸ), \texttctctlig (ʧ), \texttctctlig (ʨ), \textthreequarters (¾), \textthreesuperior (³), \texttrademark (™), \texttrprime (‴), \texttslig (ʦ), \textturna (ɐ), \textturncomma (ʻ), \textturnh (ɥ), \textturnk (ʞ), \textturnlonglegr (ɺ), \textturnm (ɯ), \textturnmrleg (ɰ), \textturnr (ɹ), \textturnrrtail (ɻ), \textturnscripta (ɒ), \textturnt (ʇ), \textturnv (ʌ), \textturnw (ʍ), \textturny (ʎ), \texttwosuperior (²), \textupsilon (ʊ), \textuptr (˄), \textvibyi (ʅ), \textvisiblespace (␣), \textyogh (ʒ), \th (þ), \therefore (∴), \thermod (⧧), \theta (θ), \thickapprox (≈), \thicksim (∼), \threedangle (⟀), \threedotcolon (⫶), \tieconcat (⁀), \tieinfty (⧝), \times (×), \timesbar (⨱), \tminus (⧿), \to (→), \toea (⤨), \tona (⤧), \tonebarextrahigh (˥), \tonebarextralow (˩), \tonebarhigh (˦), \tonebarlow (˨), \tonebarmid (˧), \top (⊤), \topbot (⌶), \topcir (⫱), \topfork (⫚), \topsemicircle (◠), \tosa (⤩), \towa (⤪), \tplus (⧾), \trapezium (⏢), \trianglecdot (◬), \triangledown (▿), \triangleexclam (⚠), \triangleleft (◁), \triangleleftblack (◭), \trianglelefteq (⊴), \triangleminus (⨺), \triangleodot (⧊), \triangleplus (⨹), \triangleq (≜), \triangleright (▷), \trianglerightblack (◮), \trianglerighteq (⊵), \triangles (⧌), \triangleserifs (⧍), \triangletimes (⨻), \triangleubar (⧋), \tripleplus (⧻), \trprime (‴), \turnangle (⦢), \turnediota (℩), \turnednot (⌙), \twocaps (⩋), \twocups (⩊), \twoheaddownarrow (↡), \twoheadleftarrow (↞), \twoheadleftarrowtail (⬻), \twoheadleftdbkarrow (⬷), \twoheadmapsfrom (⬶), \twoheadmapsto (⤅), \twoheadrightarrow (↠), \twoheadrightarrowtail (⤖), \twoheaduparrow (↟), \twoheaduparrowcircle (⥉), \twolowline (‗), \twonotes (♫), \typecolon (⦂). + +\ubrbrak (⏡), \uhorn (ư), \ularc (◜), \ulblacktriangle (◤), \ulcorner (⌜), \ulcrop (⌏), \ultriangle (◸), \uminus (⩁), \underbrace (⏟), \underbracket (⎵), \underparen (⏝), \unlhd (⊴), \unrhd (⊵), \upand (⅋), \uparrow (↑), \uparrowbarred (⤉), \uparrowoncircle (⦽), \updasharrow (⇢), \updownarrow (↕), \updownarrowbar (↨), \updownarrows (⇅), \updownharpoonleftleft (⥑), \updownharpoonleftright (⥍), \updownharpoonrightleft (⥌), \updownharpoonrightright (⥏), \updownharpoonsleftright (⥮), \upfishtail (⥾), \upharpoonleft (↿), \upharpoonleftbar (⥠), \upharpoonright (↾), \upharpoonrightbar (⥜), \upharpoonsleftright (⥣), \upin (⟒), \upint (⨛), \uplus (⊎), \uprightcurvearrow (⤴), \upuparrows (⇈), \upwhitearrow (⇧), \urarc (◝), \urblacktriangle (◥), \urcorner (⌝), \urcrop (⌎), \urtriangle (◹). + +\v (ˇ), \vBar (⫨), \vBarv (⫩), \vDash (⊨), \vDdash (⫢), \varTheta (ϴ), \varVdash (⫦), \varbarwedge (⌅), \varbeta (ϐ), \varclubsuit (♧), \vardiamondsuit (♦), \vardoublebarwedge (⌆), \varepsilon (ε), \varheartsuit (♥), \varhexagon (⬡), \varhexagonblack (⬢), \varhexagonlrbonds (⌬), \varin (∈), \varisinobar (⋶), \varisins (⋳), \varkappa (ϰ), \varlrtriangle (⊿), \varni (∋), \varniobar (⋽), \varnis (⋻), \varnothing (∅), \varointclockwise (∲), \varphi (φ), \varpi (ϖ), \varpropto (∝), \varrho (ϱ), \varrowextender (⏐), \varsigma (ς), \varspadesuit (♤), \varstar (✶), \vartheta (ϑ), \vartriangle (▵), \vartriangleleft (⊲), \vartriangleright (⊳), \varveebar (⩡), \vbraceextender (⎪), \vbrtri (⧐), \vdash (⊢), \vdots (⋮), \vectimes (⨯), \vee (∨), \veebar (⊻), \veedot (⟇), \veedoublebar (⩣), \veeeq (≚), \veemidvert (⩛), \veeodot (⩒), \veeonvee (⩖), \veeonwedge (⩙), \vert (|), \viewdata (⌗), \vlongdash (⟝), \vrectangle (▯), \vrectangleblack (▮), \vysmlblksquare (⬝), \vysmlwhtsquare (⬞), \vzigzag (⦚). + +\watchicon (⌚), \wedge (∧), \wedgebar (⩟), \wedgedot (⟑), \wedgedoublebar (⩠), \wedgemidvert (⩚), \wedgeodot (⩑), \wedgeonwedge (⩕), \wedgeq (≙), \whitearrowupfrombar (⇪), \whiteinwhitetriangle (⟁), \whitepointerleft (◅), \whitepointerright (▻), \whitesquaretickleft (⟤), \whitesquaretickright (⟥), \whthorzoval (⬭), \whtvertoval (⬯), \wideangledown (⦦), \wideangleup (⦧), \wp (℘), \wr (≀). + +\xbsol (⧹), \xi (ξ), \xsol (⧸), \yen (¥), \zeta (ζ), \zpipe (⨠), + +IF ANYBODY WILL CHECK WHETHER ALL NAMES CORRESPOND TO RIGHT TEX SYMBOLS I SHALL APPRECIATE IT GREATLY. + diff --git a/texinfo/appendix_ru.texi b/texinfo/appendix_ru.texi new file mode 100644 index 0000000..16c4c34 --- /dev/null +++ b/texinfo/appendix_ru.texi @@ -0,0 +1,67 @@ +@nav{} + +Ниже приведен полный список TeX-их команд, распознаваемых MathGL. Если команда была не распознана, то она будет напечатана как есть с пропущенным символом @samp{\}. Например, @samp{\#} выдаст ``#'', @samp{\\} выдаст ``\'', @samp{\qq} выдаст ``qq''. + +@strong{Положение символов}: _, ^, @@. + +@strong{Стиль текста}: \big, \b, \textbf, \i, \textit, \bi, \r, \textrm, \a, \overline, \u, \underline, \w, \wire, #, \color[wkrgbcymhRGBCYMHWlenupqLENUPQ] + +@strong{Корни}: \sqrt, \sqrt3, \sqrt4 + +@strong{Дроби}: \frac, \stack, \overset, \underset, \stackr, \stackl + +@strong{Акценты}: \hat, \tilde, \dot, \ddot, \dddot, \ddddot, \acute, \check, \grave, \vec, \bar, \breve + +@strong{Специальные символы}: +\# (#), \% (%), \& (&), \^ (^). + +\AA (Å), \AE (Æ), \APLboxquestion (⍰), \APLboxupcaret (⍓), \APLnotbackslash (⍀), \APLnotslash (⌿), \Alpha (Α), \And (&), \Angstrom (Å), \Barv (⫧), \BbbC (ℂ), \BbbGamma (ℾ), \BbbH (ℍ), \BbbN (ℕ), \BbbP (ℙ), \BbbPi (ℿ), \BbbQ (ℚ), \BbbR (ℝ), \BbbZ (ℤ), \Bbbgamma (ℽ), \Bbbpi (ℼ), \Bbbsum (⅀), \Beta (Β), \Bumpeq (≎), \Cap (⋒), \Chi (Χ), \Colon (∷), \Coloneq (⩴), \Cup (⋓), \DDownarrow (⟱), \DH (Ð), \DJ (Đ), \DashV (⫥), \DashVDash (⟚), \Dashv (⫤), \Ddownarrow (⤋), \Delta (Δ), \Digamma (Ϝ), \Doteq (≑), \Downarrow (⇓), \Epsilon (Ε), \Equiv (≣), \Eta (Η), \Eulerconst (ℇ), \Exclam (‼), \Finv (Ⅎ), \Game (⅁), \Gamma (Γ), \Gt (⪢), \Hermaphrodite (⚥), \Im (ℑ), \Iota (Ι), \Kappa (Κ), \Koppa (Ϟ), \L (Ł), \LLeftarrow (⭅), \Lambda (Λ), \Lbrbrak (⟬), \Ldsh (↲), \Leftarrow (⇐), \Leftrightarrow (⇔), \Lleftarrow (⇚), \Longleftarrow (⟸), \Longleftrightarrow (⟺), \Longmapsfrom (⟽), \Longmapsto (⟾), \Longrightarrow (⟹), \Lparengtr (⦕), \Lsh (↰), \Lt (⪡), \Lvzigzag (⧚), \Mapsfrom (⤆), \Mapsto (⤇), \Mu (Μ), \NG (Ŋ), \Nearrow (⇗), \Not (⫬), \Nu (Ν), \Nwarrow (⇖), \O (Ø), \OE (Œ), \Ohorn (Ơ), \Omega (Ω), \Omicron (Ο), \Otimes (⨷), \P (¶), \Phi (Φ), \Pi (Π), \Planckconst (ℎ), \Prec (⪻), \PropertyLine (⅊), \Psi (Ψ), \QED (∎), \Question (⁇), \RRightarrow (⭆), \Rbrbrak (⟭), \Rdsh (↳), \Re (ℜ), \Rho (Ρ), \Rightarrow (⇒), \Rparenless (⦖), \Rrightarrow (⇛), \Rsh (↱), \Rvzigzag (⧛), \S (§), \Sc (⪼), \Searrow (⇘), \Sigma (Σ), \Sqcap (⩎), \Sqcup (⩏), \Stigma (Ϛ), \Subset (⋐), \Supset (⋑), \Swarrow (⇙), \TH (Þ), \Tau (Τ), \Theta (Θ), \UUparrow (⟰), \Uhorn (Ư), \Uparrow (⇑), \Updownarrow (⇕), \Uuparrow (⤊), \VDash (⊫), \Vbar (⫫), \Vdash (⊩), \Vee (⩔), \Vert (‖), \Vvdash (⊪), \Vvert (⦀), \Wedge (⩓), \XBox (☒), \Xi (Ξ), \Yup (⅄), \Zbar (Ƶ), \Zeta (Ζ). + +\aa (å), \ac (∾), \accurrent (⏦), \acidfree (♾), \acwcirclearrow (⥀), \acwgapcirclearrow (⟲), \acwleftarcarrow (⤹), \acwopencirclearrow (↺), \acwoverarcarrow (⤺), \acwundercurvearrow (⤻), \adots (⋰), \ae (æ), \aleph (ℵ), \alpha (α), \amalg (⨿), \angdnr (⦟), \angle (∠), \angles (⦞), \angleubar (⦤), \approx (≈), \approxeq (≊), \approxeqq (⩰), \approxident (≋), \arceq (≘), \aries (♈), \assert (⊦), \ast (∗), \asteq (⩮), \astrosun (☉), \asymp (≍), \awint (⨑). + +\bNot (⫭), \backcong (≌), \backdprime (‶), \backepsilon (϶), \backprime (‵), \backsim (∽), \backsimeq (⋍), \backslash (\), \backtrprime (‷), \bagmember (⋿), \barV (⫪), \barcap (⩃), \barcup (⩂), \bardownharpoonleft (⥡), \bardownharpoonright (⥝), \barleftarrow (⇤), \barleftarrowrightarrowbar (↹), \barleftharpoondown (⥖), \barleftharpoonup (⥒), \barovernorthwestarrow (↸), \barrightarrowdiamond (⤠), \barrightharpoondown (⥟), \barrightharpoonup (⥛), \baruparrow (⤒), \barupharpoonleft (⥘), \barupharpoonright (⥔), \barvee (⊽), \barwedge (⊼), \bbrktbrk (⎶), \bdHrule (═), \bdVrule (║), \bdbVbH (╬), \bdbVbh (╫), \bdbVlH (╣), \bdbVlh (╢), \bdbVrH (╠), \bdbVrh (╟), \bdbvbH (╪), \bdbvbh (┼), \bdbvlH (╡), \bdbvlh (┤), \bdbvrH (╞), \bdbvrh (├), \bddVbH (╦), \bddVbh (╥), \bddVlH (╗), \bddVlh (╖), \bddVrH (╔), \bddVrh (╓), \bddvbH (╤), \bddvbh (┬), \bddvlH (╕), \bddvlh (┐), \bddvrH (╒), \bddvrh (┌), \bdhrule (─), \bdnesw (╱), \bdnwse (╲), \bdquadhdash (┈), \bdquadvdash (┊), \bdtriplevdash (┆), \bduVbH (╩), \bduVbh (╨), \bduVlH (╝), \bduVlh (╜), \bduVrH (╚), \bduVrh (╙), \bduvbH (╧), \bduvbh (┴), \bduvlH (╛), \bduvlh (┘), \bduvrH (╘), \bduvrh (└), \bdvrule (│), \because (∵), \benzenr (⏣), \beta (β), \beth (ℶ), \between (≬), \bigblacktriangledown (▼), \bigblacktriangleup (▲), \bigbot (⟘), \bigcap (⋂), \bigcup (⋃), \bigslopedvee (⩗), \bigslopedwedge (⩘), \bigstar (★), \bigtop (⟙), \bigtriangledown (▽), \bigtriangleup (△), \bigvee (⋁), \bigwedge (⋀), \bigwhitestar (☆), \blackcircledownarrow (⧭), \blackcircledrightdot (⚈), \blackcircledsanseight (➑), \blackcircledsansfive (➎), \blackcircledsansfour (➍), \blackcircledsansnine (➒), \blackcircledsansone (➊), \blackcircledsansseven (➐), \blackcircledsanssix (➏), \blackcircledsansten (➓), \blackcircledsansthree (➌), \blackcircledsanstwo (➋), \blackcircledtwodots (⚉), \blackcircleulquadwhite (◕), \blackdiamonddownarrow (⧪), \blackhourglass (⧗), \blackinwhitediamond (◈), \blackinwhitesquare (▣), \blacklefthalfcircle (◖), \blackpointerleft (◄), \blackpointerright (►), \blackrighthalfcircle (◗), \blacksmiley (☻), \blacktriangle (▴), \blacktriangledown (▾), \blacktriangleleft (◀), \blacktriangleright (▶), \blkhorzoval (⬬), \blkvertoval (⬮), \blockfull (█), \blockhalfshaded (▒), \blocklefthalf (▌), \blocklowhalf (▄), \blockqtrshaded (░), \blockrighthalf (▐), \blockthreeqtrshaded (▓), \blockuphalf (▀), \bot (⊥), \botsemicircle (◡), \bowtie (⋈), \box (◻), \boxast (⧆), \boxbar (◫), \boxbox (⧈), \boxbslash (⧅), \boxcircle (⧇), \boxdiag (⧄), \boxdot (⊡), \boxminus (⊟), \boxonbox (⧉), \boxplus (⊞), \boxtimes (⊠), \bsimilarleftarrow (⭁), \bsimilarrightarrow (⭇), \bsolhsub (⟈), \btimes (⨲), \bullet (∙), \bullseye (◎), \bumpeq (≏), \bumpeqq (⪮). + +\calB (ℬ), \calE (ℰ), \calF (ℱ), \calH (ℋ), \calM (ℳ), \calR (ℛ), \cap (∩), \capdot (⩀), \capwedge (⩄), \caretinsert (‸), \carreturn (⏎), \carriagereturn (↵), \ccwundercurvearrow (⤿), \cdot (⋅), \cdotp (·), \cdots (⋯), \cdprime (ʺ), \checkmark (✓), \chi (χ), \cirE (⧃), \cirbot (⟟), \circ (∘), \circeq (≗), \circfint (⨐), \circlebottomhalfblack (◒), \circledA (Ⓐ), \circledB (Ⓑ), \circledC (Ⓒ), \circledD (Ⓓ), \circledE (Ⓔ), \circledF (Ⓕ), \circledG (Ⓖ), \circledH (Ⓗ), \circledI (Ⓘ), \circledJ (Ⓙ), \circledK (Ⓚ), \circledL (Ⓛ), \circledM (Ⓜ), \circledN (Ⓝ), \circledO (Ⓞ), \circledP (Ⓟ), \circledQ (Ⓠ), \circledR (Ⓡ), \circledS (Ⓢ), \circledT (Ⓣ), \circledU (Ⓤ), \circledV (Ⓥ), \circledW (Ⓦ), \circledX (Ⓧ), \circledY (Ⓨ), \circledZ (Ⓩ), \circleda (ⓐ), \circledast (⊛), \circledb (ⓑ), \circledbullet (⦿), \circledc (ⓒ), \circledcirc (⊚), \circledd (ⓓ), \circleddash (⊝), \circlede (ⓔ), \circledeight (⑧), \circledequal (⊜), \circledf (ⓕ), \circledfive (⑤), \circledfour (④), \circledg (ⓖ), \circledh (ⓗ), \circledi (ⓘ), \circledj (ⓙ), \circledk (ⓚ), \circledl (ⓛ), \circledm (ⓜ), \circledn (ⓝ), \circlednine (⑨), \circledo (ⓞ), \circledone (①), \circledownarrow (⧬), \circledp (ⓟ), \circledparallel (⦷), \circledq (ⓠ), \circledr (ⓡ), \circledrightdot (⚆), \circleds (ⓢ), \circledsanseight (➇), \circledsansfive (➄), \circledsansfour (➃), \circledsansnine (➈), \circledsansone (➀), \circledsansseven (➆), \circledsanssix (➅), \circledsansten (➉), \circledsansthree (➂), \circledsanstwo (➁), \circledseven (⑦), \circledsix (⑥), \circledstar (✪), \circledt (ⓣ), \circledthree (③), \circledtwo (②), \circledtwodots (⚇), \circledu (ⓤ), \circledv (ⓥ), \circledvert (⦶), \circledw (ⓦ), \circledwhitebullet (⦾), \circledx (ⓧ), \circledy (ⓨ), \circledz (ⓩ), \circledzero (⓪), \circlehbar (⦵), \circlelefthalfblack (◐), \circlellquad (◵), \circlelrquad (◶), \circleonleftarrow (⬰), \circleonrightarrow (⇴), \circlerighthalfblack (◑), \circletophalfblack (◓), \circleulquad (◴), \circleurquad (◷), \circleurquadblack (◔), \circlevertfill (◍), \cirmid (⫯), \cirscir (⧂), \clangle (〈), \closedvarcap (⩍), \closedvarcup (⩌), \closedvarcupsmashprod (⩐), \closure (⁐), \cloverleaf (⌘), \clubsuit (♣), \colon (:), \colon (∶), \coloneq (≔), \commaminus (⨩), \complement (∁), \concavediamond (⟡), \concavediamondtickleft (⟢), \concavediamondtickright (⟣), \cong (≅), \congdot (⩭), \conictaper (⌲), \conjunction (☌), \coprod (∐), \cprime (ʹ), \crangle (〉), \csub (⫏), \csube (⫑), \csup (⫐), \csupe (⫒), \cuberoot (∛), \cup (∪), \cupdot (⊍), \cupleftarrow (⊌), \cupvee (⩅), \curlyeqprec (⋞), \curlyeqsucc (⋟), \curlyvee (⋎), \curlywedge (⋏), \curvearrowleft (↶), \curvearrowleftplus (⤽), \curvearrowright (↷), \curvearrowrightminus (⤼), \cwcirclearrow (⥁), \cwgapcirclearrow (⟳), \cwopencirclearrow (↻), \cwrightarcarrow (⤸), \cwundercurvearrow (⤾), \cylcty (⌭). + +\dag (†), \dagger (†), \daleth (ℸ), \danger (☡), \dashV (⫣), \dashVdash (⟛), \dashcolon (∹), \dashleftharpoondown (⥫), \dashrightharpoondown (⥭), \dashv (⊣), \dbkarow (⤏), \ddag (‡), \ddagger (‡), \ddots (⋱), \ddotseq (⩷), \delta (δ), \dh (ð), \diameter (⌀), \diamond (◇), \diamondbotblack (⬙), \diamondcdot (⟐), \diamondleftarrow (⤝), \diamondleftarrowbar (⤟), \diamondleftblack (⬖), \diamondrightblack (⬗), \diamondsuit (♢), \diamondtopblack (⬘), \dicei (⚀), \diceii (⚁), \diceiii (⚂), \diceiv (⚃), \dicev (⚄), \dicevi (⚅), \digamma (ϝ), \dingasterisk (✽), \dircurrent (⎓), \disin (⋲), \div (÷), \divideontimes (⋇), \dj (đ), \dlcrop (⌍), \doteq (≐), \dotequiv (⩧), \dotminus (∸), \dotplus (∔), \dots (…), \dotsim (⩪), \dotsminusdots (∺), \dottedcircle (◌), \dottedsquare (⬚), \dottimes (⨰), \doublebarvee (⩢), \doublebarwedge (⩞), \doubleplus (⧺), \downarrow (↓), \downarrowbar (⤓), \downarrowbarred (⤈), \downdasharrow (⇣), \downdownarrows (⇊), \downfishtail (⥿), \downharpoonleft (⇃), \downharpoonleftbar (⥙), \downharpoonright (⇂), \downharpoonrightbar (⥕), \downharpoonsleftright (⥥), \downrightcurvedarrow (⤵), \downtriangleleftblack (⧨), \downtrianglerightblack (⧩), \downuparrows (⇵), \downupharpoonsleftright (⥯), \downwhitearrow (⇩), \downzigzagarrow (↯), \dprime (″), \draftingarrow (➛), \drbkarow (⤐), \drcrop (⌌), \dsol (⧶), \dsub (⩤), \dualmap (⧟). + +\earth (♁), \egsdot (⪘), \eighthnote (♪), \elinters (⏧), \ell (ℓ), \elsdot (⪗), \emdash (—), \emptyset (∅), \emptysetoarr (⦳), \emptysetoarrl (⦴), \emptysetobar (⦱), \emptysetocirc (⦲), \endash (–), \enleadertwodots (‥), \envelope (✉), \eparsl (⧣), \epsilon (ϵ), \eqcirc (≖), \eqcolon (≕), \eqdef (≝), \eqdot (⩦), \eqeq (⩵), \eqeqeq (⩶), \eqgtr (⋝), \eqless (⋜), \eqqgtr (⪚), \eqqless (⪙), \eqqplus (⩱), \eqqsim (⩳), \eqqslantgtr (⪜), \eqqslantless (⪛), \eqsim (≂), \eqslantgtr (⪖), \eqslantless (⪕), \equalleftarrow (⭀), \equalparallel (⋕), \equalrightarrow (⥱), \equiv (≡), \equivDD (⩸), \equivVert (⩨), \equivVvert (⩩), \eqvparsl (⧥), \errbarblackcircle (⧳), \errbarblackdiamond (⧱), \errbarblacksquare (⧯), \errbarcircle (⧲), \errbardiamond (⧰), \errbarsquare (⧮), \eta (η), \euro (€), \exists (∃). + +\fallingdotseq (≒), \fbowtie (⧓), \fcmp (⨾), \fdiagovnearrow (⤯), \fdiagovrdiag (⤬), \female (♀), \figdash (‒), \fint (⨏), \fisheye (◉), \flat (♭), \fltns (⏥), \forall (∀), \forks (⫝̸), \forksnot (⫝), \forkv (⫙), \fourthroot (∜), \fourvdots (⦙), \fracfiveeighths (⅝), \fracfivesixths (⅚), \fracfourfifths (⅘), \fraconeeighth (⅛), \fraconefifth (⅕), \fraconesixth (⅙), \fraconethird (⅓), \fracseveneights (⅞), \fracslash (⁄), \fracthreeeighths (⅜), \fracthreefifths (⅗), \fractwofifths (⅖), \fractwothirds (⅔), \frakC (ℭ), \frakH (ℌ), \frakZ (ℨ), \frown (⌢), \frownie (☹), \fullouterjoin (⟗). + +\gamma (γ), \ge (≥), \geq (≥), \geqq (≧), \geqslant (⩾), \gescc (⪩), \gesdot (⪀), \gesdoto (⪂), \gesdotol (⪄), \gesles (⪔), \gets (←), \gg (≫), \ggg (⋙), \gggnest (⫸), \gimel (ℷ), \glE (⪒), \gla (⪥), \gleichstark (⧦), \glj (⪤), \gnapprox (⪊), \gneq (⪈), \gneqq (≩), \gnsim (⋧), \greater (>), \gsime (⪎), \gsiml (⪐), \gtcc (⪧), \gtcir (⩺), \gtlpar (⦠), \gtquest (⩼), \gtrapprox (⪆), \gtrarr (⥸), \gtrdot (⋗), \gtreqless (⋛), \gtreqqless (⪌), \gtrless (≷), \gtrsim (≳), \guillemotleft («), \guillemotright (»), \guilsinglleft (‹), \guilsinglright (›). + +\harrowextender (⎯), \hatapprox (⩯), \hbar (ℏ), \heartsuit (♡), \hermitmatrix (⊹), \hexagon (⎔), \hexagonblack (⬣), \hiraganano (の), \hknearrow (⤤), \hknwarrow (⤣), \hksearow (⤥), \hkswarow (⤦), \hookleftarrow (↩), \hookrightarrow (↪), \horizbar (―), \hourglass (⧖), \house (⌂), \hrectangle (▭), \hrectangleblack (▬), \hslash (ℏ), \hyphenbullet (⁃), \hzigzag (〰). + +\iiiint (⨌), \iiint (∭), \iinfin (⧜), \iint (∬), \imageof (⊷), \in (∈), \incare (℅), \increment (∆), \infty (∞), \int (∫), \intBar (⨎), \intbar (⨍), \intbottom (⌡), \intcap (⨙), \intclockwise (∱), \intcup (⨚), \intercal (⊺), \interleave (⫴), \intextender (⎮), \intlharhk (⨗), \intprod (⨼), \intprodr (⨽), \inttop (⌠), \intx (⨘), \inversebullet (◘), \inversewhitecircle (◙), \invnot (⌐), \invwhitelowerhalfcircle (◛), \invwhiteupperhalfcircle (◚), \iota (ι), \ipasupgamma (ˠ), \ipasupl (ˡ), \ipasuprerglotstpp (ˤ), \ipasups (ˢ), \ipasupx (ˣ), \ipaunaspirated (˭), \ipavoicing (ˬ), \isinE (⋹), \isindot (⋵), \isinobar (⋷), \isins (⋴), \isinvb (⋸), \itBbbD (ⅅ), \itBbbd (ⅆ), \itBbbe (ⅇ), \itBbbi (ⅈ), \itBbbj (ⅉ). + +\jupiter (♃), \kappa (κ), \kernelcontraction (∻), \koppa (ϟ). + +\l (ł), \lAngle (⟪), \lBrace (⦃), \lBrack (⟦), \lParen (⦅), \lambda (λ), \lambdabar (ƛ), \langle (⟨), \langledot (⦑), \laplac (⧠), \lasp (ʽ), \lat (⪫), \late (⪭), \lbag (⟅), \lblkbrbrak (⦗), \lbrace (@{), \lbracelend (⎩), \lbracemid (⎨), \lbraceuend (⎧), \lbrack ([), \lbrackextender (⎢), \lbracklend (⎣), \lbracklltick (⦏), \lbrackubar (⦋), \lbrackuend (⎡), \lbrackultick (⦍), \lbrbrak (❲), \lceil (⌈), \lcurvyangle (⧼), \ldasharrhead (⇠), \le (≤), \leadsto (↝), \leftarrow (←), \leftarrowapprox (⭊), \leftarrowbackapprox (⭂), \leftarrowbsimilar (⭋), \leftarrowless (⥷), \leftarrowonoplus (⬲), \leftarrowplus (⥆), \leftarrowshortrightarrow (⥃), \leftarrowsimilar (⥳), \leftarrowsubset (⥺), \leftarrowtail (↢), \leftarrowtriangle (⇽), \leftarrowx (⬾), \leftbkarrow (⤌), \leftcurvedarrow (⬿), \leftdasharrow (⇠), \leftdasharrowhead (⇡), \leftdbkarrow (⤎), \leftdbltail (⤛), \leftdotarrow (⬸), \leftdowncurvedarrow (⤶), \leftfishtail (⥼), \leftharpoondown (↽), \leftharpoondownbar (⥞), \leftharpoonsupdown (⥢), \leftharpoonup (↼), \leftharpoonupbar (⥚), \leftharpoonupdash (⥪), \leftleftarrows (⇇), \leftmoon (☾), \leftouterjoin (⟕), \leftrightarrow (↔), \leftrightarrowcircle (⥈), \leftrightarrows (⇆), \leftrightarrowtriangle (⇿), \leftrightharpoondowndown (⥐), \leftrightharpoondownup (⥋), \leftrightharpoons (⇋), \leftrightharpoonsdown (⥧), \leftrightharpoonsup (⥦), \leftrightharpoonupdown (⥊), \leftrightharpoonupup (⥎), \leftrightsquigarrow (↭), \leftsquigarrow (↜), \leftsquigarrow (⇜), \lefttail (⤙), \leftthreearrows (⬱), \leftthreetimes (⋋), \leftwhitearrow (⇦), \leq (≤), \leqq (≦), \leqqslant (⫹), \leqqslant (⫺), \leqslant (⩽), \lescc (⪨), \lesdot (⩿), \lesdoto (⪁), \lesdotor (⪃), \lesges (⪓), \less (<), \lessapprox (⪅), \lessdot (⋖), \lesseqgtr (⋚), \lesseqqgtr (⪋), \lessgtr (≶), \lesssim (≲), \lfbowtie (⧑), \lfloor (⌊), \lftimes (⧔), \lgE (⪑), \lgblkcircle (⬤), \lgblksquare (⬛), \lgwhtcircle (◯), \lgwhtsquare (⬜), \lhd (⊲), \linefeed (↴), \ll (≪), \llangle (⦉), \llarc (◟), \llblacktriangle (◣), \llcorner (⌞), \lll (⋘), \lllnest (⫷), \llparenthesis (⦇), \lltriangle (◺), \lmoustache (⎰), \lnapprox (⪉), \lneq (⪇), \lneqq (≨), \lnsim (⋦), \longdashv (⟞), \longdivision (⟌), \longleftarrow (⟵), \longleftrightarrow (⟷), \longleftsquigarrow (⬳), \longmapsfrom (⟻), \longmapsto (⟼), \longrightarrow (⟶), \longrightsquigarrow (⟿), \looparrowleft (↫), \looparrowright (↬), \lowint (⨜), \lozenge (◊), \lozengeminus (⟠), \lparenextender (⎜), \lparenlend (⎝), \lparenless (⦓), \lparenuend (⎛), \lq (‘), \lrarc (◞), \lrblacktriangle (◢), \lrcorner (⌟), \lrtriangle (◿), \lrtriangleeq (⧡), \lsime (⪍), \lsimg (⪏), \lsqhook (⫍), \ltcc (⪦), \ltcir (⩹), \ltimes (⋉), \ltlarr (⥶), \ltquest (⩻), \ltrivb (⧏), \lvboxline (⎸), \lvzigzag (⧘). + +\male (♂), \maltese (✠), \mapsdown (↧), \mapsfrom (↤), \mapsto (↦), \mapsup (↥), \mdblkdiamond (⬥), \mdblklozenge (⬧), \mdblkrcl (⚫), \mdblksquare (◼), \mdlgblkcircle (●), \mdlgblkdiamond (◆), \mdlgblklozenge (⧫), \mdlgblksquare (■), \mdlgwhtcircle (○), \mdlgwhtdiamond (◇), \mdlgwhtsquare (□), \mdsmblkcircle (⦁), \mdsmblksquare (◾), \mdsmwhtcircl (⚬), \mdsmwhtsquare (◽), \mdwhtcircl (⚪), \mdwhtdiamond (⬦), \mdwhtlozenge (⬨), \mdwhtsquare (◻), \measangledltosw (⦯), \measangledrtose (⦮), \measangleldtosw (⦫), \measanglelutonw (⦩), \measanglerdtose (⦪), \measanglerutone (⦨), \measangleultonw (⦭), \measangleurtone (⦬), \measeq (≞), \measuredangle (∡), \measuredangleleft (⦛), \measuredrightangle (⊾), \medblackstar (⭑), \medmathspace ( ), \medwhitestar (⭐), \mercury (☿), \mho (℧), \mid (∣), \midbarvee (⩝), \midbarwedge (⩜), \midcir (⫰), \minus (−), \minusdot (⨪), \minusfdots (⨫), \minusrdots (⨬), \mlcp (⫛), \models (⊧), \mp (∓), \mu (μ), \multimap (⊸), \multimapinv (⟜). + +\nHdownarrow (⇟), \nHuparrow (⇞), \nLeftarrow (⇍), \nLeftrightarrow (⇎), \nRightarrow (⇏), \nVDash (⊯), \nVdash (⊮), \nVleftarrow (⇺), \nVleftarrowtail (⬺), \nVleftrightarrow (⇼), \nVrightarrow (⇻), \nVrightarrowtail (⤕), \nVtwoheadleftarrow (⬵), \nVtwoheadleftarrowtail (⬽), \nVtwoheadrightarrow (⤁), \nVtwoheadrightarrowtail (⤘), \nabla (∇), \napprox (≉), \nasymp (≭), \natural (♮), \ncong (≇), \ne (≠), \nearrow (↗), \neg (¬), \neovnwarrow (⤱), \neovsearrow (⤮), \neptune (♆), \neq (≠), \nequiv (≢), \neswarrow (⤢), \neuter (⚲), \nexists (∄), \ng (ŋ), \ngeq (≱), \ngtr (≯), \ngtrless (≹), \ngtrsim (≵), \nhVvert (⫵), \nhpar (⫲), \ni (∋), \niobar (⋾), \nis (⋼), \nisd (⋺), \nleftarrow (↚), \nleftrightarrow (↮), \nleq (≰), \nless (≮), \nlessgtr (≸), \nlesssim (≴), \nmid (∤), \nni (∌), \nobreakhyphen (‑), \notin (∉), \nparallel (∦), \npolint (⨔), \nprec (⊀), \npreccurlyeq (⋠), \nrightarrow (↛), \nsim (≁), \nsime (≄), \nsqsubseteq (⋢), \nsqsupseteq (⋣), \nsubset (⊄), \nsubseteq (⊈), \nsucc (⊁), \nsucccurlyeq (⋡), \nsupset (⊅), \nsupseteq (⊉), \ntriangleleft (⋪), \ntrianglelefteq (⋬), \ntriangleright (⋫), \ntrianglerighteq (⋭), \nu (ν), \nvDash (⊭), \nvLeftarrow (⤂), \nvLeftrightarrow (⤄), \nvRightarrow (⤃), \nvdash (⊬), \nvinfty (⧞), \nvleftarrow (⇷), \nvleftarrowtail (⬹), \nvleftrightarrow (⇹), \nvrightarrow (⇸), \nvrightarrowtail (⤔), \nvtwoheadleftarrow (⬴), \nvtwoheadleftarrowtail (⬼), \nvtwoheadrightarrow (⤀), \nvtwoheadrightarrowtail (⤗), \nwarrow (↖), \nwovnearrow (⤲), \nwsearrow (⤡). + +\o (ø), \obar (⌽), \obot (⦺), \obrbrak (⏠), \obslash (⦸), \odiv (⨸), \odot (⊙), \odotslashdot (⦼), \oe (œ), \ogreaterthan (⧁), \ohorn (ơ), \oiiint (∰), \oiint (∯), \oint (∮), \ointctrclockwise (∳), \olcross (⦻), \oldKoppa (Ϙ), \oldkoppa (ϙ), \olessthan (⧀), \omega (ω), \omicron (ο), \ominus (⊖), \operp (⦹), \oplus (⊕), \opluslhrim (⨭), \oplusrhrim (⨮), \origof (⊶), \oslash (⊘), \otimes (⊗), \otimeshat (⨶), \otimeslhrim (⨴), \otimesrhrim (⨵), \overbrace (⏞), \overbracket (⎴), \overline (‾), \overparen (⏜), \owns (∋). + +\parallel (∥), \parallelogram (▱), \parallelogramblack (▰), \parsim (⫳), \partial (∂), \partialmeetcontraction (⪣), \pentagon (⬠), \pentagonblack (⬟), \perp (⟂), \perps (⫡), \phi (ϕ), \phone (☎), \pi (π), \pitchfork (⋔), \plusdot (⨥), \pluseqq (⩲), \plushat (⨣), \plussim (⨦), \plussubtwo (⨧), \plustrif (⨨), \pluto (♇), \pm (±), \pointnt (⨕), \postalmark (〒), \prec (≺), \precapprox (⪷), \preccurlyeq (≼), \preceq (⪯), \preceqq (⪳), \precnapprox (⪹), \precneq (⪱), \precneqq (⪵), \precnsim (⋨), \precsim (≾), \prime (′), \prod (∏), \profalar (⌮), \profline (⌒), \profsurf (⌓), \propto (∝), \prurel (⊰), \psi (ψ), \pullback (⟓), \pushout (⟔). + +\qprime (⁗), \quarternote (♩), \questeq (≟), \quotdblbase („), \quotdblright (‟), \quotsinglbase (‚), \quotsinglright (‛). + +\rAngle (⟫), \rBrace (⦄), \rBrack (⟧), \rParen (⦆), \rangle (⟩), \rangledot (⦒), \rangledownzigzagarrow (⍼), \rasp (ʼ), \rbag (⟆), \rblkbrbrak (⦘), \rbrace (@}), \rbracelend (⎭), \rbracemid (⎬), \rbraceuend (⎫), \rbrack (]), \rbrackextender (⎥), \rbracklend (⎦), \rbracklrtick (⦎), \rbrackubar (⦌), \rbrackuend (⎤), \rbrackurtick (⦐), \rbrbrak (❳), \rceil (⌉), \rcurvyangle (⧽), \rdiagovfdiag (⤫), \rdiagovsearrow (⤰), \recorder (⌕), \revangle (⦣), \revangleubar (⦥), \revemptyset (⦰), \revnmid (⫮), \rfbowtie (⧒), \rfloor (⌋), \rftimes (⧕), \rhd (⊳), \rho (ρ), \righarrowbsimilar (⭌), \rightangle (∟), \rightanglemdot (⦝), \rightanglesqr (⦜), \rightarrow (→), \rightarrowapprox (⥵), \rightarrowbackapprox (⭈), \rightarrowbar (⇥), \rightarrowdiamond (⤞), \rightarrowgtr (⭃), \rightarrowonoplus (⟴), \rightarrowplus (⥅), \rightarrowshortleftarrow (⥂), \rightarrowsimilar (⥴), \rightarrowsupset (⭄), \rightarrowtail (↣), \rightarrowtriangle (⇾), \rightarrowx (⥇), \rightbkarrow (⤍), \rightcurvedarrow (⤳), \rightdasharrow (⇢), \rightdbltail (⤜), \rightdotarrow (⤑), \rightdowncurvedarrow (⤷), \rightfishtail (⥽), \rightharpoondown (⇁), \rightharpoondownbar (⥗), \rightharpoonsupdown (⥤), \rightharpoonup (⇀), \rightharpoonupbar (⥓), \rightharpoonupdash (⥬), \rightimply (⥰), \rightleftarrows (⇄), \rightleftharpoons (⇌), \rightleftharpoonsdown (⥩), \rightleftharpoonsup (⥨), \rightmoon (☽), \rightouterjoin (⟖), \rightpentagon (⭔), \rightpentagonblack (⭓), \rightrightarrows (⇉), \rightsquigarrow (↝), \rightsquigarrow (⇝), \righttail (⤚), \rightthreearrows (⇶), \rightthreetimes (⋌), \rightwhitearrow (⇨), \ringplus (⨢), \risingdotseq (≓), \rmoustache (⎱), \rparenextender (⎟), \rparengtr (⦔), \rparenlend (⎠), \rparenuend (⎞), \rppolint (⨒), \rq (’), \rrangle (⦊), \rrparenthesis (⦈), \rsolbar (⧷), \rsqhook (⫎), \rsub (⩥), \rtimes (⋊), \rtriltri (⧎), \ruledelayed (⧴), \rvboxline (⎹), \rvzigzag (⧙). + +\sampi (ϡ), \sansLmirrored (⅃), \sansLturned (⅂), \saturn (♄), \scissors (✂), \scpolint (⨓), \scrB (ℬ), \scrE (ℰ), \scrF (ℱ), \scrH (ℋ), \scrI (ℐ), \scrL (ℒ), \scrM (ℳ), \scrR (ℛ), \scre (ℯ), \scrg (ℊ), \scro (ℴ), \scurel (⊱), \searrow (↘), \seovnearrow (⤭), \setminus (∖), \setminus (⧵), \sharp (♯), \shortdowntack (⫟), \shortleftarrow (←), \shortlefttack (⫞), \shortrightarrow (→), \shortrightarrowleftarrow (⥄), \shortuptack (⫠), \shuffle (⧢), \sigma (σ), \silon (υ), \silon (ϒ), \sim (∼), \simeq (≃), \simgE (⪠), \simgtr (⪞), \similarleftarrow (⭉), \similarrightarrow (⥲), \simlE (⪟), \simless (⪝), \simminussim (⩬), \simneqq (≆), \simplus (⨤), \simrdots (⩫), \sinewave (∿), \slash (∕), \smallblacktriangleleft (◂), \smallblacktriangleright (▸), \smalldiamond (⋄), \smallin (∊), \smallint (∫), \smallni (∍), \smallsetminus (∖), \smalltriangleleft (◃), \smalltriangleright (▹), \smashtimes (⨳), \smblkdiamond (⬩), \smblklozenge (⬪), \smblksquare (▪), \smeparsl (⧤), \smile (⌣), \smiley (☺), \smt (⪪), \smte (⪬), \smwhitestar (⭒), \smwhtcircle (◦), \smwhtlozenge (⬫), \smwhtsquare (▫), \spadesuit (♠), \sphericalangle (∢), \sphericalangleup (⦡), \sqcap (⊓), \sqcup (⊔), \sqint (⨖), \sqlozenge (⌑), \sqrt (√), \sqrt3 (∛), \sqrt4 (∜), \sqrtbottom (⎷), \sqsubset (⊏), \sqsubseteq (⊑), \sqsubsetneq (⋤), \sqsupset (⊐), \sqsupseteq (⊒), \sqsupsetneq (⋥), \squarecrossfill (▩), \squaregrayfill (▩), \squarehfill (▤), \squarehvfill (▦), \squareleftblack (◧), \squareleftblack (◨), \squarellblack (⬕), \squarellquad (◱), \squarelrblack (◪), \squarelrquad (◲), \squareneswfill (▨), \squarenwsefill (▧), \squareulblack (◩), \squareulquad (◰), \squareurblack (⬔), \squareurquad (◳), \squarevfill (▥), \squoval (▢), \ss (ß), \star (⋆), \stareq (≛), \sterling (£), \stigma (ϛ), \strns (⏤), \subedot (⫃), \submult (⫁), \subrarr (⥹), \subset (⊂), \subsetapprox (⫉), \subsetcirc (⟃), \subsetdot (⪽), \subseteq (⊆), \subseteqq (⫅), \subsetneq (⊊), \subsetneqq (⫋), \subsetplus (⪿), \subsim (⫇), \subsub (⫕), \subsup (⫓), \succ (≻), \succapprox (⪸), \succcurlyeq (≽), \succeq (⪰), \succeqq (⪴), \succnapprox (⪺), \succneq (⪲), \succneqq (⪶), \succnsim (⋩), \succsim (≿), \sum (∑), \sumbottom (⎳), \sumint (⨋), \sumtop (⎲), \sun (☼), \supdsub (⫘), \supedot (⫄), \suphsol (⟉), \suphsub (⫗), \suplarr (⥻), \supmult (⫂), \supn (ⁿ), \supset (⊃), \supsetapprox (⫊), \supsetcirc (⟄), \supsetdot (⪾), \supseteq (⊇), \supseteqq (⫆), \supsetneq (⊋), \supsetneqq (⫌), \supsetplus (⫀), \supsim (⫈), \supsub (⫔), \supsup (⫖), \surd (√), \swarrow (↙). + +\talloblong (⫾), \target (⌖), \tau (τ), \taurus (♉), \testhookx (ᶍ), \textAsterisks (⁑), \textacute (ˊ), \textadvanced (˖), \textain (ʿ), \textasciiacute (´), \textasciicircum (^), \textasciidieresis (¨), \textasciigrave (`), \textasciimacron (¯), \textasciitilde (~), \textasterisklow (⁎), \textbackdprime (‶), \textbackprime (‵), \textbacktrprime (‷), \textbardotlessj (ɟ), \textbardotlessjvar (ʄ), \textbarglotstop (ʡ), \textbari (ɨ), \textbarl (ƚ), \textbaro (ɵ), \textbarrevglotstop (ʢ), \textbaru (ʉ), \textbeltl (ɬ), \textbenttailyogh (ƺ), \textbreve (˘), \textbrokenbar (¦), \textbullet (•), \textbullseye (ʘ), \textcent (¢), \textcircledP (℗), \textcloseepsilon (ʚ), \textcloseomega (ɷ), \textcloserevepsilon (ɞ), \textcopyright (©), \textcrb (ƀ), \textcrh (ħ), \textcrinvglotstop (ƾ), \textcrlambda (ƛ), \textcrtwo (ƻ), \textctc (ɕ), \textctd (ȡ), \textctesh (ʆ), \textctj (ʝ), \textctl (ȴ), \textctn (ȵ), \textctt (ȶ), \textctyogh (ʓ), \textctz (ʑ), \textcurrency (¤), \textdctzlig (ʥ), \textdegree (°), \textdiscount (⁒), \textdollar ($), \textdotaccent (˙), \textdotlessj (ȷ), \textdoubleacute (˝), \textdoublebarpipe (ǂ), \textdoublepipe (ǁ), \textdprime (″), \textdptr (˅), \textdyoghlig (ʤ), \textdzlig (ʣ), \textepsilon (ɛ), \textesh (ʃ), \textestimated (℮), \textexclam (ǃ), \textexclamdown (¡), \textfishhookr (ɾ), \textflorin (ƒ), \textfranc (₣), \textgamma (ɣ), \textglotstop (ʔ), \textgrave (ˋ), \texthalflength (ˑ), \texthamza (ʾ), \texthen (ꜧ), \textheng (ꜧ), \texthooks (ᶊ), \texthookz (ᶎ), \texthtb (ɓ), \texthtc (ƈ), \texthtd (ɗ), \texthtg (ɠ), \texthth (ɦ), \texththeng (ɧ), \texthtk (ƙ), \texthtp (ƥ), \texthtq (ʠ), \texthtscg (ʛ), \texthtt (ƭ), \texthvlig (ƕ), \texthyphen (‐), \textinvglotstop (ʖ), \textinvscr (ʁ), \textiota (ɩ), \textlengthmark (ː), \textlhalfring (˓), \textlhookd (ᶁ), \textlhookk (ᶄ), \textlhookl (ᶅ), \textlhookt (ƫ), \textlhti (ɿ), \textlira (₤), \textlonglegr (ɼ), \textlongy (ʮ), \textlongy (ʯ), \textlooptoprevesh (ƪ), \textlowacute (ˏ), \textlowered (˕), \textlowgrave (ˎ), \textlowmacron (ˍ), \textlptr (˂), \textltailm (ɱ), \textltailn (ɲ), \textltilde (ɫ), \textlyoghlig (ɮ), \textmacron (ˉ), \textmu (µ), \textnumero (№), \textogonek (˛), \textohm (Ω), \textonehalf (½), \textonequarter (¼), \textonesuperior (¹), \textopeno (ɔ), \textordfeminine (ª), \textordmasculine (º), \textovercross (˟), \textoz (℥), \textpertenthousand (‱), \textperthousand (‰), \textpesetas (₧), \textphi (ɸ), \textpipe (ǀ), \textprime (′), \textprimstress (ˈ), \textqprime (⁗), \textquestiondown (¿), \textquotedbl ("), \textquotedblleft (“), \textquotedblright (”), \textraised (˔), \textraiseglotstop (ˀ), \textraiserevglotstop (ˁ), \textramshorns (ɤ), \textrecipe (℞), \textreferencemark (※), \textregistered (®), \textretracted (˗), \textreve (ɘ), \textrevepsilon (ɜ), \textrevglotstop (ʕ), \textrhalfring (˒), \textrhookrevepsilon (ɝ), \textrhookschwa (ɚ), \textrhoticity (˞), \textringaccent (˚), \textrptr (˃), \textrtaild (ɖ), \textrtaill (ɭ), \textrtailn (ɳ), \textrtailr (ɽ), \textrtails (ʂ), \textrtailt (ʈ), \textrtailz (ʐ), \textsca (ᴀ), \textscb (ʙ), \textsce (ᴇ), \textscg (ɢ), \textsch (ʜ), \textschwa (ə), \textsci (ɪ), \textscl (ʟ), \textscn (ɴ), \textscoelig (ɶ), \textscr (ʀ), \textscripta (ɑ), \textscriptg (ɡ), \textscriptv (ʋ), \textscu (ᴜ), \textscy (ʏ), \textsecstress (ˌ), \textsemicolonreversed (⁏), \textsilon (Υ), \textsmalltilde (˜), \textstretchcvar (ʗ), \textsubw (w), \textsuph (ʰ), \textsuphth (ʱ), \textsupinvscr (ʶ), \textsupj (ʲ), \textsupr (ʳ), \textsupturnr (ʴ), \textsupturnrrtail (ʵ), \textsupw (ʷ), \textsupy (ʸ), \texttctctlig (ʧ), \texttctctlig (ʨ), \textthreequarters (¾), \textthreesuperior (³), \texttrademark (™), \texttrprime (‴), \texttslig (ʦ), \textturna (ɐ), \textturncomma (ʻ), \textturnh (ɥ), \textturnk (ʞ), \textturnlonglegr (ɺ), \textturnm (ɯ), \textturnmrleg (ɰ), \textturnr (ɹ), \textturnrrtail (ɻ), \textturnscripta (ɒ), \textturnt (ʇ), \textturnv (ʌ), \textturnw (ʍ), \textturny (ʎ), \texttwosuperior (²), \textupsilon (ʊ), \textuptr (˄), \textvibyi (ʅ), \textvisiblespace (␣), \textyogh (ʒ), \th (þ), \therefore (∴), \thermod (⧧), \theta (θ), \thickapprox (≈), \thicksim (∼), \threedangle (⟀), \threedotcolon (⫶), \tieconcat (⁀), \tieinfty (⧝), \times (×), \timesbar (⨱), \tminus (⧿), \to (→), \toea (⤨), \tona (⤧), \tonebarextrahigh (˥), \tonebarextralow (˩), \tonebarhigh (˦), \tonebarlow (˨), \tonebarmid (˧), \top (⊤), \topbot (⌶), \topcir (⫱), \topfork (⫚), \topsemicircle (◠), \tosa (⤩), \towa (⤪), \tplus (⧾), \trapezium (⏢), \trianglecdot (◬), \triangledown (▿), \triangleexclam (⚠), \triangleleft (◁), \triangleleftblack (◭), \trianglelefteq (⊴), \triangleminus (⨺), \triangleodot (⧊), \triangleplus (⨹), \triangleq (≜), \triangleright (▷), \trianglerightblack (◮), \trianglerighteq (⊵), \triangles (⧌), \triangleserifs (⧍), \triangletimes (⨻), \triangleubar (⧋), \tripleplus (⧻), \trprime (‴), \turnangle (⦢), \turnediota (℩), \turnednot (⌙), \twocaps (⩋), \twocups (⩊), \twoheaddownarrow (↡), \twoheadleftarrow (↞), \twoheadleftarrowtail (⬻), \twoheadleftdbkarrow (⬷), \twoheadmapsfrom (⬶), \twoheadmapsto (⤅), \twoheadrightarrow (↠), \twoheadrightarrowtail (⤖), \twoheaduparrow (↟), \twoheaduparrowcircle (⥉), \twolowline (‗), \twonotes (♫), \typecolon (⦂). + +\ubrbrak (⏡), \uhorn (ư), \ularc (◜), \ulblacktriangle (◤), \ulcorner (⌜), \ulcrop (⌏), \ultriangle (◸), \uminus (⩁), \underbrace (⏟), \underbracket (⎵), \underparen (⏝), \unlhd (⊴), \unrhd (⊵), \upand (⅋), \uparrow (↑), \uparrowbarred (⤉), \uparrowoncircle (⦽), \updasharrow (⇢), \updownarrow (↕), \updownarrowbar (↨), \updownarrows (⇅), \updownharpoonleftleft (⥑), \updownharpoonleftright (⥍), \updownharpoonrightleft (⥌), \updownharpoonrightright (⥏), \updownharpoonsleftright (⥮), \upfishtail (⥾), \upharpoonleft (↿), \upharpoonleftbar (⥠), \upharpoonright (↾), \upharpoonrightbar (⥜), \upharpoonsleftright (⥣), \upin (⟒), \upint (⨛), \uplus (⊎), \uprightcurvearrow (⤴), \upuparrows (⇈), \upwhitearrow (⇧), \urarc (◝), \urblacktriangle (◥), \urcorner (⌝), \urcrop (⌎), \urtriangle (◹). + +\v (ˇ), \vBar (⫨), \vBarv (⫩), \vDash (⊨), \vDdash (⫢), \varTheta (ϴ), \varVdash (⫦), \varbarwedge (⌅), \varbeta (ϐ), \varclubsuit (♧), \vardiamondsuit (♦), \vardoublebarwedge (⌆), \varepsilon (ε), \varheartsuit (♥), \varhexagon (⬡), \varhexagonblack (⬢), \varhexagonlrbonds (⌬), \varin (∈), \varisinobar (⋶), \varisins (⋳), \varkappa (ϰ), \varlrtriangle (⊿), \varni (∋), \varniobar (⋽), \varnis (⋻), \varnothing (∅), \varointclockwise (∲), \varphi (φ), \varpi (ϖ), \varpropto (∝), \varrho (ϱ), \varrowextender (⏐), \varsigma (ς), \varspadesuit (♤), \varstar (✶), \vartheta (ϑ), \vartriangle (▵), \vartriangleleft (⊲), \vartriangleright (⊳), \varveebar (⩡), \vbraceextender (⎪), \vbrtri (⧐), \vdash (⊢), \vdots (⋮), \vectimes (⨯), \vee (∨), \veebar (⊻), \veedot (⟇), \veedoublebar (⩣), \veeeq (≚), \veemidvert (⩛), \veeodot (⩒), \veeonvee (⩖), \veeonwedge (⩙), \vert (|), \viewdata (⌗), \vlongdash (⟝), \vrectangle (▯), \vrectangleblack (▮), \vysmlblksquare (⬝), \vysmlwhtsquare (⬞), \vzigzag (⦚). + +\watchicon (⌚), \wedge (∧), \wedgebar (⩟), \wedgedot (⟑), \wedgedoublebar (⩠), \wedgemidvert (⩚), \wedgeodot (⩑), \wedgeonwedge (⩕), \wedgeq (≙), \whitearrowupfrombar (⇪), \whiteinwhitetriangle (⟁), \whitepointerleft (◅), \whitepointerright (▻), \whitesquaretickleft (⟤), \whitesquaretickright (⟥), \whthorzoval (⬭), \whtvertoval (⬯), \wideangledown (⦦), \wideangleup (⦧), \wp (℘), \wr (≀). + +\xbsol (⧹), \xi (ξ), \xsol (⧸), \yen (¥), \zeta (ζ), \zpipe (⨠), + +Я БУДУ КРАЙНЕ ПРИЗНАТЕЛЕН ЕСЛИ КТО-НИБУДЬ ПРОВЕРИТ СООТВЕТСТВИЕ ВСЕХ ИМЕН ПРАВИЛЬНЫМ ТЕХ-ИМ СИМВОЛАМ. + diff --git a/texinfo/classes.dia b/texinfo/classes.dia new file mode 100644 index 0000000..04bf40d Binary files /dev/null and b/texinfo/classes.dia differ diff --git a/texinfo/classes.pdf b/texinfo/classes.pdf new file mode 100644 index 0000000..db68b62 Binary files /dev/null and b/texinfo/classes.pdf differ diff --git a/texinfo/classes.png b/texinfo/classes.png new file mode 100644 index 0000000..a52e303 Binary files /dev/null and b/texinfo/classes.png differ diff --git a/texinfo/concept_en.texi b/texinfo/concept_en.texi new file mode 100644 index 0000000..455d49b --- /dev/null +++ b/texinfo/concept_en.texi @@ -0,0 +1,385 @@ +@chapter General concepts +@nav{} + +The set of MathGL features is rather rich -- just the number of basic graphics types +is larger than 50. Also there are functions for data handling, plot setup and so on. In spite of it I tried to keep a similar style in function names and in the order of arguments. Mostly it is +used for different drawing functions. + +There are six most general (base) concepts: +@enumerate +@item +@strong{Any picture is created in memory first.} The internal (memory) representation can be different: bitmap picture (for @code{SetQuality(MGL_DRAW_LMEM)}) or the list of vector primitives (default). After that the user may decide what he/she want: save to file, display on the screen, run animation, do additional editing and so on. This approach assures a high portability of the program -- the source code will produce exactly the same picture in @emph{any} OS. Another big positive consequence is the ability to create the picture in the console program (using command line, without creating a window)! +@item +@strong{Every plot settings (style of lines, font, color scheme) are specified by a string.} It provides convenience for user/programmer -- short string with parameters is more comprehensible than a large set of parameters. Also it provides portability -- the strings are the same in any OS so that it is not necessary to think about argument types. +@item +@strong{All functions have ``simplified'' and ``advanced'' forms.} It is done for user's convenience. One needs to specify only one data array in the ``simplified'' form in order to see the result. But one may set parametric dependence of coordinates and produce rather complex curves and surfaces in the ``advanced'' form. In both cases the order of function arguments is the same: first data arrays, second the string with style, and later string with options for additional plot tuning. +@item +@strong{All data arrays for plotting are encapsulated in mglData(A) class.} This reduces the number of errors while working with memory and provides a uniform interface for data of different types (mreal, double and so on) or for formula plotting. +@item +@strong{All plots are vector plots.} The MathGL library is intended for handling scientific data which have vector nature (lines, faces, matrices and so on). As a result, vector representation is used in all cases! In addition, the vector representation allows one to scale the plot easily -- change the canvas size by a factor of 2, and the picture will be proportionally scaled. +@item +@strong{New drawing never clears things drawn already.} This, in some sense, unexpected, idea allows to create a lot of ``combined'' graphics. For example, to make a surface with contour lines one needs to call the function for surface plotting and the function for contour lines plotting (in any order). Thus the special functions for making this ``combined'' plots (as it is done in Matlab and some other plotting systems) are superfluous. +@end enumerate + +In addition to the general concepts I want to comment on some non-trivial or less commonly used general ideas -- plot positioning, axis specification and curvilinear coordinates, styles for lines, text and color scheme. + +@menu +* Coordinate axes:: +* Color styles:: +* Line styles:: +* Color scheme:: +* Font styles:: +* Textual formulas:: +* Command options:: +* Interfaces:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Coordinate axes, Color styles, , General concepts +@section Coordinate axes +@nav{} + +Two axis representations are used in MathGL. The first one consists of normalizing coordinates of data points in a box @var{Min}x@var{Max} (see @ref{Axis settings}). If @code{SetCut()} is @code{true} then the outlier points are omitted, otherwise they are projected to the bounding box (see @ref{Cutting}). Also, the point will be omitted if it lies inside the box defined by @code{SetCutBox()} or if the value of formula @code{CutOff()} is nonzero for its coordinates. After that, transformation formulas defined by @code{SetFunc()} or @code{SetCoor()} are applied to the data point (see @ref{Curved coordinates}). Finally, the data point is plotted by one of the functions. + +The range of @emph{x, y, z}-axis can be specified by @code{SetRange()} or @code{SetRanges()} functions. Its origin is specified by @code{SetOrigin()} function. At this you can you can use @code{NAN} values for selecting axis origin automatically. + +There is 4-th axis @emph{c} (color axis or colorbar) in addition to the usual axes @emph{x, y, z}. It sets the range of values for the surface coloring. Its borders are automatically set to values of Min.z, Max.z during the call of @code{SetRanges()} function. Also, one can directly set it by call @code{SetRange('c', ...)}. Use @code{Colorbar()} function for drawing the colorbar. + +The form (appearence) of tick labels is controlled by @code{SetTicks()} function (@pxref{Ticks}). Function @var{SetTuneTicks} switches on/off tick enhancing by factoring out acommon multiplier (for small coordinate values, like 0.001 to 0.002, or large, like from 1000 to 2000) or common component (for narrow range, like from 0.999 to 1.000). Finally, you may use functions @code{SetTickTempl()} for setting templates for tick labels (it supports TeX symbols). Also, there is a possibility to print arbitrary text as tick labels the by help of @code{SetTicksVal()} function. + +@c ------------------------------------------------------------------ +@external{} +@node Color styles, Line styles, Coordinate axes, General concepts +@section Color styles +@nav{} + +Base colors are defined by one of symbol @samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}. +@ifhtml +@html +

The color types are: ‘k’ – black, ‘r’ – red, ‘R’ – dark red, ‘g’ – green, ‘G’ – dark green, ‘b’ – blue, ‘B’ – dark blue, ‘c’ – cyan, ‘C’ – dark cyan, ‘m’ – magenta, ‘M’ – dark magenta, ‘y’ – yellow, ‘Y’ – dark yellow (gold), ‘h’ – gray, ‘H’ – dark gray, ‘w’ – white, ‘W’ – bright gray, ‘l’ – green-blue, ‘L’ – dark green-blue, ‘e’ – green-yellow, ‘E’ – dark green-yellow, ‘n’ – sky-blue, ‘N’ – dark sky-blue, ‘u’ – blue-violet, ‘U’ – dark blue-violet, ‘p’ – purple, ‘P’ – dark purple, ‘q’ – orange, ‘Q’ – dark orange (brown).

+@end html +@end ifhtml +@ifnothtml +The color types are: @samp{k} -- black, @samp{r} -- red, @samp{R} -- dark red, @samp{g} -- green, @samp{G} -- dark green, @samp{b} -- blue, @samp{B} -- dark blue, @samp{c} -- cyan, @samp{C} -- dark cyan, @samp{m} -- magenta, @samp{M} -- dark magenta, @samp{y} -- yellow, @samp{Y} -- dark yellow (gold), @samp{h} -- gray, @samp{H} -- dark gray, @samp{w} -- white, @samp{W} -- bright gray, @samp{l} -- green-blue, @samp{L} -- dark green-blue, @samp{e} -- green-yellow, @samp{E} -- dark green-yellow, @samp{n} -- sky-blue, @samp{N} -- dark sky-blue, @samp{u} -- blue-violet, @samp{U} -- dark blue-violet, @samp{p} -- purple, @samp{P} -- dark purple, @samp{q} -- orange, @samp{Q} -- dark orange (brown). +@end ifnothtml + +You can also use ``bright'' colors. The ``bright'' color contain 2 symbols in brackets @samp{@{cN@}}: first one is the usual symbol for color id, the second one is a digit for its brightness. The digit can be in range @samp{1}...@samp{9}. Number @samp{5} corresponds to a normal color, @samp{1} is a very dark version of the color (practically black), and @samp{9} is a very bright version of the color (practically white). For example, the colors can be @samp{@{b2@}} @samp{@{b7@}} @samp{@{r7@}} and so on. + +Finally, you can specify RGB or RGBA values of a color using format @samp{@{xRRGGBB@}} or @samp{@{xRRGGBBAA@}} correspondingly. For example, @samp{@{xFF9966@}} give you +@ifhtml +@html +melone color. +@end html +@end ifhtml +@ifnothtml +melone color. +@end ifnothtml + +@c ------------------------------------------------------------------ +@external{} +@node Line styles, Color scheme, Color styles, General concepts +@section Line styles +@nav{} + +@cindex Line style +@cindex Mark style +@cindex Arrows + +The line style is defined by the string which may contain specifications for color (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), dashing style (@samp{-|;:ji=} or space), width (@samp{123456789}) and marks (@samp{*o+xsd.^v<>} and @samp{#} modifier). If one of the type of information is omitted then default values used with next color from palette (see @ref{Palette and colors}). Note, that internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @code{Box()} or @code{Axis()} functions). +@ifhtml +@html +By default palette contain following colors: dark grayH’, blueb’, greeng’, redr’, cyanc’, magentam’, yellowy’, grayh’, green-bluel’, sky-bluen’, orangeq’, green-yellowe’, blue-violetu’, purplep’. + +

Dashing style has the following meaning: space – no line (usable for plotting only marks), ‘-’ – solid line (■■■■■■■■■■■■■■■■), ‘|’ – long dashed line (■■■■■■■■□□□□□□□□), ‘;’ – dashed line (■■■■□□□□■■■■□□□□), ‘=’ – small dashed line (■■□□■■□□■■□□■■□□), ‘:’ – dotted line (■□□□■□□□■□□□■□□□), ‘j’ – dash-dotted line (■■■■■■■□□□□■□□□□), ‘i’ – small dash-dotted line (■■■□□■□□■■■□□■□□).

+@end html +@end ifhtml +@ifnothtml +By default palette contain following colors: dark gray @samp{H}, blue @samp{b}, green @samp{g}, red @samp{r}, cyan @samp{c}, magenta @samp{m}, yellow @samp{y}, gray @samp{h}, blue-green @samp{l}, sky-blue @samp{n}, orange @samp{q}, yellow-green @samp{e}, blue-violet @samp{u}, purple @samp{p}. + +Dashing style has the following meaning: space -- no line (usable for plotting only marks), @samp{-} -- solid line (################), @samp{|} -- long dashed line (########________), @samp{;} -- dashed line (####____####____), @samp{=} -- small dashed line (##__##__##__##__), @samp{:} -- dotted line (#___#___#___#___), @samp{j} -- dash-dotted line (#######____#____), @samp{i} -- small dash-dotted line (###__#__###__#__). +@end ifnothtml + +Marker types are: @samp{o} -- circle, @samp{+} -- cross, @samp{x} -- skew cross, @samp{s} - square, @samp{d} - rhomb (or diamond), @samp{.} -- dot (point), @samp{^} -- triangle up, @samp{v} -- triangle down, @samp{<} -- triangle left, @samp{>} -- triangle right, @samp{#*} -- Y sign, @samp{#+} -- squared cross, @samp{#x} -- squared skew cross, @samp{#.} -- circled dot. If string contain symbol @samp{#} then the solid versions of markers are used. + +One may specify to draw a special symbol (an arrow) at the beginning and at the end of line. This is done if the specification string contains one of the following symbols: @samp{A} -- outer arrow, @samp{V} -- inner arrow, @samp{I} -- transverse hatches, @samp{K} -- arrow with hatches, @samp{T} -- triangle, @samp{S} -- square, @samp{D} -- rhombus, @samp{O} -- circle, @samp{_} -- nothing (the default). The following rule applies: the first symbol specifies the arrow at the end of line, the second specifies the arrow at the beginning of the line. For example, @samp{r-A} defines a red solid line with usual arrow at the end, @samp{b|AI} defines a blue dash line with an arrow at the end and with hatches at the beginning, @samp{_O} defines a line with the current style and with a circle at the beginning. These styles are applicable during the graphics plotting as well (for example, @ref{1D plotting}). + +@pfig{style, Color and line styles.} + +@c ------------------------------------------------------------------ +@external{} +@node Color scheme, Font styles, Line styles, General concepts +@section Color scheme +@nav{} + +@cindex Color scheme + +The color scheme is used for determining the color of surfaces, isolines, isosurfaces and so on. The color scheme is defined by the string, which may contain several characters that are color id (@pxref{Line styles}) or characters @samp{#:|}. Symbol @samp{#} switches to mesh drawing or to a wire plot. Symbol @samp{|} disables color interpolation in color scheme, which can be useful, for example, for sharp colors during matrix plotting. Symbol @samp{:} terminate the color scheme parsing. Following it, the user may put styles for the text, rotation axis for curves/isocontours, and so on. Color scheme may contain up to 32 color values. + +The final color is a linear interpolation of color array. The color array is constructed from the string ids (including ``bright'' colors, see @ref{Color styles}). The argument is the amplitude normalized between @var{Cmin} -- @var{Cmax} (see @ref{Axis settings}). For example, string containing 4 characters @samp{bcyr} corresponds to a colorbar from blue (lowest value) through cyan (next value) through yellow (next value) to the red (highest value). String @samp{kw} corresponds to a colorbar from black (lowest value) to white (highest value). String @samp{m} corresponds to a simple magenta color. + +There are several useful combinations. String @samp{kw} corresponds to the simplest gray color scheme where higher values are brighter. String @samp{wk} presents the inverse gray color scheme where higher value is darker. Strings @samp{kRryw}, @samp{kGgw}, @samp{kBbcw} present the well-known @emph{hot}, @emph{summer} and @emph{winter} color schemes. Strings @samp{BbwrR} and @samp{bBkRr} allow to view bi-color figure on white or black background, where negative values are blue and positive values are red. String @samp{BbcyrR} gives a color scheme similar to the well-known @emph{jet} color scheme. + +For more precise coloring, you can change default (equidistant) position of colors in color scheme. The format is @samp{@{CN,pos@}}, @samp{@{CN,pos@}} or @samp{@{xRRGGBB,pos@}}. The position value @var{pos} should be in range [0, 1]. Note, that alternative method for fine tuning of the color scheme is using the formula for coloring (see @ref{Curved coordinates}). + +@pfig{schemes, Most popular color schemes.} + +When coloring by @emph{coordinate} (used in @ref{map}), the final color is determined by the position of the point in 3d space and is calculated from formula c=x*c[1] + y*c[2]. Here, c[1], c[2] are the first two elements of color array; x, y are normalized to axis range coordinates of the point. +@c This type of coloring is useful for isosurface plot where color may show the exact position of a piece of surface. + +Additionally, MathGL can apply mask to face filling at bitmap rendering. The kind of mask is specified by one of symbols @samp{-+=;oOsS~<>jdD*^} in color scheme. Mask can be rotated by arbitrary angle by command @ref{mask} or by three predefined values +45, -45 and 90 degree by symbols @samp{\/I} correspondingly. Examples of predefined masks are shown on the figure below. + +@pfig{mask, Example of masks for face coloring.} + +However, you can redefine mask for one symbol by specifying new matrix of size 8*8 as second argument for @ref{mask} command. For example, the right-down subplot on the figure above is produced by code@* +@ifclear UDAV +@code{gr->SetMask('+', "ff00182424f80000"); gr->Dens(a,"3+");} +@end ifclear +@ifset UDAV +@code{mask '+' 'ff00182424f80000':dens a '3+'} +@end ifset + +@c ------------------------------------------------------------------ +@external{} +@node Font styles, Textual formulas, Color scheme, General concepts +@section Font styles +@nav{} + +@cindex Font styles + +Text style is specified by the string which may contain: color id characters @samp{wkrgbcymhRGBCYMHW} (see @ref{Color styles}), and font style (@samp{ribwou}) and/or alignment (@samp{LRC}) specifications. At this, font style and alignment begin after the separator @samp{:}. For example, @samp{r:iCb} sets the bold (@samp{b}) italic (@samp{i}) font text aligned at the center (@samp{C}) and with red color (@samp{r}). + +The font styles are: @samp{r} -- roman (or regular) font, @samp{i} -- italic style, @samp{b} -- bold style. By default roman roman font is used. The align types are: @samp{L} -- align left (default), @samp{C} -- align center, @samp{R} -- align right. Additional font effects are: @samp{w} -- wired, @samp{o} -- over-lined, @samp{u} -- underlined. + +Also a parsing of the LaTeX-like syntax is provided. There are commands for the font style changing inside the string (for example, use \b for bold font): \a or \overline -- over-lined, \b or \textbf -- bold, \i or \textit -- italic, \r or \textrm -- roman (disable bold and italic attributes), \u or \underline -- underlined, \w or \wire -- wired, \big -- bigger size, @@ -- smaller size. The lower and upper indexes are specified by @samp{_} and @samp{^} symbols. At this the changed font style is applied only on next symbol or symbols in braces @{@}. The text in braces @{@} are treated as single symbol that allow one to print the index of index. For example, compare the strings @samp{sin (x^@{2^3@})} and @samp{sin (x^2^3)}. You may also change text color inside string by command #? or by \color? where @samp{?} is symbolic id of the color (@pxref{Color styles}). For example, words @samp{blue} and @samp{red} will be colored in the string @samp{#b@{blue@} and \colorr@{red@} text}. The most of functions understand the newline symbol @samp{\n} and allows to print multi-line text. Finally, you can use arbitrary (if it was defined in font-face) UTF codes by command @code{\utf0x????}. For example, @code{\utf0x3b1} will produce +@ifhtml +@html + α symbol. +@end html +@end ifhtml +@ifnothtml + @math{\alpha} symbol. +@end ifnothtml + +The most of commands for special TeX or AMSTeX symbols, the commands for font style changing (\textrm, \textbf, \textit, \textsc, \overline, \underline), accents (\hat, \tilde, \dot, \ddot, \acute, \check, \grave, \bar, \breve) and roots (\sqrt, \sqrt3, \sqrt4) are recognized. The full list contain approximately 2000 commands. Note that first space symbol after the command is ignored, but second one is printed as normal symbol (space). For example, the following strings produce the same result @math{\tilde a}: @samp{\tilde@{a@}}; @samp{\tilde a}; @samp{\tilde@{@}a}. + +@ifhtml +@html +In particular, the Greek letters are recognizable special symbols: α – \alpha, β – \beta, γ – \gamma, δ – \delta, ε – \epsilon, η – \eta, ι – \iota, χ – \chi, κ – \kappa, λ – \lambda, μ – \mu, ν – \nu, o – \o, ω – \omega, ϕ – \phi, π – \pi, ψ – \psi, ρ – \rho, σ – \sigma, θ – \theta, τ – \tau, υ – \upsilon, ξ – \xi, ζ – \zeta, ς – \varsigma, ɛ – \varepsilon, ϑ – \vartheta, φ – \varphi, ϰ – \varkappa; A – \Alpha, B – \Beta, Γ – \Gamma, Δ – \Delta, E – \Epsilon, H – \Eta, I – \Iota, C – \Chi, K – \Kappa, Λ – \Lambda, M – \Mu, N – \Nu, O – \O, Ω – \Omega, Φ – \Phi, Π – \Pi, Ψ – \Psi, R – \Rho, Σ – \Sigma, Θ – \Theta, T – \Tau, Υ – \Upsilon, Ξ – \Xi, Z – \Zeta. + +

The small part of most common special TeX symbols are: ∠ – \angle, ⋅ – \cdot, ♣ – \clubsuit, ✓ – \checkmark, ∪ – \cup, ∩ – \cap, ♢ – \diamondsuit, ◇ – \diamond, ÷ + – \div, +↓ – \downarrow, † – \dag, ‡ – \ddag, ≡ – \equiv, ∃ – \exists, ⌢ – \frown, ♭ – \flat, ≥ – \ge, ≥ – \geq, ≧ – \geqq, ← – \gets, ♡ – \heartsuit, ∞ – \infty, ∫ – \int, \Int, ℑ – \Im, ♢ – \lozenge, ⟨ – \langle, ≤ – \le, ≤ – \leq, ≦ – \leqq, ← – \leftarrow, ∓ – \mp, ∇ – \nabla, ≠ – \ne, ≠ – \neq, ♮ – \natural, ∮ – \oint, ⊙ – \odot, ⊕ – \oplus, ∂ – \partial, ∥ – \parallel, ⊥ –\perp, ± – \pm, ∝ – \propto, ∏ – \prod, ℜ – \Re, → – \rightarrow, ⟩ – \rangle, ♠ – \spadesuit, ~ – \sim, ⌣ – \smile, ⊂ – \subset, ⊃ – \supset, √ – \sqrt or \surd, § – \S, ♯ – \sharp, ∑ – \sum, × – \times, → – \to, ∴ – \therefore, ↑ – \uparrow, ℘ – \wp.

+@end html +@end ifhtml +@ifnothtml +In particular, the Greek letters are recognizable special symbols: @math{\alpha} -- \alpha, @math{\beta} -- \beta, @math{\gamma} -- \gamma, @math{\delta} -- \delta, @math{\epsilon} -- \epsilon, @math{\eta} -- \eta, @math{\iota} -- \iota, @math{\chi} -- \chi, @math{\kappa} -- \kappa, @math{\lambda} -- \lambda, @math{\mu} -- \mu, @math{\nu} -- \nu, @math{o} -- \o, @math{\omega} -- \omega, @math{\phi} -- \phi, @math{\pi} -- \pi, @math{\psi} -- \psi, @math{\rho} -- \rho, @math{\sigma} -- \sigma, @math{\theta} -- \theta, @math{\tau} -- \tau, @math{\upsilon} -- \upsilon, @math{\xi} -- \xi, @math{\zeta} -- \zeta, @math{\varsigma} -- \varsigma, @math{\varepsilon} -- \varepsilon, @math{\vartheta} -- \vartheta, @math{\varphi} -- \varphi, A -- \Alpha, B -- \Beta, @math{\Gamma} -- \Gamma, @math{\Delta} -- \Delta, E -- \Epsilon, H -- \Eta, I -- \Iota, C -- \Chi, K -- \Kappa, @math{\Lambda} -- \Lambda, M -- \Mu, N -- \Nu, O -- \O, @math{\Omega} -- \Omega, @math{\Phi} -- \Phi, @math{\Pi} -- \Pi, @math{\Psi} -- \Psi, R -- \Rho, @math{\Sigma} -- \Sigma, @math{\Theta} -- \Theta, T -- \Tau, @math{\Upsilon} -- \Upsilon, @math{\Xi} -- \Xi, Z -- \Zeta. + +The small part of most common special TeX symbols are: @math{\angle} -- \angle, @math{\aleph} -- \aleph, @math{\cdot} -- \cdot, @math{\clubsuit} -- \clubsuit, @math{\cup} -- \cup, @math{\cap} -- \cap, @math{\diamondsuit} -- \diamondsuit, @math{\diamond} -- \diamond, @math{\div} -- \div, @math{\downarrow} -- \downarrow, @math{\dag} -- \dag, @math{\ddag} -- \ddag, @math{\equiv} -- \equiv, @math{\exists} -- \exists, @math{\frown} -- \frown, @math{\flat} -- \flat, @math{\ge} -- \ge, @math{\geq} -- \geq, @math{\gets} -- \gets, @math{\heartsuit} -- \heartsuit, @math{\infty} -- \infty, @math{\in} -- \in, @math{\int} -- \int, @math{\Im} -- \Im, @math{\langle} -- \langle, @math{\le} -- \le, @math{\leq} -- \leq, @math{\leftarrow} -- \leftarrow, @math{\mp} -- \mp, @math{\nabla} -- \nabla, @math{\ne} -- \ne, @math{\neq} -- \neq, @math{\natural} -- \natural, @math{\oint} -- \oint, @math{\odot} -- \odot, @math{\oplus} -- \oplus, @math{\partial} -- \partial, @math{\parallel} -- \parallel, @math{\perp} -- \perp, @math{\pm} -- \pm, @math{\propto} -- \propto, @math{\prod} -- \prod, @math{\Re} -- \Re, @math{\rightarrow} -- \rightarrow, @math{\rangle} -- \rangle, @math{\spadesuit} -- \spadesuit, @math{\sim} -- \sim, @math{\smile} -- \smile, @math{\subset} -- \subset, @math{\supset} -- \supset, @math{\surd} -- \sqrt or \surd, @math{\S} -- \S, @math{\sharp} -- \sharp, @math{\sum} -- \sum, @math{\times} -- \times, @math{\to} -- \to, @math{\uparrow} -- \uparrow, @math{\wp} -- \wp and so on. +@end ifnothtml + +The font size can be defined explicitly (if @var{size}>0) or relatively to a base font size as |@var{size}|*@var{FontSize} (if @var{size}<0). The value @var{size}=0 specifies that the string will not be printed. The base font size is measured in internal ``MathGL'' units. Special functions @code{SetFontSizePT(), SetFontSizeCM(), SetFontSizeIN()} (see @ref{Font settings}) allow one to set it in more ``common'' variables for a given dpi value of the picture. + +@c ------------------------------------------------------------------ +@external{} +@node Textual formulas, Command options, Font styles, General concepts +@section Textual formulas +@nav{} + +@cindex Textual formulas + +MathGL have the fast variant of textual formula evaluation +@ifclear UDAV +(@pxref{Evaluate expression}) +@end ifclear +. There are a lot of functions and operators available. The operators are: @samp{+} -- addition, @samp{-} -- subtraction, @samp{*} -- multiplication, @samp{/} -- division, @samp{^} -- integer power. Also there are logical ``operators'': @samp{<} -- true if x} -- true if x>y, @samp{=} -- true if x=y, @samp{&} -- true if x and y both nonzero, @samp{|} -- true if x or y nonzero. These logical operators have lowest priority and return 1 if true or 0 if false. + +The basic functions are: @samp{sqrt(x)} -- square root of @var{x}, @samp{pow(x,y)} -- power @var{x} in @var{y}, @samp{ln(x)} -- natural logarithm of @var{x}, @samp{lg(x)} -- decimal logarithm of @var{x}, @samp{log(a,x)} -- logarithm base @var{a} of @var{x}, @samp{abs(x)} -- absolute value of @var{x}, @samp{sign(x)} -- sign of @var{x}, @samp{mod(x,y)} -- x modulo y, @samp{step(x)} -- step function, @samp{int(x)} -- integer part of @var{x}, @samp{rnd} -- random number, @samp{pi} -- number +@ifhtml +@html +π = 3.1415926… +@end html +@end ifhtml +@ifnothtml +@math{\pi=3.1415926...} +@end ifnothtml + +Trigonometric functions are: @samp{sin(x)}, @samp{cos(x)}, @samp{tan(x)} (or @samp{tg(x)}). Inverse trigonometric functions are: @samp{asin(x)}, @samp{acos(x)}, @samp{atan(x)}. Hyperbolic functions are: @samp{sinh(x)} (or @samp{sh(x)}), @samp{cosh(x)} (or @samp{ch(x)}), @samp{tanh(x)} (or @samp{th(x)}). Inverse hyperbolic functions are: @samp{asinh(x)}, @samp{acosh(x)}, @samp{atanh(x)}. + +@ifhtml +@html +

There are a set of special functions: ‘gamma(x)’ – Gamma function Γ(x) = ∫0 tx-1 exp(-t) dt, ‘psi(x)’ – digamma function ψ(x) = Γ′(x)/Γ(x) for x≠0, ‘ai(x)’ – Airy function Ai(x), ‘bi(x)’ – Airy function Bi(x), ‘cl(x)’ – Clausen function, ‘li2(x)’ (or ‘dilog(x)’) – dilogarithm Li2(x) = -ℜ∫0xds log(1-s)/s, ‘sinc(x)’ – compute sinc(x) = sin(πx)/(πx) for any value of x, ‘zeta(x)’ – Riemann zeta function ζ(s) = ∑k=1k-s for arbitrary s≠1, ‘eta(x)’ – eta function η(s) = (1 - 21-s)ζ(s) for arbitrary s, ‘lp(l,x)’ – Legendre polynomial Pl(x), (|x|≤1, l≥0), ‘w0(x)’ – principal branch of the Lambert W function, ‘w1(x)’ – principal branch of the Lambert W function. Function W(x) is defined to be solution of the equation: W exp(W) = x.

+ +

The exponent integrals are: ‘ci(x)’ – Cosine integral Ci(x) = ∫0xdt cos(t)/t, ‘si(x)’ – Sine integral Si(x) = ∫0xdt sin(t)/t, ‘erf(x)’ – error function erf(x) = (2/√π) ∫0xdt exp(-t2) , ‘ei(x)’ – exponential integral Ei(x) = -PV(∫-xdt exp(-t)/t) (where PV denotes the principal value of the integral), ‘e1(x)’ – exponential integral E1(x) = ℜ∫1dt exp(-xt)/t, ‘e2(x)’ – exponential integral E2(x) = ℜ∫1∞dt exp(-xt)/t2, ‘ei3(x)’ – exponential integral Ei3(x) = ∫0xdt exp(-t3) for x≥0.

+ +

Bessel functions are: ‘j(nu,x)’ – regular cylindrical Bessel function of fractional order nu, ‘y(nu,x)’ – irregular cylindrical Bessel function of fractional order nu, ‘i(nu,x)’ – regular modified Bessel function of fractional order nu, ‘k(nu,x)’ – irregular modified Bessel function of fractional order nu.

+ +

Elliptic integrals are: ‘ee(k)’ – complete elliptic integral is denoted by E(k) = E(π/2,k), ‘ek(k)’ – complete elliptic integral is denoted by K(k) = F(π/2,k), ‘e(phi,k)’ – elliptic integral E(φ,k) = ∫0φdt √(1 - k2sin2(t)), ‘f(phi,k)’ – elliptic integral F(φ,k) = ∫0φdt 1/√(1 - k2sin2(t))

+@end html +@end ifhtml +@ifnothtml +There are a set of special functions: @samp{gamma(x)} -- Gamma function @math{\Gamma(x) = \int_0^\infty dt t^@{x-1@} \exp(-t)} , @samp{psi(x)} -- digamma function @math{\psi(x) = \Gamma'(x)/\Gamma(x)} for x!=0, @samp{ai(x)} -- Airy function Ai(x), @samp{bi(x)} -- Airy function Bi(x), @samp{cl(x)} -- Clausen function, @samp{li2(x)} (or @samp{dilog(x)}) -- dilogarithm @math{Li_2(x) = - \Re \int_0^x ds \log(1-s)/s}, @samp{sinc(x)} -- compute @math{sinc(x) = \sin(\pi x) / (\pi x)} for any value of x, @samp{zeta(x)} -- Riemann zeta function @math{\zeta(s) = \sum_@{k=1@}^\infty k^@{-s@}} for arbitrary s!=1, @samp{eta(x)} -- eta function @math{\eta(s) = (1-2^@{1-s@}) \zeta(s)} for arbitrary s, @samp{lp(l,x)} -- Legendre polynomial @math{P_l(x)}, (|x|<=1, l>=0), @samp{w0(x)}, @samp{w1(x)} -- principal branch of the Lambert @var{W} functions. Function W(x) is defined to be solution of the equation @math{W \exp(W) = x}. + +The exponent integrals are: @samp{ci(x)} -- Cosine integral @math{Ci(x) = \int_0^x dt \cos(t)/t}, @samp{si(x)} -- Sine integral @math{Si(x) = \int_0^x dt \sin(t)/t}, @samp{erf(x)} -- error function @math{erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2)}, @samp{ei(x)} -- exponential integral @math{Ei(x) := - PV(\int_@{-x@}^\infty dt \exp(-t)/t)} (where PV denotes the principal value of the integral), @samp{e1(x)} -- exponential integral @math{E_1(x) := Re \int_1^\infty dt \exp(-xt)/t} , @samp{e2(x)} -- exponential integral @math{E_2(x) := Re \int_1^\infty dt \exp(-xt)/t^2}, @samp{ei3(x)} -- exponential integral @math{Ei_3(x) = \int_0^x dt \exp(-t^3)} for x>=0. + +Bessel functions are: @samp{j(nu,x)} -- regular cylindrical Bessel function of fractional order @var{nu}, @samp{y(nu,x)} -- irregular cylindrical Bessel function of fractional order @var{nu}, @samp{i(nu,x)} -- regular modified Bessel function of fractional order @var{nu}, @samp{k(nu,x)} -- irregular modified Bessel function of fractional order @var{nu}. + +Elliptic integrals are: @samp{ee(k)} -- complete elliptic integral is denoted by @math{E(k) = E(\pi/2, k)}, @samp{ek(k)} -- complete elliptic integral is denoted by @math{K(k) = F(\pi/2, k)}, @samp{e(phi,k)} -- elliptic integral @math{E(\phi,k) = \int_0^\phi dt \sqrt((1 - k^2 \sin^2(t)))}, @samp{f(phi,k)} -- elliptic integral @math{F(\phi,k) = \int_0^\phi dt 1/\sqrt((1 - k^2 \sin^2(t)))}. +@end ifnothtml + +Jacobi elliptic functions are: @samp{sn(u,m)}, @samp{cn(u,m)}, @samp{dn(u,m)}, @samp{sc(u,m)}, @samp{sd(u,m)}, @samp{ns(u,m)}, @samp{cs(u,m)}, @samp{cd(u,m)}, @samp{nc(u,m)}, @samp{ds(u,m)}, @samp{dc(u,m)}, @samp{nd(u,m)}. + +Note, some of these functions are unavailable if MathGL was compiled without GSL support. + +There is no difference between lower or upper case in formulas. If argument value lie outside the range of function definition then function returns NaN. + +@c ------------------------------------------------------------------ +@external{} +@node Command options, Interfaces, Textual formulas, General concepts +@section Command options +@nav{} + +Command options allow the easy setup of the selected plot by changing global settings only for this plot. Each option start from symbol @samp{;}. Options work so that MathGL remember the current settings, change settings as it being set in the option, execute function and return the original settings back. So, the options are most usable for plotting functions. + +The most useful options are @code{xrange, yrange, zrange}. They sets the boundaries for data change. This boundaries are used for automatically filled variables. So, these options allow one to change the position of some plots. For example, in command @code{Plot(y,"","xrange 0.1 0.9");} or @code{plot y; xrange 0.1 0.9} the x coordinate will be equidistantly distributed in range 0.1 ... 0.9. @sref{Using options} + +The full list of options are: +@cindex alpha +@cindex alphadef +@deffn {MGL option} alpha @code{val} +Sets alpha value (transparency) of the plot. The value should be in range [0, 1]. See also @ref{alphadef}. +@end deffn +@c @cindex ambient +@c @deffn {MGL option} ambient @code{val} +@c Sets brightness of ambient light for the plot. The value should be in range [0, 1]. See also @ref{ambient}. +@c @end deffn +@c @cindex diffuse +@c @deffn {MGL option} diffuse @code{val} +@c Sets brightness of diffuse light for the plot. The value should be in range [0, 1]. See also @ref{diffuse}. +@c @end deffn + +@cindex xrange +@deffn {MGL option} xrange @code{val1 val2} +Sets boundaries of x coordinate change for the plot. See also @ref{xrange}. +@end deffn +@cindex yrange +@deffn {MGL option} yrange @code{val1 val2} +Sets boundaries of y coordinate change for the plot. See also @ref{yrange}. +@end deffn +@cindex zrange +@deffn {MGL option} zrange @code{val1 val2} +Sets boundaries of z coordinate change for the plot. See also @ref{zrange}. +@end deffn + +@cindex cut +@deffn {MGL option} cut @code{val} +Sets whether to cut or to project the plot points lying outside the bounding box. See also @ref{cut}. +@end deffn +@cindex fontsize +@deffn {MGL option} size @code{val} +Sets the size of text, marks and arrows. See also @ref{font}, @ref{marksize}, @ref{arrowsize}. +@end deffn +@cindex meshnum +@deffn {MGL option} meshnum @code{val} +Work like @ref{meshnum} command. +@end deffn + +@cindex legend +@deffn {MGL option} legend 'txt' +Adds string 'txt' to internal legend accumulator. The style of described line and mark is taken from arguments of the last @ref{1D plotting} command. See also @ref{legend}. +@end deffn +@cindex value +@deffn {MGL option} value @code{val} +Set the value to be used as additional numeric parameter in plotting command. +@end deffn + + + +@c ------------------------------------------------------------------ +@external{} +@node Interfaces, , Command options, General concepts +@section Interfaces +@nav{} + +@ifset UDAV +You can use @code{mglParse} class for executing MGL scripts from different languages. +@end ifset + +@ifclear UDAV + +The MathGL library has interfaces for a set of languages. Most of them are based on the C interface via SWIG tool. There are Python, Java, Octave, Lisp, C#, Guile, Lua, Modula 3, Ocaml, Perl, PHP, Pike, R, Ruby, and Tcl interfaces. Also there is a Fortran interface which has a similar set of functions, but slightly different types of arguments (integers instead of pointers). These functions are marked as [C function]. + +Some of the languages listed above support classes (like C++ or Python). The name of functions for them is the same as in C++ (see @ref{MathGL core} and @ref{Data processing}) and marked like [Method on mglGraph]. + +Finally, a special command language MGL (see @ref{MGL scripts}) was written for a faster access to plotting functions. Corresponding scripts can be executed separately (by UDAV, mglconv, mglview and so on) or from the C/C++/Python/... code (@pxref{mglParse class}). + +@menu +* C interface:: +* C++ interface:: +@end menu + +@external{} +@node C interface, C++ interface, , Interfaces +@subsection C/Fortran interface +@nav{} + +The C interface is a base for many other interfaces. It contains the pure C functions for most of the methods of MathGL classes. In distinction to C++ classes, C functions must have an argument HMGL (for graphics) and/or HMDT (for data arrays), which specifies the object for drawing or manipulating (changing). So, firstly, the user has to create this object by the function @code{mgl_create_*()} and has to delete it after the use by function @code{mgl_delete_*()}. + +All C functions are described in the header file @code{#include } and use variables of the following types: +@itemize +@item +@code{HMGL} --- Pointer to class @code{mglGraph} (@pxref{MathGL core}). +@item +@code{HCDT} --- Pointer to class @code{const mglDataA} (@pxref{Data processing}) --- constant data array. +@item +@code{HMDT} --- Pointer to class @code{mglData} (@pxref{Data processing}) --- data array of real numbers. +@item +@code{HADT} --- Pointer to class @code{mglDataC} (@pxref{Data processing}) --- data array of complex numbers. +@item +@code{HMPR} --- Pointer to class @code{mglParse} (@pxref{mglParse class}) --- MGL script parsing. +@item +@code{HMEX} --- Pointer to class @code{mglExpr} (@pxref{Evaluate expression}) --- textual formulas for real numbers. +@item +@code{HMAX} --- Pointer to class @code{mglExprC} (@pxref{Evaluate expression}) --- textual formulas for complex numbers. +@end itemize +These variables contain identifiers for graphics drawing objects and for the data objects. + +Fortran functions/subroutines have the same names as C functions. However, there is a difference. Variable of type @code{HMGL, HMDT} must be an integer with sufficient size (@code{integer*4} in the 32-bit operating system or @code{integer*8} in the 64-bit operating system). All C functions of type @code{void} are subroutines in Fortran, which are called by operator @code{call}. The exceptions are functions, which return variables of types @code{HMGL} or @code{HMDT}. These functions should be declared as integer in Fortran code. Also, one should keep in mind that strings in Fortran are denoted by @code{'} symbol, not the @code{"} symbol. + +@external{} +@node C++ interface, , C interface, Interfaces +@subsection C++/Python interface +@nav{} + +MathGL provides the interface to a set of languages via SWIG library. Some of these languages support classes. The typical example is Python -- which is named in this chapter's title. Exactly the same classes are used for high-level C++ API. Its feature is using only inline member-functions what make high-level API to be independent on compiler even for binary build. + +There are 3 main classes in: +@itemize +@item @code{mglGraph} +-- provide most plotting functions (see @ref{MathGL core}). +@item @code{mglData} +-- provide base data processing (see @ref{Data processing}). It have an additional feature to access data values. You can use a construct like this: @code{dat[i]=sth;} or @code{sth=dat[i]} where flat representation of data is used (i.e., @var{i} can be in range 0...nx*nx*nz-1). You can also import NumPy arrays as input arguments in Python: @code{mgl_dat = mglData(numpy_dat);}. +@item @code{mglParse} +-- provide functions for parsing MGL scripts (see @ref{MGL scripts}). +@end itemize + + +To use Python classes just execute @samp{import mathgl}. The simplest example will be: +@verbatim +import mathgl +a=mathgl.mglGraph() +a.Box() +a.WritePNG("test.png") +@end verbatim +Alternatively you can import all classes from @code{mathgl} module and easily access MathGL classes like this: +@verbatim +from mathgl import * +a=mglGraph() +a.Box() +a.WritePNG("test.png") +@end verbatim +This becomes useful if you create many @code{mglData} objects, for example. + +@end ifclear + +@external{} diff --git a/texinfo/concept_ru.texi b/texinfo/concept_ru.texi new file mode 100644 index 0000000..0e81550 --- /dev/null +++ b/texinfo/concept_ru.texi @@ -0,0 +1,382 @@ +@chapter Основные принципы +@nav{} + +Возможности библиотеки MathGL довольно богаты -- число только основных типов графиков превышает 50 видов. Кроме того, есть функции для обработки данных, настройки вида графика и пр. и пр. Тем не менее, я старался придерживаться единого стиля в порядке аргументов функций и способе их ``настройки''. В основном все ниже сказанное относится к функциям рисования различных графиков. + +Всего основных концепций (базисных идей) шесть: +@enumerate +@item +@strong{Все рисунки создаются в памяти.} Это могут быть как растровые картинки (для @code{SetQuality(MGL_DRAW_LMEM)}), так и векторные списки примитивов (по умолчанию). Дальнейшая судьба рисунков определяется пользователем: можно сохранить в файл, вывести на экран, создать анимацию/кино, дополнительно отредактировать и т.д. Такой подход обеспечивает высокую переносимость библиотеки -- один и тот же программный код создаст в точности одинаковый рисунок на @emph{любой} операционной системе. Кроме того, при таком подходе рисунки можно создавать непосредственно в консольной программе -- графическое окно не нужно! +@item +@strong{Все настройки графиков (стиль линий, цветовые схемы поверхностей, стиль и цвет текста) задаются строками.} Это обеспечивает: удобство для пользователя -- короткую строку легче читать и здесь тяжелее ошибиться, чем в большом списке параметров; переносимость -- строки выглядят одинаково на всех платформах и не надо заботиться о типе и числе аргументов. +@item +@strong{Все функции имеют ``упрощенный'' и ``продвинутый'' варианты.} Сделано опять из-за удобства. В ``упрощенном'' варианте для построения графика нужны только один-два массив(а) данных, которые автоматически равнораспределяются в заданном диапазоне осей координат. В ``продвинутой'' версии можно не только указать явно диапазон построения графика, но и задать его параметрически. Последнее позволяет легко строить довольно сложные кривые и поверхности. В обоих вариантах функций порядок аргументов стандартен: сначала идут массивы данных, потом необязательный строковый параметр стиля графика, а далее строка опций для более точной настройки графика. +@item +@strong{Все данные передаются через экземпляры класса mglData(A).} Такой подход позволяет избежать ошибок при работе с памятью и единообразно передавать данные разных типов (mreal, double, данные из файла, заполненных пользователем и пр.) в функции рисования. +@item +@strong{Все элементы рисунков векторные.} Изначально библиотека MathGL была ориентированна на работу с научными данными, которые по своей природе векторные (линии, грани, матрицы и т.д.). Поэтому векторность используется во всех рисунках! Причем иногда даже в ущерб производительности (например, при выводе шрифтов). Помимо всего прочего, векторность позволяет легко масштабировать рисунок -- измените размер картинки в 2 раза, и рисунок пропорционально растянется. +@item +@strong{Новые графики не удаляют уже нарисованное.} Этот, в чем-то неожиданный, подход позволяет создавать огромное количество ``комбинированных'' графиков. Например, поверхность с наложенными линиями уровня строится двумя последовательными вызовами функций рисования поверхности и линий уровня (в любом порядке). И совершенно не надо писать специальную функцию (как в Matlab и некоторых других программах) для рисования этого графика. +@end enumerate + +Кроме основных концепций я хотел бы остановиться на нескольких, как оказалось, нетривиальных моментах -- способе указания положения графика, осей координат и строковых параметров линий, поверхностей, текста. + +@menu +* Coordinate axes:: +* Color styles:: +* Line styles:: +* Color scheme:: +* Font styles:: +* Textual formulas:: +* Command options:: +* Interfaces:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Coordinate axes, Color styles, , General concepts +@section Оси координат +@nav{} + +Представление системы координат в MathGL состоит из двух частей. Вначале координаты нормируются в интервал @var{Min}x@var{Max} (@pxref{Axis settings}). Если флаг @code{SetCut()} установлен, то точки вне интервала отбрасываются, в противном случае, они проецируются на ограничивающий параллелепипед (см. @ref{Cutting}). Кроме того, отбрасываются точки внутри границ, определенных переменными @var{CutMin}x@var{CutMax} и точки, для которых значение функции @code{CutOff}() не равно нулю. После этого формулы перехода в криволинейную систему координат @code{SetFunc()}применяются к каждой точке. Наконец, точка данных отображается с помощью одной из графических функций. + +Диапазон изменения @emph{x, y, z}-координат задается функциями @code{SetRange()} или @code{SetRanges()}. Точка пересечения осей координат задается функцией @code{SetOrigin()}. При этом можно использовать NAN значения для автоматического выбора положения оси. + +Кроме привычных осей @emph{x, y, z} есть еще одна ось -- цветовая шкала -- ось @emph{c}. Она используется при окрашивании поверхностей и задает границы изменения функции при окрашивании. Ее границы автоматически устанавливаются равными Min.z и Max.z при вызове @code{SetRanges()}. Возможно и ручное изменение границ цветового интервала посредством вызова @code{SetRange('c', ...)}. Используйте @code{Colorbar()} для отображения цветовой шкалы. + +Вид меток по осям определяется функцией @code{SetTicks()} (@pxref{Ticks}). Функция @var{SetTuneTicks} включает/выключает выделение общего множителя (большого или малого факторов в диапазоне) для меток осей координат. Наконец, если стандартный вид меток не устраивает пользователя, то их шаблон можно задать явно (можно использовать и ТеХ символы), воспользовавшись функцией @code{SetTickTempl()}. Кроме того, в качестве меток можно вывести произвольный текст использовав функцию @code{SetTicksVal()}. + +@c ------------------------------------------------------------------ +@external{} +@node Color styles, Line styles, Coordinate axes, General concepts +@section Цвета +@nav{} + +Base colors are defined by one of symbol @samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}. +@ifhtml +@html +

Символы цвета: ‘k’ – черный, ‘r’ – красный, ‘R’ – темно красный, ‘g’ – зеленый, ‘G’ – темно зеленый, ‘b’ – синий, ‘B’ – темно синий, ‘c’ – голубой, ‘C’ – темно голубой, ‘m’ – пурпурный, ‘M’ – темно пурпурный, ‘y’ – желтый, ‘Y’ – темно желтый (золотой), ‘h’ – серый, ‘H’ – темно серый, ‘w’ – белый, ‘W’ – светло серый, ‘l’ – сине-зеленый, ‘L’ – темно сине-зеленый, ‘e’ – желто-зеленый, ‘E’ – темно желто-зеленый, ‘n’ – небесно-синий, ‘N’ – темно небесно-синий, ‘u’ – сине-фиолетовый, ‘U’ – темно сине-фиолетовый, ‘p’ – фиолетовый, ‘P’ – темно фиолетовый, ‘q’ – оранжевый, ‘Q’ – темно оранжевый (коричневый).

+@end html +@end ifhtml +@ifnothtml +Символы цвета: @samp{k} -- черный, @samp{r} -- красный, @samp{R} -- темно красный, @samp{g} -- зеленый, @samp{G} -- темно зеленый, @samp{b} -- синий, @samp{B} -- темно синий, @samp{c} -- голубой, @samp{C} -- темно голубой, @samp{m} -- пурпурный, @samp{M} -- темно пурпурный, @samp{y} -- желтый, @samp{Y} -- темно желтый (золотой), @samp{h} -- серый, @samp{H} -- темно серый, @samp{w} -- белый, @samp{W} -- светло серый, @samp{l} -- сине-зеленый, @samp{L} -- темно сине-зеленый, @samp{e} -- желто-зеленый, @samp{E} -- темно желто-зеленый, @samp{n} -- небесно-синий, @samp{N} -- темно небесно-синий, @samp{u} -- сине-фиолетовый, @samp{U} -- темно сине-фиолетовый, @samp{p} -- фиолетовый, @samp{P} -- темно фиолетовый, @samp{q} -- оранжевый, @samp{Q} -- темно оранжевый (коричневый). +@end ifnothtml + +В цветовой схеме можно использовать тональные (``подсвеченные'') цвета. Тональный цвет задается двумя символами в фигурных скобках @samp{@{cN@}}: первый -- обычный цвет, второй -- его яркость цифрой. Цифра может быть в диапазоне @samp{1}...@samp{9}. При этом @samp{5} соответствует нормальному цвету, @samp{1} -- очень темная версия цвета (почти черный), @samp{9} -- очень светлая версия цвета (почти белый). Например, цвета могут быть @samp{@{b2@}} @samp{@{b7@}} @samp{@{r7@}} и т.д. + +Наконец, можно указать явно RGB или RGBA значения цвета, используя формат @samp{@{xRRGGBB@}} или @samp{@{xRRGGBBAA@}} соответственно. Например, @samp{@{xFF9966@}} даст цвет +@ifhtml +@html +дыни. +@end html +@end ifhtml +@ifnothtml +дыни. +@end ifnothtml + +@c ------------------------------------------------------------------ +@external{} +@node Line styles, Color scheme, Color styles, General concepts +@section Стиль линий +@nav{} + +@cindex Стиль линий +@cindex Стиль маркеров +@cindex Стиль стрелок + +Стиль линии задается строкой, которая может содержать символ цвета (@samp{wkrgbcymhRGBCYMHWlenupqLENUPQ}), тип пунктира (@samp{-|;:ji} или пробел), ширину линии (@samp{0123456789}) и тип маркера (@samp{o+xsd.^v} и модификатор @samp{#}). Если пропущен цвет или тип пунктира, то используется значение по умолчанию с последним указанным цветом или значение из палитры (для @pxref{1D plotting}). +@ifhtml +@html +По умолчанию палитры содержит следующие цвета: темно серыйH’, синийb’, зеленыйg’, красныйr’, голубойc’, пурпурныйm’, yellowy’, серыйh’, сине-зеленыйl’, небесно-синийn’, оранжевыйq’, желто-зеленыйe’, сине-фиолетовыйu’, фиолетовыйp’. + +

Тип пунктира: пробел – нет линии (для рисования только маркеров), ‘-’ – сплошная линия (■■■■■■■■■■■■■■■■), ‘|’ – длинный пунктир (■■■■■■■■□□□□□□□□), ‘;’ – пунктир (■■■■□□□□■■■■□□□□), ‘=’ – короткий пунктир (■■□□■■□□■■□□■■□□), ‘:’ – точки (■□□□■□□□■□□□■□□□), ‘j’ – пунктир с точками (■■■■■■■□□□□■□□□□), ‘i’ – мелкий пунктир с точками (■■■□□■□□■■■□□■□□).

+@end html +@end ifhtml +@ifnothtml +По умолчанию палитра содержит следующие цвета: темно серый @samp{H}, синий @samp{b}, зеленый @samp{g}, красный @samp{r}, голубой @samp{c}, пурпурный @samp{m}, yellow @samp{y}, серый @samp{h}, сине-зеленый @samp{l}, небесно-синий @samp{n}, оранжевый @samp{q}, желто-зеленый @samp{e}, сине-фиолетовый @samp{u}, фиолетовый @samp{p}. + +Тип пунктира: пробел -- нет линии (для рисования только маркеров), @samp{-} -- сплошная линия (################), @samp{|} -- длинный пунктир (########________), @samp{;} -- пунктир (####____####____), @samp{=} -- короткий пунктир (##__##__##__##__), @samp{:} -- точки (#___#___#___#___), @samp{j} -- пунктир с точками (#######____#____), @samp{i} -- мелкий пунктир с точками (###__#__###__#__). +@end ifnothtml + +Типы маркеров: @samp{o} -- окружность, @samp{+} -- крест, @samp{x} -- косой крест, @samp{s} -- квадрат, @samp{d} - ромб, @samp{.} -- точка, @samp{^} -- треугольник вверх, @samp{v} -- треугольник вниз, @samp{<} -- треугольник влево, @samp{>} -- треугольник вправо, @samp{#*} -- знак Y, @samp{#+} -- крест в квадрате, @samp{#x} -- косой крест в квадрате, @samp{#.} -- точка в окружности. Если в строке присутствует символ @samp{#}, то используются символы с заполнением. + +На конце и в начале линии можно выводить специальный символ (стрелку), если в строке указать один из символов: @samp{A} -- стрелка наружу, @samp{V} -- стрелка внутрь, @samp{I} -- поперечная черта, @samp{K} -- стрелка с чертой, @samp{T} -- треугольник, @samp{S} -- квадрат, @samp{D} -- ромб, @samp{O} -- круг, @samp{_} -- нет стрелки (по умолчанию). При этом действует следующее правило: первый символ определяет стрелку на конце линии, второй символ -- стрелку в начале линии. Например, @samp{r-A} -- красная сплошная линия со стрелкой на конце, @samp{b|AI} -- синий пунктир со стрелкой на конце и чертой вначале, @samp{_O} -- линия с текущим стилем и кружком вначале. Эти стили действуют и при построении графиков (например, @ref{1D plotting}). + +@pfig{style, Color and line styles.} + +@c ------------------------------------------------------------------ +@external{} +@node Color scheme, Font styles, Line styles, General concepts +@section Цветовая схема +@nav{} + +@cindex Цветовая схема + +Цветовая схема используется для определения цвета поверхностей, линий уровня и пр. Цветовая схема задается строкой @emph{s}, которая содержит символы цвета (@pxref{Line styles}) или символы @samp{#:|}. Символ @samp{#} переключает рисование поверхности на сетчатое (для трехмерных поверхностей) или включает рисование сетки на поверхности. Символ @samp{|} отключает интерполяцию цвета в цветовой схеме. Это может быть полезно для ``резких'' цветов, например, при рисовании матриц. Если в строке встречается символ @samp{:}, то он принудительно заканчивает разбор строки для стиля поверхности. После этого символа могут идти описание стиля текста или оси вращения кривой/линий уровня. Цветовая схема может содержать до 32 значений цвета. + +При определении цвета по @emph{амплитуде} (наиболее часто используется) окончательный цвет определяется путем линейной интерполяции массива цветов. Массив цветов формируется из цветов, указанных в строке спецификации. Аргумент -- амплитуда, нормированная между @var{Cmin} -- @var{Cmax} (см. @ref{Axis settings}). Например, строка из 4 символов @samp{bcyr} соответствует изменению цвета от синего (минимальное значение) через голубой и желтый (промежуточные значения) к красному (максимальное значение). Строка @samp{kw} соответствует изменению цвета от черного (минимальное значение) к белому (максимальное значение). Строка из одного символа (например, @samp{g}) соответствует однотонному цвету (в данному случае зеленому). + +Есть несколько полезных цветовых схем. Строка @samp{kw} дает обычную серую (черно-белую) схему, когда большие значения светлее. Строка @samp{wk} представляет обратную серую схему, когда большие значения темнее. Строки @samp{kRryw}, @samp{kGgw}, @samp{kBbcw} представляют собой хорошо известные схемы @emph{hot}, @emph{summer} и @emph{winter}. Строки @samp{BbwrR} и @samp{bBkRr} позволяют рисовать двухцветные фигуры на белом или черном фоне, когда отрицательные значения показаны синим цветом, а положительные -- красным. Строка @samp{BbcyrR} дает цветовую схему, близкую к хорошо известной схеме @emph{jet}. + +Для более точно раскрашивания поверхностей можно изменить равномерное (по умолчанию) положение цветов в цветовой схеме. Формат следующий: @samp{@{CN,pos@}}, @samp{@{CN,pos@}} или @samp{@{xRRGGBB,pos@}}. Здесь значение @var{pos} положения цвета должно быть в диапазоне [0, 1]. Отмечу, что альтернативным механизмом тонкой настройки цветовой схемы может служить использование формул для цветовой координаты (см. @ref{Curved coordinates}). + +@pfig{schemes, Most popular color schemes.} + +При определении цвета по @emph{положению точки в пространстве} (используется в @ref{map}) окончательный цвет определяется по формуле c=x*c[1] + y*c[2]. Здесь c[1], c[2] -- первые три цвета в цветовом массиве; x, y -- координаты точки, нормированные на @var{Min}x@var{Max}. +@c Такой тип определения цвета полезен, например, при построении поверхностей уровня, когда цвет дает представление о положении точки в пространстве. + + +Дополнительно, MathGL может наложить маску при закраске граней для создания растрового изображения. Тип маски задается одним из символов @samp{-+=;oOsS~<>jdD*^} в цветовой схеме. Маску можно повернуть на произвольный угол командой @ref{mask} или на один из улов +45, -45 или 90 градусов, используя символы @samp{\/I} соответственно. Примеры масок по умолчанию показаны на рисунке ниже. + +@pfig{mask, Example of masks for face coloring.} + +Однако, вы можете задать собственную маску (как матрицу 8*8) для любого из этих символов, используя второй аргумент команды @ref{mask}. Например, маска на правом нижнем подрисунке получается кодом@* +@ifclear UDAV +@code{gr->SetMask('+', "ff00182424f80000"); gr->Dens(a,"3+");} +@end ifclear +@ifset UDAV +@code{mask '+' 'ff00182424f80000':dens a '3+'} +@end ifset + +@c ------------------------------------------------------------------ +@external{} +@node Font styles, Textual formulas, Color scheme, General concepts +@section Стиль текста +@nav{} + +@cindex Стиль текста + +Стиль текста задается строкой, которая может содержать цвет текста @samp{wkrgbcymhRGBCYMHW} (см. @ref{Color styles}), а также тип шрифта (@samp{ribwou}) и/или выравнивания (@samp{LRC}) после символа @samp{:}. Например, @samp{r:iCb} соответствует жирному (@samp{b}) курсиву (@samp{i}) с выравниванием по центру (@samp{C} красного цвета (@samp{r}). + +Начертания шрифта: @samp{r} -- прямой шрифт, @samp{i} -- курсив, @samp{b} -- жирный. По умолчанию используется прямой шрифт. Типы выравнивания текста: @samp{L} -- по левому краю (по умолчанию), @samp{C} -- по центру, @samp{R} -- по правому краю. Дополнительные эффекты шрифта: @samp{w} -- контурный, @samp{o} -- надчеркнутый, @samp{u} -- подчеркнутый. + +Синтаксический разбор LaTeX-их команд по умолчанию включен. Это команды смены стиля текста (например, \b для жирного текста): \a или \overline -- надчеркивание, \b или \textbf -- жирный, \i или \textit -- курсив, \r или \textrm -- прямой (отменяет стили жирного и курсива), \u или \underline -- подчеркнутый, \w или \wire -- контурный, \big -- большего размера, @@ -- меньшего размера. Нижний и верхний индексы задаются символами @samp{_} и @samp{^}. При этом изменение стиля применяется только к следующему символу или к символам в фигурных скобках @{@}, которые понимаются как единый блок. Например, сравните строки @samp{sin (x^@{2^3@})} и @samp{sin (x^2^3)}. Можно также менять цвет текста внутри строки с помощью команд #? или \color?, где @samp{?} -- символ цвета (@pxref{Line styles}). Например, слова @samp{Blue} и @samp{red} будут окрашены в соответствующий цвет в строке @samp{#b@{Blue@} and \colorr@{red@} text}. Большинство функций понимает символ новой строки @samp{\n} и позволяет выводить много строчный текст. Наконец, можно использовать символы с произвольным UTF кодом с помощью команды @code{\utf0x????}. Например, @code{\utf0x3b1} даст символ +@ifhtml +@html +α. +@end html +@end ifhtml +@ifnothtml +@math{\alpha}. +@end ifnothtml + +Распознаются также большинство символов TeX и AMSTeX, команды смены стиля текста (\textrm, \textbf, \textit, \textsc, \overline, \underline), акценты (\hat, \tilde, \dot, \ddot, \acute, \check, \grave, \bar, \breve) и корни (\sqrt, \sqrt3, \sqrt4). Полный список содержит около 2000 символов. Отмечу, что первый пробел (пробел, табуляция и пр.) после команды игнорируется, а все остальные пробелы печатаются обычным образом. Например, следующие строки дают одинаковый результат @math{\tilde a}: @samp{\tilde@{a@}}; @samp{\tilde a}; @samp{\tilde@{@}a}. + +@ifhtml +@html +В частности, распознаются греческие буквы: α – \alpha, β – \beta, γ – \gamma, δ – \delta, ε – \epsilon, η – \eta, ι – \iota, χ – \chi, κ – \kappa, λ – \lambda, μ – \mu, ν – \nu, o – \o, ω – \omega, ϕ – \phi, π – \pi, ψ – \psi, ρ – \rho, σ – \sigma, θ – \theta, τ – \tau, υ – \upsilon, ξ – \xi, ζ – \zeta, ς – \varsigma, ɛ – \varepsilon, ϑ – \vartheta, φ – \varphi, ϰ – \varkappa; A – \Alpha, B – \Beta, Γ – \Gamma, Δ – \Delta, E – \Epsilon, H – \Eta, I – \Iota, C – \Chi, K – \Kappa, Λ – \Lambda, M – \Mu, N – \Nu, O – \O, Ω – \Omega, Φ – \Phi, Π – \Pi, Ψ – \Psi, R – \Rho, Σ – \Sigma, Θ – \Theta, T – \Tau, Υ – \Upsilon, Ξ – \Xi, Z – \Zeta. + +

Еще примеры наиболее общеупотребительных TeX-их символов: ∠ – \angle, ⋅ – \cdot, ♣ – \clubsuit, ✓ – \checkmark, ∪ – \cup, ∩ – \cap, ♢ – \diamondsuit, ◇ – \diamond, ÷ + – \div, +↓ – \downarrow, † – \dag, ‡ – \ddag, ≡ – \equiv, ∃ – \exists, ⌢ – \frown, ♭ – \flat, ≥ – \ge, ≥ – \geq, ≧ – \geqq, ← – \gets, ♡ – \heartsuit, ∞ – \infty, ∫ – \int, \Int, ℑ – \Im, ♢ – \lozenge, ⟨ – \langle, ≤ – \le, ≤ – \leq, ≦ – \leqq, ← – \leftarrow, ∓ – \mp, ∇ – \nabla, ≠ – \ne, ≠ – \neq, ♮ – \natural, ∮ – \oint, ⊙ – \odot, ⊕ – \oplus, ∂ – \partial, ∥ – \parallel, ⊥ –\perp, ± – \pm, ∝ – \propto, ∏ – \prod, ℜ – \Re, → – \rightarrow, ⟩ – \rangle, ♠ – \spadesuit, ~ – \sim, ⌣ – \smile, ⊂ – \subset, ⊃ – \supset, √ – \sqrt or \surd, § – \S, ♯ – \sharp, ∑ – \sum, × – \times, → – \to, ∴ – \therefore, ↑ – \uparrow, ℘ – \wp.

+@end html +@end ifhtml +@ifnothtml +В частности, распознаются греческие буквы: @math{\alpha} -- \alpha, @math{\beta} -- \beta, @math{\gamma} -- \gamma, @math{\delta} -- \delta, @math{\epsilon} -- \epsilon, @math{\eta} -- \eta, @math{\iota} -- \iota, @math{\chi} -- \chi, @math{\kappa} -- \kappa, @math{\lambda} -- \lambda, @math{\mu} -- \mu, @math{\nu} -- \nu, @math{o} -- \o, @math{\omega} -- \omega, @math{\phi} -- \phi, @math{\pi} -- \pi, @math{\psi} -- \psi, @math{\rho} -- \rho, @math{\sigma} -- \sigma, @math{\theta} -- \theta, @math{\tau} -- \tau, @math{\upsilon} -- \upsilon, @math{\xi} -- \xi, @math{\zeta} -- \zeta, @math{\varsigma} -- \varsigma, @math{\varepsilon} -- \varepsilon, @math{\vartheta} -- \vartheta, @math{\varphi} -- \varphi, A -- \Alpha, B -- \Beta, @math{\Gamma} -- \Gamma, @math{\Delta} -- \Delta, E -- \Epsilon, H -- \Eta, I -- \Iota, C -- \Chi, K -- \Kappa, @math{\Lambda} -- \Lambda, M -- \Mu, N -- \Nu, O -- \O, @math{\Omega} -- \Omega, @math{\Phi} -- \Phi, @math{\Pi} -- \Pi, @math{\Psi} -- \Psi, R -- \Rho, @math{\Sigma} -- \Sigma, @math{\Theta} -- \Theta, T -- \Tau, @math{\Upsilon} -- \Upsilon, @math{\Xi} -- \Xi, Z -- \Zeta. + +Еще примеры наиболее общеупотребительных TeX-их символов: @math{\angle} -- \angle, @math{\aleph} -- \aleph, @math{\cdot} -- \cdot, @math{\clubsuit} -- \clubsuit, @math{\cup} -- \cup, @math{\cap} -- \cap, @math{\diamondsuit} -- \diamondsuit, @math{\diamond} -- \diamond, @math{\div} -- \div, @math{\downarrow} -- \downarrow, @math{\dag} -- \dag, @math{\ddag} -- \ddag, @math{\equiv} -- \equiv, @math{\exists} -- \exists, @math{\frown} -- \frown, @math{\flat} -- \flat, @math{\ge} -- \ge, @math{\geq} -- \geq, @math{\gets} -- \gets, @math{\heartsuit} -- \heartsuit, @math{\infty} -- \infty, @math{\in} -- \in, @math{\int} -- \int, @math{\Im} -- \Im, @math{\langle} -- \langle, @math{\le} -- \le, @math{\leq} -- \leq, @math{\leftarrow} -- \leftarrow, @math{\mp} -- \mp, @math{\nabla} -- \nabla, @math{\ne} -- \ne, @math{\neq} -- \neq, @math{\natural} -- \natural, @math{\oint} -- \oint, @math{\odot} -- \odot, @math{\oplus} -- \oplus, @math{\partial} -- \partial, @math{\parallel} -- \parallel, @math{\perp} -- \perp, @math{\pm} -- \pm, @math{\propto} -- \propto, @math{\prod} -- \prod, @math{\Re} -- \Re, @math{\rightarrow} -- \rightarrow, @math{\rangle} -- \rangle, @math{\spadesuit} -- \spadesuit, @math{\sim} -- \sim, @math{\smile} -- \smile, @math{\subset} -- \subset, @math{\supset} -- \supset, @math{\surd} -- \sqrt or \surd, @math{\S} -- \S, @math{\sharp} -- \sharp, @math{\sum} -- \sum, @math{\times} -- \times, @math{\to} -- \to, @math{\uparrow} -- \uparrow, @math{\wp} -- \wp and so on. +@end ifnothtml + +Размер текста может быть задан явно (если @var{size}>0) или относительно базового размера шрифта для рисунка |@var{size}|*@var{FontSize} при @var{size}<0. Значение @var{size}=0 указывает, что соответствующая строка выводиться не будет. Базовый размер шрифта измеряется во внутренних единицах. Специальные функции @code{SetFontSizePT(), SetFontSizeCM(), SetFontSizeIN()} позволяют задавать его в более ``привычных'' единицах. + +@c ------------------------------------------------------------------ +@external{} +@node Textual formulas, Command options, Font styles, General concepts +@section Текстовые формулы + +@cindex Текстовые формулы + +MathGL имеет быстрый парсер текстовых формул +@ifclear UDAV +(@pxref{Evaluate expression}) +@end ifclear +, понимающий большое число функций и операций. Базовые операции: @samp{+} -- сложение, @samp{-} -- вычитание, @samp{*} -- умножение, @samp{/} -- деление, @samp{^} -- возведение в целосичленную степень. Также есть логические операции: @samp{<} -- истина если if x} -- истина если x>y, @samp{=} -- истина если x=y, @samp{&} -- истина если x и y оба не равны нулю, @samp{|} -- истина если x или y не нуль. Логические операции имеют наинизший приоритет и возвращают 1 если истина или 0 если ложно. + +Базовые функции: @samp{sqrt(x)} -- квадратный корень из @var{x}, @samp{pow(x,y)} -- @var{x} в степени @var{y}, @samp{ln(x)} -- натуральный логарифм @var{x}, @samp{lg(x)} -- десятичный логарифм @var{x}, @samp{log(a,x)} -- логарифм по основанию @var{a} от @var{x}, @samp{abs(x)} -- модуль @var{x}, @samp{sign(x)} -- знак @var{x}, @samp{mod(x,y)} -- остаток от деления x на y, @samp{step(x)} -- ступенчатая функция, @samp{int(x)} -- целая часть @var{x}, @samp{rnd} -- случайное число, @samp{pi} -- число +@ifhtml +@html +π = 3.1415926… +@end html +@end ifhtml +@ifnothtml +@math{\pi=3.1415926...} +@end ifnothtml + +Тригонометрические функции: @samp{sin(x)}, @samp{cos(x)}, @samp{tan(x)} (или @samp{tg(x)}). Обратные тригонометрические функции: @samp{asin(x)}, @samp{acos(x)}, @samp{atan(x)}. Гиперболические функции: @samp{sinh(x)} (или @samp{sh(x)}), @samp{cosh(x)} (или @samp{ch(x)}), @samp{tanh(x)} (или @samp{th(x)}). Обратные гиперболические функции: @samp{asinh(x)}, @samp{acosh(x)}, @samp{atanh(x)}. + +@ifhtml +@html +

Специальные функции: ‘gamma(x)’ – гамма функция Γ(x) = ∫0 tx-1 exp(-t) dt, ‘psi(x)’ – дигамма функция ψ(x) = Γ′(x)/Γ(x) для x≠0, ‘ai(x)’ – Эйри функция Ai(x), ‘bi(x)’ – Эйри функция Bi(x), ‘cl(x)’ – функция Клаузена, ‘li2(x)’ (или ‘dilog(x)’) – дилогарифм Li2(x) = -ℜ∫0xds log(1-s)/s, ‘sinc(x)’ – функция sinc(x) = sin(πx)/(πx) для любых x, ‘zeta(x)’ – зета функция Римана ζ(s) = ∑k=1k-s для s≠1, ‘eta(x)’ – эта функция η(s) = (1 - 21-s)ζ(s) для произвольного s, ‘lp(l,x)’ – полином Лежандра Pl(x), (|x|≤1, l≥0), ‘w0(x)’, ‘w1(x)’ – функции Ламберта W. Функции W(x) определены как решение уравнения: W exp(W) = x.

+ +

Экспоненциальные интегралы: ‘ci(x)’ – cos-интеграл Ci(x) = ∫0xdt cos(t)/t, ‘si(x)’ – sin-интеграл Si(x) = ∫0xdt sin(t)/t, ‘erf(x)’ – функция ошибки erf(x) = (2/√π) ∫0xdt exp(-t2) , ‘ei(x)’ – интеграл Ei(x) = -PV(∫-xdt exp(-t)/t) (где PV обозначает главное значение), ‘e1(x)’ – интеграл E1(x) = ℜ∫1dt exp(-xt)/t, ‘e2(x)’ – интеграл E2(x) = ℜ∫1∞dt exp(-xt)/t2, ‘ei3(x)’ – интеграл Ei3(x) = ∫0xdt exp(-t3) для x≥0.

+ +

Функции Бесселя: ‘j(nu,x)’ – функция Бесселя первого рода, ‘y(nu,x)’ – функция Бесселя второго рода, ‘i(nu,x)’ – модифицированная функция Бесселя первого рода, ‘k(nu,x)’ – модифицированная функция Бесселя второго рода.

+ +

Эллиптические интегралы: ‘ee(k)’ – полный эллиптический интеграл E(k) = E(π/2,k), ‘ek(k)’ – полный эллиптический интеграл K(k) = F(π/2,k), ‘e(phi,k)’ – эллиптический интеграл E(φ,k) = ∫0φdt √(1 - k2sin2(t)), ‘f(phi,k)’ – эллиптический интеграл F(φ,k) = ∫0φdt 1/√(1 - k2sin2(t))

+@end html +@end ifhtml +@ifnothtml +Специальные функции: @samp{gamma(x)} -- гамма функция @math{\Gamma(x) = \int_0^\infty dt t^@{x-1@} \exp(-t)} , @samp{psi(x)} -- дигамма функция @math{\psi(x) = \Gamma'(x)/\Gamma(x)} для x!=0, @samp{ai(x)} -- Эйри функция Ai(x), @samp{bi(x)} -- Эйри функция Bi(x), @samp{cl(x)} -- функция Клаузена, @samp{li2(x)} (или @samp{dilog(x)}) -- дилогарифм @math{Li_2(x) = - \Re \int_0^x ds \log(1-s)/s}, @samp{sinc(x)} -- функция @math{sinc(x) = \sin(\pi x) / (\pi x)} для любых x, @samp{zeta(x)} -- зета функция Римана @math{\zeta(s) = \sum_@{k=1@}^\infty k^@{-s@}} для s!=1, @samp{eta(x)} -- эта функция @math{\eta(s) = (1-2^@{1-s@}) \zeta(s)} для произвольного s, @samp{lp(l,x)} -- полином Лежандра @math{P_l(x)}, (|x|<=1, l>=0), @samp{w0(x)}, @samp{w1(x)} -- функции Ламберта @var{W}. Функции W(x) определены как решение уравнения @math{W \exp(W) = x}. + +Экспоненциальные интегралы: @samp{ci(x)} -- cos-интеграл @math{Ci(x) = \int_0^x dt \cos(t)/t}, @samp{si(x)} -- sin-интеграл @math{Si(x) = \int_0^x dt \sin(t)/t}, @samp{erf(x)} -- функция ошибки @math{erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2)}, @samp{ei(x)} -- интеграл @math{Ei(x) := - PV(\int_@{-x@}^\infty dt \exp(-t)/t)} (где PV обозначает главное значение), @samp{e1(x)} -- интеграл @math{E_1(x) := Re \int_1^\infty dt \exp(-xt)/t} , @samp{e2(x)} -- интеграл @math{E_2(x) := Re \int_1^\infty dt \exp(-xt)/t^2}, @samp{ei3(x)} -- интеграл @math{Ei_3(x) = \int_0^x dt \exp(-t^3)} для x>=0. + +Функции Бесселя: @samp{j(nu,x)} -- функция Бесселя первого рода, @samp{y(nu,x)} -- функция Бесселя второго рода, @samp{i(nu,x)} -- модифицированная функция Бесселя первого рода, @samp{k(nu,x)} -- модифицированная функция Бесселя второго рода. + +Эллиптические интегралы: @samp{ee(k)} -- полный эллиптический интеграл @math{E(k) = E(\pi/2, k)}, @samp{ek(k)} -- полный эллиптический интеграл @math{K(k) = F(\pi/2, k)}, @samp{e(phi,k)} -- эллиптический интеграл @math{E(\phi,k) = \int_0^\phi dt \sqrt((1 - k^2 \sin^2(t)))}, @samp{f(phi,k)} -- эллиптический интеграл @math{F(\phi,k) = \int_0^\phi dt 1/\sqrt((1 - k^2 \sin^2(t)))}. +@end ifnothtml + +Функции Якоби: @samp{sn(u,m)}, @samp{cn(u,m)}, @samp{dn(u,m)}, @samp{sc(u,m)}, @samp{sd(u,m)}, @samp{ns(u,m)}, @samp{cs(u,m)}, @samp{cd(u,m)}, @samp{nc(u,m)}, @samp{ds(u,m)}, @samp{dc(u,m)}, @samp{nd(u,m)}. + +Некоторые из функций могут быть недоступны если не была включена поддержка GSL при компиляции библиотеки MathGL. + +При разборе формул нет различия между верхним и нижним регистром. Если аргумент лежит вне области определения функции, то возвращается NaN. + +@c ------------------------------------------------------------------ +@external{} +@node Command options, Interfaces, Textual formulas, General concepts +@section Опции команд +@nav{} + +Опции команд позволяют легко настроить вид отдельного графика не меняя глобальных настроек для все рисунка. Каждая опция отделяется от предыдущей символом @samp{;}. Опции работают так, что запоминают текущие настройки рисунка, применяют собственные настройки, выполняют команду и возвращают глобальные настройки обратно. Поэтому использование опций для команд обработки данных или настройки графика бесполезно. + +Наиболее часто используемые опции -- @code{xrange, yrange, zrange}, устанавливают границы изменения осей координат (и тем самым автоматических массивов). Например, команда @code{Plot(y,"","xrange 0.1 0.9");} или @code{plot y; xrange 0.1 0.9} построит кривую с x-координатой равно распределенной в интервале 0.1 ... 0.9, а не вдоль текущей оси x. @sref{Using options} + +Полный список опций: +@cindex alpha +@cindex alphadef +@deffn {Опция MGL} alpha @code{val} +Задает величину прозрачности поверхности. Значение должно быть в диапазоне [0, 1]. См. также @ref{alphadef} +@end deffn +@c @cindex ambient +@c @deffn {Опция MGL} ambient @code{val} +@c Задает яркость фонового освещения. Значение должно быть в диапазоне [0, 1]. См. также @ref{ambient} +@c @end deffn +@c @cindex diffuse +@c @deffn {Опция MGL} diffuse @code{val} +@c Задает яркость диффузного освещения для поверхности. Значение должно быть в диапазоне [0, 1]. См. также @ref{diffuse}. +@c @end deffn + +@cindex xrange +@deffn {Опция MGL} xrange @code{val1 val2} +Задает границы изменения координаты x. См. также @ref{xrange} +@end deffn +@cindex yrange +@deffn {Опция MGL} yrange @code{val1 val2} +Задает границы изменения координаты y. См. также @ref{yrange} +@end deffn +@cindex zrange +@deffn {Опция MGL} zrange @code{val1 val2} +Задает границы изменения координаты z. См. также @ref{zrange} +@end deffn + +@cindex cut +@deffn {Опция MGL} cut @code{val} +Задает обрезание точек за пределами осей координат. См. также @ref{cut}. +@end deffn +@cindex fontsize +@deffn {Опция MGL} size @code{val} +Задает размер текста, маркеров и стрелок. См. также @ref{font}, @ref{marksize}, @ref{arrowsize}. +@end deffn +@cindex meshnum +@deffn {Опция MGL} meshnum @code{val} +Задает ориентировочное число линий, стрелок, ячеек и пр. См. также @ref{meshnum} +@end deffn + +@cindex legend +@deffn {Опция MGL} legend 'txt' +Добавляет строку 'txt' во внутренний массив записей легенды. Стиль линии и маркера аргумента последней вызванной команды построения @ref{1D plotting}. См. также @ref{legend} +@end deffn +@cindex value +@deffn {MGL option} value @code{val} +Задает значение, которое будет использовано как дополнительный числовой параметр при построении графика. +@end deffn + + + +@c ------------------------------------------------------------------ +@external{} +@node Interfaces, , Command options, General concepts +@section Интерфейсы +@nav{} + +@ifset UDAV +Вы можете использовать класс @code{mglParse} для выполнения MGL скриптов из других языков программирования. +@end ifset + +@ifclear UDAV + +Библиотека MathGL имеет интерфейсы к ряду языков программирования. Большинство из них основано на С интерфейсе с использованием SWIG. Это Python, Java, Octave, Lisp, C#, Guile, Lua, Modula 3, Ocaml, Perl, PHP, Pike, R, Ruby, и Tcl интерфейсы. Также есть Fortran интерфейс, который имеет схожий набор функций, но слегка различающиеся типы аргументов (целые вместо указателей). Эти функции отмечены как [C function]. + +Некоторые языки поддерживают классы (подобно C++ или Python). Имена функций для них такие же как в С++ (см. @ref{MathGL core} и @ref{Data processing}) и отмечены, например, так [Method on mglGraph]. + +Наконец, специальный командный язык MGL (см. @ref{MGL scripts}) был создан для быстрого доступа к функциям рисования. Соответствующие скрипты могут быть выполнены самостоятельно (с помощью UDAV, mglconv, mglview и т.д.) или из программы на языке C/C++/Python/... (см. @ref{mglParse class}). + +@menu +* C interface:: +* C++ interface:: +@end menu + +@external{} +@node C interface, C++ interface, , Interfaces +@subsection C/Fortran интерфейс +@nav{} + +C интерфейс -- основа для многих других интерфейсов. Он содержит функции С для всех методов MathGL. В отличие от C++ классов, C функции содержат обязательный(ые) аргумент(ы) типа HMGL (для графики) и/или HCDT/HMDT/HADT (для массивов данных), который указывают на объект для рисования или изменения. Поэтому перед использованием их необходимо создать с помощью функции @code{mgl_create_*()}, и удалить после использования (или в конце программы) с помощью функции @code{mgl_delete_*()}. + +Все C функции описаны в заголовочном файле @code{#include } и используют переменные следующих типов: +@itemize +@item +@code{HMGL} --- Указатель на класс @code{mglGraph} (см. @ref{MathGL core}). +@item +@code{HCDT} --- Указатель на класс @code{const mglDataA} (см. @ref{Data processing}) --- неизменяемые массивы данных. +@item +@code{HMDT} --- Указатель на класс @code{mglData} (см. @ref{Data processing}) --- массивы данных с действительными числами. +@item +@code{HADT} --- Указатель на класс @code{mglDataC} (см. @ref{Data processing}) --- массивы данных с комплексными числами. +@item +@code{HMPR} --- Указатель на класс @code{mglParse} (см. @ref{mglParse class}) --- выполнение MGL скриптов. +@item +@code{HMEX} --- Указатель на класс @code{mglExpr} (см. @ref{Evaluate expression}) --- текстовые формулы для действительных чисел. +@item +@code{HMAX} --- Указатель на класс @code{mglExprC} (см. @ref{Evaluate expression}) --- текстовые формулы для комплексных чисел. +@end itemize + +Фортрановские функции и подпрограммы имеют такие же имена как функции С. Однако есть отличие. Переменные типов @code{HMGL, HCDT, HMDT, ...} должны быть целыми с достаточной разрядностью (@code{integer*4} для 32-битной операционной системы или @code{integer*8} для 64-битной). Все C функции типа @code{void} --- подпрограммы на Фортране и должны вызываться оператором @code{call}. Прочие функции, возвращающие тип @code{HMGL} или @code{HMDT} и т.п. должны быть объявлены в Фортране как возвращающие целое нужной разрядности. Также необходимо иметь в виду, что строки в Фортране отделяются символом @code{'}, а не @code{"}. + +@external{} +@node C++ interface, , C interface, Interfaces +@subsection C++/Python интерфейс +@nav{} + +MathGL имеет интерфейс на основе классов (объектов с членами-функциями) с использованием библиотеки SWIG. Типичный пример -- Python, имя которого использовано в заголовке раздела. В точности те же классы используются и в C++ API. Отмечу, что С++ классы содержат только inline члены-функции, что делает С++ API независимым от компилятора даже для бинарной версии. + +Есть 3 основных класса: +@itemize +@item @code{mglGraph} +-- обеспечивает вывод графики (см. @ref{MathGL core}). +@item @code{mglData} +-- обеспечивает обработку данных (см. @ref{Data processing}). Класс имеет возможность прямого доступа к данным с помощью конструкции вида: @code{dat[i]=sth;} или @code{sth=dat[i]}, где используется "плоское" представление данных (т.е., @var{i} может быть в диапазоне 0...nx*nx*nz-1). Также можно импортировать массивы NumPy в Python: @code{mgl_dat = mglData(numpy_dat);}. +@item @code{mglParse} +-- обеспечивает выполнение скриптов MGL (см. @ref{MGL scripts}). +@end itemize + + +Для использования в Python достаточно выполнить @samp{import mathgl}. Простейший пример имеет вид: +@verbatim +import mathgl +a=mathgl.mglGraph() +a.Box() +a.WritePNG("test.png") +@end verbatim +Также можно импортировать все классы из модуля @code{mathgl} и обеспечить более легкий доступ к MathGL: +@verbatim +from mathgl import * +a=mglGraph() +a.Box() +a.WritePNG("test.png") +@end verbatim +Это становится более полезным если, например, вы создаете много объектов данных @code{mglData}. + +@end ifclear + +@external{} diff --git a/texinfo/copyright.texi b/texinfo/copyright.texi new file mode 100644 index 0000000..f76c118 --- /dev/null +++ b/texinfo/copyright.texi @@ -0,0 +1,11 @@ +Copyright @copyright{} 2008-2012 Alexey A. Balakin. + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 +or any later version published by the Free Software Foundation; +with no Invariant Sections, no Front-Cover Texts, and no Back-Cover +Texts. A copy of the license is included in the section entitled ``GNU +Free Documentation License.'' +@end quotation + diff --git a/texinfo/core_en.texi b/texinfo/core_en.texi new file mode 100644 index 0000000..80a6e74 --- /dev/null +++ b/texinfo/core_en.texi @@ -0,0 +1,3332 @@ +@c ------------------------------------------------------------------ +@chapter MathGL core +@nav{} +@cindex mglGraph + +@ifset UDAV +This chapter contains a lot of plotting commands for 1D, 2D and 3D data. It also encapsulates parameters for axes drawing. Moreover an arbitrary coordinate transformation can be used for each axis. Additional information about colors, fonts, formula parsing can be found in @ref{General concepts}. The full list of symbols used by MathGL for setting up plots can be found in @ref{Symbols for styles}. +@end ifset + +@ifclear UDAV +The core of MathGL is @strong{mglGraph} class defined in @code{#include }. It contains a lot of plotting functions for 1D, 2D and 3D data. It also encapsulates parameters for axes drawing. Moreover an arbitrary coordinate transformation can be used for each axis. All plotting functions use data encapsulated in mglData class (see @ref{Data processing}) that allows to check sizes of used arrays easily. Also it have many functions for data handling: modify it by formulas, find momentums and distribution (histogram), apply operator (differentiate, integrate, transpose, Fourier and so on), change data sizes (interpolate, squeeze, crop and so on). Additional information about colors, fonts, formula parsing can be found in @ref{General concepts} and @ref{Other classes}. +@end ifclear + +@menu +* Constructor:: +* Graphics setup:: +* Axis settings:: +* Subplots and rotation:: +* Export picture:: +* Primitives:: +* Text printing:: +* Axis and Colorbar:: +* Legend:: +* 1D plotting:: +* 2D plotting:: +* 3D plotting:: +* Dual plotting:: +* Vector fields:: +* Other plotting:: +* Nonlinear fitting:: +* Data manipulation:: +@c * IDTF functions:: +@end menu + +@c ################################################################## +@external{} +@node Constructor, Graphics setup, , MathGL core +@section Create and delete objects +@nav{} + +@ifclear UDAV +@deftypefn {Constructor on @code{mglGraph}} {} mglGraph (@code{int} kind=@code{0}, @code{int} width=@code{600}, @code{int} height=@code{400}) +@deftypefnx {Constructor on @code{mglGraph}} {} mglGraph (@code{const mglGraph &}gr) +@deftypefnx {Constructor on @code{mglGraph}} {} mglGraph (@code{HMGL} gr) +@deftypefnx {C function} @code{HMGL} mgl_create_graph (@code{int} width, @code{int} height) +@deftypefnx {C function} @code{HMGL} mgl_create_graph_gl () +Creates the instance of class mglGraph with specified sizes @var{width} and @var{height}. Parameter @var{kind} may have following values: @samp{0} -- use default plotter, @samp{1} -- use OpenGL plotter. +@end deftypefn + +@deftypefn {Destructor on @code{mglGraph}} {} ~mglGraph () +@deftypefnx {C function} @code{HMGL} mgl_delete_graph (@code{HMGL} gr) +Deletes the instance of class mglGraph. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{HMGL} Self () +Returns the pointer to internal object of type @code{HMGL}. +@end deftypefn +@end ifclear + +@ifset UDAV +You don't need to create canvas object in MGL. +@end ifset + +@c ################################################################## +@external{} +@node Graphics setup, Axis settings, Constructor, MathGL core +@section Graphics setup +@nav{} +@cindex MathGL setup + +Functions and variables in this group influences on overall graphics appearance. So all of them should be placed @emph{before} any actual plotting function calls. + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} DefaultPlotParam () +@deftypefnx {C function} @code{void} mgl_set_def_param (@code{HMGL} gr) +Restore initial values for all of parameters. +@end deftypefn +@end ifclear + +@menu +* Transparency:: +* Lighting:: +* Fog:: +* Default sizes:: +* Cutting:: +* Font settings:: +* Palette and colors:: +* Masks:: +* Error handling:: +@end menu + +@c ================================================================== +@external{} +@node Transparency, Lighting, , Graphics setup +@subsection Transparency +@nav{} +@cindex Alpha +@ifclear UDAV +@cindex SetAlphaDef +@cindex SetTranspType +@end ifclear +@cindex AlphaDef +@cindex TranspType + +There are several functions and variables for setup transparency. The general function is @ref{alpha} which switch on/off the transparency for overall plot. It influence only for graphics which created after @ref{alpha} call (with one exception, OpenGL). Function @ref{alphadef} specify the default value of alpha-channel. Finally, function @ref{transptype} set the kind of transparency. @sref{Transparency and lighting} + +@anchor{alpha} +@deftypefn {MGL command} {} alpha @code{[val=on]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Alpha (@code{bool} enable) +@deftypefnx {C function} @code{void} mgl_set_alpha (@code{HMGL} gr, @code{int} enable) +@end ifclear +Sets the transparency on/off and returns previous value of transparency. It is recommended to call this function before any plotting command. Default value is transparency off. +@end deftypefn + +@anchor{alphadef} +@deftypefn {MGL command} {} alphadef @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetAlphaDef (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_alpha_default (@code{HMGL} gr, @code{mreal} alpha) +@end ifclear +Sets default value of alpha channel (transparency) for all plotting functions. Initial value is 0.5. +@end deftypefn + +@anchor{transptype} +@deftypefn {MGL command} {} transptype @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetTranspType (@code{int} type) +@deftypefnx {C function} @code{void} mgl_set_transp_type (@code{HMGL} gr, @code{int} type) +@end ifclear +Set the type of transparency. Possible values are: +@itemize @bullet +@item +Normal transparency (@samp{0}) -- below things is less visible than upper ones. It does not look well in OpenGL mode (mglGraphGL) for several surfaces. +@item +Glass-like transparency (@samp{1}) -- below and upper things are commutable and just decrease intensity of light by RGB channel. +@item +Lamp-like transparency (@samp{2}) -- below and upper things are commutable and are the source of some additional light. I recommend to set @code{SetAlphaDef(0.3)} or less for lamp-like transparency. +@end itemize +@sref{Types of transparency}. +@end deftypefn + +@c ================================================================== +@external{} +@node Lighting, Fog, Transparency, Graphics setup +@subsection Lighting +@nav{} +@ifclear UDAV +@cindex SetAmbient +@cindex AddLight +@end ifclear +@cindex Light +@cindex Ambient + +There are several functions for setup lighting. The general function is @ref{light} which switch on/off the lighting for overall plot. It influence only for graphics which created after @ref{light} call (with one exception, OpenGL). Generally MathGL support up to 10 independent light sources. But in OpenGL mode only 8 of light sources is used due to OpenGL limitations. The position, color, brightness of each light source can be set separately. By default only one light source is active. It is source number @code{0} with white color, located at top of the plot. + +@anchor{light} +@deftypefn {MGL command} {} light @code{[val=on]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{bool} Light (@code{bool} enable) +@deftypefnx {C function} @code{void} mgl_set_light (@code{HMGL} gr, @code{int} enable) +@end ifclear +Sets the using of light on/off for overall plot. Function returns previous value of lighting. Default value is lightning off. +@end deftypefn + +@deftypefn {MGL command} {} light @code{num} @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Light (@code{int} n, @code{bool} enable) +@deftypefnx {C function} @code{void} mgl_set_light_n (@code{HMGL} gr, @code{int} n, @code{int} enable) +@end ifclear +Switch on/off @var{n}-th light source separately. +@end deftypefn + +@deftypefn {MGL command} {} light @code{num xdir ydir zdir} ['col'='w' @code{br=0.5}] +@deftypefnx {MGL command} {} light @code{num xdir ydir zdir xpos ypos zpos} ['col'='w' @code{br=0.5}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} AddLight (@code{int} n, @code{mglPoint} d, @code{char} c=@code{'w'}, @code{mreal} bright=@code{0.5}, @code{mreal} ap=@code{0}) +@deftypefnx {Method on @code{mglGraph}} @code{void} AddLight (@code{int} n, @code{mglPoint} r, @code{mglPoint} d, @code{char} c=@code{'w'}, @code{mreal} bright=@code{0.5}, @code{mreal} ap=@code{0}) +@deftypefnx {C function} @code{void} mgl_add_light (@code{HMGL} gr, @code{int} n, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz) +@deftypefnx {C function} @code{void} mgl_add_light_ext (@code{HMGL} gr, @code{int} n, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{char} c, @code{mreal} bright, @code{mreal} ap) +@deftypefnx {C function} @code{void} mgl_add_light_loc (@code{HMGL} gr, @code{int} n, @code{mreal} rx, @code{mreal} ry, @code{mreal} rz, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{char} c, @code{mreal} bright, @code{mreal} ap) +@end ifclear +The function adds a light source with identification @var{n} in direction @var{d} with color @var{c} and with brightness @var{bright} (which must be in range [0,1]). If position @var{r} is specified and isn't NAN then light source is supposed to be local otherwise light source is supposed to be placed at infinity. +@end deftypefn + +@anchor{diffuse} +@deftypefn {MGL command} {} diffuse @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetDiffuse (@code{mreal} bright) +@deftypefnx {C function} @code{void} mgl_set_difbr (@code{HMGL} gr, @code{mreal} bright) +@end ifclear +Set brightness of diffusive light (only for local light sources). +@end deftypefn + +@anchor{ambient} +@deftypefn {MGL command} {} ambient @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetAmbient (@code{mreal} bright=@code{0.5}) +@deftypefnx {C function} @code{void} mgl_set_ambbr (@code{HMGL} gr, @code{mreal} bright) +@end ifclear +Sets the brightness of ambient light. The value should be in range [0,1]. +@end deftypefn + +@c ================================================================== +@external{} +@node Fog, Default sizes, Lighting, Graphics setup +@subsection Fog +@nav{} +@cindex Fog + +@anchor{fog} +@deftypefn {MGL command} {} fog @code{val [dz=0.25]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Fog (@code{mreal} d, @code{mreal} dz=@code{0.25}) +@deftypefnx {C function} @code{void} mgl_set_fog (@code{HMGL} gr, @code{mreal} d, @code{mreal} dz) +@end ifclear +Function imitate a fog in the plot. Fog start from relative distance @var{dz} from view point and its density growths exponentially in depth. So that the fog influence is determined by law ~ 1-exp(-@emph{d*z}). Here @emph{z} is normalized to 1 depth of the plot. If value @var{d}=@code{0} then the fog is absent. Note, that fog was applied at stage of image creation, not at stage of drawing. @sref{Adding fog} +@end deftypefn + +@c ================================================================== +@external{} +@node Default sizes, Cutting, Fog, Graphics setup +@subsection Default sizes +@nav{} +@ifclear UDAV +@cindex SetBarWidth +@cindex SetMarkSize +@cindex SetArrowSize +@cindex SetMeshNum +@cindex SetPlotId +@end ifclear +@cindex BarWidth +@cindex MarkSize +@cindex ArrowSize +@cindex MeshNum + +These variables control the default (initial) values for most graphics parameters including sizes of markers, arrows, line width and so on. As any other settings these ones will influence only on plots created after the settings change. + +@anchor{barwidth} +@deftypefn {MGL command} {} barwidth @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetBarWidth ( @code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_bar_width (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Sets relative width of rectangles in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{candle}, @ref{ohlc}. Default value is @code{0.7}. +@end deftypefn + +@anchor{marksize} +@deftypefn {MGL command} {} marksize @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetMarkSize (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_mark_size (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Sets size of marks for @ref{1D plotting}. Default value is @code{1}. +@end deftypefn + +@anchor{arrowsize} +@deftypefn {MGL command} {} arrowsize @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetArrowSize (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_arrow_size (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Sets size of arrows for @ref{1D plotting}, lines and curves (see @ref{Primitives}). Default value is @code{1}. +@end deftypefn + +@anchor{meshnum} +@anchor{MeshNum} +@deftypefn {MGL command} {} meshnum @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetMeshNum (@code{int} val) +@deftypefnx {C function} @code{void} mgl_set_meshnum (@code{HMGL} gr, @code{int} num) +@end ifclear +Sets approximate number of lines in @ref{mesh}, @ref{fall}, @ref{grid} and also the number of hachures in @ref{vect}, @ref{dew} and the number of cells in @ref{cloud}. By default (=0) it draws all lines/hachures/cells. +@end deftypefn + +@anchor{facenum} +@deftypefn {MGL command} {} facenum @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetFaceNum (@code{int} val) +@deftypefnx {C function} @code{void} mgl_set_facenum (@code{HMGL} gr, @code{int} num) +@end ifclear +Sets approximate number of visible faces. Can be used for speeding up drawing by cost of lower quality. By default (=0) it draws all of them. +@end deftypefn + +@anchor{plotid} +@deftypefn {MGL command} {} plotid 'id' +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetPlotId (@code{const char *}id) +@deftypefnx {C function} @code{void} mgl_set_plotid (@code{HMGL} gr, @code{const char *}id) +@end ifclear +Sets default name @var{id} as filename for saving (in FLTK window for example). +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{const char *} GetPlotId () +@deftypefnx {C function} @code{const char *} mgl_get_plotid (@code{HMGL} gr) +Gets default name @var{id} as filename for saving (in FLTK window for example). +@end deftypefn +@end ifclear + +@c ================================================================== +@external{} +@node Cutting, Font settings, Default sizes, Graphics setup +@subsection Cutting +@nav{} +@ifclear UDAV +@cindex SetCut +@cindex SetCutBox +@cindex CutOff +@end ifclear +@cindex Cut + +These variables and functions set the condition when the points are excluded (cutted) from the drawing. Note, that a point with NAN value(s) of coordinate or amplitude will be automatically excluded from the drawing. @sref{Cutting sample} + +@anchor{cut} +@deftypefn {MGL command} {} cut @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetCut (@code{bool} val) +@deftypefnx {C function} @code{void} mgl_set_cut (@code{HMGL} gr, @code{int} val) +@end ifclear +Flag which determines how points outside bounding box are drawn. If it is @code{true} then points are excluded from plot (it is default) otherwise the points are projected to edges of bounding box. +@end deftypefn + +@deftypefn {MGL command} {} cut @code{x1 y1 z1 x2 y2 z2} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetCutBox (@code{mglPoint} p1, @code{mglPoint} p1) +@deftypefnx {C function} @code{void} mgl_set_cut_box (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2) +@end ifclear +Lower and upper edge of the box in which never points are drawn. If both edges are the same (the variables are equal) then the cutting box is empty. +@end deftypefn + +@deftypefn {MGL command} {} cut 'cond' +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} CutOff (@code{const char *}cond) +@deftypefnx {C function} @code{void} mgl_set_cutoff (@code{HMGL} gr, @code{const char *}cond) +@end ifclear +Sets the cutting off condition by formula @var{cond}. This condition determine will point be plotted or not. If value of formula is nonzero then point is omitted, otherwise it plotted. Set argument as @code{""} to disable cutting off condition. +@end deftypefn + +@c ================================================================== +@external{} +@node Font settings, Palette and colors, Cutting, Graphics setup +@subsection Font settings +@nav{} +@ifclear UDAV +@cindex SetFontSize +@cindex SetFontDef +@cindex SetRotatedText +@cindex SetFontSizePT +@cindex SetFontSizeCM +@cindex SetFontSizeIN +@cindex LoadFont +@cindex CopyFont +@cindex RestoreFont +@end ifclear +@cindex Font +@cindex RotateText + +@anchor{font} +@deftypefn {MGL command} {} font 'fnt' [@code{val=6}] +Font style for text and labels (see text). Initial style is 'fnt'=':rC' give Roman font with centering. Parameter @code{val} sets the size of font for tick and axis labels. Default font size of axis labels is 1.4 times large than for tick labels. For more detail, see @ref{Font styles}. +@end deftypefn + +@anchor{rotatetext} +@deftypefn {MGL command} {} rotatetext @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRotatedText (@code{bool} val) +@deftypefnx {C function} @code{void} mgl_set_rotated_text (@code{HMGL} gr, @code{int} val) +@end ifclear +Sets to use or not text rotation. +@end deftypefn + +@anchor{loadfont} +@deftypefn {MGL command} {} loadfont ['name'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} LoadFont (@code{const char *}name, @code{const char *}path=@code{""}) +@deftypefnx {C function} @code{void} mgl_load_font (@code{HMGL} gr, @code{const char *}name, @code{const char *}path) +@end ifclear +Load font typeface from @var{path}/@var{name}. Empty name will load default font. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} SetFontDef (@code{const char *}fnt) +@deftypefnx {C function} @code{void} mgl_set_font_def (@code{HMGL} gr, @code{const char *} val) +Sets the font specification (see @ref{Text printing}). Default is @samp{rC} -- Roman font centering. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetFontSize (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_font_size (@code{HMGL} gr, @code{mreal} val) +Sets the size of font for tick and axis labels. Default font size of axis labels is 1.4 times large than for tick labels. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetFontSizePT (@code{mreal} cm, @code{int} dpi=@code{72}) +Set FontSize by size in pt and picture DPI (default is 16 pt for dpi=72). +@end deftypefn +@deftypefn {Method on @code{mglGraph}} @code{inline void} SetFontSizeCM (@code{mreal} cm, @code{int} dpi=@code{72}) +Set FontSize by size in centimeters and picture DPI (default is 0.56 cm = 16 pt). +@end deftypefn +@deftypefn {Method on @code{mglGraph}} @code{inline void} SetFontSizeIN (@code{mreal} cm, @code{int} dpi=@code{72}) +Set FontSize by size in inch and picture DPI (default is 0.22 in = 16 pt). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} LoadFont (@code{const char *}name, @code{const char *}path=@code{""}) +@deftypefnx {C function} @code{void} mgl_load_font (@code{HMGL} gr, @code{const char *}name, @code{const char *}path) +Load font typeface from @var{path}/@var{name}. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} CopyFont (@code{mglGraph *} from) +@deftypefnx {C function} @code{void} mgl_copy_font (@code{HMGL} gr, @code{HMGL} gr_from) +Copy font data from another @code{mglGraph} object. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} RestoreFont () +@deftypefnx {C function} @code{void} mgl_restore_font (@code{HMGL} gr) +Restore font data to default typeface. +@end deftypefn + +@deftypefn {C function} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path) +Load default font typeface (for all newly created HMGL/mglGraph objects) from @var{path}/@var{name}. +@end deftypefn + +@end ifclear + +@c ================================================================== +@external{} +@node Palette and colors, Masks, Font settings, Graphics setup +@subsection Palette and colors +@nav{} +@ifclear UDAV +@cindex SetPalette +@end ifclear +@cindex Palette + +@anchor{palette} +@deftypefn {MGL command} {} palette 'colors' +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetPalette (@code{const char *}colors) +@deftypefnx {C function} @code{void} mgl_set_palette (@code{HMGL} gr, @code{const char *}colors) +@end ifclear +Sets the palette as selected colors. Default value is @code{"Hbgrcmyhlnqeup"} that corresponds to colors: dark gray @samp{H}, blue @samp{b}, green @samp{g}, red @samp{r}, cyan @samp{c}, magenta @samp{m}, yellow @samp{y}, gray @samp{h}, blue-green @samp{l}, sky-blue @samp{n}, orange @samp{q}, yellow-green @samp{e}, blue-violet @samp{u}, purple @samp{p}. The palette is used mostly in 1D plots (see @ref{1D plotting}) for curves which styles are not specified. Internal color counter will be nullified by any change of palette. This includes even hidden change (for example, by @ref{box} or @ref{axis} functions). +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} SetDefScheme (@code{const char *}sch) +@deftypefnx {C function} @code{void} mgl_set_def_sch (@code{HMGL} gr, @code{const char *}sch) +Sets the @var{sch} as default color scheme. Default value is @code{"BbcyrR"}. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetColor (@code{char} id, @code{mreal} r, @code{mreal} g, @code{mreal} b) static +@deftypefnx {C function} @code{void} mgl_set_color (@code{char} id, @code{mreal} r, @code{mreal} g, @code{mreal} b) +Sets RGB values for color with given @var{id}. This is global setting which influence on any later usage of symbol @var{id}. +@end deftypefn +@end ifclear + + +@c ================================================================== +@external{} +@node Masks, Error handling, Palette and colors, Graphics setup +@subsection Masks +@nav{} +@cindex SetMask +@cindex SetMaskAngle + +@anchor{mask} +@deftypefn {MGL command} {} mask 'id' 'hex' +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetMask (@code{char} id, @code{const char *}hex) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetMask (@code{char} id, @code{uint64_t} hex) +@deftypefnx {C function} @code{void} mgl_set_mask (@code{HMGL} gr, @code{const char *}hex) +@deftypefnx {C function} @code{void} mgl_set_mask_val (@code{HMGL} gr, @code{uint64_t} hex) +@end ifclear +Sets new bit matrix @var{hex} of size 8*8 for mask with given @var{id}. This is global setting which influence on any later usage of symbol @var{id}. The predefined masks are (see @ref{Color scheme}): @samp{-} is 000000FF00000000, @samp{+} is 080808FF08080808, @samp{=} is 0000FF00FF000000, @samp{;} is 0000007700000000, @samp{o} is 0000182424180000, @samp{O} is 0000183C3C180000, @samp{s} is 00003C24243C0000, @samp{S} is 00003C3C3C3C0000, @samp{~} is 0000060990600000, @samp{<} is 0060584658600000, @samp{>} is 00061A621A060000, @samp{j} is 0000005F00000000, @samp{d} is 0008142214080000, @samp{D} is 00081C3E1C080000, @samp{*} is 8142241818244281, @samp{^} is 0000001824420000. +@end deftypefn + +@deftypefn {MGL command} {} mask angle +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetMaskAngle (@code{int} angle) +@deftypefnx {C function} @code{void} mgl_set_mask_angle (@code{HMGL} gr, @code{int} angle) +@end ifclear +Sets the default rotation angle (in degrees) for masks. Note, you can use symbols @samp{\}, @samp{/}, @samp{I} in color scheme for setting rotation angles as 45, -45 and 90 degrees correspondingly. +@end deftypefn + + +@c ================================================================== +@external{} +@node Error handling, , Masks, Graphics setup +@subsection Error handling +@nav{} +@ifclear UDAV +@cindex Message +@cindex SetWarn +@cindex GetWarn + +Normally user should set it to zero by @code{SetWarn(0);} before plotting and check if @code{GetWarn()} or @code{Message()} return non zero after plotting. Only last warning will be saved. All warnings/errors produced by MathGL is not critical -- the plot just will not be drawn. + +@deftypefn {Method on @code{mglGraph}} @code{void} SetWarn (@code{int} code, @code{const char *}info=@code{""}) +@deftypefnx {C function} @code{void} mgl_set_warn (@code{HMGL} gr, @code{int} code, @code{const char *}info) +Set warning code. Normally you should call this function only for clearing the warning state, i.e. call @code{SetWarn(0);}. Text @var{info} will be printed as is if @var{code}<0. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{const char *}Message () +@deftypefnx {C function} @code{const char *}mgl_get_mess (@code{HMGL} gr) +Return messages about matters why some plot are not drawn. If returned string is empty then there are no messages. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} GetWarn () +@deftypefnx {C function} @code{int} mgl_get_warn (@code{HMGL} gr) +Return the numerical ID of warning about the not drawn plot. Possible values are: +@table @code +@item mglWarnNone=0 +Everything OK +@item mglWarnDim +Data dimension(s) is incompatible +@item mglWarnLow +Data dimension(s) is too small +@item mglWarnNeg +Minimal data value is negative +@item mglWarnFile +No file or wrong data dimensions +@item mglWarnMem +Not enough memory +@item mglWarnZero +Data values are zero +@item mglWarnLeg +No legend entries +@item mglWarnSlc +Slice value is out of range +@item mglWarnCnt +Number of contours is zero or negative +@item mglWarnOpen +Couldn't open file +@item mglWarnLId +Light: ID is out of range +@item mglWarnSize +Setsize: size(s) is zero or negative +@item mglWarnFmt +Format is not supported for that build +@item mglWarnTern +Axis ranges are incompatible +@item mglWarnNull +Pointer is NULL +@item mglWarnSpc +Not enough space for plot +@item mglScrArg +Wrong argument(s) of a command in MGL script +@item mglScrCmd +Wrong command in MGL script +@item mglScrLong +Too long line in MGL script +@item mglScrStr +Unbalanced ' in MGL script +@end table +@end deftypefn +@end ifclear + +@c ================================================================== +@external{} +@node Axis settings, Subplots and rotation, Graphics setup, MathGL core +@section Axis settings +@nav{} + +These large set of variables and functions control how the axis and ticks will be drawn. Note that there is 3-step transformation of data coordinates are performed. Firstly, coordinates are projected if @code{Cut=true} (see @ref{Cutting}), after it transformation formulas are applied, and finally the data was normalized in bounding box. Note, that MathGL will produce warning if axis range and transformation formulas are not compatible. + +@menu +* Ranges (bounding box):: +* Curved coordinates:: +* Ticks:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Ranges (bounding box), Curved coordinates, , Axis settings +@subsection Ranges (bounding box) +@nav{} +@cindex CRange +@cindex XRange +@cindex YRange +@cindex ZRange +@cindex Ranges +@cindex Origin +@ifclear UDAV +@cindex SetRange +@cindex SetRanges +@cindex SetOrigin +@end ifclear + +@anchor{xrange} +@anchor{yrange} +@anchor{zrange} +@anchor{crange} +@deftypefn {MGL command} {} xrange @code{v1 v2} [@code{add=off}] +@deftypefnx {MGL command} {} yrange @code{v1 v2} [@code{add=off}] +@deftypefnx {MGL command} {} zrange @code{v1 v2} [@code{add=off}] +@deftypefnx {MGL command} {} crange @code{v1 v2} [@code{add=off}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRange (@code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {Method on @code{mglGraph}} @code{void} AddRange (@code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {C function} @code{void} mgl_set_range_val (@code{HMGL} gr, @code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {C function} @code{void} mgl_add_range_val (@code{HMGL} gr, @code{char} dir, @code{mreal} v1, @code{mreal} v2) +@end ifclear +Sets or adds the range for @samp{x}-,@samp{y}-,@samp{z}- coordinate or coloring (@samp{c}). If one of values is @code{NAN} then it is ignored. See also @ref{ranges}. +@end deftypefn + + +@deftypefn {MGL command} {} xrange dat [@code{add=off}] +@deftypefnx {MGL command} {} yrange dat [@code{add=off}] +@deftypefnx {MGL command} {} zrange dat [@code{add=off}] +@deftypefnx {MGL command} {} crange dat [@code{add=off}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRange (@code{char} dir, @code{const mglDataA &}dat, @code{bool} add=@code{false}) +@deftypefnx {C function} @code{void} mgl_set_range_dat (@code{HMGL} gr, @code{char} dir, @code{const HCDT} a, @code{int} add) +@end ifclear +Sets the range for @samp{x}-,@samp{y}-,@samp{z}- coordinate or coloring (@samp{c}) as minimal and maximal values of data @var{dat}. Parameter @code{add=on} shows that the new range will be joined to existed one (not replace it). +@end deftypefn + +@anchor{ranges} +@deftypefn {MGL command} {} ranges @code{x1 x2 y1 y2 [z1=0 z2=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRanges (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRanges (@code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1=@code{0}, @code{double} z2=@code{0}) +@deftypefnx {C function} @code{void} mgl_set_ranges (@code{HMGL} gr, @code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1, @code{double} z2) +@end ifclear +Sets the ranges of coordinates. If minimal and maximal values of the coordinate are the same then they are ignored. Also it sets the range for coloring (analogous to @code{crange z1 z2}). This is default color range for 2d plots. Initial ranges are [-1, 1]. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz, @code{const mglDataA &}cc) +Sets the ranges of @samp{x}-,@samp{y}-,@samp{z}-coordinates and coloring as minimal and maximal values of data @var{xx}, @var{yy}, @var{zz}, @var{cc} correspondingly. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetAutoRanges (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetAutoRanges (@code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1=@code{0}, @code{double} z2=@code{0}, @code{double} c1=@code{0}, @code{double} c2=@code{0}) +@deftypefnx {C function} @code{void} mgl_set_auto_ranges (@code{HMGL} gr, @code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1, @code{double} z2, @code{double} z1, @code{double} z2) +Sets the ranges for automatic coordinates. If minimal and maximal values of the coordinate are the same then they are ignored. +@end deftypefn + +@end ifclear + +@anchor{origin} +@deftypefn {MGL command} {} origin @code{x0 y0 [z0=nan]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetOrigin (@code{mglPoint} p0) +@deftypefnx {Method on @code{mglGraph}} @code{void} SetOrigin (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0=@code{NAN}) +@deftypefnx {C function} @code{void} mgl_set_origin (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0) +@end ifclear +Sets center of axis cross section. If one of values is NAN then MathGL try to select optimal axis position. +@end deftypefn + +@anchor{zoomaxis} +@deftypefn {MGL command} {} zoomaxis @code{x1 x2} +@deftypefnx {MGL command} {} zoomaxis @code{x1 y1 x2 y2} +@deftypefnx {MGL command} {} zoomaxis @code{x1 y1 z1 x2 y2 z2} +@deftypefnx {MGL command} {} zoomaxis @code{x1 y1 z1 c1 x2 y2 z2 c2} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ZoomAxis (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {C function} @code{void} mgl_zoom_axis (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} c1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} c2) +@end ifclear +Additionally extend axis range for any settings made by @code{SetRange} or @code{SetRanges} functions according the formula @math{min += (max-min)*p1} and @math{max += (max-min)*p1} (or @math{min *= (max/min)^p1} and @math{max *= (max/min)^p1} for log-axis range when @math{inf>max/min>100} or @math{00 set relative length of subticks which is in @code{sqrt(1+stt)} times smaller. +@end deftypefn + +@deftypefn {MGL command} {} axisstl 'stl' ['tck'='' 'sub'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetAxisStl (@code{const char *}stl=@code{"k"}, @code{const char *}tck=@code{0}, @code{const char *}sub=@code{0}) +@deftypefnx {C function} @code{void} mgl_set_axis_stl (@code{HMGL} gr, @code{const char *}stl, @code{const char *}tck, @code{const char *}sub) +@end ifclear +The line style of axis (@var{stl}), ticks (@var{tck}) and subticks (@var{sub}). If @var{stl} is empty then default style is used (@samp{k} or @samp{w} depending on transparency type). If @var{tck} or @var{sub} is empty then axis style is used (i.e. @var{stl}). +@end deftypefn + +@c ################################################################## +@external{} +@node Subplots and rotation, Export picture, Axis settings, MathGL core +@section Subplots and rotation +@nav{} +@cindex Aspect +@cindex Rotate +@cindex RotateN +@cindex SubPlot +@cindex MultiPlot +@cindex StickPlot +@cindex ColumnPlot +@cindex InPlot +@cindex Title +@cindex Perspective +@cindex View +@cindex Push +@cindex Pop + +These functions control how and where further plotting will be placed. There is a certain calling order of these functions for the better plot appearance. First one should be @ref{subplot}, @ref{multiplot} or @ref{inplot} for specifying the place. Second one can be @ref{title} for adding title for the subplot. After it a @ref{rotate} and @ref{aspect}. And finally any other plotting functions may be called. Alternatively you can use @ref{columnplot}, @ref{gridplot}, @ref{stickplot} or relative @ref{inplot} for positioning plots in the column (or grid, or stick) one by another without gap between plot axis (bounding boxes). @sref{Subplots} + +@anchor{subplot} +@deftypefn {MGL command} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SubPlot (@code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl=@code{"<>_^"}, @code{mreal} dx=@code{0}, @code{mreal} dy=@code{0}) +@deftypefnx {C function} @code{void} mgl_subplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl) +@deftypefnx {C function} @code{void} mgl_subplot_d (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl, @code{mreal} dx, @code{mreal} dy) +@end ifclear +Puts further plotting in a @var{m}-th cell of @var{nx}*@var{ny} grid of the whole frame area. This function set off any aspects or rotations. So it should be used first for creating the subplot. Extra space will be reserved for axis/colorbar if @var{stl} contain: +@itemize @bullet +@item +@samp{L} or @samp{<} -- at left side, +@item +@samp{R} or @samp{>} -- at right side, +@item +@samp{A} or @samp{^} -- at top side, +@item +@samp{U} or @samp{_} -- at bottom side, +@item +@samp{#} -- reserve none space (use whole region for axis range). +@end itemize +From the aesthetical point of view it is not recommended to use this function with different matrices in the same frame. The position of the cell can be shifted from its default position by relative size @var{dx}, @var{dy}. +@end deftypefn + +@anchor{multiplot} +@deftypefn {MGL command} {} multiplot @code{nx ny m dx dy} ['style'='<>_^'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} MultiPlot (@code{int} nx, @code{int} ny, @code{int} m, @code{int} dx, @code{int} dy, @code{const char *}stl=@code{"<>_^"}) +@deftypefnx {C function} @code{void} mgl_multiplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{int} dx, @code{int} dy, @code{const char *}stl) +@end ifclear +Puts further plotting in a rectangle of @var{dx}*@var{dy} cells starting from @var{m}-th cell of @var{nx}*@var{ny} grid of the whole frame area. This function set off any aspects or rotations. So it should be used first for creating subplot. Extra space will be reserved for axis/colorbar if @var{stl} contain: +@itemize @bullet +@item +@samp{L} or @samp{<} -- at left side, +@item +@samp{R} or @samp{>} -- at right side, +@item +@samp{A} or @samp{^} -- at top side, +@item +@samp{U} or @samp{_} -- at bottom side. +@end itemize +@end deftypefn + +@anchor{inplot} +@deftypefn {MGL command} {} inplot @code{x1 x2 y1 y2 [rel=on]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} InPlot (@code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{bool} rel=@code{true}) +@deftypefnx {C function} @code{void} mgl_inplot (@code{HMGL} gr, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@deftypefnx {C function} @code{void} mgl_relplot (@code{HMGL} gr, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@end ifclear +Puts further plotting in some region of the whole frame surface. This function allows one to create a plot in arbitrary place of the screen. The position is defined by rectangular coordinates [@var{x1}, @var{x2}]*[@var{y1}, @var{y2}]. The coordinates @var{x1}, @var{x2}, @var{y1}, @var{y2} are normalized to interval [0, 1]. If parameter @var{rel}=@code{true} then the relative position to current @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}) is used. This function set off any aspects or rotations. So it should be used first for creating subplot. +@end deftypefn + +@anchor{columnplot} +@deftypefn {MGL command} {} columnplot @code{num ind [d=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ColumnPlot (@code{int} num, @code{int} ind, @code{mreal} d=@code{0}) +@deftypefnx {C function} @code{void} mgl_columnplot (@code{HMGL} gr, @code{int} num, @code{int} ind) +@deftypefnx {C function} @code{void} mgl_columnplot_d (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} d) +@end ifclear +Puts further plotting in @var{ind}-th cell of column with @var{num} cells. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}). Parameter @var{d} set extra gap between cells. +@end deftypefn + +@anchor{gridplot} +@deftypefn {MGL command} {} gridplot @code{nx ny ind [d=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} GridPlot (@code{int} nx, @code{int} ny, @code{int} ind, @code{mreal} d=@code{0}) +@deftypefnx {C function} @code{void} mgl_gridplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} ind) +@deftypefnx {C function} @code{void} mgl_gridplot_d (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} ind, @code{mreal} d) +@end ifclear +Puts further plotting in @var{ind}-th cell of @var{nx}*@var{ny} grid. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}). Parameter @var{d} set extra gap between cells. +@end deftypefn + +@anchor{stickplot} +@deftypefn {MGL command} {} stickplot @code{num ind tet phi} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} StickPlot (@code{int} num, @code{int} ind, @code{mreal} tet, @code{mreal} phi) +@deftypefnx {C function} @code{void} mgl_stickplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} tet, @code{mreal} phi) +@end ifclear +Puts further plotting in @var{ind}-th cell of stick with @var{num} cells. At this, stick is rotated on angles @var{tet}, @var{phi}. The position is relative to previous @ref{subplot} (or @ref{inplot} with @var{rel}=@code{false}). +@end deftypefn + +@anchor{title} +@deftypefn {MGL command} {} title 'title' ['stl'='' @code{size=-2}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Title (@code{const char *}txt, @code{const char *}stl=@code{""}, @code{mreal} size=@code{-2}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Title (@code{const wchar_t *}txt, @code{const char *}stl=@code{""}, @code{mreal} size=@code{-2}) +@deftypefnx {C function} @code{void} mgl_title (@code{HMGL} gr, @code{const char *}txt, @code{const char *}stl, @code{mreal} size) +@deftypefnx {C function} @code{void} mgl_titlew (@code{HMGL} gr, @code{const wchar_t *}txt, @code{const char *}stl, @code{mreal} size) +@end ifclear +Add text @var{title} for current subplot/inplot. Paramater @var{stl} can contain: +@itemize @bullet +@item +font style (see, @ref{Font styles}); +@item +@samp{#} for box around the title. +@end itemize +Parameter @var{size} set font size. This function set off any aspects or rotations. So it should be used just after creating subplot. +@end deftypefn + +@anchor{rotate} +@deftypefn {MGL command} {} rotate @code{tetx tetz [tety=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Rotate (@code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY=@code{0}) +@deftypefnx {C function} @code{void} mgl_rotate (@code{HMGL} gr, @code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY) +@end ifclear +Rotates a further plotting relative to each axis @{x, z, y@} consecutively on angles @var{TetX}, @var{TetZ}, @var{TetY}. +@end deftypefn + +@deftypefn {MGL command} {} rotate @code{tet x y z} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} RotateN (@code{mreal} Tet, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {C function} @code{void} mgl_rotate_vector (@code{HMGL} gr, @code{mreal Tet}, @code{mreal x}, @code{mreal y}, @code{mreal z}) +@end ifclear +Rotates a further plotting around vector @{@var{x}, @var{y}, @var{z}@} on angle @var{Tet}. +@end deftypefn + +@anchor{aspect} +@deftypefn {MGL command} {} aspect @code{ax ay [az=1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Aspect (@code{mreal} Ax, @code{mreal} Ay, @code{mreal} Az=@code{1}) +@deftypefnx {C function} @code{void} mgl_aspect (@code{HMGL} gr, @code{mreal} Ax, @code{mreal} Ay, @code{mreal} Az) +@end ifclear +Defines aspect ratio for the plot. The viewable axes will be related one to another as the ratio @var{Ax:Ay:Az}. For the best effect it should be used after @ref{rotate} function. If @var{Ax} is @code{NAN} then function try to select optimal aspect ratio to keep equal ranges for x-y axis. At this, @var{Ay} will specify proportionality factor, or set to use automatic one if @var{Ay}=@code{NAN}. +@end deftypefn + +@ifclear UDAV + +@deftypefn {Method on @code{mglGraph}} @code{void} Push () +@deftypefnx {C function} @code{void} mgl_mat_push (@code{HMGL} gr) +Push transformation matrix into stack. Later you can restore its current state by Pop() function. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} Pop () +@deftypefnx {C function} @code{void} mgl_mat_pop (@code{HMGL} gr) +Pop (restore last 'pushed') transformation matrix into stack. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetPlotFactor (@code{mreal} val) +@deftypefnx {C function} @code{void} mgl_set_plotfactor (@code{HMGL} gr, @code{mreal} val) +Sets the factor of plot size. It is not recommended to set it lower then 1.5. This is some analogue of function Zoom() but applied not to overall image but for each InPlot. Use negative value or zero to enable automatic selection. +@end deftypefn + +@end ifclear + +There are 3 functions @code{View()}, @code{Zoom()} and @code{Perspective()} which transform whole image. I.e. they act as secondary transformation matrix. They were introduced for rotating/zooming the whole plot by mouse. It is not recommended to call them for picture drawing. + +@anchor{perspective} +@deftypefn {MGL command} {} perspective @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Perspective (@code{mreal} a) +@deftypefnx {C function} @code{void} mgl_perspective (@code{HMGL} gr, @code{mreal} a) +@end ifclear +Add (switch on) the perspective to plot. The parameter @math{a = Depth/(Depth+dz) \in [0,1)}. By default (@code{a=0}) the perspective is off. +@end deftypefn + +@anchor{view} +@deftypefn {MGL command} {} view @code{tetx tetz [tety=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} View (@code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY=@code{0}) +@deftypefnx {C function} @code{void} mgl_view (@code{HMGL} gr, @code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY) +@end ifclear +Rotates a further plotting relative to each axis @{x, z, y@} consecutively on angles @var{TetX}, @var{TetZ}, @var{TetY}. Rotation is done independently on @ref{rotate}. Attention! this settings can not be overwritten by @code{DefaultPlotParam()}. Use @code{Zoom(0,0,1,1)} to return default view. +@end deftypefn + +@anchor{zoom} +@deftypefn {MGL command} {} zoom @code{x1 y1 x2 y2} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph} (C++, Python)} @code{void} Zoom (@code{mreal} x1, @code{mreal} y1, @code{mreal} x2, @code{mreal} y2) +@deftypefnx {C function} @code{void} mgl_set_zoom (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} x2, @code{mreal} y2) +@end ifclear +The function changes the scale of graphics that correspond to zoom in/out of the picture. After function call the current plot will be cleared and further the picture will contain plotting from its part [x1,x2]*[y1,y2]. Here picture coordinates @var{x1}, @var{x2}, @var{y1}, @var{y2} changes from 0 to 1. Attention! this settings can not be overwritten by any other functions, including @code{DefaultPlotParam()}. Use @code{Zoom(0,0,1,1)} to return default view. +@end deftypefn + +@c ################################################################## +@external{} +@node Export picture, Primitives, Subplots and rotation, MathGL core +@section Export picture +@nav{} +@cindex SetSize + +Functions in this group save or give access to produced picture. So, usually they should be called after plotting is done. + +@anchor{setsize} +@deftypefn {MGL command} {} setsize @code{w h} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetSize (@code{int} width, @code{int} height) +@deftypefnx {C function} @code{void} mgl_set_size (@code{HMGL} gr, @code{int} width, @code{int} height) +@end ifclear +Sets size of picture in pixels. This function @strong{must be} called before any other plotting because it completely remove picture contents. +@end deftypefn + +@anchor{quality} +@deftypefn {MGL command} {} quality [@code{val}=2] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetQuality (@code{int} val=@code{MGL_DRAW_NORM}) +@deftypefnx {C function} @code{void} mgl_set_quality (@code{HMGL} gr, @code{int} val) +@end ifclear +Sets quality of the plot depending on value @var{val}: @code{MGL_DRAW_WIRE=0} -- no face drawing (fastest), @code{MGL_DRAW_FAST=1} -- no color interpolation (fast), @code{MGL_DRAW_NORM=2} -- high quality (normal), @code{MGL_DRAW_HIGH=3} -- high quality with 3d primitives (arrows and marks); @code{MGL_DRAW_LMEM=0x4} -- direct bitmap drawing (low memory usage); @code{MGL_DRAW_DOTS=0x8} -- for dots drawing instead of primitives (extremely fast). +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{int} GetQuality () +@deftypefnx {C function} @code{int} mgl_get_quality (@code{HMGL} gr) +Gets quality of the plot: @code{MGL_DRAW_WIRE=0} -- no face drawing (fastest), @code{MGL_DRAW_FAST=1} -- no color interpolation (fast), @code{MGL_DRAW_NORM=2} -- high quality (normal), @code{MGL_DRAW_HIGH=3} -- high quality with 3d primitives (arrows and marks); @code{MGL_DRAW_LMEM=0x4} -- direct bitmap drawing (low memory usage); @code{MGL_DRAW_DOTS=0x8} -- for dots drawing instead of primitives (extremely fast). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} StartGroup (const char *name) +@deftypefnx {C function} @code{void} mgl_start_group (@code{HMGL} gr, @code{const char *}name) +Starts group definition. Groups contain objects and other groups, they are used to select a part of a model to zoom to or to make invizible or to make semitransparent and so on. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} EndGroup () +@deftypefnx {C function} @code{void} mgl_end_group (@code{HMGL} gr) +Ends group definition. +@end deftypefn +@end ifclear + +@menu +* Export to file:: +* Frames/Animation:: +* Bitmap in memory:: +* Parallelization:: +@end menu + +@c ================================================================== +@external{} +@node Export to file, Frames/Animation, , Export picture +@subsection Export to file +@nav{} +@cindex Write +@ifclear UDAV +@cindex WriteFrame +@cindex WritePNG +@cindex WriteGIF +@c @cindex WriteIDTF +@cindex WriteSVG +@cindex WriteBMP +@cindex WriteEPS +@cindex WriteBPS +@cindex WriteTGA +@cindex WriteTEX +@cindex WritePRC +@cindex WriteOBJ +@cindex WriteWGL +@cindex WriteJPEG +@cindex ShowImage +@end ifclear + +These functions export current view to a graphic file. The filename @var{fname} should have appropriate extension. Parameter @var{descr} gives the short description of the picture. Just now the transparency is supported in PNG, SVG, OBJ and PRC files. + +@anchor{write} +@deftypefn {MGL command} {} write ['fname'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} WriteFrame (@code{const char *}fname=@code{""}, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_frame (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@end ifclear +Exports current frame to a file @var{fname} which type is determined by the extension. Parameter @var{descr} adds description to file (can be @code{""}). If @var{fname}=@code{""} then the file @samp{frame####.jpg} is used, where @samp{####} is current frame id and name @samp{frame} is defined by @ref{plotid} class property. +@end deftypefn + +@ifclear UDAV + +@deftypefn {Method on @code{mglGraph}} @code{void} WritePNG (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{int} compr=@code{""}, @code{bool} alpha=@code{true}) +@deftypefnx {C function} @code{void} mgl_write_png (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@deftypefnx {C function} @code{void} mgl_write_png_solid (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to PNG file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file, @var{alpha} gives the transparency type. By default there are no description added and semitransparent image used. This function does nothing if HAVE_PNG isn't defined during compilation of MathGL library. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteJPEG (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_jpg (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to JPEG file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. By default there is no description added. This function does nothing if HAVE_JPEG isn't defined during compilation of MathGL library. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteGIF (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_gif (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to GIF file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. By default there is no description added. This function does nothing if HAVE_GIF isn't defined during compilation of MathGL library. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteBMP (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_bmp (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to BMP file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. There is no compression used. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteTGA (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_tga (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to TGA file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. There is no compression used. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteEPS (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_eps (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to EPS file using vector representation. So it is not recommended for the export of large data plot. It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. By default there is no description added. If file name is terminated by @samp{z} (for example, @samp{fname.eps.gz}) then file will be compressed in gzip format. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteBPS (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_eps (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to EPS file using bitmap representation. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. By default there is no description added. If file name is terminated by @samp{z} (for example, @samp{fname.eps.gz}) then file will be compressed in gzip format. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteSVG (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_svg (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to SVG (Scalable Vector Graphics) file using vector representation. In difference of EPS format, SVG format support transparency that allows to correctly draw semitransparent plot (like @ref{surfa}, @ref{surf3a} or @ref{cloud}). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). If file name is terminated by @samp{z} (for example, @samp{fname.svgz}) then file will be compressed in gzip format. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteTEX (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_tex (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to LaTeX (package Tikz/PGF) file using vector representation. Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). Note, there is no text scaling now (for example, in subplots), what may produce miss-aligned labels. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WritePRC (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{bool} make_pdf=@code{true}) +@deftypefnx {C function} @code{void} mgl_write_prc (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr, @code{int} make_pdf) +Exports current frame to PRC file using vector representation (see @url{http://en.wikipedia.org/wiki/PRC_%28file_format%29}). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). If parameter @var{make_pdf}=@code{true} and PDF was enabled at MathGL configure then corresponding PDF file with 3D image will be created. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteOBJ (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_obj (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to OBJ/MTL file using vector representation (see @url{http://en.wikipedia.org/wiki/Wavefront_.obj_file, OBJ format} for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteXYZ (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_xyz (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to XYZ/XYZL/XYZF files using vector representation (see @url{http://people.sc.fsu.edu/~jburkardt/data/xyz/xyz.html, XYZ format} for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteSTL (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_stl (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to STL file using vector representation (see @url{http://en.wikipedia.org/wiki/STL_(file_format), STL format} for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteOFF (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{bool} colored=@code{false}) +@deftypefnx {C function} @code{void} mgl_write_off (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr, @code{bool} colored) +Exports current frame to OFF file using vector representation (see @url{http://people.sc.fsu.edu/~jburkardt/data/off/off.html, OFF format} for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@end deftypefn + +@c @deftypefn {Method on @code{mglGraph}} @code{void} WriteX3D (@code{const char *}fname, @code{const char *}descr=@code{""}) +@c @deftypefnx {C function} @code{void} mgl_write_x3d (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@c Exports current frame to X3D file using vector representation (see @url{http://en.wikipedia.org/wiki/X3d, X3D format} for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@c @end deftypefn + + +@c @deftypefn {Method on @code{mglGraph}} @code{void} WriteIDTF (@code{const char *}fname, @code{const char *}descr=@code{""}) +@c @deftypefnx {C function} @code{void} mgl_write_idtf (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@c Exports current frame to IDTF file. Later this file can be converted to U3D format. The vector representation is used. So, the output file may be too large for graphic of large data array (especially for surfaces). However, program has no internal limitations for size of output file. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@c @end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} ShowImage (@code{const char *}viewer, @code{bool} nowait=@code{false}) +@deftypefnx {C function} @code{void} mgl_show_image (@code{const char *}viewer, @code{int} nowait) +Displays the current picture using external program @var{viewer} for viewing. The function save the picture to temporary file and call @var{viewer} to display it. If @var{nowait}=@code{true} then the function return immediately (it will not wait while window will be closed). +@end deftypefn + + +@deftypefn {Method on @code{mglGraph}} @code{void} WriteJSON (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_write_json (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports current frame to textual file using @ref{JSON format}. Later this file can be used for faster loading and viewing by JavaScript script. Parameter @var{fname} specifies the file name, @var{descr} adds description to file. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} ExportMGLD (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {C function} @code{void} mgl_export_mgld (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Exports points and primitives in file using @ref{MGLD format}. Later this file can be used for faster loading and viewing by @code{mglview} utility. Parameter @var{fname} specifies the file name, @var{descr} adds description to file (default is file name). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} ImportMGLD (@code{const char *}fname, @code{bool} add=@code{false}) +@deftypefnx {C function} @code{void} mgl_import_mgld (@code{HMGL} gr, @code{const char *}fname, @code{int} add) +Imports points and primitives in file using @ref{MGLD format}. Later this file can be used for faster loading and viewing by @code{mglview} utility. Parameter @var{fname} specifies the file name, @var{add} sets to append or replace primitives to existed ones. +@end deftypefn + +@end ifclear + + +@c ################################################################## +@external{} +@node Frames/Animation, Bitmap in memory, Export to file, Export picture +@subsection Frames/Animation +@nav{} + +@ifset UDAV +There are no commands for making animation in MGL. However you can use features of @code{mglconv} and @code{mglview} utilities. For example, by busing special comments @samp{##a } or @samp{##c }. +@end ifset + +@ifclear UDAV +@cindex NewFrame +@cindex EndFrame +@cindex GetNumFrame +@cindex ResetFrames +@cindex StartGIF +@cindex CloseGIF + +These functions provide ability to create several pictures simultaneously. For most of cases it is useless but for widget classes (see @ref{Widget classes}) they can provide a way to show animation. Also you can write several frames into animated GIF file. + +@deftypefn {Method on @code{mglGraph}} @code{void} NewFrame () +@deftypefnx {C function} @code{void} mgl_new_frame (@code{HMGL} gr) +Creates new frame. Function returns current frame id. This is not thread safe function in OpenGL mode! Use direct list creation in multi-threading drawing. The function @code{EndFrame()} @strong{must} be call after the finishing of the frame drawing for each call of this function. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} EndFrame () +@deftypefnx {C function} @code{void} mgl_end_frame (@code{HMGL} gr) +Finishes the frame drawing. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} GetNumFrame () +@deftypefnx {C function} @code{int} mgl_get_num_frame (@code{HMGL} gr) +Gets the number of created frames. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetFrame (@code{int} i) +@deftypefnx {C function} @code{void} mgl_set_frame (@code{HMGL} gr, @code{int} i) +Finishes the frame drawing and sets drawing data to frame @var{i}, which should be in range [0, @code{GetNumFrame()}-1]. This function is similar to @code{EndFrame()} but don't add frame to the GIF image. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} GetFrame (@code{int} i) +@deftypefnx {C function} @code{void} mgl_get_frame (@code{HMGL} gr, @code{int} i) +Replaces drawing data by one from frame @var{i}. Function work if @code{MGL_VECT_FRAME} is set on (by default). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} ShowFrame (@code{int} i) +@deftypefnx {C function} @code{void} mgl_show_frame (@code{HMGL} gr, @code{int} i) +Appends drawing data from frame @var{i} to current one. Function work if @code{MGL_VECT_FRAME} is set on (by default). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} DelFrame (@code{int} i) +@deftypefnx {C function} @code{void} mgl_del_frame (@code{HMGL} gr, @code{int} i) +Deletes drawing data for frame @var{i} and shift all later frame indexes. Function work if @code{MGL_VECT_FRAME} is set on (by default). Do nothing in OpenGL mode. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} ResetFrames () +@deftypefnx {C function} @code{void} mgl_reset_frames (@code{HMGL} gr) +Reset frames counter (start it from zero). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} StartGIF (@code{const char *}fname, @code{int} ms=@code{100}) +@deftypefnx {C function} @code{void} mgl_start_gif (@code{HMGL} gr, @code{const char *}fname, @code{int} ms) +Start writing frames into animated GIF file @var{fname}. Parameter @var{ms} set the delay between frames in milliseconds. You @strong{should not} change the picture size during writing the cinema. Use @code{CloseGIF()} to finalize writing. Note, that this function is disabled in OpenGL mode. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} CloseGIF () +@deftypefnx {C function} @code{void} mgl_close_gif (@code{HMGL} gr) +Finish writing animated GIF and close connected pointers. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Bitmap in memory, Parallelization, Frames/Animation, Export picture +@subsection Bitmap in memory +@nav{} + +@ifclear UDAV +These functions return the created picture (bitmap), its width and height. You may display it by yourself in any graphical library (see also, @ref{Widget classes}) or save in file (see also, @ref{Export to file}). + +@deftypefn {Method on @code{mglGraph}} @code{const unsigned char *} GetRGB () +@deftypefnx {Method on @code{mglGraph}} @code{void} GetRGB (@code{char *}buf, @code{int} size) +@deftypefnx {Method on @code{mglGraph}} @code{void} GetBGRN (@code{char *}buf, @code{int} size) +@deftypefnx {C function} @code{const unsigned char *} mgl_get_rgb (@code{HMGL} gr) +Gets RGB bitmap of the current state of the image. Format of each element of bits is: @{red, green, blue@}. Number of elements is Width*Height. Position of element @{i,j@} is [3*i + 3*Width*j] (or is [4*i + 4*Width*j] for @code{GetBGRN()}). You have to provide the proper @var{size} of the buffer, @var{buf}, i.e. the code for Python should look like +@verbatim +from mathgl import * +gr = mglGraph(); +bits='\t'; +bits=bits.expandtabs(4*gr.GetWidth()*gr.GetHeight()); +gr.GetBGRN(bits, len(bits)); +@end verbatim +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{const unsigned char *} GetRGBA () +@deftypefnx {Method on @code{mglGraph}} @code{void} GetRGBA (@code{char *}buf, @code{int} size) +@deftypefnx {C function} @code{const unsigned char *} mgl_get_rgba (@code{HMGL} gr) +Gets RGBA bitmap of the current state of the image. Format of each element of bits is: @{red, green, blue, alpha@}. Number of elements is Width*Height. Position of element @{i,j@} is [4*i + 4*Width*j]. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} GetWidth () +@deftypefnx {Method on @code{mglGraph}} @code{int} GetHeight () +@deftypefnx {C function} @code{int} mgl_get_width (@code{HMGL} gr) +@deftypefnx {C function} @code{int} mgl_get_height (@code{HMGL} gr) +Gets width and height of the image. +@end deftypefn + + +@deftypefn {Method on @code{mglGraph}} @code{mglPoint} CalcXYZ (@code{int} xs, @code{int} ys) +@deftypefnx {C function} @code{void} mgl_calc_xyz (@code{HMGL} gr, @code{int} xs, @code{int} ys, @code{mreal *}x, @code{mreal *}y, @code{mreal *}z) +Calculate 3D coordinate @{x,y,z@} for screen point @{xs,ys@}. At this moment it ignore perspective and transformation formulas (curvilinear coordinates). The calculation are done for the last used InPlot (see @ref{Subplots and rotation}). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{mglPoint} CalcScr (@code{mglPoint} p) +@deftypefnx {C function} @code{void} mgl_calc_scr (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{int *}xs, @code{int *}ys) +Calculate screen point @{xs,ys@} for 3D coordinate @{x,y,z@}. The calculation are done for the last used InPlot (see @ref{Subplots and rotation}). +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} SetObjId (@code{int} id) +@deftypefnx {C function} @code{void} mgl_set_obj_id (@code{HMGL} gr, @code{int} id) +Set the numeric id for object or subplot/inplot. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} GetObjId (@code{int} xs, @code{int} ys) +@deftypefnx {C function} @code{int} mgl_get_obj_id (@code{HMGL} gr, @code{int} xs, @code{int} ys) +Get the numeric id for most upper object at pixel @{xs, ys@} of the picture. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} GetSplId (@code{int} xs, @code{int} ys) +@deftypefnx {C function} @code{int} mgl_get_spl_id (@code{HMGL} gr, @code{int} xs, @code{int} ys) +Get the numeric id for most subplot/inplot at pixel @{xs, ys@} of the picture. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{void} Highlight (@code{int} id) +@deftypefnx {C function} @code{void} mgl_highlight (@code{HMGL} gr, @code{int} id) +Highlight the object with given @var{id}. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{long} IsActive (@code{int} xs, @code{int} ys, @code{int} d=@code{1}) +@deftypefnx {C function} @code{long} mgl_is_active (@code{HMGL} gr, @code{int} xs, @code{int} ys, @code{int} d) +Checks if point @{@var{xs}, @var{ys}@} is close to one of active point (i.e. mglBase::Act) with accuracy @var{d} and return its index or @code{-1} if not found. Active points are special points which characterize primitives (like edges and so on). This function for advanced users only. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{long} SetDrawReg (@code{int} nx=@code{1}, @code{int} ny=@code{1}, @code{int} m=@code{0}) +@deftypefnx {C function} @code{long} mgl_set_draw_reg (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m) +Limits drawing region by rectangular area of @var{m}-th cell of matrix with sizes @var{nx}*@var{ny} (like in @ref{subplot}). This function can be used to update only small region of the image for purposes of higher speed. This function for advanced users only. +@end deftypefn + + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Parallelization, , Bitmap in memory, Export picture +@subsection Parallelization +@nav{} + +@ifclear UDAV +@cindex Combine +@cindex MPI_Send +@cindex MPI_Recv + +Many of things MathGL do in parallel by default (if MathGL was built with pthread). However, there is function which set the number of threads to be used. + +@deftypefn {C function} @code{int} mgl_set_num_thr (@code{int} n) +Set the number of threads to be used by MathGL. If @var{n}<1 then the number of threads is set as maximal number of processors (cores). If @var{n}=1 then single thread will be used (this is default if pthread was disabled). +@end deftypefn + +Another option is combining bitmap image (taking into account Z-ordering) from different instances of @code{mglGraph}. This method is most appropriate for computer clusters when the data size is so large that it exceed the memory of single computer node. + +@deftypefn {Method on @code{mglGraph}} @code{int} Combine (@code{const mglGraph *}g) +@deftypefnx {C function} @code{int} mgl_combine_gr (@code{HMGL} gr, @code{HMGL} g) +Combine drawing from instance @var{g} with @var{gr} (or with this) taking into account Z-ordering of pixels. The width and height of both instances must be the same. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} MPI_Send (@code{int} id) +@deftypefnx {C function} @code{int} mgl_mpi_send (@code{HMGL} gr, @code{int} id) +Send graphical information from node @var{id} using MPI. The width and height in both nodes must be the same. +@end deftypefn + +@deftypefn {Method on @code{mglGraph}} @code{int} MPI_Recv (@code{int} id) +@deftypefnx {C function} @code{int} mgl_mpi_send (@code{HMGL} gr, @code{int} id) +Receive graphical information from node @var{id} using MPI. The width and height in both nodes must be the same. +@end deftypefn +@end ifclear + + +@c ################################################################## +@external{} +@node Primitives, Text printing, Export picture, MathGL core +@section Primitives +@nav{} +@cindex Ball +@cindex Clf +@cindex Line +@cindex Curve +@cindex Glyph +@cindex Face +@cindex FaceX +@cindex FaceY +@cindex FaceZ +@cindex Cone +@cindex Drop +@cindex Sphere + +@ifclear UDAV +@cindex Mark +@cindex Error +@end ifclear + +These functions draw some simple objects like line, point, sphere, drop, cone and so on. @sref{Using primitives} + +@anchor{clf} +@deftypefn {MGL command} {} clf ['col'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Clf () +@deftypefnx {Method on @code{mglGraph}} @code{void} Clf (@code{char} col) +@deftypefnx {Method on @code{mglGraph}} @code{void} Clf (@code{mreal} r, @code{mreal} g, @code{mreal} b) +@deftypefnx {C function} @code{void} mgl_clf (@code{HMGL} gr) +@deftypefnx {C function} @code{void} mgl_clf_chr (@code{HMGL} gr, @code{char} col) +@deftypefnx {C function} @code{void} mgl_clf_rgb (@code{HMGL} gr, @code{mreal} r, @code{mreal} g, @code{mreal} b) +@end ifclear +Clear the picture and fill it by specified color. +@end deftypefn + +@anchor{ball} +@deftypefn {MGL command} {} ball @code{x y} ['col'='r.'] +@deftypefnx {MGL command} {} ball @code{x y z} ['col'='r.'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Ball (@code{mglPoint} p, @code{char} col=@code{'r'}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Mark (@code{mglPoint} p, @code{const char *}mark) +@deftypefnx {C function} @code{void} mgl_mark (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}mark) +@end ifclear +Draws a mark (point @samp{.} by default) at position @var{p}=@{@var{x}, @var{y}, @var{z}@} with color @var{col}. +@end deftypefn + +@anchor{errbox} +@deftypefn {MGL command} {} errbox @code{x y ex ey} ['stl'=''] +@deftypefnx {MGL command} {} errbox @code{x y z ex ey ez} ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Error (@code{mglPoint} p, @code{mglPoint} e, @code{char} *stl=@code{""}) +@deftypefnx {C function} @code{void} mgl_error_box (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal} ex, @code{mreal} ey, @code{mreal} ez, @code{char *}stl) +@end ifclear +Draws a 3d error box at position @var{p}=@{@var{x}, @var{y}, @var{z}@} with sizes @var{e}=@{@var{ex}, @var{ey}, @var{ez}@} and style @var{stl}. Use NAN for component of @var{e} to reduce number of drawn elements. +@end deftypefn + +@anchor{line} +@deftypefn {MGL command} {} line @code{x1 y1 x2 y2} ['stl'=''] +@deftypefnx {MGL command} {} line @code{x1 y1 z1 x2 y2 z2} ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Line (@code{mglPoint} p1, @code{mglPoint} p2, @code{char *}stl=@code{"B"}, @code{int} num=@code{2}) +@deftypefnx {C function} @code{void} mgl_line (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{char *}stl, @code{int} num) +@end ifclear +Draws a geodesic line (straight line in Cartesian coordinates) from point @var{p1} to @var{p2} using line style @var{stl}. Parameter @var{num} define the ``quality'' of the line. If @var{num}=@code{2} then the stright line will be drawn in all coordinate system (independently on transformation formulas (see @ref{Curved coordinates}). Contrary, for large values (for example, =@code{100}) the geodesic line will be drawn in corresponding coordinate system (straight line in Cartesian coordinates, circle in polar coordinates and so on). Line will be drawn even if it lies out of bounding box. +@end deftypefn + +@anchor{curve} +@deftypefn {MGL command} {} curve @code{x1 y1 dx1 dy1 x2 y2 dx2 dy2} ['stl'=''] +@deftypefnx {MGL command} {} curve @code{x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2} ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Curve (@code{mglPoint} p1, @code{mglPoint} d1, @code{mglPoint} p2, @code{mglPoint} d2, @code{const char *}stl=@code{"B"}, @code{int} num=@code{100}) +@deftypefnx {C function} @code{void} mgl_curve (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} dx1, @code{mreal} dy1, @code{mreal} dz1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} dx2, @code{mreal} dy2, @code{mreal} dz2, @code{const char *}stl, @code{int} num) +@end ifclear +Draws Bezier-like curve from point @var{p1} to @var{p2} using line style @var{stl}. At this tangent is codirected with @var{d1}, @var{d2} and proportional to its amplitude. Parameter @var{num} define the ``quality'' of the curve. If @var{num}=@code{2} then the straight line will be drawn in all coordinate system (independently on transformation formulas, see @ref{Curved coordinates}). Contrary, for large values (for example, =@code{100}) the spline like Bezier curve will be drawn in corresponding coordinate system. Curve will be drawn even if it lies out of bounding box. +@end deftypefn + +@anchor{face} +@deftypefn {MGL command} {} face @code{x1 y1 x2 y2 x3 y3 x4 y4} ['stl'=''] +@deftypefnx {MGL command} {} face @code{x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4} ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Face (@code{mglPoint} p1, @code{mglPoint} p2, @code{mglPoint} p3, @code{mglPoint} p4, @code{const char *}stl=@code{"w"}) +@deftypefnx {C function} @code{void} mgl_face (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} x3, @code{mreal} y3, @code{mreal} z3, @code{mreal} x4, @code{mreal} y4, @code{mreal} z4, @code{const char *}stl) +@end ifclear +Draws the solid quadrangle (face) with vertexes @var{p1}, @var{p2}, @var{p3}, @var{p4} and with color(s) @var{stl}. At this colors can be the same for all vertexes or different if all 4 colors are specified for each vertex. Face will be drawn even if it lies out of bounding box. +@end deftypefn + +@anchor{rect} +@deftypefn {MGL command} {} rect @code{x1 y1 x2 y2} ['stl'=''] +@deftypefnx {MGL command} {} rect @code{x1 y1 z1 x2 y2 z2} ['stl'=''] +Draws the solid rectangle (face) with vertexes @{@var{x1}, @var{y1}, @var{z1}@} and @{@var{x2}, @var{y2}, @var{z2}@} with color @var{stl}. At this colors can be the same for all vertexes or separately if all 4 colors are specified for each vertex. Face will be drawn even if it lies out of bounding box. +@end deftypefn + +@anchor{facex} +@anchor{facey} +@anchor{facez} +@deftypefn {MGL command} {} facex @code{x0 y0 z0 wy wz} ['stl'='' @code{d1=0 d2=0}] +@deftypefnx {MGL command} {} facey @code{x0 y0 z0 wx wz} ['stl'='' @code{d1=0 d2=0}] +@deftypefnx {MGL command} {} facez @code{x0 y0 z0 wx wy} ['stl'='' @code{d1=0 d2=0}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FaceX (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wy, @code{mreal} wz, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {Method on @code{mglGraph}} @code{void} FaceY (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wz, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {Method on @code{mglGraph}} @code{void} FaceZ (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wy, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {C function} @code{void} mgl_facex (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wy, @code{mreal} wz, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@deftypefnx {C function} @code{void} mgl_facey (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wz, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@deftypefnx {C function} @code{void} mgl_facez (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wy, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@end ifclear +Draws the solid rectangle (face) perpendicular to [x,y,z]-axis correspondingly at position @{@var{x0}, @var{y0}, @var{z0}@} with color @var{stl} and with widths @var{wx}, @var{wy}, @var{wz} along corresponding directions. At this colors can be the same for all vertexes or separately if all 4 colors are specified for each vertex. Parameters @var{d1}!=0, @var{d2}!=0 set additional shift of the last vertex (i.e. to draw quadrangle). Face will be drawn even if it lies out of bounding box. +@end deftypefn + +@anchor{sphere} +@deftypefn {MGL command} {} sphere @code{x0 y0 r} ['col'='r'] +@deftypefnx {MGL command} {} sphere @code{x0 y0 z0 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Sphere (@code{mglPoint} p, @code{mreal} r, @code{const char *}stl=@code{"r"}) +@deftypefnx {C function} @code{void} mgl_sphere (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} r, @code{const char *}stl) +@end ifclear +Draw the sphere with radius @var{r} and center at point @var{p}=@{@var{x0}, @var{y0}, @var{z0}@} and color @var{stl}. +@end deftypefn + +@anchor{drop} +@deftypefn {MGL command} {} drop @code{x0 y0 dx dy r} ['col'='r' @code{sh=1 asp=1}] +@deftypefnx {MGL command} {} drop @code{x0 y0 z0 dx dy dz r} ['col'='r' @code{sh=1 asp=1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Drop (@code{mglPoint} p, @code{mglPoint} d, @code{mreal} r, @code{const char *}col=@code{"r"}, @code{mreal} shift=@code{1}, @code{mreal} ap=@code{1}) +@deftypefnx {C function} @code{void} mgl_drop (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{mreal} r, @code{const char *}col, @code{mreal} shift, @code{mreal} ap) +@end ifclear +Draw the drop with radius @var{r} at point @var{p} elongated in direction @var{d} and with color @var{col}. Parameter @var{shift} set the degree of drop oblongness: @samp{0} is sphere, @samp{1} is maximally oblongness drop. Parameter @var{ap} set relative width of the drop (this is analogue of ``ellipticity'' for the sphere). +@end deftypefn + +@anchor{cone} +@deftypefn {MGL command} {} cone @code{x1 y1 z1 x2 y2 z2 r1} [@code{r2=-1} 'stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cone (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r1, @code{mreal} r2=@code{-1}, @code{const char *}stl=@code{"B"}) +@deftypefnx {C function} @code{void} mgl_cone (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r1, @code{mreal} r2, @code{const char *}stl) +@end ifclear +Draw tube (or truncated cone if @var{edge}=@code{false}) between points @var{p1}, @var{p2} with radius at the edges @var{r1}, @var{r2}. If @var{r2}<0 then it is supposed that @var{r2}=@var{r1}. The cone color is defined by string @var{stl}. Parameter @var{stl} can contain: +@itemize @bullet +@item +@samp{@@} for drawing edges; +@item +@samp{#} for wired cones; +@item +@samp{t} for drawing tubes/cylinder instead of cones/prisms; +@item +@samp{4}, @samp{6}, @samp{8}, @samp{t} for drawing square, hex- or octo-prism instead of cones. +@end itemize +@end deftypefn + +@anchor{circle} +@deftypefn {MGL command} {} circle @code{x0 y0 r} ['col'='r'] +@deftypefnx {MGL command} {} circle @code{x0 y0 z0 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Circle (@code{mglPoint} p, @code{mreal} r, @code{const char *}stl=@code{"r"}) +@end ifclear +Draw the circle with radius @var{r} and center at point @var{p}=@{@var{x0}, @var{y0}, @var{z0}@}. Parameter @var{col} may contain +@itemize @bullet +@item +colors for filling and boundary (second one if style @samp{@@} is used, black color is used by default); +@item +@samp{#} for wire figure (boundary only); +@item +@samp{@@} for filling and boundary. +@end itemize +@end deftypefn + +@anchor{ellipse} +@deftypefn {MGL command} {} ellipse @code{x1 y1 x2 y2 r} ['col'='r'] +@deftypefnx {MGL command} {} ellipse @code{x1 y1 z1 x2 y2 z2 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Ellipse (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r, @code{const char *}col=@code{"r"}) +@deftypefnx {C function} @code{void} mgl_ellipse (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r, @code{const char *}col) +@end ifclear +Draw the ellipse with radius @var{r} and focal points @var{p1}, @var{p2}. Parameter @var{col} may contain +@itemize @bullet +@item +colors for filling and boundary (second one if style @samp{@@} is used, black color is used by default); +@item +@samp{#} for wire figure (boundary only); +@item +@samp{@@} for filling and boundary. +@end itemize +@end deftypefn + +@anchor{rhomb} +@deftypefn {MGL command} {} rhomb @code{x1 y1 x2 y2 r} ['col'='r'] +@deftypefnx {MGL command} {} rhomb @code{x1 y1 z1 x2 y2 z2 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Rhomb (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r, @code{const char *}col=@code{"r"}) +@deftypefnx {C function} @code{void} mgl_rhomb (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r, @code{const char *}col) +@end ifclear +Draw the rhombus with width @var{r} and edge points @var{p1}, @var{p2}. Parameter @var{col} may contain +@itemize @bullet +@item +colors for filling and boundary (second one if style @samp{@@} is used, black color is used by default); +@item +@samp{#} for wire figure (boundary only); +@item +@samp{@@} for filling and boundary. +@end itemize +@end deftypefn + +@c ################################################################## +@external{} +@node Text printing, Axis and Colorbar, Primitives, MathGL core +@section Text printing +@nav{} +@ifclear UDAV +@cindex Puts +@cindex Putsw +@end ifclear +@cindex Text +@cindex Label +@cindex fgets + +These functions draw the text. There are functions for drawing text in arbitrary place, in arbitrary direction and along arbitrary curve. MathGL can use arbitrary font-faces and parse many TeX commands (for more details see @ref{Font styles}). All these functions have 2 variant: for printing 8-bit text (@code{char *}) and for printing Unicode text (@code{wchar_t *}). In first case the conversion into the current locale is used. So sometimes you need to specify it by @code{setlocale()} function. The @var{size} argument control the size of text: if positive it give the value, if negative it give the value relative to @code{SetFontSize()}. The font type (STIX, arial, courier, times and so on) can be selected by function LoadFont(). @xref{Font settings}. + +The font parameters are described by string. This string may set the text color @samp{wkrgbcymhRGBCYMHW} (see @ref{Color styles}). Also, after delimiter symbol @samp{:}, it can contain characters of font type (@samp{rbiwou}) and/or align (@samp{LRC}) specification. The font types are: @samp{r} -- roman (or regular) font, @samp{i} -- italic style, @samp{b} -- bold style, @samp{w} -- wired style, @samp{o} -- over-lined text, @samp{u} -- underlined text. By default roman font is used. The align types are: @samp{L} -- align left (default), @samp{C} -- align center, @samp{R} -- align right. For example, string @samp{b:iC} correspond to italic font style for centered text which printed by blue color. + +If string contains symbols @samp{aA} then text is printed at absolute position @{@var{x}, @var{y}@} (supposed to be in range [0,1]) of picture (for @samp{A}) or subplot/inplot (for @samp{a}). If string contains symbol @samp{@@} then box around text is drawn. + +@sref{Text features} + +@anchor{text} +@deftypefn {MGL command} {} text @code{x y} 'text' ['fnt'='' @code{size=-1}] +@deftypefnx {MGL command} {} text @code{x y z} 'text' ['fnt'='' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Puts (@code{mglPoint} p, @code{const char *}text, @code{const char *}fnt=@code{":C"}, @code{mreal} size=@code{-1}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Putsw (@code{mglPoint} p, @code{const wchar_t *}text, @code{const char *}fnt=@code{":C"}, @code{mreal} size=@code{-1}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Puts (@code{mreal} x, @code{mreal} y, @code{const char *}text, @code{const char *}fnt=@code{":AC"}, @code{mreal} size=@code{-1}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Putsw (@code{mreal} x, @code{mreal} y, @code{const wchar_t *}text, @code{const char *}fnt=@code{":AC"}, @code{mreal} size=@code{-1}) +@deftypefnx {C function} @code{void} mgl_puts (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}text, @code{const char *}fnt, @code{mreal} size) +@deftypefnx {C function} @code{void} mgl_putsw (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const wchar_t *}text, @code{const char *}fnt, @code{mreal} size) +@end ifclear +The function plots the string @var{text} at position @var{p} with fonts specifying by the criteria @var{fnt}. The size of font is set by @var{size} parameter (default is @code{-1}). +@end deftypefn + +@deftypefn {MGL command} {} text @code{x y dx dy} 'text' ['fnt'=':L' @code{size=-1}] +@deftypefnx {MGL command} {} text @code{x y z dx dy dz} 'text' ['fnt'=':L' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Puts (@code{mglPoint} p, @code{mglPoint} d, @code{const char *}text, @code{const char *}fnt=@code{":L"}, @code{mreal} size=@code{-1}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Putsw (@code{mglPoint} p, @code{mglPoint} d, @code{const wchar_t *}text, @code{const char *}fnt=@code{":L"}, @code{mreal} size=@code{-1}) +@deftypefnx {C function} @code{void} mgl_puts_dir (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{const char *}text, @code{const char *}fnt, @code{mreal} size) +@deftypefnx {C function} @code{void} mgl_putsw_dir (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{const wchar_t *}text, @code{const char *}fnt, @code{mreal} size) +@end ifclear +The function plots the string @var{text} at position @var{p} along direction @var{d} with specified @var{size}. Parameter @var{fnt} set text style and text position: above (@samp{T}) or under (@samp{t}) the line. +@end deftypefn + +@anchor{fgets} +@deftypefn {MGL command} {} fgets @code{x y} 'fname' [@code{n=0} 'fnt'='' @code{size=-1.4}] +@deftypefnx {MGL command} {} fgets @code{x y z} 'fname' [@code{n=0} 'fnt'='' @code{size=-1.4}] +Draws unrotated @var{n}-th line of file @var{fname} at position @{@var{x},@var{y},@var{z}@} with specified @var{size}. By default parameters from @ref{font} command are used. +@end deftypefn + +@deftypefn {MGL command} {} text ydat 'text' ['fnt'=''] +@deftypefnx {MGL command} {} text xdat ydat 'text' ['fnt'=''] +@deftypefnx {MGL command} {} text xdat ydat zdat 'text' ['fnt'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}y, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}y, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_text_y (@code{HMGL} gr, @code{HCDT} y, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textw_y (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_text_xy (@code{HCDT} x, @code{HCDT} y, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textw_xy (@code{HCDT} x, @code{HCDT} y, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_text_xyz (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textw_xyz (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +The function draws @var{text} along the curve between points @{@var{x}[i], @var{y}[i], @var{z}[i]@} by font style @var{fnt}. The string @var{fnt} may contain symbols @samp{t} for printing the text under the curve (default), or @samp{T} for printing the text above the curve. The sizes of 1st dimension must be equal for all arrays @code{x.nx=y.nx=z.nx}. If array @var{x} is not specified then its an automatic array is used with values equidistantly distributed in interval [@var{Min}.x, @var{Max}.x] (see @ref{Ranges (bounding box)}). If array @var{z} is not specified then @var{z}[i] = @var{Min}.z is used. String @var{opt} contain command options (see @ref{Command options}). +@end deftypefn + +@c ################################################################## +@external{} +@node Axis and Colorbar, Legend, Text printing, MathGL core +@section Axis and Colorbar +@nav{} +@cindex Axis +@cindex Box +@cindex Grid +@cindex Colorbar +@cindex Label + +These functions draw the ``things for measuring'', like axis with ticks, colorbar with ticks, grid along axis, bounding box and labels for axis. For more information see @ref{Axis settings}. + +@anchor{axis} +@deftypefn {MGL command} {} axis ['dir'='xyz' 'stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Axis (@code{const char *}dir=@code{"xyz"}, @code{const char *}stl=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_axis (@code{HMGL} gr, @code{const char *}dir, @code{const char *}stl, @code{const char *}opt) +@end ifclear +Draws axes with ticks (see @ref{Axis settings}). Parameter @var{dir} may contain: +@itemize @bullet +@item +@samp{xyz} for drawing axis in corresponding direction; +@item +@samp{XYZ} for drawing axis in corresponding direction but with inverted positions of labels; +@item +@samp{~} or @samp{_} for disabling tick labels; +@item +@samp{U} for disabling rotation of tick labels; +@item +@samp{^} for inverting default axis origin; +@item +@samp{AKDTVISO} for drawing arrow at the end of axis; +@item +@samp{a} for forced adjusting of axis ticks. +@end itemize +Styles of ticks and axis can be overrided by using @var{stl} string. @sref{Axis and ticks} +@end deftypefn + +@anchor{colorbar} +@deftypefn {MGL command} {} colorbar ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Colorbar (@code{const char *}sch=@code{""}) +@deftypefnx {C function} @code{void} mgl_colorbar (@code{HMGL} gr, @code{const char *}sch) +@end ifclear +Draws colorbar. Parameter @var{sch} may contain: +@itemize @bullet +@item +color scheme (see @ref{Color scheme}); +@item +@samp{<>^_} for positioning at left, at right, at top or at bottom correspondingly; +@item +@samp{I} for positioning near bounding (by default, is positioned at edges of subplot); +@item +@samp{A} for using absolute coordinates; +@item +@samp{~} for disabling tick labels. +@end itemize +@sref{Colorbars} +@end deftypefn + +@deftypefn {MGL command} {} colorbar vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Colorbar (@code{const mglDataA &}v, @code{const char *}sch=@code{""}) +@deftypefnx {C function} @code{void} mgl_colorbar_val (@code{HMGL} gr, @code{HCDT} v, @code{const char *}sch) +@end ifclear +The same as previous but with sharp colors @var{sch} (current palette if @code{sch=""}) for values @var{v}. @sref{ContD sample} +@end deftypefn + +@deftypefn {MGL command} {} colorbar 'sch' @code{x y [w=1 h=1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Colorbar (@code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w=@code{1}, @code{mreal} h=@code{1}) +@deftypefnx {C function} @code{void} mgl_colorbar_ext (@code{HMGL} gr, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w, @code{mreal} h) +@end ifclear +The same as first one but at arbitrary position of subplot @{@var{x}, @var{y}@} (supposed to be in range [0,1]). Parameters @var{w}, @var{h} set the relative width and height of the colorbar. +@end deftypefn + +@deftypefn {MGL command} {} colorbar vdat 'sch' @code{x y [w=1 h=1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Colorbar (@code{const mglDataA &}v, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w=@code{1}, @code{mreal} h=@code{1}) +@deftypefnx {C function} @code{void} mgl_colorbar_val_ext (@code{HMGL} gr, @code{HCDT} v, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w, @code{mreal} h) +@end ifclear +The same as previous but with sharp colors @var{sch} (current palette if @code{sch=""}) for values @var{v}. @sref{ContD sample} +@end deftypefn + +@anchor{grid} +@deftypefn {MGL command} {} grid ['dir'='xyz' 'pen'='B'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Grid (@code{const char *}dir=@code{"xyz"}, @code{const char *}pen=@code{"B"}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_axis_grid (@code{HMGL} gr, @code{const char *}dir, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Draws grid lines perpendicular to direction determined by string parameter @var{dir}. The step of grid lines is the same as tick step for @ref{axis}. The style of lines is determined by @var{pen} parameter (default value is dark blue solid line @samp{B-}). +@end deftypefn + +@anchor{box} +@deftypefn {MGL command} {} box ['stl'='k' @code{ticks=on}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Box (@code{const char *}col=@code{""}, @code{bool} ticks=@code{true}) +@deftypefnx {C function} @code{void} mgl_box (@code{HMGL} gr, @code{int} ticks) +@deftypefnx {C function} @code{void} mgl_box_str (@code{HMGL} gr, @code{const char *}col, @code{int} ticks) +@end ifclear +Draws bounding box outside the plotting volume with color @var{col}. If @var{col} contain @samp{@@} then filled faces are drawn. At this first color is used for faces (default is light yellow), last one for edges. @sref{Bounding box} +@end deftypefn + +@anchor{xlabel} +@anchor{ylabel} +@anchor{zlabel} +@anchor{tlabel} +@deftypefn {MGL command} {} xlabel 'text' [@code{pos=1}] +@deftypefnx {MGL command} {} ylabel 'text' [@code{pos=1}] +@deftypefnx {MGL command} {} zlabel 'text' [@code{pos=1}] +@deftypefnx {MGL command} {} tlabel 'text' [@code{pos=1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{char} dir, @code{const char *}text, @code{mreal} pos=@code{1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{char} dir, @code{const wchar_t *}text, @code{mreal} pos=@code{1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_label (@code{HMGL} gr, @code{char} dir, @code{const char *}text, @code{mreal} pos, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_labelw (@code{HMGL} gr, @code{char} dir, @code{const wchar_t *}text, @code{mreal} pos, @code{const char *}opt) +@end ifclear +Prints the label @var{text} for axis @var{dir}=@samp{x},@samp{y},@samp{z},@samp{t} (here @samp{t} is ``ternary'' axis @math{t=1-x-y}). The position of label is determined by @var{pos} parameter. If @var{pos}=0 then label is printed at the center of axis. If @var{pos}>0 then label is printed at the maximum of axis. If @var{pos}<0 then label is printed at the minimum of axis. Option @code{value} set additional shifting of the label. @xref{Text printing}. +@end deftypefn + +@c ################################################################## +@external{} +@node Legend, 1D plotting, Axis and Colorbar, MathGL core +@section Legend +@nav{} +@cindex Legend +@cindex AddLegend +@cindex ClearLegend +@cindex SetLegendBox +@cindex SetLegendMarks + +These functions draw legend to the graph (useful for @ref{1D plotting}). Legend entry is a pair of strings: one for style of the line, another one with description text (with included TeX parsing). The arrays of strings may be used directly or by accumulating first to the internal arrays (by function @ref{addlegend}) and further plotting it. The position of the legend can be selected automatic or manually (even out of bounding box). Parameters @var{fnt} and @var{size} specify the font style and size (see @ref{Font settings}). Parameter @var{llen} set the relative width of the line sample and the text indent. If line style string for entry is empty then the corresponding text is printed without indent. Parameter @var{fnt} may contain: +@itemize @bullet +@item +font style for legend text; +@item +@samp{A} for positioning in absolute coordinates; +@item +@samp{^} for positioning outside of specified point; +@item +@samp{#} for drawing box around legend; +@item +colors for background (first one) and border (second one) of legend. Note, that last color is always used as color for legend text. +@end itemize +@sref{Legend sample} + +@anchor{legend} +@deftypefn {MGL command} {} legend [@code{pos=3} 'fnt'='#'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Legend (@code{int} pos=@code{0x3}, @code{const char *}fnt=@code{"#"}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_legend (@code{HMGL} gr, @code{int} pos, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Draws legend of accumulated legend entries by font @var{fnt} with @var{size}. Parameter @var{pos} sets the position of the legend: @samp{0} is bottom left corner, @samp{1} is bottom right corner, @samp{2} is top left corner, @samp{3} is top right corner (is default). Parameter @var{fnt} can contain colors for face (1st one), for border (2nd one) and for text (last one). If less than 3 colors are specified then the color for border is black (for 2 and less colors), and the color for face is white (for 1 or none colors). If string @var{fnt} contain @samp{#} then border around the legend is drawn. If string @var{fnt} contain @samp{-} then legend entries will arranged horizontally. Option @code{value} set the space between line samples and text (default is 0.1). +@end deftypefn + +@deftypefn {MGL command} {} legend @code{x y} ['fnt'='#'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Legend (@code{mreal} x, @code{mreal} y, @code{const char *}fnt=@code{"#"}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_legend_pos (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Draws legend of accumulated legend entries by font @var{fnt} with @var{size}. Position of legend is determined by parameter @var{x}, @var{y} which supposed to be normalized to interval [0,1]. Option @code{value} set the space between line samples and text (default is 0.1). +@end deftypefn + +@anchor{addlegend} +@deftypefn {MGL command} {} addlegend 'text' 'stl' +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} AddLegend (@code{const char *}text, @code{const char *}style) +@deftypefnx {Method on @code{mglGraph}} @code{void} AddLegend (@code{const wchar_t *}text, @code{const char *}style) +@deftypefnx {C function} @code{void} mgl_add_legend (@code{HMGL} gr, @code{const char *}text, @code{const char *}style) +@deftypefnx {C function} @code{void} mgl_add_legendw (@code{HMGL} gr, @code{const wchar_t *}text, @code{const char *}style) +@end ifclear +Adds string @var{text} to internal legend accumulator. The style of described line and mark is specified in string @var{style} (see @ref{Line styles}). +@end deftypefn + +@anchor{clearlegend} +@deftypefn {MGL command} {} clearlegend +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ClearLegend () +@deftypefnx {C function} @code{void} mgl_clear_legend (@code{HMGL} gr) +@end ifclear +Clears saved legend strings. +@end deftypefn + +@anchor{legendmarks} +@deftypefn {MGL command} {} legendmarks @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SetLegendMarks (@code{int} num) +@deftypefnx {C function} @code{void} mgl_set_legend_marks (@code{HMGL} gr, @code{int} num) +@end ifclear +Set the number of marks in the legend. By default 1 mark is used. +@end deftypefn + +@c ################################################################## +@external{} +@node 1D plotting, 2D plotting, Legend, MathGL core +@section 1D plotting +@nav{} +@cindex Plot +@cindex Radar +@cindex Tens +@cindex Area +@cindex Region +@cindex Stem +@cindex Bars +@cindex Barh +@cindex Chart +@cindex Step +@cindex Torus +@cindex Tube +@cindex Mark +@cindex TextMark +@cindex Error +@cindex BoxPlot +@cindex Candle +@cindex Tape +@cindex Label +@cindex Cones + +These functions perform plotting of 1D data. 1D means that data depended from only 1 parameter like parametric curve @{x[i],y[i],z[i]@}, i=1...n. By default (if absent) values of @var{x}[i] are equidistantly distributed in axis range, and @var{z}[i]=@var{Min}.z. The plots are drawn for each row if one of the data is the matrix. By any case the sizes of 1st dimension @strong{must be equal} for all arrays @code{x.nx=y.nx=z.nx}. + +String @var{pen} specifies the color and style of line and marks (see @ref{Line styles}). By default (@code{pen=""}) solid line with color from palette is used (see @ref{Palette and colors}). Symbol @samp{!} set to use new color from palette for each point (not for each curve, as default). String @var{opt} contain command options (see @ref{Command options}). @sref{1D samples} + +@anchor{plot} +@deftypefn {MGL command} {} plot ydat ['stl'=''] +@deftypefnx {MGL command} {} plot xdat ydat ['stl'=''] +@deftypefnx {MGL command} {} plot xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_plot (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_plot_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_plot_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw continuous lines between points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. See also @ref{area}, @ref{step}, @ref{stem}, @ref{tube}, @ref{mark}, @ref{error}, @ref{belt}, @ref{tens}, @ref{tape}. @sref{Plot sample} +@end deftypefn + +@anchor{radar} +@deftypefn {MGL command} {} radar adat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Radar (@code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_radar (@code{HMGL} gr, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@end ifclear +This functions draws radar chart which is continuous lines between points located on an radial lines (like plot in Polar coordinates). Option @code{value} set the additional shift of data (i.e. the data @var{a}+@code{value} is used instead of @var{a}). If @code{value<0} then @code{r=max(0, -min(value)}. If @var{pen} containt @samp{#} symbol then "grid" (radial lines and circle for @var{r}) is drawn. See also @ref{plot}. @sref{Radar sample} +@end deftypefn + +@anchor{step} +@deftypefn {MGL command} {} step ydat ['stl'=''] +@deftypefnx {MGL command} {} step xdat ydat ['stl'=''] +@deftypefnx {MGL command} {} step xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Step (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Step (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Step (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_step (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_step_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_step_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw continuous stairs for points to axis plane. See also @ref{plot}, @ref{stem}, @ref{tile}, @ref{boxs}. @sref{Step sample} +@end deftypefn + +@anchor{tens} +@deftypefn {MGL command} {} tens ydat cdat ['stl'=''] +@deftypefnx {MGL command} {} tens xdat ydat cdat ['stl'=''] +@deftypefnx {MGL command} {} tens xdat ydat zdat cdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}y, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tens (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tens_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tens_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw continuous lines between points @{@var{x}[i], @var{y}[i], @var{z}[i]@} with color defined by the special array @var{c}[i] (look like tension plot). String @var{pen} specifies the color scheme (see @ref{Color scheme}) and style and/or width of line (see @ref{Line styles}). See also @ref{plot}, @ref{mesh}, @ref{fall}. @sref{Tens sample} +@end deftypefn + +@anchor{tape} +@deftypefn {MGL command} {} tape ydat ['stl'=''] +@deftypefnx {MGL command} {} tape xdat ydat ['stl'=''] +@deftypefnx {MGL command} {} tape xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tape (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tape_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tape_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw tapes of normals for curve between points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Initial tape(s) was selected in x-y plane (for @samp{x} in @var{pen}) and/or y-z plane (for @samp{x} in @var{pen}). The width of tape is proportional to @ref{barwidth} and can be changed by option @code{value}. See also @ref{plot}, @ref{flow}, @ref{barwidth}. @sref{Tape sample} +@end deftypefn + +@anchor{area} +@deftypefn {MGL command} {} area ydat ['stl'=''] +@deftypefnx {MGL command} {} area xdat ydat ['stl'=''] +@deftypefnx {MGL command} {} area xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Area (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Area (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Area (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_area (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_area_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_area_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw continuous lines between points and fills it to axis plane. Also you can use gradient filling if number of specified colors is equal to 2*number of curves. See also @ref{plot}, @ref{bars}, @ref{stem}, @ref{region}. @sref{Area sample} +@end deftypefn + +@anchor{region} +@deftypefn {MGL command} {} region ydat1 ydat2 ['stl'=''] +@deftypefnx {MGL command} {} region xdat ydat1 ydat2 ['stl'=''] +@deftypefnx {MGL command} {} region xdat1 ydat1 xdat2 ydat2 ['stl'=''] +@deftypefnx {MGL command} {} region xdat1 ydat1 zdat1 xdat2 ydat2 zdat2 ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Region (@code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x1, @code{const mglDataA &}y1, @code{const mglDataA &}x2, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x1, @code{const mglDataA &}y1, @code{const mglDataA &}z1, @code{const mglDataA &}x2, @code{const mglDataA &}y2, @code{const mglDataA &}z2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_region (@code{HMGL} gr, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_region_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_region_3d (@code{HMGL} gr, @code{HCDT} x1, @code{HCDT} y1, @code{HCDT} z1, @code{HCDT} x2, @code{HCDT} y2, @code{HCDT} z2, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions fill area between 2 curves. Dimensions of arrays @var{y1} and @var{y2} must be equal. Also you can use gradient filling if number of specified colors is equal to 2*number of curves. If @var{pen} contain symbol @samp{i} then only area with y1} then boxes will be aligned left, right or centered at its x-coordinates. See also @ref{barh}, @ref{cones}, @ref{area}, @ref{stem}, @ref{chart}, @ref{barwidth}. @sref{Bars sample} +@end deftypefn + +@anchor{barh} +@deftypefn {MGL command} {} barh vdat ['stl'=''] +@deftypefnx {MGL command} {} barh ydat vdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Barh (@code{const mglDataA &}v, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Barh (@code{const mglDataA &}y, @code{const mglDataA &}v, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_barh (@code{HMGL} gr, @code{HCDT} v, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_barh_xy (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} v, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw horizontal bars from points to axis plane. If string contain symbol @samp{a} then lines are drawn one above another (like summation). If string contain symbol @samp{f} then waterfall chart is drawn for determining the cumulative effect of sequentially introduced positive or negative values. You can give different colors for positive and negative values if number of specified colors is equal to 2*number of curves. If @var{pen} contain @samp{<}, @samp{^} or @samp{>} then boxes will be aligned left, right or centered at its x-coordinates. See also @ref{bars}, @ref{barwidth}. @sref{Barh sample} +@end deftypefn + +@anchor{cones} +@deftypefn {MGL command} {} cones ydat ['stl'=''] +@deftypefnx {MGL command} {} cones xdat ydat ['stl'=''] +@deftypefnx {MGL command} {} cones xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cones (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cones_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cones_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw cones from points to axis plane. If string contain symbol @samp{a} then cones are drawn one above another (like summation). You can give different colors for positive and negative values if number of specified colors is equal to 2*number of curves. Parameter @var{pen} can contain: +@itemize @bullet +@item +@samp{@@} for drawing edges; +@item +@samp{#} for wired cones; +@item +@samp{t} for drawing tubes/cylinders instead of cones/prisms; +@item +@samp{4}, @samp{6}, @samp{8}, @samp{t} for drawing square, hex- or octo-prism instead of cones; +@item +@samp{<}, @samp{^} or @samp{>} for aligning boxes left, right or centering them at its x-coordinates. +@end itemize +See also @ref{bars}, @ref{cone}, @ref{barwidth}. @sref{Cones sample} +@end deftypefn + + + +@anchor{chart} +@deftypefn {MGL command} {} chart adat ['col'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Chart (@code{const mglDataA &}a, @code{const char *}col=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_chart (@code{HMGL} gr, @code{HCDT} a, @code{const char *}col, @code{const char *}opt) +@end ifclear +The function draws colored stripes (boxes) for data in array @var{a}. The number of stripes is equal to the number of rows in @var{a} (equal to @var{a.ny}). The color of each next stripe is cyclically changed from colors specified in string @var{col} or in palette Pal (see @ref{Palette and colors}). Spaces in colors denote transparent ``color'' (i.e. corresponding stripe(s) are not drawn). The stripe width is proportional to value of element in @var{a}. Chart is plotted only for data with non-negative elements. If string @var{col} have symbol @samp{#} then black border lines are drawn. The most nice form the chart have in 3d (after rotation of coordinates) or in cylindrical coordinates (becomes so called Pie chart). @sref{Chart sample} +@end deftypefn + +@anchor{boxplot} +@deftypefn {MGL command} {} boxplot adat ['stl'=''] +@deftypefnx {MGL command} {} boxplot xdat adat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} BoxPlot (@code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} BoxPlot (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_boxplot (@code{HMGL} gr, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_boxplot_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw boxplot (also known as a box-and-whisker diagram) at points @var{x}[i]. This is five-number summaries of data @var{a}[i,j] (minimum, lower quartile (Q1), median (Q2), upper quartile (Q3) and maximum) along second (j-th) direction. If @var{pen} contain @samp{<}, @samp{^} or @samp{>} then boxes will be aligned left, right or centered at its x-coordinates. See also @ref{plot}, @ref{error}, @ref{bars}, @ref{barwidth}. @sref{BoxPlot sample} +@end deftypefn + +@anchor{candle} +@deftypefn {MGL command} {} candle vdat1 ['stl'=''] +@deftypefnx {MGL command} {} candle vdat1 vdat2 ['stl'=''] +@deftypefnx {MGL command} {} candle vdat1 ydat1 ydat2 ['stl'=''] +@deftypefnx {MGL command} {} candle vdat1 vdat2 ydat1 ydat2 ['stl'=''] +@deftypefnx {MGL command} {} candle xdat vdat1 vdat2 ydat1 ydat2 ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}x, @code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_candle (@code{HMGL} gr, @code{HCDT} v1, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_candle_yv (@code{HMGL} gr, @code{HCDT} v1, @code{HCDT} v2, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_candle_xyv (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} v1, @code{HCDT} v2, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw candlestick chart at points @var{x}[i]. This is a combination of a line-chart and a bar-chart, in that each bar represents the range of price movement over a given time interval. Wire (or white) candle correspond to price growth @var{v1}[i]<@var{v2}[i], opposite case -- solid (or dark) candle. "Shadows" show the minimal @var{y1} and maximal @var{y2} prices. If @var{v2} is absent then it is determined as @var{v2}[i]=@var{v1}[i+1]. See also @ref{plot}, @ref{bars}, @ref{ohlc}, @ref{barwidth}. @sref{Candle sample} +@end deftypefn + +@anchor{ohlc} +@deftypefn {MGL command} {} ohlc odat hdat ldat cdat ['stl'=''] +@deftypefnx {MGL command} {} ohlc xdat odat hdat ldat cdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} OHLC (@code{const mglDataA &}o, @code{const mglDataA &}h, @code{const mglDataA &}l, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} OHLC (@code{const mglDataA &}x, @code{const mglDataA &}o, @code{const mglDataA &}h, @code{const mglDataA &}l, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_ohlc (@code{HMGL} gr, @code{HCDT} o, @code{HCDT} h, @code{HCDT} l, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_ohlc_x (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} o, @code{HCDT} h, @code{HCDT} l, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw Open-High-Low-Close diagram. This diagram show vertical line for between maximal(high @var{h}) and minimal(low @var{l}) values, as well as horizontal lines before/after vertical line for initial(open @var{o})/final(close @var{c}) values of some process (usually price). See also @ref{candle}, @ref{plot}, @ref{barwidth}. @sref{OHLC sample} +@end deftypefn + + +@anchor{error} +@deftypefn {MGL command} {} error ydat yerr ['stl'=''] +@deftypefnx {MGL command} {} error xdat ydat yerr ['stl'=''] +@deftypefnx {MGL command} {} error xdat ydat xerr yerr ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Error (@code{const mglDataA &}y, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Error (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Error (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ex, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_error (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_error_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_error_exy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ex, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw error boxes @{@var{ex}[i], @var{ey}[i]@} at points @{@var{x}[i], @var{y}[i]@}. This can be useful, for example, in experimental points, or to show numeric error or some estimations and so on. If string @var{pen} contain symbol @samp{@@} than large semitransparent mark is used instead of error box. See also @ref{plot}, @ref{mark}. @sref{Error sample} +@end deftypefn + +@anchor{mark} +@deftypefn {MGL command} {} mark ydat rdat ['stl'=''] +@deftypefnx {MGL command} {} mark xdat ydat rdat ['stl'=''] +@deftypefnx {MGL command} {} mark xdat ydat zdat rdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_mark_y (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_mark_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_mark_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw marks with size @var{r}[i]*@ref{marksize} at points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. If you need to draw markers of the same size then you can use @ref{plot} function with empty line style @samp{ }. For markers with size in axis range use @ref{error} with style @samp{@@}. See also @ref{plot}, @ref{textmark}, @ref{error}, @ref{stem}. @sref{Mark sample} +@end deftypefn + +@anchor{textmark} +@deftypefn {MGL command} {} textmark ydat 'txt' ['stl'=''] +@deftypefnx {MGL command} {} textmark ydat rdat 'txt' ['stl'=''] +@deftypefnx {MGL command} {} textmark xdat ydat rdat 'txt' ['stl'=''] +@deftypefnx {MGL command} {} textmark xdat ydat zdat rdat 'txt' ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_textmark (@code{HMGL} gr, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmarkw (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmark_yr (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmarkw_yr (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmark_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmarkw_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmark_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_textmarkw_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +These functions draw string @var{txt} as marks with size proportional to @var{r}[i]*@var{marksize} at points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. By default (if omitted) @var{r}[i]=1. See also @ref{plot}, @ref{mark}, @ref{stem}. @sref{TextMark sample} +@end deftypefn + +@anchor{label} +@deftypefn {MGL command} {} label ydat 'txt' ['stl'=''] +@deftypefnx {MGL command} {} label xdat ydat 'txt' ['stl'=''] +@deftypefnx {MGL command} {} label xdat ydat zdat 'txt' ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_label (@code{HMGL} gr, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_labelw (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_label_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_labelw_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_label_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_labelw_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +These functions draw string @var{txt} at points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. If string @var{txt} contain @samp{%x}, @samp{%y}, @samp{%z} or @samp{%n} then it will be replaced by the value of x-,y-,z-coordinate of the point or its index. See also @ref{plot}, @ref{mark}, @ref{textmark}, @ref{table}. @sref{Label sample} +@end deftypefn + +@anchor{table} +@deftypefn {MGL command} {} table vdat 'txt' ['stl'='#'] +@deftypefnx {MGL command} {} table x y vdat 'txt' ['stl'='#'] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Table (@code{const mglDataA &}val, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Table (@code{const mglDataA &}val, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Table (@code{mreal} x, @code{mreal} y, @code{const mglDataA &}val, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Table (@code{mreal} x, @code{mreal} y, @code{const mglDataA &}val, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_table (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{HCDT} val, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tablew (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{HCDT} val, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +These functions draw table with values of @var{val} and captions from string @var{txt} (separated by newline symbol @samp{\n}) at points @{@var{x}, @var{y}@} (default at @{0,0@}) related to current subplot. If string @var{fnt} contain @samp{#} then cell border will be drawn. If string @var{fnt} contain @samp{|} then table width is limited by subplot width (equivalent option @samp{value 1}). If string @var{fnt} contain @samp{=} then widths of all cells are the same. Option @code{value} set the width of the table (default is 1). See also @ref{plot}, @ref{label}. @sref{Table sample} +@end deftypefn + +@anchor{tube} +@deftypefn {MGL command} {} tube ydat rdat ['stl'=''] +@deftypefnx {MGL command} {} tube ydat @code{rval} ['stl'=''] +@deftypefnx {MGL command} {} tube xdat ydat rdat ['stl'=''] +@deftypefnx {MGL command} {} tube xdat ydat @code{rval} ['stl'=''] +@deftypefnx {MGL command} {} tube xdat ydat zdat rdat ['stl'=''] +@deftypefnx {MGL command} {} tube xdat ydat zdat @code{rval} ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}y, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tube_r (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tube (@code{HMGL} gr, @code{HCDT} y, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tube_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tube_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tube_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tube_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw the tube with variable radius @var{r}[i] along the curve between points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. See also @ref{plot}. @sref{Tube sample} +@end deftypefn + +@anchor{torus} +@deftypefn {MGL command} {} torus rdat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Torus (@code{const mglDataA &}r, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_torus (@code{HMGL} gr, @code{HCDT} r, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +These functions draw surface which is result of curve @{@var{r}, @var{z}@} rotation around axis. If string @var{pen} contain symbols @samp{x} or @samp{z} then rotation axis will be set to specified direction (default is @samp{y}). If string @var{pen} have symbol @samp{#} then wire plot is produced. If string @var{pen} have symbol @samp{.} then plot by dots is produced. See also @ref{plot}, @ref{axial}. @sref{Torus sample} +@end deftypefn + +@c ################################################################## +@external{} +@node 2D plotting, 3D plotting, 1D plotting, MathGL core +@section 2D plotting +@nav{} +@cindex Mesh +@cindex Fall +@cindex Belt +@cindex Surf +@cindex Boxs +@cindex Tile +@cindex Dens +@cindex Cont +@cindex ContF +@cindex ContD +@cindex Axial +@cindex Grad +@cindex Grid + +These functions perform plotting of 2D data. 2D means that data depend from 2 independent parameters like matrix @math{f(x_i,y_j), i=1...n, j=1...m}. By default (if absent) values of @var{x}, @var{y} are equidistantly distributed in axis range. The plots are drawn for each z slice of the data. The minor dimensions of arrays @var{x}, @var{y}, @var{z} should be equal @code{x.nx=z.nx && y.nx=z.ny} or @code{x.nx=y.nx=z.nx && x.ny=y.ny=z.ny}. Arrays @var{x} and @var{y} can be vectors (not matrices as @var{z}). String @var{sch} sets the color scheme (see @ref{Color scheme}) for plot. String @var{opt} contain command options (see @ref{Command options}). @sref{2D samples} + +@anchor{surf} +@deftypefn {MGL command} {} surf zdat ['sch'=''] +@deftypefnx {MGL command} {} surf xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. If string @var{sch} have symbol @samp{#} then grid lines are drawn. If string @var{sch} have symbol @samp{.} then plot by dots is produced. See also @ref{mesh}, @ref{dens}, @ref{belt}, @ref{tile}, @ref{boxs}, @ref{surfc}, @ref{surfa}. @sref{Surf sample} +@end deftypefn + +@anchor{mesh} +@deftypefn {MGL command} {} mesh zdat ['sch'=''] +@deftypefnx {MGL command} {} mesh xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Mesh (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Mesh (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_mesh (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_mesh_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws mesh lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. See also @ref{surf}, @ref{fall}, @ref{meshnum}, @ref{cont}, @ref{tens}. @sref{Mesh sample} +@end deftypefn + +@anchor{fall} +@deftypefn {MGL command} {} fall zdat ['sch'=''] +@deftypefnx {MGL command} {} fall xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Fall (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Fall (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_fall (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_fall_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws fall lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. This plot can be used for plotting several curves shifted in depth one from another. If @var{sch} contain @samp{x} then lines are drawn along x-direction else (by default) lines are drawn along y-direction. See also @ref{belt}, @ref{mesh}, @ref{tens}, @ref{meshnum}. @sref{Fall sample} +@end deftypefn + +@anchor{belt} +@deftypefn {MGL command} {} belt zdat ['sch'=''] +@deftypefnx {MGL command} {} belt xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Belt (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Belt (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_belt (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_belt_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws belts for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. This plot can be used as 3d generalization of @ref{plot}). If @var{sch} contain @samp{x} then belts are drawn along x-direction else (by default) belts are drawn along y-direction. See also @ref{fall}, @ref{surf}, @ref{plot}, @ref{meshnum}. @sref{Belt sample} +@end deftypefn + +@anchor{boxs} +@deftypefn {MGL command} {} boxs zdat ['sch'=''] +@deftypefnx {MGL command} {} boxs xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Boxs (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Boxs (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_boxs (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_boxs_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws vertical boxes for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Symbol @samp{@@} in @var{sch} set to draw filled boxes. See also @ref{surf}, @ref{dens}, @ref{tile}, @ref{step}. @sref{Boxs sample} +@end deftypefn + +@anchor{tile} +@deftypefn {MGL command} {} tile zdat ['sch'=''] +@deftypefnx {MGL command} {} tile xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Tile (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Tile (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tile (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tile_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws horizontal tiles for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Such plot can be used as 3d generalization of @ref{step}. See also @ref{surf}, @ref{boxs}, @ref{step}, @ref{tiles}. @sref{Tile sample} +@end deftypefn + +@anchor{dens} +@deftypefn {MGL command} {} dens zdat ['sch'=''] +@deftypefnx {MGL command} {} dens xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Dens (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{mreal} zVal=@code{NAN}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Dens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{mreal} zVal=@code{NAN}) +@deftypefnx {C function} @code{void} mgl_dens (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dens_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws density plot for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z} = @var{Min}.z. If string @var{sch} have symbol @samp{#} then grid lines are drawn. If string @var{sch} have symbol @samp{.} then plot by dots is produced. See also @ref{surf}, @ref{cont}, @ref{contf}, @ref{boxs}, @ref{tile}, @code{dens[xyz]}. @sref{Dens sample} +@end deftypefn + +@anchor{cont} +@deftypefn {MGL command} {} cont vdat zdat ['sch'=''] +@deftypefnx {MGL command} {} cont vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont__val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws contour lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z}=@var{v}[k] or at @var{z} = @var{Min}.z if @var{sch} contain symbol @samp{_}. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v}. If string @var{sch} have symbol @samp{t} or @samp{T} then contour labels @var{v}[k] will be drawn below (or above) the contours. See also @ref{dens}, @ref{contf}, @ref{contd}, @ref{axial}, @code{cont[xyz]}. @sref{Cont sample} +@end deftypefn + +@deftypefn {MGL command} {} cont zdat ['sch'=''] +@deftypefnx {MGL command} {} cont xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{contf} +@deftypefn {MGL command} {} contf vdat zdat ['sch'=''] +@deftypefnx {MGL command} {} contf vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws solid (or filled) contour lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z}=@var{v}[k] or at @var{z} = @var{Min}.z if @var{sch} contain symbol @samp{_}. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v} (must be @code{v.nx>2}). See also @ref{dens}, @ref{cont}, @ref{contd}, @code{contf[xyz]}. @sref{ContF sample} +@end deftypefn + +@deftypefn {MGL command} {} contf zdat ['sch'=''] +@deftypefnx {MGL command} {} contf xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{contd} +@deftypefn {MGL command} {} contd vdat zdat ['sch'=''] +@deftypefnx {MGL command} {} contd vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contd_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contd_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws solid (or filled) contour lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z}=@var{v}[k] (or at @var{z} = @var{Min}.z if @var{sch} contain symbol @samp{_}) with manual colors. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v} (must be @code{v.nx>2}). String @var{sch} sets the contour colors: the color of k-th contour is determined by character @code{sch[k%strlen(sch)]}. See also @ref{dens}, @ref{cont}, @ref{contf}. @sref{ContD sample} +@end deftypefn + +@deftypefn {MGL command} {} contd zdat ['sch'=''] +@deftypefnx {MGL command} {} contd xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contd (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contd_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{contv} +@deftypefn {MGL command} {} contv vdat zdat ['sch'=''] +@deftypefnx {MGL command} {} contv vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contv_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contv_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws vertical cylinder (tube) at contour lines for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z}=@var{v}[k] or at @var{z} = @var{Min}.z if @var{sch} contain symbol @samp{_}. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v}. See also @ref{cont}, @ref{contf}. @sref{ContV sample} +@end deftypefn + +@deftypefn {MGL command} {} contv zdat ['sch'=''] +@deftypefnx {MGL command} {} contv xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contv (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contv_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{axial} +@deftypefn {MGL command} {} axial vdat zdat ['sch'=''] +@deftypefnx {MGL command} {} axial vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_axial_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_axial_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws surface which is result of contour plot rotation for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v}. If string @var{sch} have symbol @samp{#} then wire plot is produced. If string @var{sch} have symbol @samp{.} then plot by dots is produced. If string contain symbols @samp{x} or @samp{z} then rotation axis will be set to specified direction (default is @samp{y}). See also @ref{cont}, @ref{contf}, @ref{torus}, @ref{surf3}. @sref{Axial sample} +@end deftypefn + +@deftypefn {MGL command} {} axial zdat ['sch'=''] +@deftypefnx {MGL command} {} axial xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{int} num=@code{3}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{int} num=@code{3}) +@deftypefnx {C function} @code{void} mgl_axial (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_axial_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 3). +@end deftypefn + +@anchor{grid2} +@deftypefn {MGL command} {} grid2 zdat ['sch'=''] +@deftypefnx {MGL command} {} grid2 xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Grid (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Grid (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_grid (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_grid_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws grid lines for density plot of surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} at @var{z} = @var{Min}.z. See also @ref{dens}, @ref{cont}, @ref{contf}, @ref{meshnum}. +@end deftypefn + + +@c ################################################################## +@external{} +@node 3D plotting, Dual plotting, 2D plotting, MathGL core +@section 3D plotting +@nav{} +@cindex Surf3 +@cindex Dens3 +@cindex Cont3 +@cindex ContF3 +@cindex Grid3 +@cindex Cloud +@cindex Beam + +These functions perform plotting of 3D data. 3D means that data depend from 3 independent parameters like matrix @math{f(x_i,y_j,z_k), i=1...n, j=1...m, k=1...l}. By default (if absent) values of @var{x}, @var{y}, @var{z} are equidistantly distributed in axis range. The minor dimensions of arrays @var{x}, @var{y}, @var{z}, @var{a} should be equal @code{x.nx=a.nx && y.nx=a.ny && z.nz=a.nz} or @code{x.nx=y.nx=z.nx=a.nx && x.ny=y.ny=z.ny=a.ny && x.nz=y.nz=z.nz=a.nz}. Arrays @var{x}, @var{y} and @var{z} can be vectors (not matrices as @var{a}). String @var{sch} sets the color scheme (see @ref{Color scheme}) for plot. String @var{opt} contain command options (see @ref{Command options}). @sref{3D samples} + +@anchor{surf3} +@deftypefn {MGL command} {} surf3 adat @code{val} ['sch'=''] +@deftypefnx {MGL command} {} surf3 xdat ydat zdat adat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3 (@code{mreal} val, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3 (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws isosurface plot for 3d array specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) at @var{a}(x,y,z)=@var{val}. If string contain @samp{#} then wire plot is produced. If string @var{sch} have symbol @samp{.} then plot by dots is produced. Note, that there is possibility of incorrect plotting due to uncertainty of cross-section defining if there are two or more isosurface intersections inside one cell. See also @ref{cloud}, @ref{dens3}, @ref{surf3c}, @ref{surf3a}, @ref{axial}. @sref{Surf3 sample} +@end deftypefn + +@deftypefn {MGL command} {} surf3 adat ['sch'=''] +@deftypefnx {MGL command} {} surf3 xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Draws @var{num}-th uniformly distributed in color range isosurfaces for 3d data. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 3). +@end deftypefn + +@anchor{cloud} +@deftypefn {MGL command} {} cloud adat ['sch'=''] +@deftypefnx {MGL command} {} cloud xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cloud (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cloud (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cloud (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cloud_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws cloud plot for 3d data specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). This plot is a set of cubes with color and transparency proportional to value of @var{a}. The resulting plot is like cloud -- low value is transparent but higher ones are not. The number of plotting cells depend on @ref{meshnum}. If string @var{sch} contain symbol @samp{.} then lower quality plot will produced with much low memory usage. If string @var{sch} contain symbol @samp{i} then transparency will be inversed, i.e. higher become transparent and lower become not transparent. See also @ref{surf3}, @ref{meshnum}. @sref{Cloud sample} +@end deftypefn + +@anchor{dens3} +@deftypefn {MGL command} {} dens3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} dens3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Dens3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Dens3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_dens3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dens3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The function draws density plot for 3d data specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Density is plotted at slice @var{sVal} in direction @{@samp{x}, @samp{y}, @samp{z}@} if @var{sch} contain corresponding symbol (by default, @samp{y} direction is used). If string @var{stl} have symbol @samp{#} then grid lines are drawn. See also @ref{cont3}, @ref{contf3}, @ref{dens}, @ref{grid3}. @sref{Dens3 sample} +@end deftypefn + +@anchor{cont3} +@deftypefn {MGL command} {} cont3 vdat adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} cont3 vdat xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont3_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont3_xyz_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The function draws contour plot for 3d data specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Contours are plotted for values specified in array @var{v} at slice @var{sVal} in direction @{@samp{x}, @samp{y}, @samp{z}@} if @var{sch} contain corresponding symbol (by default, @samp{y} direction is used). If string @var{sch} have symbol @samp{#} then grid lines are drawn. If string @var{sch} have symbol @samp{t} or @samp{T} then contour labels will be drawn below (or above) the contours. See also @ref{dens3}, @ref{contf3}, @ref{cont}, @ref{grid3}. @sref{Cont3 sample} +@end deftypefn + +@deftypefn {MGL command} {} cont3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} cont3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{contf3} +@deftypefn {MGL command} {} contf3 vdat adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} contf3 vdat xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf3_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf3_xyz_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The function draws solid (or filled) contour plot for 3d data specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Contours are plotted for values specified in array @var{v} at slice @var{sVal} in direction @{@samp{x}, @samp{y}, @samp{z}@} if @var{sch} contain corresponding symbol (by default, @samp{y} direction is used). If string @var{sch} have symbol @samp{#} then grid lines are drawn. See also @ref{dens3}, @ref{cont3}, @ref{contf}, @ref{grid3}. @sref{ContF3 sample} +@end deftypefn + +@deftypefn {MGL command} {} contf3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} contf3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The same as previous with vector @var{v} of @var{num}-th elements equidistantly distributed in color range. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 7). +@end deftypefn + +@anchor{grid3} +@deftypefn {MGL command} {} grid3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {MGL command} {} grid3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Grid3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Grid3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_grid3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_grid3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The function draws grid for 3d data specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Grid is plotted at slice @var{sVal} in direction @{@samp{x}, @samp{y}, @samp{z}@} if @var{sch} contain corresponding symbol (by default, @samp{y} direction is used). See also @ref{cont3}, @ref{contf3}, @ref{dens3}, @ref{grid2}, @ref{meshnum}. +@end deftypefn + +@anchor{beam} +@deftypefn {MGL command} {} beam tr g1 g2 adat @code{rval} ['sch'='' @code{flag=0 num=3}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Beam (@code{const mglDataA &}tr, @code{const mglDataA &}g1, @code{const mglDataA &}g2, @code{const mglDataA &}a, @code{mreal} r, @code{const char *}stl=@code{""}, @code{int} flag=@code{0}, @code{int} num=@code{3}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Beam (@code{mreal} val, @code{const mglDataA &}tr, @code{const mglDataA &}g1, @code{const mglDataA &}g2, @code{const mglDataA &}a, @code{mreal} r, @code{const char *}stl=@code{""}, @code{int} flag=@code{0}) +@deftypefnx {C function} @code{void} mgl_beam (@code{HMGL} gr, @code{HCDT} tr, @code{HCDT} g1, @code{HCDT} g2, @code{HCDT} a, @code{mreal} r, @code{const char *}stl, @code{int} flag, @code{int} num) +@deftypefnx {C function} @code{void} mgl_beam_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} tr, @code{HCDT} g1, @code{HCDT} g2, @code{HCDT} a, @code{mreal} r, @code{const char *}stl, @code{int} flag) +@end ifclear +Draws the isosurface for 3d array @var{a} at constant values of @var{a}=@var{val}. This is special kind of plot for @var{a} specified in accompanied coordinates along curve @var{tr} with orts @var{g1}, @var{g2} and with transverse scale @var{r}. Variable @var{flag} is bitwise: @samp{0x1} - draw in accompanied (not laboratory) coordinates; @samp{0x2} - draw projection to @math{\rho-z} plane; @samp{0x4} - draw normalized in each slice field. The x-size of data arrays @var{tr}, @var{g1}, @var{g2} must be nx>2. The y-size of data arrays @var{tr}, @var{g1}, @var{g2} and z-size of the data array @var{a} must be equal. See also @ref{surf3}. +@end deftypefn + + +@c ################################################################## +@external{} +@node Dual plotting, Vector fields, 3D plotting, MathGL core +@section Dual plotting +@nav{} +@cindex SurfC +@cindex SurfA +@cindex Surf3C +@cindex Surf3A +@cindex TileS +@cindex Map +@cindex STFA + +These plotting functions draw @emph{two matrix} simultaneously. There are 5 generally different types of data representations: surface or isosurface colored by other data (SurfC, Surf3C), surface or isosurface transpared by other data (SurfA, Surf3A), tiles with variable size (TileS), mapping diagram (Map), STFA diagram (STFA). By default (if absent) values of @var{x}, @var{y}, @var{z} are equidistantly distributed in axis range. The minor dimensions of arrays @var{x}, @var{y}, @var{z}, @var{c} should be equal. Arrays @var{x}, @var{y} (and @var{z} for @code{Surf3C, Surf3A}) can be vectors (not matrices as @var{c}). String @var{sch} sets the color scheme (see @ref{Color scheme}) for plot. String @var{opt} contain command options (see @ref{Command options}). + +@anchor{surfc} +@deftypefn {MGL command} {} surfc zdat cdat ['sch'=''] +@deftypefnx {MGL command} {} surfc xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SurfC (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} SurfC (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surfc (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surfc_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} and color it by matrix @var{c}[i,j]. If string @var{sch} have symbol @samp{#} then grid lines are drawn. If string @var{sch} have symbol @samp{.} then plot by dots is produced. All dimensions of arrays @var{z} and @var{c} must be equal. Surface is plotted for each z slice of the data. See also @ref{surf}, @ref{surfa}, @ref{surf3c}. @sref{SurfC sample} +@end deftypefn + +@anchor{surf3c} +@deftypefn {MGL command} {} surf3c adat cdat @code{val} ['sch'=''] +@deftypefnx {MGL command} {} surf3c xdat ydat zdat adat cdat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3C (@code{mreal} val, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3C (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3c_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3c_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws isosurface plot for 3d array specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) at @var{a}(x,y,z)=@var{val}. It is mostly the same as @ref{surf3} function but the color of isosurface depends on values of array @var{c}. If string @var{sch} contain @samp{#} then wire plot is produced. If string @var{sch} have symbol @samp{.} then plot by dots is produced. See also @ref{surf3}, @ref{surfc}, @ref{surf3a}. @sref{Surf3C sample} +@end deftypefn + +@deftypefn {MGL command} {} surf3c adat cdat ['sch'=''] +@deftypefnx {MGL command} {} surf3c xdat ydat zdat adat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3C (@code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3C (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3c (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3c_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Draws @var{num}-th uniformly distributed in color range isosurfaces for 3d data. Here @var{num} is equal to parameter @code{value} in options @var{opt} (default is 3). +@end deftypefn + + +@anchor{surfa} +@deftypefn {MGL command} {} surfa zdat cdat ['sch'=''] +@deftypefnx {MGL command} {} surfa xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} SurfA (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} SurfA (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surfa (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surfa_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} and transparent it by matrix @var{c}[i,j]. If string @var{sch} have symbol @samp{#} then grid lines are drawn. If string @var{sch} have symbol @samp{.} then plot by dots is produced. All dimensions of arrays @var{z} and @var{c} must be equal. Surface is plotted for each z slice of the data. See also @ref{surf}, @ref{surfc}, @ref{surf3a}. @sref{SurfA sample} +@end deftypefn + +@anchor{surf3a} +@deftypefn {MGL command} {} surf3a adat cdat @code{val} ['sch'=''] +@deftypefnx {MGL command} {} surf3a xdat ydat zdat adat cdat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3A (@code{mreal} val, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3A (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3a_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3a_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws isosurface plot for 3d array specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) at @var{a}(x,y,z)=@var{val}. It is mostly the same as @ref{surf3} function but the transparency of isosurface depends on values of array @var{c}. If string @var{sch} contain @samp{#} then wire plot is produced. If string @var{sch} have symbol @samp{.} then plot by dots is produced. See also @ref{surf3}, @ref{surfc}, @ref{surf3a}. @sref{Surf3A sample} +@end deftypefn + +@deftypefn {MGL command} {} surf3a adat cdat ['sch'=''] +@deftypefnx {MGL command} {} surf3a xdat ydat zdat adat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3A (@code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Surf3A (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_surf3a (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_surf3a_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Draws @var{num}-th uniformly distributed in color range isosurfaces for 3d data. At this array @var{c} can be vector with values of transparency and @var{num}=@var{c}.nx. In opposite case @var{num} is equal to parameter @code{value} in options @var{opt} (default is 3). +@end deftypefn + +@anchor{tiles} +@deftypefn {MGL command} {} tiles zdat rdat ['sch'=''] +@deftypefnx {MGL command} {} tiles xdat ydat zdat rdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} TileS (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TileS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tiles (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tiles_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws horizontal tiles for surface specified parametrically @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. It is mostly the same as @ref{tile} but the size of tiles is determined by @var{r} array. This is some kind of ``transparency'' useful for exporting to EPS files. Tiles is plotted for each z slice of the data. See also @ref{surfa}, @ref{tile}. @sref{TileS sample} +@end deftypefn + +@anchor{map} +@deftypefn {MGL command} {} map udat vdat ['sch'=''] +@deftypefnx {MGL command} {} map xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Map (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Map (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_map (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_map_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws mapping plot for matrices @{@var{ax}, @var{ay} @} which parametrically depend on coordinates @var{x}, @var{y}. The initial position of the cell (point) is marked by color. Height is proportional to Jacobian(ax,ay). This plot is like Arnold diagram ??? If string @var{sch} contain symbol @samp{.} then the color ball at matrix knots are drawn otherwise face is drawn. @sref{Mapping visualization} +@end deftypefn + +@anchor{stfa} +@deftypefn {MGL command} {} stfa re im @code{dn} ['sch'=''] +@deftypefnx {MGL command} {} stfa xdat ydat re im @code{dn} ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} STFA (@code{const mglDataA &}re, @code{const mglDataA &}im, @code{int} dn, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} STFA (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}re, @code{const mglDataA &}im, @code{int} dn, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_stfa (@code{HMGL} gr, @code{HCDT} re, @code{HCDT} im, @code{int} dn, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_stfa_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} re, @code{HCDT} im, @code{int} dn, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Draws spectrogram of complex array @var{re}+i*@var{im} for Fourier size of @var{dn} points at plane @var{z}=@var{Min}.z. For example in 1D case, result is density plot of data @math{res[i,j]=|\sum_d^dn exp(I*j*d)*(re[i*dn+d]+I*im[i*dn+d])|/dn} with size @{int(nx/dn), dn, ny@}. At this array @var{re}, @var{im} parametrically depend on coordinates @var{x}, @var{y}. The size of @var{re} and @var{im} must be the same. The minor dimensions of arrays @var{x}, @var{y}, @var{re} should be equal. Arrays @var{x}, @var{y} can be vectors (not matrix as @var{re}). @sref{STFA sample} +@end deftypefn + + +@c ################################################################## +@external{} +@node Vector fields, Other plotting, Dual plotting, MathGL core +@section Vector fields +@nav{} +@cindex Traj +@cindex Vect +@cindex Dew +@cindex Flow +@cindex FlowP +@cindex Pipe + +These functions perform plotting of 2D and 3D vector fields. There are 5 generally different types of vector fields representations: simple vector field (Vect), vectors along the curve (Traj), vector field by dew-drops (Dew), flow threads (Flow, FlowP), flow pipes (Pipe). By default (if absent) values of @var{x}, @var{y}, @var{z} are equidistantly distributed in axis range. The minor dimensions of arrays @var{x}, @var{y}, @var{z}, @var{ax} should be equal. The size of @var{ax}, @var{ay} and @var{az} must be equal. Arrays @var{x}, @var{y}, @var{z} can be vectors (not matrices as @var{ax}). String @var{sch} sets the color scheme (see @ref{Color scheme}) for plot. String @var{opt} contain command options (see @ref{Command options}). + +@anchor{traj} +@deftypefn {MGL command} {} traj xdat ydat udat vdat ['sch'=''] +@deftypefnx {MGL command} {} traj xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Traj (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Traj (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_traj_xyz (@code{HMGL} gr, @code{HCDT}x, @code{HCDT}y, @code{HCDT}z, @code{HCDT}ax, @code{HCDT}ay, @code{HCDT}az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_traj_xy (@code{HMGL} gr, @code{HCDT}x, @code{HCDT}y, @code{HCDT}ax, @code{HCDT}ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws vectors @{@var{ax}, @var{ay}, @var{az}@} along a curve @{@var{x}, @var{y}, @var{z}@}. The length of arrows are proportional to @math{\sqrt@{ax^2+ay^2+az^2@}}. String @var{pen} specifies the color (see @ref{Line styles}). By default (@code{pen=""}) color from palette is used (see @ref{Palette and colors}). Option @code{value} set the vector length factor (if non-zero) or vector length to be proportional the distance between curve points (if @code{value=0}). The minor sizes of all arrays must be equal and large 2. The plots are drawn for each row if one of the data is the matrix. See also @ref{vect}. @sref{Traj sample} +@end deftypefn + +@anchor{vect} +@deftypefn {MGL command} {} vect udat vdat ['sch'=''] +@deftypefnx {MGL command} {} vect xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_vect_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_vect_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws plane vector field plot for the field @{@var{ax}, @var{ay}@} depending parametrically on coordinates @var{x}, @var{y} at level @var{z}=@var{Min}.z. The length and color of arrows are proportional to @math{\sqrt@{ax^2+ay^2@}}. The number of arrows depend on @ref{meshnum}. The appearance of the hachures (arrows) can be changed by symbols: +@itemize @bullet +@item +@samp{f} for drawing arrows with fixed lengths, +@item +@samp{>}, @samp{<} for drawing arrows to or from the cell point (default is centering), +@item +@samp{.} for drawing hachures with dots instead of arrows, +@item +@samp{=} for enabling color gradient along arrows. +@end itemize +See also @ref{flow}, @ref{dew}. @sref{Vect sample} +@end deftypefn + +@deftypefn {MGL command} {} vect udat vdat wdat ['sch'=''] +@deftypefnx {MGL command} {} vect xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_vect_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_vect_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +This is 3D version of the first functions. Here arrays @var{ax}, @var{ay}, @var{az} must be 3-ranged tensors with equal sizes and the length and color of arrows is proportional to @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + +@anchor{vect3} +@deftypefn {MGL command} {} vect3 udat vdat wdat ['sch'='' sval] +@deftypefnx {MGL command} {} vect3 xdat ydat zdat udat vdat wdat ['sch'='' sval] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect3 (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Vect3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_vect3 (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_vect3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +The function draws 3D vector field plot for the field @{@var{ax}, @var{ay}, @var{az}@} depending parametrically on coordinates @var{x}, @var{y}, @var{z}. Vector field is drawn at slice @var{sVal} in direction @{@samp{x}, @samp{y}, @samp{z}@} if @var{sch} contain corresponding symbol (by default, @samp{y} direction is used). The length and color of arrows are proportional to @math{\sqrt@{ax^2+ay^2+az^2@}}. The number of arrows depend on @ref{meshnum}. The appearance of the hachures (arrows) can be changed by symbols: +@itemize @bullet +@item +@samp{f} for drawing arrows with fixed lengths, +@item +@samp{>}, @samp{<} for drawing arrows to or from the cell point (default is centering), +@item +@samp{.} for drawing hachures with dots instead of arrows, +@item +@samp{=} for enabling color gradient along arrows. +@end itemize +See also @ref{vect}, @ref{flow}, @ref{dew}. @sref{Vect3 sample} +@end deftypefn + +@anchor{dew} +@deftypefn {MGL command} {} dew udat vdat ['sch'=''] +@deftypefnx {MGL command} {} dew xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Dew (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Dew (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_dew (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dew_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws dew-drops for plane vector field @{@var{ax}, @var{ay}@} depending parametrically on coordinates @var{x}, @var{y} at level @var{z}=@var{Min}.z. Note that this is very expensive plot in memory usage and creation time! The color of drops is proportional to @math{\sqrt@{ax^2+ay^2@}}. The number of drops depend on @ref{meshnum}. See also @ref{vect}. @sref{Dew sample} +@end deftypefn + +@anchor{flow} +@deftypefn {MGL command} {} flow udat vdat ['sch'=''] +@deftypefnx {MGL command} {} flow xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_flow_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_flow_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws flow threads for the plane vector field @{@var{ax}, @var{ay}@} parametrically depending on coordinates @var{x}, @var{y} at level @var{z} = @var{Min}.z. Number of threads is proportional to @code{value} option (default is 5). String @var{sch} may contain: +@itemize @bullet +@item +color scheme -- up-half (warm) corresponds to normal flow (like attractor), bottom-half (cold) corresponds to inverse flow (like source); +@item +@samp{#} for starting threads from edges only; +@item +@samp{v} for drawing arrows on the threads; +@item +@samp{x}, @samp{z} for drawing tapes of normals in x-y and y-z planes correspondingly. +@end itemize +See also @ref{pipe}, @ref{vect}, @ref{tape}, @ref{barwidth}. @sref{Flow sample} +@end deftypefn + +@deftypefn {MGL command} {} flow udat vdat wdat ['sch'=''] +@deftypefnx {MGL command} {} flow xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_flow_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_flow_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +This is 3D version of the first functions. Here arrays @var{ax}, @var{ay}, @var{az} must be 3-ranged tensors with equal sizes and the color of line is proportional to @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + +@deftypefn {MGL command} {} flow @code{x0 y0} udat vdat ['sch'=''] +@deftypefnx {MGL command} {} flow @code{x0 y0} xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_flowp_2d (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_flowp_xy (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The same as first one (@ref{flow}) but draws single flow thread starting from point @var{p0}=@{@var{x0},@var{y0},@var{z0}@}. +@end deftypefn + +@deftypefn {MGL command} {} flow @code{x0 y0 z0} udat vdat wdat ['sch'=''] +@deftypefnx {MGL command} {} flow @code{x0 y0 z0} xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_flowp_3d (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_flowp_xyz (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +This is 3D version of the previous functions. +@end deftypefn + +@anchor{grad} +@deftypefn {MGL command} {} grad pdat ['sch'=''] +@deftypefnx {MGL command} {} grad xdat ydat pdat ['sch'=''] +@deftypefnx {MGL command} {} grad xdat ydat zdat pdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_grad (@code{HMGL} gr, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_grad_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_grad_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws gradient lines for scalar field @var{phi}[i,j] (or @var{phi}[i,j,k] in 3d case) specified parametrically @{@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]@}. Number of lines is proportional to @code{value} option (default is 5). See also @ref{dens}, @ref{cont}, @ref{flow}. +@end deftypefn + +@anchor{pipe} +@deftypefn {MGL command} {} pipe udat vdat ['sch'='' @code{r0=0.05}] +@deftypefnx {MGL command} {} pipe xdat ydat udat vdat ['sch'='' @code{r0=0.05}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_pipe_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_pipe_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@end ifclear +The function draws flow pipes for the plane vector field @{@var{ax}, @var{ay}@} parametrically depending on coordinates @var{x}, @var{y} at level @var{z} = @var{Min}.z. Number of pipes is proportional to @code{value} option (default is 5). If @samp{#} symbol is specified then pipes start only from edges of axis range. The color of lines is proportional to @math{\sqrt@{ax^2+ay^2@}}. Warm color corresponds to normal flow (like attractor). Cold one corresponds to inverse flow (like source). Parameter @var{r0} set the base pipe radius. If @var{r0}<0 or symbol @samp{i} is specified then pipe radius is inverse proportional to amplitude. The vector field is plotted for each z slice of @var{ax}, @var{ay}. See also @ref{flow}, @ref{vect}. @sref{Pipe sample} +@end deftypefn + +@deftypefn {MGL command} {} pipe udat vdat wdat ['sch'='' @code{r0=0.05}] +@deftypefnx {MGL command} {} pipe xdat ydat zdat udat vdat wdat ['sch'='' @code{r0=0.05}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_pipe_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_pipe_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@end ifclear +This is 3D version of the first functions. Here arrays @var{ax}, @var{ay}, @var{az} must be 3-ranged tensors with equal sizes and the color of line is proportional to @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + + +@c ################################################################## +@external{} +@node Other plotting, Nonlinear fitting, Vector fields, MathGL core +@section Other plotting +@nav{} +@cindex DensXYZ +@cindex ContXYZ +@cindex ContFXYZ +@cindex Dots +@cindex Crust +@cindex TriPlot +@cindex TriCont +@cindex QuadPlot +@cindex FPlot +@cindex FSurf + +These functions perform miscellaneous plotting. There is unstructured data points plots (Dots), surface reconstruction (Crust), surfaces on the triangular or quadrangular mesh (TriPlot, TriCont, QuadPlot), textual formula plotting (Plots by formula), data plots at edges (Dens[XYZ], Cont[XYZ], ContF[XYZ]). Each type of plotting has similar interface. There are 2 kind of versions which handle the arrays of data and coordinates or only single data array. Parameters of color scheme are specified by the string argument. @xref{Color scheme}. + +@anchor{densz} @anchor{densy} @anchor{densx} @anchor{DensXYZ} +@deftypefn {MGL command} {} densx dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} densy dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} densz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} DensX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} DensY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} DensZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_dens_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dens_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dens_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +These plotting functions draw density plot in x, y, or z plain. If @var{a} is a tensor (3-dimensional data) then interpolation to a given @var{sVal} is performed. These functions are useful for creating projections of the 3D data array to the bounding box. See also @ref{ContXYZ}, @ref{ContFXYZ}, @ref{dens}, @ref{Data manipulation}. @sref{Dens projection sample} +@end deftypefn + +@anchor{contz} @anchor{conty} @anchor{contx} @anchor{ContXYZ} +@deftypefn {MGL command} {} contx dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} conty dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} contz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +These plotting functions draw contour lines in x, y, or z plain. If @var{a} is a tensor (3-dimensional data) then interpolation to a given @var{sVal} is performed. These functions are useful for creating projections of the 3D data array to the bounding box. Option @code{value} set the number of contours. See also @ref{ContFXYZ}, @ref{DensXYZ}, @ref{cont}, @ref{Data manipulation}. @sref{Cont projection sample} +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} ContX (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContY (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContZ (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_cont_x_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_y_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_cont_z_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +The same as previous with manual contour levels. +@end deftypefn +@end ifclear + +@anchor{contfz} @anchor{contfy} @anchor{contfx} @anchor{ContFXYZ} +@deftypefn {MGL command} {} contfx dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} contfy dat ['sch'='' @code{sval=nan}] +@deftypefnx {MGL command} {} contfz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} ContFX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContFY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContFZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +These plotting functions draw solid contours in x, y, or z plain. If @var{a} is a tensor (3-dimensional data) then interpolation to a given @var{sVal} is performed. These functions are useful for creating projections of the 3D data array to the bounding box. Option @code{value} set the number of contours. See also @ref{ContFXYZ}, @ref{DensXYZ}, @ref{cont}, @ref{Data manipulation}. @sref{ContF projection sample} +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{void} ContFX (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContFY (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} ContFZ (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_contf_x_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_y_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_contf_z_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +The same as previous with manual contour levels. +@end deftypefn +@end ifclear + +@anchor{fplot} +@deftypefn {MGL command} {} fplot 'y(x)' ['pen'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FPlot (@code{const char *}eqY, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_fplot (@code{HMGL} gr, @code{const char *}eqY, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Draws command function @samp{y(x)} at plane @var{z}=@var{Min}.z where @samp{x} variable is changed in @code{xrange}. You do not need to create the data arrays to plot it. Option @code{value} set initial number of points. See also @ref{plot}. +@end deftypefn + +@deftypefn {MGL command} {} fplot 'x(t)' 'y(t)' 'z(t)' ['pen'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FPlot (@code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}pen, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_fplot_xyz (@code{HMGL} gr, @code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Draws command parametrical curve @{@samp{x(t)}, @samp{y(t)}, @samp{z(t)}@} where @samp{t} variable is changed in range [0, 1]. You do not need to create the data arrays to plot it. Option @code{value} set number of points. See also @ref{plot}. +@end deftypefn + +@anchor{fsurf} +@deftypefn {MGL command} {} fsurf 'z(x,y)' ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FSurf (@code{const char *}eqZ, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}); +@deftypefnx {C function} @code{void} mgl_fsurf (@code{HMGL} gr, @code{const char *}eqZ, @code{const char *}sch, @code{const char *}opt); +@end ifclear +Draws command surface for function @samp{z(x,y)} where @samp{x}, @samp{y} variable are changed in @code{xrange, yrange}. You do not need to create the data arrays to plot it. Option @code{value} set number of points. See also @ref{surf}. +@end deftypefn + +@deftypefn {MGL command} {} fsurf 'x(u,v)' 'y(u,v)' 'z(u,v)' ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} FSurf (@code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_fsurf_xyz (@code{HMGL} gr, @code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Draws command parametrical surface @{@samp{x(u,v)}, @samp{y(u,v)}, @samp{z(u,v)}@} where @samp{u}, @samp{v} variable are changed in range [0, 1]. You do not need to create the data arrays to plot it. Option @code{value} set number of points. See also @ref{surf}. +@end deftypefn + +@anchor{triplot} +@deftypefn {MGL command} {} triplot idat xdat ydat ['sch'=''] +@deftypefnx {MGL command} {} triplot idat xdat ydat zdat ['sch'=''] +@deftypefnx {MGL command} {} triplot idat xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_triplot_xy (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_triplot_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_triplot_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws the surface of triangles. Triangle vertexes are set by indexes @var{id} of data points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. String @var{sch} sets the color scheme. If string contain @samp{#} then wire plot is produced. First dimensions of @var{id} must be 3 or greater. Arrays @var{x}, @var{y}, @var{z} must have equal sizes. Parameter @var{c} set the colors of triangles (if @var{id}.ny=@var{c}.nx) or colors of vertexes (if @var{x}.nx=@var{c}.nx). See also @ref{dots}, @ref{crust}, @ref{quadplot}, @ref{triangulation}. @sref{TriPlot and QuadPlot} +@end deftypefn + +@anchor{tricont} +@deftypefn {MGL command} {} tricont vdat idat xdat ydat zdat cdat ['sch'=''] +@deftypefnx {MGL command} {} tricont vdat idat xdat ydat zdat ['sch'=''] +@deftypefnx {MGL command} {} tricont idat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} TriCont (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TriCont (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TriContV (@code{const mglDataA &}v, @code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} TriContV (@code{const mglDataA &}v, @code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_tricont_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tricont_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tricont_xyzcv (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_tricont_xyzv (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws contour lines for surface of triangles at @var{z}=@var{v}[k] (or at @var{z} = @var{Min}.z if @var{sch} contain symbol @samp{_}). Triangle vertexes are set by indexes @var{id} of data points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Contours are plotted for @var{z}[i,j]=@var{v}[k] where @var{v}[k] are values of data array @var{v}. If @var{v} is absent then arrays of option @code{value} elements equidistantly distributed in color range is used. String @var{sch} sets the color scheme. Array @var{c} (if specified) is used for contour coloring. First dimensions of @var{id} must be 3 or greater. Arrays @var{x}, @var{y}, @var{z} must have equal sizes. Parameter @var{c} set the colors of triangles (if @var{id}.ny=@var{c}.nx) or colors of vertexes (if @var{x}.nx=@var{c}.nx). See also @ref{triplot}, @ref{cont}, @ref{triangulation}. +@end deftypefn + +@anchor{quadplot} +@deftypefn {MGL command} {} quadplot idat xdat ydat ['sch'=''] +@deftypefnx {MGL command} {} quadplot idat xdat ydat zdat ['sch'=''] +@deftypefnx {MGL command} {} quadplot idat xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_quadplot_xy (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_quadplot_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_quadplot_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws the surface of quadrangles. Quadrangles vertexes are set by indexes @var{id} of data points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. String @var{sch} sets the color scheme. If string contain @samp{#} then wire plot is produced. First dimensions of @var{id} must be 4 or greater. Arrays @var{x}, @var{y}, @var{z} must have equal sizes. Parameter @var{c} set the colors of quadrangles (if @var{id}.ny=@var{c}.nx) or colors of vertexes (if @var{x}.nx=@var{c}.nx). See also @ref{triplot}. @sref{TriPlot and QuadPlot} +@end deftypefn + +@anchor{dots} +@deftypefn {MGL command} {} dots xdat ydat zdat ['sch'=''] +@deftypefnx {MGL command} {} dots xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_dots (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dots_a (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_dots_ca (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function draws the arbitrary placed points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. String @var{sch} sets the color scheme and kind of marks. If arrays @var{c}, @var{a} are specified then they define colors and transparencies of dots. You can use @ref{tens} plot with style @samp{ .} to draw non-transparent dots with specified colors. Arrays @var{x}, @var{y}, @var{z}, @var{a} must have equal sizes. See also @ref{crust}, @ref{tens}, @ref{mark}, @ref{plot}. @sref{Dots sample} +@end deftypefn + +@anchor{crust} +@deftypefn {MGL command} {} crust xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Crust (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_crust (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +The function reconstruct and draws the surface for arbitrary placed points @{@var{x}[i], @var{y}[i], @var{z}[i]@}. String @var{sch} sets the color scheme. If string contain @samp{#} then wire plot is produced. Arrays @var{x}, @var{y}, @var{z} must have equal sizes. See also @ref{dots}, @ref{triplot}. @c @sref{Crust sample} +@end deftypefn + +@c ################################################################## +@external{} +@node Nonlinear fitting, Data manipulation, Other plotting, MathGL core +@section Nonlinear fitting +@nav{} +@cindex Fit +@cindex FitS +@cindex PutsFit +@cindex mglFitPnts +@cindex Fit2 +@cindex Fit3 + +These functions fit data to formula. Fitting goal is to find formula parameters for the best fit the data points, i.e. to minimize the sum @math{\sum_i (f(x_i, y_i, z_i) - a_i)^2/s_i^2}. At this, approximation function @samp{f} can depend only on one argument @samp{x} (1D case), on two arguments @samp{x,y} (2D case) and on three arguments @samp{x,y,z} (3D case). The function @samp{f} also may depend on parameters. Normally the list of fitted parameters is specified by @var{var} string (like, @samp{abcd}). Usually user should supply initial values for fitted parameters by @var{ini} variable. But if he/she don't supply it then the zeros are used. Parameter @var{print}=@code{true} switch on printing the found coefficients to @var{Message} (see @ref{Error handling}). + +Functions Fit() and FitS() do not draw the obtained data themselves. They fill the data @var{fit} by formula @samp{f} with found coefficients and return it. At this, the @samp{x,y,z} coordinates are equidistantly distributed in the axis range. Number of points in @var{fit} is defined by option @code{value} (default is @var{mglFitPnts}=100). Note, that this functions use GSL library and do something only if MathGL was compiled with GSL support. @sref{Nonlinear fitting hints} + +@anchor{fits} +@deftypefn {MGL command} {} fits res adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fits res xdat adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fits res xdat ydat adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fits res xdat ydat zdat adat sdat 'func' 'var' [ini=0] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_fit_ys (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xys (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xyzs (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xyzas (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@end ifclear +Fit data along x-, y- and z-directions for array specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) with weight factor @var{s}[i,j,k]. +@end deftypefn + +@anchor{fit} +@deftypefn {MGL command} {} fit res adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fit res xdat adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fit res xdat ydat adat sdat 'func' 'var' [ini=0] +@deftypefnx {MGL command} {} fit res xdat ydat zdat adat sdat 'func' 'var' [ini=0] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_fit_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_xyza (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@end ifclear +Fit data along x-, y- and z-directions for array specified parametrically @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) with weight factor 1. +@end deftypefn + + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{mglData} Fit2 (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit2 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit3 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Fit3 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_fit_2 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_fit_3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +Fit data along all directions for 2d or 3d arrays @var{a} with @var{s}=1 and @var{x}, @var{y}, @var{z} equidistantly distributed in interval [@var{Min}, @var{Max}]. +@end deftypefn +@end ifclear + +@anchor{putsfit} +@deftypefn {MGL command} {} putsfit @code{x y} ['pre'='' 'fnt'='' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} PutsFit (@code{mglPoint} p, @code{const char *}prefix=@code{""}, @code{const char *}font=@code{""}, @code{mreal} size=@code{-1}) +@deftypefnx {C function} @code{void} mgl_puts_fit (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}prefix, @code{const char *}font, @code{mreal} size) +@end ifclear +Print last fitted formula with found coefficients (as numbers) at position @var{p0}. The string @var{prefix} will be printed before formula. All other parameters are the same as in @ref{Text printing}. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglGraph}} @code{const char *}GetFit () +@deftypefnx {C function} @code{const char *} mgl_get_fit (@code{HMGL} gr) +Get last fitted formula with found coefficients (as numbers). +@end deftypefn +@end ifclear + + +@c ################################################################## +@external{} +@node Data manipulation, , Nonlinear fitting, MathGL core +@section Data manipulation +@nav{} +@cindex Hist +@cindex Fill +@cindex DataGrid + +@deftypefn {MGL command} {} hist @sc{res} xdat adat +@deftypefnx {MGL command} {} hist @sc{res} xdat ydat adat +@deftypefnx {MGL command} {} hist @sc{res} xdat ydat zdat adat +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_hist_x (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_hist_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{const char *}opt) +@deftypefnx {C function} @code{HMDT} mgl_hist_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}opt) +@end ifclear +These functions make distribution (histogram) of data. They do not draw the obtained data themselves. These functions can be useful if user have data defined for random points (for example, after PIC simulation) and he want to produce a plot which require regular data (defined on grid(s)). The range for grids is always selected as axis range. Arrays @var{x}, @var{y}, @var{z} define the positions (coordinates) of random points. Array @var{a} define the data value. Number of points in output array @var{res} is defined by option @code{value} (default is @var{mglFitPnts}=100). +@end deftypefn + + +@deftypefn {MGL command} {} fill dat 'eq' +@deftypefnx {MGL command} {} fill dat 'eq' vdat +@deftypefnx {MGL command} {} fill dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_data_fill_eq (@code{HMGL} gr, @code{HMDT} u, @code{const char *}eq, @code{HCDT}v, @code{HCDT}w, @code{const char *}opt) +@end ifclear +Fills the value of array @samp{u} according to the formula in string @var{eq}. Formula is an arbitrary expression depending on variables @samp{x}, @samp{y}, @samp{z}, @samp{u}, @samp{v}, @samp{w}. Coordinates @samp{x}, @samp{y}, @samp{z} are supposed to be normalized in axis range. Variable @samp{u} is the original value of the array. Variables @samp{v} and @samp{w} are values of arrays @var{v}, @var{w} which can be @code{NULL} (i.e. can be omitted). +@end deftypefn + +@deftypefn {MGL command} {} datagrid dat xdat ydat zdat +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{void} DataGrid (@code{mglData &}u, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_data_grid (@code{HMGL} gr, @code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}opt) +@end ifclear +Fills the value of array @samp{u} according to the linear interpolation of triangulated surface, found for arbitrary placed points @samp{x}, @samp{y}, @samp{z}. Interpolation is done at points equidistantly distributed in axis range. NAN value is used for grid points placed outside of triangulated surface. @sref{Making regular data} +@end deftypefn + +@deftypefn {MGL command} {} refill dat xdat vdat [sl=-1] +@deftypefnx {MGL command} {} refill dat xdat ydat vdat [sl=-1] +@deftypefnx {MGL command} {} refill dat xdat ydat zdat vdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_data_refill_gr (@code{HMGL} gr, @code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{long} sl, @code{const char *}opt) +@end ifclear +Fills by interpolated values of array @var{v} at the point @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i], Y[j], Z[k]}@} (or @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i,j,k], Y[i,j,k], Z[i,j,k]}@} if @var{x}, @var{y}, @var{z} are not 1d arrays), where @code{X,Y,Z} are equidistantly distributed in axis range and have the same sizes as array @var{dat}. If parameter @var{sl} is 0 or positive then changes will be applied only for slice @var{sl}. +@end deftypefn + + +@deftypefn {MGL command} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}] +@ifclear UDAV +@deftypefnx {Method on @code{mglGraph}} @code{mglData} PDE (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{mreal} dz=@code{0.1}, @code{mreal} k0=@code{100}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_pde_solve (@code{HMGL} gr, @code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{mreal} dz, @code{mreal} k0, @code{const char *}opt) +@end ifclear +Solves equation du/dz = i*k0*@var{ham}(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters @var{ini_re}, @var{ini_im} specify real and imaginary part of initial field distribution. Coordinates @samp{x}, @samp{y}, @samp{z} are supposed to be normalized in axis range. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter @var{dz} set the step along evolutionary coordinate z. At this moment, simplified form of function @var{ham} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this function is effectively @math{ham = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed. Here variable @samp{u} is used for field amplitude |u|. This allow one solve nonlinear problems -- for example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. You may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{ham = hre+i*him}). @sref{PDE solving hints} +@end deftypefn + +@c ################################################################## +@c @external{} +@c @node IDTF functions, , Data manipulation, MathGL core +@c @section IDTF functions +@c @nav{} + +@c These functions provide IDTF specific features. In all other cases they do nothing. + +@c @ifclear UDAV + +@c @deftypefn {Method on @code{mglGraph}} @code{void} VertexColor (@code{bool} enable) +@c Enables smooth color change. +@c @end deftypefn + +@c @deftypefn {Method on @code{mglGraph}} @code{void} Compression (@code{bool} enable) +@c Gives smaller files, but quality degrades. +@c @end deftypefn + +@c inline void DoubleSided(bool){} // NOTE: Add later -- IDTF +@c inline void TextureColor(bool){} // NOTE: Add later -- IDTF + +@c @end ifclear + +@external{} diff --git a/texinfo/core_ru.texi b/texinfo/core_ru.texi new file mode 100644 index 0000000..6405d92 --- /dev/null +++ b/texinfo/core_ru.texi @@ -0,0 +1,3223 @@ +@c ------------------------------------------------------------------ +@chapter Ядро MathGL +@nav{} +@cindex mglGraph + +@ifset UDAV +Эта глава посвящена описанию множества команд построения графиков для 1D, 2D и 3D массивов данных. Сюда включены также команды настройки графика, вывода текста и примитивов, рисования осей координат и др. Дополнительную информацию о цвете, шрифтах, стилях линий и формулах можно найти в @ref{General concepts}. +@end ifset + +@ifclear UDAV +Основным классом MathGL является класс @strong{mglGraph}, определённый в @code{#include }. Он включает в себя множество функций для построения графиков от 1D, 2D и 3D массивов. Он также содержит функции вывода текста и построения осей координат. Есть возможность построения в произвольной системе координат, которая задается строковыми формулами. Все графические функции используют класс mglData (см. @ref{Data processing}) для хранения массивов данных. Это позволяет легко контролировать размеры, работу с памятью и производить обработку данных. Дополнительная информация о цветах, шрифтах, вычисления формул может быть найдена в @ref{General concepts} и @ref{Other classes}. +@end ifclear + +@menu +* Constructor:: +* Graphics setup:: +* Axis settings:: +* Subplots and rotation:: +* Export picture:: +* Primitives:: +* Text printing:: +* Axis and Colorbar:: +* Legend:: +* 1D plotting:: +* 2D plotting:: +* 3D plotting:: +* Dual plotting:: +* Vector fields:: +* Other plotting:: +* Nonlinear fitting:: +* Data manipulation:: +@c * IDTF functions:: +@end menu + +@c ################################################################## +@external{} +@node Constructor, Graphics setup, , MathGL core +@section Создание и удаление графического объекта +@nav{} + +@ifclear UDAV +@deftypefn {Конструктор класса @code{mglGraph}} {} mglGraph (@code{int} kind=@code{0}, @code{int} width=@code{600}, @code{int} height=@code{400}) +@deftypefnx {Конструктор класса @code{mglGraph}} {} mglGraph (@code{const mglGraph &}gr) +@deftypefnx {Конструктор класса @code{mglGraph}} {} mglGraph (@code{HMGL} gr) +@deftypefnx {Функция С} @code{HMGL} mgl_create_graph (@code{int} width, @code{int} height) +@deftypefnx {Функция С} @code{HMGL} mgl_create_graph_gl () +Создает (или использует созданный) экземпляр класса, производного от @code{mglGraph} (тип @code{HMGL}) с указанными размерами @var{width} и @var{height}. Параметр @var{kind} может иметь следующие значения: @samp{0} -- использовать рисование по умолчанию, @samp{1} -- использовать рисование в OpenGL. +@end deftypefn + +@deftypefn {Destructor on @code{mglGraph}} {} ~mglGraph () +@deftypefnx {Функция С} @code{HMGL} mgl_delete_graph (@code{HMGL} gr) +Удаляет экземпляр класса mglGraph. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{HMGL} Self () +Возвращает указатель на используемый объект типа @code{HMGL}. +@end deftypefn +@end ifclear + +@ifset UDAV +MGL не требует создания данного типа объектов. +@end ifset + +@c ################################################################## +@external{} +@node Graphics setup, Axis settings, Constructor, MathGL core +@section Настройка графика +@nav{} +@cindex Настройка MathGL + +Функции и переменные в этой группе влияют на вид всего рисунка. Соответственно они должны располагаться @emph{перед} вызовом функций непосредственно рисующих графики. + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} DefaultPlotParam () +@deftypefnx {Функция С} @code{void} mgl_set_def_param (@code{HMGL} gr) +Устанавливает все настройки по умолчанию. +@end deftypefn +@end ifclear + +@menu +* Transparency:: +* Lighting:: +* Fog:: +* Default sizes:: +* Cutting:: +* Font settings:: +* Palette and colors:: +* Masks:: +* Error handling:: +@end menu + +@c ================================================================== +@external{} +@node Transparency, Lighting, , Graphics setup +@subsection Прозрачность +@nav{} +@cindex Alpha +@ifclear UDAV +@cindex SetAlphaDef +@cindex SetTranspType +@end ifclear +@cindex AlphaDef +@cindex TranspType + +Эти функции и переменные настраивают тип и степень прозрачности поверхностей. Главной является функция @ref{alpha}, которая включает/выключает прозрачность для всего графика. Функция @ref{alphadef} устанавливает величину alpha-канала по умолчанию. Наконец, функция @ref{transptype} задает тип прозрачности. @sref{Transparency and lighting} + +@anchor{alpha} +@deftypefn {Команда MGL} {} alpha @code{[val=on]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Alpha (@code{bool} enable) +@deftypefnx {Функция С} @code{void} mgl_set_alpha (@code{HMGL} gr, @code{int} enable) +@end ifclear +Включает/выключает прозрачность и возвращает свое предыдущее состояние. По умолчанию прозрачность выключена. Функция включает прозрачность для @emph{всего} рисунка. +@end deftypefn + +@anchor{alphadef} +@deftypefn {Команда MGL} {} alphadef @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetAlphaDef (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_alpha_default (@code{HMGL} gr, @code{mreal} alpha) +@end ifclear +Задает значение прозрачности по умолчанию для всех графиков. Значение по умолчанию 0.5. +@end deftypefn + +@anchor{transptype} +@deftypefn {Команда MGL} {} transptype @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetTranspType (@code{int} type) +@deftypefnx {Функция С} @code{void} mgl_set_transp_type (@code{HMGL} gr, @code{int} type) +@end ifclear +Задает тип прозрачности. Обычная прозрачность (@samp{0}) -- "закрытые" объекты видны меньше чем закрывающие. Этот режим некорректно отображается в OpenGL (mglGraphGL) для нескольких перекрывающихся поверхностей. "Стеклянная" прозрачность (@samp{1}) -- закрытые и закрывающие объекты единообразно ослабляют интенсивность света (по RGB каналам). "Ламповая" прозрачность (@samp{2}) -- закрытые и закрывающие объекты являются источниками дополнительного освещения (рекомендую установить @code{SetAlphaDef(0.3)} или меньше в этом случае). @sref{Types of transparency} +@end deftypefn + +@c ================================================================== +@external{} +@node Lighting, Fog, Transparency, Graphics setup +@subsection Освещение +@nav{} +@ifclear UDAV +@cindex SetAmbient +@cindex AddLight +@end ifclear +@cindex Light +@cindex Ambient + +Эти функции настраивают освещение графика. Главная функция @ref{light} включает/выключает освещение графиков построенных после ее вызова (в OpenGL работает сразу для всего рисунка). MathGL поддерживает до 10 независимых источников света. Но в режиме OpenGL можно использовать только первые 8 из них. Положение, цвет, яркость каждого источника света можно задавать по отдельности. По умолчанию включен только первый (с порядковым номером @code{0}) источник света белого цвета, расположенный сверху. + +@anchor{light} +@deftypefn {Команда MGL} {} light @code{[val=on]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{bool} Light (@code{bool} enable) +@deftypefnx {Функция С} @code{void} mgl_set_light (@code{HMGL} gr, @code{int} enable) +@end ifclear +Включает/выключает освещение графика и возвращает предыдущее состояние. По умолчанию освещение выключено. +@end deftypefn + +@deftypefn {Команда MGL} {} light @code{num} @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Light (@code{int} n, @code{bool} enable) +@deftypefnx {Функция С} @code{void} mgl_set_light_n (@code{HMGL} gr, @code{int} n, @code{int} enable) +@end ifclear +Включает/выключает @var{n}-ый источник света. +@end deftypefn + +@deftypefn {Команда MGL} {} light @code{num xdir ydir zdir} ['col'='w' @code{br=0.5}] +@deftypefnx {Команда MGL} {} light @code{num xdir ydir zdir xpos ypos zpos} ['col'='w' @code{br=0.5}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} AddLight (@code{int} n, @code{mglPoint} d, @code{char} c=@code{'w'}, @code{mreal} bright=@code{0.5}, @code{mreal} ap=@code{0}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} AddLight (@code{int} n, @code{mglPoint} r, @code{mglPoint} d, @code{char} c=@code{'w'}, @code{mreal} bright=@code{0.5}, @code{mreal} ap=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_add_light (@code{HMGL} gr, @code{int} n, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz) +@deftypefnx {Функция С} @code{void} mgl_add_light_ext (@code{HMGL} gr, @code{int} n, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{char} c, @code{mreal} bright, @code{mreal} ap) +@deftypefnx {Функция С} @code{void} mgl_add_light_loc (@code{HMGL} gr, @code{int} n, @code{mreal} rx, @code{mreal} ry, @code{mreal} rz, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{char} c, @code{mreal} bright, @code{mreal} ap) +@end ifclear +Добавляет источник света с номером @var{n} в положение @var{p} с цветом @var{c} и яркостью @var{bright}, которая должна быть в диапазоне [0,1]. Если указано положение источника @var{r} и оно не NAN, то источник считается локальным, иначе источник полагается бесконечно удалённым (для более быстрого рисования). +@end deftypefn + +@anchor{diffuse} +@deftypefn {Команда MGL} {} diffuse @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetDifLight (@code{mreal} bright) +@deftypefnx {Функция С} @code{void} mgl_set_difbr (@code{HMGL} gr, @code{mreal} bright) +@end ifclear +Задает яркость диффузного освещения (только для локальных источников света). +@end deftypefn + +@anchor{ambient} +@deftypefn {Команда MGL} {} ambient @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetAmbient (@code{mreal} bright=@code{0.5}) +@deftypefnx {Функция С} @code{void} mgl_set_ambbr (@code{HMGL} gr, @code{mreal} bright) +@end ifclear +Задает яркость рассеянного освещения. Значение должно быть в диапазоне [0,1]. +@end deftypefn + +@c ================================================================== +@external{} +@node Fog, Default sizes, Lighting, Graphics setup +@subsection Туман +@nav{} +@cindex Fog + +@anchor{fog} +@deftypefn {Команда MGL} {} fog @code{val [dz=0.25]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fog (@code{mreal} d, @code{mreal} dz=@code{0.25}) +@deftypefnx {Функция С} @code{void} mgl_set_fog (@code{HMGL} gr, @code{mreal} d, @code{mreal} dz) +@end ifclear +Имитирует туман на графике. Туман начинается на относительном расстоянии @var{dz} от точки обзора и его плотность растет экспоненциально вглубь по закону ~ 1-exp(-@emph{d*z}). Здесь @emph{z} -- нормализованная на 1 глубина графика. Если @var{d}=@code{0} то туман отсутствует. @sref{Adding fog} +@end deftypefn + +@c ================================================================== +@external{} +@node Default sizes, Cutting, Fog, Graphics setup +@subsection Базовые размеры +@nav{} +@ifclear UDAV +@cindex SetBarWidth +@cindex SetMarkSize +@cindex SetArrowSize +@cindex SetMeshNum +@cindex SetPlotId +@end ifclear +@cindex BarWidth +@cindex MarkSize +@cindex ArrowSize +@cindex MeshNum + +Эти функции задают величины большинства параметров графика, включая размеры маркеров, стрелок, толщину линий и т.д. Как и любые другие настройки, они подействуют только на графики созданные после изменения настроек. + +@anchor{barwidth} +@deftypefn {Команда MGL} {} barwidth @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetBarWidth ( @code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_bar_width (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Задает относительный размер прямоугольников в @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{candle}. Значение по умолчанию @code{0.7}. +@end deftypefn + +@anchor{marksize} +@deftypefn {Команда MGL} {} marksize @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetMarkSize (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_mark_size (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Задает размер маркеров для @ref{1D plotting}. Значение по умолчанию @code{1}. +@end deftypefn + +@anchor{arrowsize} +@deftypefn {Команда MGL} {} arrowsize @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetArrowSize (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_arrow_size (@code{HMGL} gr, @code{mreal} val) +@end ifclear +Задает размер стрелок для @ref{1D plotting}, линий и кривых (см. @ref{Primitives}). Значение по умолчанию @code{1}. +@end deftypefn + +@anchor{meshnum} +@anchor{MeshNum} +@deftypefn {Команда MGL} {} meshnum @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetMeshNum (@code{int} val) +@deftypefnx {Функция С} @code{void} mgl_set_meshnum (@code{HMGL} gr, @code{int} num) +@end ifclear +Задает ориентировочное число линий в @ref{mesh}, @ref{fall}, @ref{grid} и число стрелок (штрихов) в @ref{vect}, @ref{dew} и число ячеек в @ref{cloud}. По умолчанию (=0) рисуются все линии, стрелки, ячейки. +@end deftypefn + +@anchor{facenum} +@deftypefn {Команда MGL} {} facenum @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetFaceNum (@code{int} val) +@deftypefnx {Функция С} @code{void} mgl_set_facenum (@code{HMGL} gr, @code{int} num) +@end ifclear +Задает ориентировочное число видимых граней. Может быть использована для ускорения рисования за счет более грубого рисунка. По умолчанию (=0) рисуются все грани. +@end deftypefn + +@anchor{plotid} +@deftypefn {Команда MGL} {} plotid 'id' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetPlotId (@code{const char *}id) +@deftypefnx {Функция С} @code{void} mgl_set_plotid (@code{HMGL} gr, @code{const char *}id) +@end ifclear +Задает имя графика для сохранения в файл (например, в окне FLTK). +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{const char *} GetPlotId () +@deftypefnx {Функция С} @code{const char *} mgl_get_plotid (@code{HMGL} gr) +Возвращает имя графика для сохранения в файл (например, в окне FLTK). +@end deftypefn +@end ifclear + +@c ================================================================== +@external{} +@node Cutting, Font settings, Default sizes, Graphics setup +@subsection Обрезание +@nav{} +@ifclear UDAV +@cindex SetCut +@cindex SetCutBox +@cindex CutOff +@end ifclear +@cindex Cut + +Эти функции задают условия когда точка будет исключена (вырезана) из рисования. Замечу, что все точки со значением(-ями) NAN по одной из координат или амплитуде автоматически исключаются из рисования. @sref{Cutting sample} + +@anchor{cut} +@deftypefn {Команда MGL} {} cut @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetCut (@code{bool} val) +@deftypefnx {Функция С} @code{void} mgl_set_cut (@code{HMGL} gr, @code{int} val) +@end ifclear +Задает обрезание точек за пределами осей координат. Если @code{true} то такие точки исключаются из рисования (это по умолчанию) иначе они проецируются на ограничивающий прямоугольник. +@end deftypefn + +@deftypefn {Команда MGL} {} cut @code{x1 y1 z1 x2 y2 z2} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetCutBox (@code{mglPoint} p1, @code{mglPoint} p1) +@deftypefnx {Функция С} @code{void} mgl_set_cut_box (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2) +@end ifclear +Задает границы параллелепипеда внутри которого точки не рисуются. Если границы одинаковы (переменные равны), то параллелепипеда считается пустым. +@end deftypefn + +@deftypefn {Команда MGL} {} cut 'cond' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} CutOff (@code{const char *}cond) +@deftypefnx {Функция С} @code{void} mgl_set_cutoff (@code{HMGL} gr, @code{const char *}cond) +@end ifclear +Задает условие обрезания по формуле @var{cond}. Это условие исключает точки из рисования если результат вычисления формулы не равен нулю. Установите аргумент @code{""} для выключения условия обрезания. +@end deftypefn + +@c ================================================================== +@external{} +@node Font settings, Palette and colors, Cutting, Graphics setup +@subsection Шрифты +@nav{} +@ifclear UDAV +@cindex SetFontSize +@cindex SetFontDef +@cindex SetRotatedText +@cindex SetFontSizePT +@cindex SetFontSizeCM +@cindex SetFontSizeIN +@cindex LoadFont +@cindex CopyFont +@cindex RestoreFont +@end ifclear +@cindex Font +@cindex RotateText + +@anchor{font} +@deftypefn {Команда MGL} {} font 'fnt' [@code{val=6}] +Задает стиль и размер шрифта. Вначале используется @samp{:rC} -- прямой шрифт с выравниванием по центру. По умолчанию размер подписей оси координат в 1.4 раза больше. См. также см. @ref{Font styles}. +@end deftypefn + +@anchor{rotatetext} +@deftypefn {Команда MGL} {} rotatetext @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRotatedText (@code{bool} val) +@deftypefnx {Функция С} @code{void} mgl_set_rotated_text (@code{HMGL} gr, @code{int} val) +@end ifclear +Включает/выключает вращение меток и подписей осей координат вдоль оси. +@end deftypefn + +@anchor{loadfont} +@deftypefn {Команда MGL} {} loadfont ['name'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} LoadFont (@code{const char *}name, @code{const char *}path=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_load_font (@code{HMGL} gr, @code{const char *}name, @code{const char *}path) +@end ifclear +Загружает начертание шрифта из файла @var{path}/@var{name}. Пустая строка загрузит шрифт по умолчанию. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetFontDef (@code{const char *}fnt) +@deftypefnx {Функция С} @code{void} mgl_set_font_def (@code{HMGL} gr, @code{const char *} val) +Задает стиль шрифта (см. @ref{Text printing}). По умолчанию используется @samp{rC} -- прямой шрифт с выравниванием по центру. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetFontSize (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_font_size (@code{HMGL} gr, @code{mreal} val) +Задает базовый размер шрифта. По умолчанию размер подписей оси координат в 1.4 раза больше. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetFontSizePT (@code{mreal} cm, @code{int} dpi=@code{72}) +Задает размер шрифта в пунктах для заданного DPI (по умолчанию 16 pt для dpi=72). +@end deftypefn +@deftypefn {Метод класса @code{mglGraph}} @code{inline void} SetFontSizeCM (@code{mreal} cm, @code{int} dpi=@code{72}) +Задает размер шрифта в сантиметрах для заданного DPI (по умолчанию 0.56 см = 16 pt). +@end deftypefn +@deftypefn {Метод класса @code{mglGraph}} @code{inline void} SetFontSizeIN (@code{mreal} cm, @code{int} dpi=@code{72}) +Задает размер шрифта в дюймах для заданного DPI (по умолчанию 0.22 in = 16 pt). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} CopyFont (@code{mglGraph *} from) +@deftypefnx {Функция С} @code{void} mgl_copy_font (@code{HMGL} gr, @code{HMGL} gr_from) +Копирует начертание шрифта из другого объекта @code{mglGraph}. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} RestoreFont () +@deftypefnx {Функция С} @code{void} mgl_restore_font (@code{HMGL} gr) +Восстанавливает начертание шрифта по умолчанию. +@end deftypefn + +@deftypefn {Функция С} @code{void} mgl_def_font (@code{const char *}name, @code{const char *}path) +Загружает начертание шрифта по умолчанию (для всех вновь создаваемых HMGL/mglGraph объектов) из файла @var{path}/@var{name}. +@end deftypefn + +@end ifclear + +@c ================================================================== +@external{} +@node Palette and colors, Masks, Font settings, Graphics setup +@subsection Палитра и цвета +@nav{} +@ifclear UDAV +@cindex SetPalette +@end ifclear +@cindex Palette + +@anchor{palette} +@deftypefn {Команда MGL} {} palette 'colors' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetPalette (@code{const char *}colors) +@deftypefnx {Функция С} @code{void} mgl_set_palette (@code{HMGL} gr, @code{const char *}colors) +@end ifclear +Задает палитру как последовательность цветов. Значение по умолчанию @code{"Hbgrcmyhlnqeup"}, что соответствует цветам: темно серый @samp{H}, синий @samp{b}, зелёный @samp{g}, красный @samp{r}, голубой @samp{c}, малиновый @samp{m}, жёлтый @samp{y}, серый @samp{h}, сине-зелёный @samp{l}, небесно-голубой @samp{n}, оранжевый @samp{q}, желто-зелёный @samp{e}, сине-фиолетовый @samp{u}, фиолетовый @samp{p}. Палитра в основном используется в 1D графиках (см. @ref{1D plotting}) для кривых с неопределённым стилем линии. Внутренний счетчик цвета будет сброшен при любом изменении палитры, включая скрытые (например, функциями @ref{box} или @ref{axis}). +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetDefScheme (@code{const char *}sch) +@deftypefnx {Функция С} @code{void} mgl_set_def_sch (@code{HMGL} gr, @code{const char *}sch) +Устанавливает @var{sch} в качестве цветовой схемы по умолчанию. Начальное значение @code{"BbcyrR"}. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetColor (@code{char} id, @code{mreal} r, @code{mreal} g, @code{mreal} b) static +@deftypefnx {Функция С} @code{void} mgl_set_color (@code{char} id, @code{mreal} r, @code{mreal} g, @code{mreal} b) +Задает RGB значения для цвета с заданным @var{id}. Изменения действуют глобально для всех последующих использований данного @var{id}. +@end deftypefn +@end ifclear + +@c ================================================================== +@external{} +@node Masks, Error handling, Palette and colors, Graphics setup +@subsection Маски +@nav{} +@cindex SetMask +@cindex SetMaskAngle + +@anchor{mask} +@deftypefn {Команда MGL} {} mask 'id' 'hex' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetMask (@code{char} id, @code{const char *}hex) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetMask (@code{char} id, @code{uint64_t} hex) +@deftypefnx {Функция С} @code{void} mgl_set_mask (@code{HMGL} gr, @code{const char *}hex) +@deftypefnx {Функция С} @code{void} mgl_set_mask_val (@code{HMGL} gr, @code{uint64_t} hex) +@end ifclear +Задает новую матрицу @var{hex} размером 8*8 для маски с заданным @var{id}. Изменения действуют глобально для всех последующих использований данного @var{id}. Значения по умолчанию (см. @ref{Color scheme}): @samp{-} -- 000000FF00000000, @samp{+} -- 080808FF08080808, @samp{=} -- 0000FF00FF000000, @samp{;} -- 0000007700000000, @samp{o} -- 0000182424180000, @samp{O} -- 0000183C3C180000, @samp{s} -- 00003C24243C0000, @samp{S} -- 00003C3C3C3C0000, @samp{~} -- 0000060990600000, @samp{<} -- 0060584658600000, @samp{>} -- 00061A621A060000, @samp{j} -- 0000005F00000000, @samp{d} -- 0008142214080000, @samp{D} -- 00081C3E1C080000, @samp{*} -- 8142241818244281, @samp{^} -- 0000001824420000. +@end deftypefn + +@deftypefn {Команда MGL} {} mask angle +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetMaskAngle (@code{int} angle) +@deftypefnx {Функция С} @code{void} mgl_set_mask_angle (@code{HMGL} gr, @code{int} angle) +@end ifclear +Задает угол поворота маски в градусах. Отмечу, что символы @samp{\}, @samp{/}, @samp{I} в цветовой схеме задают угол поворота в 45, -45 и 90 градусов соответственно. +@end deftypefn + +@c ================================================================== +@external{} +@node Error handling, , Masks, Graphics setup +@subsection Обработка ошибок +@nav{} +@ifclear UDAV +@cindex Message +@cindex SetWarn +@cindex GetWarn + +Обычно вы должны сбросить признак ошибки с помощью @code{SetWarn(0);} перед построением и проверить @code{GetWarnCode()} или @code{Message()} на наличие ошибок после построения. Только последнее предупреждение сохраняется. Замечу, что все предупреждения/ошибки в MathGL не являются критичными -- в худшем из вариантов соответствующий график просто не будет построен. + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetWarn (@code{int} code, @code{const char *}info=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_set_warn (@code{HMGL} gr, @code{int} code, @code{const char *}info) +Задает код предупреждения. Обычно вызывается только для очистки предупреждений (@code{SetWarn(0);}) или внутри библиотеки. Текст @var{info} будет добавлен к предупреждениям как есть при @var{code}<0. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{const char *}Message () +@deftypefnx {Функция С} @code{const char *}mgl_get_mess (@code{HMGL} gr) +Возвращает текст предупреждений о причине отсутствия графика. Если возвращаемая строка пустая, то сообщений нет. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetWarn () +@deftypefnx {Функция С} @code{int} mgl_get_warn (@code{HMGL} gr) +Возвращает код сообщения о причине отсутствия графика. Возможные значения: +@table @code +@item mglWarnNone=0 +Предупреждений нет +@item mglWarnDim +Неправильные или несовместимые размеры данных +@item mglWarnLow +Размеры данных слишком малы +@item mglWarnNeg +Минимальное значение отрицательно +@item mglWarnFile +Файл не найден или указаны неправильные размерности +@item mglWarnMem +Не достаточно памяти +@item mglWarnZero +Значение данных равно нулю +@item mglWarnLeg +Нет записей в легенде +@item mglWarnSlc +Индекс среза вне данных +@item mglWarnCnt +Число линий уровня меньше или равно нулю +@item mglWarnOpen +Не могу открыть файл +@item mglWarnLId +Light: ID вне допустимых значений +@item mglWarnSize +Setsize: размер(ы) равны нулю или отрицательны +@item mglWarnFmt +Формат не поддерживается +@item mglWarnTern +Диапазоны осей несовместимые +@item mglWarnNull +Указатель равен NULL +@item mglWarnSpc +Не хватает места для графика +@item mglScrArg +Неправильные аргументы команды скрипта MGL +@item mglScrCmd +Неправильная команда в скрипте MGL +@item mglScrLong +Слишком длинная строка в скрипте MGL +@item mglScrStr +Одиночная ' в скрипте MGL +@end table +@end deftypefn +@end ifclear + + +@c ================================================================== +@external{} +@node Axis settings, Subplots and rotation, Graphics setup, MathGL core +@section Настройки осей координат +@nav{} + +Эти функции управляет видом и масштабом осей координат. Перед построением для каждой точки выполняются 3 преобразования: сначала определяется возможность рисования точки (см. @ref{Cutting}), далее применяются формулы перехода к криволинейным координатам и наконец точка отображается. Отмечу, что MathGL выдает предупреждение если масштабы осей координат лежат вне области определения формул преобразования координат. + +@menu +* Ranges (bounding box):: +* Curved coordinates:: +* Ticks:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Ranges (bounding box), Curved coordinates, , Axis settings +@subsection Масштаб осей координат +@nav{} +@cindex CRange +@cindex XRange +@cindex YRange +@cindex ZRange +@cindex Ranges +@cindex Origin +@ifclear UDAV +@cindex SetRange +@cindex SetRanges +@cindex SetOrigin +@end ifclear + +@anchor{xrange} +@anchor{yrange} +@anchor{zrange} +@anchor{crange} +@deftypefn {Команда MGL} {} xrange @code{v1 v2} [@code{add=off}] +@deftypefnx {Команда MGL} {} yrange @code{v1 v2} [@code{add=off}] +@deftypefnx {Команда MGL} {} zrange @code{v1 v2} [@code{add=off}] +@deftypefnx {Команда MGL} {} crange @code{v1 v2} [@code{add=off}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRange (@code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} AddRange (@code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {Функция С} @code{void} mgl_set_range_val (@code{HMGL} gr, @code{char} dir, @code{mreal} v1, @code{mreal} v2) +@deftypefnx {Функция С} @code{void} mgl_add_range_val (@code{HMGL} gr, @code{char} dir, @code{mreal} v1, @code{mreal} v2) +@end ifclear +Задает диапазон изменения @samp{x}-,@samp{y}-,@samp{z}-,@samp{c}-координат. Если одно из значений равно @code{NAN}, то оно игнорируется. Параметр @code{add=on} указывает добавлять новый диапазон к существующему (не заменять его). См. также @ref{ranges}. +@end deftypefn + +@deftypefn {Команда MGL} {} xrange dat [@code{add=off}] +@deftypefnx {Команда MGL} {} yrange dat [@code{add=off}] +@deftypefnx {Команда MGL} {} zrange dat [@code{add=off}] +@deftypefnx {Команда MGL} {} crange dat [@code{add=off}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRange (@code{char} dir, @code{const mglDataA &}dat, @code{bool} add=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_set_range_dat (@code{HMGL} gr, @code{char} dir, @code{const HCDT} a, @code{int} add) +@end ifclear +Задает диапазон изменения @samp{x}-,@samp{y}-,@samp{z}-,@samp{c}-координат как минимальное и максимальное значение массива @var{dat}. Параметр @code{add=on} указывает добавлять новый диапазон к существующему (не заменять его). +@end deftypefn + +@anchor{ranges} +@deftypefn {Команда MGL} {} ranges @code{x1 x2 y1 y2 [z1=0 z2=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRanges (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRanges (@code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1=@code{0}, @code{mreal} z2=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_set_ranges (@code{HMGL} gr, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1, @code{mreal} z2) +@end ifclear +Задает диапазон изменения координат. Если минимальное и максимальное значение координаты равны, то они игнорируются по данному направлению. Также устанавливает размер цветовой шкалы, аналогично команде @code{crange z1 z2}. Начальные диапазоны равны [-1, 1]. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetRanges (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz, @code{const mglDataA &}cc) +Задает диапазон изменения @samp{x}-,@samp{y}-,@samp{z}-,@samp{c}-координат как минимальное и максимальное значение массивов @var{xx}, @var{yy}, @var{zz}, @var{cc} соответственно. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetAutoRanges (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetAutoRanges (@code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1=@code{0}, @code{double} z2=@code{0}, @code{double} c1=@code{0}, @code{double} c2=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_set_auto_ranges (@code{HMGL} gr, @code{double} x1, @code{double} x2, @code{double} y1, @code{double} y2, @code{double} z1, @code{double} z2, @code{double} z1, @code{double} z2) +Задает диапазон изменения координат для автоматических переменных. Если минимальное и максимальное значение координаты равны, то они игнорируются по данному направлению. +@end deftypefn +@end ifclear + +@anchor{origin} +@deftypefn {Команда MGL} {} origin @code{x0 y0 [z0=nan]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetOrigin (@code{mglPoint} p0) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetOrigin (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0=@code{NAN}) +@deftypefnx {Функция С} @code{void} mgl_set_origin (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0) +@end ifclear +Задает центр пересечения осей координат. Если одно из значений равно NAN, то MathGL попытается выбрать оптимальное положение осей координат по этому направлению. +@end deftypefn + +@anchor{zoomaxis} +@deftypefn {Команда MGL} {} zoomaxis @code{x1 x2} +@deftypefnx {Команда MGL} {} zoomaxis @code{x1 y1 x2 y2} +@deftypefnx {Команда MGL} {} zoomaxis @code{x1 y1 z1 x2 y2 z2} +@deftypefnx {Команда MGL} {} zoomaxis @code{x1 y1 z1 c1 x2 y2 z2 c2} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ZoomAxis (@code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Функция С} @code{void} mgl_zoom_axis (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} c1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} c2) +@end ifclear +Дополнительно расширяет диапазон осей координат, задаваемый функциями @code{SetRange} или @code{SetRanges}, в соответствии с формулами @math{min += (max-min)*p1} и @math{max += (max-min)*p1} (или @math{min *= (max/min)^p1} и @math{max *= (max/min)^p1} для "логарифмических" диапазонов, когда @math{inf>max/min>100} или @math{00 задает относительную длину подметок, которые в @code{sqrt(1+stt)} раз меньше. +@end deftypefn + +@deftypefn {Команда MGL} {} axisstl 'stl' ['tck'='' 'sub'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetAxisStl (@code{const char *}stl=@code{"k"}, @code{const char *}tck=@code{0}, @code{const char *}sub=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_set_axis_stl (@code{HMGL} gr, @code{const char *}stl, @code{const char *}tck, @code{const char *}sub) +@end ifclear +Задает стиль осей (@var{stl}), меток (@var{tck}) и подметок (@var{sub}) осей координат. Если @var{stl} пустая или ноль, то используется стиль по умолчанию (@samp{k} или @samp{w} в зависимости от типа прозрачности). Если @var{tck}, @var{sub} пустая или ноль, то используется стиль осей (т.е. @var{stl}). +@end deftypefn + +@c ################################################################## +@external{} +@node Subplots and rotation, Export picture, Axis settings, MathGL core +@section Матрица преобразования +@nav{} +@cindex Aspect +@cindex Rotate +@cindex RotateN +@cindex SubPlot +@cindex MultiPlot +@cindex StickPlot +@cindex ColumnPlot +@cindex InPlot +@cindex Title +@cindex Perspective +@cindex View +@cindex Push +@cindex Pop + +Эти функции контролируют где и как график будет расположен. Существует определенный порядок вызова этих функций для лучшего вида графика. Вначале должны вызываться функции @ref{subplot}, @ref{multiplot} или @ref{inplot} для указания местоположения вывода. После них -- функции вращения @ref{rotate} и @ref{aspect}. И наконец любые другие функции для рисования графика. Вместо вращения графика можно вызвать функцию @ref{columnplot}, @ref{gridplot}, @ref{stickplot} или относительную @ref{inplot} для расположения графиков в столбец одного над другим без зазора между осями. @sref{Subplots} + +@anchor{subplot} +@deftypefn {Команда MGL} {} subplot @code{nx ny m ['stl'='<>_^' dx=0 dy=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SubPlot (@code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl=@code{"<>_^"}, @code{mreal} dx=@code{0}, @code{mreal} dy=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_subplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl) +@deftypefnx {Функция С} @code{void} mgl_subplot_d (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{const char *}stl, @code{mreal} dx, @code{mreal} dy) +@end ifclear +Помещает последующий вывод в @var{m}-ую ячейку сетки размером @var{nx}*@var{ny} от всего рисунка. Функция сбрасывает матрицу трансформации (повороты и сжатие графика) и должна вызываться первой для создания "подграфика". С эстетической точки зрения не рекомендуется вызывать эту функцию с различными (или не кратными) размерами сетки. Место для осей/colorbar резервируется только если строка @var{stl} содержит: @samp{L} или @samp{<} -- с левого края, @samp{R} или @samp{>} -- с правого края, @samp{A} или @samp{^} -- с верхнего края, @samp{U} или @samp{_} -- с нижнего края. Если строка @var{stl} содержит @samp{#}, то оси координат будут занимать все доступное пространство (место резервироваться не будет). Ячейка может быть дополнительно сдвинута относительно своего обычного положения на относительный размер @var{dx}, @var{dy}. +@end deftypefn + +@anchor{multiplot} +@deftypefn {Команда MGL} {} multiplot @code{nx ny m dx dy} ['style'='<>_^'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} MultiPlot (@code{int} nx, @code{int} ny, @code{int} m, @code{int} dx, @code{int} dy, @code{const char *}stl=@code{"<>_^"}) +@deftypefnx {Функция С} @code{void} mgl_multiplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m, @code{int} dx, @code{int} dy, @code{const char *}stl) +@end ifclear +Помещает последующий вывод в прямоугольник из @var{dx}*@var{dy} ячеек, начиная с @var{m}-ой ячейки, сетки размером @var{nx}*@var{ny} от всего рисунка. Функция сбрасывает матрицу трансформации (повороты и сжатие графика) и должна вызываться первой для создания "подграфика". Место для осей/colorbar резервируется если строка @var{stl} содержит: @samp{L} или @samp{<} -- с левого края, @samp{R} или @samp{>} -- с правого края, @samp{A} или @samp{^} -- с верхнего края, @samp{U} или @samp{_} -- с нижнего края. +@end deftypefn + +@anchor{inplot} +@deftypefn {Команда MGL} {} inplot @code{x1 x2 y1 y2 [rel=on]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} InPlot (@code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{bool} rel=@code{true}) +@deftypefnx {Функция С} @code{void} mgl_inplot (@code{HMGL} gr, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@deftypefnx {Функция С} @code{void} mgl_relplot (@code{HMGL} gr, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@end ifclear +Помещает последующий вывод в прямоугольную область [@var{x1}, @var{x2}]*[@var{y1}, @var{y2}] (исходный размер [0,1]*[0,1]). Эта функция позволяет поместить график в произвольную область рисунка. Если параметр @var{rel}=@code{true}, то используется позиция относительно текущего @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). Функция сбрасывает матрицу трансформации (повороты и сжатие графика) и должна вызываться первой для создания "подграфика". +@end deftypefn + +@anchor{columnplot} +@deftypefn {Команда MGL} {} columnplot @code{num ind [d=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ColumnPlot (@code{int} num, @code{int} ind, @code{mreal} d=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_columnplot (@code{HMGL} gr, @code{int} num, @code{int} ind) +@deftypefnx {Функция С} @code{void} mgl_columnplot_d (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} d) +@end ifclear +Помещает последующий вывод в @var{ind}-ую строку столбца из @var{num} строк. Положение столбца выбирается относительно последнего вызова @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). Параметр @var{d} задает дополнительный зазор между строк. +@end deftypefn + +@anchor{gridplot} +@deftypefn {Команда MGL} {} gridplot @code{nx ny ind [d=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} GridPlot (@code{int} nx, @code{int} ny, @code{int} ind, @code{mreal} d=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_gridplot (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} ind) +@deftypefnx {Функция С} @code{void} mgl_gridplot_d (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} ind, @code{mreal} d) +@end ifclear +Помещает последующий вывод в @var{ind}-ую ячейку таблицы @var{nx}*@var{ny}. Положение ячейки выбирается относительно последнего вызова @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). Параметр @var{d} задает дополнительный зазор между строк. +@end deftypefn + +@anchor{stickplot} +@deftypefn {Команда MGL} {} stickplot @code{num ind tet phi} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} StickPlot (@code{int} num, @code{int} ind, @code{mreal} tet, @code{mreal} phi) +@deftypefnx {Функция С} @code{void} mgl_stickplot (@code{HMGL} gr, @code{int} num, @code{int} ind, @code{mreal} tet, @code{mreal} phi) +@end ifclear +Помещает последующий вывод в @var{ind}-ую ячейку "бруска" из @var{num} ячеек. При этом сам брусок повернут на углы @var{tet}, @var{phi}. Положение выбирается относительно последнего вызова @ref{subplot} (или @ref{inplot} с @var{rel}=@code{false}). +@end deftypefn + +@anchor{title} +@deftypefn {Команда MGL} {} title 'title' ['stl'='' @code{size=-2}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Title (@code{const char *}txt, @code{const char *}stl=@code{""}, @code{mreal} size=@code{-2}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Title (@code{const wchar_t *}txt, @code{const char *}stl=@code{""}, @code{mreal} size=@code{-2}) +@deftypefnx {Функция С} @code{void} mgl_title (@code{HMGL} gr, @code{const char *}txt, @code{const char *}stl, @code{mreal} size) +@deftypefnx {Функция С} @code{void} mgl_titlew (@code{HMGL} gr, @code{const wchar_t *}txt, @code{const char *}stl, @code{mreal} size) +@end ifclear +Выводит заголовок @var{title} для текущего "подграфика" шрифтом @var{stl} с размером @var{size}. Если строка @var{stl} содержит @samp{#}, то рисуется обрамляющий прямоугольник. Функция сбрасывает матрицу трансформации (повороты и сжатие графика) и должна вызываться сразу после создания "подграфика". +@end deftypefn + +@anchor{rotate} +@deftypefn {Команда MGL} {} rotate @code{tetx tetz [tety=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Rotate (@code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_rotate (@code{HMGL} gr, @code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY) +@end ifclear +Вращает систему координат относительно осей @{x, z, y@} последовательно на углы @var{TetX}, @var{TetZ}, @var{TetY}. +@end deftypefn + +@deftypefn {Команда MGL} {} rotate @code{tet x y z} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} RotateN (@code{mreal} Tet, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Функция С} @code{void} mgl_rotate_vector (@code{HMGL} gr, @code{mreal Tet}, @code{mreal x}, @code{mreal y}, @code{mreal z}) +@end ifclear +Вращает систему координат относительно вектора @{@var{x}, @var{y}, @var{z}@} на угол @var{Tet}. +@end deftypefn + +@anchor{aspect} +@deftypefn {Команда MGL} {} aspect @code{ax ay [az=1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Aspect (@code{mreal} Ax, @code{mreal} Ay, @code{mreal} Az=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_aspect (@code{HMGL} gr, @code{mreal} Ax, @code{mreal} Ay, @code{mreal} Az) +@end ifclear +Устанавливает соотношение размеров осей в отношении @var{Ax:Ay:Az}. Для лучшего вида следует вызывать после функции @ref{rotate}. Если @var{Ax}=@code{NAN}, то функция выберет оптимальное соотношение размеров, чтобы шаг по осям x-y был одинаков. При этом, @var{Ay} задает фактор пропорциональности шага (обычно 1), или указывает на его автоматический выбор при @var{Ay}=@code{NAN}. +@end deftypefn + +@ifclear UDAV + +@deftypefn {Метод класса @code{mglGraph}} @code{void} Push () +@deftypefnx {Функция С} @code{void} mgl_mat_push (@code{HMGL} gr) +Помещает матрицу преобразования в стек. Позднее вы можете восстановить текущее состояние с помощью функции Pop(). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} Pop () +@deftypefnx {Функция С} @code{void} mgl_mat_pop (@code{HMGL} gr) +Заменяет (восстанавливает) матрицу преобразования на последнюю помещенную в стек матрицу. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetPlotFactor (@code{mreal} val) +@deftypefnx {Функция С} @code{void} mgl_set_plotfactor (@code{HMGL} gr, @code{mreal} val) +Задает масштаб картинки. Не рекомендуется устанавливать значения меньше 1.5. Это аналог функции Zoom(), но применяется только к конкретному подграфику. Используйте ноль для включения автоматического масштабирования. +@end deftypefn + +@end ifclear + + +Также есть 3 функции, которые управляют перспективой @code{Perspective()}, масштабированием @code{Zoom()} и вращением @code{View()} всего рисунка. Т.е. они действуют как ещё одна матрица трансформации. Они были введены для вращения/приближения графика с помощью мыши. Не рекомендуется вызывать их при рисовании графика. + +@anchor{perspective} +@deftypefn {Команда MGL} {} perspective @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Perspective (@code{mreal} a) +@deftypefnx {Функция С} @code{void} mgl_perspective (@code{HMGL} gr, @code{mreal} a) +@end ifclear +Добавляет (включает) перспективу для графика. Параметр @math{a = Depth/(Depth+dz) \in [0,1)}. По умолчанию (@code{a=0}) перспектива отключена. +@end deftypefn + +@anchor{view} +@deftypefn {Команда MGL} {} view @code{tetx tetz [tety=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} View (@code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_view (@code{HMGL} gr, @code{mreal} TetX, @code{mreal} TetZ, @code{mreal} TetY) +@end ifclear +Вращает систему координат относительно осей @{x, z, y@} последовательно на углы @var{TetX}, @var{TetZ}, @var{TetY}. Вращение происходит независимо от @ref{rotate}. Внимание! эти настройки не могут быть переписаны функцией @code{DefaultPlotParam()}. Используйте @code{Zoom(0,0,1,1)} для возвращения к виду по умолчанию. +@end deftypefn + +@anchor{zoom} +@deftypefn {Команда MGL} {} zoom @code{x1 y1 x2 y2} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Zoom (@code{mreal} x1, @code{mreal} y1, @code{mreal} x2, @code{mreal} y2) +@deftypefnx {Функция С} @code{void} mgl_set_zoom (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} x2, @code{mreal} y2) +@end ifclear +Масштабирует весь рисунок. После вызова функции текущий график будет очищен и в дальнейшем рисунок будет содержать только область [x1,x2]*[y1,y2] от исходного рисунка. Координаты @var{x1}, @var{x2}, @var{y1}, @var{y2} меняются в диапазоне от 0 до 1. Внимание! эти настройки не могут быть переписаны никакими другими функциями, включая @code{DefaultPlotParam()}. Используйте @code{Zoom(0,0,1,1)} для возвращения к виду по умолчанию. +@end deftypefn + +@c ################################################################## +@external{} +@node Export picture, Primitives, Subplots and rotation, MathGL core +@section Экспорт рисунка +@nav{} +@cindex SetSize + +Функции в этой группе сохраняют или дают доступ к полученному рисунку. Поэтом обычно они должны вызываться в конце рисования. + +@anchor{setsize} +@deftypefn {Команда MGL} {} setsize @code{w h} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetSize (@code{int} width, @code{int} height) +@deftypefnx {Функция С} @code{void} mgl_set_size (@code{HMGL} gr, @code{int} width, @code{int} height) +@end ifclear +Изменяет размер картинки в пикселях. Функция должна вызываться @strong{перед} любыми функциями построения потому что полностью очищает содержимое рисунка. +@end deftypefn + +@anchor{quality} +@deftypefn {Команда MGL} {} quality [@code{val}=2] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetQuality (@code{int} val=@code{MGL_DRAW_NORM}) +@deftypefnx {Функция С} @code{void} mgl_set_quality (@code{HMGL} gr, @code{int} val) +@end ifclear +Задает качество графика в зависимости от значения @var{val}: @code{MGL_DRAW_WIRE=0} -- нет рисования граней (наиболее быстрый), @code{MGL_DRAW_FAST=1} -- нет интерполяции цвета (быстрый), @code{MGL_DRAW_NORM=2} -- высокое качество (нормальный), @code{MGL_DRAW_HIGH=3} -- высокое качество с рисованием 3d примитивов (стрелок и маркеров). Если установлен бит @code{MGL_DRAW_LMEM=0x4}, то происходит прямое рисование в растровое изображение (меньше затраты памяти). Если установлен бит @code{MGL_DRAW_DOTS=0x8}, то рисуются точки вместо примитивов (очень быстро). +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetQuality () +@deftypefnx {Функция С} @code{void} mgl_get_quality (@code{HMGL} gr) +Возвращает качество графика: @code{MGL_DRAW_WIRE=0} -- нет рисования граней (наиболее быстрый), @code{MGL_DRAW_FAST=1} -- нет интерполяции цвета (быстрый), @code{MGL_DRAW_NORM=2} -- высокое качество (нормальный), @code{MGL_DRAW_HIGH=3} -- высокое качество с рисованием 3d примитивов (стрелок и маркеров). Если установлен бит @code{MGL_DRAW_LMEM=0x4}, то происходит прямое рисование в растровое изображение (меньше затраты памяти). Если установлен бит @code{MGL_DRAW_DOTS=0x8}, то рисуются точки вместо примитивов (очень быстро). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} StartGroup (const char *name) +@deftypefnx {Функция С} @code{void} mgl_start_group (@code{HMGL} gr, @code{const char *}name) +Начинает определение группы. Группа может содержать объекты и другие группы. Они используются для выбора части модели при приближении, изменении прозрачности и т.д. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} EndGroup () +@deftypefnx {Функция С} @code{void} mgl_end_group (@code{HMGL} gr) +Завершает определение группы. +@end deftypefn +@end ifclear + +@menu +* Export to file:: +* Frames/Animation:: +* Bitmap in memory:: +* Parallelization:: +@end menu + +@c ================================================================== +@external{} +@node Export to file, Frames/Animation, , Export picture +@subsection Экспорт в файл +@nav{} +@cindex Write +@ifclear UDAV +@cindex WriteFrame +@cindex WritePNG +@cindex WriteGIF +@c @cindex WriteIDTF +@cindex WriteSVG +@cindex WriteBMP +@cindex WriteEPS +@cindex WriteBPS +@cindex WriteTGA +@cindex WriteTEX +@cindex WritePRC +@cindex WriteOBJ +@cindex WriteWGL +@cindex WriteJPEG +@cindex ShowImage +@end ifclear + +Эти функции экспортируют текущую картинку (кадр) в файл. Имя файла @var{fname} должно иметь соответствующее расширение. Параметр @var{descr} дает краткое описание картинки. Пока прозрачность поддерживается только для форматов PNG, SVG, OBJ и PRC. + +@anchor{write} +@deftypefn {Команда MGL} {} write ['fname'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} WriteFrame (@code{const char *}fname=@code{""}, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_frame (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@end ifclear +Экспортирует текущий кадр в файл @var{fname} с типом, определяемым по расширению. Параметр @var{descr} добавляет описание (может быть пустым). Если @var{fname} пустой, то используется имя @samp{frame####.jpg}, где @samp{####} -- текущий номер кадра и имя @samp{frame} определяется переменной @ref{plotid}. +@end deftypefn + +@ifclear UDAV + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WritePNG (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{int} compr=@code{""}, @code{bool} alpha=@code{true}) +@deftypefnx {Функция С} @code{void} mgl_write_png (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@deftypefnx {Функция С} @code{void} mgl_write_png_solid (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в PNG файл. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла, @var{alpha} -- прозрачность фона. Если при компиляции MathGL не был определен флаг HAVE_PNG, то экспорт в файл не производится. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteJPEG (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_jpg (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в JPEG файл. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если при компиляции MathGL не был определен флаг HAVE_JPEG, то экспорт в файл не производится. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteGIF (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_gif (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в GIF файл. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если при компиляции MathGL не был определен флаг HAVE_GIF, то экспорт в файл не производится. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteBMP (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_bmp (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в BMP файл. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteTGA (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_tga (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в TGA файл. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteEPS (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_eps (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в EPS файл, используя векторное представление графика. Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если имя файла оканчивается на @samp{z} (например, @samp{fname.eps.gz}), то файл автоматически архивируется в формате gzip. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteBPS (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_eps (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в EPS файл, используя растровое представление графика. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если имя файла оканчивается на @samp{z} (например, @samp{fname.eps.gz}), то файл автоматически архивируется в формате gzip. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteSVG (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_svg (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в SVG файл, используя векторное представление графика. Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если имя файла оканчивается на @samp{z} (например, @samp{fname.svgz}), то файл автоматически архивируется в формате gzip. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteTEX (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_tex (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в LaTeX файл (пакет Tikz/PGF), используя векторное представление графика. Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Отмечу, что сейчас отсутствует изменение размера текста (например, в subplot), что может приводить к неправильному положению надписей. +@end deftypefn + + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WritePRC (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{bool} make_pdf=@code{true}) +@deftypefnx {Функция С} @code{void} mgl_write_prc (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr, @code{int} make_pdf) +Экспортирует текущий кадр в PRC файл, используя векторное представление графика (см. @url{http://en.wikipedia.org/wiki/PRC_%28file_format%29}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. Если параметр @var{make_pdf}=@code{true} и PDF был выбран при конфигурировании MathGL, то также создается соответствующий PDF файл с 3D изображением. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteOBJ (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_obj (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в OBJ/MTL файл, используя векторное представление графика (см. @url{http://en.wikipedia.org/wiki/Wavefront_.obj_file, OBJ формат}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteXYZ (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_xyz (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в XYZ/XYZL/XYZF файлы, используя векторное представление графика (см. @url{http://people.sc.fsu.edu/~jburkardt/data/xyz/xyz.html, XYZ формат}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteSTL (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_stl (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует текущий кадр в STL файл, используя векторное представление графика (см. @url{http://en.wikipedia.org/wiki/STL_(file_format), STL формат}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteOFF (@code{const char *}fname, @code{const char *}descr=@code{""}, @code{bool} colored=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_write_off (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr, @code{bool} colored) +Экспортирует текущий кадр в OFF файл, используя векторное представление графика (см. @url{http://people.sc.fsu.edu/~jburkardt/data/off/off.html, OFF формат}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@c @deftypefn {Метод класса @code{mglGraph}} @code{void} WriteX3D (@code{const char *}fname, @code{const char *}descr=@code{""}) +@c @deftypefnx {Функция С} @code{void} mgl_write_x3d (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@c Экспортирует текущий кадр в X3D файл, используя векторное представление графика (см. @url{http://en.wikipedia.org/wiki/X3d, X3D формат}). Вследствие чего не рекомендуется сохранять большие графики (поверхности, а особенно поверхности уровня) из-за большого размера файла. Хотя никаких внутренних ограничений на размер выходного файла нет. Для них лучше использовать растровый формат (например, PNG или JPEG). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@c @end deftypefn + + +@c @deftypefn {Метод класса @code{mglGraph}} @code{void} WriteIDTF (@code{const char *}fname, @code{const char *}descr=@code{""}) +@c @deftypefnx {Функция С} @code{void} mgl_write_idtf (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +@c Экспортирует текущий кадр в IDTF файл, используя векторное представление графика (класс mglGraphIDTF). Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@c @end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} ShowImage (@code{const char *}viewer, @code{bool} nowait=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_show_image (@code{const char *}viewer, @code{int} nowait) +Отображает текущий кадр используя внешнюю программу просмотра @var{viewer}. Функция сохраняет картинку во временный файл и вызывает @var{viewer} для его отображения. Если @var{nowait}=@code{true}, то функция возвращает управление немедленно -- не ждет пока окно просмотра будет закрыто. +@end deftypefn + + +@deftypefn {Метод класса @code{mglGraph}} @code{void} WriteJSON (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_write_json (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует точки и примитивы в текстовый файл используя @ref{JSON format}. В дальнейшем этот файл можно загрузить и просмотреть в JavaScript скрипте. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} ExportMGLD (@code{const char *}fname, @code{const char *}descr=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_export_mgld (@code{HMGL} gr, @code{const char *}fname, @code{const char *}descr) +Экспортирует точки и примитивы в файл @ref{MGLD format}. В дальнейшем этот файл можно загрузить и просмотреть с помощью @code{mglview}. Параметры функции следующие: @var{fname} -- имя файла, @var{descr} -- описание файла. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} ImportMGLD (@code{const char *}fname, @code{bool} add=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_import_mgld (@code{HMGL} gr, @code{const char *}fname, @code{int} add) +Импортирует точки и примитивы из файла в @ref{MGLD format}. Параметры функции следующие: @var{fname} -- имя файла, @var{add} -- флаг добавления или замены существующих точек и примитивов. +@end deftypefn + +@end ifclear + + +@c ################################################################## +@external{} +@node Frames/Animation, Bitmap in memory, Export to file, Export picture +@subsection Кадры/Анимация +@nav{} + +@ifset UDAV +В MGL нет специальных команд для создания анимации. Однако можно воспользоваться возможностями утилит @code{mglconv} и @code{mglview}. Например, используя комментарии спеиального вида @samp{##a } или @samp{##c }. +@end ifset + +@ifclear UDAV +@cindex NewFrame +@cindex EndFrame +@cindex GetNumFrame +@cindex ResetFrames +@cindex StartGIF +@cindex CloseGIF + +Эти функции позволяют создавать несколько картинок одновременно. В большинстве случаев это бесполезно, но для органов управления (см. @ref{Widget classes}) это позволяет показывать анимацию. Также можно записать несколько кадров в анимированный GIF файл. + +@deftypefn {Метод класса @code{mglGraph}} @code{void} NewFrame () +@deftypefnx {Функция С} @code{void} mgl_new_frame (@code{HMGL} gr) +Создает новый кадр. Функция возвращает номер текущего кадра. В режиме OpenGL функция не должны вызываться в параллельных потоках! -- используйте прямое создание списка. Функция @code{EndFrame()} @strong{должна} быть вызвана после рисования кадра для каждого вызова этой функции. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} EndFrame () +@deftypefnx {Функция С} @code{void} mgl_end_frame (@code{HMGL} gr) +Завершает рисование кадра. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetNumFrame () +@deftypefnx {Функция С} @code{int} mgl_get_num_frame (@code{HMGL} gr) +Возвращает число созданных кадров. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} GetFrame (@code{int} i) +@deftypefnx {Функция С} @code{void} mgl_get_frame (@code{HMGL} gr, @code{int} i) +Завершает рисование кадра и сохраняет объекты рисования в кадр с номером @var{i}, который должен быть в диапазоне [0, @code{GetNumFrame()}-1]. Функция аналогична @code{EndFrame()}, но не добавляет кадр в GIF изображение. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} GetFrame (@code{int} i) +@deftypefnx {Функция С} @code{void} mgl_get_frame (@code{HMGL} gr, @code{int} i) +Заменяет объекты рисования на объекты из кадра с номером @var{i}. Функция работает если установлен флаг @code{MGL_VECT_FRAME} (по умолчанию). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} ShowFrame (@code{int} i) +@deftypefnx {Функция С} @code{void} mgl_show_frame (@code{HMGL} gr, @code{int} i) +Добавляет объекты рисования из кадра с номером @var{i} к уже существующим. Функция работает если установлен флаг @code{MGL_VECT_FRAME} (по умолчанию). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} DelFrame (@code{int} i) +@deftypefnx {Функция С} @code{void} mgl_del_frame (@code{HMGL} gr, @code{int} i) +Удаляет объекты рисования для кадра с номером @var{i} и сдвигает нумерацию всех последующих кадров. Функция работает если установлен флаг @code{MGL_VECT_FRAME} (по умолчанию). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} ResetFrames () +@deftypefnx {Функция С} @code{void} mgl_reset_frames (@code{HMGL} gr) +Сбрасывает счетчик кадров в 0. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} StartGIF (@code{const char *}fname, @code{int} ms=@code{100}) +@deftypefnx {Функция С} @code{void} mgl_start_gif (@code{HMGL} gr, @code{const char *}fname, @code{int} ms) +Начинает запись кадров в анимированный GIF файл @var{fname}. Параметр @var{ms} задает задержку между кадрами в миллисекундах. Вы @strong{не должны} менять размер рисунка во время создания кино. Используйте CloseGIF() для завершения записи. Эта функция не работает в режиме OpenGL. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} CloseGIF () +@deftypefnx {Функция С} @code{void} mgl_close_gif (@code{HMGL} gr) +Завершает запись анимированного GIF файла. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Bitmap in memory, Parallelization, Frames/Animation, Export picture +@subsection Рисование в памяти +@nav{} + +@ifclear UDAV +Эти функции возвращают созданный растровый рисунок, его ширину и высоту. В дальнейшем его можно использовать в любой графической библиотеке (см. также, @ref{Widget classes}) или сохранить в файл (см. также, @ref{Export to file}). + +@deftypefn {Метод класса @code{mglGraph}} @code{const unsigned char *} GetRGB () +@deftypefnx {Метод класса @code{mglGraph}} @code{void} GetRGB (@code{char *}buf, @code{int} size) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} GetBGRN (@code{char *}buf, @code{int} size) +@deftypefnx {Функция С} @code{const unsigned char *} mgl_get_rgb (@code{HMGL} gr) +Возвращает растровое изображение в формате RGB для текущего кадра. Формат каждого элемента (пикселя): @{red, green, blue@}. Число элементов Width*Height. Положение элемента @{i,j@} есть [3*i + 3*Width*j] (или [4*i + 4*Width*j] для @code{GetBGRN()}). В Python вы должны предоставить буфер @var{buf} достаточного размера @var{size}, т.е. код должен выглядеть следующим образом (для Python) +@verbatim +from mathgl import * +gr = mglGraph(); +bits='\t'; +bits=bits.expandtabs(4*gr.GetWidth()*gr.GetHeight()); +gr.GetBGRN(bits, len(bits)); +@end verbatim +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{const unsigned char *} GetRGBA () +@deftypefnx {Метод класса @code{mglGraph}} @code{void} GetRGBA (@code{char *}buf, @code{int} size) +@deftypefnx {Функция С} @code{const unsigned char *} mgl_get_rgba (@code{HMGL} gr) +Возвращает растровое изображение в формате RGBA для текущего кадра. Формат каждого элемента (пикселя): @{red, green, blue, alpha@}. Число элементов Width*Height. Положение элемента @{i,j@} есть [4*i + 4*Width*j]. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetWidth () +@deftypefnx {Метод класса @code{mglGraph}} @code{int} GetHeight () +@deftypefnx {Функция С} @code{int} mgl_get_width (@code{HMGL} gr) +@deftypefnx {Функция С} @code{int} mgl_get_height (@code{HMGL} gr) +Возвращает ширину и высоту изображения. +@end deftypefn + + +@deftypefn {Метод класса @code{mglGraph}} @code{mglPoint} CalcXYZ (@code{int} xs, @code{int} ys) +@deftypefnx {Функция С} @code{void} mgl_calc_xyz (@code{HMGL} gr, @code{int} xs, @code{int} ys, @code{mreal *}x, @code{mreal *}y, @code{mreal *}z) +Вычисляет 3D координаты @{x,y,z@} для экранной точки @{xs,ys@}. В данный момент игнорируется перспектива графика и формулы перехода в криволинейные координаты. Вычисления производятся для последнего использованного InPlot (см. @ref{Subplots and rotation}). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{mglPoint} CalcScr (@code{mglPoint} p) +@deftypefnx {Функция С} @code{void} mgl_calc_scr (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{int *}xs, @code{int *}ys) +Вычисляет экранные координаты @{xs,ys@} для 3D координат @{x,y,z@}. Вычисления производятся для последнего использованного InPlot (см. @ref{Subplots and rotation}). +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} SetObjId (@code{int} id) +@deftypefnx {Функция С} @code{void} mgl_set_obj_id (@code{HMGL} gr, @code{int} id) +Задает числовой идентификатор для объектов или subplot/inplot. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetObjId (@code{int} xs, @code{int} ys) +@deftypefnx {Функция С} @code{int} mgl_get_obj_id (@code{HMGL} gr, @code{int} xs, @code{int} ys) +Возвращает числовой идентификатор верхнего объекта в точке @{xs, ys@} рисунка. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} GetSplId (@code{int} xs, @code{int} ys) +@deftypefnx {Функция С} @code{int} mgl_get_spl_id (@code{HMGL} gr, @code{int} xs, @code{int} ys) +Возвращает числовой идентификатор верхнего "подграфика" в точке @{xs, ys@} рисунка. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{void} Highlight (@code{int} id) +@deftypefnx {Функция С} @code{void} mgl_highlight (@code{HMGL} gr, @code{int} id) +Выделяет объект с заданным @var{id}. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{long} IsActive (@code{int} xs, @code{int} ys, @code{int} d=@code{1}) +@deftypefnx {Функция С} @code{long} mgl_is_active (@code{HMGL} gr, @code{int} xs, @code{int} ys, @code{int} d) +Проверяет близка ли точка @{@var{xs}, @var{ys}@} к активной точке (т.е. mglBase::Act) с точностью @var{d} и возвращает индекс активной точки или @code{-1} если не найдено. Активные точки -- специальные точки, которые характеризуют примитивы (например, вершины). Это функция только для опытных пользователей. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{long} SetDrawReg (@code{int} nx=@code{1}, @code{int} ny=@code{1}, @code{int} m=@code{0}) +@deftypefnx {Функция С} @code{long} mgl_set_draw_reg (@code{HMGL} gr, @code{int} nx, @code{int} ny, @code{int} m) +Ограничивает рисование прямоугольной областью @var{m}-ой клетки матрицы размером @var{nx}*@var{ny} (аналогично @ref{subplot}). Функция может бытб использована для ускорения вывода путем уменьшения выводимых примитивов. Это функция только для опытных пользователей. +@end deftypefn + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Parallelization, , Bitmap in memory, Export picture +@subsection Распараллеливание +@nav{} + +@ifclear UDAV +@cindex Combine +@cindex MPI_Send +@cindex MPI_Recv + +Многие функции MathGL используют несколько потоков для ускорения работы (если MathGL была собрана с поддержкой pthread). При этом можно настраивать число используемых потоков. + +@deftypefn {Функция С} @code{int} mgl_set_num_thr (@code{int} n) +Задает число потоков, которое будет использовано в MathGL. При @var{n}<1 число потоков задается как максимальное число процессоров (ядер) в системе. При @var{n}=1 не используется распараллеливание. +@end deftypefn + +Другая возможность -- комбинирование изображений из разных объектов @code{mglGraph}. Эти методы наиболее подходят для компьютерных кластеров, когда данные настолько велики, что не могут поместиться в памяти отдельного компьютера. + +@deftypefn {Метод класса @code{mglGraph}} @code{int} Combine (@code{const mglGraph *}g) +@deftypefnx {Функция С} @code{int} mgl_combine_gr (@code{HMGL} gr, @code{HMGL} g) +Комбинирует (добавляет) рисунок из @var{g} с @var{gr}, принимая во внимание ``высоту'' пикселей. Ширина и высота обоих рисунков должна быть одинаковы. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} MPI_Send (@code{int} id) +@deftypefnx {Функция С} @code{int} mgl_mpi_send (@code{HMGL} gr, @code{int} id) +Посылает рисунок из компьютера (ноды) @var{id}, используя MPI. Ширина и высота обоих рисунков должна быть одинаковы. +@end deftypefn + +@deftypefn {Метод класса @code{mglGraph}} @code{int} MPI_Recv (@code{int} id) +@deftypefnx {Функция С} @code{int} mgl_mpi_send (@code{HMGL} gr, @code{int} id) +Принимает рисунок из компьютера (ноды) @var{id}, используя MPI. Ширина и высота обоих рисунков должна быть одинаковы. +@end deftypefn +@end ifclear + + +@c ################################################################## +@external{} +@node Primitives, Text printing, Export picture, MathGL core +@section Рисование примитивов +@nav{} +@cindex Ball +@cindex Clf +@cindex Line +@cindex Curve +@cindex Glyph +@cindex Face +@cindex FaceX +@cindex FaceY +@cindex FaceZ +@cindex Cone +@cindex Drop +@cindex Sphere + +@ifclear UDAV +@cindex Mark +@cindex Error +@end ifclear + +Эти функции рисуют рисуют простые объекты типа линий, точек, сфер, капель, конусов, и т.д. + +@anchor{clf} +@deftypefn {Команда MGL} {} clf ['col'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Clf () +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Clf (@code{char} col) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Clf (@code{mreal} r, @code{mreal} g, @code{mreal} b) +@deftypefnx {Функция С} @code{void} mgl_clf (@code{HMGL} gr) +@deftypefnx {Функция С} @code{void} mgl_clf_chr (@code{HMGL} gr, @code{char} col) +@deftypefnx {Функция С} @code{void} mgl_clf_rgb (@code{HMGL} gr, @code{mreal} r, @code{mreal} g, @code{mreal} b) +@end ifclear +Очищает рисунок и заполняет его заданным цветом. +@end deftypefn + +@anchor{ball} +@deftypefn {Команда MGL} {} ball @code{x y} ['col'='r.'] +@deftypefnx {Команда MGL} {} ball @code{x y z} ['col'='r.'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Ball (@code{mglPoint} p, @code{char} col=@code{'r'}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mark (@code{mglPoint} p, @code{const char *}mark) +@deftypefnx {Функция С} @code{void} mgl_mark (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}mark) +@end ifclear +Рисует маркер (точку по умолчанию) с координатами @var{p}=@{@var{x}, @var{y}, @var{z}@} и цветом @var{col}. +@end deftypefn + +@anchor{errbox} +@deftypefn {Команда MGL} {} errbox @code{x y ex ey} ['stl'=''] +@deftypefnx {Команда MGL} {} errbox @code{x y z ex ey ez} ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Error (@code{mglPoint} p, @code{mglPoint} e, @code{char} *stl=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_error_box (@code{HMGL} gr, @code{mreal} px, @code{mreal} py, @code{mreal} pz, @code{mreal} ex, @code{mreal} ey, @code{mreal} ez, @code{char *}stl) +@end ifclear +Рисует 3d error box в точке @var{p}=@{@var{x}, @var{y}, @var{z}@} размером @var{e}=@{@var{ex}, @var{ey}, @var{ez}@} и стилем @var{stl}. Используйте NAN в компонентах @var{e} для уменьшения рисуемых элементов. +@end deftypefn + +@anchor{line} +@deftypefn {Команда MGL} {} line @code{x1 y1 x2 y2} ['stl'=''] +@deftypefnx {Команда MGL} {} line @code{x1 y1 z1 x2 y2 z2} ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Line (@code{mglPoint} p1, @code{mglPoint} p2, @code{char *}stl=@code{"B"}, @code{int}num=@code{2}) +@deftypefnx {Функция С} @code{void} mgl_line (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{char *}stl, @code{int}num) +@end ifclear +Рисует геодезическую линию (декартовых координатах -- прямую) из точки @var{p1} в @var{p2} использую стиль линии @var{stl}. Параметр @var{num} определяет гладкость линии (число точек на линии). Если @var{num}=@code{2}, то рисуется прямая даже в криволинейных координатах (см. @ref{Curved coordinates}). Наоборот, для больших значений (например, =@code{100}) рисуется геодезическая линия (окружность в полярных координатах, парабола в параболических и т.д.). Линия рисуется даже если часть ее лежит вне диапазона осей координат. +@end deftypefn + +@anchor{curve} +@deftypefn {Команда MGL} {} curve @code{x1 y1 dx1 dy1 x2 y2 dx2 dy2} ['stl'=''] +@deftypefnx {Команда MGL} {} curve @code{x1 y1 z1 dx1 dy1 dz1 x2 y2 z2 dx2 dy2 dz2} ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Curve (@code{mglPoint} p1, @code{mglPoint} d1, @code{mglPoint} p2, @code{mglPoint} d2, @code{const char *}stl=@code{"B"}, @code{int} num=@code{100}) +@deftypefnx {Функция С} @code{void} mgl_curve (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} dx1, @code{mreal} dy1, @code{mreal} dz1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} dx2, @code{mreal} dy2, @code{mreal} dz2, @code{const char *}stl, @code{int} num) +@end ifclear +Рисует кривую Безье из точки @var{p1} в @var{p2} используя стиль линии @var{stl}. Касательные в точках пропорциональны @var{d1}, @var{d2}. Параметр @var{num} определяет гладкость линии (число точек на линии). Если @var{num}=@code{2}, то рисуется прямая даже в криволинейных координатах (см. @ref{Curved coordinates}). Наоборот, для больших значений (например, =@code{100}) рисуется геодезическая линия (окружность в полярных координатах, парабола в параболических и т.д.). Кривая рисуется даже если часть ее лежит вне диапазона осей координат. +@end deftypefn + +@anchor{face} +@deftypefn {Команда MGL} {} face @code{x1 y1 x2 y2 x3 y3 x4 y4} ['stl'=''] +@deftypefnx {Команда MGL} {} face @code{x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4} ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Face (@code{mglPoint} p1, @code{mglPoint} p2, @code{mglPoint} p3, @code{mglPoint} p4, @code{const char *}stl=@code{"w"}) +@deftypefnx {Функция С} @code{void} mgl_face (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} x3, @code{mreal} y3, @code{mreal} z3, @code{mreal} x4, @code{mreal} y4, @code{mreal} z4, @code{const char *}stl) +@end ifclear +Рисует заполненный четырехугольник (грань) с углами в точках @var{p1}, @var{p2}, @var{p3}, @var{p4} и цветом(-ами) @var{stl}. При этом цвет может быть один для всей грани, или различным если указаны все 4 цвета. Грань будет нарисована даже если часть ее лежит вне диапазона осей координат. +@end deftypefn + +@anchor{rect} +@deftypefn {Команда MGL} {} rect @code{x1 y1 x2 y2} ['stl'=''] +@deftypefnx {Команда MGL} {} rect @code{x1 y1 z1 x2 y2 z2} ['stl'=''] +Рисует закрашенный прямоугольник (грань) с вершинами @{@var{x1}, @var{y1}, @var{z1}@} и @{@var{x2}, @var{y2}, @var{z2}@} цветом @var{stl}. При этом цвет может быть один для всей грани, или различным для разных вершин если указаны все 4 цвета. Грань будет нарисована даже если часть ее лежит вне диапазона осей координат. +@end deftypefn + +@anchor{facex} +@anchor{facey} +@anchor{facez} +@deftypefn {Команда MGL} {} facex @code{x0 y0 z0 wy wz} ['stl'='' @code{d1=0 d2=0}] +@deftypefnx {Команда MGL} {} facey @code{x0 y0 z0 wx wz} ['stl'='' @code{d1=0 d2=0}] +@deftypefnx {Команда MGL} {} facez @code{x0 y0 z0 wx wy} ['stl'='' @code{d1=0 d2=0}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FaceX (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wy, @code{mreal} wz, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FaceY (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wz, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FaceZ (@code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wy, @code{const char *}stl=@code{"w"}, @code{mreal} d1=@code{0}, @code{mreal} d2=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_facex (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wy, @code{mreal} wz, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@deftypefnx {Функция С} @code{void} mgl_facey (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wz, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@deftypefnx {Функция С} @code{void} mgl_facez (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} wx, @code{mreal} wy, @code{const char *}stl, @code{mreal} d1, @code{mreal} d2) +@end ifclear +Рисует закрашенный прямоугольник (грань) перпендикулярно оси [x,y,z] в точке @{@var{x0}, @var{y0}, @var{z0}@} цветом @var{stl} и шириной @var{wx}, @var{wy}, @var{wz} вдоль соответствующего направления. При этом цвет может быть один для всей грани, или различным для разных вершин если указаны все 4 цвета. Параметры @var{d1}!=0, @var{d2}!=0 задают дополнительный сдвиг последней точки (т.е. рисуют четырехугольник). Грань будет нарисована даже если часть ее лежит вне диапазона осей координат. +@end deftypefn + +@anchor{sphere} +@deftypefn {Команда MGL} {} sphere @code{x0 y0 r} ['col'='r'] +@deftypefnx {Команда MGL} {} sphere @code{x0 y0 z0 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Sphere (@code{mglPoint} p, @code{mreal} r, @code{const char *}stl=@code{"r"}) +@deftypefnx {Функция С} @code{void} mgl_sphere (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} r, @code{const char *}stl) +@end ifclear +Рисует сферу радиуса @var{r} с центром в точке @var{p}=@{@var{x0}, @var{y0}, @var{z0}@} цветом @var{stl}. +@end deftypefn + +@anchor{drop} +@deftypefn {Команда MGL} {} drop @code{x0 y0 dx dy r} ['col'='r' @code{sh=1 asp=1}] +@deftypefnx {Команда MGL} {} drop @code{x0 y0 z0 dx dy dz r} ['col'='r' @code{sh=1 asp=1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Drop (@code{mglPoint} p, @code{mglPoint} d, @code{mreal} r, @code{const char *}col=@code{"r"}, @code{mreal} shift=@code{1}, @code{mreal} ap=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_drop (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{mreal} r, @code{const char *}col, @code{mreal} shift, @code{mreal} ap) +@end ifclear +Рисует каплю радиуса @var{r} в точке @var{p} вытянутую вдоль направления @var{d} цветом @var{col}. Параметр @var{shift} определяет степень вытянутости: @samp{0} -- сфера, @samp{1} -- классическая капля. Параметр @var{ap} определяет относительную ширину капли (аналог "эллиптичности" для сферы). +@end deftypefn + +@anchor{cone} +@deftypefn {Команда MGL} {} cone @code{x1 y1 z1 x2 y2 z2 r1} [@code{r2=-1} 'stl'='' @code{edge=off}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cone (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r1, @code{mreal} r2=@code{-1}, @code{const char *}stl=@code{"B"}, @code{bool} edge=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_cone (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r1, @code{mreal} r2, @code{const char *}stl, @code{int} draw_edge) +@end ifclear +Рисует трубу (или усеченный конус если @var{edge}=@code{false}) между точками @var{p1}, @var{p2} с радиусами на концах @var{r1}, @var{r2}. Если @var{r2}<0, то полагается @var{r2}=@var{r1}. Цвет конуса задается строкой @var{stl}. Параметр @var{stl} может содержать: +@itemize @bullet +@item +@samp{@@} для рисования торцов; +@item +@samp{#} для сетчатой фигуры; +@item +@samp{t} для рисования цилиндра вместо конуса/призмы; +@item +@samp{4}, @samp{6}, @samp{8}, @samp{t} для рисования квадратной, шестиугольной или восьмиугольной призмы вместо конуса. +@end itemize + +@end deftypefn + +@anchor{circle} +@deftypefn {Команда MGL} {} circle @code{x0 y0 r} ['col'='r'] +@deftypefnx {Команда MGL} {} circle @code{x0 y0 z0 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Circle (@code{mglPoint} p, @code{mreal} r, @code{const char *}stl=@code{"r"}) +@end ifclear +Рисует круг радиуса @var{r} с центром в точке @var{p}=@{@var{x0}, @var{y0}, @var{z0}@} цветом @var{stl}. Если @var{col} содержит: @samp{#} то рисуется только граница, @samp{@@} то рисуется граница (вторым цветом из @var{col} или черными). +@end deftypefn + +@anchor{ellipse} +@deftypefn {Команда MGL} {} ellipse @code{x1 y1 x2 y2 r} ['col'='r'] +@deftypefnx {Команда MGL} {} ellipse @code{x1 y1 z1 x2 y2 z2 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Ellipse (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r, @code{const char *}col=@code{"r"}) +@deftypefnx {Функция С} @code{void} mgl_ellipse (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r, @code{const char *}col) +@end ifclear +Рисует круг радиуса @var{r} с фокусами в точках @var{p1}, @var{p2} цветом @var{stl}. Если @var{col} содержит: @samp{#} то рисуется только граница, @samp{@@} то рисуется граница (вторым цветом из @var{col} или черными). +@end deftypefn + +@anchor{rhomb} +@deftypefn {Команда MGL} {} rhomb @code{x1 y1 x2 y2 r} ['col'='r'] +@deftypefnx {Команда MGL} {} rhomb @code{x1 y1 z1 x2 y2 z2 r} ['col'='r'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Rhomb (@code{mglPoint} p1, @code{mglPoint} p2, @code{mreal} r, @code{const char *}col=@code{"r"}) +@deftypefnx {Функция С} @code{void} mgl_rhomb (@code{HMGL} gr, @code{mreal} x1, @code{mreal} y1, @code{mreal} z1, @code{mreal} x2, @code{mreal} y2, @code{mreal} z2, @code{mreal} r, @code{const char *}col) +@end ifclear +Рисует ромб ширины @var{r} с вершинами в точках @var{p1}, @var{p2} цветом @var{stl}. Если @var{col} содержит: @samp{#} то рисуется только граница, @samp{@@} то рисуется граница (вторым цветом из @var{col} или черными). Если @var{col} содержит 3 цвета, то используется градиентная заливка. +@end deftypefn + +@c ################################################################## +@external{} +@node Text printing, Axis and Colorbar, Primitives, MathGL core +@section Вывод текста +@nav{} +@ifclear UDAV +@cindex Puts +@cindex Putsw +@end ifclear +@cindex Text +@cindex fgets + +Функции для вывода текста позволяют вывести строку текста в произвольном месте рисунка, в произвольном направлении и вдоль произвольной кривой. MathGL позволяет использовать произвольное начертание шрифта и многие ТеХ-ие команды (детальнее см. @ref{Font styles}). Все функции вывода текста имеют варианты для 8-bit строк (@code{char *}) и для Unicode строк (@code{wchar_t *}). В первом случае используется конверсия из текущей локали, т.е. иногда вам требуется явно указать локаль с помощью функции @code{setlocale()}. Аргумент @var{size} определяет размер текста: размер шрифта если положителен или относительный размер (=-@var{size}*@code{SetFontSize()}) если отрицателен. Начертание шрифта (STIX, arial, courier, times и др.) можно изменить с помощью функции LoadFont(). @xref{Font settings}. + +Параметры шрифта задаются строкой, которая может содержать символы цвета @samp{wkrgbcymhRGBCYMHW} (см. @ref{Color styles}). Также после символа @samp{:} можно указать символы стиля (@samp{rbiwou}) и/или выравнивания (@samp{LRC}). Стили шрифта: @samp{r} -- прямой, @samp{i} -- курсив, @samp{b} -- жирный, @samp{w} -- контурный, @samp{o} -- надчеркнутый, @samp{u} -- подчеркнутый. По умолчанию используется прямой шрифт. Типы выравнивания: @samp{L} -- по левому краю (по умолчанию), @samp{C} -- по центру, @samp{R} -- по правому краю. Например, строка @samp{b:iC} соответствует курсиву синего цвета с выравниванием по центру. + +Если строка содержит символы @samp{aA}, то текст выводится в абсолютных координатах (полагаются в диапазоне [0,1]). При этом используются координаты относительно рисунка (если указано @samp{A}) или относительно последнего subplot/inplot (если указано @samp{a}). Если строка содержит символ @samp{@@}, то вокруг текста рисуется прямоугольник. + +@sref{Text features} + +@anchor{text} +@deftypefn {Команда MGL} {} text @code{x y} 'text' ['fnt'='' @code{size=-1}] +@deftypefnx {Команда MGL} {} text @code{x y z} 'text' ['fnt'='' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Puts (@code{mglPoint} p, @code{const char *}text, @code{const char *}fnt=@code{":C"}, @code{mreal} size=@code{-1}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Putsw (@code{mglPoint} p, @code{const wchar_t *}text, @code{const char *}fnt=@code{":C"}, @code{mreal} size=@code{-1}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Puts (@code{mreal} x, @code{mreal} y, @code{const char *}text, @code{const char *}fnt=@code{":AC"}, @code{mreal} size=@code{-1}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Putsw (@code{mreal} x, @code{mreal} y, @code{const wchar_t *}text, @code{const char *}fnt=@code{":AC"}, @code{mreal} size=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_puts (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}text, @code{const char *}fnt, @code{mreal} size) +@deftypefnx {Функция С} @code{void} mgl_putsw (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const wchar_t *}text, @code{const char *}fnt, @code{mreal} size) +@end ifclear +Выводит строку @var{text} от точки @var{p} шрифтом определяемым строкой @var{fnt}. Размер шрифта задается параметром @var{size} (по умолчанию @code{-1}). +@end deftypefn + +@deftypefn {Команда MGL} {} text @code{x y dx dy} 'text' ['fnt'=':L' @code{size=-1}] +@deftypefnx {Команда MGL} {} text @code{x y z dx dy dz} 'text' ['fnt'=':L' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Puts (@code{mglPoint} p, @code{mglPoint} d, @code{const char *}text, @code{const char *}fnt=@code{':L'}, @code{mreal} size=@code{-1}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Putsw (@code{mglPoint} p, @code{mglPoint} d, @code{const wchar_t *}text, @code{const char *}fnt=@code{':L'}, @code{mreal} size=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_puts_dir (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{const char *}text, @code{const char *}fnt, @code{mreal} size) +@deftypefnx {Функция С} @code{void} mgl_putsw_dir (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal} dx, @code{mreal} dy, @code{mreal} dz, @code{const wchar_t *}text, @code{const char *}fnt, @code{mreal} size) +@end ifclear +Выводит строку @var{text} от точки @var{p} вдоль направления @var{d}. Параметр @var{fnt} задает стиль текста и указывает выводить текст над линией (@samp{T}) или под ней (@samp{t}). +@end deftypefn + +@anchor{fgets} +@deftypefn {Команда MGL} {} fgets @code{x y} 'fname' [@code{n=0} 'fnt'='' @code{size=-1.4}] +@deftypefnx {Команда MGL} {} fgets @code{x y z} 'fname' [@code{n=0} 'fnt'='' @code{size=-1.4}] +Выводит @var{n}-ую строку файла @var{fname} от точки @{@var{x},@var{y},@var{z}@} шрифтом @var{fnt} и размером @var{size}. По умолчанию используются параметры заданные командой @ref{font}. +@end deftypefn + +@deftypefn {Команда MGL} {} text ydat 'text' ['fnt'=''] +@deftypefnx {Команда MGL} {} text xdat ydat 'text' ['fnt'='' @code{size=-1 zval=nan}] +@deftypefnx {Команда MGL} {} text xdat ydat zdat 'text' ['fnt'='' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}y, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}y, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Text (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const wchar_t *}text, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_text_y (@code{HMGL} gr, @code{HCDT} y, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textw_y (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_text_xy (@code{HCDT} x, @code{HCDT} y, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textw_xy (@code{HCDT} x, @code{HCDT} y, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_text_xyz (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}text, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textw_xyz (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const wchar_t *}text, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Выводит строку @var{text} вдоль кривой @{@var{x}[i], @var{y}[i], @var{z}[i]@} шрифтом @var{fnt}. Строка @var{fnt} может содержать символы: @samp{t} для вывода текста под кривой (по умолчанию), или @samp{T} для вывода текста над кривой. Размеры по 1-ой размерности должны быть одинаковы для всех массивов @code{x.nx=y.nx=z.nx}. Если массив @var{x} не указан, то используется "автоматический" массив со значениями в диапазоне [@var{Min}.x, @var{Max}.x] (см. @ref{Ranges (bounding box)}). Если массив @var{z} не указан, то используется @var{z}[i] = @var{Min}.z. Строка @var{opt} содержит опции команды (см. @ref{Command options}). +@end deftypefn + +@c ################################################################## +@external{} +@node Axis and Colorbar, Legend, Text printing, MathGL core +@section Оси и Colorbar +@nav{} +@cindex Axis +@cindex Box +@cindex Grid +@cindex Colorbar +@cindex Label + +Эти функции рисуют объекты для "измерения" типа осей координат, цветовой таблицы (colorbar), сетку по осям, обрамляющий параллелепипед и подписи по осям координат. См. также см. @ref{Axis settings}. + +@anchor{axis} +@deftypefn {Команда MGL} {} axis ['dir'='xyz' 'stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Axis (@code{const char *}dir=@code{"xyz"}, @code{const char *}stl=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_axis (@code{HMGL} gr, @code{const char *}dir, @code{const char *}stl, @code{const char *}opt) +@end ifclear +Рисует оси координат и метки на них (см. @ref{Axis settings}) в направлениях @samp{xyz}, указанных строкой @var{dir}. Заглавные буквы @samp{XYZ} приведут к расположению меток с другой стороны от оси. Если строка содержит символ @samp{~} или @samp{_}, то подписи меток отображаться не будут. Если строка содержит символ @samp{^}, то инвертируется положение осей по умолчанию. Если строка содержит символ @samp{AKDTVISO}, то будет нарисована соответствующая стрелка на конце оси. Стиль меток и оси(ей) задается строкой @var{stl}. @sref{Axis and ticks} +@end deftypefn + +@anchor{colorbar} +@deftypefn {Команда MGL} {} colorbar ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Colorbar (@code{const char *}sch=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_colorbar (@code{HMGL} gr, @code{const char *}sch) +@end ifclear +Рисует полосу соответствия цвета и числовых значений (colorbar) для цветовой схемы @var{sch} (используется текущая для @code{sch=""}) с краю от графика. Если строка @var{sch} содержит @samp{<>^_}, то положение выбирается: @samp{>} -- справа, @samp{<} -- слева, @samp{^} -- сверху, @samp{_} -- снизу. Если строка содержит @samp{A}, то используются абсолютные координаты (относительно рисунка). Если строка содержит @samp{~}, то подписи меток не рисуются. @sref{Colorbars} +@end deftypefn + +@deftypefn {Команда MGL} {} colorbar vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Colorbar (@code{const mglDataA &}v, @code{const char *}sch=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_colorbar_val (@code{HMGL} gr, @code{HCDT} v, @code{const char *}sch) +@end ifclear +Аналогично предыдущему, но для цветовой схемы без сглаживания с заданными значениями @var{v}. @sref{ContD sample} +@end deftypefn + +@deftypefn {Команда MGL} {} colorbar 'sch' @code{x y [w=1 h=1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Colorbar (@code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w=@code{1}, @code{mreal} h=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_colorbar_ext (@code{HMGL} gr, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w, @code{mreal} h) +@end ifclear +Аналогично первому, но в произвольном месте графика @{@var{x}, @var{y}@} (полагаются в диапазоне [0,1]). Параметры @var{w}, @var{h} задают относительную ширину и высоту colorbar. +@end deftypefn + +@deftypefn {Команда MGL} {} colorbar vdat 'sch' @code{x y [w=1 h=1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Colorbar (@code{const mglDataA &}v, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w=@code{1}, @code{mreal} h=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_colorbar_val_ext (@code{HMGL} gr, @code{HCDT} v, @code{const char *}sch, @code{mreal} x, @code{mreal} y, @code{mreal} w, @code{mreal} h) +@end ifclear +Аналогично предыдущему, но для цветовой схемы @var{sch} без сглаживания с заданными значениями @var{v}. @sref{ContD sample} +@end deftypefn + +@anchor{grid} +@deftypefn {Команда MGL} {} grid ['dir'='xyz' 'pen'='B'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grid (@code{const char *}dir=@code{"xyz"}, @code{const char *}pen=@code{"B"}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_axis_grid (@code{HMGL} gr, @code{const char *}dir, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Рисует линии сетки в направлениях перпендикулярным @var{dir}. Шаг сетки такой же как у меток осей координат. Стиль линий задается параметром @var{pen} (по умолчанию -- сплошная темно синяя линия @samp{B-}). +@end deftypefn + +@anchor{box} +@deftypefn {Команда MGL} {} box ['stl'='k' @code{ticks=on}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Box (@code{const char *}col=@code{""}, @code{bool} ticks=@code{true}) +@deftypefnx {Функция С} @code{void} mgl_box (@code{HMGL} gr, @code{int} ticks) +@deftypefnx {Функция С} @code{void} mgl_box_str (@code{HMGL} gr, @code{const char *}col, @code{int} ticks) +@end ifclear +Рисует ограничивающий параллелепипед цветом @var{col}. Если @var{col} содержит @samp{@@}, то рисуются закрашенные задние грани. При этом первый цвет используется для граней (по умолчанию светло жёлтый), а последний для рёбер и меток. +@end deftypefn + +@anchor{xlabel} +@anchor{ylabel} +@anchor{zlabel} +@anchor{tlabel} +@deftypefn {Команда MGL} {} xlabel 'text' [@code{pos=1}] +@deftypefnx {Команда MGL} {} ylabel 'text' [@code{pos=1}] +@deftypefnx {Команда MGL} {} zlabel 'text' [@code{pos=1}] +@deftypefnx {Команда MGL} {} tlabel 'text' [@code{pos=1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{char} dir, @code{const char *}text, @code{mreal} pos=@code{1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{char} dir, @code{const wchar_t *}text, @code{mreal} pos=@code{1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_label (@code{HMGL} gr, @code{char} dir, @code{const char *}text, @code{mreal} pos, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_labelw (@code{HMGL} gr, @code{char} dir, @code{const wchar_t *}text, @code{mreal} pos, @code{const char *}opt) +@end ifclear +Выводит подпись @var{text} для оси @var{dir}=@samp{x},@samp{y},@samp{z},@samp{t} (где @samp{t} -- ``тернарная'' ось @math{t=1-x-y}). Параметр @var{pos} задает положение подписи: при @var{pos}=0 -- по центру оси, при @var{pos}>0 -- около максимальных значений, при @var{pos}<0 -- около минимальных значений. Опция @code{value} задает дополнительный сдвиг текста. @xref{Text printing}. +@end deftypefn + +@c ################################################################## +@external{} +@node Legend, 1D plotting, Axis and Colorbar, MathGL core +@section Легенда +@nav{} +@cindex Legend +@cindex AddLegend +@cindex ClearLegend +@cindex SetLegendBox +@cindex SetLegendMarks + +Эти функции обеспечивают рисование легенды графика (полезно для @ref{1D plotting}). Запись в легенде состоит из двух строк: одна для стиля линии и маркеров, другая с текстом описания (с включенным разбором TeX-их команд). Можно использовать непосредственно массивы строк, или накопление во внутренние массивы с помощью функции AddLegend() с последующим отображением. Положение легенды можно задать автоматически или вручную. Параметры @var{fnt} и @var{size} задают стиль и размер шрифта (см. @ref{Font settings}). Параметр @var{llen} задает относительную ширину примера линии. Ели стиль линии пустой, то соответствующий текст печатается без отступа. Если строка @var{fnt} содержит символ @samp{A}, то координаты легенды считаются относительно картинки (а не текущего subplot). Если строка @var{fnt} содержит символ @samp{^}, то легенда располагается снаружи от указанных координат. Если строка @var{fnt} содержит символ @samp{#}, то рисуется прямоугольник вокруг легенды. @sref{Legend sample} + +@anchor{legend} +@deftypefn {Команда MGL} {} legend [@code{pos=3} 'fnt'='#'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Legend (@code{int} pos=@code{0x3}, @code{const char *}fnt=@code{"#"}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_legend (@code{HMGL} gr, @code{int} pos, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Рисует легенду из накопленных записей шрифтом @var{fnt} размером @var{size}. Параметр @var{pos} задает положение легенды: @samp{0} -- в нижнем левом углу, @samp{1} -- нижнем правом углу, @samp{2} -- верхнем левом углу, @samp{3} -- верхнем правом углу (по умолчанию). Строка @var{fnt} может содержать вет для прямоугольника (1-ый цвет), для его границы (2-ой цвет) и для текста (последний). Если указано менее 3 цветов, то цвет рёбер будет чёрным (2 и менее цвета), а цвет прямоугольника белым (1 и менее цвета). Прямоугольник рисуется если строка @var{fnt} содержит @samp{#}. Если строка @var{fnt} содержит @samp{-}, то записи располагаются горизонтально. Опция @code{value} задает зазор между примером линии и текстом (по умолчанию 0.1). +@end deftypefn + +@deftypefn {Команда MGL} {} legend @code{x y} ['fnt'='#'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Legend (@code{mreal} x, @code{mreal} y, @code{const char *}fnt=@code{"#"}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_legend_pos (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Рисует легенду из накопленных записей шрифтом @var{fnt} размером @var{size}. Положение легенды задается параметрами @var{x}, @var{y}, которые полагаются нормированными в диапазоне [0,1]. Опция @code{value} задает зазор между примером линии и текстом (по умолчанию 0.1). +@end deftypefn + +@anchor{addlegend} +@deftypefn {Команда MGL} {} addlegend 'text' 'stl' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} AddLegend (@code{const char *}text, @code{const char *}style) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} AddLegend (@code{const wchar_t *}text, @code{const char *}style) +@deftypefnx {Функция С} @code{void} mgl_add_legend (@code{HMGL} gr, @code{const char *}text, @code{const char *}style) +@deftypefnx {Функция С} @code{void} mgl_add_legendw (@code{HMGL} gr, @code{const wchar_t *}text, @code{const char *}style) +@end ifclear +Добавляет описание @var{text} кривой со стилем @var{style} (см. @ref{Line styles}) во внутренний массив записей легенды. +@end deftypefn + +@anchor{clearlegend} +@deftypefn {Команда MGL} {} clearlegend +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ClearLegend () +@deftypefnx {Функция С} @code{void} mgl_clear_legend (@code{HMGL} gr) +@end ifclear +Очищает внутренний массив записей легенды. +@end deftypefn + +@anchor{legendmarks} +@deftypefn {Команда MGL} {} legendmarks @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SetLegendMarks (@code{int} num) +@deftypefnx {Функция С} @code{void} mgl_set_legend_marks (@code{HMGL} gr, @code{int} num) +@end ifclear +Задает число маркеров в легенде. По умолчанию используется 1 маркер. +@end deftypefn + +@c ################################################################## +@external{} +@node 1D plotting, 2D plotting, Legend, MathGL core +@section 1D графики +@nav{} +@cindex Plot +@cindex Radar +@cindex Tens +@cindex Area +@cindex Region +@cindex Stem +@cindex Bars +@cindex Barh +@cindex Chart +@cindex Step +@cindex Torus +@cindex Tube +@cindex Mark +@cindex TextMark +@cindex Error +@cindex BoxPlot +@cindex Candle +@cindex Tape +@cindex Label +@cindex Cones + +Эти функции строят графики для одномерных (1D) массивов. Одномерными считаются массивы, зависящие только от одного параметра (индекса) подобно кривой в параметрической форме @{x(i),y(i),z(i)@}, i=1...n. По умолчанию (если отсутствуют) значения @var{x}[i] равно распределены в диапазоне оси х, и @var{z}[i]=@var{Min}.z. Графики рисуются для каждой строки массива данных если он двумерный. Размер по 1-ой координате @strong{должен быть одинаков} для всех массивов @code{x.nx=y.nx=z.nx}. + +Строка @var{pen} задает цвет и стиль линии и маркеров (см. @ref{Line styles}). По умолчанию (@code{pen=""}) рисуется сплошная линия с текущим цветом из палитры (см. @ref{Palette and colors}). Символ @samp{!} в строке задает использование нового цвета из палитры для каждой точки данных (не для всей кривой, как по умолчанию). Строка @var{opt} задает опции графика (см. @ref{Command options}). @sref{1D samples} + +@anchor{plot} +@deftypefn {Команда MGL} {} plot ydat ['stl'=''] +@deftypefnx {Команда MGL} {} plot xdat ydat ['stl'=''] +@deftypefnx {Команда MGL} {} plot xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Plot (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_plot (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_plot_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_plot_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют ломанную линию по точкам @{@var{x}[i], @var{y}[i], @var{z}[i]@}. См. также @ref{area}, @ref{step}, @ref{stem}, @ref{tube}, @ref{mark}, @ref{error}, @ref{belt}, @ref{tens}, @ref{tape}. @sref{Plot sample} +@end deftypefn + +@anchor{radar} +@deftypefn {Команда MGL} {} radar adat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Radar (@code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_radar (@code{HMGL} gr, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют radar chart, представляющий собой ломанную с вершинами на радиальных линиях (типа ломанной в полярных координатах). Параметр @code{value} в опциях @var{opt} задает дополнительный сдвиг данных (т.е. использование @var{a}+@code{value} вместо @var{a}). Если @var{pen} содержит @samp{#}, то рисуется "сетка" (радиальные линии). См. также @ref{plot}. @sref{Radar sample} +@end deftypefn + +@anchor{step} +@deftypefn {Команда MGL} {} step ydat ['stl'=''] +@deftypefnx {Команда MGL} {} step xdat ydat ['stl'=''] +@deftypefnx {Команда MGL} {} step xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Step (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Step (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Step (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_step (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_step_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_step_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют ступеньки для точек массива. См. также @ref{plot}, @ref{stem}, @ref{tile}, @ref{boxs}. @sref{Step sample} +@end deftypefn + +@anchor{tens} +@deftypefn {Команда MGL} {} tens ydat cdat ['stl'=''] +@deftypefnx {Команда MGL} {} tens xdat ydat cdat ['stl'=''] +@deftypefnx {Команда MGL} {} tens xdat ydat zdat cdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}y, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tens (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tens_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tens_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют ломанную линию по точкам с цветом, определяемым массивом @var{c} (типа графика натяжений). Строка @var{pen} задает цветовую схему (см. @ref{Color scheme}) и стиль линий и/или маркеров (см. @ref{Line styles}). См. также @ref{plot}, @ref{mesh}, @ref{fall}. @sref{Tens sample} +@end deftypefn + +@anchor{tape} +@deftypefn {Команда MGL} {} tape ydat ['stl'=''] +@deftypefnx {Команда MGL} {} tape xdat ydat ['stl'=''] +@deftypefnx {Команда MGL} {} tape xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tape (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tape (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tape_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tape_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют ленты, которые вращаются вокруг кривой @{@var{x}[i], @var{y}[i], @var{z}[i]@} как её нормали. Начальная лента(ы) выбираются в плоскости x-y (для @samp{x} в @var{pen}) и/или y-z (для @samp{x} в @var{pen}). Ширина лент пропорциональна @ref{barwidth}, а также может быть изменена опцией @code{value}. См. также @ref{plot}, @ref{flow}, @ref{barwidth}. @sref{Tape sample} +@end deftypefn + +@anchor{area} +@deftypefn {Команда MGL} {} area ydat ['stl'=''] +@deftypefnx {Команда MGL} {} area xdat ydat ['stl'=''] +@deftypefnx {Команда MGL} {} area xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Area (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Area (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Area (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_area (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_area_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_area_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют ломанную линию между точками и закрашивает её вниз до плоскости осей координат. Градиентная заливка используется если число цветов равно удвоенному число кривых. См. также @ref{plot}, @ref{bars}, @ref{stem}, @ref{region}. @sref{Area sample} +@end deftypefn + +@anchor{region} +@deftypefn {Команда MGL} {} region ydat1 ydat2 ['stl'=''] +@deftypefnx {Команда MGL} {} region xdat ydat1 ydat2 ['stl'=''] +@deftypefnx {Команда MGL} {} region xdat1 ydat1 xdat2 ydat2 ['stl'=''] +@deftypefnx {Команда MGL} {} region xdat1 ydat1 zdat1 xdat2 ydat2 zdat2 ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Region (@code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x1, @code{const mglDataA &}y1, @code{const mglDataA &}x2, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Region (@code{const mglDataA &}x1, @code{const mglDataA &}y1, @code{const mglDataA &}z1, @code{const mglDataA &}x2, @code{const mglDataA &}y2, @code{const mglDataA &}z2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_region (@code{HMGL} gr, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_region_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_region_3d (@code{HMGL} gr, @code{HCDT} x1, @code{HCDT} y1, @code{HCDT} z1, @code{HCDT} x2, @code{HCDT} y2, @code{HCDT} z2, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции закрашивают область между 2 кривыми. Градиентная заливка используется если число цветов равно удвоенному число кривых. Если @var{pen} содержит @samp{i}, то закрашивается только область y1}, то полоски будут выровнены влево, вправо или центрированы относительно их координат. См. также @ref{barh}, @ref{cones}, @ref{area}, @ref{stem}, @ref{chart}, @ref{barwidth}. @sref{Bars sample} +@end deftypefn + +@anchor{barh} +@deftypefn {Команда MGL} {} barh vdat ['stl'=''] +@deftypefnx {Команда MGL} {} barh ydat vdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Barh (@code{const mglDataA &}v, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Barh (@code{const mglDataA &}y, @code{const mglDataA &}v, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_barh (@code{HMGL} gr, @code{HCDT} v, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_barh_xy (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} v, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют горизонтальные полосы (прямоугольники) из точек до плоскости осей координат. Если строка @var{pen} содержит символ @samp{a}, то линии рисуются одна поверх другой. Если строка содержит символ @samp{f}, то рисуется график типа waterfall для определения кумулятивного эффекта последовательности положительных и отрицательных значений. Можно использовать разные цвета для положительных и отрицательных значений если число указанных цветов равно удвоенному числу кривых для построения. Если @var{pen} содержит @samp{<}, @samp{^} или @samp{>}, то полоски будут выровнены влево, вправо или центрированы относительно их координат. См. также @ref{bars}, @ref{barwidth}. @sref{Barh sample} +@end deftypefn + +@anchor{cones} +@deftypefn {Команда MGL} {} cones ydat ['stl'=''] +@deftypefnx {Команда MGL} {} cones xdat ydat ['stl'=''] +@deftypefnx {Команда MGL} {} cones xdat ydat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cones (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cones (@code{HMGL} gr, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cones_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cones_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют конусы из точек до плоскости осей координат. Если строка @var{pen} содержит символ @samp{a}, то линии рисуются одна поверх другой. Можно использовать разные цвета для положительных и отрицательных значений если число указанных цветов равно удвоенному числу кривых для построения. Параметр @var{pen} может содержать: +@itemize @bullet +@item +@samp{@@} для рисования торцов; +@item +@samp{#} для сетчатой фигуры; +@item +@samp{t} для рисования цилиндра вместо конуса/призмы; +@item +@samp{4}, @samp{6}, @samp{8}, @samp{t} для рисования квадратной, шестиугольной или восьмиугольной призмы вместо конуса; +@item +@samp{<}, @samp{^} или @samp{>} для выравнивания конусов влево, вправо или по центру относительно их координат. +@end itemize +См. также @ref{bars}, @ref{cone}, @ref{barwidth}. @sref{Cones sample} +@end deftypefn + + + +@anchor{chart} +@deftypefn {Команда MGL} {} chart adat ['col'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Chart (@code{const mglDataA &}a, @code{const char *}col=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_chart (@code{HMGL} gr, @code{HCDT} a, @code{const char *}col, @code{const char *}opt) +@end ifclear +Рисует цветные полосы (пояса) для массива данных @var{a}. Число полос равно числу строк @var{a} (равно @var{a.ny}). Цвет полос поочерёдно меняется из цветов указанных в @var{col} или в палитре (см. @ref{Palette and colors}). Пробел в цветах соответствует прозрачному "цвету", т.е. если @var{col} содержит пробел(ы), то соответствующая полоса не рисуется. Ширина полосы пропорциональна значению элемента в @var{a}. График строится только для массивов не содержащих отрицательных значений. Если строка @var{col} содержит @samp{#}, то рисуется также чёрная граница полос. График выглядит лучше в (после вращения системы координат) и/или в полярной системе координат (становится Pie chart). @sref{Chart sample} +@end deftypefn + +@anchor{boxplot} +@deftypefn {Команда MGL} {} boxplot adat ['stl'=''] +@deftypefnx {Команда MGL} {} boxplot xdat adat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} BoxPlot (@code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} BoxPlot (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_boxplot (@code{HMGL} gr, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_boxplot_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют boxplot (называемый также как box-and-whisker diagram или как "ящик с усами") в точках @var{x}[i] на плоскости @var{z} = @var{zVal} (по умолчанию @var{z}=@var{Min.z}). Это график, компактно изображающий распределение вероятностей @var{a}[i,j] (минимум, нижний квартиль (Q1), медиана (Q2), верхний квартиль (Q3) и максимум) вдоль второго (j-го) направления. Если @var{pen} содержит @samp{<}, @samp{^} или @samp{>}, то полоски будут выровнены влево, вправо или центрированы относительно их координат. См. также @ref{plot}, @ref{error}, @ref{bars}, @ref{barwidth}. @sref{BoxPlot sample} +@end deftypefn + +@anchor{candle} +@deftypefn {Команда MGL} {} candle vdat1 ['stl'=''] +@deftypefnx {Команда MGL} {} candle vdat1 vdat2 ['stl'=''] +@deftypefnx {Команда MGL} {} candle vdat1 ydat1 ydat2 ['stl'=''] +@deftypefnx {Команда MGL} {} candle vdat1 vdat2 ydat1 ydat2 ['stl'=''] +@deftypefnx {Команда MGL} {} candle xdat vdat1 vdat2 ydat1 ydat2 ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Candle (@code{const mglDataA &}x, @code{const mglDataA &}v1, @code{const mglDataA &}v2, @code{const mglDataA &}y1, @code{const mglDataA &}y2, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_candle (@code{HMGL} gr, @code{HCDT} v1, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_candle_yv (@code{HMGL} gr, @code{HCDT} v1, @code{HCDT} v2, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_candle_xyv (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} v1, @code{HCDT} v2, @code{HCDT} y1, @code{HCDT} y2, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют candlestick chart в точках @var{x}[i]. Этот график показывает прямоугольником ("свечой") диапазон изменения величины. Прозрачная (белая) свеча соответствует росту величины @var{v1}[i]<@var{v2}[i], чёрная -- уменьшению. "Тени" показывают минимальное @var{y1} и максимальное @var{y2} значения. Если @var{v2} отсутствует, то он определяется как @var{v2}[i]=@var{v1}[i+1]. См. также @ref{plot}, @ref{bars}, @ref{ohlc}, @ref{barwidth}. @sref{Candle sample} +@end deftypefn + +@anchor{ohlc} +@deftypefn {Команда MGL} {} ohlc odat hdat ldat cdat ['stl'=''] +@deftypefnx {Команда MGL} {} ohlc xdat odat hdat ldat cdat ['stl'=''] +@ifclear UDAV +@deftypefnx {MМетод класса @code{mglGraph}} @code{void} OHLC (@code{const mglDataA &}o, @code{const mglDataA &}h, @code{const mglDataA &}l, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} OHLC (@code{const mglDataA &}x, @code{const mglDataA &}o, @code{const mglDataA &}h, @code{const mglDataA &}l, @code{const mglDataA &}c, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_ohlc (@code{HMGL} gr, @code{HCDT} o, @code{HCDT} h, @code{HCDT} l, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_ohlc_x (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} o, @code{HCDT} h, @code{HCDT} l, @code{HCDT} c, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют Open-High-Low-Close диаграмму. Этот график содержит вертикальные линии между максимальным @var{h} и минимальным @var{l} значениями, и горизонтальные линии перед/после вертикальной линии для начального @var{o} и конечного @var{c} значений процесса (обычно цены). См. также @ref{candle}, @ref{plot}, @ref{barwidth}. @sref{OHLC sample} +@end deftypefn + + +@anchor{error} +@deftypefn {Команда MGL} {} error ydat yerr ['stl'=''] +@deftypefnx {Команда MGL} {} error xdat ydat yerr ['stl'=''] +@deftypefnx {Команда MGL} {} error xdat ydat xerr yerr ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Error (@code{const mglDataA &}y, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Error (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Error (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ex, @code{const mglDataA &}ey, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_error (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_error_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_error_exy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ex, @code{HCDT} ey, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют размер ошибки @{@var{ex}[i], @var{ey}[i]@} в точках @{@var{x}[i], @var{y}[i]@} на плоскости @var{z} = @var{zVal} (по умолчанию @var{z}=@var{Min.z}). Такой график полезен для отображения ошибки эксперимента, вычислений и пр. Если @var{pen} содержит @samp{@@}, то будут использованы большие полупрозрачные маркеры. См. также @ref{plot}, @ref{mark}. @sref{Error sample} +@end deftypefn + +@anchor{mark} +@deftypefn {Команда MGL} {} mark ydat rdat ['stl'=''] +@deftypefnx {Команда MGL} {} mark xdat ydat rdat ['stl'=''] +@deftypefnx {Команда MGL} {} mark xdat ydat zdat rdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_mark_y (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_mark_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_mark_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют маркеры размером @var{r}[i]*@ref{marksize} (см. @ref{Default sizes}) в точках @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Для рисования маркеров одинакового размера можно использовать функцию @ref{plot} с невидимой линией (со стилем содержащим @samp{ }). Для маркеров с размером как у координат можно использовать @ref{error} со стилем @samp{@@}. См. также @ref{plot}, @ref{textmark}, @ref{error}, @ref{stem}. @sref{Mark sample} +@end deftypefn + +@anchor{textmark} +@deftypefn {Команда MGL} {} textmark ydat 'txt' ['stl'=''] +@deftypefnx {Команда MGL} {} textmark ydat rdat 'txt' ['stl'=''] +@deftypefnx {Команда MGL} {} textmark xdat ydat rdat 'txt' ['stl'=''] +@deftypefnx {Команда MGL} {} textmark xdat ydat zdat rdat 'txt' ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TextMark (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_textmark (@code{HMGL} gr, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmarkw (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmark_yr (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmarkw_yr (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmark_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmarkw_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmark_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_textmarkw_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Функции рисуют текст @var{txt} как маркер с размером пропорциональным @var{r}[i]*@var{marksize} в точках @{@var{x}[i], @var{y}[i], @var{z}[i]@}. См. также @ref{plot}, @ref{mark}, @ref{stem}. @sref{TextMark sample} +@end deftypefn + +@anchor{label} +@deftypefn {Команда MGL} {} label ydat 'txt' ['stl'=''] +@deftypefnx {Команда MGL} {} label xdat ydat 'txt' ['stl'=''] +@deftypefnx {Команда MGL} {} label xdat ydat zdat 'txt' ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Label (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_label (@code{HMGL} gr, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_labelw (@code{HMGL} gr, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_label_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_labelw_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_label_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_labelw_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Функции выводят текстовую строку @var{txt} в точках @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Если строка @var{txt} содержит @samp{%x}, @samp{%y}, @samp{%z} или @samp{%n}, то они будут заменены на значения соответствующих координат или на номер точки. См. также @ref{plot}, @ref{mark}, @ref{textmark}, @ref{table}. @sref{Label sample} +@end deftypefn + +@anchor{table} +@deftypefn {Команда MGL} {} table vdat 'txt' ['stl'='#'] +@deftypefnx {Команда MGL} {} table x y vdat 'txt' ['stl'='#'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Table (@code{const mglDataA &}val, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Table (@code{const mglDataA &}val, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Table (@code{mreal} x, @code{mreal} y, @code{const mglDataA &}val, @code{const char *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Table (@code{mreal} x, @code{mreal} y, @code{const mglDataA &}val, @code{const wchar_t *}txt, @code{const char *}fnt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_table (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{HCDT} val, @code{const char *}txt, @code{const char *}fnt, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tablew (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{HCDT} val, @code{const wchar_t *}txt, @code{const char *}fnt, @code{const char *}opt) +@end ifclear +Рисует таблицу значений массива @var{val} с заголовками @var{txt} (разделенными символом новой строки @samp{\n}) в точке @{@var{x}, @var{y}@} (по умолчанию @{0,0@}) относительно текущего subplot. Если строка @var{fnt} содержит @samp{#}, то рисуются границы ячеек. Если строка @var{fnt} содержит @samp{=}, то ширина всех ячеек одинакова. Если строка @var{fnt} содержит @samp{|}, то ширина таблицы ограничена шириной subplot (эквивалентно опции @samp{value 1}). Опция @code{value} задает ширину таблицы (по умолчанию 1). См. также @ref{label}. @sref{Table sample} +@end deftypefn + +@anchor{tube} +@deftypefn {Команда MGL} {} tube ydat rdat ['stl'=''] +@deftypefnx {Команда MGL} {} tube ydat @code{rval} ['stl'=''] +@deftypefnx {Команда MGL} {} tube xdat ydat rdat ['stl'=''] +@deftypefnx {Команда MGL} {} tube xdat ydat @code{rval} ['stl'=''] +@deftypefnx {Команда MGL} {} tube xdat ydat zdat rdat ['stl'=''] +@deftypefnx {Команда MGL} {} tube xdat ydat zdat @code{rval} ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}y, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tube (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{mreal} r, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tube_r (@code{HMGL} gr, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tube (@code{HMGL} gr, @code{HCDT} y, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tube_xyr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tube_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tube_xyzr (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}pen, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tube_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{mreal} r, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют трубу радиуса @var{r}[i] вдоль кривой между точками @{@var{x}[i], @var{y}[i], @var{z}[i]@}. См. также @ref{plot}. @sref{Tube sample} +@end deftypefn + +@anchor{torus} +@deftypefn {Команда MGL} {} torus rdat zdat ['stl'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Torus (@code{const mglDataA &}r, @code{const mglDataA &}z, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_torus (@code{HMGL} gr, @code{HCDT} r, @code{HCDT} z, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Функции рисуют поверхность вращения кривой @{@var{r}, @var{z}@} относительно оси. Если строка @var{pen} содержит @samp{x} или @samp{z}, то ось вращения будет выбрана в указанном направлении (по умолчанию вдоль оси y). Если @var{sch} содержит @samp{#}, то рисуется сетчатая поверхность. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. См. также @ref{plot}, @ref{axial}. @sref{Torus sample} +@end deftypefn + + + + +@c ################################################################## +@external{} +@node 2D plotting, 3D plotting, 1D plotting, MathGL core +@section 2D графики +@nav{} +@cindex Mesh +@cindex Fall +@cindex Belt +@cindex Surf +@cindex Boxs +@cindex Tile +@cindex Dens +@cindex Cont +@cindex ContF +@cindex ContD +@cindex Axial +@cindex Grad +@cindex Grid + +Эти функции строят графики для двумерных (2D) массивов. Двумерными считаются массивы, зависящие только от двух параметров (индексов) подобно матрице @math{f(x_i,y_j), i=1...n, j=1...m}. По умолчанию (если отсутствуют) значения @var{x}, @var{y} равно распределены в диапазоне осей координат. Младшие размерности массивов @var{x}, @var{y}, @var{z} должны быть одинаковы @code{x.nx=z.nx && y.nx=z.ny} или @code{x.nx=y.nx=z.nx && x.ny=y.ny=z.ny}. Массивы @var{x} и @var{y} могут быть векторами (не матрицами как @var{z}). График строится для каждого z среза данных. Строка @var{sch} задает цветовую схему (см. @ref{Color scheme}). Строка @var{opt} задает опции графика (см. @ref{Command options}). @sref{2D samples} + +@anchor{surf} +@deftypefn {Команда MGL} {} surf zdat ['sch'=''] +@deftypefnx {Команда MGL} {} surf xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует параметрически заданную поверхность @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Если @var{sch} содержит @samp{#}, то рисуется сетка на поверхности. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. См. также @ref{mesh}, @ref{dens}, @ref{belt}, @ref{tile}, @ref{boxs}, @ref{surfc}, @ref{surfa}. @sref{Surf sample} +@end deftypefn + +@anchor{mesh} +@deftypefn {Команда MGL} {} mesh zdat ['sch'=''] +@deftypefnx {Команда MGL} {} mesh xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mesh (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Mesh (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_mesh (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_mesh_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует сетчатую поверхность, заданную параметрически @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. См. также @ref{surf}, @ref{fall}, @ref{meshnum}, @ref{cont}, @ref{tens}. @sref{Mesh sample} +@end deftypefn + +@anchor{fall} +@deftypefn {Команда MGL} {} fall zdat ['sch'=''] +@deftypefnx {Команда MGL} {} fall xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fall (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fall (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_fall (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_fall_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует водопад для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. График удобен для построения нескольких кривых, сдвинутых вглубь друг относительно друга. Если @var{sch} содержит @samp{x}, то линии рисуются вдоль оси x, иначе (по умолчанию) вдоль оси y. См. также @ref{belt}, @ref{mesh}, @ref{tens}, @ref{meshnum}. @sref{Fall sample} +@end deftypefn + +@anchor{belt} +@deftypefn {Команда MGL} {} belt zdat ['sch'=''] +@deftypefnx {Команда MGL} {} belt xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Belt (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Belt (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_belt (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_belt_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует ленточки для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. График может использоваться как 3d обобщение графика @ref{plot}. Если @var{sch} содержит @samp{x}, то ленточки рисуются вдоль оси x, иначе (по умолчанию) вдоль оси y. См. также @ref{fall}, @ref{surf}, @ref{plot}, @ref{meshnum}. @sref{Belt sample} +@end deftypefn + +@anchor{boxs} +@deftypefn {Команда MGL} {} boxs zdat ['sch'=''] +@deftypefnx {Команда MGL} {} boxs xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Boxs (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Boxs (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_boxs (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_boxs_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует вертикальные ящики для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. См. также @ref{surf}, @ref{dens}, @ref{tile}, @ref{step}. @sref{Boxs sample} +@end deftypefn + +@anchor{tile} +@deftypefn {Команда MGL} {} tile zdat ['sch'=''] +@deftypefnx {Команда MGL} {} tile xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tile (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Tile (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tile (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tile_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует плитки для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. График может использоваться как 3d обобщение @ref{step}. См. также @ref{surf}, @ref{boxs}, @ref{step}, @ref{tiles}. @sref{Tile sample} +@end deftypefn + +@anchor{dens} +@deftypefn {Команда MGL} {} dens zdat ['sch'=''] +@deftypefnx {Команда MGL} {} dens xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dens (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{mreal} zVal=@code{NAN}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dens (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{mreal} zVal=@code{NAN}) +@deftypefnx {Функция С} @code{void} mgl_dens (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dens_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует график плотности для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z} = @var{Min}.z. Если @var{sch} содержит @samp{#}, то рисуется сетка. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. См. также @ref{surf}, @ref{cont}, @ref{contf}, @ref{boxs}, @ref{tile}, @code{dens[xyz]}. @sref{Dens sample} +@end deftypefn + +@anchor{cont} +@deftypefn {Команда MGL} {} cont vdat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} cont vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont__val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует линии уровня для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z=v}[k] или при @var{z} = @var{Min}.z если @var{sch} содержит @samp{_}. Линии уровня рисуются для @var{z}[i,j]=@var{v}[k]. Если @var{sch} содержит @samp{t} или @samp{T}, то значения @var{v}[k] будут выведены вдоль контуров над (или под) кривой. См. также @ref{dens}, @ref{contf}, @ref{contd}, @ref{axial}, @code{cont[xyz]}. @sref{Cont sample} +@end deftypefn + +@deftypefn {Команда MGL} {} cont zdat ['sch'=''] +@deftypefnx {Команда MGL} {} cont xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Как предыдущий с вектором @var{v} из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{contf} +@deftypefn {Команда MGL} {} contf vdat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contf vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует закрашенные линии (контуры) уровня для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z=v}[k] или при @var{z} = @var{Min}.z если @var{sch} содержит @samp{_}. Линии уровня рисуются для @var{z}[i,j]=@var{v}[k]. См. также @ref{dens}, @ref{cont}, @ref{contd}, @code{contf[xyz]}. @sref{ContF sample} +@end deftypefn + +@deftypefn {Команда MGL} {} contf zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contf xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContF (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Как предыдущий с вектором @var{v} из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{contd} +@deftypefn {Команда MGL} {} contd vdat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contd vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contd_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contd_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует закрашенные линии (контуры) уровня для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z=v}[k] или при @var{z} = @var{Min}.z если @var{sch} содержит @samp{_}. Линии уровня рисуются для @var{z}[i,j]=@var{v}[k]. Строка @var{sch} задает цвета контуров: цвет k-го контура определяется как k-ый цвет строки. См. также @ref{dens}, @ref{cont}, @ref{contf}. @sref{ContD sample} +@end deftypefn + +@deftypefn {Команда MGL} {} contd zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contd xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContD (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contd (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contd_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Как предыдущий с вектором @var{v} из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{contv} +@deftypefn {Команда MGL} {} contv vdat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contv vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contv_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contv_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует вертикальные цилиндры от линий уровня для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z}=@var{v}[k] или при @var{z} = @var{Min}.z если @var{sch} содержит @samp{_}. Линии уровня рисуются для @var{z}[i,j]=@var{v}[k]. См. также @ref{cont}, @ref{contf}. @sref{ContV sample} +@end deftypefn + +@deftypefn {Команда MGL} {} contv zdat ['sch'=''] +@deftypefnx {Команда MGL} {} contv xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContV (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contv (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contv_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Как предыдущий с вектором @var{v} из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{axial} +@deftypefn {Команда MGL} {} axial vdat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} axial vdat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}v, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_axial_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_axial_xy_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность вращения линии уровня для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Линии уровня рисуются для @var{z}[i,j]=@var{v}[k]. Если @var{sch} содержит @samp{#}, то рисуется сетчатая поверхность. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. Если строка содержит символы @samp{x} или @samp{z}, то ось вращения устанавливается в указанное направление (по умолчанию вдоль @samp{y}). См. также @ref{cont}, @ref{contf}, @ref{torus}, @ref{surf3}. @sref{Axial sample} +@end deftypefn + +@deftypefn {Команда MGL} {} axial zdat ['sch'=''] +@deftypefnx {Команда MGL} {} axial xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{int} num=@code{3}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Axial (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}, @code{int} num=@code{3}) +@deftypefnx {Функция С} @code{void} mgl_axial (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_axial_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Как предыдущий с вектором @var{v} из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 3). +@end deftypefn + +@anchor{grid2} +@deftypefn {Команда MGL} {} grid2 zdat ['sch'=''] +@deftypefnx {Команда MGL} {} grid2 xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grid (@code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grid (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_grid (@code{HMGL} gr, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_grid_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует плоскую сету для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} при @var{z} = @var{Min}.z. См. также @ref{dens}, @ref{cont}, @ref{contf}, @ref{meshnum}. +@end deftypefn + + +@c ################################################################## +@external{} +@node 3D plotting, Dual plotting, 2D plotting, MathGL core +@section 3D графики +@nav{} +@cindex Surf3 +@cindex Dens3 +@cindex Cont3 +@cindex ContF3 +@cindex Grid3 +@cindex Cloud +@cindex Beam + +Эти функции строят графики для трехмерных (3D) массивов. Трёхмерными считаются массивы, зависящие от трёх параметров (индексов) подобно матрице @math{f(x_i,y_j,z_k), i=1...n, j=1...m, k=1...l}. По умолчанию (если отсутствуют) значения @var{x}, @var{y}, @var{z} равно распределены в диапазоне осей координат. Младшие размерности массивов @var{x}, @var{y}, @var{z} должны быть одинаковы @code{x.nx=a.nx && y.nx=a.ny && z.nz=a.nz} или @code{x.nx=y.nx=z.nx=a.nx && x.ny=y.ny=z.ny=a.ny && x.nz=y.nz=z.nz=a.nz}. Массивы @var{x}, @var{y} и @var{z} могут быть векторами (не матрицами как @var{a}). Строка @var{sch} задает цветовую схему (см. @ref{Color scheme}). Строка @var{opt} задает опции графика (см. @ref{Command options}). @sref{3D samples} + + +@anchor{surf3} +@deftypefn {Команда MGL} {} surf3 adat @code{val} ['sch'=''] +@deftypefnx {Команда MGL} {} surf3 xdat ydat zdat adat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3 (@code{mreal} val, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3 (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность уровня для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) при @var{a}(x,y,z)=@var{val}. Если @var{sch} содержит @samp{#}, то рисуется сетчатая поверхность. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. Замечу, что возможно некорректная отрисовка граней вследствие неопределённости построения сечения если поверхность пересекает ячейку данных 2 и более раз. См. также @ref{cloud}, @ref{dens3}, @ref{surf3c}, @ref{surf3a}, @ref{axial}. @sref{Surf3 sample} +@end deftypefn + +@deftypefn {Команда MGL} {} surf3 adat ['sch'=''] +@deftypefnx {Команда MGL} {} surf3 xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Аналогично предыдущему для @var{num} поверхностей уровня равномерно распределённых в диапазоне изменения цвета. Величина @var{num} равна значению параметра @code{value} в опциях @var{opt} (по умолчанию 3). +@end deftypefn + +@anchor{cloud} +@deftypefn {Команда MGL} {} cloud adat ['sch'=''] +@deftypefnx {Команда MGL} {} cloud xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cloud (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cloud (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cloud (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cloud_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует облачный график для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). График состоит из кубиков с цветом и прозрачностью пропорциональной значениям @var{a}. Результат похож на облако -- малые значения прозрачны, а большие нет. Число кубиков зависит от @ref{meshnum}. Если @var{sch} содержит @samp{.}, то будет построен график более низкого качества, но с заметно меньшим использованием памяти. Если @var{sch} содержит @samp{i}, то прозрачность будет инвертирована, т.е. области с более высокими значениями будут более прозрачны, а с более низким -- менее прозрачны. См. также @ref{surf3}, @ref{meshnum}. @sref{Cloud sample} +@end deftypefn + +@anchor{dens3} +@deftypefn {Команда MGL} {} dens3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} dens3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dens3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dens3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_dens3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dens3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Рисует график плотности для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). График рисуется на срезе @var{sVal} в направлении @{@samp{x}, @samp{y}, @samp{z}@}, указанном в строке @var{sch} (по умолчанию, в напралении @samp{y}). Если @var{sch} содержит @samp{#}, то на срезе рисуется сетка. См. также @ref{cont3}, @ref{contf3}, @ref{dens}, @ref{grid3}. @sref{Dens3 sample} +@end deftypefn + +@anchor{cont3} +@deftypefn {Команда MGL} {} cont3 vdat adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} cont3 vdat xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont3_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont3_xyz_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Рисует линии уровня для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Линии рисуются для значений из массива @var{v} на срезе @var{sVal} в направлении @{@samp{x}, @samp{y}, @samp{z}@}, указанном в строке @var{sch} (по умолчанию, в напралении @samp{y}). Если @var{sch} содержит @samp{#}, то на срезе рисуется сетка. Если @var{sch} содержит @samp{t} или @samp{T}, то значения @var{v}[k] будут выведены вдоль контуров над (или под) кривой. См. также @ref{dens3}, @ref{contf3}, @ref{cont}, @ref{grid3}. @sref{Cont3 sample} +@end deftypefn + +@deftypefn {Команда MGL} {} cont3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} cont3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Cont3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Аналогично предыдущему для @var{num} линий уровня равномерно распределённых в диапазоне изменения цвета. Величина @var{num} равна значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{contf3} +@deftypefn {Команда MGL} {} contf3 vdat adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} contf3 vdat xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}v, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf3_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf3_xyz_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Рисует закрашенные линии (контуры) уровня для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). Линии рисуются для значений из массива @var{v} на срезе @var{sVal} в направлении @{@samp{x}, @samp{y}, @samp{z}@}, указанном в строке @var{sch} (по умолчанию, в напралении @samp{y}). Если @var{sch} содержит @samp{#}, то на срезе рисуется сетка. См. также @ref{dens3}, @ref{cont3}, @ref{contf}, @ref{grid3}. @sref{ContF3 sample} +@end deftypefn + +@deftypefn {Команда MGL} {} contf3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} contf3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Contf3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Аналогично предыдущему для @var{num} закрашенных линий (контуров) уровня равномерно распределённых в диапазоне изменения цвета. Величина @var{num} равна значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). +@end deftypefn + +@anchor{grid3} +@deftypefn {Команда MGL} {} grid3 adat ['sch'='' @code{sval=-1}] +@deftypefnx {Команда MGL} {} grid3 xdat ydat zdat adat ['sch'='' @code{sval=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grid3 (@code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grid3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_grid3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_grid3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Рисует сетку для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]). График рисуется на срезе @var{sVal} в направлении @{@samp{x}, @samp{y}, @samp{z}@}, указанном в строке @var{sch} (по умолчанию, в напралении @samp{y}). См. также @ref{cont3}, @ref{contf3}, @ref{dens3}, @ref{grid2}, @ref{meshnum}. +@end deftypefn + +@anchor{beam} +@deftypefn {Команда MGL} {} beam tr g1 g2 adat @code{rval} ['sch'='' @code{flag=0 num=3}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Beam (@code{const mglDataA &}tr, @code{const mglDataA &}g1, @code{const mglDataA &}g2, @code{const mglDataA &}a, @code{mreal} r, @code{const char *}stl=@code{""}, @code{int} flag=@code{0}, @code{int} num=@code{3}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Beam (@code{mreal} val, @code{const mglDataA &}tr, @code{const mglDataA &}g1, @code{const mglDataA &}g2, @code{const mglDataA &}a, @code{mreal} r, @code{const char *}stl=@code{""}, @code{int} flag=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_beam (@code{HMGL} gr, @code{HCDT} tr, @code{HCDT} g1, @code{HCDT} g2, @code{HCDT} a, @code{mreal} r, @code{const char *}stl, @code{int} flag, @code{int} num) +@deftypefnx {Функция С} @code{void} mgl_beam_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} tr, @code{HCDT} g1, @code{HCDT} g2, @code{HCDT} a, @code{mreal} r, @code{const char *}stl, @code{int} flag) +@end ifclear +Рисует поверхность уровня для 3d массива @var{a} при постоянном значении @var{a}=@var{val}. Это специальный тип графика для @var{a} заданного в сопровождающей системе координат вдоль кривой @var{tr} с ортами @var{g1}, @var{g2} и с поперечным размером @var{r}. Переменная @var{flag} -- битовый флаг: @samp{0x1} - рисовать в сопровождающих (не лабораторных) координатах; @samp{0x2} - рисовать проекцию на плоскость @math{\rho-z}; @samp{0x4} - рисовать нормированное в каждом сечении поле. Размеры массивов по 1-му индексу @var{tr}, @var{g1}, @var{g2} должны быть nx>2. Размеры массивов по 2-му индексу @var{tr}, @var{g1}, @var{g2} и размер по 3-му индексу массива @var{a} должны быть одинаковы. См. также @ref{surf3}. +@end deftypefn + + +@c ################################################################## +@external{} +@node Dual plotting, Vector fields, 3D plotting, MathGL core +@section Парные графики +@nav{} +@cindex SurfC +@cindex SurfA +@cindex Surf3C +@cindex Surf3A +@cindex TileS +@cindex Map +@cindex STFA + +Эти функции строят графики для двух связанных массивов. Есть несколько основных типов 3D графиков: поверхность и поверхность уровня с окраской по второму массиву (SurfC, Surf3C), поверхность и поверхность уровня с прозрачностью по второму массиву (SurfA, Surf3A), плитки переменного размера (TileS), диаграмма точечного отображения (Map), STFA диаграмма (STFA). По умолчанию (если отсутствуют) значения @var{x}, @var{y} (и @var{z} для @code{Surf3C, Surf3A}) равно распределены в диапазоне осей координат. Младшие размерности массивов @var{x}, @var{y}, @var{z}, @var{c} должны быть одинаковы @code{x.nx=a.nx && y.nx=a.ny && z.nz=a.nz} или @code{x.nx=y.nx=z.nx=a.nx && x.ny=y.ny=z.ny=a.ny && x.nz=y.nz=z.nz=a.nz}. Массивы @var{x}, @var{y} (и @var{z} для @code{Surf3C, Surf3A}) могут быть векторами (не матрицами как @var{c}). Строка @var{sch} задает цветовую схему (см. @ref{Color scheme}). Строка @var{opt} задает опции графика (см. @ref{Command options}). + + +@anchor{surfc} +@deftypefn {Команда MGL} {} surfc zdat cdat ['sch'=''] +@deftypefnx {Команда MGL} {} surfc xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SurfC (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SurfC (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surfc (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surfc_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует параметрически заданную поверхность @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} с цветом, заданным массивом @var{c}[i,j]. Если @var{sch} содержит @samp{#}, то на поверхности рисуется сетка. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. Размерность массивов @var{z} и @var{c} должна быть одинакова. График строится для каждого z среза данных. См. также @ref{surf}, @ref{surfa}, @ref{surf3c}. @sref{SurfC sample} +@end deftypefn + +@anchor{surf3c} +@deftypefn {Команда MGL} {} surf3c adat cdat @code{val} ['sch'=''] +@deftypefnx {Команда MGL} {} surf3c xdat ydat zdat adat cdat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3C (@code{mreal} val, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3C (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3c_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3c_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность уровня для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) при @var{a}(x,y,z)=@var{val}. Аналогично @ref{surf3}, но цвет задается массивом @var{c}. Если @var{sch} содержит @samp{#}, то рисуется сетчатая поверхность. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. См. также @ref{surf3}, @ref{surfc}, @ref{surf3a}. @sref{Surf3C sample} +@end deftypefn + +@deftypefn {Команда MGL} {} surf3c adat cdat ['sch'=''] +@deftypefnx {Команда MGL} {} surf3c xdat ydat zdat adat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3C (@code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3C (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3c (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3c_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Аналогично предыдущему для @var{num} поверхностей уровня равномерно распределённых в диапазоне изменения цвета. Величина @var{num} равна значению параметра @code{value} в опциях @var{opt} (по умолчанию 3). +@end deftypefn + + +@anchor{surfa} +@deftypefn {Команда MGL} {} surfa zdat cdat ['sch'=''] +@deftypefnx {Команда MGL} {} surfa xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SurfA (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} SurfA (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surfa (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surfa_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует параметрически заданную поверхность @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@} с прозрачностью, заданной массивом @var{c}[i,j]. Если @var{sch} содержит @samp{#}, то на поверхности рисуется сетка. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. Размерность массивов @var{z} и @var{c} должна быть одинакова. График строится для каждого z среза данных. См. также @ref{surf}, @ref{surfc}, @ref{surf3a}. @sref{SurfA sample} +@end deftypefn + +@anchor{surf3a} +@deftypefn {Команда MGL} {} surf3a adat cdat @code{val} ['sch'=''] +@deftypefnx {Команда MGL} {} surf3a xdat ydat zdat adat cdat @code{val} ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3A (@code{mreal} val, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3A (@code{mreal} val, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3a_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3a_xyz_val (@code{HMGL} gr, @code{mreal} val, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность уровня для 3d массива, заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) при @var{a}(x,y,z)=@var{val}. Аналогично @ref{surf3}, но прозрачность задается массивом @var{c}. Если @var{sch} содержит @samp{#}, то рисуется сетчатая поверхность. Если @var{sch} содержит @samp{.}, то рисуется поверхность из точек. См. также @ref{surf3}, @ref{surfc}, @ref{surf3a}. @sref{Surf3A sample} +@end deftypefn + +@deftypefn {Команда MGL} {} surf3a adat cdat ['sch'=''] +@deftypefnx {Команда MGL} {} surf3a xdat ydat zdat adat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3A (@code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Surf3A (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_surf3a (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_surf3a_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Аналогично предыдущему для @var{num} поверхностей уровня равномерно распределённых в диапазоне изменения цвета. При этом массив @var{c} может быть вектором со значениями прозрачности и @var{num}=@var{c}.nx. В противном случае величина @var{num} равна значению параметра @code{value} в опциях @var{opt} (по умолчанию 3). +@end deftypefn + +@anchor{tiles} +@deftypefn {Команда MGL} {} tiles zdat rdat ['sch'=''] +@deftypefnx {Команда MGL} {} tiles xdat ydat zdat rdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TileS (@code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TileS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}r, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tiles (@code{HMGL} gr, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tiles_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} r, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует плитки для параметрически заданной поверхности @{@var{x}[i,j], @var{y}[i,j], @var{z}[i,j]@}. Аналогично Tile(), но размер плиток задается массивов @var{r}. Это создает эффект "прозрачности" при экспорте в файлы EPS. График строится для каждого z среза данных. См. также @ref{surfa}, @ref{tile}. @sref{TileS sample} +@end deftypefn + +@anchor{map} +@deftypefn {Команда MGL} {} map udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} map xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Map (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Map (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_map (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_map_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует точечное отображение для матриц @{@var{ax}, @var{ay} @} параметрически зависящих от координат @var{x}, @var{y}. Исходное положение ячейки задает ее цвет. Высота пропорциональна якобиану J(ax,ay). График является аналогом диаграммы Арнольда ??? Если @var{sch} содержит @samp{.}, то цветные точки рисуются в узлах матриц (полезно для "запутанного" отображения), иначе рисуются грани. @sref{Mapping visualization} +@end deftypefn + +@anchor{stfa} +@deftypefn {Команда MGL} {} stfa re im @code{dn} ['sch'=''] +@deftypefnx {Команда MGL} {} stfa xdat ydat re im @code{dn} ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} STFA (@code{const mglDataA &}re, @code{const mglDataA &}im, @code{int} dn, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} STFA (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}re, @code{const mglDataA &}im, @code{int} dn, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_stfa (@code{HMGL} gr, @code{HCDT} re, @code{HCDT} im, @code{int} dn, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_stfa_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} re, @code{HCDT} im, @code{int} dn, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует спектрограмму комплексного массива @var{re}+i*@var{im} для Фурье размером @var{dn} точек в плоскости @var{z}=@var{Min}.z. Параметр @var{dn} -- любое чётное число. Например в 1D случае, результатом будет график плотности от массива @math{res[i,j]=|\sum_d^dn exp(I*j*d)*(re[i*dn+d]+I*im[i*dn+d])|/dn} размером @{int(nx/dn), dn, ny@}. Массивы @var{re}, @var{im} параметрически зависят от координат @var{x}, @var{y}. Все размеры массивов @var{re} и @var{im} должны быть одинаковы. Младшие размерности массивов @var{x}, @var{y}, @var{re} должны быть одинаковы. Массивы @var{x} и @var{y} могут быть векторами (не матрицами как @var{re}). @sref{STFA sample} +@end deftypefn + + +@c ################################################################## +@external{} +@node Vector fields, Other plotting, Dual plotting, MathGL core +@section Векторные поля +@nav{} +@cindex Traj +@cindex Vect +@cindex Dew +@cindex Flow +@cindex FlowP +@cindex Pipe + +Эти функции рисуют графики для 2D и 3D векторных полей. Есть несколько типов графиков: просто векторное поле (Vect), вектора вдоль траектории (Traj), векторное поле каплями (Dew), нити тока (Flow, FlowP), трубки тока (Pipe). По умолчанию (если отсутствуют) значения @var{x}, @var{y} и @var{z} равно распределены в диапазоне осей координат. Младшие размерности массивов @var{x}, @var{y}, @var{z} и @var{ax} должны быть одинаковы. Размеры массивов @var{ax}, @var{ay} и @var{az} должны быть одинаковы. Массивы @var{x}, @var{y} и @var{z} могут быть векторами (не матрицами как @var{ax}). Строка @var{sch} задает цветовую схему (см. @ref{Color scheme}). Строка @var{opt} задает опции графика (см. @ref{Command options}). + +@anchor{traj} +@deftypefn {Команда MGL} {} traj xdat ydat udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} traj xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Traj (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Traj (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_traj_xyz (@code{HMGL} gr, @code{HCDT}x, @code{HCDT}y, @code{HCDT}z, @code{HCDT}ax, @code{HCDT}ay, @code{HCDT}az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_traj_xy (@code{HMGL} gr, @code{HCDT}x, @code{HCDT}y, @code{HCDT}ax, @code{HCDT}ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует вектора @{@var{ax}, @var{ay}, @var{az}@} вдоль кривой @{@var{x}, @var{y}, @var{z}@}. Длина векторов пропорциональна @math{\sqrt@{ax^2+ay^2+az^2@}}. Строка @var{pen} задает цвет (см. @ref{Line styles}). По умолчанию (@code{pen=""}) используется текущий цвет из палитры (см. @ref{Palette and colors}). Опция @code{value} задает фактор длины векторов (если не нуль) или выбирать длину пропорционально расстоянию между точками кривой (если @code{value=0}). Размер по 1-му индексу должен быть 2 или больше. График рисуется для каждой строки если один из массивов матрица. См. также @ref{vect}. @sref{Traj sample} +@end deftypefn + +@anchor{vect} +@deftypefn {Команда MGL} {} vect udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} vect xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_vect_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_vect_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует векторное поле @{@var{ax}, @var{ay}@} параметрически зависящее от координат @var{x}, @var{y} на плоскости при @var{z}=@var{Min}.z. Длина и цвет векторов пропорциональна @math{\sqrt@{ax^2+ay^2@}}. Число рисуемых векторов зависит от @ref{meshnum}. Вид стрелок/штрихов может быть изменён символами: +@itemize @bullet +@item +@samp{f} для стрелок одинаковой длины, +@item +@samp{>}, @samp{<} для стрелок начинающихся или заканчивающихся в ячейке сетки (по умолчанию центрированы), +@item +@samp{.} для рисования штрихов с точкой в начале вместо стрелок, +@item +@samp{=} для использования градиента цвета вдоль стрелок. +@end itemize +См. также @ref{flow}, @ref{dew}. @sref{Vect sample} +@end deftypefn + +@deftypefn {Команда MGL} {} vect udat vdat wdat ['sch'=''] +@deftypefnx {Команда MGL} {} vect xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_vect_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_vect_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Это 3d версия графика. Здесь массивы @var{ax}, @var{ay}, @var{az} должны трёхмерными тензорами и длина вектора пропорциональна @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + +@anchor{vect3} +@deftypefn {Команда MGL} {} vect3 udat vdat wdat ['sch'='' sval] +@deftypefnx {Команда MGL} {} vect3 xdat ydat zdat udat vdat wdat ['sch'='' sval] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect3 (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Vect3 (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} sVal=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_vect3 (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_vect3_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Рисует 3D векторное поле @{@var{ax}, @var{ay}, @var{az}@} параметрически зависящее от координат @var{x}, @var{y}, @var{z}. График рисуется на срезе @var{sVal} в направлении @{@samp{x}, @samp{y}, @samp{z}@}, указанном в строке @var{sch} (по умолчанию, в напралении @samp{y}). Длина и цвет векторов пропорциональна @math{\sqrt@{ax^2+ay^2+az^2@}}. Число рисуемых векторов зависит от @ref{meshnum}. Вид стрелок/штрихов может быть изменён символами: +@itemize @bullet +@item +@samp{f} для стрелок одинаковой длины, +@item +@samp{>}, @samp{<} для стрелок начинающихся или заканчивающихся в ячейке сетки (по умолчанию центрированы), +@item +@samp{.} для рисования штрихов с точкой в начале вместо стрелок, +@item +@samp{=} для использования градиента цвета вдоль стрелок. +@end itemize +См. также @ref{vect}, @ref{flow}, @ref{dew}. @sref{Vect sample} +@end deftypefn + +@anchor{dew} +@deftypefn {Команда MGL} {} dew udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} dew xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dew (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dew (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_dew (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dew_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует капли для векторного поля @{@var{ax}, @var{ay}@}, параметрически зависящего от координат @var{x}, @var{y} при @var{z}=@var{Min}.z. Замечу, что график требует много памяти и процессорного времени для своего создания! Цвет капель пропорционален @math{\sqrt@{ax^2+ay^2@}}. Число капель определяется @ref{meshnum}. См. также @ref{vect}. @sref{Dew sample} +@end deftypefn + +@anchor{flow} +@deftypefn {Команда MGL} {} flow udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} flow xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_flow_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_flow_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует нити тока для векторного поля @{@var{ax}, @var{ay}@}, параметрически зависящего от координат @var{x}, @var{y} на плоскости при @var{z} = @var{Min}.z. Число нитей пропорционально значению опции @code{value} (по умолчанию 5). Цвет нитей пропорционален @math{\sqrt@{ax^2+ay^2@}}. Строка @var{sch} может содержать +@itemize @bullet +@item +цветовую схему -- тёплые цвета соответствуют нормальному току (типа стока), холодные цвета соответствуют обратному току (типа источника); +@item +@samp{#} для использования нитей, начинающихся только на границе; +@item +@samp{v} для рисования стрелок на нитях; +@item +@samp{x}, @samp{z} для рисования лент нормалей, начинающихся в плоскостях x-y и y-z соответственно. +@end itemize +См. также @ref{pipe}, @ref{vect}, @ref{tape}, @ref{barwidth}. @sref{Flow sample} +@end deftypefn + +@deftypefn {Команда MGL} {} flow udat vdat wdat ['sch'=''] +@deftypefnx {Команда MGL} {} flow xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Flow (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_flow_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_flow_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Это 3d версия графика. Здесь массивы должны трёхмерными тензорами и цвет пропорционален @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + +@deftypefn {Команда MGL} {} flow @code{x0 y0} udat vdat ['sch'=''] +@deftypefnx {Команда MGL} {} flow @code{x0 y0} xdat ydat udat vdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_flowp_2d (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_flowp_xy (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Аналогично @ref{flow}, но рисует одну нить из точки @var{p0}=@{@var{x0},@var{y0},@var{z0}@}. +@end deftypefn + +@deftypefn {Команда MGL} {} flow @code{x0 y0 z0} udat vdat wdat ['sch'=''] +@deftypefnx {Команда MGL} {} flow @code{x0 y0 z0} xdat ydat zdat udat vdat wdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FlowP (@code{mglPoint} p0, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_flowp_3d (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_flowp_xyz (@code{HMGL} gr, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Это 3d версия графика. +@end deftypefn + +@anchor{grad} +@deftypefn {Команда MGL} {} grad pdat ['sch'=''] +@deftypefnx {Команда MGL} {} grad xdat ydat pdat ['sch'=''] +@deftypefnx {Команда MGL} {} grad xdat ydat zdat pdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Grad (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}phi, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_grad (@code{HMGL} gr, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_grad_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_grad_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} phi, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует линии градиента скалярного поля @var{phi}[i,j] (или @var{phi}[i,j,k] в 3d случае) заданного параметрически @{@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]@}. Число линий пропорционально значению опции @code{value} (по умолчанию 5). См. также @ref{dens}, @ref{cont}, @ref{flow}. +@end deftypefn + +@anchor{pipe} +@deftypefn {Команда MGL} {} pipe udat vdat ['sch'='' @code{r0=0.05}] +@deftypefnx {Команда MGL} {} pipe xdat ydat udat vdat ['sch'='' @code{r0=0.05}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_pipe_2d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_pipe_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} ax, @code{HCDT} ay, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@end ifclear +Рисует трубки тока для векторного поля @{@var{ax}, @var{ay}@}, параметрически зависящего от координат @var{x}, @var{y} на плоскости при @var{z} = @var{Min}.z. Число трубок пропорционально значению опции @code{value}. Цвет и радиус трубок пропорционален @math{\sqrt@{ax^2+ay^2@}}. Тёплые цвета соответствуют нормальному току (типа стока). Холодные цвета соответствуют обратному току (типа источника). Параметр @var{r0} задает радиус трубок. При @var{r0}<0 радиус трубок обратно пропорционален их амплитуде. См. также @ref{flow}, @ref{vect}. @sref{Pipe sample} +@end deftypefn + +@deftypefn {Команда MGL} {} pipe udat vdat wdat ['sch'='' @code{r0=0.05}] +@deftypefnx {Команда MGL} {} pipe xdat ydat zdat udat vdat wdat ['sch'='' @code{r0=0.05}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Pipe (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}ax, @code{const mglDataA &}ay, @code{const mglDataA &}az, @code{const char *}sch=@code{""}, @code{mreal} r0=@code{0.05}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_pipe_3d (@code{HMGL} gr, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_pipe_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} ax, @code{HCDT} ay, @code{HCDT} az, @code{const char *}sch, @code{mreal} r0, @code{const char *}opt) +@end ifclear +Это 3d версия графика. Здесь массивы @var{ax}, @var{ay}, @var{az} должны трёхмерными тензорами и цвет пропорционален @math{\sqrt@{ax^2+ay^2+az^2@}}. +@end deftypefn + + +@c ################################################################## +@external{} +@node Other plotting, Nonlinear fitting, Vector fields, MathGL core +@section Прочие графики +@nav{} +@cindex DensXYZ +@cindex ContXYZ +@cindex ContFXYZ +@cindex Dots +@cindex Crust +@cindex TriPlot +@cindex TriCont +@cindex QuadPlot +@cindex FPlot +@cindex FSurf + +Это функции, не относящиеся к какой-то специальной категории. Сюда входят функции построения графиков по текстовым формулам (FPlot и FSurf), рисования поверхностей из треугольников и четырёхугольников (TriPlot, TriCont, QuadPlot), произвольных точек в пространстве (Dots) и реконструкции по ним поверхности (Crust), графики плотности и линии уровня на плоскостях, перпендикулярных осям x, y или z (Dens[XYZ], Cont[XYZ], ContF[XYZ]). Каждый тип графика имеет похожий интерфейс. Есть версия для рисования одного массива с автоматическими координатами и версия для параметрически заданного массива. Параметры цветовой схемы задаются строкой. @xref{Color scheme}. + +@anchor{densz} @anchor{densy} @anchor{densx} @anchor{DensXYZ} +@deftypefn {Команда MGL} {} densx dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} densy dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} densz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} DensX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} DensY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} DensZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_dens_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dens_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dens_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Эти функции рисуют график плотности на x, y или z плоскостях. Если @var{a} -- 3d массив, то выполняется интерполяция к заданному срезу @var{sVal}. Функции полезны для создания проекций 3D массивов на оси координат. См. также @ref{ContXYZ}, @ref{ContFXYZ}, @ref{dens}, @ref{Data manipulation}. @sref{Dens projection sample} +@end deftypefn + +@anchor{contz} @anchor{conty} @anchor{contx} @anchor{ContXYZ} +@deftypefn {Команда MGL} {} contx dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} conty dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} contz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Эти функции рисуют линии уровня на x, y или z плоскостях. Если @var{a} -- 3d массив, то выполняется интерполяция к заданному срезу @var{sVal}. Опция @code{value} задает число контуров. Функции полезны для создания проекций 3D массивов на оси координат. См. также @ref{ContFXYZ}, @ref{DensXYZ}, @ref{cont}, @ref{Data manipulation}. @sref{Cont projection sample} +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} ContX (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContY (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContZ (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_cont_x_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_y_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_cont_z_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +Аналогично предыдущему с ручным заданием значений для линий уровня. +@end deftypefn +@end ifclear + +@anchor{contfz} @anchor{contfy} @anchor{contfx} @anchor{ContFXYZ} +@deftypefn {Команда MGL} {} contfx dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} contfy dat ['sch'='' @code{sval=nan}] +@deftypefnx {Команда MGL} {} contfz dat ['sch'='' @code{sval=nan}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContFX (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContFY (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContFZ (@code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf_x (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_z (@code{HMGL} gr, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@end ifclear +Эти функции рисуют закрашенные контуры уровня на x, y или z плоскостях. Если @var{a} -- 3d массив, то выполняется интерполяция к заданному срезу @var{sVal}. Опция @code{value} задает число контуров. Функции полезны для создания проекций 3D массивов на оси координат. См. также @ref{ContFXYZ}, @ref{DensXYZ}, @ref{cont}, @ref{Data manipulation}. @sref{ContF projection sample} +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{void} ContFX (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContFY (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} ContFZ (@code{const mglDataA &}v, @code{const mglDataA &}a, @code{const char *}stl=@code{""}, @code{mreal} sVal=@code{NAN}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_contf_x_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_y_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_contf_z_val (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} a, @code{const char *}stl, @code{mreal} sVal, @code{const char *}opt) +Аналогично предыдущему с ручным заданием значений для линий уровня. +@end deftypefn +@end ifclear + +@anchor{fplot} +@deftypefn {Команда MGL} {} fplot 'y(x)' ['pen'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FPlot (@code{const char *}eqY, @code{const char *}pen=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_fplot (@code{HMGL} gr, @code{const char *}eqY, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Рисует функцию @samp{eqY(x)} в плоскости @var{z}=@var{Min}.z с координатой @samp{x} в диапазоне [@var{Min}.x, @var{Max}.x]. Опция @code{value} задает начальное число точек. См. также @ref{plot}. +@end deftypefn + +@deftypefn {Команда MGL} {} fplot 'x(t)' 'y(t)' 'z(t)' ['pen'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FPlot (@code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}pen, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_fplot_xyz (@code{HMGL} gr, @code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}pen, @code{const char *}opt) +@end ifclear +Рисует параметрическую кривую @{@samp{eqX(t)}, @samp{eqY(t)}, @samp{eqZ(t)}@}, где координата @samp{t} меняется в диапазоне [0, 1]. Опция @code{value} задает начальное число точек. См. также @ref{plot}. +@end deftypefn + +@anchor{fsurf} +@deftypefn {Команда MGL} {} fsurf 'z(x,y)' ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FSurf (@code{const char *}eqZ, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}); +@deftypefnx {Функция С} @code{void} mgl_fsurf (@code{HMGL} gr, @code{const char *}eqZ, @code{const char *}sch, @code{const char *}opt); +@end ifclear +Рисует поверхность @samp{eqY(x,y)} с координатами @samp{x}, @samp{y} в диапазоне @code{xrange, yrange}. Опция @code{value} задает число точек. См. также @ref{surf}. +@end deftypefn + +@deftypefn {Команда MGL} {} fsurf 'x(u,v)' 'y(u,v)' 'z(u,v)' ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} FSurf (@code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_fsurf_xyz (@code{HMGL} gr, @code{const char *}eqX, @code{const char *}eqY, @code{const char *}eqZ, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует параметрическую поверхность @{@samp{eqX(u,v)}, @samp{eqY(u,v)}, @samp{eqZ(u,v)}@}, где координаты @samp{u}, @samp{v} меняются в диапазоне [0, 1]. Опция @code{value} задает число точек. См. также @ref{surf}. +@end deftypefn + +@anchor{triplot} +@deftypefn {Команда MGL} {} triplot idat xdat ydat ['sch'=''] +@deftypefnx {Команда MGL} {} triplot idat xdat ydat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} triplot idat xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_triplot_xy (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_triplot_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_triplot_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность из треугольников. Вершины треугольников задаются индексами @var{id} в массиве точек @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Строка @var{sch} задает цветовую схему. Если строка содержит @samp{#}, то рисуется сетчатая поверхность. Размер по 1-му индексу массива @var{id} должен быть 3 или больше. Массивы @var{x}, @var{y}, @var{z} должны иметь одинаковые размеры. Массив @var{c} задает цвет треугольников (если @var{id}.ny=@var{c}.nx) или цвет вершин (если @var{x}.nx=@var{c}.nx). См. также @ref{dots}, @ref{crust}, @ref{quadplot}, @ref{triangulation}. @sref{TriPlot and QuadPlot} +@end deftypefn + +@anchor{tricont} +@deftypefn {Команда MGL} {} tricont vdat idat xdat ydat zdat cdat ['sch'=''] +@deftypefnx {Команда MGL} {} tricont vdat idat xdat ydat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} tricont idat xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriCont (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriCont (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriContV (@code{const mglDataA &}v, @code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} TriContV (@code{const mglDataA &}v, @code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_tricont_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tricont_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tricont_xyzcv (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_tricont_xyzv (@code{HMGL} gr, @code{HCDT} v, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует линии уровня поверхности из треугольников при @var{z}=@var{v}[k] (или при @var{z} = @var{Min}.z если @var{sch} содержит @samp{_}). Вершины треугольников задаются индексами @var{id} в массиве точек @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Если аргуент @var{v} не задан, то используется массив из @var{num} элементов равно распределенных в диапазоне изменения цвета. Здесь @var{num} равен значению параметра @code{value} в опциях @var{opt} (по умолчанию 7). Строка @var{sch} задает цветовую схему. Размер по 1-му индексу массива @var{id} должен быть 3 или больше. Массивы @var{x}, @var{y}, @var{z} должны иметь одинаковые размеры. Массив @var{c} задает цвет треугольников (если @var{id}.ny=@var{c}.nx) или цвет вершин (если @var{x}.nx=@var{c}.nx). См. также @ref{triplot}, @ref{cont}, @ref{triangulation}. +@end deftypefn + +@anchor{quadplot} +@deftypefn {Команда MGL} {} quadplot idat xdat ydat ['sch'=''] +@deftypefnx {Команда MGL} {} quadplot idat xdat ydat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} quadplot idat xdat ydat zdat cdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} QuadPlot (@code{const mglDataA &}id, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_quadplot_xy (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_quadplot_xyz (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_quadplot_xyzc (@code{HMGL} gr, @code{HCDT} id, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует поверхность из четырёхугольников. Вершины четырёхугольников задаются индексами @var{id} в массиве точек @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Строка @var{sch} задает цветовую схему. Если строка содержит @samp{#}, то рисуется сетчатая поверхность. Размер по 1-му индексу массива @var{id} должен быть 4 или больше. Массивы @var{x}, @var{y}, @var{z} должны иметь одинаковые размеры. Массив @var{c} задает цвет четырёхугольников (если @var{id}.ny=@var{c}.nx) или цвет вершин (если @var{x}.nx=@var{c}.nx). См. также @ref{triplot}. @sref{TriPlot and QuadPlot} +@end deftypefn + +@anchor{dots} +@deftypefn {Команда MGL} {} dots xdat ydat zdat ['sch'=''] +@deftypefnx {Команда MGL} {} dots xdat ydat zdat adat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Dots (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}c, @code{const mglDataA &}a, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_dots (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dots_a (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_dots_ca (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} c, @code{HCDT} a, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Рисует произвольно расположенные точки @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Строка @var{sch} задает цветовую схему и тип маркеров. Если определёны массивы @var{c}, @var{a} то они задают цвет и прозрачность точек соответственно. Непрозрачные точки с заданным цветом можно нарисовать с помощью @ref{tens}, используя стиль @samp{ .}. Массивы @var{x}, @var{y}, @var{z}, @var{a} должны иметь одинаковые размеры. См. также @ref{crust}, @ref{tens}, @ref{mark}, @ref{plot}. @sref{Dots sample} +@end deftypefn + +@anchor{crust} +@deftypefn {Команда MGL} {} crust xdat ydat zdat ['sch'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Crust (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}sch=@code{""}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_crust (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}sch, @code{const char *}opt) +@end ifclear +Реконструирует и рисует поверхность по произвольно расположенным точкам @{@var{x}[i], @var{y}[i], @var{z}[i]@}. Опция @var{value} задает радиус ошибки (увеличите для удаления дыр). Строка @var{sch} задает цветовую схему. Если строка содержит @samp{#}, то рисуется сетчатая поверхность. Массивы @var{x}, @var{y}, @var{z} должны иметь одинаковые размеры. См. также @ref{dots}, @ref{triplot}. @c @sref{Crust sample} +@end deftypefn + +@c ################################################################## +@external{} +@node Nonlinear fitting, Data manipulation, Other plotting, MathGL core +@section Nonlinear fitting +@nav{} +@cindex Fit +@cindex FitS +@cindex PutsFit +@cindex mglFitPnts +@cindex Fit2 +@cindex Fit3 + +Эти функции подбирают параметры функции для наилучшей аппроксимации данных, т.е. минимизируют сумму @math{\sum_i (f(x_i, y_i, z_i) - a_i)^2/s_i^2}. При этом аппроксимирующая функция @samp{f} может зависеть от одного аргумента @samp{x} (1D случай), от двух аргументов @samp{x,y} (2D случай) или от трех аргументов @samp{x,y,z} (3D случай). Функция @samp{f} также может зависеть от параметров. Список параметров задается строкой @var{var} (например, @samp{abcd}). Обычно пользователь должен предоставить начальные значения параметров в переменной @var{ini}. Однако, при его отсутствии используются нулевые значения. Параметр @var{print}=@code{true} включает вывод найденной формулы в @var{Message} (см. @ref{Error handling}). + +Функции Fit() и FitS() не рисуют полученные массивы. Они заполняют массив @var{fit} по формуле @samp{f} с найденными коэффициентами и возвращают @math{\chi^2} ошибку аппроксимации. При этом, координаты @samp{x,y,z} равно распределены в интервале @var{Min}--@var{Max}. Число точек в @var{fit} определяется опцией @code{value} (по умолчанию @var{mglFitPnts}=100). Функции используют библиотеку GSL. @sref{Nonlinear fitting hints} + +@anchor{fits} +@deftypefn {Команда MGL} {} fits res adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fits res xdat adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fits res xdat ydat adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fits res xdat ydat zdat adat sdat 'func' 'var' [ini=0] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} FitS (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const mglDataA &}s, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_ys (@code{HMGL} gr, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xys (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xyzs (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xyzas (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{HCDT} s, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@end ifclear +"Подгоняют" формулу вдоль x-, y- и z-направлений для 3d массива заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) с весовым множителем @var{s}[i,j,k]. +@end deftypefn + +@anchor{fit} +@deftypefn {Команда MGL} {} fit res adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fit res xdat adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fit res xdat ydat adat sdat 'func' 'var' [ini=0] +@deftypefnx {Команда MGL} {} fit res xdat ydat zdat adat sdat 'func' 'var' [ini=0] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_y (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_xyza (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@end ifclear +"Подгоняют" формулу вдоль x-, y- и z-направлений для 3d массива заданного параметрически @var{a}[i,j,k](@var{x}[i,j,k], @var{y}[i,j,k], @var{z}[i,j,k]) с весовым множителем 1. +@end deftypefn + + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{mglData} Fit2 (@code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit2 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit3 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Fit3 (@code{mglData &}fit, @code{const mglDataA &}a, @code{const char *}func, @code{const char *}var, @code{mglData &}ini, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_2 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_fit_3 (@code{HMGL} gr, @code{HCDT} a, @code{const char *}func, @code{const char *}var, @code{HMDT} ini, @code{const char *}opt) +"Подгоняют" формулу вдоль всех направлений для 2d или 3d массива @var{a} с @var{s}=1 и @var{x}, @var{y}, @var{z} равно распределёнными в диапазоне осей координат. +@end deftypefn +@end ifclear + +@anchor{putsfit} +@deftypefn {Команда MGL} {} putsfit @code{x y} ['pre'='' 'fnt'='' @code{size=-1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} PutsFit (@code{mglPoint} p, @code{const char *}prefix=@code{""}, @code{const char *}font=@code{""}, @code{mreal} size=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_puts_fit (@code{HMGL} gr, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{const char *}prefix, @code{const char *}font, @code{mreal} size) +@end ifclear +Печатает последнюю подобранную формулу с найденными коэффициентами в точке @var{p0}. Строка @var{prefix} будет напечатана перед формулой. Все другие параметры такие же как в @ref{Text printing}. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglGraph}} @code{const char *}GetFit () +@deftypefnx {Функция С} @code{const char *} mgl_get_fit (@code{HMGL} gr) +Возвращает последнюю подобранную формулу с найденными коэффициентами. +@end deftypefn +@end ifclear + + +@c ################################################################## +@external{} +@node Data manipulation, , Nonlinear fitting, MathGL core +@section Распределение данных +@nav{} +@cindex Hist +@cindex Fill +@cindex DataGrid + +@deftypefn {Команда MGL} {} hist @sc{res} xdat adat +@deftypefnx {Команда MGL} {} hist @sc{res} xdat ydat adat +@deftypefnx {Команда MGL} {} hist @sc{res} xdat ydat zdat adat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} Hist (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}a, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_hist_x (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} a, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_hist_xy (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} a, @code{const char *}opt) +@deftypefnx {Функция С} @code{HMDT} mgl_hist_xyz (@code{HMGL} gr, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} a, @code{const char *}opt) +@end ifclear +Создают распределения данных. Они не рисуют данные. Функции могут быть полезны в случае когда данные пользователя определены на случайно расположенных точка (например, после PIC расчетов) и он хочет построить график, требующий регулярных данных (данных на сетках). Диапазон сеток равен диапазону осей координат. Массивы @var{x}, @var{y}, @var{z} определяют положение (координаты) точек. Массив @var{a} задает значения данных. Число точек в результате @var{res} определяется опцией @code{value} (по умолчанию @var{mglFitPnts}=100). +@end deftypefn + + +@deftypefn {Команда MGL} {} fill dat 'eq' +@deftypefnx {Команда MGL} {} fill dat 'eq' vdat +@deftypefnx {Команда MGL} {} fill dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglGraph}} @code{void} Fill (@code{mglData &}u, @code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_data_fill_eq (@code{HMGL} gr, @code{HMDT} u, @code{const char *}eq, @code{HCDT}v, @code{HCDT}w, @code{const char *}opt) +@end ifclear +Заполняют значения массива @samp{u} в соответствии с формулой в строке @var{eq}. Формула -- произвольное выражение, зависящее от переменных @samp{x}, @samp{y}, @samp{z}, @samp{u}, @samp{v}, @samp{w}. Координаты @samp{x}, @samp{y}, @samp{z} полагаются в диапазоне изменения осей координат. Переменная @samp{u} -- значение исходного массива. Переменные @samp{v} и @samp{w} -- значения массивов @var{v}, @var{w}, которые могут быть @code{NULL} (т.е. могут быть опущены). +@end deftypefn + +@deftypefn {Команда MGL} {} datagrid dat xdat ydat zdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{void} DataGrid (@code{mglData &}u, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_data_grid (@code{HMGL} gr, @code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}opt) +@end ifclear +Заполняет значения массива @samp{u} результатом линейной интерполяции по триангулированной поверхности, найденной по произвольно расположенным точкам @samp{x}, @samp{y}, @samp{z}. NAN значение используется для точек сетки вне триангулированной поверхности. @sref{Making regular data} +@end deftypefn + +@deftypefn {Команда MGL} {} refill dat xdat vdat [sl=-1] +@deftypefnx {Команда MGL} {} refill dat xdat ydat vdat [sl=-1] +@deftypefnx {Команда MGL} {} refill dat xdat ydat zdat vdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{mglDataA &}dat, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_data_refill_gr (@code{HMGL} gr, @code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{long} sl, @code{const char *}opt) +@end ifclear +Заполняет значениями интерполяции массива @var{v} в точках @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i], Y[j], Z[k]}@} (или @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i,j,k], Y[i,j,k], Z[i,j,k]}@} если @var{x}, @var{y}, @var{z} не 1d массивы), где @code{X,Y,Z} равномерно распределены в диапазоне осей координат и имеют такой же размер как и массив @var{dat}. Если параметр @var{sl} равен 0 или положительный, то изменятся будет только @var{sl}-ый срез. +@end deftypefn + + + +@deftypefn {Команда MGL} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglGraph}} @code{mglData} PDE (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{mreal} dz=@code{0.1}, @code{mreal} k0=@code{100}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_pde_solve (@code{HMGL} gr, @code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{mreal} dz, @code{mreal} k0, @code{const char *}opt) +@end ifclear +Решает уравнение в частных производных du/dz = i*k0*@var{ham}(p,q,x,y,z,|u|)[u], где p=-i/k0*d/dx, q=-i/k0*d/dy -- псевдо-дифференциальные оперторы. Параметры @var{ini_re}, @var{ini_im} задают действительную и мнимую часть начального распределения поля. Координаты @samp{x}, @samp{y}, @samp{z} полагаются в диапазоне изменения осей координат. Отмечу, ято в действительности этот диапазон увеличен на 3/2 для уменьшения отражения от границ сетки. Параметр @var{dz} задает шаг по эволюционной координате z. Сейчас используется упрощенный вид функции @var{ham} -- исключены все ``смешанные'' члены (типа @samp{x*p}->x*d/dx). Например, в 2D случае это функция вида @math{ham = f(p,z) + g(x,z,u)}. Однако, коммутирующие члены (типа @samp{x*q}->x*d/dy) разрешены. Переменная @samp{u} используется для амплитуды поля |u|, что позволяет решать нелинейные задачи -- например уравнение Шредингера @code{ham="p^2 + q^2 - u^2"}. Вы можете задавать мнимую часть для поглощения волн, например @code{ham = "p^2 + i*x*(x>0)"}, но только для линейной зависимости от переменной @samp{i} (т.е. @math{ham = hre+i*him}). @sref{PDE solving hints} +@end deftypefn + +@c ################################################################## +@c @external{} +@c @node IDTF functions, , Data distributions, MathGL core +@c @section IDTF функции +@c @nav{} + +@c Эти функции обеспечивают поддержку особых возможностей при создании IDTF. Во всех прочих случаях они не делают ничего. + +@c @deftypefn {Метод класса @code{mglGraph}} @code{void} VertexColor (@code{bool} enable) +@c Разрешает плавное изменение цвета. +@c @end deftypefn + +@c @deftypefn {Метод класса @code{mglGraph}} @code{void} Compression (@code{bool} enable) +@c Дает меньший объем файла, но с худшим качеством. +@c @end deftypefn + +@c inline void DoubleSided(bool){} // NOTE: Add later -- IDTF +@c inline void TextureColor(bool){} // NOTE: Add later -- IDTF + +@c @end ifclear + +@external{} diff --git a/texinfo/data_en.texi b/texinfo/data_en.texi new file mode 100644 index 0000000..0a4db63 --- /dev/null +++ b/texinfo/data_en.texi @@ -0,0 +1,1617 @@ +@c ------------------------------------------------------------------ +@chapter Data processing +@nav{} + +@ifset UDAV +This chapter describe commands for allocation, resizing, loading and saving, modifying of data arrays. Also it can numerically differentiate and integrate data, interpolate, fill data by formula and so on. Class supports data with dimensions up to 3 (like function of 3 variables -- x,y,z). Data arrays are denoted by Small Caps (like @sc{dat}) if it can be (re-)created by MGL commands. +@end ifset + +@ifclear UDAV +This chapter describe classes @code{mglData} and @code{mglDataC} for working with data arrays of real and complex numbers. Both classes are derived from abstract class @code{mglDataA}, and can be used as arguments of any plotting functions (see @ref{MathGL core}). These classes are defined in @code{#include } and @code{#include } correspondingly. The classes have mostly the same set of functions for easy and safe allocation, resizing, loading, saving, modifying of data arrays. Also it can numerically differentiate and integrate data, interpolate, fill data by formula and so on. Classes support data with dimensions up to 3 (like function of 3 variables -- x,y,z). The internal representation of numbers is mreal (or dual=std::complex for @code{mglDataC}), which can be configured as float or double by selecting option @code{--enable-double} at the MathGL configuring (see @ref{Installation}). Float type have smaller size in memory and usually it has enough precision in plotting purposes. However, double type provide high accuracy what can be important for time-axis, for example. Data arrays are denoted by Small Caps (like @sc{dat}) if it can be (re-)created by MGL commands. +@end ifclear + +@menu +* Public variables:: +* Data constructor:: +* Data resizing:: +* Data filling:: +* File I/O:: +* Make another data:: +* Data changing:: +* Interpolation:: +* Data information:: +* Operators:: +* Global functions:: +* Evaluate expression:: +* MGL variables:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Public variables, Data constructor, , Data processing +@section Public variables +@nav{} + +@ifset UDAV +MGL don't support direct access to data arrays. See section @ref{Data filling} +@end ifset + +@ifclear UDAV +@deftypecv {Variable} mglData @code{mreal *} a +@deftypecvx {Variable} mglDataC @code{dual *} a +Data array itself. The flat data representation is used. For example, matrix [nx x ny] is presented as flat (1d-) array with length nx*ny. The element with indexes @{i, j, k@} is a[i+nx*j+nx*ny*k] (indexes are zero based). +@end deftypecv +@deftypecv {Variable} mglData @code{long} nx +@deftypecvx {Variable} mglDataC @code{long} nx +Number of points in 1st dimensions ('x' dimension). +@end deftypecv +@deftypecv {Variable} mglData @code{long} ny +@deftypecvx {Variable} mglDataC @code{long} ny +Number of points in 2nd dimensions ('y' dimension). +@end deftypecv +@deftypecv {Variable} mglData @code{long} nz +@deftypecvx {Variable} mglDataC @code{long} nz +Number of points in 3d dimensions ('z' dimension). +@end deftypecv +@deftypecv {Variable} mglData @code{std::string} id +@deftypecvx {Variable} mglDataC @code{std::string} id +Names of column (or slice if nz>1) -- one character per column. +@end deftypecv +@deftypecv {Variable} mglData @code{bool} link +@deftypecvx {Variable} mglDataC @code{bool} link +Flag to use external data, i.e. don't delete it. +@end deftypecv + +@deftypefn {Method on @code{mglData}} @code{mreal} GetVal (@code{long} i) +@deftypefnx {Method on @code{mglDataC}} @code{mreal} GetVal (@code{long} i) +@deftypefnx {Method on @code{mglData}} @code{void} SetVal (@code{mreal} val, @code{long} i) +@deftypefnx {Method on @code{mglDataC}} @code{void} SetVal (@code{mreal} val, @code{long} i) +Gets or sets the value in by "flat" index @var{i} without border checking. Index @var{i} should be in range [0, nx*ny*nz-1]. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{long} GetNx () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNx () +@deftypefnx {Method on @code{mglData}} @code{long} GetNy () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNy () +@deftypefnx {Method on @code{mglData}} @code{long} GetNz () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNz () +@deftypefnx {C function} @code{long} mgl_data_get_nx (@code{HCDT} dat) +@deftypefnx {C function} @code{long} mgl_data_get_ny (@code{HCDT} dat) +@deftypefnx {C function} @code{long} mgl_data_get_nz (@code{HCDT} dat) +Gets the x-, y-, z-size of the data. +@end deftypefn + +@deftypefn {C function} @code{mreal} mgl_data_get_value (@code{HCDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{dual} mgl_datac_get_value (@code{HCDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{mreal *} mgl_data_value (@code{HMDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{dual *} mgl_datac_value (@code{HADT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{void} mgl_data_set_value (@code{HMDT} dat, @code{mreal} v, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{void} mgl_datac_set_value (@code{HADT} dat, @code{dual} v, @code{int} i, @code{int} j, @code{int} k) +Gets or sets the value in specified cell of the data with border checking. +@end deftypefn +@deftypefn {C function} @code{const mreal *} mgl_data_data (@code{HCDT} dat) +@deftypefnx {C function} @code{const dual *} mgl_datac_data (@code{HCDT} dat) +Returns pointer to internal data array. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data constructor, Data resizing, Public variables, Data processing +@section Data constructor +@nav{} +@cindex mglData + +@ifset UDAV +There are many functions, which can create data for output (see @ref{Data filling}, @ref{File I/O}, @ref{Make another data}, @ref{Global functions}). Here I put most useful of them. +@end ifset + +@anchor{new} +@deftypefn {MGL command} {} new @sc{dat} [@code{nx=1} 'eq'] +@deftypefnx {MGL command} {} new @sc{dat} @code{nx ny} ['eq'] +@deftypefnx {MGL command} {} new @sc{dat} @code{nx ny nz} ['eq'] +@ifclear UDAV +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{int} mx=@code{1}, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} mx=@code{1}, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {C function} @code{HMDT} mgl_create_data () +@deftypefnx {C function} @code{HMDT} mgl_create_data_size (@code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {C function} @code{HADT} mgl_create_datac () +@deftypefnx {C function} @code{HADT} mgl_create_datac_size (@code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Default constructor. Allocates the memory for data array and initializes it by zero. If string @var{eq} is specified then data will be filled by corresponding formula as in @ref{fill}. +@end deftypefn + +@anchor{copy} +@deftypefn {MGL command} {} copy @sc{dat} dat2 ['eq'=''] +@deftypefnx {MGL command} {} copy @sc{dat} @code{val} +@ifclear UDAV +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{const mglDataA &}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{const mglDataA *}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{int} size, @code{const float *}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{int} size, @code{int} cols, @code{const float *}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{int} size, @code{const double *}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{int} size, @code{int} cols, @code{const double *}dat2) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{const double *}dat2, @code{int} size) +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{const double *}dat2, @code{int} size, @code{int} cols) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{const mglDataA &}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{const mglDataA *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{const float *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const float *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{const double *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const double *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{const dual *}dat2) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const dual *}dat2) +@end ifclear +Copy constructor. Allocates the memory for data array and copy values from other array. At this, if parameter @var{eq} is specified then the data will be modified by corresponding formula similarly to @ref{fill}. +@end deftypefn + +@deftypefn {MGL command} {} read @sc{dat} 'fname' +@ifclear UDAV +@deftypefnx {Constructor on @code{mglData}} {} mglData (@code{const char *}fname) +@deftypefnx {Constructor on @code{mglDataC}} {} mglDataC (@code{const char *}fname) +@deftypefnx {C function} @code{HMDT} mgl_create_data_file (@code{const char *}fname) +@deftypefnx {C function} @code{HADT} mgl_create_datac_file (@code{const char *}fname) +@end ifclear +Reads data from tab-separated text file with auto determining sizes of the data. +@end deftypefn + +@deftypefn {MGL command} {} delete dat +@ifclear UDAV +@deftypefnx {Destructor on @code{mglData}} {} ~mglData () +@deftypefnx {C function} @code{void} mgl_delete_data (@code{HMDT} dat) +@deftypefnx {Destructor on @code{mglDataC}} {} ~mglDataC () +@deftypefnx {C function} @code{void} mgl_delete_datac (@code{HADT} dat) +@end ifclear +Deletes the instance of class mglData. +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Data resizing, Data filling, Data constructor, Data processing +@section Data resizing +@nav{} +@cindex Create +@cindex Rearrange +@cindex Extend +@cindex Transpose +@cindex Squeeze +@cindex Crop +@cindex Insert +@cindex Delete +@cindex Sort +@cindex Clean +@cindex Join + +@deftypefn {MGL command} {} new @sc{dat} [@code{nx=1 ny=1 nz=1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Create (@code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Create (@code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_create (@code{HMDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {C function} @code{void} mgl_datac_create (@code{HADT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Creates or recreates the array with specified size and fills it by zero. This function does nothing if one of parameters @var{mx}, @var{my}, @var{mz} is zero or negative. +@end deftypefn + +@anchor{rearrange} +@deftypefn {MGL command} {} rearrange dat @code{mx [my=0 mz=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Rearrange (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Rearrange (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}) +@deftypefnx {C function} @code{void} mgl_data_rearrange (@code{HMDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {C function} @code{void} mgl_datac_rearrange (@code{HADT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Rearrange dimensions without changing data array so that resulting sizes should be @var{mx}*@var{my}*@var{mz} < nx*ny*nz. If some of parameter @var{my} or @var{mz} are zero then it will be selected to optimal fill of data array. For example, if @var{my}=0 then it will be change to @var{my}=nx*ny*nz/@var{mx} and @var{mz}=1. +@end deftypefn + +@anchor{transpose} +@deftypefn {MGL command} {} transpose dat ['dim'='yxz'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Transpose (@code{const char *}dim=@code{"yx"}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Transpose (@code{const char *}dim=@code{"yx"}) +@deftypefnx {C function} @code{void} mgl_data_transpose (@code{HMDT} dat, @code{const char *}dim) +@deftypefnx {C function} @code{void} mgl_datac_transpose (@code{HADT} dat, @code{const char *}dim) +@end ifclear +Transposes (shift order of) dimensions of the data. New order of dimensions is specified in string @var{dim}. This function can be useful also after reading of one-dimensional data. +@end deftypefn + +@anchor{extend} +@deftypefn {MGL command} {} extend dat @code{n1 [n2=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Extend (@code{int} n1, @code{int} n2=@code{0}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Extend (@code{int} n1, @code{int} n2=@code{0}) +@deftypefnx {C function} @code{void} mgl_data_extend (@code{HMDT} dat, @code{int} n1, @code{int} n2) +@deftypefnx {C function} @code{void} mgl_datac_extend (@code{HADT} dat, @code{int} n1, @code{int} n2) +@end ifclear +Increase the dimensions of the data by inserting new (|@var{n1}|+1)-th slices after (for @var{n1}>0) or before (for @var{n1}<0) of existed one. It is possible to insert 2 dimensions simultaneously for 1d data by using parameter @var{n2}. Data to new slices is copy from existed one. For example, for @var{n1}>0 new array will be +@iftex +@math{a_{ij}^{new} = a_i^{old}} where j=0...@var{n1}. Correspondingly, for @var{n1}<0 new array will be @math{a_{ij}^{new} = a_j^{old}} where i=0...|@var{n1}|. +@end iftex +@ifnottex +a_ij^new = a_i^old where j=0...@var{n1}. Correspondingly, for @var{n1}<0 new array will be a_ij^new = a_j^old where i=0...|@var{n1}|. +@end ifnottex +@end deftypefn + +@anchor{squeeze} +@deftypefn {MGL command} {} squeeze dat @code{rx [ry=1 rz=1 sm=off]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Squeeze (@code{int} rx, @code{int} ry=@code{1}, @code{int} rz=@code{1}, @code{bool} smooth=@code{false}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Squeeze (@code{int} rx, @code{int} ry=@code{1}, @code{int} rz=@code{1}, @code{bool} smooth=@code{false}) +@deftypefnx {C function} @code{void} mgl_data_squeeze (@code{HMDT} dat, @code{int} rx, @code{int} ry, @code{int} rz, @code{int} smooth) +@deftypefnx {C function} @code{void} mgl_datac_squeeze (@code{HADT} dat, @code{int} rx, @code{int} ry, @code{int} rz, @code{int} smooth) +@end ifclear +Reduces the data size by excluding data elements which indexes are not divisible by @var{rx}, @var{ry}, @var{rz} correspondingly. Parameter @var{smooth} set to use smoothing +@iftex +(i.e. @math{a_{out}[i]=\sum_{j=i,i+r}a[j]/r}) or not (i.e. @math{a_{out}[i]=a[j*r]}). +@end iftex +@ifnottex +(i.e. out[i]=\sum_@{j=i,i+r@} a[j]/r) or not (i.e. out[i]=a[j*r]). +@end ifnottex +@end deftypefn + +@anchor{crop} +@deftypefn {MGL command} {} crop dat @code{n1 n2} 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Crop (@code{int} n1, @code{int} n2, @code{char} dir=@code{'x'}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Crop (@code{int} n1, @code{int} n2, @code{char} dir=@code{'x'}) +@deftypefnx {C function} @code{void} mgl_data_crop (@code{HMDT} dat, @code{int} n1, @code{int} n2, @code{char} dir) +@deftypefnx {C function} @code{void} mgl_datac_crop (@code{HADT} dat, @code{int} n1, @code{int} n2, @code{char} dir) +@end ifclear +Cuts off edges of the data @var{i}<@var{n1} and @var{i}>@var{n2} if @var{n2}>0 or @var{i}>@code{n[xyz]}-@var{n2} if @var{n2}<=0 along direction @var{dir}. +@end deftypefn + +@anchor{insert} +@deftypefn {MGL command} {} insert dat 'dir' @code{[pos=off num=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Insert (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Insert (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_insert (@code{HMDT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@deftypefnx {C function} @code{void} mgl_datac_insert (@code{HADT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@end ifclear +Insert @var{num} slices along @var{dir}-direction at position @var{pos} and fill it by zeros. +@end deftypefn + +@anchor{delete} +@deftypefn {MGL command} {} delete dat 'dir' @code{[pos=off num=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Delete (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Delete (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_delete (@code{HMDT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@deftypefnx {C function} @code{void} mgl_datac_delete (@code{HADT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@end ifclear +Delete @var{num} slices along @var{dir}-direction at position @var{pos}. +@end deftypefn + +@anchor{sort} +@deftypefn {MGL command} {} sort dat @code{idx [idy=-1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Sort (@code{lond} idx, @code{long} idy=@code{-1}) +@deftypefnx {C function} @code{void} mgl_data_sort (@code{HMDT} dat, @code{lond} idx, @code{long} idy) +@end ifclear +Sort data rows (or slices in 3D case) by values of specified column @var{idx} (or cell @{@var{idx},@var{idy}@} for 3D case). Note, this function is not thread safe! +@end deftypefn + +@anchor{clean} +@deftypefn {MGL command} {} clean dat @code{idx} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Clean (@code{lond} idx) +@deftypefnx {C function} @code{void} mgl_data_clean (@code{HMDT} dat, @code{lond} idx) +@end ifclear +Delete rows which values are equal to next row for given column @var{idx}. +@end deftypefn + +@anchor{join} +@deftypefn {MGL command} {} join dat vdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Join (@code{const mglDataA &}vdat) +@deftypefnx {Method on @code{mglDataC}} @code{void} Join (@code{const mglDataA &}vdat) +@deftypefnx {C function} @code{void} mgl_data_join (@code{HMDT} dat, @code{HCDT} vdat) +@deftypefnx {C function} @code{void} mgl_datac_join (@code{HADT} dat, @code{HCDT} vdat) +@end ifclear +Join data cells from @var{vdat} to @var{dat}. At this, function increase @var{dat} sizes according following: z-size for 3D data arrays arrays with equal x-,y-sizes; or y-size for 2D data arrays with equal x-sizes; or x-size otherwise. +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Data filling, File I/O, Data resizing, Data processing +@section Data filling +@nav{} +@cindex Fill +@cindex Modify +@cindex Set +@cindex List +@cindex Var +@cindex Refill + +@anchor{list} +@deftypefn {MGL command} {} list @sc{dat} @code{v1 ...} +Creates new variable with name @var{dat} and fills it by numeric values of command arguments @code{v1 ...}. Command can create one-dimensional and two-dimensional arrays with arbitrary values. For creating 2d array the user should use delimiter @samp{|} which means that the following values lie in next row. Array sizes are [maximal of row sizes * number of rows]. For example, command @code{list 1 | 2 3} creates the array [1 0; 2 3]. Note, that the maximal number of arguments is 1000. +@end deftypefn +@deftypefn {MGL command} {} list @sc{dat} d1 ... +Creates new variable with name @var{dat} and fills it by data values of arrays of command arguments @var{d1 ...}. Command can create two-dimensional or three-dimensional (if arrays in arguments are 2d arrays) arrays with arbitrary values. Minor dimensions of all arrays in arguments should be equal to dimensions of first array d1. In the opposite case the argument will be ignored. Note, that the maximal number of arguments is 1000. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const float *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{const double *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_set_float (@code{HMDT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {C function} @code{void} mgl_data_set_double (@code{HMDT} dat, @code{const double *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const float *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const double *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const dual *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_datac_set_float (@code{HADT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {C function} @code{void} mgl_datac_set_double (@code{HADT} dat, @code{const double *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {C function} @code{void} mgl_datac_set_complex (@code{HADT} dat, @code{const dual *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +Allocates memory and copies the data from the @strong{flat} @code{float*} or @code{double*} array. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const float **}A, @code{int} N1, @code{int} N2) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{const double **}A, @code{int} N1, @code{int} N2) +@deftypefnx {C function} @code{void} mgl_data_set_mreal2 (@code{HMDT} dat, @code{const mreal **}A, @code{int} N1, @code{int} N2) +@deftypefnx {C function} @code{void} mgl_data_set_double2 (@code{HMDT} dat, @code{const double **}A, @code{int} N1, @code{int} N2) +Allocates memory and copies the data from the @code{float**} or @code{double**} array with dimensions @var{N1}, @var{N2}, i.e. from array defined as @code{mreal a[N1][N2];}. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const float ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{const double ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {C function} @code{void} mgl_data_set_mreal3 (@code{HMDT} dat, @code{const mreal ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {C function} @code{void} mgl_data_set_double3 (@code{HMDT} dat, @code{const double ***}A, @code{int} N1, @code{int} N2) +Allocates memory and copies the data from the @code{float***} or @code{double***} array with dimensions @var{N1}, @var{N2}, @var{N3}, i.e. from array defined as @code{mreal a[N1][N2][N3];}. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{gsl_vector *}v) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{gsl_vector *}v) +@deftypefnx {C function} @code{void} mgl_data_set_vector (@code{HMDT} dat, @code{gsl_vector *}v) +@deftypefnx {C function} @code{void} mgl_datac_set_vector (@code{HADT} dat, @code{gsl_vector *}v) +Allocates memory and copies the data from the @code{gsl_vector *} structure. +@end deftypefn +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{gsl_matrix *}m) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{gsl_matrix *}m) +@deftypefnx {C function} @code{void} mgl_data_set_matrix (@code{HMDT} dat, @code{gsl_matrix *}m) +@deftypefnx {C function} @code{void} mgl_datac_set_matrix (@code{HADT} dat, @code{gsl_matrix *}m) +Allocates memory and copies the data from the @code{gsl_matrix *} structure. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const mglDataA &}from) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{HCDT} from) +@deftypefnx {C function} @code{void} mgl_data_set (@code{HMDT} dat, @code{HCDT} from) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const mglDataA &}from) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{HCDT} from) +@deftypefnx {C function} @code{void} mgl_datac_set (@code{HADT} dat, @code{HCDT} from) +Copies the data from @code{mglData} (or @code{mglDataA}) instance @var{from}. +@end deftypefn + +@deftypefn {Method on @code{mglDataC}} @code{void} Set (@code{const mglDataA &}re, @code{const mglDataA &}im) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{HCDT} re, @code{HCDT} im) +@deftypefnx {Method on @code{mglDataC}} @code{void} SetAmpl (@code{HCDT} ampl, @code{const mglDataA &}phase) +@deftypefnx {C function} @code{void} mgl_datac_set_ri (@code{HADT} dat, @code{HCDT} re, @code{HCDT} im) +@deftypefnx {C function} @code{void} mgl_datac_set_ap (@code{HADT} dat, @code{HCDT} ampl, @code{HCDT} phase) +Copies the data from @code{mglData} instances for real and imaginary parts of complex data arrays. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +Allocates memory and copies the data from the @code{std::vector} array. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Set (@code{const char *}str, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_set_values (@code{const char *}str, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Method on @code{mglDataC}} @code{void} Set (@code{const char *}str, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_datac_set_values (@code{const char *}str, @code{int} NX, @code{int} NY, @code{int} NZ) +Allocates memory and scanf the data from the string. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{void} Link (@code{mglData &}from) +@deftypefnx {Method on @code{mglData}} @code{void} Link (@code{mreal *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_link (@code{HMDT} dat, @code{mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Method on @code{mglDataC}} @code{void} Link (@code{mglDataC &}from) +@deftypefnx {Method on @code{mglDataC}} @code{void} Link (@code{dual *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {C function} @code{void} mgl_datac_link (@code{HADT} dat, @code{dual *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +Links external data array, i.e. don't delete this array at exit. +@end deftypefn +@end ifclear + +@anchor{var} +@deftypefn {MGL command} {} var @sc{dat} @code{num v1 [v2=nan]} +Creates new variable with name @var{dat} for one-dimensional array of size @var{num}. Array elements are equidistantly distributed in range [@var{v1}, @var{v2}]. If @var{v2}=@code{nan} then @var{v2=v1} is used. +@end deftypefn + +@anchor{fill} +@deftypefn {MGL command} {} fill dat v1 v2 ['dir'='x'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Fill (@code{mreal} v1, @code{mreal} v2, @code{char} dir=@code{'x'}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Fill (@code{dual} v1, @code{dual} v2, @code{char} dir=@code{'x'}) +@deftypefnx {C function} @code{void} mgl_data_fill (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{char} dir) +@deftypefnx {C function} @code{void} mgl_datac_fill (@code{HADT} dat, @code{dual} v1, @code{dual} v2, @code{char} dir) +@end ifclear +Equidistantly fills the data values to range [@var{v1}, @var{v2}] in direction @var{dir}=@{@samp{x},@samp{y},@samp{z}@}. +@end deftypefn + +@deftypefn {MGL command} {} fill dat 'eq' +@deftypefnx {MGL command} {} fill dat 'eq' vdat +@deftypefnx {MGL command} {} fill dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const mglDataA &}wdat, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const mglDataA &}wdat, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_data_fill_eq (@code{HMGL} gr, @code{HMDT} dat, @code{const char *}eq, @code{HCDT} vdat, @code{HCDT} wdat, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_datac_fill_eq (@code{HMGL} gr, @code{HADT} dat, @code{const char *}eq, @code{HCDT} vdat, @code{HCDT} wdat, @code{const char *}opt) +@end ifclear +Fills the value of array according to the formula in string @var{eq}. Formula is an arbitrary expression depending on variables @samp{x}, @samp{y}, @samp{z}, @samp{u}, @samp{v}, @samp{w}. Coordinates @samp{x}, @samp{y}, @samp{z} are supposed to be normalized in axis range of canvas @var{gr} (in difference from @code{Modify} functions). Variable @samp{u} is the original value of the array. Variables @samp{v} and @samp{w} are values of @var{vdat}, @var{wdat} which can be @code{NULL} (i.e. can be omitted). +@end deftypefn + +@anchor{modify} +@deftypefn {MGL command} {} modify dat 'eq' [@code{dim=0}] +@deftypefnx {MGL command} {} modify dat 'eq' vdat +@deftypefnx {MGL command} {} modify dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{int} dim=@code{0}) +@deftypefnx {Method on @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v) +@deftypefnx {Method on @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w) +@deftypefnx {Method on @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{int} dim=@code{0}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v) +@deftypefnx {Method on @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w) +@deftypefnx {C function} @code{void} mgl_data_modify (@code{HMDT} dat, @code{const char *}eq, @code{int} dim) +@deftypefnx {C function} @code{void} mgl_data_modify_vw (@code{HMDT} dat, @code{const char *}eq, @code{HCDT} v, @code{HCDT} w) +@deftypefnx {C function} @code{void} mgl_datac_modify (@code{HADT} dat, @code{const char *}eq, @code{int} dim) +@deftypefnx {C function} @code{void} mgl_datac_modify_vw (@code{HADT} dat, @code{const char *}eq, @code{HCDT} v, @code{HCDT} w) +@end ifclear +The same as previous ones but coordinates @samp{x}, @samp{y}, @samp{z} are supposed to be normalized in range [0,1]. If @var{dim}>0 is specified then modification will be fulfilled only for slices >=@var{dim}. +@end deftypefn + +@anchor{fillsample} +@deftypefn {MGL command} {} fillsample dat 'how' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} FillSample (@code{const char *}how) +@deftypefnx {C function} @code{void} mgl_data_fill_sample (@code{HMDT} a, @code{const char *}how) +@end ifclear +Fills data by 'x' or 'k' samples for Hankel ('h') or Fourier ('f') transform. +@end deftypefn + + +@anchor{datagrid} +@deftypefn {MGL command} {} datagrid dat xdat ydat zdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Grid (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{mglData} Grid (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {C function} @code{void} mgl_data_grid (@code{HMGL} gr, @code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}opt) +@deftypefnx {C function} @code{void} mgl_data_grid_xy (@code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@end ifclear +Fills the value of array according to the linear interpolation of triangulated surface assuming x-,y-coordinates equidistantly distributed in axis range (or in range [x1,x2]*[y1,y2]). Triangulated surface is found for arbitrary placed points @samp{x}, @samp{y}, @samp{z}. NAN value is used for grid points placed outside of triangulated surface. @sref{Making regular data} +@end deftypefn + + +@anchor{put} +@deftypefn {MGL command} {} put dat @code{val [i=: j=: k=:]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Put (@code{mreal} val, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Put (@code{dual} val, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {C function} @code{void} mgl_data_put_val (@code{HMDT} a, @code{mreal} val, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{void} mgl_datac_put_val (@code{HADT} a, @code{dual} val, @code{int} i, @code{int} j, @code{int} k) +@end ifclear +Sets value(s) of array a[@var{i}, @var{j}, @var{k}] = @var{val}. Negative indexes @var{i}, @var{j}, @var{k}=-1 set the value @var{val} to whole range in corresponding direction(s). For example, @code{Put(val,-1,0,-1);} sets a[i,0,j]=@var{val} for i=0...(nx-1), j=0...(nz-1). +@end deftypefn + +@deftypefn {MGL command} {} put dat vdat [@code{i=: j=: k=:}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Put (@code{const mglDataA &}v, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Put (@code{const mglDataA &}v, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {C function} @code{void} mgl_data_put_dat (@code{HMDT} a, @code{HCDT} v, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {C function} @code{void} mgl_datac_put_dat (@code{HADT} a, @code{HCDT} v, @code{int} i, @code{int} j, @code{int} k) +@end ifclear +Copies value(s) from array @var{v} to the range of original array. Negative indexes @var{i}, @var{j}, @var{k}=-1 set the range in corresponding direction(s). At this minor dimensions of array @var{v} should be large than corresponding dimensions of this array. For example, @code{Put(v,-1,0,-1);} sets a[i,0,j]=v.ny>nz ? v[i,j] : v[i], where i=0...(nx-1), j=0...(nz-1) and condition v.nx>=nx is true. +@end deftypefn + +@anchor{refill} +@deftypefn {MGL command} {} refill dat xdat vdat [sl=-1] +@deftypefnx {MGL command} {} refill dat xdat ydat vdat [sl=-1] +@deftypefnx {MGL command} {} refill dat xdat ydat zdat vdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mreal} x1, @code{mreal} x2, @code{long} sl=@code{-1}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2, @code{long} sl=@code{-1}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2, @code{long} sl=@code{-1}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Method on @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{void} mgl_data_refill_x (@code{HMDT} a, @code{HCDT} x, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{long} sl) +@deftypefnx {C function} @code{void} mgl_data_refill_xy (@code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{long} sl) +@deftypefnx {C function} @code{void} mgl_data_refill_xyz (@code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1, @code{mreal} z2) +@deftypefnx {C function} @code{void} mgl_data_refill_gr (@code{HMGL} gr, @code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{long} sl, @code{const char *}opt) +@end ifclear +Fills by interpolated values of array @var{v} at the point @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i], Y[j], Z[k]}@} (or @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i,j,k], Y[i,j,k], Z[i,j,k]}@} if @var{x}, @var{y}, @var{z} are not 1d arrays), where @code{X,Y,Z} are equidistantly distributed in range [@var{x1},@var{x2}]*[@var{y1},@var{y2}]*[@var{z1},@var{z2}] and have the same sizes as this array. If parameter @var{sl} is 0 or positive then changes will be applied only for slice @var{sl}. +@end deftypefn + +@anchor{idset} +@deftypefn {MGL command} {} idset dat 'ids' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} SetColumnId (@code{const char *}ids) +@deftypefnx {Method on @code{mglDataC}} @code{void} SetColumnId (@code{const char *}ids) +@deftypefnx {C function} @code{void} mgl_data_set_id (@code{HMDT} a, @code{const char *}ids) +@deftypefnx {C function} @code{void} mgl_datac_set_id (@code{HADT} a, @code{const char *}ids) +@end ifclear +Sets the symbol @var{ids} for data columns. The string should contain one symbol 'a'...'z' per column. These ids are used in @ref{column}. +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node File I/O, Make another data, Data filling, Data processing +@section File I/O +@nav{} +@cindex Read +@cindex ReadMat +@cindex ReadRange +@cindex ReadAll +@cindex Save +@cindex ReadHDF +@cindex SaveHDF +@cindex Import +@cindex Export + +@anchor{read} +@deftypefn {MGL command} {} read @sc{dat} 'fname' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{bool} Read (@code{const char *}fname) +@deftypefnx {Method on @code{mglDataC}} @code{bool} Read (@code{const char *}fname) +@deftypefnx {C function} @code{int} mgl_data_read (@code{HMDT} dat, @code{const char *}fname) +@deftypefnx {C function} @code{int} mgl_datac_read (@code{HADT} dat, @code{const char *}fname) +@end ifclear +Reads data from tab-separated text file with auto determining sizes of the data. Double newline means the beginning of new z-slice. +@end deftypefn + +@deftypefn {MGL command} {} read @sc{dat} 'fname' @code{mx [my=1 mz=1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{bool} Read (@code{const char *}fname, @code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Method on @code{mglDataC}} @code{bool} Read (@code{const char *}fname, @code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {C function} @code{int} mgl_data_read_dim (@code{HMDT} dat, @code{const char *}fname, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {C function} @code{int} mgl_datac_read_dim (@code{HADT} dat, @code{const char *}fname, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Reads data from text file with specified data sizes. This function does nothing if one of parameters @var{mx}, @var{my} or @var{mz} is zero or negative. +@end deftypefn + +@anchor{readmat} +@deftypefn {MGL command} {} readmat @sc{dat} 'fname' [@code{dim=2}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{bool} ReadMat (@code{const char *}fname, @code{int} dim=@code{2}) +@deftypefnx {Method on @code{mglDataC}} @code{bool} ReadMat (@code{const char *}fname, @code{int} dim=@code{2}) +@deftypefnx {C function} @code{int} mgl_data_read_mat (@code{HMDT} dat, @code{const char *}fname, @code{int} dim) +@deftypefnx {C function} @code{int} mgl_datac_read_mat (@code{HADT} dat, @code{const char *}fname, @code{int} dim) +@end ifclear +Read data from text file with size specified at beginning of the file by first @var{dim} numbers. At this, variable @var{dim} set data dimensions. +@end deftypefn + +@anchor{readall} +@deftypefn {MGL command} {} readall @sc{dat} 'templ' @code{v1 v2 [dv=1 slice=off]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} ReadRange (@code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step=@code{1}, @code{bool} as_slice=@code{false}) +@deftypefnx {Method on @code{mglDataC}} @code{void} ReadRange (@code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step=@code{1}, @code{bool} as_slice=@code{false}) +@deftypefnx {C function} @code{int} mgl_data_read_range (@code{HMDT} dat, @code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step, @code{int} as_slice) +@deftypefnx {C function} @code{int} mgl_datac_read_range (@code{HADT} dat, @code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step, @code{int} as_slice) +@end ifclear +Join data arrays from several text files. The file names are determined by function call @code{sprintf(fname,templ,val);}, where @var{val} changes from @var{from} to @var{to} with step @var{step}. The data load one-by-one in the same slice if @var{as_slice}=@code{false} or as slice-by-slice if @var{as_slice}=@code{true}. +@end deftypefn + +@deftypefn {MGL command} {} readall @sc{dat} 'templ' @code{[slice=off]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} ReadAll (@code{const char *}templ, @code{bool} as_slice=@code{false}) +@deftypefnx {Method on @code{mglDataC}} @code{void} ReadAll (@code{const char *}templ, @code{bool} as_slice=@code{false}) +@deftypefnx {C function} @code{int} mgl_data_read_all (@code{HMDT} dat, @code{const char *}templ, @code{int} as_slice) +@deftypefnx {C function} @code{int} mgl_datac_read_all (@code{HADT} dat, @code{const char *}templ, @code{int} as_slice) +@end ifclear +Join data arrays from several text files which filenames satisfied the template @var{templ} (for example, @var{templ}=@code{"t_*.dat"}). The data load one-by-one in the same slice if @var{as_slice}=@code{false} or as slice-by-slice if @var{as_slice}=@code{true}. +@end deftypefn + +@anchor{save} +@deftypefn {MGL command} {} save dat 'fname' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Save (@code{const char *}fname, @code{int} ns=@code{-1}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{void} Save (@code{const char *}fname, @code{int} ns=@code{-1}) @code{const} +@deftypefnx {C function} @code{void} mgl_data_save (@code{HCDT} dat, @code{const char *}fname, @code{int} ns) +@deftypefnx {C function} @code{void} mgl_datac_save (@code{HCDT} dat, @code{const char *}fname, @code{int} ns) +@end ifclear +Saves the whole data array (for @var{ns}=@code{-1}) or only @var{ns}-th slice to text file. +@end deftypefn + +@anchor{readhdf} +@deftypefn {MGL command} {} readhdf @sc{dat} 'fname' 'dname' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} ReadHDF (@code{const char *}fname, @code{const char *}dname) +@deftypefnx {Method on @code{mglDataC}} @code{void} ReadHDF (@code{const char *}fname, @code{const char *}dname) +@deftypefnx {C function} @code{void} mgl_data_read_hdf (@code{HMDT} dat, @code{const char *}fname, @code{const char *}dname) +@deftypefnx {C function} @code{void} mgl_datac_read_hdf (@code{HADT} dat, @code{const char *}fname, @code{const char *}dname) +@end ifclear +Reads data array named @var{dname} from HDF5 or HDF4 file. This function does nothing if HDF5|HDF4 was disabled during library compilation. +@end deftypefn + +@anchor{savehdf} +@deftypefn {MGL command} {} savehdf dat 'fname' 'dname' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} SaveHDF (@code{const char *}fname, @code{const char *}dname, @code{bool} rewrite=@code{false}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{void} SaveHDF (@code{const char *}fname, @code{const char *}dname, @code{bool} rewrite=@code{false}) @code{const} +@deftypefnx {C function} @code{void} mgl_data_save_hdf (@code{HCDT} dat, @code{const char *}fname, @code{const char *}dname, @code{int} rewrite) +@deftypefnx {C function} @code{void} mgl_datac_save_hdf (@code{HCDT} dat, @code{const char *}fname, @code{const char *}dname, @code{int} rewrite) +@end ifclear +Saves data array named @var{dname} to HDF5 file. This function does nothing if HDF5 was disabled during library compilation. +@end deftypefn + +@anchor{datas} +@deftypefn {MGL command} {} datas 'fname' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{int} DatasHDF (@code{const char *}fname, @code{char *}buf, @code{long} size) @code{static} +@deftypefnx {Method on @code{mglDataC}} @code{int} DatasHDF (@code{const char *}fname, @code{char *}buf, @code{long} size) @code{static} +@deftypefnx {C function} @code{int} mgl_datas_hdf (@code{const char *}fname, @code{char *}buf, @code{long} size) +@end ifclear +Put data names from HDF5 file @var{fname} into @var{buf} as '\t' separated fields. In MGL version the list of data names will be printed as message. This function does nothing if HDF5 was disabled during library compilation. +@end deftypefn + +@anchor{import} +@deftypefn {MGL command} {} import @sc{dat} 'fname' 'sch' [@code{v1=0 v2=1}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Import (@code{const char *}fname, @code{const char *}scheme, @code{mreal} v1=@code{0}, mreal v2=@code{1}) +@deftypefnx {C function} @code{void} mgl_data_import (@code{HMDT} dat, @code{const char *}fname, @code{const char *}scheme, @code{mreal} v1, mreal v2) +@end ifclear +Reads data from bitmap file (now support only PNG format). The RGB values of bitmap pixels are transformed to mreal values in range [@var{v1}, @var{v2}] using color scheme @var{scheme} (@pxref{Color scheme}). +@end deftypefn + +@anchor{export} +@deftypefn {MGL command} {} export dat 'fname' 'sch' [@code{v1=0 v2=0}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Export (@code{const char *}fname, @code{const char *}scheme, @code{mreal} v1=@code{0}, mreal v2=@code{0}, @code{int} ns=@code{-1}) const +@deftypefnx {C function} @code{void} mgl_data_export (@code{HMDT} dat, @code{const char *}fname, @code{const char *}scheme, @code{mreal} v1, mreal v2, @code{int} ns) const +@end ifclear +Saves data matrix (or @code{ns}-th slice for 3d data) to bitmap file (now support only PNG format). The data values are transformed from range [@var{v1}, @var{v2}] to RGB pixels of bitmap using color scheme @var{scheme} (@pxref{Color scheme}). If @var{v1}>=@var{v2} then the values of @var{v1}, @var{v2} are automatically determined as minimal and maximal value of the data array. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Make another data, Data changing, File I/O, Data processing +@section Make another data +@nav{} +@cindex SubData +@cindex Column +@cindex Trace +@cindex Hist +@cindex Resize +@cindex Evaluate +@cindex Combine +@cindex Momentum +@cindex Sum +@cindex Min +@cindex Max +@cindex Roots +@cindex Correl +@cindex AutoCorrel + + +@anchor{subdata} +@deftypefn {MGL command} {} subdata @sc{res} dat @code{xx [yy=: zz=:]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} SubData (@code{mreal} xx, @code{mreal} yy=@code{-1}, @code{mreal} zz=@code{-1}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} SubData (@code{mreal} xx, @code{mreal} yy=@code{-1}, @code{mreal} zz=@code{-1}) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_subdata (@code{HCDT} dat, @code{mreal} xx, @code{mreal} yy, @code{mreal} zz) +@end ifclear +Extracts sub-array data from the original data array keeping fixed positive index. For example @code{SubData(-1,2)} extracts 3d row (indexes are zero based), @code{SubData(4,-1)} extracts 5th column, @code{SubData(-1,-1,3)} extracts 4th slice and so on. If argument(s) are non-integer then linear interpolation between slices is used. In MGL version this command usually is used as inline one @code{dat(xx,yy,zz)}. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@deftypefn {MGL command} {} subdata @sc{res} dat xdat [ydat=: zdat=:] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} SubData (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} SubData (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_subdata_ext (@code{HCDT} dat, @code{HCDT} xx, @code{HCDT} yy, @code{HCDT} zz) +@end ifclear +Extracts sub-array data from the original data array for indexes specified by arrays @var{xx}, @var{yy}, @var{zz} (indirect access). This function work like previous one for 1D arguments or numbers, and resulting array dimensions are equal dimensions of 1D arrays for corresponding direction. For 2D and 3D arrays in arguments, the resulting array have the same dimensions as input arrays. The dimensions of all argument must be the same (or to be scalar 1*1*1) if they are 2D or 3D arrays. In MGL version this command usually is used as inline one @code{dat(xx,yy,zz)}. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{column} +@deftypefn {MGL command} {} column @sc{res} dat 'eq' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Column (@code{const char *}eq) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Column (@code{const char *}eq) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_column (@code{HCDT} dat, @code{const char *}eq) +@end ifclear +Get column (or slice) of the data filled by formula @var{eq} on column ids. For example, @code{Column("n*w^2/exp(t)");}. The column ids must be defined first by @ref{idset} function or read from files. In MGL version this command usually is used as inline one @code{dat('eq')}. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{resize} +@deftypefn {MGL command} {} resize @sc{res} dat @code{mx [my=1 mz=1]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Resize (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}, @code{mreal} x1=@code{0}, @code{mreal} x2=@code{1}, @code{mreal} y1=@code{0}, @code{mreal} y2=@code{1}, @code{mreal} z1=@code{0}, @code{mreal} z2=@code{1}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Resize (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}, @code{mreal} x1=@code{0}, @code{mreal} x2=@code{1}, @code{mreal} y1=@code{0}, @code{mreal} y2=@code{1}, @code{mreal} z1=@code{0}, @code{mreal} z2=@code{1}) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_resize (@code{HCDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {C function} @code{HMDT} mgl_data_resize_box (@code{HCDT} dat, @code{int} mx, @code{int} my, @code{int} mz, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1, @code{mreal} z2) +@end ifclear +Resizes the data to new size @var{mx}, @var{my}, @var{mz} from box (part) [@var{x1},@var{x2}] x [@var{y1},@var{y2}] x [@var{z1},@var{z2}] of original array. Initially x,y,z coordinates are supposed to be in [0,1]. If one of sizes @var{mx}, @var{my} or @var{mz} is 0 then initial size is used. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{evaluate} +@deftypefn {MGL command} {} evaluate @sc{res} dat idat [@code{norm=on}] +@deftypefnx {MGL command} {} evaluate @sc{res} dat idat jdat [@code{norm=on}] +@deftypefnx {MGL command} {} evaluate @sc{res} dat idat jdat kdat [@code{norm=on}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{const mglDataA &}kdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{const mglDataA &}kdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_evaluate (@code{HCDT} dat, @code{HCDT} idat, @code{HCDT} jdat, @code{HCDT} kdat, @code{int} norm) +@end ifclear +Gets array which values is result of interpolation of original array for coordinates from other arrays. All dimensions must be the same for data @var{idat}, @var{jdat}, @var{kdat}. Coordinates from @var{idat}, @var{jdat}, @var{kdat} are supposed to be normalized in range [0,1] (if @var{norm}=@code{true}) or in ranges [0,nx], [0,ny], [0,nz] correspondingly. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{solve} +@deftypefn {MGL command} {} solve @sc{res} dat @code{val} 'dir' [@code{norm=on}] +@deftypefnx {MGL command} {} solve @sc{res} dat @code{val} 'dir' idat [@code{norm=on}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Solve (@code{mreal} val, @code{char} dir, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mglData} Solve (@code{mreal} val, @code{char} dir, @code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_solve (@code{HCDT} dat, @code{mreal} val, @code{char} dir, @code{HCDT} idat, @code{int} norm) +@end ifclear +Gets array which values is indexes (roots) along given direction @var{dir}, where interpolated values of data @var{dat} are equal to @var{val}. Output data will have the sizes of @var{dat} in directions transverse to @var{dir}. If data @var{idat} is provided then its values are used as starting points. This allows to find several branches by consequentive calls. Indexes are supposed to be normalized in range [0,1] (if @var{norm}=@code{true}) or in ranges [0,nx], [0,ny], [0,nz] correspondingly. Function return NULL or create empty data if data cannot be created for given arguments. @sref{Solve sample} +@end deftypefn + +@anchor{roots} +@deftypefn {MGL command} {} roots @sc{res} 'func' ini ['var'='x'] +@deftypefnx {MGL command} {} roots @sc{res} 'func' @code{ini} ['var'='x'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Roots (@code{const char *}func, @code{char} var) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_roots (@code{const char *}func, @code{HCDT} ini, @code{char} var) +@deftypefnx {C function} @code{mreal} mgl_find_root_txt (@code{const char *}func, @code{mreal} ini, @code{char} var) +@end ifclear +Find roots of equation 'func'=0 for variable @var{var} with initial guess @var{ini}. Secant method is used for root finding. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{hist} +@deftypefn {MGL command} {} hist @sc{res} dat @code{num v1 v2 [nsub=0]} +@deftypefnx {MGL command} {} hist @sc{res} dat wdat @code{num v1 v2 [nsub=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Hist (@code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mglData} Hist (@code{const mglDataA &}w, @code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Hist (@code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Hist (@code{const mglDataA &}w, @code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_hist (@code{HCDT} dat, @code{int} n, @code{mreal} v1, @code{mreal} v2, @code{int} nsub) +@deftypefnx {C function} @code{HMDT} mgl_data_hist_w (@code{HCDT} dat, @code{HCDT} w, @code{int} n, @code{mreal} v1, @code{mreal} v2, @code{int} nsub) +@end ifclear +Creates @var{n}-th points distribution of the data values in range [@var{v1}, @var{v2}]. Array @var{w} specifies weights of the data elements (by default is 1). Parameter @var{nsub} define the number of additional interpolated points (for smoothness of histogram). Function return NULL or create empty data if data cannot be created for given arguments. See also @ref{Data manipulation} +@end deftypefn + +@anchor{momentum} +@deftypefn {MGL command} {} momentum @sc{res} dat 'how' ['dir'='z'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Momentum (@code{char} dir, @code{const char *}how) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Momentum (@code{char} dir, @code{const char *}how) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_momentum (@code{HCDT} dat, @code{char} dir, @code{const char *}how) +@end ifclear +Gets momentum (1d-array) of the data along direction @var{dir}. String @var{how} contain kind of momentum. The momentum is defined like as +@iftex +@math{res_k = \sum_{ij} how(x_i,y_j,z_k) a_{ij}/\sum_{ij} a_{ij}} +@end iftex +@ifnottex +res_k = \sum_ij how(x_i,y_j,z_k) a_ij/ \sum_ij a_ij +@end ifnottex +if @var{dir}=@samp{z} and so on. Coordinates @samp{x}, @samp{y}, @samp{z} are data indexes normalized in range [0,1]. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{sum} +@deftypefn {MGL command} {} sum @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Sum (@code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Sum (@code{const char *}dir) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_sum (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Gets array which is the result of summation in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{max} +@deftypefn {MGL command} {} max @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Max (@code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Max (@code{const char *}dir) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_max_dir (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Gets array which is the maximal data values in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{min} +@deftypefn {MGL command} {} min @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Min (@code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Min (@code{const char *}dir) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_min_dir (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Gets array which is the maximal data values in given direction or direction(s). Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{combine} +@deftypefn {MGL command} {} combine @sc{res} adat bdat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Combine (@code{const mglDataA &}a) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Combine (@code{const mglDataA &}a) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_combine (@code{HCDT} dat, @code{HCDT} a) +@end ifclear +Returns direct multiplication of arrays (like, res[i,j] = this[i]*a[j] and so on). Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{trace} +@deftypefn {MGL command} {} trace @sc{res} dat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Trace () @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglData} Trace () @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_trace (@code{HCDT} dat) +@end ifclear +Gets array of diagonal elements a[i,i] (for 2D case) or a[i,i,i] (for 3D case) where i=0...nx-1. Function return copy of itself for 1D case. Data array must have dimensions ny,nz >= nx or ny,nz = 1. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@anchor{correl} +@deftypefn {MGL command} {} correl @sc{res} adat bdat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mglData} Correl (@code{const mglDataA &}b, @code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mglData} AutoCorrel (@code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglDataC} Correl (@code{const mglDataA &}b, @code{const char *}dir) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mglDataC} AutoCorrel (@code{const char *}dir) @code{const} +@deftypefnx {C function} @code{HMDT} mgl_data_correl (@code{HCDT} a, @code{HCDT} b, @code{const char *}dir) +@deftypefnx {C function} @code{HADT} mgl_datac_correl (@code{HCDT} a, @code{HCDT} b, @code{const char *}dir) +@end ifclear +Find correlation between data @var{a} (or this in C++) and @var{b} along directions @var{dir}. Fourier transform is used to find the correlation. So, you may want to use functions @ref{swap} or @ref{norm} before plotting it. Function return NULL or create empty data if data cannot be created for given arguments. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglDataC}} @code{mglData} Real () @code{const} +@deftypefnx {C function} @code{HMDT} mgl_datac_real (@code{HCDT} dat) +Gets array of real parts of the data. +@end deftypefn +@deftypefn {Method on @code{mglDataC}} @code{mglData} Imag () @code{const} +@deftypefnx {C function} @code{HMDT} mgl_datac_imag (@code{HCDT} dat) +Gets array of imaginary parts of the data. +@end deftypefn +@deftypefn {Method on @code{mglDataC}} @code{mglData} Abs () @code{const} +@deftypefnx {C function} @code{HMDT} mgl_datac_abs (@code{HCDT} dat) +Gets array of absolute values of the data. +@end deftypefn +@deftypefn {Method on @code{mglDataC}} @code{mglData} Arg () @code{const} +@deftypefnx {C function} @code{HMDT} mgl_datac_arg (@code{HCDT} dat) +Gets array of arguments of the data. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data changing, Interpolation, Make another data, Data processing +@section Data changing +@nav{} +@cindex CumSum +@cindex Integral +@cindex Diff +@cindex Diff2 +@cindex SinFFT +@cindex CosFFT +@cindex Hankel +@cindex Swap +@cindex Roll +@cindex Mirror +@cindex Sew +@cindex Smooth +@cindex Envelop +@cindex Norm +@cindex NormSl + +These functions change the data in some direction like differentiations, integrations and so on. The direction in which the change will applied is specified by the string parameter, which may contain @samp{x}, @samp{y} or @samp{z} characters for 1-st, 2-nd and 3-d dimension correspondingly. + +@anchor{cumsum} +@deftypefn {MGL command} {} cumsum dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} CumSum (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} CumSum (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_cumsum (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_cumsum (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Cumulative summation of the data in given direction or directions. +@end deftypefn + +@anchor{integrate} +@deftypefn {MGL command} {} integrate dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Integral (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Integral (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_integral (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_integral (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Integrates (like cumulative summation) the data in given direction or directions. +@end deftypefn + +@anchor{diff} +@deftypefn {MGL command} {} diff dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Diff (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Diff (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_diff (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_diff (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Differentiates the data in given direction or directions. +@end deftypefn + +@deftypefn {MGL command} {} diff dat xdat ydat [zdat=0] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Diff (@code{const mglDataA &}x, @code{const mglDataA &}y) +@deftypefnx {Method on @code{mglData}} @code{void} Diff (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {C function} @code{void} mgl_data_diff_par (@code{HMDT} dat, @code{HCDT} x, @code{HCDT}y, @code{HCDT}z) +@end ifclear +Differentiates the data specified parametrically in direction @var{x} with @var{y}, @var{z}=constant. Parametrical differentiation uses the formula (for 2D case): @math{da/dx = (a_j*y_i-a_i*y_j)/(x_j*y_i-x_i*y_j)} where @math{a_i=da/di, a_j=da/dj} denotes usual differentiation along 1st and 2nd dimensions. The similar formula is used for 3D case. Note, that you may change the order of arguments -- for example, if you have 2D data a(i,j) which depend on coordinates @{x(i,j), y(i,j)@} then usual derivative along @samp{x} will be @code{Diff(x,y);} and usual derivative along @samp{y} will be @code{Diff(y,x);}. +@end deftypefn + +@anchor{diff2} +@deftypefn {MGL command} {} diff2 dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Diff2 (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Diff2 (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_diff2 (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_diff2 (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Double-differentiates (like Laplace operator) the data in given direction. +@end deftypefn + +@anchor{sinfft} +@deftypefn {MGL command} {} sinfft dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} SinFFT (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_sinfft (@code{HMDT} dat, @code{const char *}dir) +@end ifclear +Do Sine transform of the data in given direction or directions. The Sine transform is @math{\sum a_j \sin(k j)} (see @uref{http://en.wikipedia.org/wiki/Discrete_sine_transform#DST-I}). +@end deftypefn + +@anchor{cosfft} +@deftypefn {MGL command} {} cosfft dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} CosFFT (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_cosfft (@code{HMDT} dat, @code{const char *}dir) +@end ifclear +Do Cosine transform of the data in given direction or directions. The Cosine transform is @math{\sum a_j \cos(k j)} (see @uref{http://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-I}). +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglDataC}} @code{void} FFT (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_fft (@code{HADT} dat, @code{const char *}dir) +Do Fourier transform of the data in given direction or directions. If @var{dir} contain @samp{i} then inverse Fourier is used. The Fourier transform is @math{\sum a_j \exp(i k j)} (see @uref{http://en.wikipedia.org/wiki/Discrete_Fourier_transform}). +@end deftypefn +@end ifclear + +@anchor{hankel} +@deftypefn {MGL command} {} hankel dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Hankel (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Hankel (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_hankel (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_hankel (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Do Hankel transform of the data in given direction or directions. The Hankel transform is @math{\sum a_j J_0(k j)} (see @uref{http://en.wikipedia.org/wiki/Hankel_transform}). +@end deftypefn + +@anchor{swap} +@deftypefn {MGL command} {} swap dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Swap (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Swap (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_swap (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_swap (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Swaps the left and right part of the data in given direction (useful for Fourier spectrum). +@end deftypefn + +@anchor{roll} +@deftypefn {MGL command} {} roll dat 'dir' num +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Roll (@code{char} dir, @code{num}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Roll (@code{char} dir, @code{num}) +@deftypefnx {C function} @code{void} mgl_data_roll (@code{HMDT} dat, @code{char} dir, @code{num}) +@deftypefnx {C function} @code{void} mgl_datac_roll (@code{HADT} dat, @code{char} dir, @code{num}) +@end ifclear +Rolls the data along direction @var{dir}. Resulting array will be out[i] = ini[(i+@var{num})%nx] if @code{dir='x'}. +@end deftypefn + +@anchor{mirror} +@deftypefn {MGL command} {} mirror dat 'dir' +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Mirror (@code{const char *}dir) +@deftypefnx {Method on @code{mglDataC}} @code{void} Mirror (@code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_mirror (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_datac_mirror (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Mirror the left-to-right part of the data in given direction. Looks like change the value index @var{i}->@var{n-i}. Note, that the similar effect in graphics you can reach by using options (@pxref{Command options}), for example, @code{surf dat; xrange 1 -1}. +@end deftypefn + +@anchor{sew} +@deftypefn {MGL command} {} sew dat ['dir'='xyz' @code{da=2*pi}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Sew (@code{const char *}dir, @code{mreal} da=@code{2*M_PI}) +@deftypefnx {C function} @code{void} mgl_data_sew (@code{HMDT} dat, @code{const char *}dir, @code{mreal} da) +@end ifclear +Remove value steps (like phase jumps after inverse trigonometric functions) with period @var{da} in given direction. +@end deftypefn + +@anchor{smooth} +@deftypefn {MGL command} {} smooth data @code{type} ['dir'='xyz'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Smooth (@code{const char *}dir=@code{"xyz"}, @code{mreal} delta=@code{0}) +@deftypefnx {Method on @code{mglDataC}} @code{void} Smooth (@code{const char *}dir=@code{"xyz"}, @code{mreal} delta=@code{0}) +@deftypefnx {C function} @code{void} mgl_data_smooth (@code{HMDT} dat, @code{const char *}dir, @code{mreal} delta) +@deftypefnx {C function} @code{void} mgl_datac_smooth (@code{HADT} dat, @code{const char *}dir, @code{mreal} delta) +@end ifclear +Smooths the data on specified direction or directions. String @var{dirs} specifies the dimensions which will be smoothed. It may contain characters: @samp{x} for 1st dimension, @samp{y} for 2nd dimension, @samp{z} for 3d dimension. If string @var{dir} contain: @samp{0} then does nothing, @samp{3} -- linear averaging over 3 points, @samp{5} -- linear averaging over 5 points. By default quadratic averaging over 5 points is used. +@end deftypefn + +@anchor{envelop} +@deftypefn {MGL command} {} envelop dat ['dir'='x'] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Envelop (@code{char} dir=@code{'x'}) +@deftypefnx {C function} @code{void} mgl_data_envelop (@code{HMDT} dat, @code{char} dir) +@end ifclear +Find envelop for data values along direction @var{dir}. +@end deftypefn + +@anchor{norm} +@deftypefn {MGL command} {} norm dat @code{v1 v2 [sym=off dim=0]} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{int} dim=@code{0}) +@end ifclear +Normalizes the data to range [@var{v1},@var{v2}]. If flag @var{sym}=@code{true} then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. Modification will be applied only for slices >=@var{dim}. +@end deftypefn + +@anchor{normsl} +@deftypefn {MGL command} {} normsl dat @code{v1 v2} ['dir'='z' @code{keep=on sym=off}] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} NormSl (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{char} dir=@code{'z'}, @code{bool} keep_en=@code{true}, @code{bool} sym=@code{false}) +@deftypefnx {C function} @code{void} mgl_data_norm_slice (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{char} dir, @code{int} keep_en, @code{int} sym) +@end ifclear +Normalizes data slice-by-slice along direction @var{dir} the data in slices to range [@var{v1},@var{v2}]. If flag @var{sym}=@code{true} then symmetrical interval [-max(|v1|,|v2|), max(|v1|,|v2|)] is used. If @var{keep_en} is set then maximal value of k-th slice will be limited by +@iftex +@math{\sqrt{\sum a_{ij}(k)/\sum a_{ij}(0)}}. +@end iftex +@ifnottex +@math{\sqrt@{\sum a_ij(k)/\sum a_ij(0)@}}. +@end ifnottex +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Interpolation, Data information, Data changing, Data processing +@section Interpolation +@nav{} + +MGL scripts can use linear interpolation by @ref{subdata} command, or spline interpolation by @ref{evaluate} command. Also you can use @ref{resize} for obtaining a data array with new sizes. + +@ifclear UDAV + +However, there are much special faster functions in other modes (C/C++/Fortran/Python/...). + +@cindex Spline +@deftypefn {Method on @code{mglData}} @code{mreal} Spline (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Spline (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_spline (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {C function} @code{dual} mgl_datac_spline (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Interpolates data by cubic spline to the given point @var{x} in [0...nx-1], @var{y} in [0...ny-1], @var{z} in [0...nz-1]. +@end deftypefn +@cindex Spline1 +@deftypefn {Method on @code{mglData}} @code{mreal} Spline1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Spline1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Interpolates data by cubic spline to the given point @var{x}, @var{y}, @var{z} which assumed to be normalized in range [0, 1]. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{mreal} Spline (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_spline_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal *}dx, @code{mreal *}dy, @code{mreal *}dz) +@deftypefnx {C function} @code{dual} mgl_datac_spline_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{dual *}dx, @code{dual *}dy, @code{dual *}dz) +Interpolates data by cubic spline to the given point @var{x} in [0...nx-1], @var{y} in [0...ny-1], @var{z} in [0...nz-1]. The values of derivatives at the point are saved in @var{dif}. +@end deftypefn +@cindex Spline1 +@deftypefn {Method on @code{mglData}} @code{mreal} Spline1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Interpolates data by cubic spline to the given point @var{x}, @var{y}, @var{z} which assumed to be normalized in range [0, 1]. The values of derivatives at the point are saved in @var{dif}. +@end deftypefn + +@cindex Linear +@deftypefn {Method on @code{mglData}} @code{mreal} Linear (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Linear (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_linear (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {C function} @code{dual} mgl_datac_linear (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Interpolates data by linear function to the given point @var{x} in [0...nx-1], @var{y} in [0...ny-1], @var{z} in [0...nz-1]. +@end deftypefn +@cindex Linear1 +@deftypefn {Method on @code{mglData}} @code{mreal} Linear1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Linear1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Interpolates data by linear function to the given point @var{x}, @var{y}, @var{z} which assumed to be normalized in range [0, 1]. +@end deftypefn + +@deftypefn {Method on @code{mglData}} @code{mreal} Linear (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Linear (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_linear_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal *}dx, @code{mreal *}dy, @code{mreal *}dz) +@deftypefnx {C function} @code{dual} mgl_datac_linear_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{dual *}dx, @code{dual *}dy, @code{dual *}dz) +Interpolates data by linear function to the given point @var{x} in [0...nx-1], @var{y} in [0...ny-1], @var{z} in [0...nz-1]. The values of derivatives at the point are saved in @var{dif}. +@end deftypefn +@cindex Linear1 +@deftypefn {Method on @code{mglData}} @code{mreal} Linear1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{dual} Linear1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Interpolates data by linear function to the given point @var{x}, @var{y}, @var{z} which assumed to be normalized in range [0, 1]. The values of derivatives at the point are saved in @var{dif}. +@end deftypefn + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data information, Operators, Interpolation, Data processing +@section Data information +@nav{} + +There are a set of functions for obtaining data properties in MGL language. However most of them can be found using "suffixes". Suffix can get some numerical value of the data array (like its size, maximal or minimal value, the sum of elements and so on) as number. Later it can be used as usual number in command arguments. The suffixes start from point @samp{.} right after (without spaces) variable name or its sub-array. For example, @code{a.nx} give the x-size of data @var{a}, @code{b(1).max} give maximal value of second row of variable @var{b}, @code{(c(:,0)^2).sum} give the sum of squares of elements in the first column of @var{c} and so on. + + +@cindex PrintInfo +@anchor{info} +@deftypefn {MGL command} {} info dat +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{const char *} PrintInfo () @code{const} +@deftypefnx {Method on @code{mglData}} @code{void} PrintInfo (@code{FILE *}fp) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{const char *} PrintInfo () @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{void} PrintInfo (@code{FILE *}fp) @code{const} +@deftypefnx {C function} @code{const char *} mgl_data_info (@code{HCDT} dat) +@end ifclear +Gets or prints to file @var{fp} or as message (in MGL) information about the data (sizes, maximum/minimum, momentums and so on). +@end deftypefn + +@deftypefn {MGL command} {} info 'txt' +Prints string @var{txt} as message. +@end deftypefn + +@deftypefn {MGL command} {} info val +Prints value of number @var{val} as message. +@end deftypefn + +@cindex GetNx +@cindex GetNy +@cindex GetNz +@anchor{.nx} @anchor{.ny} @anchor{.nz} +@deftypefn {MGL suffix} {(dat)} .nx +@deftypefnx {MGL suffix} {(dat)} .ny +@deftypefnx {MGL suffix} {(dat)} .nz +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{long} GetNx () +@deftypefnx {Method on @code{mglData}} @code{long} GetNy () +@deftypefnx {Method on @code{mglData}} @code{long} GetNz () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNx () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNy () +@deftypefnx {Method on @code{mglDataC}} @code{long} GetNz () +@deftypefnx {C function} @code{long} mgl_data_get_nx (@code{HCDT} dat) +@deftypefnx {C function} @code{long} mgl_data_get_ny (@code{HCDT} dat) +@deftypefnx {C function} @code{long} mgl_data_get_nz (@code{HCDT} dat) +@end ifclear +Gets the x-, y-, z-size of the data. +@end deftypefn + + + +@cindex Maximal +@anchor{.max} +@deftypefn {MGL suffix} {(dat)} .max +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mreal} Maximal () @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Maximal () @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_max (@code{HCDT} dat) +@end ifclear +Gets maximal value of the data. +@end deftypefn + +@cindex Minimal +@anchor{.min} +@deftypefn {MGL suffix} {(dat)} .min +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mreal} Minimal () @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Minimal () @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_min (@code{HMDT} dat) @code{const} +@end ifclear +Gets minimal value of the data. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglData}} @code{mreal} Minimal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Minimal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_min_int (@code{HCDT} dat, @code{int} *i, @code{int} *j, @code{int} *k) +Gets position of minimum to variables @var{i}, @var{j}, @var{k} and returns the minimal value. +@end deftypefn +@deftypefn {Method on @code{mglData}} @code{mreal} Maximal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Maximal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_max_int (@code{HCDT} dat, @code{int} *i, @code{int} *j, @code{int} *k) +Gets position of maximum to variables @var{i}, @var{j}, @var{k} and returns the maximal value. +@end deftypefn +@deftypefn {Method on @code{mglData}} @code{mreal} Minimal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Minimal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_min_real (@code{HCDT} dat, @code{mreal} *x, @code{mreal} *y, @code{mreal} *z) +Gets approximated (interpolated) position of minimum to variables @var{x}, @var{y}, @var{z} and returns the minimal value. +@end deftypefn +@end ifclear + +@anchor{.mx} @anchor{.my} @anchor{.mz} +@deftypefn {MGL suffix} {(dat)} .mx +@deftypefnx {MGL suffix} {(dat)} .my +@deftypefnx {MGL suffix} {(dat)} .mz +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mreal} Maximal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Method on @code{mglDataC}} @code{mreal} Maximal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_max_real (@code{HCDT} dat, @code{mreal} *x, @code{mreal} *y, @code{mreal} *z) +@end ifclear +Gets approximated (interpolated) position of maximum to variables @var{x}, @var{y}, @var{z} and returns the maximal value. +@end deftypefn + + +@cindex Momentum +@anchor{.ax} @anchor{.ay} @anchor{.az} @anchor{.aa} @anchor{.sum} +@anchor{.wx} @anchor{.wy} @anchor{.wz} @anchor{.wa} +@anchor{.sx} @anchor{.sy} @anchor{.sz} @anchor{.sa} +@anchor{.kx} @anchor{.ky} @anchor{.kz} @anchor{.ka} +@deftypefn {MGL suffix} {(dat)} .sum +@deftypefnx {MGL suffix} {(dat)} .ax +@deftypefnx {MGL suffix} {(dat)} .ay +@deftypefnx {MGL suffix} {(dat)} .az +@deftypefnx {MGL suffix} {(dat)} .aa +@deftypefnx {MGL suffix} {(dat)} .wx +@deftypefnx {MGL suffix} {(dat)} .wy +@deftypefnx {MGL suffix} {(dat)} .wz +@deftypefnx {MGL suffix} {(dat)} .wa +@deftypefnx {MGL suffix} {(dat)} .sx +@deftypefnx {MGL suffix} {(dat)} .sy +@deftypefnx {MGL suffix} {(dat)} .sz +@deftypefnx {MGL suffix} {(dat)} .sa +@deftypefnx {MGL suffix} {(dat)} .kx +@deftypefnx {MGL suffix} {(dat)} .ky +@deftypefnx {MGL suffix} {(dat)} .kz +@deftypefnx {MGL suffix} {(dat)} .ka +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{mreal} Momentum (@code{char} dir, @code{mreal} &a, @code{mreal} &w) @code{const} +@deftypefnx {Method on @code{mglData}} @code{mreal} Momentum (@code{char} dir, @code{mreal} &m, @code{mreal} &w, @code{mreal} &s, @code{mreal} &k) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_momentum_val (@code{HCDT} dat, @code{char} dir, @code{mreal} *a, @code{mreal} *w, @code{mreal} *s, @code{mreal} *k) +@end ifclear +Gets zero-momentum (energy, @math{I=\sum dat_i}) and write first momentum (median, @math{a = \sum \xi_i dat_i/I}), second momentum (width, @math{w^2 = \sum (\xi_i-a)^2 dat_i/I}), third momentum (skewness, @math{s = \sum (\xi_i-a)^3 dat_i/ I w^3}) and fourth momentum (kurtosis, @math{k = \sum (\xi_i-a)^4 dat_i / 3 I w^4}) to variables. Here @math{\xi} is corresponding coordinate if @var{dir} is @samp{'x'}, @samp{'y'} or @samp{'z'}. Otherwise median is @math{a = \sum dat_i/N}, width is @math{w^2 = \sum (dat_i-a)^2/N} and so on. +@end deftypefn + +@anchor{.fst} +@deftypefn {MGL suffix} {(dat)} .fst +@ifclear UDAV +@cindex Find +@deftypefnx {Method on @code{mglData}} @code{mreal} Find (@code{const char *}cond, @code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_first (@code{HCDT} dat, @code{const char *}cond, @code{int} *i, @code{int} *j, @code{int} *k) +@end ifclear +Find position (after specified in @var{i}, @var{j}, @var{k}) of first nonzero value of formula @var{cond}. Function return the data value at found position. +@end deftypefn + +@anchor{.lst} +@deftypefn {MGL suffix} {(dat)} .lst +@ifclear UDAV +@cindex Last +@deftypefnx {Method on @code{mglData}} @code{mreal} Last (@code{const char *}cond, @code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_last (@code{HCDT} dat, @code{const char *}cond, @code{int} *i, @code{int} *j, @code{int} *k) +@end ifclear +Find position (before specified in @var{i}, @var{j}, @var{k}) of last nonzero value of formula @var{cond}. Function return the data value at found position. +@end deftypefn + +@ifclear UDAV +@deftypefn {Method on @code{mglData}} @code{int} Find (@code{const char *}cond, @code{char} dir, @code{int} i=@code{0}, @code{int} j=@code{0}, @code{int} k=@code{0}) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_find (@code{HCDT} dat, @code{const char *}cond, @code{int} i, @code{int} j, @code{int} k) +Return position of first in direction @var{dir} nonzero value of formula @var{cond}. The search is started from point @{i,j,k@}. +@end deftypefn +@cindex FindAny +@deftypefn {Method on @code{mglData}} @code{bool} FindAny (@code{const char *}cond) @code{const} +@deftypefnx {C function} @code{mreal} mgl_data_find_any (@code{HCDT} dat, @code{const char *}cond) +Determines if any nonzero value of formula in the data array. +@end deftypefn +@end ifclear + +@anchor{.a} +@deftypefn {MGL suffix} {(dat)} .a +Give first (for @code{.a}, i.e. @code{dat->a[0]}). +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Operators, Global functions, Data information, Data processing +@section Operators +@nav{} + +@deftypefn {MGL command} {} copy @sc{dat} dat2 ['eq'=''] +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} operator= (@code{const mglDataA &}d) +@end ifclear +Copies data from other variable. +@end deftypefn + +@deftypefn {MGL command} {} copy dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mreal}} @code{void} operator= (@code{mreal} val) +@end ifclear +Set all data values equal to @var{val}. +@end deftypefn + +@anchor{multo} +@deftypefn {MGL command} {} multo dat dat2 +@deftypefnx {MGL command} {} multo dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} operator*= (@code{const mglDataA &}d) +@deftypefnx {Method on @code{mglData}} @code{void} operator*= (@code{mreal} d) +@deftypefnx {C function} @code{void} mgl_data_mul_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {C function} @code{void} mgl_data_mul_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Multiplies data element by the other one or by value. +@end deftypefn + +@anchor{divto} +@deftypefn {MGL command} {} divto dat dat2 +@deftypefnx {MGL command} {} divto dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} operator/= (@code{const mglDataA &}d) +@deftypefnx {Method on @code{mglData}} @code{void} operator/= (@code{mreal} d) +@deftypefnx {C function} @code{void} mgl_data_div_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {C function} @code{void} mgl_data_div_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Divides each data element by the other one or by value. +@end deftypefn + +@anchor{addto} +@deftypefn {MGL command} {} addto dat dat2 +@deftypefnx {MGL command} {} addto dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} operator+= (@code{const mglDataA &}d) +@deftypefnx {Method on @code{mglData}} @code{void} operator+= (@code{mreal} d) +@deftypefnx {C function} @code{void} mgl_data_add_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {C function} @code{void} mgl_data_add_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Adds to each data element the other one or the value. +@end deftypefn + +@anchor{subto} +@deftypefn {MGL command} {} subto dat dat2 +@deftypefnx {MGL command} {} subto dat @code{val} +@ifclear UDAV +@deftypefnx {Method on @code{mglData}} @code{void} operator-= (@code{const mglDataA &}d) +@deftypefnx {Method on @code{mglData}} @code{void} operator-= (@code{mreal} d) +@deftypefnx {C function} @code{void} mgl_data_sub_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {C function} @code{void} mgl_data_sub_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Subtracts from each data element the other one or the value. +@end deftypefn + +@ifclear UDAV +@deftypefn {Library Function} mglData operator+ (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator+ (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator+ (@code{const mglDataA &}a, @code{mreal} b) +Adds the other data or the number. +@end deftypefn + +@deftypefn {Library Function} mglData operator- (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator- (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator- (@code{const mglDataA &}a, @code{mreal} b) +Subtracts the other data or the number. +@end deftypefn + +@deftypefn {Library Function} mglData operator* (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator* (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator* (@code{const mglDataA &}a, @code{mreal} b) +Multiplies by the other data or the number. +@end deftypefn + +@deftypefn {Library Function} mglData operator/ (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator/ (@code{const mglDataA &}a, @code{mreal} b) +Divides by the other data or the number. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Global functions, Evaluate expression, Operators, Data processing +@section Global functions +@nav{} + +@ifclear UDAV +These functions are not methods of @code{mglData} class. However it provide additional functionality to handle data. So I put it in this chapter. +@end ifclear + +@anchor{transform} +@deftypefn {MGL command} {} transform @sc{dat} 'type' real imag +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTransform (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{const char *}type) +@deftypefnx {C function} @code{HMDT} mgl_transform (@code{HCDT} real, @code{HCDT} imag, @code{const char *}type) +@end ifclear +Does integral transformation of complex data @var{real}, @var{imag} on specified direction. The order of transformations is specified in string @var{type}: first character for x-dimension, second one for y-dimension, third one for z-dimension. The possible character are: @samp{f} is forward Fourier transformation, @samp{i} is inverse Fourier transformation, @samp{s} is Sine transform, @samp{c} is Cosine transform, @samp{h} is Hankel transform, @samp{n} or @samp{ } is no transformation. +@end deftypefn + +@anchor{transforma} +@deftypefn {MGL command} {} transforma @sc{dat} 'type' ampl phase +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTransformA @code{const mglDataA &}ampl, @code{const mglDataA &}phase, @code{const char *}type) +@deftypefnx {C function} @code{HMDT} mgl_transform_a @code{HCDT} ampl, @code{HCDT} phase, @code{const char *}type) +@end ifclear +The same as previous but with specified amplitude @var{ampl} and phase @var{phase} of complex numbers. +@end deftypefn + +@anchor{fourier} +@deftypefn {MGL command} {} fourier reDat imDat 'dir' +@ifclear UDAV +@deftypefnx {Global function} @code{void} mglFourier @code{const mglDataA &}re, @code{const mglDataA &}im, @code{const char *}dir) +@deftypefnx {C function} @code{void} mgl_data_fourier @code{HCDT} re, @code{HCDT} im, @code{const char *}dir) +@end ifclear +Does Fourier transform of complex data @var{re}+i*@var{im} in directions @var{dir}. Result is placed back into @var{re} and @var{im} data arrays. +@end deftypefn + +@anchor{stfad} +@deftypefn {MGL command} {} stfad @sc{res} real imag @code{dn} ['dir'='x'] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglSTFA (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{int} dn, @code{char} dir=@code{'x'}) +@deftypefnx {C function} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn,@code{char} dir) +@end ifclear +Short time Fourier transformation for real and imaginary parts. Output is amplitude of partial Fourier of length @var{dn}. For example if @var{dir}=@samp{x}, result will have size @{int(nx/dn), dn, ny@} and it will contain @math{res[i,j,k]=|\sum_d^dn exp(I*j*d)*(real[i*dn+d,k]+I*imag[i*dn+d,k])|/dn}. +@end deftypefn + +@anchor{pde} +@deftypefn {MGL command} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglPDE (@code{HMGL} gr, @code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{mreal} dz=@code{0.1}, @code{mreal} k0=@code{100}, @code{const char *}opt=@code{""}) +@deftypefnx {C function} @code{HMDT} mgl_pde_solve (@code{HMGL} gr, @code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{mreal} dz, @code{mreal} k0, @code{const char *}opt) +@end ifclear +Solves equation du/dz = i*k0*@var{ham}(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters @var{ini_re}, @var{ini_im} specify real and imaginary part of initial field distribution. Parameters @var{Min}, @var{Max} set the bounding box for the solution. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter @var{dz} set the step along evolutionary coordinate z. At this moment, simplified form of function @var{ham} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this function is effectively @math{ham = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed. Here variable @samp{u} is used for field amplitude |u|. This allow one solve nonlinear problems -- for example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. You may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{ham = hre+i*him}). @sref{PDE solving hints} +@end deftypefn + +@anchor{ray} +@deftypefn {MGL command} {} ray @sc{res} 'ham' @code{x0 y0 z0 p0 q0 v0 [dt=0.1 tmax=10]} +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglRay (@code{const char *}ham, @code{mglPoint} r0, @code{mglPoint} p0, @code{mreal} dt=@code{0.1}, @code{mreal} tmax=@code{10}) +@deftypefnx {C function} @code{HMDT} mgl_ray_trace (@code{const char *}ham, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} px, @code{mreal} py, @code{mreal} pz, @code{mreal} dt, @code{mreal} tmax) +@end ifclear +Solves GO ray equation like dr/dt = d @var{ham}/dp, dp/dt = -d @var{ham}/dr. This is Hamiltonian equations for particle trajectory in 3D case. Here @var{ham} is Hamiltonian which may depend on coordinates @samp{x}, @samp{y}, @samp{z}, momentums @samp{p}=px, @samp{q}=py, @samp{v}=pz and time @samp{t}: @math{ham = H(x,y,z,p,q,v,t)}. The starting point (at @code{t=0}) is defined by variables @var{r0}, @var{p0}. Parameters @var{dt} and @var{tmax} specify the integration step and maximal time for ray tracing. Result is array of @{x,y,z,p,q,v,t@} with dimensions @{7 * int(@var{tmax}/@var{dt}+1) @}. +@end deftypefn + +@anchor{qo2d} +@deftypefn {MGL command} {} qo2d @sc{res} 'ham' ini_re ini_im ray [@code{r=1 k0=100} xx yy] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglQO2d (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{const mglDataA &}ray, @code{mreal} r=@code{1}, @code{mreal} k0=@code{100}, @code{mglData *}xx=@code{0}, @code{mglData *}yy=@code{0}) +@deftypefnx {Global function} @code{mglData} mglQO2d (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{const mglDataA &}ray, @code{mglData &}xx, @code{mglData &}yy, @code{mreal} r=@code{1}, @code{mreal} k0=@code{100}) +@deftypefnx {C function} @code{HMDT} mgl_qo2d_solve (@code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{HCDT} ray, @code{mreal} r, @code{mreal} k0, @code{HMDT} xx, @code{HMDT} yy) +@end ifclear +Solves equation du/dt = i*k0*@var{ham}(p,q,x,y,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators (see @code{mglPDE()} for details). Parameters @var{ini_re}, @var{ini_im} specify real and imaginary part of initial field distribution. Parameters @var{ray} set the reference ray, i.e. the ray around which the accompanied coordinate system will be maked. You may use, for example, the array created by @code{mglRay()} function. Note, that the reference ray @strong{must be} smooth enough to make accompanied coodrinates unambiguity. Otherwise errors in the solution may appear. If @var{xx} and @var{yy} are non-zero then Cartesian coordinates for each point will be written into them. See also @code{mglPDE()}. @sref{PDE solving hints} +@end deftypefn + +@anchor{jacobian} +@deftypefn {MGL command} {} jacobian @sc{res} xdat ydat [zdat] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglJacobian (@code{const mglDataA &}x, @code{const mglDataA &}y) +@deftypefnx {Global function} @code{mglData} mglJacobian (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {C function} @code{HMDT} mgl_jacobian_2d (@code{HCDT} x, @code{HCDT} y) +@deftypefnx {C function} @code{HMDT} mgl_jacobian_3d (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z) +@end ifclear +Computes the Jacobian for transformation @{i,j,k@} to @{@var{x},@var{y},@var{z}@} where initial coordinates @{i,j,k@} are data indexes normalized in range [0,1]. The Jacobian is determined by formula det||@math{dr_\alpha/d\xi_\beta}|| where @math{r}=@{@var{x},@var{y},@var{z}@} and @math{\xi}=@{i,j,k@}. All dimensions must be the same for all data arrays. Data must be 3D if all 3 arrays @{@var{x},@var{y},@var{z}@} are specified or 2D if only 2 arrays @{@var{x},@var{y}@} are specified. +@end deftypefn + +@anchor{triangulation} +@deftypefn {MGL command} {} triangulation @sc{res} xdat ydat +@c @deftypefn {MGL command} {} triangulation @sc{res} xdat ydat [zdat] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTriangulation (@code{const mglDataA &}x, @code{const mglDataA &}y) +@c @deftypefnx {Global function} @code{mglData} mglTriangulation (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {C function} @code{HMDT} mgl_triangulation_2d (@code{HCDT} x, @code{HCDT} y) +@c @deftypefnx {C function} @code{HMDT} mgl_triangulation_3d (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z) +@end ifclear +Computes triangulation for arbitrary placed points with coordinates @{@var{x},@var{y}@} (i.e. finds triangles which connect points). MathGL use @uref{http://www.s-hull.org/,s-hull} code for triangulation. The sizes of 1st dimension @strong{must be equal} for all arrays @code{x.nx=y.nx}. Resulting array can be used in @ref{triplot} or @ref{tricont} functions for visualization of reconstructed surface. @sref{Making regular data} +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Evaluate expression, MGL variables, Global functions, Data processing +@section Evaluate expression +@nav{} + +@ifset UDAV +You can use arbitrary formulas of existed data arrays or constants as any argument of data processing or data plotting commands. There are only 2 limitations: formula shouldn't contain spaces (to be recognized as single argument), and formula cannot be used as argument which will be (re)created by MGL command. +@end ifset + +@ifclear UDAV +@cindex mglExpr +@cindex mglExprC + +MathGL have a special classes @code{mglExpr} and @code{mglExprC} for evaluating of formula specified by the string for real and complex numbers correspondingly. These classes are defined in @code{#include } and @code{#include } correspondingly. It is the fast variant of formula evaluation. At creation it will be recognized and compiled to tree-like internal code. At evaluation stage only fast calculations are performed. There is no difference between lower or upper case in formulas. If argument value lie outside the range of function definition then function returns NaN. @xref{Textual formulas}. + +@deftypefn {Constructor on @code{mglExpr}} @code{} mglExpr (@code{const char *}expr) +@deftypefnx {Constructor on @code{mglExprC}} @code{} mglExprC (@code{const char *}expr) +@deftypefnx {C function} @code{HMEX} mgl_create_expr (@code{const char *}expr) +@deftypefnx {C function} @code{HAEX} mgl_create_cexpr (@code{const char *}expr) +Parses the formula @var{expr} and creates formula-tree. Constructor recursively parses the formula and creates a tree-like structure containing functions and operators for fast further evaluating by @code{Calc()} or @code{CalcD()} functions. +@end deftypefn + +@deftypefn {Destructor on @code{mglExpr}} @code{} ~mglExpr () +@deftypefnx {Destructor on @code{mglExprC}} @code{} ~mglExprC () +@deftypefnx {C function} @code{void} mgl_delete_expr (@code{HMEX} ex) +@deftypefnx {C function} @code{void} mgl_delete_cexpr (@code{HAEX} ex) +Deletes the instance of class mglExpr. +@end deftypefn + +@deftypefn {Method on @code{mglExpr}} @code{mreal} Eval (@code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Method on @code{mglExprC}} @code{dual} Eval (@code{dual} x, @code{dual} y, @code{dual} z) +@deftypefnx {C function} @code{mreal} mgl_expr_eval (@code{HMEX} ex, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {C function} @code{dual} mgl_cexpr_eval (@code{HAEX} ex, @code{dual} x, @code{dual} y, @code{dual} z) +Evaluates the formula for @code{'x','r'}=@var{x}, @code{'y','n'}=@var{y}, @code{'z','t'}=@var{z}, @code{'a','u'}=@var{u}. +@end deftypefn + +@deftypefn {Method on @code{mglExpr}} @code{mreal} Eval (@code{mreal} var[26]) +@deftypefnx {Method on @code{mglExprC}} @code{dual} Eval (@code{dual} var[26]) +@deftypefnx {C function} @code{mreal} mgl_expr_eval_v (@code{HMEX} ex, @code{mreal *}var) +@deftypefnx {C function} @code{dual} mgl_expr_eval_v (@code{HAEX} ex, @code{dual *}var) +Evaluates the formula for variables in array @var{var}[0,...,'z'-'a']. +@end deftypefn + + +@deftypefn {Method on @code{mglExpr}} @code{mreal} Diff (@code{char} dir, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {C function} @code{mreal} mgl_expr_diff (@code{HMEX} ex, @code{char} dir, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Evaluates the formula derivation respect to @var{dir} for @code{'x','r'}=@var{x}, @code{'y','n'}=@var{y}, @code{'z','t'}=@var{z}, @code{'a','u'}=@var{u}. +@end deftypefn + +@deftypefn {Method on @code{mglExpr}} @code{mreal} Diff (@code{char} dir, @code{mreal} var[26]) +@deftypefnx {C function} @code{mreal} mgl_expr_diff_v (@code{HMEX} ex, @code{char} dir, @code{mreal *}var) +Evaluates the formula derivation respect to @var{dir} for variables in array @var{var}[0,...,'z'-'a']. +@end deftypefn + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node MGL variables, , Evaluate expression, Data processing +@section MGL variables +@nav{} + +@ifset UDAV +For information about MGL variables see @ref{MGL definition}. +@end ifset + +@ifclear UDAV + +Class mglVar represent MGL variables. It is needed for parsing MGL scripts (see @ref{mglParse class}). This class is derived from @code{mglData} and is defined in @code{#include }. + +@deftypecv {Variable} mglVar @code{std::wstring} s +Name of variable. +@end deftypecv + +@deftypecv {Variable} mglVar @code{mglVar *} next +@deftypecvx {Variable} mglVar @code{mglVar *} prev +Next and previous variable in the list. +@end deftypecv + +@deftypecv {Variable} mglVar @code{bool} temp +Flag of the temporary variable. If @code{true} the this variable will be removed after script execution. +@end deftypecv + +@deftypecv {Variable} mglVar @code{void} @code{void (*}func@code{)(void *)} +Callback function, which will be called at variable destroying. +@end deftypecv + +@deftypecv {Variable} mglVar @code{void *} o +Pointer to external object for callback function. +@end deftypecv + +@deftypefn {Constructor on @code{mglVar}} @code{} mglVar () +Create variable with size 1*1*1. +@end deftypefn + +@deftypefn {Destructor on @code{mglVar}} @code{} ~mglVar () +Deletes the instance of class mglVar. +@end deftypefn + +@deftypefn {Method on @code{mglVar}} @code{void} MoveAfter (@code{mglVar *}var) +Move variable after @var{var} in the list. +@end deftypefn + +@end ifclear + +@external{} diff --git a/texinfo/data_ru.texi b/texinfo/data_ru.texi new file mode 100644 index 0000000..a5c82ca --- /dev/null +++ b/texinfo/data_ru.texi @@ -0,0 +1,1611 @@ +@c ------------------------------------------------------------------ +@chapter Обработка данных +@nav{} + +@ifset UDAV +В данной главе описываются команды для работы с массивами данных. Они включают команды для выделения памяти и изменения размера данных, чтения данных из файла, численного дифференцирования, интегрирования, интерполяции и пр., заполнения по текстовой формуле и т.д. Класс позволяет работать с данными размерности не более 3 (как функции от трёх переменных -- x,y,z). Массивы которые могут быть созданы командами MGL отображаются Small Caps шрифтом (например, @sc{dat}). +@end ifset + +@ifclear UDAV +В данной главе описываются классы @code{mglData} и @code{mglDataC} для работы с массивами действительных и комплексных данных, определённые в @code{#include } и @code{#include } соответственно. Оба класса являются наследниками абстрактного класса @code{mglDataA}, и могут быть использованы в аргументах всех функций рисования (см. @ref{MathGL core}). Классы содержат функции для выделения памяти и изменения размера данных, чтения данных из файла, численного дифференцирования, интегрирования, интерполяции и пр., заполнения по текстовой формуле и т.д. Классы позволяют работать с данными размерности не более 3 (как функции от трёх переменных -- x,y,z). По умолчанию внутреннее представление данных использует тип mreal (и dual=std::complex для @code{mglDataC}), который может быть сконфигурирован как float или double на этапе установки указав опцию @code{--enable-double} (см. @ref{Installation}). Тип float удобен в силу меньшего размера занимаемой памяти и, как правило, достаточной для построения графиков точности. Однако, тип double имеет большую точность, что может быть важно, например, для осей с метками времени. Массивы которые могут быть созданы командами MGL отображаются Small Caps шрифтом (например, @sc{dat}). +@end ifclear + +@menu +* Public variables:: +* Data constructor:: +* Data resizing:: +* Data filling:: +* File I/O:: +* Make another data:: +* Data changing:: +* Interpolation:: +* Data information:: +* Operators:: +* Global functions:: +* Evaluate expression:: +* MGL variables:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Public variables, Data constructor, , Data processing +@section Переменные +@nav{} + +@ifset UDAV +MGL не поддерживает прямой доступ к элементам массива. См. раздел @ref{Data filling} +@end ifset + +@ifclear UDAV +@deftypecv {Variable} mglData @code{mreal *} a +@deftypecvx {Variable} mglDataC @code{dual *} a +Указатель на массив данных. Это одномерный массив. Например, матрица [nx x ny x nz] представляется одномерным массивом длиной nx*ny*nz, где элемент с индексами @{i, j, k@} находится как a[i+nx*j+nx*ny*k] (индексы отсчитываются от нуля). +@end deftypecv +@deftypecv {Variable} mglData @code{int} nx +@deftypecvx {Variable} mglDataC @code{long} nx +Размер массива по 1-ой размерности ('x' размерности). +@end deftypecv +@deftypecv {Variable} mglData @code{int} ny +@deftypecvx {Variable} mglDataC @code{long} ny +Размер массива по 2-ой размерности ('y' размерности). +@end deftypecv +@deftypecv {Variable} mglData @code{int} nz +@deftypecvx {Variable} mglDataC @code{long} nz +Размер массива по 3-ей размерности ('z' размерности). +@end deftypecv +@deftypecv {Variable} mglData @code{std::string} id +@deftypecvx {Variable} mglDataC @code{std::string} id +Имена колонки (или среза при nz>1) -- один символ на колонку. +@end deftypecv +@deftypecv {Variable} mglData @code{bool} link +@deftypecvx {Variable} mglDataC @code{bool} link +Флаг использования указателя на внешние данные, включает запрет на удаление массива данных. +@end deftypecv + +@deftypefn {Метод класса @code{mglData}} @code{mreal} GetVal (@code{long} i) +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} GetVal (@code{long} i) +@deftypefnx {Метод класса @code{mglData}} @code{void} SetVal (@code{mreal} val, @code{long} i) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} SetVal (@code{mreal} val, @code{long} i) +Присваивает или возвращает значение используя "непрерывную" индексацию без проверки выхода за границы массива. Индекс @var{i} должен быть в диапазоне [0, nx*ny*nz-1]. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{long} GetNx () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNx () +@deftypefnx {Метод класса @code{mglData}} @code{long} GetNy () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNy () +@deftypefnx {Метод класса @code{mglData}} @code{long} GetNz () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNz () +@deftypefnx {Функция С} @code{long} mgl_data_get_nx (@code{HCDT} dat) +@deftypefnx {Функция С} @code{long} mgl_data_get_ny (@code{HCDT} dat) +@deftypefnx {Функция С} @code{long} mgl_data_get_nz (@code{HCDT} dat) +Возвращает размер данных в направлении x, y и z соответственно. +@end deftypefn + +@deftypefn {Функция С} @code{mreal} mgl_data_get_value (@code{HCDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{dual} mgl_datac_get_value (@code{HCDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{mreal *} mgl_data_value (@code{HMDT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{dual *} mgl_datac_value (@code{HADT} dat, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{void} mgl_data_set_value (@code{HMDT} dat, @code{mreal} v, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{void} mgl_datac_set_value (@code{HADT} dat, @code{dual} v, @code{int} i, @code{int} j, @code{int} k) +Присваивает или возвращает значение ячейки данных с проверкой выхода за пределы массива. +@end deftypefn +@deftypefn {Функция С} @code{const mreal *} mgl_data_data (@code{HCDT} dat) +Возвращает указатель на внутренний массив данных. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data constructor, Data resizing, Public variables, Data processing +@section Создание и удаление данных +@nav{} +@cindex mglData + +@ifset UDAV +There are many functions, which can create data for output (see @ref{Data filling}, @ref{File I/O}, @ref{Make another data}, @ref{Global functions}). Here I put most useful of them. +@end ifset + +@anchor{new} +@deftypefn {Команда MGL} {} new @sc{dat} [@code{nx=1} 'eq'] +@deftypefnx {Команда MGL} {} new @sc{dat} @code{nx ny} ['eq'] +@deftypefnx {Команда MGL} {} new @sc{dat} @code{nx ny nz} ['eq'] +@ifclear UDAV +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{int} mx=@code{1}, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} mx=@code{1}, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Функция С} @code{HMDT} mgl_create_data () +@deftypefnx {Функция С} @code{HMDT} mgl_create_data_size (@code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Выделяет память для массива данных и заполняет её нулями. Если указана формула @var{eq}, то данные заполняются также как при использовании @ref{fill}. +@end deftypefn + +@anchor{copy} +@deftypefn {Команда MGL} {} copy @sc{dat} dat2 ['eq'=''] +@deftypefnx {Команда MGL} {} copy @sc{dat} @code{val} +@ifclear UDAV +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{const mglData &}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{const mglDataA *}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{int} size, @code{const mreal *}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{int} size, @code{int} cols, @code{const mreal *}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{int} size, @code{const double *}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{int} size, @code{int} cols, @code{const double *}dat2) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{const double *}dat2, @code{int} size) +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{const double *}dat2, @code{int} size, @code{int} cols) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{const mglDataA &}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{const mglDataA *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{const float *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const float *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{const double *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const double *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{const dual *}dat2) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{int} size, @code{int} cols, @code{const dual *}dat2) +@end ifclear +Копирует данные из другого экземпляра данных. Если указана формула @var{eq}, то данные заполняются также как при использовании @ref{fill}. +@end deftypefn + +@deftypefn {Команда MGL} {} read @sc{dat} 'fname' +@ifclear UDAV +@deftypefnx {Конструктор класса @code{mglData}} {} mglData (@code{const char *}fname) +@deftypefnx {Конструктор класса @code{mglDataC}} {} mglDataC (@code{const char *}fname) +@deftypefnx {Функция С} @code{HMDT} mgl_create_data_file (@code{const char *}fname) +@deftypefnx {Функция С} @code{HADT} mgl_create_datac_file (@code{const char *}fname) +@end ifclear +Читает данные из текстового файла с автоматическим определением размеров массива. +@end deftypefn + +@deftypefn {Команда MGL} {} delete dat +@ifclear UDAV +@deftypefnx {Destructor on @code{mglData}} {} ~mglData () +@deftypefnx {Функция С} @code{void} mgl_delete_data (@code{HMDT} dat) +@deftypefnx {Destructor on @code{mglDataC}} {} ~mglDataC () +@deftypefnx {Функция С} @code{void} mgl_delete_datac (@code{HADT} dat) +@end ifclear +Удаляет массив данных из памяти. +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Data resizing, Data filling, Data constructor, Data processing +@section Изменение размеров данных +@nav{} +@cindex Create +@cindex Rearrange +@cindex Extend +@cindex Transpose +@cindex Squeeze +@cindex Crop +@cindex Insert +@cindex Delete +@cindex Sort +@cindex Clean +@cindex Join + + +@deftypefn {Команда MGL} {} new @sc{dat} [@code{nx=1 ny=1 nz=1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Create (@code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Create (@code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_create (@code{HMDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {Функция С} @code{void} mgl_datac_create (@code{HADT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Создает/пересоздает массив данных указанного размера и заполняет его нулями. Ничего не делает при @var{mx}, @var{my}, @var{mz} отрицательных или равных нулю. +@end deftypefn + +@anchor{rearrange} +@deftypefn {Команда MGL} {} rearrange dat @code{mx [my=0 mz=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Rearrange (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Rearrange (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_data_rearrange (@code{HMDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {Функция С} @code{void} mgl_datac_rearrange (@code{HADT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Изменяет размерность данных без изменения самого массива данных, так что результирующий массив @var{mx}*@var{my}*@var{mz} < nx*ny*nz. Если один из параметров @var{my} или @var{mz} ноль, то он будет выбран оптимальным образом. Например, если @var{my}=0, то будет @var{my}=nx*ny*nz/@var{mx} и @var{mz}=1. +@end deftypefn + +@anchor{transpose} +@deftypefn {Команда MGL} {} transpose dat ['dim'='yxz'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Transpose (@code{const char *}dim=@code{"yx"}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Transpose (@code{const char *}dim=@code{"yx"}) +@deftypefnx {Функция С} @code{void} mgl_data_transpose (@code{const char *}dim) +@deftypefnx {Функция С} @code{void} mgl_datac_transpose (@code{HADT} dat, @code{const char *}dim) +@end ifclear +Транспонирует (меняет порядок размерностей) массив данных. Новый порядок размерностей задается строкой @var{dim}. Функция может быть полезна для транспонирования одномерных (или квазиодномерных) массивов после чтения их из файла. +@end deftypefn + +@anchor{extend} +@deftypefn {Команда MGL} {} extend dat @code{n1 [n2=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Extend (@code{int} n1, @code{int} n2=@code{0}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Extend (@code{int} n1, @code{int} n2=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_data_extend (@code{HMDT} dat, @code{int} n1, @code{int} n2) +@deftypefnx {Функция С} @code{void} mgl_datac_extend (@code{HADT} dat, @code{int} n1, @code{int} n2) +@end ifclear +Увеличивает размер данных путем вставки (|@var{n1}|+1) новых срезов после (для @var{n1}>0) или перед (для @var{n1}<0) существующими данными. Можно добавить сразу 2 размерности для 1d массива, используя второй параметр @var{n2}. Данные в новые срезы будут скопированы из существующих. Например, для @var{n1}>0 новый массив будет +@iftex +@math{a_{ij}^{new} = a_i^{old}} where j=0...@var{n1}. Соответственно, для @var{n1}<0 новый массив будет @math{a_{ij}^{new} = a_j^{old}}, где i=0...|@var{n1}|. +@end iftex +@ifnottex +a_ij^new = a_i^old where j=0...@var{n1}. Соответственно, для @var{n1}<0 новый массив будет a_ij^new = a_j^old, где i=0...|@var{n1}|. +@end ifnottex +@end deftypefn + +@anchor{squeeze} +@deftypefn {Команда MGL} {} squeeze dat @code{rx [ry=1 rz=1 sm=off]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Squeeze (@code{int} rx, @code{int} ry=@code{1}, @code{int} rz=@code{1}, @code{bool} smooth=@code{false}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Squeeze (@code{int} rx, @code{int} ry=@code{1}, @code{int} rz=@code{1}, @code{bool} smooth=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_data_squeeze (@code{HMDT} dat, @code{int} rx, @code{int} ry, @code{int} rz, @code{int} smooth) +@deftypefnx {Функция С} @code{void} mgl_datac_squeeze (@code{HADT} dat, @code{int} rx, @code{int} ry, @code{int} rz, @code{int} smooth) +@end ifclear +Уменьшает размер данных путём удаления элементов с индексами не кратными @var{rx}, @var{ry}, @var{rz} соответственно. Параметр @var{smooth} задает использовать сглаживания +@iftex +(т.е. @math{a_{out}[i]=\sum_{j=i,i+r}a[j]/r}) или нет (т.е. @math{a_{out}[i]=a[j*r]}). +@end iftex +@ifnottex +(т.е. out[i]=\sum_@{j=i,i+r@} a[j]/r) или нет (т.е. out[i]=a[j*r]). +@end ifnottex +@end deftypefn + +@anchor{crop} +@deftypefn {Команда MGL} {} crop dat @code{n1 n2} 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Crop (@code{int} n1, @code{int} n2, @code{char} dir=@code{'x'}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Crop (@code{int} n1, @code{int} n2, @code{char} dir=@code{'x'}) +@deftypefnx {Функция С} @code{void} mgl_data_crop (@code{HMDT} dat, @code{int} n1, @code{int} n2, @code{char} dir) +@deftypefnx {Функция С} @code{void} mgl_datac_crop (@code{HADT} dat, @code{int} n1, @code{int} n2, @code{char} dir) +@end ifclear +Обрезает границы данных при @var{i}<@var{n1} и @var{i}>@var{n2} (при @var{n2}>0) или @var{i}>@code{n[xyz]}-@var{n2} (при @var{n2}<=0) вдоль направления @var{dir}. +@end deftypefn + +@anchor{insert} +@deftypefn {Команда MGL} {} insert dat 'dir' @code{[pos=off num=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Insert (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Insert (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_insert (@code{HMDT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@deftypefnx {Функция С} @code{void} mgl_datac_insert (@code{HADT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@end ifclear +Вставляет @var{num} срезов вдоль направления @var{dir} с позиции @var{pos} и заполняет их нулями. +@end deftypefn + +@anchor{delete} +@deftypefn {Команда MGL} {} delete dat 'dir' @code{[pos=off num=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Delete (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Delete (@code{char} dir, @code{int} pos=@code{0}, @code{int} num=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_delete (@code{HMDT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@deftypefnx {Функция С} @code{void} mgl_datac_delete (@code{HADT} dat, @code{char} dir, @code{int} pos, @code{char} num) +@end ifclear +Удаляет @var{num} срезов вдоль направления @var{dir} с позиции @var{pos}. +@end deftypefn + +@anchor{sort} +@deftypefn {Команда MGL} {} sort dat @code{idx [idy=-1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Sort (@code{lond} idx, @code{long} idy=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_data_sort (@code{HMDT} dat, @code{lond} idx, @code{long} idy) +@end ifclear +Сортирует строки (или срезы в 3D случае) по значениям в указанной колонке @var{idx} (или ячейках @{@var{idx},@var{idy}@} для 3D случая). Не используйте в многопоточных функциях! +@end deftypefn + +@anchor{clean} +@deftypefn {Команда MGL} {} clean dat @code{idx} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Clean (@code{lond} idx) +@deftypefnx {Функция С} @code{void} mgl_data_clean (@code{HMDT} dat, @code{lond} idx) +@end ifclear +Удаляет строки в которых значения для заданной колонки @var{idx} совпадают со значениями в следующей строке. +@end deftypefn + + +@anchor{join} +@deftypefn {Команда MGL} {} join dat vdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Join (@code{const mglDataA &}vdat) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Join (@code{const mglDataA &}vdat) +@deftypefnx {Функция С} @code{void} mgl_data_join (@code{HMDT} dat, @code{HCDT} vdat) +@deftypefnx {Функция С} @code{void} mgl_datac_join (@code{HADT} dat, @code{HCDT} vdat) +@end ifclear +Объединяет данные из массива @var{vdat} с данными массива @var{dat}. При этом, функция увеличивает размер массива @var{dat}: в z-направлении для 3D массивов с одинаковыми размерами по x и y; в y-направлении для 2D массивов с одинаковыми размерами по x; в x-направлении в остальных случаях. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Data filling, File I/O, Data resizing, Data processing +@section Заполнение данных +@nav{} +@cindex Fill +@cindex Modify +@cindex Set +@cindex List +@cindex Var +@cindex Refill + +@anchor{list} +@deftypefn {Команда MGL} {} list @sc{dat} @code{v1 ...} +Создает новый массив данных @var{dat} и заполняет его числовыми значениями аргументов @code{v1 ...}. Команда может создавать одно- и двухмерные массивы с произвольными значениями. Для создания 2d массива следует использовать разделитель @samp{|}, который означает начало новой строки данных. Размер массива данных будет [maximal of row sizes * number of rows]. Например, команда @code{list 1 | 2 3} создаст массив [1 0; 2 3]. Замечу, что максимальное число аргументов равно 1000. +@end deftypefn +@deftypefn {Команда MGL} {} list @sc{dat} d1 ... +Создает новый массив данных @var{dat} и заполняет его значениями из массивов @var{d1 ...}. Команда может создавать двух- и трёхмерные (если аргументы -- двумерные массивы) массивы. Меньшая размерность всех массивов в аргументах должна совпадать. В противном случае аргумент (массив) будет пропущен. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const mreal *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{const double *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_set_mreal (@code{HMDT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Функция С} @code{void} mgl_data_set_double (@code{HMDT} dat, @code{const double *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const float *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const double *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const dual *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_datac_set_float (@code{HADT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Функция С} @code{void} mgl_datac_set_double (@code{HADT} dat, @code{const double *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Функция С} @code{void} mgl_datac_set_complex (@code{HADT} dat, @code{const dual *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +Выделяет память и копирует данные из массивов типа @code{mreal*} или @code{double*}, т.е. из массивов определённых как @code{mreal a[NX*NY*NZ];}. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const mreal **}A, @code{int} N1, @code{int} N2) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{const double **}A, @code{int} N1, @code{int} N2) +@deftypefnx {Функция С} @code{void} mgl_data_set_mreal2 (@code{HMDT} dat, @code{const mreal **}A, @code{int} N1, @code{int} N2) +@deftypefnx {Функция С} @code{void} mgl_data_set_double2 (@code{HMDT} dat, @code{const double **}A, @code{int} N1, @code{int} N2) +Выделяет память и копирует данные из массивов типа @code{mreal**} или @code{double**} с размерностями @var{N1}, @var{N2}, т.е. из массивов определённых как @code{mreal a[N1][N2];}. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const mreal ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{const double ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {Функция С} @code{void} mgl_data_set_mreal3 (@code{HMDT} dat, @code{const mreal ***}A, @code{int} N1, @code{int} N2) +@deftypefnx {Функция С} @code{void} mgl_data_set_double3 (@code{HMDT} dat, @code{const double ***}A, @code{int} N1, @code{int} N2) +Выделяет память и копирует данные из массивов типа @code{mreal***} или @code{double***} с размерностями @var{N1}, @var{N2}, @var{N3}, т.е. из массивов определённых как @code{mreal a[N1][N2][N3];}. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{gsl_vector *}v) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{gsl_vector *}v) +@deftypefnx {Функция С} @code{void} mgl_data_set_vector (@code{HMDT} dat, @code{gsl_vector *}v) +@deftypefnx {Функция С} @code{void} mgl_datac_set_vector (@code{HADT} dat, @code{gsl_vector *}v) +Выделяет память и копирует данные из структуры типа @code{gsl_vector *}. +@end deftypefn +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{gsl_matrix *}m) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{gsl_matrix *}m) +@deftypefnx {Функция С} @code{void} mgl_data_set_matrix (@code{HMDT} dat, @code{gsl_matrix *}m) +@deftypefnx {Функция С} @code{void} mgl_datac_set_matrix (@code{HADT} dat, @code{gsl_matrix *}m) +Выделяет память и копирует данные из структуры типа @code{gsl_matrix *}. +@end deftypefn +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const mglDataA &}from) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{HCDT} from) +@deftypefnx {Функция С} @code{void} mgl_data_set (@code{HMDT} dat, @code{HCDT} from) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const mglDataA &}from) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{HCDT} from) +@deftypefnx {Функция С} @code{void} mgl_datac_set (@code{HADT} dat, @code{HCDT} from) +Выделяет память и копирует данные из другого экземпляра данных @var{from}. +@end deftypefn + +@deftypefn {Метод класса @code{mglDataC}} @code{void} Set (@code{const mglDataA &}re, @code{const mglDataA &}im) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{HCDT} re, @code{HCDT} im) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} SetAmpl (@code{HCDT} ampl, @code{const mglDataA &}phase) +@deftypefnx {Функция С} @code{void} mgl_datac_set_ri (@code{HADT} dat, @code{HCDT} re, @code{HCDT} im) +@deftypefnx {Функция С} @code{void} mgl_datac_set_ap (@code{HADT} dat, @code{HCDT} ampl, @code{HCDT} phase) +Выделяет память и копирует данные из экземпляра данных для действительной @var{re} и мнимой @var{im} частей комплексного массива данных. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const std::vector &}d) +Выделяет память и копирует данные из массива типа @code{std::vector}. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Set (@code{const char *}str, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_set_values (@code{const char *}str, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Set (@code{const char *}str, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_datac_set_values (@code{const char *}str, @code{int} NX, @code{int} NY, @code{int} NZ) +Выделяет память и сканирует массив данных из строки. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{void} Link (@code{mglData &}from) +@deftypefnx {Метод класса @code{mglData}} @code{void} Link (@code{mreal *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_link (@code{HMDT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Link (@code{mglDataC &}from) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Link (@code{dual *}A, @code{int} NX, @code{int} NY=@code{1}, @code{int} NZ=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_datac_link (@code{HADT} dat, @code{const mreal *}A, @code{int} NX, @code{int} NY, @code{int} NZ) +Устанавливает флаг использования внешнего массива данных, которые не будут удалены. Флаг может быть возвращён в исходное состояние и создан новый внутренний массив если использовались функции изменяющие размер данных. +@end deftypefn +@end ifclear + +@anchor{var} +@deftypefn {Команда MGL} {} var @sc{dat} @code{num v1 [v2=nan]} +Создает новый одномерный массив данных @var{dat} размером @var{num}, и заполняет его равномерно в диапазоне [@var{v1}, @var{v2}]. Если @var{v2}=@code{nan}, то используется @var{v2=v1}. +@end deftypefn + +@anchor{fill} +@deftypefn {Команда MGL} {} fill dat v1 v2 ['dir'='x'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Fill (@code{mreal} v1, @code{mreal} v2, @code{char} dir=@code{'x'}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Fill (@code{dual} v1, @code{dual} v2, @code{char} dir=@code{'x'}) +@deftypefnx {Функция С} @code{void} mgl_data_fill (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{char} dir) +@deftypefnx {Функция С} @code{void} mgl_datac_fill (@code{HADT} dat, @code{dual} v1, @code{dual} v2, @code{char} dir) +@end ifclear +Заполняет значениями равно распределёнными в диапазоне [@var{x1}, @var{x2}] в направлении @var{dir}=@{@samp{x},@samp{y},@samp{z}@}. +@end deftypefn + +@deftypefn {Команда MGL} {} fill dat 'eq' +@deftypefnx {Команда MGL} {} fill dat 'eq' vdat +@deftypefnx {Команда MGL} {} fill dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const mglDataA &}wdat, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Fill (@code{HMGL} gr, @code{const char *}eq, @code{const mglDataA &}vdat, @code{const mglDataA &}wdat, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_data_fill_eq (@code{HMGL} gr, @code{HMDT} dat, @code{const char *}eq, @code{HCDT} vdat, @code{HCDT} wdat, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_datac_fill_eq (@code{HMGL} gr, @code{HADT} dat, @code{const char *}eq, @code{HCDT} vdat, @code{HCDT} wdat, @code{const char *}opt) +@end ifclear +Заполняет значениями вычисленными по формуле @var{eq}. Формула представляет собой произвольное выражение, зависящее от переменных @samp{x}, @samp{y}, @samp{z}, @samp{u}, @samp{v}, @samp{w}. Координаты @samp{x}, @samp{y}, @samp{z} полагаются меняющимися в диапазоне @var{Min} x @var{Max} (в отличие от функции @code{Modify}). Переменная @samp{u} -- значения исходного массива, переменные @samp{v}, @samp{w} -- значения массивов @var{vdat}, @var{wdat}. Последние могут быть @code{NULL}, т.е. опущены. +@end deftypefn + +@anchor{modify} +@deftypefn {Команда MGL} {} modify dat 'eq' [@code{dim=0}] +@deftypefnx {Команда MGL} {} modify dat 'eq' vdat +@deftypefnx {Команда MGL} {} modify dat 'eq' vdat wdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{int} dim=@code{0}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v) +@deftypefnx {Метод класса @code{mglData}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{int} dim=@code{0}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Modify (@code{const char *}eq, @code{const mglDataA &}v, @code{const mglDataA &}w) +@deftypefnx {Функция С} @code{void} mgl_data_modify (@code{HMDT} dat, @code{const char *}eq, @code{int} dim) +@deftypefnx {Функция С} @code{void} mgl_data_modify_vw (@code{HMDT} dat, @code{const char *}eq, @code{HCDT} v, @code{HCDT} w) +@deftypefnx {Функция С} @code{void} mgl_datac_modify (@code{HADT} dat, @code{const char *}eq, @code{int} dim) +@deftypefnx {Функция С} @code{void} mgl_datac_modify_vw (@code{HADT} dat, @code{const char *}eq, @code{HCDT} v, @code{HCDT} w) +@end ifclear +Аналогично предыдущему с координатами @samp{x}, @samp{y}, @samp{z}, меняющимися в диапазоне [0,1]. Если указан @var{dim}>0, то изменяются только слои >=@var{dim}. +@end deftypefn + +@anchor{fillsample} +@deftypefn {Команда MGL} {} fillsample dat 'how' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} FillSample (@code{const char *}how) +@deftypefnx {Функция С} @code{void} mgl_data_fill_sample (@code{HMDT} a, @code{const char *}how) +@end ifclear +Заполняет массив данных 'x' или 'k' значениями для преобразований Ханкеля ('h') или Фурье ('f'). +@end deftypefn + + +@anchor{datagrid} +@deftypefn {Команда MGL} {} datagrid dat xdat ydat zdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Grid (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Grid (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Функция С} @code{void} mgl_data_grid (@code{HMGL} gr, @code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{const char *}opt) +@deftypefnx {Функция С} @code{void} mgl_data_grid_xy (@code{HMDT} u, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2) +@end ifclear +Заполняет значения массива результатом линейной интерполяции (считая координаты равнораспределенными в диапазоне осей координат или в диапазоне [x1,x2]*[y1,y2]) по триангулированной поверхности, найденной по произвольно расположенным точкам @samp{x}, @samp{y}, @samp{z}. NAN значение используется для точек сетки вне триангулированной поверхности. @sref{Making regular data} +@end deftypefn + + +@anchor{put} +@deftypefn {Команда MGL} {} put dat @code{val [i=: j=: k=:]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Put (@code{mreal} val, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Put (@code{dual} val, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_data_put_val (@code{HMDT} a, @code{mreal} val, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{void} mgl_datac_put_val (@code{HADT} a, @code{dual} val, @code{int} i, @code{int} j, @code{int} k) +@end ifclear +Присваивает значения (под-)массива @var{dat}[@var{i}, @var{j}, @var{k}] = @var{val}. Индексы @var{i}, @var{j}, @var{k} равные @samp{-1} задают значения @var{val} для всего диапазона соответствующего направления(ий). Например, @code{Put(val,-1,0,-1);} задает a[i,0,j]=@var{val} для i=0...(nx-1), j=0...(nz-1). +@end deftypefn + +@deftypefn {Команда MGL} {} put dat vdat [@code{i=: j=: k=:}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Put (@code{const mglDataA &}v, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Put (@code{const mglDataA &}v, @code{int} i=@code{-1}, @code{int} j=@code{-1}, @code{int} k=@code{-1}) +@deftypefnx {Функция С} @code{void} mgl_data_put_dat (@code{HMDT} a, @code{HCDT} v, @code{int} i, @code{int} j, @code{int} k) +@deftypefnx {Функция С} @code{void} mgl_datac_put_dat (@code{HADT} a, @code{HCDT} v, @code{int} i, @code{int} j, @code{int} k) +@end ifclear +Копирует значения из массива @var{v} в диапазон значений данного массива. Индексы @var{i}, @var{j}, @var{k} равные @samp{-1} задают диапазон изменения значений в соответствующих направление(ях). Младшие размерности массива @var{v} должны быть больше выбранного диапазона массива. Например, @code{Put(v,-1,0,-1);} присвоит a[i,0,j]=@var{v}.ny>nz ? @var{v}.a[i,j] : @var{v}.a[i], где i=0...(nx-1), j=0...(nz-1) и условие v.nx>=nx выполнено. +@end deftypefn + +@anchor{refill} +@deftypefn {Команда MGL} {} refill dat xdat vdat [sl=-1] +@deftypefnx {Команда MGL} {} refill dat xdat ydat vdat [sl=-1] +@deftypefnx {Команда MGL} {} refill dat xdat ydat zdat vdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mreal} x1, @code{mreal} x2, @code{long} sl=@code{-1}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2, @code{long} sl=@code{-1}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2, @code{long} sl=@code{-1}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{mglPoint} p1, @code{mglPoint} p2) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}v, @code{long} sl=@code{-1}, @code{const char *}opt=@code{""}) +@deftypefnx {Метод класса @code{mglData}} @code{void} Refill (@code{HMGL} gr, @code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z, @code{const mglDataA &}v, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{void} mgl_data_refill_x (@code{HMDT} a, @code{HCDT} x, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{long} sl) +@deftypefnx {Функция С} @code{void} mgl_data_refill_xy (@code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{long} sl) +@deftypefnx {Функция С} @code{void} mgl_data_refill_xyz (@code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1, @code{mreal} z2) +@deftypefnx {Функция С} @code{void} mgl_data_refill_gr (@code{HMGL} gr, @code{HMDT} a, @code{HCDT} x, @code{HCDT} y, @code{HCDT} z, @code{HCDT} v, @code{long} sl, @code{const char *}opt) +@end ifclear +Заполняет значениями интерполяции массива @var{v} в точках @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i], Y[j], Z[k]}@} (или @{@var{x}, @var{y}, @var{z}@}=@{@code{X[i,j,k], Y[i,j,k], Z[i,j,k]}@} если @var{x}, @var{y}, @var{z} не 1d массивы), где @code{X,Y,Z} равномерно распределены в диапазоне [@var{x1},@var{x2}]*[@var{y1},@var{y2}]*[@var{z1},@var{z2}] и имеют такой же размер как и заполняемый массив. Если параметр @var{sl} равен 0 или положительный, то изменятся будет только @var{sl}-ый срез. +@end deftypefn + +@anchor{idset} +@deftypefn {Команда MGL} {} idset dat 'ids' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} SetColumnId (@code{const char *}ids) +@deftypefnx {Функция С} @code{void} mgl_data_set_id (@code{const char *}ids) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} SetColumnId (@code{const char *}ids) +@deftypefnx {Функция С} @code{void} mgl_datac_set_id (@code{HADT} a, @code{const char *}ids) +@end ifclear +Задает названия @var{ids} для колонок массива данных. Строка должна содержать один символ 'a'...'z' на колонку. Эти названия используются в функции @ref{column}. +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node File I/O, Make another data, Data filling, Data processing +@section Чтение/сохранение данных +@nav{} +@cindex Read +@cindex ReadMat +@cindex ReadRange +@cindex ReadAll +@cindex Save +@cindex ReadHDF +@cindex SaveHDF +@cindex Import +@cindex Export + +@anchor{read} +@deftypefn {Команда MGL} {} read @sc{dat} 'fname' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Read (@code{const char *}fname) +@deftypefnx {Метод класса @code{mglDataC}} @code{bool} Read (@code{const char *}fname) +@deftypefnx {Функция С} @code{int} mgl_data_read (@code{HMDT} dat, @code{const char *}fname) +@deftypefnx {Функция С} @code{int} mgl_datac_read (@code{HADT} dat, @code{const char *}fname) +@end ifclear +Читает данные из текстового файла с разделителями символом пробела/табуляции с автоматическим определением размера массива. Двойной перевод строки начинает новый срез данных (по направлению z). +@end deftypefn + +@deftypefn {Команда MGL} {} read @sc{dat} 'fname' @code{mx [my=1 mz=1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Read (@code{const char *}fname, @code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Метод класса @code{mglDataC}} @code{bool} Read (@code{const char *}fname, @code{int} mx, @code{int} my=@code{1}, @code{int} mz=@code{1}) +@deftypefnx {Функция С} @code{int} mgl_data_read_dim (@code{HMDT} dat, @code{const char *}fname, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {Функция С} @code{int} mgl_datac_read_dim (@code{HADT} dat, @code{const char *}fname, @code{int} mx, @code{int} my, @code{int} mz) +@end ifclear +Читает данные из текстового файла с заданными размерами. Ничего не делается если параметры @var{mx}, @var{my} или @var{mz} равны нулю или отрицательны. +@end deftypefn + +@anchor{readmat} +@deftypefn {Команда MGL} {} readmat @sc{dat} 'fname' [@code{dim=2}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} ReadMat (@code{const char *}fname, @code{int} dim=@code{2}) +@deftypefnx {Метод класса @code{mglDataC}} @code{bool} ReadMat (@code{const char *}fname, @code{int} dim=@code{2}) +@deftypefnx {Функция С} @code{int} mgl_data_read_mat (@code{HMDT} dat, @code{const char *}fname, @code{int} dim) +@deftypefnx {Функция С} @code{int} mgl_datac_read_mat (@code{HADT} dat, @code{const char *}fname, @code{int} dim) +@end ifclear +Читает данные из текстового файла с размерами, указанными в первых @var{dim} числах файла. При этом переменная @var{dim} задает размерность (1d, 2d, 3d) данных. +@end deftypefn + +@anchor{readall} +@deftypefn {Команда MGL} {} readall @sc{dat} 'templ' @code{v1 v2 [dv=1 slice=off]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} ReadRange (@code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step=@code{1.f}, @code{bool} as_slice=@code{false}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} ReadRange (@code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step=@code{1}, @code{bool} as_slice=@code{false}) +@deftypefnx {Функция С} @code{int} mgl_data_read_range (@code{HMDT} dat, @code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step, @code{int} as_slice) +@deftypefnx {Функция С} @code{int} mgl_datac_read_range (@code{HADT} dat, @code{const char *}templ, @code{mreal} from, @code{mreal} to, @code{mreal} step, @code{int} as_slice) +@end ifclear +Объединяет данные из нескольких текстовых файлов. Имена файлов определяются вызовом функции @code{sprintf(fname,templ,val);}, где @var{val} меняется от @var{from} до @var{to} с шагом @var{step}. Данные загружаются один за другим в один и тот же срез данных (при @var{as_slice}=@code{false}) или срез-за-срезом (при @var{as_slice}=@code{true}). +@end deftypefn + +@deftypefn {Команда MGL} {} readall @sc{dat} 'templ' @code{[slice=off]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} ReadAll (@code{const char *}templ, @code{bool} as_slice=@code{false}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} ReadAll (@code{const char *}templ, @code{bool} as_slice=@code{false}) +@deftypefnx {Функция С} @code{int} mgl_data_read_all (@code{HMDT} dat, @code{const char *}templ, @code{int} as_slice) +@deftypefnx {Функция С} @code{int} mgl_datac_read_all (@code{HADT} dat, @code{const char *}templ, @code{int} as_slice) +@end ifclear +Объединяет данные из нескольких текстовых файлов, чьи имена удовлетворяют шаблону @var{templ} (например, @var{templ}=@code{"t_*.dat"}). Данные загружаются один за другим в один и тот же срез данных (при @var{as_slice}=@code{false}) или срез-за-срезом (при @var{as_slice}=@code{true}). +@end deftypefn + +@anchor{save} +@deftypefn {Команда MGL} {} save dat 'fname' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Save (@code{const char *}fname, @code{int} ns=@code{-1}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Save (@code{const char *}fname, @code{int} ns=@code{-1}) @code{const} +@deftypefnx {Функция С} @code{void} mgl_data_save (@code{HCDT} dat, @code{const char *}fname, @code{int} ns) +@deftypefnx {Функция С} @code{void} mgl_datac_save (@code{HCDT} dat, @code{const char *}fname, @code{int} ns) +@end ifclear +Сохраняет весь массив данных при @var{ns}=@code{-1} или только @var{ns}-ый срез в текстовый файл. +@end deftypefn + +@anchor{readhdf} +@deftypefn {Команда MGL} {} readhdf @sc{dat} 'fname' 'dname' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} ReadHDF (@code{const char *}fname, @code{const char *}dname) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} ReadHDF (@code{const char *}fname, @code{const char *}dname) +@deftypefnx {Функция С} @code{void} mgl_data_read_hdf (@code{HMDT} dat, @code{const char *}fname, @code{const char *}dname) +@deftypefnx {Функция С} @code{void} mgl_datac_read_hdf (@code{HADT} dat, @code{const char *}fname, @code{const char *}dname) +@end ifclear +Читает массив с именем @var{dname} из HDF5 или HDF4 файла @var{fname}. Функция ничего не делает если библиотека была собрана без поддержки HDF5|HDF4. +@end deftypefn + +@anchor{savehdf} +@deftypefn {Команда MGL} {} savehdf dat 'fname' 'dname' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} SaveHDF (@code{const char *}fname, @code{const char *}dname, @code{bool} rewrite=@code{false}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{void} SaveHDF (@code{const char *}fname, @code{const char *}dname, @code{bool} rewrite=@code{false}) @code{const} +@deftypefnx {Функция С} @code{void} mgl_data_save_hdf (@code{HCDT} dat, @code{const char *}fname, @code{const char *}dname, @code{int} rewrite) +@deftypefnx {Функция С} @code{void} mgl_datac_save_hdf (@code{HCDT} dat, @code{const char *}fname, @code{const char *}dname, @code{int} rewrite) +@end ifclear +Сохраняет массив под именем @var{dname} в HDF5 или HDF4 файл @var{fname}. Функция ничего не делает если библиотека была собрана без поддержки HDF5|HDF4. +@end deftypefn + +@anchor{datas} +@deftypefn {Команда MGL} {} datas 'fname' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} DatasHDF (@code{const char *}fname, @code{char *}buf, @code{long} size) @code{static} +@deftypefnx {Метод класса @code{mglDataC}} @code{int} DatasHDF (@code{const char *}fname, @code{char *}buf, @code{long} size) @code{static} +@deftypefnx {Функция С} @code{void} mgl_datas_hdf (@code{const char *}fname, @code{char *}buf, @code{long} size) +@end ifclear +Помещает имена массивов данных в HDF5 файле @var{fname} в строку @var{buf} разделёнными символом табуляции '\t'. В версии MGL имена массивов будут выведены как сообщение. Функция ничего не делает если библиотека была собрана без поддержки HDF5. +@end deftypefn + +@anchor{import} +@deftypefn {Команда MGL} {} import @sc{dat} 'fname' 'sch' [@code{v1=0 v2=1}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Import (@code{const char *}fname, @code{const char *}scheme, @code{mreal} v1=@code{0}, mreal v2=@code{1}) +@deftypefnx {Функция С} @code{void} mgl_data_import (@code{HMDT} dat, @code{const char *}fname, @code{const char *}scheme, @code{mreal} v1, mreal v2) +@end ifclear +Читает данные из растрового файла. RGB значения пикселов преобразуются в число в диапазоне [@var{v1}, @var{v2}] используя цветовую схему @var{sch} (@pxref{Color scheme}). +@end deftypefn + +@anchor{export} +@deftypefn {Команда MGL} {} export dat 'fname' 'sch' [@code{v1=0 v2=0}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Export (@code{const char *}fname, @code{const char *}scheme, @code{mreal} v1=@code{0}, mreal v2=@code{0}, @code{int} ns=@code{-1}) const +@deftypefnx {Функция С} @code{void} mgl_data_export (@code{HMDT} dat, @code{const char *}fname, @code{const char *}scheme, @code{mreal} v1, mreal v2, @code{int} ns) const +@end ifclear +Сохраняет данные в растровый файл. Числовые значения, нормированные в диапазон [@var{v1}, @var{v2}], преобразуются в RGB значения пикселов, используя цветовую схему @var{sch} (@pxref{Color scheme}). Если @var{v1}>=@var{v2}, то значения @var{v1}, @var{v2} определяются автоматически как минимальное и максимальное значение данных. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Make another data, Data changing, File I/O, Data processing +@section Make another data +@nav{} +@cindex SubData +@cindex Column +@cindex Trace +@cindex Hist +@cindex Resize +@cindex Evaluate +@cindex Combine +@cindex Momentum +@cindex Sum +@cindex Min +@cindex Max +@cindex Roots +@cindex Correl +@cindex AutoCorrel + +@anchor{subdata} +@deftypefn {Команда MGL} {} subdata @sc{res} dat @code{xx [yy=: zz=:]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} SubData (@code{mreal} xx, @code{mreal} yy=@code{-1}, @code{mreal} zz=@code{-1}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} SubData (@code{mreal} xx, @code{mreal} yy=@code{-1}, @code{mreal} zz=@code{-1}) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_subdata (@code{HCDT} dat, @code{mreal} xx, @code{mreal} yy, @code{mreal} zz) +@end ifclear +Возвращает в @var{res} подмассив массива данных @var{dat} с фиксированными значениями индексов с положительными значениями. Например, @code{SubData(-1,2)} выделяет третью строку (индексы начинаются с нуля), @code{SubData(4,-1)} выделяет 5-ую колонку, @code{SubData(-1,-1,3)} выделяет 4-ый срез и т.д. В MGL скриптах обычно используется упрощенная версия @code{dat(xx,yy,zz)}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@deftypefn {Команда MGL} {} subdata @sc{res} dat xdat [ydat=: zdat=:] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} SubData (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} SubData (@code{const mglDataA &}xx, @code{const mglDataA &}yy, @code{const mglDataA &}zz) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_subdata_ext (@code{HCDT} dat, @code{HCDT} xx, @code{HCDT} yy, @code{HCDT} zz) +@end ifclear +Возвращает в @var{res} подмассив массива данных @var{dat} с индексами, заданными в массивах @var{xx}, @var{yy}, @var{zz} (косвенная адресация). Результат будет иметь размерность массивов с индексами. Размеры массивов @var{xx}, @var{yy}, @var{zz} с индексами должна быть одинакова, либо должны быть "скаляром" (т.е. 1*1*1). В MGL скриптах обычно используется упрощенная версия @code{dat(xx,yy,zz)}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{column} +@deftypefn {Команда MGL} {} column @sc{res} dat 'eq' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Column (@code{const char *}eq) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Column (@code{const char *}eq) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_column (@code{HCDT} dat, @code{const char *}eq) +@end ifclear +Возвращает массив данных заполненный по формуле @var{eq}, вычисленной для именованных колонок (или срезов). Например, @code{Column("n*w^2/exp(t)");}. Имена колонок должны быть предварительно заданы функцией @ref{idset} или при чтении файлов данных. В MGL скриптах обычно используется упрощенная версия @code{dat('eq')}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{resize} +@deftypefn {Команда MGL} {} resize @sc{res} dat @code{mx [my=1 mz=1]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Resize (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}, @code{mreal} x1=@code{0}, @code{mreal} x2=@code{1}, @code{mreal} y1=@code{0}, @code{mreal} y2=@code{1}, @code{mreal} z1=@code{0}, @code{mreal} z2=@code{1}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Resize (@code{int} mx, @code{int} my=@code{0}, @code{int} mz=@code{0}, @code{mreal} x1=@code{0}, @code{mreal} x2=@code{1}, @code{mreal} y1=@code{0}, @code{mreal} y2=@code{1}, @code{mreal} z1=@code{0}, @code{mreal} z2=@code{1}) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_resize (@code{HCDT} dat, @code{int} mx, @code{int} my, @code{int} mz) +@deftypefnx {Функция С} @code{HMDT} mgl_data_resize_box (@code{HCDT} dat, @code{int} mx, @code{int} my, @code{int} mz, @code{mreal} x1, @code{mreal} x2, @code{mreal} y1, @code{mreal} y2, @code{mreal} z1, @code{mreal} z2) +@end ifclear +Возвращает массив данных размером @var{mx}, @var{my}, @var{mz} со значениями полученными интерполяцией значений из части [@var{x1},@var{x2}] x [@var{y1},@var{y2}] x [@var{z1},@var{z2}] исходного массива. Величины x,y,z полагаются нормированными в диапазоне [0,1]. Если значение @var{mx}, @var{my} или @var{mz} равно 0, то исходный размер используется. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{evaluate} +@deftypefn {Команда MGL} {} evaluate @sc{res} dat idat [@code{norm=on}] +@deftypefnx {Команда MGL} {} evaluate @sc{res} dat idat jdat [@code{norm=on}] +@deftypefnx {Команда MGL} {} evaluate @sc{res} dat idat jdat kdat [@code{norm=on}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{const mglDataA &}kdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Evaluate (@code{const mglDataA &}idat, @code{const mglDataA &}jdat, @code{const mglDataA &}kdat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_evaluate (@code{HCDT} dat, @code{HCDT} idat, @code{HCDT} jdat, @code{HCDT} kdat, @code{int} norm) +@end ifclear +Возвращает массив данных, полученный в результате интерполяции исходного массива в точках других массивов (например, res[i,j]=dat[idat[i,j],jdat[i,j]]). Размеры массивов @var{idat}, @var{jdat}, @var{kdat} должны совпадать. Координаты в @var{idat}, @var{jdat}, @var{kdat} полагаются нормированными в диапазон [0,1] (при @var{norm}=@code{true}) или в диапазоны [0,nx], [0,ny], [0,nz] соответственно. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{solve} +@deftypefn {Команда MGL} {} solve @sc{res} dat @code{val} 'dir' [@code{norm=on}] +@deftypefnx {Команда MGL} {} solve @sc{res} dat @code{val} 'dir' idat [@code{norm=on}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Solve (@code{mreal} val, @code{char} dir, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Solve (@code{mreal} val, @code{char} dir, @code{const mglDataA &}idat, @code{bool} norm=@code{true}) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_solve (@code{HCDT} dat, @code{mreal} val, @code{char} dir, @code{HCDT} idat, @code{int} norm) +@end ifclear +Возвращает массив индексов (корней) вдоль выбранного направления @var{dir} в которых значения массива @var{dat} равны @var{val}. Выходной массив будет иметь размеры массива @var{dat} в направлениях поперечных @var{dir}. Если предоставлен массив @var{idat}, то его значения используются как стартовые при поиске. Это позволяет найти несколько веток с помощью последовательного вызова функции. Индексы полагаются нормированными в диапазон [0,1] (при @var{norm}=@code{true}) или в диапазоны [0,nx], [0,ny], [0,nz] соответственно. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. @sref{Solve sample} +@end deftypefn + +@anchor{roots} +@deftypefn {Команда MGL} {} roots @sc{res} 'func' ini ['var'='x'] +@deftypefnx {Команда MGL} {} roots @sc{res} 'func' @code{ini} ['var'='x'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Roots (@code{const char *}func, @code{char} var) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_roots (@code{const char *}func, @code{HCDT} ini, @code{char} var) +@deftypefnx {Функция С} @code{mreal} mgl_find_root_txt (@code{const char *}func, @code{mreal} ini, @code{char} var) +@end ifclear +Возвращает массив корней уравнения 'func'=0 для переменной @var{var} с начальными положениями @var{ini}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{hist} +@deftypefn {Команда MGL} {} hist @sc{res} dat @code{num v1 v2 [nsub=0]} +@deftypefnx {Команда MGL} {} hist @sc{res} dat wdat @code{num v1 v2 [nsub=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Hist (@code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Hist (@code{const mglDataA &}w, @code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Hist (@code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Hist (@code{const mglDataA &}w, @code{int} n, @code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{int} nsub=@code{0}) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_hist (@code{HCDT} dat, @code{int} n, @code{mreal} v1, @code{mreal} v2, @code{int} nsub) +@deftypefnx {Функция С} @code{HMDT} mgl_data_hist_w (@code{HCDT} dat, @code{HCDT} w, @code{int} n, @code{mreal} v1, @code{mreal} v2, @code{int} nsub) +@end ifclear +Возвращает распределение (гистограмму) из @var{n} точек от значений массива в диапазоне [@var{v1}, @var{v2}]. Массив @var{w} задает веса элементов (по умолчанию все веса равны 1). Параметр @var{nsub} задает число дополнительных точек интерполяции (для сглаживания получившейся гистограммы). Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. См. также @ref{Data manipulation} +@end deftypefn + +@anchor{momentum} +@deftypefn {Команда MGL} {} momentum @sc{res} dat 'how' ['dir'='z'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Momentum (@code{char} dir, @code{const char *}how) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Momentum (@code{char} dir, @code{const char *}how) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_momentum (@code{HCDT} dat, @code{char} dir, @code{const char *}how) +@end ifclear +Возвращает момент (1d массив) данных вдоль направления @var{dir}. Строка @var{how} определяет тип момента. Момент определяется как +@iftex +@math{res_k = \sum_{ij} how(x_i,y_j,z_k) a_{ij}/\sum_{ij} a_{ij}} +@end iftex +@ifnottex +res_k = \sum_ij how(x_i,y_j,z_k) a_ij/ \sum_ij a_ij +@end ifnottex +если @var{dir}=@samp{z} и т.д. Координаты @samp{x}, @samp{y}, @samp{z} -- индексы массива в диапазоне [0,1]. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{sum} +@deftypefn {Команда MGL} {} sum @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Sum (@code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Sum (@code{const char *}dir) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_sum (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Возвращает результат суммирования данных вдоль направления(ий) @var{dir}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{max} +@deftypefn {Команда MGL} {} max @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Max (@code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Max (@code{const char *}dir) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_max_dir (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Возвращает максимальное значение данных вдоль направления(ий) @var{dir}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{min} +@deftypefn {Команда MGL} {} min @sc{res} dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Min (@code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Min (@code{const char *}dir) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_min_dir (@code{HCDT} dat, @code{const char *}dir) +@end ifclear +Возвращает минимальное значение данных вдоль направления(ий) @var{dir}. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{combine} +@deftypefn {Команда MGL} {} combine @sc{res} adat bdat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Combine (@code{const mglDataA &}a) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Combine (@code{const mglDataA &}a) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_combine (@code{HCDT} dat, @code{HCDT} a) +@end ifclear +Возвращает прямое произведение массивов (наподобие, res[i,j] = adat[i]*bdat[j] и т.д.). Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{trace} +@deftypefn {Команда MGL} {} trace @sc{res} dat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Trace () @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglData} Trace () @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_trace (@code{HCDT} dat) +@end ifclear +Возвращает массив диагональных элементов a[i,i] (для 2D данных) или a[i,i,i] (для 3D данных) где i=0...nx-1. В 1D случае возвращается сам массив данных. Размеры массива данных должен быть ny,nz >= nx или ny,nz = 1. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@anchor{correl} +@deftypefn {Команда MGL} {} correl @sc{res} adat bdat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mglData} Correl (@code{const mglDataA &}b, @code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mglData} AutoCorrel (@code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglDataC} Correl (@code{const mglDataA &}b, @code{const char *}dir) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mglDataC} AutoCorrel (@code{const char *}dir) @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_data_correl (@code{HCDT} a, @code{HCDT} b, @code{const char *}dir) +@deftypefnx {Функция С} @code{HADT} mgl_datac_correl (@code{HCDT} a, @code{HCDT} b, @code{const char *}dir) +@end ifclear +Возвращает корреляцию массивов @var{a} (или this в C++) и @var{b} вдоль направлений @var{dir}. При вычислении используется преобразование Фурье. Поэтому может потребоваться вызов функций @ref{swap} и/или @ref{norm} перед построением. Функция возвращает NULL или пустой массив если данные не могут быть созданы при данных значениях аргументов. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglDataC}} @code{mglData} Real () @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_datac_real (@code{HCDT} dat) +Возвращает массив действительных частей массива данных. +@end deftypefn +@deftypefn {Метод класса @code{mglDataC}} @code{mglData} Imag () @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_datac_imag (@code{HCDT} dat) +Возвращает массив мнимых частей массива данных. +@end deftypefn +@deftypefn {Метод класса @code{mglDataC}} @code{mglData} Abs () @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_datac_abs (@code{HCDT} dat) +Возвращает массив абсолютных значений массива данных. +@end deftypefn +@deftypefn {Метод класса @code{mglDataC}} @code{mglData} Arg () @code{const} +@deftypefnx {Функция С} @code{HMDT} mgl_datac_arg (@code{HCDT} dat) +Возвращает массив аргументов массива данных. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data changing, Interpolation, Make another data, Data processing +@section Изменение данных +@nav{} +@cindex CumSum +@cindex Integral +@cindex Diff +@cindex Diff2 +@cindex SinFFT +@cindex CosFFT +@cindex Hankel +@cindex Swap +@cindex Roll +@cindex Mirror +@cindex Sew +@cindex Smooth +@cindex Envelop +@cindex Norm +@cindex NormSl + +These functions change the data in some direction like differentiations, integrations and so on. The direction in which the change will applied is specified by the string parameter, which may contain @samp{x}, @samp{y} or @samp{z} characters for 1-st, 2-nd and 3-d dimension correspondingly. + +@anchor{cumsum} +@deftypefn {Команда MGL} {} cumsum dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} CumSum (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} CumSum (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_cumsum (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_cumsum (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Суммирует с накоплением в выбранном направлении(ях). +@end deftypefn + +@anchor{integrate} +@deftypefn {Команда MGL} {} integrate dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Integral (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Integral (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_integral (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_integral (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Выполняет интегрирование (методом трапеций) в выбранном направлении(ях). +@end deftypefn + +@anchor{diff} +@deftypefn {Команда MGL} {} diff dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Diff (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Diff (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_diff (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_diff (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Выполняет дифференцирование в выбранном направлении(ях). +@end deftypefn + +@deftypefn {Команда MGL} {} diff dat xdat ydat [zdat=0] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Diff (@code{const mglDataA &}x, @code{const mglDataA &}y) +@deftypefnx {Метод класса @code{mglData}} @code{void} Diff (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {Функция С} @code{void} mgl_data_diff_par (@code{HMDT} dat, @code{HCDT} x, @code{HCDT}y, @code{HCDT}z) +@end ifclear +Выполняет дифференцирование данных, параметрически зависящих от координат, в направлении @var{x} с @var{y}, @var{z}=constant. Параметр @var{z} может быть опущен, что соответствует 2D случаю. Используются следующие формулы (2D случай): @math{da/dx = (a_j*y_i-a_i*y_j)/(x_j*y_i-x_i*y_j)}, где @math{a_i=da/di, a_j=da/dj} обозначает дифференцирование вдоль 1-ой и 2-ой размерности. Похожие формулы используются и в 3D случае. Порядок аргументов можно менять -- например, если данные a(i,j) зависят от координат @{x(i,j), y(i,j)@}, то обычная производная по @samp{x} будет равна @code{Diff(x,y);}, а обычная производная по @samp{y} будет равна @code{Diff(y,x);}. +@end deftypefn + +@anchor{diff2} +@deftypefn {Команда MGL} {} diff2 dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Diff2 (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Diff2 (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_diff2 (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_diff2 (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Выполняет двойное дифференцирование (как в операторе Лапласа) в выбранном направлении(ях). +@end deftypefn + +@anchor{sinfft} +@deftypefn {Команда MGL} {} sinfft dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} SinFFT (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_sinfft (@code{HMDT} dat, @code{const char *}dir) +@end ifclear +Выполняет синус преобразование в выбранном направлении(ях). Синус преобразование есть @math{\sum a_j \sin(k j)} (см. @uref{http://en.wikipedia.org/wiki/Discrete_sine_transform#DST-I}). +@end deftypefn + +@anchor{cosfft} +@deftypefn {Команда MGL} {} cosfft dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} CosFFT (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_cosfft (@code{HMDT} dat, @code{const char *}dir) +@end ifclear +Выполняет косинус преобразование в выбранном направлении(ях). Синус преобразование есть @math{\sum a_j \cos(k j)} (см. @uref{http://en.wikipedia.org/wiki/Discrete_cosine_transform#DCT-I}). +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglDataC}} @code{void} FFT (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_fft (@code{HADT} dat, @code{const char *}dir) +Выполняет фурье преобразование в выбранном направлении(ях). Если строка @var{dir} содержит @samp{i}, то используется обратное преобразование фурье. Фурье преобразование есть @math{\sum a_j \exp(i k j)} (см. @uref{http://en.wikipedia.org/wiki/Discrete_Fourier_transform}). +@end deftypefn +@end ifclear + +@anchor{hankel} +@deftypefn {Команда MGL} {} hankel dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Hankel (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Hankel (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_hankel (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_hankel (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Выполняет преобразование Ханкеля в выбранном направлении(ях). Преобразование Ханкеля есть @math{\sum a_j J_0(k j)} (см. @uref{http://en.wikipedia.org/wiki/Hankel_transform}). +@end deftypefn + +@anchor{swap} +@deftypefn {Команда MGL} {} swap dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Swap (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Swap (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_swap (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_swap (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Меняет местами левую и правую части данных в выбранном направлении(ях). Полезно для отображения результата FFT. +@end deftypefn + +@anchor{roll} +@deftypefn {Команда MGL} {} roll dat 'dir' num +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Roll (@code{char} dir, @code{num}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Roll (@code{char} dir, @code{num}) +@deftypefnx {Функция С} @code{void} mgl_data_roll (@code{HMDT} dat, @code{char} dir, @code{num}) +@deftypefnx {Функция С} @code{void} mgl_datac_roll (@code{HADT} dat, @code{char} dir, @code{num}) +@end ifclear +Сдвигает данные на @var{num} ячеек в выбранном направлении(ях). Соответствует замене индекса на @var{i}->(i+@var{num})%nx при @code{dir='x'}. +@end deftypefn + +@anchor{mirror} +@deftypefn {Команда MGL} {} mirror dat 'dir' +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Mirror (@code{const char *}dir) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Mirror (@code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_mirror (@code{HMDT} dat, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_datac_mirror (@code{HADT} dat, @code{const char *}dir) +@end ifclear +Отражает данные в выбранном направлении(ях). Соответствует замене индекса на @var{i}->@var{n}-@var{i}. Отмечу, что похожего эффекта на графике можно достичь используя опции (@pxref{Command options}), например, @code{surf dat; xrange 1 -1}. +@end deftypefn + +@anchor{sew} +@deftypefn {Команда MGL} {} sew dat ['dir'='xyz' @code{da=2*pi}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Sew (@code{const char *}dir, @code{mreal} da=@code{2*M_PI}) +@deftypefnx {Функция С} @code{void} mgl_data_sew (@code{HMDT} dat, @code{const char *}dir, @code{mreal} da) +@end ifclear +Удаляет скачки данных (например, скачки фазы после обратных тригонометрических функций) с периодом @var{da} в выбранном направлении(ях). +@end deftypefn + +@anchor{smooth} +@deftypefn {Команда MGL} {} smooth data @code{type} ['dir'='xyz'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Smooth (@code{const char *}dir=@code{"xyz"}, @code{mreal} delta=@code{0}) +@deftypefnx {Метод класса @code{mglDataC}} @code{void} Smooth (@code{const char *}dir=@code{"xyz"}, @code{mreal} delta=@code{0}) +@deftypefnx {Функция С} @code{void} mgl_data_smooth (@code{HMDT} dat, @code{const char *}dir, @code{mreal} delta) +@deftypefnx {Функция С} @code{void} mgl_datac_smooth (@code{HADT} dat, @code{const char *}dir, @code{mreal} delta) +@end ifclear +Сглаживает данные в выбранном направлении(ях) @var{dir}. Строка @var{dirs} задает направления вдоль которых будет производиться сглаживание. Если @var{dirs} содержит: @samp{0} -- ничего не делает, @samp{3} линейное усреднение по 3 точкам, @samp{5} линейное усреднение по 5 точкам. По умолчанию используется квадратичное усреднение по 5 точкам. +@end deftypefn + +@anchor{envelop} +@deftypefn {Команда MGL} {} envelop dat ['dir'='x'] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Envelop (@code{char} dir=@code{'x'}) +@deftypefnx {Функция С} @code{void} mgl_data_envelop (@code{HMDT} dat, @code{char} dir) +@end ifclear +Находит огибающую данных в выбранном направлении @var{dir}. +@end deftypefn + +@anchor{norm} +@deftypefn {Команда MGL} {} norm dat @code{v1 v2 [sym=off dim=0]} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} Norm (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{bool} sym=@code{false}, @code{int} dim=@code{0}) +@end ifclear +Нормирует данные в интервал [@var{v1},@var{v2}]. Если @var{sym}=@code{true}, то используется симметричный интервал [-max(|v1|,|v2|), max(|v1|,|v2|)]. Изменения применяются только к срезам >=@var{dim}. +@end deftypefn + +@anchor{normsl} +@deftypefn {Команда MGL} {} normsl dat @code{v1 v2} ['dir'='z' @code{keep=on sym=off}] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} NormSl (@code{mreal} v1=@code{0}, @code{mreal} v2=@code{1}, @code{char} dir=@code{'z'}, @code{bool} keep_en=@code{true}, @code{bool} sym=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_data_norm_slice (@code{HMDT} dat, @code{mreal} v1, @code{mreal} v2, @code{char} dir, @code{int} keep_en, @code{int} sym) +@end ifclear +Нормирует данные срез-за-срезом в выбранном направлении @var{dir} в интервал [@var{v1},@var{v2}]. Если @var{sym}=@code{true}, то используется симметричный интервал [-max(|v1|,|v2|), max(|v1|,|v2|)]. Если @var{keep}=@code{true}, то максимальное значение k-го среза ограничено величиной +@iftex +@math{\sqrt{\sum a_{ij}(k)/\sum a_{ij}(0)}}. +@end iftex +@ifnottex +@math{\sqrt@{\sum a_ij(k)/\sum a_ij(0)@}}. +@end ifnottex +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Interpolation, Data information, Data changing, Data processing +@section Интерполяция +@nav{} + +Скрипты MGL могут использовать линейную интерполяцию с помощью команды @ref{subdata}, или кубические сплайны при использовании команды @ref{evaluate}. Также можно использовать @ref{resize} для массива с новыми размерами. + +@ifclear UDAV + +Однако, есть специальные и более быстрые функции при использовании других языков (C/C++/Fortran/Python/...). + +@cindex Spline +@deftypefn {Метод класса @code{mglData}} @code{mreal} Spline (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Spline (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_spline (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Функция С} @code{dual} mgl_datac_spline (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Интерполирует данные кубическим сплайном в точке @var{x} в [0...nx-1], @var{y} в [0...ny-1], @var{z} в [0...nz-1]. +@end deftypefn +@cindex Spline1 +@deftypefn {Метод класса @code{mglData}} @code{mreal} Spline1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Spline1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Интерполирует данные кубическим сплайном в точке @var{x}, @var{y}, @var{z}, где координаты полагаются в интервале [0, 1]. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{mreal} Spline (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_spline_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal *}dx, @code{mreal *}dy, @code{mreal *}dz) +@deftypefnx {Функция С} @code{dual} mgl_datac_spline_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{dual *}dx, @code{dual *}dy, @code{dual *}dz) +Интерполирует данные кубическим сплайном в точке @var{x} в [0...nx-1], @var{y} в [0...ny-1], @var{z} в [0...nz-1]. Значения производных в точке записываются в @var{dif}. +@end deftypefn +@cindex Spline1 +@deftypefn {Метод класса @code{mglData}} @code{mreal} Spline1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Интерполирует данные кубическим сплайном в точке @var{x}, @var{y}, @var{z}, где координаты полагаются в интервале [0, 1]. Значения производных в точке записываются в @var{dif}. +@end deftypefn + + +@cindex Linear +@deftypefn {Метод класса @code{mglData}} @code{mreal} Linear (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Linear (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_linear (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Функция С} @code{dual} mgl_datac_linear (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Интерполирует данные линейной функцией в точке @var{x} в [0...nx-1], @var{y} в [0...ny-1], @var{z} в [0...nz-1]. +@end deftypefn +@cindex Linear1 +@deftypefn {Метод класса @code{mglData}} @code{mreal} Linear1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Linear1 (@code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Интерполирует данные линейной функцией в точке @var{x}, @var{y}, @var{z}, где координаты полагаются в интервале [0, 1]. +@end deftypefn + +@deftypefn {Метод класса @code{mglData}} @code{mreal} Linear (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Linear (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_linear_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{mreal *}dx, @code{mreal *}dy, @code{mreal *}dz) +@deftypefnx {Функция С} @code{dual} mgl_datac_linear_ext (@code{HCDT} dat, @code{mreal} x, @code{mreal} y, @code{mreal} z, @code{dual *}dx, @code{dual *}dy, @code{dual *}dz) +Интерполирует данные линейной функцией в точке @var{x}, @var{y}, @var{z}, где координаты полагаются в интервале [0, 1]. Значения производных в точке записываются в @var{dif}. +@end deftypefn +@cindex Linear1 +@deftypefn {Метод класса @code{mglData}} @code{mreal} Linear1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{dual} Linear1 (@code{mglPoint} &dif, @code{mreal} x, @code{mreal} y=@code{0}, @code{mreal} z=@code{0}) @code{const} +Интерполирует данные линейной функцией в точке @var{x}, @var{y}, @var{z}, где координаты полагаются в интервале [0, 1]. Значения производных в точке записываются в @var{dif}. +@end deftypefn + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Data information, Operators, Interpolation, Data processing +@section Информационные функции +@nav{} + +В MathGL есть ряд функций для получения свойств массива данных. В MGL скриптах большинство из них реализовано в виде "суффиксов". Суффиксы дают числовое значение некоторой характеристики массива данных. Например, его размер, минимальное и максимальное значение, сумму элементов и т.д. Суффиксы начинаются с точки @samp{.} сразу после массива (без пробелов). Например, @code{a.nx} даст размер массива @var{a} вдоль x, @code{b(1).max} даст максимальное значение второй колонки массива @var{b}, @code{(c(:,0)^2).sum} даст сумму квадратов в первой строке массива @var{c} и т.д. + + +@cindex PrintInfo +@anchor{info} +@deftypefn {Команда MGL} {} info dat +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{const char *} PrintInfo () @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{void} PrintInfo (@code{FILE *}fp) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{const char *} PrintInfo () @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{void} PrintInfo (@code{FILE *}fp) @code{const} +@deftypefnx {Функция С} @code{const char *} mgl_data_info (@code{HCDT} dat) +@end ifclear +Возвращает строку с информацией о данных (размеры, моменты и пр.) или пишет её в файл. В MGL скрипте печатает её как сообщение. +@end deftypefn + +@deftypefn {Команда MGL} {} info 'txt' +Печатает строку @var{txt} как сообщение. +@end deftypefn + +@deftypefn {Команда MGL} {} info val +Печатает значение числа @var{val} как сообщение. +@end deftypefn + +@cindex GetNx +@cindex GetNy +@cindex GetNz +@anchor{.nx} @anchor{.ny} @anchor{.nz} +@deftypefn {MGL suffix} {(dat)} .nx +@deftypefnx {MGL suffix} {(dat)} .ny +@deftypefnx {MGL suffix} {(dat)} .nz +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{long} GetNx () +@deftypefnx {Метод класса @code{mglData}} @code{long} GetNy () +@deftypefnx {Метод класса @code{mglData}} @code{long} GetNz () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNx () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNy () +@deftypefnx {Метод класса @code{mglDataC}} @code{long} GetNz () +@deftypefnx {Функция С} @code{long} mgl_data_get_nx (@code{HCDT} dat) +@deftypefnx {Функция С} @code{long} mgl_data_get_ny (@code{HCDT} dat) +@deftypefnx {Функция С} @code{long} mgl_data_get_nz (@code{HCDT} dat) +@end ifclear +Возвращает размер данных в направлении x, y и z соответственно. +@end deftypefn + + + +@cindex Maximal +@anchor{.max} +@deftypefn {MGL suffix} {(dat)} .max +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Maximal () @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Maximal () @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_max (@code{HCDT} dat) +@end ifclear +Возвращает максимальное значение массива данных. +@end deftypefn + +@cindex Minimal +@anchor{.min} +@deftypefn {MGL suffix} {(dat)} .min +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Minimal () @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Minimal () @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_min (@code{HMDT} dat) @code{const} +@end ifclear +Возвращает минимальное значение массива данных. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglData}} @code{mreal} Minimal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Minimal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_min_int (@code{HCDT} dat, @code{int} *i, @code{int} *j, @code{int} *k) +Возвращает максимальное значение массива данных и сохраняет его положение в переменные @var{i}, @var{j}, @var{k}. +@end deftypefn +@deftypefn {Метод класса @code{mglData}} @code{mreal} Maximal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Maximal (@code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_max_int (@code{HCDT} dat, @code{int} *i, @code{int} *j, @code{int} *k) +Возвращает минимальное значение массива данных и сохраняет его положение в переменные @var{i}, @var{j}, @var{k}. +@end deftypefn +@deftypefn {Метод класса @code{mglData}} @code{mreal} Minimal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Minimal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_min_real (@code{HCDT} dat, @code{mreal} *x, @code{mreal} *y, @code{mreal} *z) +Возвращает максимальное значение массива данных и его приближенное (интерполированное) положение в переменные @var{x}, @var{y}, @var{z}. +@end deftypefn +@end ifclear + +@anchor{.mx} @anchor{.my} @anchor{.mz} +@deftypefn {MGL suffix} {(dat)} .mx +@deftypefnx {MGL suffix} {(dat)} .my +@deftypefnx {MGL suffix} {(dat)} .mz +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Maximal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Метод класса @code{mglDataC}} @code{mreal} Maximal (@code{mreal} &x, @code{mreal} &y, @code{mreal} &z) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_max_real (@code{HCDT} dat, @code{mreal} *x, @code{mreal} *y, @code{mreal} *z) +@end ifclear +Возвращает минимальное значение массива данных и его приближенное (интерполированное) положение в переменные @var{x}, @var{y}, @var{z}. +@end deftypefn + + +@cindex Momentum +@anchor{.ax} @anchor{.ay} @anchor{.az} @anchor{.aa} @anchor{.sum} +@anchor{.wx} @anchor{.wy} @anchor{.wz} @anchor{.wa} +@anchor{.sx} @anchor{.sy} @anchor{.sz} @anchor{.sa} +@anchor{.kx} @anchor{.ky} @anchor{.kz} @anchor{.ka} +@deftypefn {MGL suffix} {(dat)} .sum +@deftypefnx {MGL suffix} {(dat)} .ax +@deftypefnx {MGL suffix} {(dat)} .ay +@deftypefnx {MGL suffix} {(dat)} .az +@deftypefnx {MGL suffix} {(dat)} .aa +@deftypefnx {MGL suffix} {(dat)} .wx +@deftypefnx {MGL suffix} {(dat)} .wy +@deftypefnx {MGL suffix} {(dat)} .wz +@deftypefnx {MGL suffix} {(dat)} .wa +@deftypefnx {MGL suffix} {(dat)} .sx +@deftypefnx {MGL suffix} {(dat)} .sy +@deftypefnx {MGL suffix} {(dat)} .sz +@deftypefnx {MGL suffix} {(dat)} .sa +@deftypefnx {MGL suffix} {(dat)} .kx +@deftypefnx {MGL suffix} {(dat)} .ky +@deftypefnx {MGL suffix} {(dat)} .kz +@deftypefnx {MGL suffix} {(dat)} .ka +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Momentum (@code{char} dir, @code{mreal} &a, @code{mreal} &w) @code{const} +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Momentum (@code{char} dir, @code{mreal} &m, @code{mreal} &w, @code{mreal} &s, @code{mreal} &k) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_momentum_val (@code{HCDT} dat, @code{char} dir, @code{mreal} *a, @code{mreal} *w, @code{mreal} *s, @code{mreal} *k) +@end ifclear +Возвращает нулевой момент (энергию, @math{I=\sum a_i}) и записывает первый (среднее, @math{m = \sum \xi_i a_i/I}), второй (ширину, @math{w^2 = \sum (\xi_i-m)^2 a_i/I}), третий (асимметрия, @math{s = \sum (\xi_i-m)^3 a_i/ I w^3}) и четвёртый моменты (эксцесс, @math{k = \sum (\xi_i-m)^4 a_i / 3 I w^4})). Здесь @math{\xi} -- соответствующая координата если @var{dir} равно @samp{'x'}, @samp{'y'}, @samp{'z'}. В противном случае среднее, ширина, асимметрия, эксцесс равны @math{m = \sum a_i/N}, @math{w^2 = \sum (a_i-m)^2/N} и т.д. +@end deftypefn + +@anchor{.fst} +@deftypefn {MGL suffix} {(dat)} .fst +@ifclear UDAV +@cindex Find +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Find (@code{const char *}cond, @code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_first (@code{HCDT} dat, @code{const char *}cond, @code{int} *i, @code{int} *j, @code{int} *k) +@end ifclear +Находит положение (после заданного в @var{i}, @var{j}, @var{k}) первого не нулевого значения формулы @var{cond}. Функция возвращает найденное значение и записывает его положение в @var{i}, @var{j}, @var{k}. +@end deftypefn + +@anchor{.lst} +@deftypefn {MGL suffix} {(dat)} .lst +@ifclear UDAV +@cindex Last +@deftypefnx {Метод класса @code{mglData}} @code{mreal} Last (@code{const char *}cond, @code{int} &i, @code{int} &j, @code{int} &k) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_last (@code{HCDT} dat, @code{const char *}cond, @code{int} *i, @code{int} *j, @code{int} *k) +@end ifclear +Находит положение (перед заданного в @var{i}, @var{j}, @var{k}) последнего не нулевого значения формулы @var{cond}. Функция возвращает найденное значение и записывает его положение в @var{i}, @var{j}, @var{k}. +@end deftypefn + +@ifclear UDAV +@deftypefn {Метод класса @code{mglData}} @code{int} Find (@code{const char *}cond, @code{char} dir, @code{int} i=@code{0}, @code{int} j=@code{0}, @code{int} k=@code{0}) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_find (@code{HCDT} dat, @code{const char *}cond, @code{int} i, @code{int} j, @code{int} k) +Возвращает положение первого в направлении @var{dir} не нулевого значения формулы @var{cond}. Поиск начинается с точки @{i,j,k@}. +@end deftypefn +@cindex FindAny +@deftypefn {Метод класса @code{mglData}} @code{bool} FindAny (@code{const char *}cond) @code{const} +@deftypefnx {Функция С} @code{mreal} mgl_data_find_any (@code{HCDT} dat, @code{const char *}cond) +Определяет есть ли хоть одно значение массива, удовлетворяющее условию @var{cond}. +@end deftypefn +@end ifclear + +@anchor{.a} +@deftypefn {MGL suffix} {(dat)} .a +Возвращает первое число массива (для @code{.a} это @code{dat->a[0]}). +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Operators, Global functions, Data information, Data processing +@section Операторы +@nav{} + +@deftypefn {Команда MGL} {} copy @sc{dat} dat2 ['eq'=''] +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} operator= (@code{const mglDataA &}d) +@end ifclear +Копирует данные из другого экземпляра. +@end deftypefn + +@deftypefn {Команда MGL} {} copy dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mreal}} @code{void} operator= (@code{mreal} val) +@end ifclear +Устанавливает все значения массива равными @var{val}. +@end deftypefn + +@anchor{multo} +@deftypefn {Команда MGL} {} multo dat dat2 +@deftypefnx {Команда MGL} {} multo dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} operator*= (@code{const mglDataA &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} operator*= (@code{mreal} d) +@deftypefnx {Функция С} @code{void} mgl_data_mul_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {Функция С} @code{void} mgl_data_mul_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Поэлементно умножает на массив @var{d} или на число @var{val}. +@end deftypefn + +@anchor{divto} +@deftypefn {Команда MGL} {} divto dat dat2 +@deftypefnx {Команда MGL} {} divto dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} operator/= (@code{const mglDataA &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} operator/= (@code{mreal} d) +@deftypefnx {Функция С} @code{void} mgl_data_div_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {Функция С} @code{void} mgl_data_div_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Поэлементно делит на массив @var{d} или на число @var{val}. +@end deftypefn + +@anchor{addto} +@deftypefn {Команда MGL} {} addto dat dat2 +@deftypefnx {Команда MGL} {} addto dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} operator+= (@code{const mglDataA &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} operator+= (@code{mreal} d) +@deftypefnx {Функция С} @code{void} mgl_data_add_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {Функция С} @code{void} mgl_data_add_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Поэлементно прибавляет @var{d} или число @var{val}. +@end deftypefn + +@anchor{subto} +@deftypefn {Команда MGL} {} subto dat dat2 +@deftypefnx {Команда MGL} {} subto dat @code{val} +@ifclear UDAV +@deftypefnx {Метод класса @code{mglData}} @code{void} operator-= (@code{const mglDataA &}d) +@deftypefnx {Метод класса @code{mglData}} @code{void} operator-= (@code{mreal} d) +@deftypefnx {Функция С} @code{void} mgl_data_sub_dat (@code{HMDT} dat, @code{HCDT} d) +@deftypefnx {Функция С} @code{void} mgl_data_sub_num (@code{HMDT} dat, @code{mreal} d) +@end ifclear +Поэлементно вычитает @var{d} или число @var{val}. +@end deftypefn + +@ifclear UDAV +@deftypefn {Library Function} mglData operator+ (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator+ (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator+ (@code{const mglDataA &}a, @code{mreal} b) +Возвращает поэлементную сумму данных. +@end deftypefn + +@deftypefn {Library Function} mglData operator- (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator- (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator- (@code{const mglDataA &}a, @code{mreal} b) +Возвращает поэлементную разность данных. +@end deftypefn + +@deftypefn {Library Function} mglData operator* (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator* (@code{mreal} a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator* (@code{const mglDataA &}a, @code{mreal} b) +Возвращает поэлементное произведение данных. +@end deftypefn + +@deftypefn {Library Function} mglData operator/ (@code{const mglDataA &}a, @code{const mglDataA &}b) +@deftypefnx {Library Function} mglData operator/ (@code{const mglDataA &}a, @code{mreal} b) +Возвращает поэлементное деление данных. +@end deftypefn +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node Global functions, Evaluate expression, Operators, Data processing +@section Глобальные функции +@nav{} + +@ifclear UDAV +Эти функции не методы класса @code{mglData}, но они дают дополнительные возможности по обработке данных. Поэтому я поместил их в эту главу. +@end ifclear + +@anchor{transform} +@deftypefn {Команда MGL} {} transform @sc{dat} 'type' real imag +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTransform (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{const char *}type) +@deftypefnx {Функция С} @code{HMDT} mgl_transform (@code{HCDT} real, @code{HCDT} imag, @code{const char *}type) +@end ifclear +Выполняет интегральное преобразование комплексных данных @var{real}, @var{imag} в выбранном направлении и возвращает модуль результата. Порядок и тип преобразований задается строкой @var{type}: первый символ для x-направления, второй для y-направления, третий для z-направления. Возможные символы: @samp{f} -- прямое преобразование Фурье, @samp{i} -- обратное преобразование Фурье, @samp{s} -- синус преобразование, @samp{c} -- косинус преобразование, @samp{h} -- преобразование Ханкеля, @samp{n} или @samp{ } -- нет преобразования. +@end deftypefn + +@anchor{transforma} +@deftypefn {Команда MGL} {} transforma @sc{dat} 'type' ampl phase +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTransformA @code{const mglDataA &}ampl, @code{const mglDataA &}phase, @code{const char *}type) +@deftypefnx {Функция С} @code{HMDT} mgl_transform_a @code{HCDT} ampl, @code{HCDT} phase, @code{const char *}type) +@end ifclear +Аналогично предыдущему с заданными амплитудой @var{ampl} и фазой @var{phase} комплексных чисел. +@end deftypefn + +@anchor{fourier} +@deftypefn {Команда MGL} {} fourier reDat imDat 'dir' +@ifclear UDAV +@deftypefnx {Global function} @code{void} mglFourier @code{const mglDataA &}re, @code{const mglDataA &}im, @code{const char *}dir) +@deftypefnx {Функция С} @code{void} mgl_data_fourier @code{HCDT} re, @code{HCDT} im, @code{const char *}dir) +@end ifclear +Выполняет Фурье преобразование для комплексных данных @var{re}+i*@var{im} в направлениях @var{dir}. Результат помещается обратно в массивы @var{re} и @var{im}. +@end deftypefn + +@anchor{stfad} +@deftypefn {Команда MGL} {} stfad @sc{res} real imag @code{dn} ['dir'='x'] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglSTFA (@code{const mglDataA &}real, @code{const mglDataA &}imag, @code{int} dn, @code{char} dir=@code{'x'}) +@deftypefnx {Функция С} @code{HMDT} mgl_data_stfa (@code{HCDT} real, @code{HCDT} imag, @code{int} dn,@code{char} dir) +@end ifclear +Выполняет оконное преобразование Фурье длиной @var{dn} для комплексных данных @var{real}, @var{imag} и возвращает модуль результата. Например, для @var{dir}=@samp{x} результат будет иметь размер @{int(nx/dn), dn, ny@} и будет равен @math{res[i,j,k]=|\sum_d^dn exp(I*j*d)*(real[i*dn+d,k]+I*imag[i*dn+d,k])|/dn}. +@end deftypefn + +@anchor{pde} +@deftypefn {Команда MGL} {} pde @sc{res} 'ham' ini_re ini_im [@code{dz=0.1 k0=100}] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglPDE (@code{HMGL} gr, @code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{mreal} dz=@code{0.1}, @code{mreal} k0=@code{100}, @code{const char *}opt=@code{""}) +@deftypefnx {Функция С} @code{HMDT} mgl_pde_solve (@code{HMGL} gr, @code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{mreal} dz, @code{mreal} k0, @code{const char *}opt) +@end ifclear +Решает уравнение в частных производных du/dz = i*k0*@var{ham}(p,q,x,y,z,|u|)[u], где p=-i/k0*d/dx, q=-i/k0*d/dy -- псевдо-дифференциальные операторы. Параметры @var{ini_re}, @var{ini_im} задают начальное распределение поля. Координаты в уравнении и в решении полагаются в диапазоне осей координат. Замечу, что внутри этот диапазон увеличивается в 3/2 раза для уменьшения отражения от границ расчетного интервала. Параметр @var{dz} задает шаг по эволюционной координате z. В данный момент использован упрощенный алгоритм, когда все ``смешанные'' члена (типа @samp{x*p}->x*d/dx) исключаются. Например, в 2D случае это функции типа @math{ham = f(p,z) + g(x,z,u)}. При этом допускаются коммутирующие комбинации (типа @samp{x*q}->x*d/dy). Переменная @samp{u} используется для обозначения амплитуды поля |u|. Это позволяет решать нелинейные задачи -- например, нелинейное уравнение Шредингера @code{ham='p^2+q^2-u^2'}. Также можно указать мнимую часть для поглощения (типа @code{ham = 'p^2+i*x*(x>0)'}), но только если зависимость от @samp{i} линейная, т.е. @math{ham = hre+i*him}. @sref{PDE solving hints} +@end deftypefn + +@anchor{ray} +@deftypefn {Команда MGL} {} ray @sc{res} 'ham' @code{x0 y0 z0 p0 q0 v0 [dt=0.1 tmax=10]} +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglRay (@code{const char *}ham, @code{mglPoint} r0, @code{mglPoint} p0, @code{mreal} dt=@code{0.1}, @code{mreal} tmax=@code{10}) +@deftypefnx {Функция С} @code{HMDT} mgl_ray_trace (@code{const char *}ham, @code{mreal} x0, @code{mreal} y0, @code{mreal} z0, @code{mreal} px, @code{mreal} py, @code{mreal} pz, @code{mreal} dt, @code{mreal} tmax) +@end ifclear +Решает систему геометрооптических уравнений d@emph{r}/dt = d @var{ham}/d@emph{p}, d@emph{p}/dt = -d @var{ham}/d@emph{r}. Это гамильтоновы уравнения для траектории частицы в 3D случае. Гамильтониан @var{ham} может зависеть от координат @samp{x}, @samp{y}, @samp{z}, импульсов @samp{p}=px, @samp{q}=py, @samp{v}=pz и времени @samp{t}: @math{ham = H(x,y,z,p,q,v,t)}. Начальная точка (при @code{t=0}) задается переменными @{@var{x0}, @var{y0}, @var{z0}, @var{p0}, @var{q0}, @var{v0}@}. Параметры @var{dt} и @var{tmax} задают шаг и максимальное время интегрирования. Результат -- массив @{x,y,z,p,q,v,t@} с размером @{7 * int(@var{tmax}/@var{dt}+1) @}. +@end deftypefn + +@anchor{qo2d} +@deftypefn {Команда MGL} {} qo2d @sc{res} 'ham' ini_re ini_im ray [@code{r=1 k0=100} xx yy] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglQO2d (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{const mglDataA &}ray, @code{mreal} r=@code{1}, @code{mreal} k0=@code{100}, @code{mglData *}xx=@code{0}, @code{mglData *}yy=@code{0}) +@deftypefnx {Global function} @code{mglData} mglQO2d (@code{const char *}ham, @code{const mglDataA &}ini_re, @code{const mglDataA &}ini_im, @code{const mglDataA &}ray, @code{mglData &}xx, @code{mglData &}yy, @code{mreal} r=@code{1}, @code{mreal} k0=@code{100}) +@deftypefnx {Функция С} @code{HMDT} mgl_qo2d_solve (@code{const char *}ham, @code{HCDT} ini_re, @code{HCDT} ini_im, @code{HCDT} ray, @code{mreal} r, @code{mreal} k0, @code{HMDT} xx, @code{HMDT} yy) +@end ifclear +Решает уравнение в частных производных du/dt = i*k0*@var{ham}(p,q,x,y,|u|)[u] в сопровождающей системе координат, где p=-i/k0*d/dx, q=-i/k0*d/dy -- псевдо-дифференциальные операторы. Параметры @var{ini_re}, @var{ini_im} задают начальное распределение поля. Параметр @var{ray} задает опорный луч для сопровождающей системы координат. Можно использовать луч найденный с помощью @code{mglRay()}. Опорный луч должен быть достаточно гладкий, чтобы система координат была однозначной и для исключения ошибок интегрирования. Если массивы @var{xx} и @var{yy} указаны, то в них записываются декартовы координаты для каждой точки найденного решения. См. также @code{mglPDE()}. @sref{PDE solving hints} +@end deftypefn + +@anchor{jacobian} +@deftypefn {Команда MGL} {} jacobian @sc{res} xdat ydat [zdat] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglJacobian (@code{const mglDataA &}x, @code{const mglDataA &}y) +@deftypefnx {Global function} @code{mglData} mglJacobian (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {Функция С} @code{HMDT} mgl_jacobian_2d (@code{HCDT} x, @code{HCDT} y) +@deftypefnx {Функция С} @code{HMDT} mgl_jacobian_3d (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z) +@end ifclear +Вычисляет якобиан преобразования @{i,j,k@} в @{@var{x},@var{y},@var{z}@}, где координаты @{i,j,k@} полагаются нормированными в интервал [0,1]. Якобиан находится по формуле det||@math{dr_\alpha/d\xi_\beta}||, где @math{r}=@{@var{x},@var{y},@var{z}@} и @math{\xi}=@{i,j,k@}. Все размерности всех массивов должны быть одинаковы. Данные должны быть трехмерными если указаны все 3 массива @{@var{x},@var{y},@var{z}@} или двумерными если только 2 массива @{@var{x},@var{y}@}. +@end deftypefn + +@anchor{triangulation} +@deftypefn {Команда MGL} {} triangulation @sc{res} xdat ydat [zdat] +@c @deftypefn {Команда MGL} {} triangulation @sc{res} xdat ydat [zdat] +@ifclear UDAV +@deftypefnx {Global function} @code{mglData} mglTriangulation (@code{const mglDataA &}x, @code{const mglDataA &}y) +@deftypefnx {Global function} @code{mglData} mglTriangulation (@code{const mglDataA &}x, @code{const mglDataA &}y, @code{const mglDataA &}z) +@deftypefnx {Функция С} @code{HMDT} mgl_triangulation_2d (@code{HCDT} x, @code{HCDT} y) +@deftypefnx {Функция С} @code{HMDT} mgl_triangulation_3d (@code{HCDT} x, @code{HCDT} y, @code{HCDT} z) +@end ifclear +Выполняет триангуляцию для произвольно расположенных точек с координатами @{@var{x},@var{y},@var{z}@} (т.е. находит треугольники, соединяющие точки). Первая размерность всех массивов должна быть одинакова @code{x.nx=y.nx=z.nx}. Получившийся массив можно использовать в @ref{triplot} или @ref{tricont} для визуализации реконструированной поверхности. @sref{Making regular data} +@end deftypefn + + +@c ------------------------------------------------------------------ +@external{} +@node Evaluate expression, MGL variables, Global functions, Data processing +@section Вычисление выражений +@nav{} + +@ifset UDAV +В MGL скриптах в качестве аргументов команд можно использовать произвольные формулы от существующих массивов данных и констант. Есть только 2 ограничения: формула не должна содержать пробелов (чтобы распознаваться как один аргумент), формула не может быть аргументом, который может быть пересоздан при выполнении скрипта. +@end ifset + +@ifclear UDAV +В MathGL есть специальные классы @code{mglExpr} и @code{mglExprC} для вычисления формул заданных строкой для действительных и комплексных чисел соответственно. Классы определены в @code{#include } и @code{#include } соответственно. При создании класса происходит разбор формулы в древовидную структуру. А при вычислении только выполняется достаточно быстрый обход по дереву. В данный момент нет различия между верхним и нижним регистром. Если аргумент какой-либо функции лежит вне её области определения, то возвращается NaN. @xref{Textual formulas}. + +@deftypefn {Конструктор класса @code{mglExpr}} @code{} mglExpr (@code{const char *}expr) +@deftypefnx {Конструктор класса @code{mglExprC}} @code{} mglExprC (@code{const char *}expr) +@deftypefnx {Функция С} @code{HMEX} mgl_create_expr (@code{const char *}expr) +@deftypefnx {Функция С} @code{HAEX} mgl_create_cexpr (@code{const char *}expr) +Разбирает формулу @var{expr} и создает древовидную структуру, содержащую последовательность вызова функций и операторов для последующего быстрого вычисления формулы с помощью функций @code{Calc()} и/или @code{CalcD()}. +@end deftypefn + +@deftypefn {Destructor on @code{mglExpr}} @code{} ~mglExpr () +@deftypefnx {Destructor on @code{mglExprC}} @code{} ~mglExprC () +@deftypefnx {Функция С} @code{void} mgl_delete_expr (@code{HMEX} ex) +@deftypefnx {Функция С} @code{void} mgl_delete_cexpr (@code{HAEX} ex) +Удаляет объект типа @code{mglExpr}. +@end deftypefn + +@deftypefn {Метод класса @code{mglExpr}} @code{mreal} Eval (@code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Метод класса @code{mglExprC}} @code{dual} Eval (@code{dual} x, @code{dual} y, @code{dual} z) +@deftypefnx {Функция С} @code{mreal} mgl_expr_eval (@code{HMEX} ex, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Функция С} @code{dual} mgl_cexpr_eval (@code{HAEX} ex, @code{dual} x, @code{dual} y, @code{dual} z) +Вычисляет значение формулы для @code{'x','r'}=@var{x}, @code{'y','n'}=@var{y}, @code{'z','t'}=@var{z}, @code{'a','u'}=@var{u}. +@end deftypefn + +@deftypefn {Метод класса @code{mglExpr}} @code{mreal} Eval (@code{mreal} var[26]) +@deftypefnx {Метод класса @code{mglExprC}} @code{dual} Eval (@code{dual} var[26]) +@deftypefnx {Функция С} @code{mreal} mgl_expr_eval_v (@code{HMEX} ex, @code{mreal *}var) +@deftypefnx {Функция С} @code{dual} mgl_cexpr_eval_v (@code{HMEX} ex, @code{dual *}var) +Вычисляет значение формулы для переменных в массиве @var{var}[0,...,'z'-'a']. +@end deftypefn + + +@deftypefn {Метод класса @code{mglExpr}} @code{mreal} Diff (@code{char} dir, @code{mreal} x, @code{mreal} y, @code{mreal} z) +@deftypefnx {Функция С} @code{mreal} mgl_expr_diff (@code{HMEX} ex, @code{char} dir, @code{mreal} x, @code{mreal} y, @code{mreal} z) +Вычисляет производную от формулы по переменной @var{dir} для @code{'x','r'}=@var{x}, @code{'y','n'}=@var{y}, @code{'z','t'}=@var{z}, @code{'a','u'}=@var{u}. +@end deftypefn + +@deftypefn {Метод класса @code{mglExpr}} @code{mreal} Diff (@code{char} dir, @code{mreal} var[26]) +@deftypefnx {Функция С} @code{mreal} mgl_expr_diff_v (@code{HMEX} ex, @code{char} dir, @code{mreal *}var) +Вычисляет производную от формулы по переменной @var{dir} для переменных в массиве @var{var}[0,...,'z'-'a']. +@end deftypefn + +@end ifclear + +@c ------------------------------------------------------------------ +@external{} +@node MGL variables, , Evaluate expression, Data processing +@section Переменные MGL +@nav{} + +@ifset UDAV +Для информации о переменных MGL см. @ref{MGL definition}. +@end ifset + +@ifclear UDAV + +Класс mglVar содержит переменную/массив скрипта MGL и используется при разборе MGL скриптов (см. @ref{mglParse class}). Это класс наследник @code{mglData} и определен в @code{#include }. + +@deftypecv {Variable} mglVar @code{std::wstring} s +Имя переменной в скрипте. +@end deftypecv + +@deftypecv {Variable} mglVar @code{mglVar *} next +@deftypecvx {Variable} mglVar @code{mglVar *} prev +Следующая и предыдущая переменная в списке. +@end deftypecv + +@deftypecv {Variable} mglVar @code{bool} temp +Флаг временной переменной. Если @code{true}, то переменная будет удалена после выполнения скрипта. +@end deftypecv + +@deftypecv {Variable} mglVar @code{void (*}func@code{)(void *)} +Callback функция, вызываемая при удалении переменной. +@end deftypecv + +@deftypecv {Variable} mglVar @code{void *} o +Указатель на внешний объект, передаваемый callback функции. +@end deftypecv + +@deftypefn {Constructor on @code{mglVar}} @code{} mglVar () +Создает переменную с размерами 1*1*1. +@end deftypefn + +@deftypefn {Destructor on @code{mglVar}} @code{} ~mglVar () +Удаляет переменную mglVar. +@end deftypefn + +@deftypefn {Метод класса @code{mglVar}} @code{void} MoveAfter (@code{mglVar *}var) +Перемещает переменную после @var{var} в списке переменных. +@end deftypefn + +@end ifclear + +@external{} diff --git a/texinfo/datadvance.png b/texinfo/datadvance.png new file mode 100644 index 0000000..72b95be Binary files /dev/null and b/texinfo/datadvance.png differ diff --git a/texinfo/doc_en.texi b/texinfo/doc_en.texi new file mode 100644 index 0000000..3dcd007 --- /dev/null +++ b/texinfo/doc_en.texi @@ -0,0 +1,218 @@ +\input texinfo +@documentencoding UTF-8 +@documentlanguage en + +@setfilename mathgl_en.info +@include version.texi +@settitle MathGL @value{VERSION} +@syncodeindex pg cp +@comment %**end of header + +@copying +This manual is for MathGL (version @value{VERSION}), a collection of classes and routines for scientific plotting. Please report any errors in this manual to @email{mathgl.abalakin@@gmail.org}. + +@include copyright.texi +@end copying + +@dircategory MathGL documentation system +@direntry +* MathGL: (mathgl). The library for scientific graphics. +@end direntry + +@titlepage +@title MathGL +@subtitle for version @value{VERSION} +@author A.A. Balakin (@uref{http://mathgl.sourceforge.net/}) +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@node Top +@top MathGL + +This file documents the Mathematical Graphic Library (MathGL), a collection of classes and routines for scientific plotting. It corresponds to release @value{VERSION} of the library. Please report any errors in this manual to @email{mathgl.abalakin@@gmail.org}. More information about MathGL can be found at the project homepage, @uref{http://mathgl.sourceforge.net/}. + +@include copyright.texi + +@menu +* Website:: +* Overview:: +* Examples:: +* General concepts:: +* MathGL core:: +* Widget classes:: +* Data processing:: +* MGL scripts:: +* UDAV:: +* Other classes:: +* Symbols and hot-keys:: +* File formats:: +* TeX-like symbols:: +* Plotting time:: +* Copying This Manual:: +* Index:: +@end menu + +@macro nav {} +@html + +@end html +@end macro + +@macro external {} +@html +
+ + +
+ + +
+
+@end html +@end macro + +@macro fig {fname,text} +@center @image{../\fname\, 11cm, , \text\, png} +@end macro +@macro pfig {fname,text} +@center @uref{../pdf/\fname\.pdf, @image{../png/\fname\, 11cm, , \text\, png}} +@c @center @image{../png/\fname\, 11cm, , \text\. See also @uref{../pdf/\fname\.pdf, 3D PDF} sample, .png} +@end macro +@macro ufig {fname,width,text} +@center @image{../udav/\fname\, \width\cm, , \text\, png} +@end macro +@macro sfig {plot,text} +@ref{\text\, @image{../small/\plot\-sm,3cm, , , png}} +@end macro + + +@macro sref {arg} +@xref{\arg\}, for sample code and picture. +@end macro + +@node Website, Overview, , Top +@include web_en.texi + +@node Overview, Examples, Website, Top +@include overview_en.texi + +@node Examples, General concepts, Overview, Top +@include example_en.texi + +@node General concepts, MathGL core, Examples, Top +@include concept_en.texi + +@node MathGL core, Widget classes, General concepts, Top +@include core_en.texi + +@node Widget classes, Data processing, MathGL core, Top +@include widget_en.texi + +@node Data processing, MGL scripts, Widget classes, Top +@include data_en.texi + +@node MGL scripts, UDAV, Data processing, Top +@include parse_en.texi + +@node UDAV, Other classes, MGL scripts, Top +@include udav_en.texi + +@node Other classes, Symbols and hot-keys, UDAV, Top +@include other_en.texi + +@node Symbols and hot-keys, File formats, Other classes, Top +@appendix Symbols and hot-keys +@include symbols_en.texi + +@node File formats, TeX-like symbols, Symbols and hot-keys, Top +@appendix File formats +@include formats_en.texi + +@node TeX-like symbols, Plotting time, File formats, Top +@appendix TeX-like symbols +@include appendix_en.texi + +@node Plotting time, Copying This Manual, TeX-like symbols, Top +@appendix Plotting time +@nav{} + +Table below show plotting time in seconds for all samples in file @uref{http://sourceforge.net/p/mathgl/code/HEAD/tree/mathgl-2x/examples/samples.cpp, examples/samples.cpp}. The test was done in my laptop (i5-2430M) with 64-bit Debian. + +Few words about the speed. Firstly, direct bitmap drawing (Quality=4,5,6) is faster than buffered one (Quality=0,1,2), but sometimes it give incorrect result (see @ref{cloud}) and don't allow to export in vector or 3d formats (like EPS, SVG, PDF ...). Secondly, lower quality is faster than high one generally, i.e. Quality=1 is faster than Quality=2, and Quality=0 is faster than Quality=1. However, if plot contain a lot of faces (like @ref{cloud}, @ref{surf3}, @ref{pipe}, @ref{dew}) then Quality=0 may become slow, especially for small images. Finally, smaller images are drawn faster than larger ones. + +Results for image size 800*600 (default one). +@include time.texi + +Results for image size 1920*1440 (print quality) +@include time_big.texi + +@node Copying This Manual, Index, Plotting time, Top +@appendix GNU Free Documentation License +@include fdl.texi + +@node Index, , Copying This Manual, Top +@unnumbered Index + +@printindex cp + +@bye diff --git a/texinfo/doc_ru.texi b/texinfo/doc_ru.texi new file mode 100644 index 0000000..0dac42f --- /dev/null +++ b/texinfo/doc_ru.texi @@ -0,0 +1,218 @@ +\input texinfo +@documentencoding UTF-8 +@documentlanguage ru + +@setfilename mathgl_en.info +@include version.texi +@settitle MathGL @value{VERSION} +@syncodeindex pg cp +@comment %**end of header + +@copying +This manual is for MathGL (version @value{VERSION}), a collection of classes and routines for scientific plotting. Please report any errors in this manual to @email{mathgl.abalakin@@gmail.org}. + +@include copyright.texi +@end copying + +@dircategory MathGL documentation system +@direntry +* MathGL: (mathgl). The library for scientific graphics. +@end direntry + +@titlepage +@title MathGL +@subtitle for version @value{VERSION} +@author A.A. Balakin (@uref{http://mathgl.sourceforge.net/}) +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + +@contents + +@ifnottex +@node Top +@top MathGL + +This file documents the Mathematical Graphic Library (MathGL), a collection of classes and routines for scientific plotting. It corresponds to release @value{VERSION} of the library. Please report any errors in this manual to @email{mathgl.abalakin@@gmail.org}. More information about MathGL can be found at the project homepage, @uref{http://mathgl.sourceforge.net/}. + +@include copyright.texi + +@end ifnottex + +@menu +* Website:: +* Overview:: +* Examples:: +* General concepts:: +* MathGL core:: +* Widget classes:: +* Data processing:: +* MGL scripts:: +* UDAV :: +* Other classes:: +* Symbols and hot-keys:: +* File formats:: +* TeX-like symbols:: +* Plotting time:: +* Copying This Manual:: +* Index:: +@end menu + +@macro nav {} +@html + +@end html +@end macro + +@macro external {} +@html +
+ + +
+ + +
+ + +SourceForge.net Logo + + thefreecountry.com: Free Programmers' Resources, Free Webmasters' Resources, Free Security Resources, Free Software + +Support This Project +@end html +@end macro + +@macro fig {fname,text} +@center @image{../\fname\, 11cm, , \text\, png} +@end macro +@macro pfig {fname,text} +@uref{../pdf/\fname\.pdf, @image{../png/\fname\, 11cm, , \text\, png}} +@c @center @image{../png/\fname\, 11cm, , \text\ См. также пример @uref{../pdf/\fname\.pdf, 3D PDF}, .png} +@end macro +@macro ufig {fname,width,text} +@center @image{../udav/\fname\, \width\cm, , \text\, png} +@end macro +@macro sfig {plot,text} +@ref{\text\, @image{../small/\plot\-sm,3cm, , , png}} +@end macro + +@macro sref {arg} +См. раздел @ref{\arg\}, для примеров кода и графика. +@end macro + +@node Website, Overview, , Top +@include web_ru.texi + +@node Overview, Examples, Website, Top +@include overview_ru.texi + +@node Examples, General concepts, Overview, Top +@include example_ru.texi + +@node General concepts, MathGL core, Examples, Top +@include concept_ru.texi + +@node MathGL core, Widget classes, General concepts, Top +@include core_ru.texi + +@node Widget classes, Data processing, MathGL core, Top +@include widget_ru.texi + +@node Data processing, MGL scripts, Widget classes, Top +@include data_ru.texi + +@node MGL scripts, UDAV, Data processing, Top +@include parse_ru.texi + +@node UDAV, Other classes, MGL scripts, Top +@include udav_ru.texi + +@node Other classes, Symbols and hot-keys, UDAV, Top +@include other_ru.texi + +@node Symbols and hot-keys, File formats, Other classes, Top +@appendix Symbols and hot-keys +@include symbols_ru.texi + +@node File formats, TeX-like symbols, Symbols and hot-keys, Top +@appendix File formats +@include formats_ru.texi + +@node TeX-like symbols, Plotting time, File formats, Top +@appendix Символы TeX +@include appendix_ru.texi + +@node Plotting time, Copying This Manual, TeX-like symbols, Top +@appendix Время отрисовки +@nav{} + +В таблице показаны времена создания графика для всех примеров из файла @uref{http://sourceforge.net/p/mathgl/code/HEAD/tree/mathgl-2x/examples/samples.cpp, examples/samples.cpp}. Тест выполнен на моем ноутбуке (i5-2430M) с 64-bit Debian. + +Несколько слов о скорости. Во-первых, прямое рисование в память (Quality=4,5,6) быстрее буферизованного (Quality=0,1,2), но иногда результат некоректен (см. @ref{cloud}) и пропадает возможность экспорта в векторные и 3d форматы (например, EPS, SVG, PDF, ...). Во-вторых, обычно картинка худшего качества рисуется быстрее, т.е. Quality=1 быстрее Quality=2, и Quality=0 быстрее Quality=1. Однако, если график содержит множество граней (например @ref{cloud}, @ref{surf3}, @ref{pipe}, @ref{dew}), то Quality=0 может быть достаточно медленным, особенно для маленьких картинок. Наконец, картинки меньшего размера рисуются быстрее. + +Результаты для изображения размером 800*600 (по умолчанию). +@include time.texi + +Результаты для изображения размером 1920*1440 (для печати) +@include time_big.texi + +@node Copying This Manual, Index, Plotting time, Top +@appendix GNU Free Documentation License +@include fdl.texi + +@node Index, , Copying This Manual, Top +@unnumbered Index + +@printindex cp + +@bye diff --git a/texinfo/emblem_sm.png b/texinfo/emblem_sm.png new file mode 100644 index 0000000..0b8a3e5 Binary files /dev/null and b/texinfo/emblem_sm.png differ diff --git a/texinfo/ex_mgl_en.texi b/texinfo/ex_mgl_en.texi new file mode 100644 index 0000000..c97475d --- /dev/null +++ b/texinfo/ex_mgl_en.texi @@ -0,0 +1,2834 @@ +@c ------------------------------------------------------------------ +@chapter MathGL examples +@nav{} + +This chapter contain information about basic and advanced MathGL, hints and samples for all types of graphics. I recommend you read first 2 sections one after another and at least look on @ref{Hints} section. Also I recommend you to look at @ref{General concepts} and @ref{FAQ}. + +Most of sample scripts placed below use a set of functions for preparing the data. +@verbatim +func 'prepare1d' +new y 50 3 +modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' +modify y 'sin(2*pi*x)' 1 +modify y 'cos(2*pi*x)' 2 +new x1 50 'x' +new x2 50 '0.05-0.03*cos(pi*x)' +new y1 50 '0.5-0.3*cos(pi*x)' +new y2 50 '-0.3*sin(pi*x)' +return + +func 'prepare2d' +new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +return + +func 'prepare3d' +new c 61 50 40 '-2*(x^2+y^2+z^4-z^2)+0.2' +new d 61 50 40 '1-2*tanh((x+y)*(x+y))' +return + +func 'prepare2v' +new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +return + +func 'prepare3v' +define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5) +define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5) +new ex 10 10 10 '0.2*x/$1-0.2*x/$2' +new ey 10 10 10 '0.2*y/$1-0.2*y/$2' +new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2' +return +@end verbatim +Basically, you can put this text after the script. Note, that you need to terminate main script by @ref{stop} command before defining a function. + +@menu +* Basic usage:: +* Advanced usage:: +* Data handling:: +* Data plotting:: +* 1D samples:: +* 2D samples:: +* 3D samples:: +* Vector field samples:: +* Hints:: +* FAQ:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Basic usage, Advanced usage, , Examples +@section Basic usage +@nav{} + +MGL script can be used by several manners. Each has positive and negative sides: +@itemize @bullet +@item +@emph{Using UDAV.} + +Positive sides are possibilities to view the plot at once and to modify it, rotate, zoom or switch on transparency or lighting by hands or by mouse. Negative side is the needness of the X-terminal. @c For more details, see @ref{UDAV}. + +@item +@emph{Using command line tools.} + +Positive aspects are: batch processing of similar data set, for example, a set of resulting data files for different calculation parameters), running from the console program, including the cluster calculation), fast and automated drawing, saving pictures for further analysis, or demonstration). Negative sides are: the usage of the external program for picture viewing. Also, the data plotting is non-visual. So, you have to imagine the picture, view angles, lighting and so on) before the plotting. I recommend to use graphical window for determining the optimal parameters of plotting on the base of some typical data set. And later use these parameters for batch processing in console program. + +In this case you can use the program: @code{mglconv} or @code{mglview} for viewing. + +@item +@emph{Using C/C++/... code.} + +You can easily execute MGL script within C/C++/Fortan code. This can be useful for fast data plotting, for example, in web applications, where textual string (MGL script) may contain all necessary information for plot. The basic C++ code may look as following +@verbatim +const char *mgl_script; // script itself, can be of type const wchar_t* +mglGraph gr; +mglParse pr; +pr.Execute(&gr, mgl_script); +@end verbatim +@end itemize + +The simplest script is +@verbatim +box # draw bounding box +axis # draw axis +fplot 'x^3' # draw some function +@end verbatim + +Just type it in UDAV and press F5. Also you can save it in text file @samp{test.mgl} and type in the console @code{mglconv test.mgl} what produce file @samp{test.mgl.png} with resulting picture. + +@c ------------------------------------------------------------------ +@external{} +@node Advanced usage, Data handling, Basic usage, Examples +@section Advanced usage +@nav{} + +Now I show several non-obvious features of MGL: several subplots in a single picture, curvilinear coordinates, text printing and so on. Generally you may miss this section at first reading, but I don't recommend it. + +@menu +* Subplots:: +* Axis and ticks:: +* Curvilinear coordinates:: +* Colorbars:: +* Bounding box:: +* Ternary axis:: +* Text features:: +* Legend sample:: +* Cutting sample:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Subplots, Axis and ticks, , Advanced usage +@subsection Subplots +@nav{} + +Let me demonstrate possibilities of plot positioning and rotation. MathGL has a set of functions: @ref{subplot}, @ref{inplot}, @ref{title}, @ref{aspect} and @ref{rotate} and so on (see @ref{Subplots and rotation}). The order of their calling is strictly determined. First, one changes the position of plot in image area (functions @ref{subplot}, @ref{inplot} and @ref{multiplot}). Secondly, you can add the title of plot by @ref{title} function. After that one may rotate the plot (command @ref{rotate}). Finally, one may change aspects of axes (command @ref{aspect}). The following code illustrates the aforesaid it: +@verbatim +subplot 2 2 0 +box:text -1 1.1 'Just box' ':L' +inplot 0.2 0.5 0.7 off +box:text 0 1.2 'InPlot example' + +subplot 2 2 1:title 'Rotate only' +rotate 50 60:box + +subplot 2 2 2:title 'Rotate and Aspect' +rotate 50 60:aspect 1 1 2:box + +subplot 2 2 3:title 'Aspect in other direction' +rotate 50 60:aspect 1 2 2:box +@end verbatim +Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. + +Note that several commands can be placed in a string if they are separated by @samp{:} symbol. + +@pfig{aspect, Example of several subplots on the single picture.} + +More complicated sample show how to use most of positioning functions: +@verbatim +subplot 3 2 0:title 'StickPlot' +stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r' +stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g' +stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b' + +subplot 3 2 3 '':title 'ColumnPlot' +columnplot 3 0:box 'r':text 0 0 '0' 'r' +columnplot 3 1:box 'g':text 0 0 '1' 'g' +columnplot 3 2:box 'b':text 0 0 '2' 'b' + +subplot 3 2 4 '':title 'GridPlot' +gridplot 2 2 0:box 'r':text 0 0 '0' 'r' +gridplot 2 2 1:box 'g':text 0 0 '1' 'g' +gridplot 2 2 2:box 'b':text 0 0 '2' 'b' +gridplot 2 2 3:box 'm':text 0 0 '3' 'm' + +subplot 3 2 5 '':title 'InPlot':box +inplot 0.4 1 0.6 1 on:box 'r' + +multiplot 3 2 1 2 1 '':title 'MultiPlot':box +@end verbatim + +@pfig{inplot, Example for most of positioning functions.} + +@c ------------------------------------------------------------------ +@external{} +@node Axis and ticks, Curvilinear coordinates, Subplots, Advanced usage +@subsection Axis and ticks +@nav{} + +MathGL library can draw not only the bounding box but also the axes, grids, labels and so on. The ranges of axes and their origin (the point of intersection) are determined by functions @code{SetRange()}, @code{SetRanges()}, @code{SetOrigin()} (see @ref{Ranges (bounding box)}). Ticks on axis are specified by function @code{SetTicks}, @code{SetTicksVal}, @code{SetTicksTime} (see @ref{Ticks}). But usually + +Command @ref{axis} draws axes. Its textual string shows in which directions the axis or axes will be drawn (by default @code{"xyz"}, function draws axes in all directions). Command @ref{grid} draws grid perpendicularly to specified directions. Example of axes and grid drawing is: +@verbatim +subplot 2 2 0:title 'Axis origin, Grid' +origin 0 0:axis:grid:fplot 'x^3' + +subplot 2 2 1:title '2 axis' +ranges -1 1 -1 1:origin -1 -1:axis +ylabel 'axis_1':fplot 'sin(pi*x)' 'r2' +ranges 0 1 0 1:origin 1 1:axis +ylabel 'axis_2':fplot 'cos(pi*x)' + +subplot 2 2 3:title 'More axis' +origin nan nan:xrange -1 1:axis +xlabel 'x' 0:ylabel 'y_1' 0:fplot 'x^2' 'k' +yrange -1 1:origin -1.3 -1:axis 'y' 'r' +ylabel '#r{y_2}' 0.2:fplot 'x^3' 'r' + +subplot 2 2 2:title '4 segments, inverted axis':origin 0 0: +inplot 0.5 1 0.5 1 on:ranges 0 10 0 2:axis +fplot 'sqrt(x/2)':xlabel 'W' 1:ylabel 'U' 1 +inplot 0 0.5 0.5 1 on:ranges 1 0 0 2:axis 'x' +fplot 'sqrt(x)+x^3':xlabel '\tau' 1 +inplot 0.5 1 0 0.5 on:ranges 0 10 4 0:axis 'y' +fplot 'x/4':ylabel 'L' -1 +inplot 0 0.5 0 0.5 on:ranges 1 0 4 0:fplot '4*x^2' +@end verbatim + +Note, that MathGL can draw not only single axis (which is default). But also several axis on the plot (see right plots). The idea is that the change of settings does not influence on the already drawn graphics. So, for 2-axes I setup the first axis and draw everything concerning it. Then I setup the second axis and draw things for the second axis. Generally, the similar idea allows one to draw rather complicated plot of 4 axis with different ranges (see bottom left plot). + +At this inverted axis can be created by 2 methods. First one is used in this sample -- just specify minimal axis value to be large than maximal one. This method work well for 2D axis, but can wrongly place labels in 3D case. Second method is more general and work in 3D case too -- just use @ref{aspect} function with negative arguments. For example, following code will produce exactly the same result for 2D case, but 2nd variant will look better in 3D. +@verbatim +# variant 1 +ranges 0 10 4 0:axis + +# variant 2 +ranges 0 10 0 4:aspect 1 -1:axis +@end verbatim + +@pfig{axis, Example of axis.} + +Another MathGL feature is fine ticks tunning. By default (if it is not changed by @code{SetTicks} function), MathGL try to adjust ticks positioning, so that they looks most human readable. At this, MathGL try to extract common factor for too large or too small axis ranges, as well as for too narrow ranges. Last one is non-common notation and can be disabled by @code{SetTuneTicks} function. + +Also, one can specify its own ticks with arbitrary labels by help of @code{SetTicksVal} function. Or one can set ticks in time format. In last case MathGL will try to select optimal format for labels with automatic switching between years, months/days, hours/minutes/seconds or microseconds. However, you can specify its own time representation using formats described in @url{http://www.manpagez.com/man/3/strftime/}. Most common variants are @samp{%X} for national representation of time, @samp{%x} for national representation of date, @samp{%Y} for year with century. + +The sample code, demonstrated ticks feature is +@verbatim +subplot 3 2 0:title 'Usual axis' +axis + +subplot 3 2 1:title 'Too big/small range' +ranges -1000 1000 0 0.001:axis + +subplot 3 2 3:title 'Too narrow range' +ranges 100 100.1 10 10.01:axis + +subplot 3 2 4:title 'Disable ticks tuning' +tuneticks off:axis + +subplot 3 2 2:title 'Manual ticks' +ranges -pi pi 0 2 +xtick -pi '\pi' -pi/2 '-\pi/2' 0 '0' 0.886 'x^*' pi/2 '\pi/2' pi 'pi' +# or you can use: +#list v -pi -pi/2 0 0.886 pi/2 pi:xtick v '-\pi\n-\pi/2\n{}0\n{}x^*\n\pi/2\n\pi' +axis:grid:fplot '2*cos(x^2)^2' 'r2' + +subplot 3 2 5:title 'Time ticks' +xrange 0 3e5:ticktime 'x':axis +@end verbatim + +@pfig{ticks, Features of axis ticks.} + +The last sample I want to show in this subsection is Log-axis. From MathGL's point of view, the log-axis is particular case of general curvilinear coordinates. So, we need first define new coordinates (see also @ref{Curvilinear coordinates}) by help of @code{SetFunc} or @code{SetCoor} functions. At this one should wary about proper axis range. So the code looks as following: +@verbatim +subplot 2 2 0 '<_':title 'Semi-log axis' +ranges 0.01 100 -1 1:axis 'lg(x)' '' '' +axis:grid 'xy' 'g':fplot 'sin(1/x)' +xlabel 'x' 0:ylabel 'y = sin 1/x' 0 + +subplot 2 2 1 '<_':title 'Log-log axis' +ranges 0.01 100 0.1 100:axis 'lg(x)' 'lg(y)' '' +axis:fplot 'sqrt(1+x^2)' +xlabel 'x' 0:ylabel 'y = \sqrt{1+x^2}' 0 + +subplot 2 2 2 '<_':title 'Minus-log axis' +ranges -100 -0.01 -100 -0.1:axis '-lg(-x)' '-lg(-y)' '' +axis:fplot '-sqrt(1+x^2)' +xlabel 'x' 0:ylabel 'y = -\sqrt{1+x^2}' 0 + +subplot 2 2 3 '<_':title 'Log-ticks' +ranges 0.01 100 0 100:axis 'sqrt(x)' '' '' +axis:fplot 'x' +xlabel 'x' 1:ylabel 'y = x' 0 +@end verbatim + +@pfig{loglog, Features of axis ticks.} + +You can see that MathGL automatically switch to log-ticks as we define log-axis formula (in difference from v.1.*). Moreover, it switch to log-ticks for any formula if axis range will be large enough (see right bottom plot). Another interesting feature is that you not necessary define usual log-axis (i.e. when coordinates are positive), but you can define ``minus-log'' axis when coordinate is negative (see left bottom plot). + +@c ------------------------------------------------------------------ +@external{} +@node Curvilinear coordinates, Colorbars, Axis and ticks, Advanced usage +@subsection Curvilinear coordinates +@nav{} + +As I noted in previous subsection, MathGL support curvilinear coordinates. In difference from other plotting programs and libraries, MathGL uses textual formulas for connection of the old (data) and new (output) coordinates. This allows one to plot in arbitrary coordinates. The following code plots the line @var{y}=0, @var{z}=0 in Cartesian, polar, parabolic and spiral coordinates: +@verbatim +origin -1 1 -1 +subplot 2 2 0:title 'Cartesian':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis 'y*sin(pi*x)' 'y*cos(pi*x)' '': +subplot 2 2 1:title 'Cylindrical':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis '2*y*x' 'y*y - x*x' '' +subplot 2 2 2:title 'Parabolic':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z' +subplot 2 2 3:title 'Spiral':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid +@end verbatim + +@pfig{curvcoor, Example of curvilinear coordinates} + + +@c ------------------------------------------------------------------ +@external{} +@node Colorbars, Bounding box, Curvilinear coordinates, Advanced usage +@subsection Colorbars +@nav{} + +MathGL handle @ref{colorbar} as special kind of axis. So, most of functions for axis and ticks setup will work for colorbar too. Colorbars can be in log-scale, and generally as arbitrary function scale; common factor of colorbar labels can be separated; and so on. + +But of course, there are differences -- colorbars usually located out of bounding box. At this, colorbars can be at subplot boundaries (by default), or at bounding box (if symbol @samp{I} is specified). Colorbars can handle sharp colors. And they can be located at arbitrary position too. The sample code, which demonstrate colorbar features is: +@verbatim +call 'prepare2d' +new v 9 'x' + +subplot 2 2 0:title 'Colorbar out of box':box +colorbar '<':colorbar '>':colorbar '_':colorbar '^' + +subplot 2 2 1:title 'Colorbar near box':box +colorbar 'I':colorbar '_I':colorbar '^I' + +subplot 2 2 2:title 'manual colors':box:contd v a +colorbar v '<':colorbar v '>':colorbar v '_':colorbar v '^' + +subplot 2 2 3:title '':text -0.5 1.55 'Color positions' ':C' -2 + +colorbar 'bwr>' 0.25 0:text -0.9 1.2 'Default' +colorbar 'b{w,0.3}r>' 0.5 0:text -0.1 1.2 'Manual' + +crange 0.01 1e3 +colorbar '>' 0.75 0:text 0.65 1.2 'Normal scale' +colorbar '>':text 1.35 1.2 'Log scale' +@end verbatim + +@pfig{colorbar, Example of colorbars} + + +@c ------------------------------------------------------------------ +@external{} +@node Bounding box, Ternary axis, Colorbars, Advanced usage +@subsection Bounding box +@nav{} + +Box around the plot is rather useful thing because it allows one to: see the plot boundaries, and better estimate points position since box contain another set of ticks. MathGL provide special function for drawing such box -- @ref{box} function. By default, it draw black or white box with ticks (color depend on transparency type, see @ref{Types of transparency}). However, you can change the color of box, or add drawing of rectangles at rear faces of box. Also you can disable ticks drawing, but I don't know why anybody will want it. The sample code, which demonstrate @ref{box} features is: +@verbatim +subplot 2 2 0:title 'Box (default)':rotate 50 60:box + +subplot 2 2 1:title 'colored':rotate 50 60:box 'r' + +subplot 2 2 2:title 'with faces':rotate 50 60:box '@' + +subplot 2 2 3:title 'both':rotate 50 60:box '@cm' +@end verbatim + +@pfig{box, Example of Box()} + + +@c ------------------------------------------------------------------ +@external{} +@node Ternary axis, Text features, Bounding box, Advanced usage +@subsection Ternary axis +@nav{} + +There are another unusual axis types which are supported by MathGL. These are ternary and quaternary axis. Ternary axis is special axis of 3 coordinates @var{a}, @var{b}, @var{c} which satisfy relation @var{a}+@var{b}+@var{c}=1. Correspondingly, quaternary axis is special axis of 4 coordinates @var{a}, @var{b}, @var{c}, @var{d} which satisfy relation @var{a}+@var{b}+@var{c}+@var{d}=1. + +Generally speaking, only 2 of coordinates (3 for quaternary) are independent. So, MathGL just introduce some special transformation formulas which treat @var{a} as @samp{x}, @var{b} as @samp{y} (and @var{c} as @samp{z} for quaternary). As result, all plotting functions (curves, surfaces, contours and so on) work as usual, but in new axis. You should use @ref{ternary} function for switching to ternary/quaternary coordinates. The sample code is: +@verbatim +ranges 0 1 0 1 0 1 +new x 50 '0.25*(1+cos(2*pi*x))' +new y 50 '0.25*(1+sin(2*pi*x))' +new z 50 'x' +new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' +new rx 10 'rnd':copy ry (1-rx)*rnd +light on + +subplot 2 2 0:title 'Ordinary axis 3D':rotate 50 60 +box:axis:grid +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':zlabel 'Z' + +subplot 2 2 1:title 'Ternary axis (x+y+t=1)':ternary 1 +box:axis:grid 'xyz' 'B;' +plot x y 'r2':plot rx ry 'q^ ':cont a:line 0.5 0 0 0.75 'g2' +xlabel 'B':ylabel 'C':tlabel 'A' + +subplot 2 2 2:title 'Quaternary axis 3D':rotate 50 60:ternary 2 +box:axis:grid 'xyz' 'B;' +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':tlabel 'A':zlabel 'D' + +subplot 2 2 3:title 'Ternary axis 3D':rotate 50 60:ternary 1 +box:axis:grid 'xyz' 'B;' +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':tlabel 'A':zlabel 'Z' +@end verbatim + +@pfig{ternary, Ternary and Quaternary axis} + +@c ------------------------------------------------------------------ +@external{} +@node Text features, Legend sample, Ternary axis, Advanced usage +@subsection Text features +@nav{} + +MathGL prints text by vector font. There are functions for manual specifying of text position (like @code{Puts}) and for its automatic selection (like @code{Label}, @code{Legend} and so on). MathGL prints text always in specified position even if it lies outside the bounding box. The default size of font is specified by functions @var{SetFontSize*} (see @ref{Font settings}). However, the actual size of output string depends on subplot size (depends on functions @code{SubPlot}, @code{InPlot}). The switching of the font style (italic, bold, wire and so on) can be done for the whole string (by function parameter) or inside the string. By default MathGL parses TeX-like commands for symbols and indexes (see @ref{Font styles}). + +Text can be printed as usual one (from left to right), along some direction (rotated text), or along a curve. Text can be printed on several lines, divided by new line symbol @samp{\n}. + +Example of MathGL font drawing is: +@verbatim +call 'prepare1d' + +subplot 2 2 0 '' +text 0 1 'Text can be in ASCII and in Unicode' +text 0 0.6 'It can be \wire{wire}, \big{big} or #r{colored}' +text 0 0.2 'One can change style in string: \b{bold}, \i{italic, \b{both}}' +text 0 -0.2 'Easy to \a{overline} or \u{underline}' +text 0 -0.6 'Easy to change indexes ^{up} _{down} @{center}' +text 0 -1 'It parse TeX: \int \alpha \cdot \ +\sqrt3{sin(\pi x)^2 + \gamma_{i_k}} dx' + +subplot 2 2 1 '' + text 0 0.5 '\sqrt{\frac{\alpha^{\gamma^2}+\overset 1{\big\infty}}{\sqrt3{2+b}}}' '@' -2 +text 0 -0.5 'Text can be printed\n{}on several lines' + +subplot 2 2 2 '':box:plot y(:,0) +text y 'This is very very long string drawn along a curve' 'k' +text y 'Another string drawn above a curve' 'Tr' + +subplot 2 2 3 '':line -1 -1 1 -1 'rA':text 0 -1 1 -1 'Horizontal' +line -1 -1 1 1 'rA':text 0 0 1 1 'At angle' '@' +line -1 -1 -1 1 'rA':text -1 0 -1 1 'Vertical' +@end verbatim + +@pfig{text, Example of text printing} + +You can change font faces by loading font files by function @ref{loadfont}. Note, that this is long-run procedure. Font faces can be downloaded from @uref{http://mathgl.sourceforge.net/download.html, MathGL website} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. The sample code is: +@verbatim +define d 0.25 +loadfont 'STIX':text 0 1.1 'default font (STIX)' +loadfont 'adventor':text 0 1.1-d 'adventor font' +loadfont 'bonum':text 0 1.1-2*d 'bonum font' +loadfont 'chorus':text 0 1.1-3*d 'chorus font' +loadfont 'cursor':text 0 1.1-4*d 'cursor font' +loadfont 'heros':text 0 1.1-5*d 'heros font' +loadfont 'heroscn':text 0 1.1-6*d 'heroscn font' +loadfont 'pagella':text 0 1.1-7*d 'pagella font' +loadfont 'schola':text 0 1.1-8*d 'schola font' +loadfont 'termes':text 0 1.1-9*d 'termes font' +@end verbatim + +@pfig{fonts, Example of font faces} + +@c ------------------------------------------------------------------ +@external{} +@node Legend sample, Cutting sample, Text features, Advanced usage +@subsection Legend sample +@nav{} + +Legend is one of standard ways to show plot annotations. Basically you need to connect the plot style (line style, marker and color) with some text. In MathGL, you can do it by 2 methods: manually using @ref{addlegend} function; or use @samp{legend} option (see @ref{Command options}), which will use last plot style. In both cases, legend entries will be added into internal accumulator, which later used for legend drawing itself. @ref{clearlegend} function allow you to remove all saved legend entries. + +There are 2 features. If plot style is empty then text will be printed without indent. If you want to plot the text with indent but without plot sample then you need to use space @samp{ } as plot style. Such style @samp{ } will draw a plot sample (line with marker(s)) which is invisible line (i.e. nothing) and print the text with indent as usual one. + +Command @ref{legend} draw legend on the plot. The position of the legend can be selected automatic or manually. You can change the size and style of text labels, as well as setup the plot sample. The sample code demonstrating legend features is: +@verbatim +addlegend 'sin(\pi {x^2})' 'b' +addlegend 'sin(\pi x)' 'g*' +addlegend 'sin(\pi \sqrt{x})' 'rd' +addlegend 'jsut text' ' ' +addlegend 'no indent for this' '' + +subplot 2 2 0 '':title 'Legend (default)':box +legend + +text 0.75 0.65 'Absolute position' 'A' +legend 3 'A#' + +subplot 2 2 2 '':title 'coloring':box +legend 0 'r#':legend 1 'Wb#':legend 2 'ygr#' + +subplot 2 2 3 '':title 'manual position':box +legend 0.5 1:text 0.5 0.55 'at x=0.5, y=1' 'a' +legend 1 '#-':text 0.75 0.25 'Horizontal legend' 'a' +@end verbatim + +@pfig{legend, Example of legend} + +@c ------------------------------------------------------------------ +@external{} +@node Cutting sample, , Legend sample, Advanced usage +@subsection Cutting sample +@nav{} + +The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that. +@itemize @bullet +@item +You can set one of coordinate to NAN value. All points with NAN values will be omitted. + +@item +You can enable cutting at edges by @code{SetCut} function. As result all points out of bounding box will be omitted. + +@item +You can set cutting box by @code{SetCutBox} function. All points inside this box will be omitted. + +@item +You can define cutting formula by @code{SetCutOff} function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant. +@end itemize + +Below I place the code which demonstrate last 3 possibilities: +@verbatim +call 'prepare2d' +call 'prepare3d' + +subplot 2 2 0:title 'Cut on (default)':rotate 50 60 +light on:box:surf a; zrange -1 0.5 + +subplot 2 2 1:title 'Cut off':rotate 50 60 +box:surf a; zrange -1 0.5; cut off + +subplot 2 2 2:title 'Cut in box':rotate 50 60:box:alpha on +cut 0 -1 -1 1 0 1.1:surf3 c +cut 0 0 0 0 0 0 # restore back + +subplot 2 2 3:title 'Cut by formula':rotate 50 60:box +cut '(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)':surf3 c +@end verbatim + +@pfig{cut, Example of point cutting} + + + +@c ------------------------------------------------------------------ +@external{} +@node Data handling, Data plotting, Advanced usage, Examples +@section Data handling +@nav{} + +Class @code{mglData} contains all functions for the data handling in MathGL (@pxref{Data processing}). There are several matters why I use class @code{mglData} but not a single array: it does not depend on type of data (mreal or double), sizes of data arrays are kept with data, memory working is simpler and safer. + +@menu +* Array creation:: +* Change data:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Array creation, Change data, , Data handling +@subsection Array creation +@nav{} + +One can put numbers into the data instance by several ways. Let us do it for square function: +@itemize @bullet +@item +one can create array by @code{list} command +@verbatim +list a 0 0.04 0.16 0.36 0.64 1 +@end verbatim + +@item +another way is to copy from ``inline'' array +@verbatim +copy a [0,0.04,0.16,0.36,0.64,1] +@end verbatim + +@item +next way is to fill the data by textual formula with the help of @code{modify} function +@verbatim +new a 6 +modify a 'x^2' +@end verbatim + +@item +or one may fill the array in some interval and modify it later +@verbatim +new a 6 +fill a 0 1 +modify a 'u^2' +@end verbatim + +@item +or fill the array using current axis range +@verbatim +new a 6 +fill a '(x+1)^2/4' +@end verbatim +or use single line +@verbatim +new a 6 '(x+1)^2/4' +@end verbatim + +@item +finally it can be loaded from file +@verbatim +new s 6 '(x+1)^2/4' +save s 'sqr.dat' # create file first +read a 'sqr.dat' # load it +@end verbatim + +@item +at this one can read only part of data +@verbatim +new s 6 '(x+1)^2/4' +save s 'sqr.dat' # create file first +read a 'sqr.dat' 5 # load it +@end verbatim +@end itemize + +Creation of 2d- and 3d-arrays is mostly the same. One can use direct data filling by @code{list} command +@verbatim +list a 11 12 13 | 21 22 23 | 31 32 33 +@end verbatim +or by inline arrays +@verbatim +copy a [[11,12,13],[21,22,23],[31,32,33]] +@end verbatim +Also data can be filled by formula +@verbatim +new z 30 40 'sin(pi*x)*cos(pi*y)' +@end verbatim +or loaded from a file. + +@c ------------------------------------------------------------------ +@external{} +@node Change data, , Array creation, Data handling +@subsection Change data +@nav{} + +MathGL has functions for data processing: differentiating, integrating, smoothing and so on (for more detail, see @ref{Data processing}). Let us consider some examples. The simplest ones are integration and differentiation. The direction in which operation will be performed is specified by textual string, which may contain symbols @samp{x}, @samp{y} or @samp{z}. For example, the call of @code{diff 'x'} will differentiate data along @samp{x} direction; the call of @code{integrate 'xy'} perform the double integration of data along @samp{x} and @samp{y} directions; the call of @code{diff2 'xyz'} will apply 3d Laplace operator to data and so on. Example of this operations on 2d array a=x*y is presented in code: +@verbatim +ranges 0 1 0 1 0 1:new a 30 40 'x*y' +subplot 2 2 0:title 'a(x,y)':rotate 60 40 +surf a:box + +subplot 2 2 1:title 'da/dx':rotate 60 40 +diff a 'x':surf a:box + +subplot 2 2 2:title '\int da/dx dxdy':rotate 60 40 +integrate a 'xy':surf a:box + +subplot 2 2 3:title '\int {d^2}a/dxdy dx':rotate 60 40 +diff2 a 'y':surf a:box +@end verbatim + +@pfig{dat_diff, Example of data differentiation and integration} + +Data smoothing (command @ref{smooth}) is more interesting and important. This function has single argument which define type of smoothing and its direction. Now 3 methods are supported: @samp{3} -- linear averaging by 3 points, @samp{5} -- linear averaging by 5 points, and default one -- quadratic averaging by 5 points. + +MathGL also have some amazing functions which is not so important for data processing as useful for data plotting. There are functions for finding envelope (useful for plotting rapidly oscillating data), for data sewing (useful to removing jumps on the phase), for data resizing (interpolation). Let me demonstrate it: +@verbatim +subplot 2 2 0 '':title 'Envelop sample' +new d1 1000 'exp(-8*x^2)*sin(10*pi*x)' +axis:plot d1 'b' +envelop d1 'x' +plot d1 'r' + +subplot 2 2 1 '':title 'Smooth sample':ranges 0 1 0 1 +new y0 30 '0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd' +copy y1 y0:smooth y1 'x3':plot y1 'r';legend '"3" style' +copy y2 y0:smooth y2 'x5':plot y2 'g';legend '"5" style' +copy y3 y0:smooth y3 'x':plot y3 'b';legend 'default' +plot y0 '{m7}:s';legend 'none':legend:box + +subplot 2 2 2:title 'Sew sample':rotate 50 60:light on:alpha on +new d2 100 100 'mod((y^2-(1-x)^2)/2,0.1)' +box:surf d2 'b' +sew d2 'xy' 0.1 +surf d2 'r' + +subplot 2 2 3:title 'Resize sample (interpolation)' +new x0 10 'rnd':new v0 10 'rnd' +resize x1 x0 100:resize v1 v0 100 +plot x0 v0 'b+ ':plot x1 v1 'r-':label x0 v0 '%n' +@end verbatim + +@pfig{dat_extra, Example of data smoothing} + +Finally one can create new data arrays on base of the existing one: extract slice, row or column of data (@ref{subdata}), summarize along a direction(s) (@ref{sum}), find distribution of data elements (@ref{hist}) and so on. + +@anchor{Solve sample} +Another interesting feature of MathGL is interpolation and root-finding. There are several functions for linear and cubic spline interpolation (see @ref{Interpolation}). Also there is a function @ref{evaluate} which do interpolation of data array for values of each data element of index data. It look as indirect access to the data elements. + +This function have inverse function @ref{solve} which find array of indexes at which data array is equal to given value (i.e. work as root finding). But @ref{solve} function have the issue -- usually multidimensional data (2d and 3d ones) have an infinite number of indexes which give some value. This is contour lines for 2d data, or isosurface(s) for 3d data. So, @ref{solve} function will return index only in given direction, assuming that other index(es) are the same as equidistant index(es) of original data. Let me demonstrate this on the following sample. + +@verbatim +zrange 0 1 +new x 20 30 '(x+2)/3*cos(pi*y)' +new y 20 30 '(x+2)/3*sin(pi*y)' +new z 20 30 'exp(-6*x^2-2*sin(pi*y)^2)' + +subplot 2 1 0:title 'Cartesian space':rotate 30 -40 +axis 'xyzU':box +xlabel 'x':ylabel 'y'origin 1 1:grid 'xy' +mesh x y z + +# section along 'x' direction +solve u x 0.5 'x' +var v u.nx 0 1 +evaluate yy y u v +evaluate xx x u v +evaluate zz z u v +plot xx yy zz 'k2o' + +# 1st section along 'y' direction +solve u1 x -0.5 'y' +var v1 u1.nx 0 1 +evaluate yy y v1 u1 +evaluate xx x v1 u1 +evaluate zz z v1 u1 +plot xx yy zz 'b2^' + +# 2nd section along 'y' direction +solve u2 x -0.5 'y' u1 +evaluate yy y v1 u2 +evaluate xx x v1 u2 +evaluate zz z v1 u2 +plot xx yy zz 'r2v' + +subplot 2 1 1:title 'Accompanied space' +ranges 0 1 0 1:origin 0 0 +axis:box:xlabel 'i':ylabel 'j':grid2 z 'h' + +plot u v 'k2o':line 0.4 0.5 0.8 0.5 'kA' +plot v1 u1 'b2^':line 0.5 0.15 0.5 0.3 'bA' +plot v1 u2 'r2v':line 0.5 0.7 0.5 0.85 'rA' +@end verbatim + +@pfig{solve, Example of data interpolation and root finding} + +@c ------------------------------------------------------------------ +@external{} +@node Data plotting, 1D samples, Data handling, Examples +@section Data plotting +@nav{} + +Let me now show how to plot the data. Next section will give much more examples for all plotting functions. Here I just show some basics. MathGL generally has 2 types of plotting functions. Simple variant requires a single data array for plotting, other data (coordinates) are considered uniformly distributed in axis range. Second variant requires data arrays for all coordinates. It allows one to plot rather complex multivalent curves and surfaces (in case of parametric dependencies). Usually each function have one textual argument for plot style and accept options (see @ref{Command options}). + +Note, that the call of drawing function adds something to picture but does not clear the previous plots (as it does in Matlab). Another difference from Matlab is that all setup (like transparency, lightning, axis borders and so on) must be specified @strong{before} plotting functions. + +Let start for plots for 1D data. Term ``1D data'' means that data depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. The textual argument allow you specify styles of line and marks (see @ref{Line styles}). If this parameter is empty @code{''} then solid line with color from palette is used (see @ref{Palette and colors}). + +Below I shall show the features of 1D plotting on base of @ref{plot} function. Let us start from sinus plot: +@verbatim +new y0 50 'sin(pi*x)' +subplot 2 2 0 +plot y0:box +@end verbatim +Style of line is not specified in @ref{plot} function. So MathGL uses the solid line with first color of palette (this is blue). Next subplot shows array @var{y1} with 2 rows: +@verbatim +subplot 2 2 1 +new y1 50 2 +fill y1 'cos(pi*(x+y/4))*2/(y+3)' +plot y1:box +@end verbatim +As previously I did not specify the style of lines. As a result, MathGL again uses solid line with next colors in palette (there are green and red). Now let us plot a circle on the same subplot. The circle is parametric curve @math{x=cos(\pi t), y=sin(\pi t)}. I will set the color of the circle (dark yellow, @samp{Y}) and put marks @samp{+} at point position: +@verbatim +new x 50 'cos(pi*x)' +plot x y0 'Y+' +@end verbatim +Note that solid line is used because I did not specify the type of line. The same picture can be achieved by @ref{plot} and @ref{subdata} functions. Let us draw ellipse by orange dash line: +@verbatim +plot y1(:,0) y1(:,1) 'q|' +@end verbatim + +Drawing in 3D space is mostly the same. Let us draw spiral with default line style. Now its color is 4-th color from palette (this is cyan): +@verbatim +subplot 2 2 2:rotate 60 40 +new z 50 'x' +plot x y0 z:box +@end verbatim +Functions @ref{plot} and @ref{subdata} make 3D curve plot but for single array. Use it to put circle marks on the previous plot: +@verbatim +new y2 10 3 'cos(pi*(x+y/2))' +modify y2 '2*x-1' 2 +plot y2(:,0) y2(:,1) y2(:,2) 'bo ' +@end verbatim +Note that line style is empty @samp{ } here. Usage of other 1D plotting functions looks similar: +@verbatim +subplot 2 2 3:rotate 60 40 +bars x y0 z 'r':box +@end verbatim + +Surfaces @ref{surf} and other 2D plots (@pxref{2D plotting}) are drown the same simpler as 1D one. The difference is that the string parameter specifies not the line style but the color scheme of the plot (see @ref{Color scheme}). Here I draw attention on 4 most interesting color schemes. There is gray scheme where color is changed from black to white (string @samp{kw}) or from white to black (string @samp{wk}). Another scheme is useful for accentuation of negative (by blue color) and positive (by red color) regions on plot (string @samp{"BbwrR"}). Last one is the popular ``jet'' scheme (string @samp{"BbcyrR"}). + +Now I shall show the example of a surface drawing. At first let us switch lightning on +@verbatim +light on +@end verbatim +and draw the surface, considering coordinates x,y to be uniformly distributed in interval @var{Min}*@var{Max} +@verbatim +new a0 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +subplot 2 2 0:rotate 60 40 +surf a0:box +@end verbatim +Color scheme was not specified. So previous color scheme is used. In this case it is default color scheme (``jet'') for the first plot. Next example is a sphere. The sphere is parametrically specified surface: +@verbatim +new x 50 40 '0.8*sin(pi*x)*cos(pi*y/2)' +new y 50 40 '0.8*cos(pi*x)*cos(pi*y/2)' +new z 50 40 '0.8*sin(pi*y/2)' +subplot 2 2 1:rotate 60 40 +surf x y z 'BbwrR':box +@end verbatim +I set color scheme to @code{"BbwrR"} that corresponds to red top and blue bottom of the sphere. + +Surfaces will be plotted for each of slice of the data if @var{nz}>1. Next example draws surfaces for data arrays with @var{nz}=3: +@verbatim +new a1 50 40 3 +modify a1 '0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))' +modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*sin(3*pi*(x*y))' 1 +modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))' 2 +subplot 2 2 2:rotate 60 40 +alpha on +surf a1:box +@end verbatim +Note, that it may entail a confusion. However, if one will use density plot then the picture will look better: +@verbatim +subplot 2 2 3:rotate 60 40 +dens a1:box +@end verbatim + +Drawing of other 2D plots is analogous. The only peculiarity is the usage of flag @samp{#}. By default this flag switches on the drawing of a grid on plot (@ref{grid} or @ref{mesh} for plots in plain or in volume). However, for isosurfaces (including surfaces of rotation @ref{axial}) this flag switches the face drawing off and figure becomes wired. +@c ------------------------------------------------------------------ +@external{} +@node 1D samples, 2D samples, Data plotting, Examples +@section 1D samples +@nav{} + +This section is devoted to visualization of 1D data arrays. 1D means the data which depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +func 'prepare1d' +new y 50 3 +modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' +modify y 'sin(2*pi*x)' 1 +modify y 'cos(2*pi*x)' 2 +new x1 50 'x' +new x2 50 '0.05-0.03*cos(pi*x)' +new y1 50 '0.5-0.3*cos(pi*x)' +new y2 50 '-0.3*sin(pi*x)' +return +@end verbatim +Basically, you can put this text after the script. Note, that you need to terminate main script by @ref{stop} command before defining a function. + +@menu +* Plot sample:: +* Radar sample:: +* Step sample:: +* Tens sample:: +* Area sample:: +* Region sample:: +* Stem sample:: +* Bars sample:: +* Barh sample:: +* Cones sample:: +* Chart sample:: +* BoxPlot sample:: +* Candle sample:: +* OHLC sample:: +* Error sample:: +* Mark sample:: +* TextMark sample:: +* Label sample:: +* Table sample:: +* Tube sample:: +* Tape sample:: +* Torus sample:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node Plot sample, Radar sample, , 1D samples +@subsection Plot sample +@nav{} + +Command @ref{plot} is most standard way to visualize 1D data array. By default, @code{Plot} use colors from palette. However, you can specify manual color/palette, and even set to use new color for each points by using @samp{!} style. Another feature is @samp{ } style which draw only markers without line between points. The sample code is: +@verbatim +call 'prepare1d' +subplot 2 2 0 '':title 'Plot plot (default)':box +plot y + +subplot 2 2 2 '':title ''!' style; 'rgb' palette':box +plot y 'o!rgb' + +subplot 2 2 3 '':title 'just markers':box +plot y ' +' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +plot xc yc z 'rs' +@end verbatim + +@pfig{plot, Example of Plot()} + + +@c ------------------------------------------------------------------ +@external{} +@node Radar sample, Step sample, Plot sample, 1D samples +@subsection Radar sample +@nav{} + +Command @ref{radar} plot is variant of @code{Plot} one, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use @ref{Curvilinear coordinates} or @code{Plot} in parabolic form with @code{x=r*cos(fi); y=r*sin(fi);}. The sample code is: +@verbatim +new yr 10 3 '0.4*sin(pi*(x+1.5+y/2)+0.1*rnd)' +subplot 1 1 0 '':title 'Radar plot (with grid, "\#")' +radar yr '#' +@end verbatim + +@pfig{radar, Example of Radar()} + +@c ------------------------------------------------------------------ +@external{} +@node Step sample, Tens sample, Radar sample, 1D samples +@subsection Step sample +@nav{} + +Command @ref{step} plot data as stairs. It have the same options as @code{Plot}. The sample code is: +@verbatim +call 'prepare1d' +origin 0 0 0:subplot 2 2 0 '':title 'Step plot (default)':box +step y + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +step xc yc z 'r' + +subplot 2 2 2 '':title '"!" style':box +step y 's!rgb' +@end verbatim + +@pfig{step, Example of Step()} + +@c ------------------------------------------------------------------ +@external{} +@node Tens sample, Area sample, Step sample, 1D samples +@subsection Tens sample +@nav{} + +Command @ref{tens} is variant of @ref{plot} with smooth coloring along the curves. At this, color is determined as for surfaces (see @ref{Color scheme}). The sample code is: +@verbatim +call 'prepare1d' +subplot 2 2 0 '':title 'Tens plot (default)':box +tens y(:,0) y(:,1) + +subplot 2 2 2 '':title ' style':box +tens y(:,0) y(:,1) 'o ' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +tens xc yc z z 's' +@end verbatim + +@pfig{tens, Example of Tens()} + +@c ------------------------------------------------------------------ +@external{} +@node Area sample, Region sample, Tens sample, 1D samples +@subsection Area sample +@nav{} + +Command @ref{area} fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified. The sample code is: +@verbatim +call 'prepare1d' +origin 0 0 0 +subplot 2 2 0 '':title 'Area plot (default)':box +area y + +subplot 2 2 1 '':title '2 colors':box +area y 'cbgGyr' + +subplot 2 2 2 '':title '"!" style':box +area y '!' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 3:title '3d variant':rotate 50 60:box +area xc yc z 'r':area xc -yc z 'b#' +@end verbatim + +@pfig{area, Example of Area()} + +@c ------------------------------------------------------------------ +@external{} +@node Region sample, Stem sample, Area sample, 1D samples +@subsection Region sample +@nav{} + +Command @ref{region} fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1" style':box +vect a b '>' + +subplot 3 2 4 '':title '"<" style':box +vect a b '<' + +call 'prepare3v' +subplot 3 2 5:title '3d variant':rotate 50 60:box +vect ex ey ez +@end verbatim + +@pfig{vect, Example of Vect()} + +@c ------------------------------------------------------------------ +@external{} +@node Vect3 sample, Traj sample, Vect sample, Vector field samples +@subsection Vect3 sample +@nav{} + +Command @ref{vect3} draw just usual vector field plot but at slices of 3D data. The sample code is: +@verbatim +origin 0 0 0:call 'prepare3v' +subplot 2 1 0:title 'Vect3 sample':rotate 50 60 +box:axis '_xyz' +vect3 ex ey ez 'x':vect3 ex ey ez:vect3 ex ey ez 'z' + +subplot 2 1 1:title '"f" style':rotate 50 60 +box:axis '_xyz' +vect3 ex ey ez 'fx':vect3 ex ey ez 'f':vect3 ex ey ez 'fz' +grid3 ex 'Wx':grid3 ex 'W':grid3 ex 'Wz' +@end verbatim + +@pfig{vecta, Example of Vect3()} + +@c ------------------------------------------------------------------ +@external{} +@node Traj sample, Flow sample, Vect3 sample, Vector field samples +@subsection Traj sample +@nav{} + +Command @ref{traj} is 1D analogue of @code{Vect}. It draw vectors from specified points. The sample code is: +@verbatim +call 'prepare1d' +subplot 1 1 0 '':title 'Traj plot':box +plot x1 y:traj x1 y y1 y2 +@end verbatim + +@pfig{traj, Example of Traj()} + + +@c ------------------------------------------------------------------ +@external{} +@node Flow sample, Pipe sample, Traj sample, Vector field samples +@subsection Flow sample +@nav{} + +Command @ref{flow} is another standard way to visualize vector fields -- it draw lines (threads) which is tangent to local vector field direction. MathGL draw threads from edges of bounding box and from central slices. Sometimes it is not most appropriate variant -- you may want to use @code{FlowP} to specify manual position of threads. @code{Flow} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +call 'prepare2v' +subplot 2 2 0 '':title 'Flow plot (default)':box +flow a b + +subplot 2 2 1 '':title '"v" style':box +flow a b 'v' + +subplot 2 2 2 '':title 'from edges only':box +flow a b '#' + +call 'prepare3v' +subplot 2 2 3:title '3d variant':rotate 50 60:box +flow ex ey ez +@end verbatim + +@pfig{flow, Example of Flow()} + +@c ------------------------------------------------------------------ +@external{} +@node Pipe sample, Dew sample, Flow sample, Vector field samples +@subsection Pipe sample +@nav{} + +Command @ref{pipe} is similar to @ref{flow} but draw pipes (tubes) which radius is proportional to the amplitude of vector field. @code{Pipe} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +call 'prepare2v' +subplot 2 2 0 '':title 'Pipe plot (default)':light on:box +pipe a b + +subplot 2 2 1 '':title '"i" style':box +pipe a b 'i' + +subplot 2 2 2 '':title 'from edges only':box +pipe a b '#' + +call 'prepare3v' +subplot 2 2 3:title '3d variant':rotate 50 60:box +pipe ex ey ez '' 0.1 +@end verbatim + +@pfig{pipe, Example of Pipe()} + +@c ------------------------------------------------------------------ +@external{} +@node Dew sample, , Pipe sample, Vector field samples +@subsection Dew sample +@nav{} + +Command @ref{dew} is similar to @code{Vect} but use drops instead of arrows. The sample code is: +@verbatim +call 'prepare2v' +subplot 1 1 0 '':title 'Dew plot':light on:box +dew a b +@end verbatim + +@pfig{dew, Example of Dew()} + + +@c ------------------------------------------------------------------ +@external{} +@node Hints, FAQ, Vector field samples, Examples +@section Hints +@nav{} + +In this section I've included some small hints and advices for the improving of the quality of plots and for the demonstration of some non-trivial features of MathGL library. In contrast to previous examples I showed mostly the idea but not the whole drawing function. + +@menu +* ``Compound'' graphics:: +* Transparency and lighting:: +* Types of transparency:: +* Axis projection:: +* Adding fog:: +* Lighting sample:: +* Using primitives:: +* STFA sample:: +* Mapping visualization:: +* Making regular data:: +* Making histogram:: +* Nonlinear fitting hints:: +* PDE solving hints:: +* MGL parser using:: +* Using options:: +* ``Templates'':: +* Stereo image:: +* Reduce memory usage:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node ``Compound'' graphics, Transparency and lighting, , Hints +@subsection ``Compound'' graphics +@nav{} + +As I noted above, MathGL functions (except the special one, like Clf()) do not erase the previous plotting but just add the new one. It allows one to draw ``compound'' plots easily. For example, popular Matlab command @code{surfc} can be emulated in MathGL by 2 calls: +@verbatim + Surf(a); + Cont(a, "_"); // draw contours at bottom +@end verbatim +Here @var{a} is 2-dimensional data for the plotting, @code{-1} is the value of z-coordinate at which the contour should be plotted (at the bottom in this example). Analogously, one can draw density plot instead of contour lines and so on. + +Another nice plot is contour lines plotted directly on the surface: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "BbcyrR"); // select 'jet' colormap for the surface + Cont(a, "y"); // and yellow color for contours +@end verbatim +The possible difficulties arise in black&white case, when the color of the surface can be close to the color of a contour line. In that case I may suggest the following code: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "kw"); // select 'gray' colormap for the surface + CAxis(-1,0); // first draw for darker surface colors + Cont(a, "w"); // white contours + CAxis(0,1); // now draw for brighter surface colors + Cont(a, "k"); // black contours + CAxis(-1,1); // return color range to original state +@end verbatim +The idea is to divide the color range on 2 parts (dark and bright) and to select the contrasting color for contour lines for each of part. + +Similarly, one can plot flow thread over density plot of vector field amplitude (this is another amusing plot from Matlab) and so on. The list of compound graphics can be prolonged but I hope that the general idea is clear. + +Just for illustration I put here following sample code: +@verbatim +call 'prepare2v' +call 'prepare3d' +new v 10:fill v -0.5 1:copy d sqrt(a^2+b^2) +subplot 2 2 0:title 'Surf + Cont':rotate 50 60:light on:box +surf a:cont a 'y' + +subplot 2 2 1 '':title 'Flow + Dens':light off:box +flow a b 'br':dens d + +subplot 2 2 2:title 'Mesh + Cont':rotate 50 60:box +mesh a:cont a '_' + +subplot 2 2 3:title 'Surf3 + ContF3':rotate 50 60:light on +box:contf3 v c 'z' 0:contf3 v c 'x':contf3 v c +cut 0 -1 -1 1 0 1.1 +contf3 v c 'z' c.nz-1:surf3 c -0.5 +@end verbatim + +@pfig{combined, Example of ``combined'' plots} + +@c ------------------------------------------------------------------ +@external{} +@node Transparency and lighting, Types of transparency, ``Compound'' graphics, Hints +@subsection Transparency and lighting +@nav{} + +Here I want to show how transparency and lighting both and separately change the look of a surface. So, there is code and picture for that: +@verbatim +call 'prepare2d' +subplot 2 2 0:title 'default':rotate 50 60:box +surf a + +subplot 2 2 1:title 'light on':rotate 50 60:box +light on:surf a + +subplot 2 2 3:title 'light on; alpha on':rotate 50 60:box +alpha on:surf a + +subplot 2 2 2:title 'alpha on':rotate 50 60:box +light off:surf a +@end verbatim + +@pfig{alpha, Example of transparency and lightings} + +@c ------------------------------------------------------------------ +@external{} +@node Types of transparency, Axis projection, Transparency and lighting, Hints +@subsection Types of transparency +@nav{} + +MathGL library has advanced features for setting and handling the surface transparency. The simplest way to add transparency is the using of command @ref{alpha}. As a result, all further surfaces (and isosurfaces, density plots and so on) become transparent. However, their look can be additionally improved. + +The value of transparency can be different from surface to surface. To do it just use @code{SetAlphaDef} before the drawing of the surface, or use option @code{alpha} (see @ref{Command options}). If its value is close to 0 then the surface becomes more and more transparent. Contrary, if its value is close to 1 then the surface becomes practically non-transparent. + +Also you can change the way how the light goes through overlapped surfaces. The function @code{SetTranspType} defines it. By default the usual transparency is used (@samp{0}) -- surfaces below is less visible than the upper ones. A ``glass-like'' transparency (@samp{1}) has a different look -- each surface just decreases the background light (the surfaces are commutable in this case). + +A ``neon-like'' transparency (@samp{2}) has more interesting look. In this case a surface is the light source (like a lamp on the dark background) and just adds some intensity to the color. At this, the library sets automatically the black color for the background and changes the default line color to white. + +As example I shall show several plots for different types of transparency. The code is the same except the values of @code{SetTranspType} function: +@verbatim +call 'prepare2d' +alpha on:light on +transptype 0:clf +subplot 2 2 0:rotate 50 60:surf a:box +subplot 2 2 1:rotate 50 60:dens a:box +subplot 2 2 2:rotate 50 60:cont a:box +subplot 2 2 3:rotate 50 60:axial a:box +@end verbatim + +@pfig{type0, Example of @code{SetTranspType(0)}.} +@pfig{type1, Example of @code{SetTranspType(1)}.} +@pfig{type2, Example of @code{SetTranspType(2)}.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis projection, Adding fog, Ternary axis, Hints +@subsection Axis projection +@nav{} + +You can easily make 3D plot and draw its x-,y-,z-projections (like in CAD) by using @ref{ternary} function with arguments: 4 for Cartesian, 5 for Ternary and 6 for Quaternary coordinates. The sample code is: +@verbatim +ranges 0 1 0 1 0 1 +new x 50 '0.25*(1+cos(2*pi*x))' +new y 50 '0.25*(1+sin(2*pi*x))' +new z 50 'x' +new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' +new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx +light on + +title 'Projection sample':ternary 4:rotate 50 60 +box:axis:grid +plot x y z 'r2':surf a '#' +xlabel 'X':ylabel 'Y':zlabel 'Z' +@end verbatim + +@pfig{projection, Example of axis projections} + +@c ------------------------------------------------------------------ +@external{} +@node Adding fog, Lighting sample, Axis projection, Hints +@subsection Adding fog +@nav{} + +MathGL can add a fog to the image. Its switching on is rather simple -- just use @ref{fog} function. There is the only feature -- fog is applied for whole image. Not to particular subplot. The sample code is: +@verbatim +call 'prepare2d' +title 'Fog sample':rotate 50 60:light on +fog 1 +box:surf a +@end verbatim + +@pfig{fog, Example of @code{Fog()}.} + +@c ------------------------------------------------------------------ +@external{} +@node Lighting sample, Using primitives, Adding fog, Hints +@subsection Lighting sample +@nav{} + +In contrast to the most of other programs, MathGL supports several (up to 10) light sources. Moreover, the color each of them can be different: white (this is usual), yellow, red, cyan, green and so on. The use of several light sources may be interesting for the highlighting of some peculiarities of the plot or just to make an amusing picture. Note, each light source can be switched on/off individually. The sample code is: +@verbatim +call 'prepare2d' +title 'Several light sources':rotate 50 60:light on +light 1 0 1 0 'c':light 2 1 0 0 'y':light 3 0 -1 0 'm' +box:surf a 'h' +@end verbatim + +@pfig{several_light, Example of several light sources.} + +Additionally, you can use local light sources and set to use diffise reflection instead of specular one (by default) or both kinds. +@verbatim +# use Quality=6 because need lighting in placed +light on:quality 6 +call 'prepare2d' +subplot 2 2 0:title 'Default':rotate 50 60:box:surf a +line -1 -0.7 1.7 -1 -0.7 0.7 'BA' + +light 0 1 0 1 -2 -1 -1 +subplot 2 2 1:title 'Local':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' + +diffuse 0 +subplot 2 2 2:title 'no diffuse':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' + +diffuse 0.5:light 0 1 0 1 -2 -1 -1 'w' 0 +subplot 2 2 3:title 'diffusive only':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' +@end verbatim + +@pfig{light, Example of different types of lighting.} + +@c ------------------------------------------------------------------ +@external{} +@node Using primitives, STFA sample, Lighting sample, Hints +@subsection Using primitives +@nav{} + +MathGL provide a set of functions for drawing primitives (see @ref{Primitives}). Primitives are low level object, which used by most of plotting functions. Picture below demonstrate some of commonly used primitives. +@verbatim +subplot 2 2 0 '':title 'Line, Curve, Rhomb, Ellipse' '' -1.5 +line -1 -1 -0.5 1 'qAI' +curve -0.6 -1 1 1 0 1 1 1 'rA' +ball 0 -0.5 '*':ball 1 -0.1 '*' +rhomb 0 0.4 1 0.9 0.2 'b#' +rhomb 0 0 1 0.4 0.2 'cg@' +ellipse 0 -0.5 1 -0.1 0.2 'u#' +ellipse 0 -1 1 -0.6 0.2 'm@' + +light on +subplot 2 2 1:title 'Face[xyz]':rotate 50 60:box +facex 1 0 -1 1 1 'r':facey -1 -1 -1 1 1 'g':facez 1 -1 -1 -1 1 'b' +face -1 -1 1 -1 1 1 1 -1 0 1 1 1 'bmgr' + +subplot 2 2 3 '':title 'Cone' +cone -0.7 -0.3 0 -0.7 0.7 0.5 0.2 0.1 'b':text -0.7 -0.7 'no edges\n(default)' +cone 0 -0.3 0 0 0.7 0.5 0.2 0.1 'g@':text 0 -0.7 'with edges\n('\@' style)' +cone 0.7 -0.3 0 0.7 0.7 0.5 0.2 0.1 'ry':text 0.7 -0.7 '"arrow" with\n{}gradient' + +subplot 2 2 2 '':title 'Sphere and Drop' +line -0.9 0 1 0.9 0 1 +text -0.9 -0.7 'sh=0':drop -0.9 0 0 1 0.5 'r' 0:ball -0.9 0 1 'k' +text -0.3 -0.7 'sh=0.33':drop -0.3 0 0 1 0.5 'r' 0.33:ball -0.3 0 1 'k' +text 0.3 -0.7 'sh=0.67':drop 0.3 0 0 1 0.5 'r' 0.67:ball 0.3 0 1 'k' +text 0.9 -0.7 'sh=1':drop 0.9 0 0 1 0.5 'r' 1:ball 0.9 0 1 'k' +@end verbatim + +@pfig{primitives, Primitives in MathGL.} + +Generally, you can create arbitrary new kind of plot using primitives. For example, MathGL don't provide any special functions for drawing molecules. However, you can do it using only one type of primitives @ref{drop}. The sample code is: +@verbatim +alpha on:light on +subplot 2 2 0 '':title 'Methane, CH_4':rotate 60 120 +sphere 0 0 0 0.25 'k':drop 0 0 0 0 0 1 0.35 'h' 1 2:sphere 0 0 0.7 0.25 'g' +drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2:sphere -0.66 0 -0.23 0.25 'g' +drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2:sphere 0.33 0.57 -0.23 0.25 'g' +drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2:sphere 0.33 -0.57 -0.23 0.25 'g' + +subplot 2 2 1 '':title 'Water, H{_2}O':rotate 60 100 +sphere 0 0 0 0.25 'r':drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2:sphere 0.3 0.5 0 0.25 'g' +drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2:sphere 0.3 -0.5 0 0.25 'g' + +subplot 2 2 2 '':title 'Oxygen, O_2':rotate 60 120 +drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2:sphere 0 0.5 0 0.25 'r' +drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2:sphere 0 -0.5 0 0.25 'r' + +subplot 2 2 3 '':title 'Ammonia, NH_3':rotate 60 120 +sphere 0 0 0 0.25 'b':drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2 +sphere 0.33 0.57 0 0.25 'g':drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2 +sphere 0.33 -0.57 0 0.25 'g':drop 0 0 0 -0.65 0 0 0.32 'n' 1 2 +sphere -0.65 0 0 0.25 'g' +@end verbatim + +@pfig{molecule, Example of molecules drawing.} + +Moreover, some of special plots can be more easily produced by primitives rather than by specialized function. For example, Venn diagram can be produced by @code{Error} plot: +@verbatim +list x -0.3 0 0.3:list y 0.3 -0.3 0.3:list e 0.7 0.7 0.7 +title 'Venn-like diagram':alpha on +error x y e e '!rgb@#o' +@end verbatim +You see that you have to specify and fill 3 data arrays. The same picture can be produced by just 3 calls of @ref{circle} function: +@verbatim +title 'Venn-like diagram':alpha on +circle -0.3 0.3 0.7 'rr@' +circle 0 -0.3 0.7 'gg@' +circle 0.3 0.3 0.7 'bb@' +@end verbatim +Of course, the first variant is more suitable if you need to plot a lot of circles. But for few ones the usage of primitives looks easy. + +@pfig{venn, Example of Venn diagram.} + +@c ------------------------------------------------------------------ +@external{} +@node STFA sample, Mapping visualization, Using primitives, Hints +@subsection STFA sample +@nav{} + +Short-time Fourier Analysis (@ref{stfa}) is one of informative method for analyzing long rapidly oscillating 1D data arrays. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. + +MathGL can find and draw STFA result. Just to show this feature I give following sample. Initial data arrays is 1D arrays with step-like frequency. Exactly this you can see at bottom on the STFA plot. The sample code is: +@verbatim +new a 2000:new b 2000 +fill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\ +cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)' + +subplot 1 2 0 '<_':title 'Initial signal' +plot a:axis:xlabel '\i t' + +subplot 1 2 1 '<_':title 'STFA plot' +stfa a b 64:axis:ylabel '\omega' 0:xlabel '\i t' +@end verbatim + +@pfig{stfa, Example of STFA().} + +@c ------------------------------------------------------------------ +@external{} +@node Mapping visualization, Making regular data, STFA sample, Hints +@subsection Mapping visualization +@nav{} + +Sometime ago I worked with mapping and have a question about its visualization. Let me remember you that mapping is some transformation rule for one set of number to another one. The 1d mapping is just an ordinary function -- it takes a number and transforms it to another one. The 2d mapping (which I used) is a pair of functions which take 2 numbers and transform them to another 2 ones. Except general plots (like @ref{surfc}, @ref{surfa}) there is a special plot -- Arnold diagram. It shows the area which is the result of mapping of some initial area (usually square). + +I tried to make such plot in @ref{map}. It shows the set of points or set of faces, which final position is the result of mapping. At this, the color gives information about their initial position and the height describes Jacobian value of the transformation. Unfortunately, it looks good only for the simplest mapping but for the real multivalent quasi-chaotic mapping it produces a confusion. So, use it if you like :). + +The sample code for mapping visualization is: +@verbatim +new a 50 40 'x':new b 50 40 'y':zrange -2 2:text 0 0 '\to' +subplot 2 1 0:text 0 1.1 '\{x, y\}' '' -2:box +map a b 'brgk' + +subplot 2 1 1:box +text 0 1.1 '\{\frac{x^3+y^3}{2}, \frac{x-y}{2}\}' '' -2 +fill a '(x^3+y^3)/2':fill b '(x-y)/2':map a b 'brgk' +@end verbatim + +@pfig{map, Example of Map().} + +@c ------------------------------------------------------------------ +@external{} +@node Making regular data, Making histogram, Mapping visualization, Hints +@subsection Making regular data +@nav{} + +Sometimes, one have only unregular data, like as data on triangular grids, or experimental results and so on. Such kind of data cannot be used as simple as regular data (like matrices). Only few functions, like @ref{dots}, can handle unregular data as is. + +However, one can use built in triangulation functions for interpolating unregular data points to a regular data grids. There are 2 ways. First way, one can use @ref{triangulation} function to obtain list of vertexes for triangles. Later this list can be used in functions like @ref{triplot} or @ref{tricont}. Second way consist in usage of @ref{datagrid} function, which fill regular data grid by interpolated values, assuming that coordinates of the data grid is equidistantly distributed in axis range. Note, you can use options (see @ref{Command options}) to change default axis range as well as in other plotting functions. +@verbatim +new x 100 '2*rnd-1':new y 100 '2*rnd-1':copy z x^2-y^2 +# first way - plot triangular surface for points +triangulate d x y +title 'Triangulation' +rotate 50 60:box:light on +triplot d x y z:triplot d x y z '#k' +# second way - make regular data and plot it +new g 30 30:datagrid g x y z:mesh g 'm' +@end verbatim + +@pfig{triangulation, Example of triangulation.} + +@c ------------------------------------------------------------------ +@external{} +@node Making histogram, Nonlinear fitting hints, Making regular data, Hints +@subsection Making histogram +@nav{} + +Using the @ref{hist} function(s) for making regular distributions is one of useful fast methods to process and plot irregular data. @code{Hist} can be used to find some momentum of set of points by specifying weight function. It is possible to create not only 1D distributions but also 2D and 3D ones. Below I place the simplest sample code which demonstrate @ref{hist} usage: +@verbatim +new x 10000 '2*rnd-1':new y 10000 '2*rnd-1':copy z exp(-6*(x^2+y^2)) +hist xx x z:norm xx 0 1:hist yy y z:norm yy 0 1 +multiplot 3 3 3 2 2 '':ranges -1 1 -1 1 0 1:box:dots x y z 'wyrRk' +multiplot 3 3 0 2 1 '':ranges -1 1 0 1:box:bars xx +multiplot 3 3 5 1 2 '':ranges 0 1 -1 1:box:barh yy +subplot 3 3 2:text 0.5 0.5 'Hist and\n{}MultiPlot\n{}sample' 'a' -3 +@end verbatim + +@pfig{hist, Example of Hist().} + + +@c ------------------------------------------------------------------ +@external{} +@node Nonlinear fitting hints, PDE solving hints, Making histogram, Hints +@subsection Nonlinear fitting hints +@nav{} + +Nonlinear fitting is rather simple. All that you need is the data to fit, the approximation formula and the list of coefficients to fit (better with its initial guess values). Let me demonstrate it on the following simple example. First, let us use sin function with some random noise: +@verbatim +new rnd 100 '0.4*rnd+0.1+sin(2*pi*x)' +new in 100 '0.3+sin(2*pi*x)' +@end verbatim +and plot it to see that data we will fit +@verbatim +title 'Fitting sample':yrange -2 2:box:axis:plot rnd '. ' +@end verbatim + +The next step is the fitting itself. For that let me specify an initial values @var{ini} for coefficients @samp{abc} and do the fitting for approximation formula @samp{a+b*sin(c*x)} +@verbatim +list ini 1 1 3:fit res rnd 'a+b*sin(c*x)' 'abc' ini +@end verbatim +Now display it +@verbatim +plot res 'r':plot in 'b' +text -0.9 -1.3 'fitted:' 'r:L' +putsfit 0 -1.8 'y = ' 'r' +text 0 2.2 'initial: y = 0.3+sin(2\pi x)' 'b' +@end verbatim + +NOTE! the fitting results may have strong dependence on initial values for coefficients due to algorithm features. The problem is that in general case there are several local "optimums" for coefficients and the program returns only first found one! There are no guaranties that it will be the best. Try for example to set @code{ini[3] = @{0, 0, 0@}} in the code above. + +The full sample code for nonlinear fitting is: +@verbatim +new rnd 100 '0.4*rnd+0.1+sin(2*pi*x)' +new in 100 '0.3+sin(2*pi*x)' +list ini 1 1 3:fit res rnd 'a+b*sin(c*x)' 'abc' ini +title 'Fitting sample':yrange -2 2:box:axis:plot rnd '. ' +plot res 'r':plot in 'b' +text -0.9 -1.3 'fitted:' 'r:L' +putsfit 0 -1.8 'y = ' 'r' +text 0 2.2 'initial: y = 0.3+sin(2\pi x)' 'b' +@end verbatim + +@pfig{fit, Example of nonlinear fitting.} + +@c ------------------------------------------------------------------ +@external{} +@node PDE solving hints, MGL parser using, Nonlinear fitting hints, Hints +@subsection PDE solving hints +@nav{} + +Solving of Partial Differential Equations (PDE, including beam tracing) and ray tracing (or finding particle trajectory) are more or less common task. So, MathGL have several functions for that. There are @code{mglRay()} for ray tracing, @code{mglPDE()} for PDE solving, @code{mglQO2d()} for beam tracing in 2D case (see @ref{Global functions}). Note, that these functions take ``Hamiltonian'' or equations as string values. And I don't plan now to allow one to use user-defined functions. There are 2 reasons: the complexity of corresponding interface; and the basic nature of used methods which are good for samples but may not good for serious scientific calculations. + +The ray tracing can be done by @code{mglRay()} function. Really ray tracing equation is Hamiltonian equation for 3D space. So, the function can be also used for finding a particle trajectory (i.e. solve Hamiltonian ODE) for 1D, 2D or 3D cases. The function have a set of arguments. First of all, it is Hamiltonian which defined the media (or the equation) you are planning to use. The Hamiltonian is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z}, time @samp{t} (for particle dynamics) and momentums @samp{p}=@math{p_x}, @samp{q}=@math{p_y}, @samp{v}=@math{p_z}. Next, you have to define the initial conditions for coordinates and momentums at @samp{t}=0 and set the integrations step (default is 0.1) and its duration (default is 10). The Runge-Kutta method of 4-th order is used for integration. +@verbatim + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + mglData r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); +@end verbatim +This example calculate the reflection from linear layer (media with Hamiltonian @samp{p^2+q^2-x-1}=@math{p_x^2+p_y^2-x-1}). This is parabolic curve. The resulting array have 7 columns which contain data for @{x,y,z,p,q,v,t@}. + +The solution of PDE is a bit more complicated. As previous you have to specify the equation as pseudo-differential operator @math{\hat H(x, \nabla)} which is called sometime as ``Hamiltonian'' (for example, in beam tracing). As previously, it is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z} (but not time!), momentums @samp{p}=@math{(d/dx)/i k_0}, @samp{q}=@math{(d/dy)/i k_0} and field amplitude @samp{u}=@math{|u|}. The evolutionary coordinate is @samp{z} in all cases. So that, the equation look like @math{du/dz = ik_0 H(x,y,\hat p, \hat q, |u|)[u]}. Dependence on field amplitude @samp{u}=@math{|u|} allows one to solve nonlinear problems too. For example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. Also you may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{H = Hre+i*Him}). + +Next step is specifying the initial conditions at @samp{z}=@code{Min.z}. The function need 2 arrays for real and for imaginary part. Note, that coordinates x,y,z are supposed to be in specified range [Min, Max]. So, the data arrays should have corresponding scales. Finally, you may set the integration step and parameter k0=@math{k_0}. Also keep in mind, that internally the 2 times large box is used (for suppressing numerical reflection from boundaries) and the equation should well defined even in this extended range. + +Final comment is concerning the possible form of pseudo-differential operator @math{H}. At this moment, simplified form of operator @math{H} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this operator is effectively @math{H = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed for 3D case. + +So, for example let solve the equation for beam deflected from linear layer and absorbed later. The operator will have the form @samp{"p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)"} that correspond to equation @math{ik_0 \partial_z u + \Delta u + x \cdot u + i (x+z)/2 \cdot u = 0}. This is typical equation for Electron Cyclotron (EC) absorption in magnetized plasmas. For initial conditions let me select the beam with plane phase front @math{exp(-48*(x+0.7)^2)}. The corresponding code looks like this: +@verbatim +new re 128 'exp(-48*(x+0.7)^2)':new im 128 +pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30 +transpose a +subplot 1 1 0 '<_':title 'PDE solver' +axis:xlabel '\i x':ylabel '\i z' +crange 0 1:dens a 'wyrRk' +fplot '-x' 'k|' +text 0 0.95 'Equation: ik_0\partial_zu + \Delta u + x\cdot u +\ + i \frac{x+z}{2}\cdot u = 0\n{}absorption: (x+z)/2 for x+z>0' +@end verbatim + +@pfig{pde, Example of PDE solving.} + +The last example is example of beam tracing. Beam tracing equation is special kind of PDE equation written in coordinates accompanied to a ray. Generally this is the same parameters and limitation as for PDE solving but the coordinates are defined by the ray and by parameter of grid width @var{w} in direction transverse the ray. So, you don't need to specify the range of coordinates. @strong{BUT} there is limitation. The accompanied coordinates are well defined only for smooth enough rays, i.e. then the ray curvature @math{K} (which is defined as @math{1/K^2 = (|\ddot r|^2 |\dot r|^2 - (\ddot r, \dot r)^2)/|\dot r|^6}) is much large then the grid width: @math{K>>w}. So, you may receive incorrect results if this condition will be broken. + +You may use following code for obtaining the same solution as in previous example: +@verbatim +define $1 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)' +subplot 1 1 0 '<_':title 'Beam and ray tracing' +ray r $1 -0.7 -1 0 0 0.5 0 0.02 2:plot r(0) r(1) 'k' +axis:xlabel '\i x':ylabel '\i z' +new re 128 'exp(-48*x^2)':new im 128 +new xx 1:new yy 1 +qo2d a $1 re im r 1 30 xx yy +crange 0 1:dens xx yy a 'wyrRk':fplot '-x' 'k|' +text 0 0.85 'absorption: (x+y)/2 for x+y>0' +text 0.7 -0.05 'central ray' +@end verbatim + +@pfig{qo2d, Example of beam tracing.} + + +@c ------------------------------------------------------------------ +@external{} +@node MGL parser using, Using options, PDE solving hints, Hints +@subsection MGL parser using +@nav{} + +MGL scripts can contain loops, conditions and user-defined functions. Below I show very simple example of its usage: +@verbatim +title 'MGL parser sample' +call 'sample' +stop + +func 'sample' +new dat 100 'sin(2*pi*(x+1))' +plot dat; xrange 0 1 +box:axis:xlabel 'x':ylabel 'y' +for $0 -1 1 0.1 +if $0<0 +line 0 0 -1 $0 'r' +else +line 0 0 -1 $0 'r' +endif +next +@end verbatim + +@pfig{parser, Example of MGL script parsing.} + +@c ------------------------------------------------------------------ +@external{} +@node Using options, ``Templates'', MGL parser using, Hints +@subsection Using options +@nav{} + +@ref{Command options} allow the easy setup of the selected plot by changing global settings only for this plot. Often, options are used for specifying the range of automatic variables (coordinates). However, options allows easily change plot transparency, numbers of line or faces to be drawn, or add legend entries. The sample function for options usage is: +@verbatim +new a 31 41 '-pi*x*exp(-(y+1)^2-4*x^2)' +alpha on:light on +subplot 2 2 0:title 'Options for coordinates':rotate 40 60:box +surf a 'r';yrange 0 1 +surf a 'b';yrange 0 -1 + +subplot 2 2 1:title 'Option "meshnum"':rotate 40 60:box +mesh a 'r'; yrange 0 1 +mesh a 'b';yrange 0 -1; meshnum 5 + +subplot 2 2 2:title 'Option "alpha"':rotate 40 60:box +surf a 'r';yrange 0 1; alpha 0.7 +surf a 'b';yrange 0 -1; alpha 0.3 + +subplot 2 2 3 '<_':title 'Option "legend"' +fplot 'x^3' 'r'; legend 'y = x^3' +fplot 'cos(pi*x)' 'b'; legend 'y = cos \pi x' +box:axis:legend 2 +@end verbatim + +@pfig{mirror, Example of options usage.} + +@c ------------------------------------------------------------------ +@external{} +@node ``Templates'', Nonlinear fitting hints, Using options, Hints +@subsection ``Templates'' +@nav{} + +As I have noted before, the change of settings will influence only for the further plotting commands. This allows one to create ``template'' function which will contain settings and primitive drawing for often used plots. Correspondingly one may call this template-function for drawing simplification. + +For example, let one has a set of points (experimental or numerical) and wants to compare it with theoretical law (for example, with exponent law @math{\exp(-x/2), x \in [0, 20]}). The template-function for this task is: +@verbatim +void template(mglGraph *gr) +{ + mglData law(100); // create the law + law.Modify("exp(-10*x)"); + gr->SetRanges(0,20, 0.0001,1); + gr->SetFunc(0,"lg(y)",0); + gr->Plot(law,"r2"); + gr->Puts(mglPoint(10,0.2),"Theoretical law: e^x","r:L"); + gr->Label('x',"x val."); gr->Label('y',"y val."); + gr->Axis(); gr->Grid("xy","g;"); gr->Box(); +} +@end verbatim +At this, one will only write a few lines for data drawing: +@verbatim + template(gr); // apply settings and default drawing from template + mglData dat("fname.dat"); // load the data + // and draw it (suppose that data file have 2 columns) + gr->Plot(dat.SubData(0),dat.SubData(1),"bx "); +@end verbatim +A template-function can also contain settings for font, transparency, lightning, color scheme and so on. + +I understand that this is obvious thing for any professional programmer, but I several times receive suggestion about ``templates'' ... So, I decide to point out it here. + +@c ------------------------------------------------------------------ +@external{} +@node Stereo image, Reduce memory usage, ``Templates'', Hints +@subsection Stereo image +@nav{} + +One can easily create stereo image in MathGL. Stereo image can be produced by making two subplots with slightly different rotation angles. The corresponding code looks like this: +@verbatim +call 'prepare2d' +light on +subplot 2 1 0:rotate 50 60+1:box:surf a +subplot 2 1 1:rotate 50 60-1:box:surf a +@end verbatim + +@pfig{stereo, Example of stereo image.} + +@c ------------------------------------------------------------------ +@external{} +@node Reduce memory usage, , Stereo image, Hints +@subsection Reduce memory usage +@nav{} + +By default MathGL save all primitives in memory, rearrange it and only later draw them on bitmaps. Usually, this speed up drawing, but may require a lot of memory for plots which contain a lot of faces (like @ref{cloud}, @ref{dew}). You can use @ref{quality} function for setting to use direct drawing on bitmap and bypassing keeping any primitives in memory. This function also allow you to decrease the quality of the resulting image but increase the speed of the drawing. + +The code for lower memory usage looks like this: +@verbatim +quality 6 # firstly, set to draw directly on bitmap +for $1 0 1000 + sphere 2*rnd-1 2*rnd-1 0.05 +next +@end verbatim + +@c ================================================================== + +@external{} +@node FAQ, , Hints, Examples +@section FAQ +@nav{} + +@table @strong +@item The plot does not appear +Check that points of the plot are located inside the bounding box and resize the bounding box using @ref{ranges} function. Check that the data have correct dimensions for selected type of plot. Sometimes the light reflection from flat surfaces (like, @ref{dens}) can look as if the plot were absent. + +@item I can not find some special kind of plot. +Most ``new'' types of plots can be created by using the existing drawing functions. For example, the surface of curve rotation can be created by a special function @ref{torus}, or as a parametrically specified surface by @ref{surf}. See also, @ref{Hints}. If you can not find a specific type of plot, please e-mail me and this plot will appear in the next version of MathGL library. + +@item How can I print in Russian/Spanish/Arabic/Japanese, and so on? +The standard way is to use Unicode encoding for the text output. But the MathGL library also has interface for 8-bit (char *) strings with internal conversion to Unicode. This conversion depends on the current locale OS. + +@item How can I exclude a point or a region of plot from the drawing? +There are 3 general ways. First, the point with @code{nan} value as one of the coordinates (including color/alpha range) will never be plotted. Second, special functions define the condition when the points should be omitted (see @ref{Cutting}). Last, you may change the transparency of a part of the plot by the help of functions @ref{surfa}, @ref{surf3a} (see @ref{Dual plotting}). In last case the transparency is switched on smoothly. + +@item How many people write this library? +Most of the library was written by one person. This is a result of nearly a year of work (mostly in the evening and on holidays): I spent half a year to write the kernel and half a year to a year on extending, improving the library and writing documentation. This process continues now :). The build system (cmake files) was written mostly by D.Kulagin, and the export to PRC/PDF was written mostly by M.Vidassov. + +@item How can I display a bitmap on the figure? +You can import data by command @ref{import} and display it by @ref{dens} function. For example, for black-and-white bitmap you can use the code: @code{import bmp 'fname.png' 'wk':dens bmp 'wk'}. + + +@item How can I create 3D in PDF? +Just use command @code{write fname.pdf}, which create PDF file if enable-pdf=ON at MathGL configure. + +@item How can I create TeX figure? +Just use command @code{write fname.tex}, which create LaTeX files with figure itself @samp{@var{fname}.tex}, with MathGL colors @samp{mglcolors.tex} and main file @samp{mglmain.tex}. Last one can be used for viewing image by command like @code{pdflatex mglmain.tex}. + + +@item How I can change the font family? +First, you should download new font files from @uref{http://mathgl.sourceforge.net/download.html, here} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. Next, you should load the font files into by the following command: @code{loadfont 'fontname'}. Here @var{fontname} is the base font name like @samp{STIX}. Use @code{loadfont ''} to start using the default font. + +@item How can I draw tick out of a bounding box? +Just set a negative value in @ref{ticklen}. For example, use @code{ticklen -0.1}. + +@item How can I prevent text rotation? +Just use @code{rotatetext off}. Also you can use axis style @samp{U} for disable only tick labels rotation. + +@item How can I draw equal axis range even for rectangular image? +Just use @code{aspect nan nan} for each subplot, or at the beginning of the drawing. + +@end table + +@external{} diff --git a/texinfo/ex_mgl_ru.texi b/texinfo/ex_mgl_ru.texi new file mode 100644 index 0000000..c97475d --- /dev/null +++ b/texinfo/ex_mgl_ru.texi @@ -0,0 +1,2834 @@ +@c ------------------------------------------------------------------ +@chapter MathGL examples +@nav{} + +This chapter contain information about basic and advanced MathGL, hints and samples for all types of graphics. I recommend you read first 2 sections one after another and at least look on @ref{Hints} section. Also I recommend you to look at @ref{General concepts} and @ref{FAQ}. + +Most of sample scripts placed below use a set of functions for preparing the data. +@verbatim +func 'prepare1d' +new y 50 3 +modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' +modify y 'sin(2*pi*x)' 1 +modify y 'cos(2*pi*x)' 2 +new x1 50 'x' +new x2 50 '0.05-0.03*cos(pi*x)' +new y1 50 '0.5-0.3*cos(pi*x)' +new y2 50 '-0.3*sin(pi*x)' +return + +func 'prepare2d' +new a 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +new b 50 40 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +return + +func 'prepare3d' +new c 61 50 40 '-2*(x^2+y^2+z^4-z^2)+0.2' +new d 61 50 40 '1-2*tanh((x+y)*(x+y))' +return + +func 'prepare2v' +new a 20 30 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +new b 20 30 '0.6*cos(pi*(x+1))*cos(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +return + +func 'prepare3v' +define $1 pow(x*x+y*y+(z-0.3)*(z-0.3)+0.03,1.5) +define $2 pow(x*x+y*y+(z+0.3)*(z+0.3)+0.03,1.5) +new ex 10 10 10 '0.2*x/$1-0.2*x/$2' +new ey 10 10 10 '0.2*y/$1-0.2*y/$2' +new ez 10 10 10 '0.2*(z-0.3)/$1-0.2*(z+0.3)/$2' +return +@end verbatim +Basically, you can put this text after the script. Note, that you need to terminate main script by @ref{stop} command before defining a function. + +@menu +* Basic usage:: +* Advanced usage:: +* Data handling:: +* Data plotting:: +* 1D samples:: +* 2D samples:: +* 3D samples:: +* Vector field samples:: +* Hints:: +* FAQ:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Basic usage, Advanced usage, , Examples +@section Basic usage +@nav{} + +MGL script can be used by several manners. Each has positive and negative sides: +@itemize @bullet +@item +@emph{Using UDAV.} + +Positive sides are possibilities to view the plot at once and to modify it, rotate, zoom or switch on transparency or lighting by hands or by mouse. Negative side is the needness of the X-terminal. @c For more details, see @ref{UDAV}. + +@item +@emph{Using command line tools.} + +Positive aspects are: batch processing of similar data set, for example, a set of resulting data files for different calculation parameters), running from the console program, including the cluster calculation), fast and automated drawing, saving pictures for further analysis, or demonstration). Negative sides are: the usage of the external program for picture viewing. Also, the data plotting is non-visual. So, you have to imagine the picture, view angles, lighting and so on) before the plotting. I recommend to use graphical window for determining the optimal parameters of plotting on the base of some typical data set. And later use these parameters for batch processing in console program. + +In this case you can use the program: @code{mglconv} or @code{mglview} for viewing. + +@item +@emph{Using C/C++/... code.} + +You can easily execute MGL script within C/C++/Fortan code. This can be useful for fast data plotting, for example, in web applications, where textual string (MGL script) may contain all necessary information for plot. The basic C++ code may look as following +@verbatim +const char *mgl_script; // script itself, can be of type const wchar_t* +mglGraph gr; +mglParse pr; +pr.Execute(&gr, mgl_script); +@end verbatim +@end itemize + +The simplest script is +@verbatim +box # draw bounding box +axis # draw axis +fplot 'x^3' # draw some function +@end verbatim + +Just type it in UDAV and press F5. Also you can save it in text file @samp{test.mgl} and type in the console @code{mglconv test.mgl} what produce file @samp{test.mgl.png} with resulting picture. + +@c ------------------------------------------------------------------ +@external{} +@node Advanced usage, Data handling, Basic usage, Examples +@section Advanced usage +@nav{} + +Now I show several non-obvious features of MGL: several subplots in a single picture, curvilinear coordinates, text printing and so on. Generally you may miss this section at first reading, but I don't recommend it. + +@menu +* Subplots:: +* Axis and ticks:: +* Curvilinear coordinates:: +* Colorbars:: +* Bounding box:: +* Ternary axis:: +* Text features:: +* Legend sample:: +* Cutting sample:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Subplots, Axis and ticks, , Advanced usage +@subsection Subplots +@nav{} + +Let me demonstrate possibilities of plot positioning and rotation. MathGL has a set of functions: @ref{subplot}, @ref{inplot}, @ref{title}, @ref{aspect} and @ref{rotate} and so on (see @ref{Subplots and rotation}). The order of their calling is strictly determined. First, one changes the position of plot in image area (functions @ref{subplot}, @ref{inplot} and @ref{multiplot}). Secondly, you can add the title of plot by @ref{title} function. After that one may rotate the plot (command @ref{rotate}). Finally, one may change aspects of axes (command @ref{aspect}). The following code illustrates the aforesaid it: +@verbatim +subplot 2 2 0 +box:text -1 1.1 'Just box' ':L' +inplot 0.2 0.5 0.7 off +box:text 0 1.2 'InPlot example' + +subplot 2 2 1:title 'Rotate only' +rotate 50 60:box + +subplot 2 2 2:title 'Rotate and Aspect' +rotate 50 60:aspect 1 1 2:box + +subplot 2 2 3:title 'Aspect in other direction' +rotate 50 60:aspect 1 2 2:box +@end verbatim +Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. + +Note that several commands can be placed in a string if they are separated by @samp{:} symbol. + +@pfig{aspect, Example of several subplots on the single picture.} + +More complicated sample show how to use most of positioning functions: +@verbatim +subplot 3 2 0:title 'StickPlot' +stickplot 3 0 20 30:box 'r':text 0 0 '0' 'r' +stickplot 3 1 20 30:box 'g':text 0 0 '1' 'g' +stickplot 3 2 20 30:box 'b':text 0 0 '2' 'b' + +subplot 3 2 3 '':title 'ColumnPlot' +columnplot 3 0:box 'r':text 0 0 '0' 'r' +columnplot 3 1:box 'g':text 0 0 '1' 'g' +columnplot 3 2:box 'b':text 0 0 '2' 'b' + +subplot 3 2 4 '':title 'GridPlot' +gridplot 2 2 0:box 'r':text 0 0 '0' 'r' +gridplot 2 2 1:box 'g':text 0 0 '1' 'g' +gridplot 2 2 2:box 'b':text 0 0 '2' 'b' +gridplot 2 2 3:box 'm':text 0 0 '3' 'm' + +subplot 3 2 5 '':title 'InPlot':box +inplot 0.4 1 0.6 1 on:box 'r' + +multiplot 3 2 1 2 1 '':title 'MultiPlot':box +@end verbatim + +@pfig{inplot, Example for most of positioning functions.} + +@c ------------------------------------------------------------------ +@external{} +@node Axis and ticks, Curvilinear coordinates, Subplots, Advanced usage +@subsection Axis and ticks +@nav{} + +MathGL library can draw not only the bounding box but also the axes, grids, labels and so on. The ranges of axes and their origin (the point of intersection) are determined by functions @code{SetRange()}, @code{SetRanges()}, @code{SetOrigin()} (see @ref{Ranges (bounding box)}). Ticks on axis are specified by function @code{SetTicks}, @code{SetTicksVal}, @code{SetTicksTime} (see @ref{Ticks}). But usually + +Command @ref{axis} draws axes. Its textual string shows in which directions the axis or axes will be drawn (by default @code{"xyz"}, function draws axes in all directions). Command @ref{grid} draws grid perpendicularly to specified directions. Example of axes and grid drawing is: +@verbatim +subplot 2 2 0:title 'Axis origin, Grid' +origin 0 0:axis:grid:fplot 'x^3' + +subplot 2 2 1:title '2 axis' +ranges -1 1 -1 1:origin -1 -1:axis +ylabel 'axis_1':fplot 'sin(pi*x)' 'r2' +ranges 0 1 0 1:origin 1 1:axis +ylabel 'axis_2':fplot 'cos(pi*x)' + +subplot 2 2 3:title 'More axis' +origin nan nan:xrange -1 1:axis +xlabel 'x' 0:ylabel 'y_1' 0:fplot 'x^2' 'k' +yrange -1 1:origin -1.3 -1:axis 'y' 'r' +ylabel '#r{y_2}' 0.2:fplot 'x^3' 'r' + +subplot 2 2 2:title '4 segments, inverted axis':origin 0 0: +inplot 0.5 1 0.5 1 on:ranges 0 10 0 2:axis +fplot 'sqrt(x/2)':xlabel 'W' 1:ylabel 'U' 1 +inplot 0 0.5 0.5 1 on:ranges 1 0 0 2:axis 'x' +fplot 'sqrt(x)+x^3':xlabel '\tau' 1 +inplot 0.5 1 0 0.5 on:ranges 0 10 4 0:axis 'y' +fplot 'x/4':ylabel 'L' -1 +inplot 0 0.5 0 0.5 on:ranges 1 0 4 0:fplot '4*x^2' +@end verbatim + +Note, that MathGL can draw not only single axis (which is default). But also several axis on the plot (see right plots). The idea is that the change of settings does not influence on the already drawn graphics. So, for 2-axes I setup the first axis and draw everything concerning it. Then I setup the second axis and draw things for the second axis. Generally, the similar idea allows one to draw rather complicated plot of 4 axis with different ranges (see bottom left plot). + +At this inverted axis can be created by 2 methods. First one is used in this sample -- just specify minimal axis value to be large than maximal one. This method work well for 2D axis, but can wrongly place labels in 3D case. Second method is more general and work in 3D case too -- just use @ref{aspect} function with negative arguments. For example, following code will produce exactly the same result for 2D case, but 2nd variant will look better in 3D. +@verbatim +# variant 1 +ranges 0 10 4 0:axis + +# variant 2 +ranges 0 10 0 4:aspect 1 -1:axis +@end verbatim + +@pfig{axis, Example of axis.} + +Another MathGL feature is fine ticks tunning. By default (if it is not changed by @code{SetTicks} function), MathGL try to adjust ticks positioning, so that they looks most human readable. At this, MathGL try to extract common factor for too large or too small axis ranges, as well as for too narrow ranges. Last one is non-common notation and can be disabled by @code{SetTuneTicks} function. + +Also, one can specify its own ticks with arbitrary labels by help of @code{SetTicksVal} function. Or one can set ticks in time format. In last case MathGL will try to select optimal format for labels with automatic switching between years, months/days, hours/minutes/seconds or microseconds. However, you can specify its own time representation using formats described in @url{http://www.manpagez.com/man/3/strftime/}. Most common variants are @samp{%X} for national representation of time, @samp{%x} for national representation of date, @samp{%Y} for year with century. + +The sample code, demonstrated ticks feature is +@verbatim +subplot 3 2 0:title 'Usual axis' +axis + +subplot 3 2 1:title 'Too big/small range' +ranges -1000 1000 0 0.001:axis + +subplot 3 2 3:title 'Too narrow range' +ranges 100 100.1 10 10.01:axis + +subplot 3 2 4:title 'Disable ticks tuning' +tuneticks off:axis + +subplot 3 2 2:title 'Manual ticks' +ranges -pi pi 0 2 +xtick -pi '\pi' -pi/2 '-\pi/2' 0 '0' 0.886 'x^*' pi/2 '\pi/2' pi 'pi' +# or you can use: +#list v -pi -pi/2 0 0.886 pi/2 pi:xtick v '-\pi\n-\pi/2\n{}0\n{}x^*\n\pi/2\n\pi' +axis:grid:fplot '2*cos(x^2)^2' 'r2' + +subplot 3 2 5:title 'Time ticks' +xrange 0 3e5:ticktime 'x':axis +@end verbatim + +@pfig{ticks, Features of axis ticks.} + +The last sample I want to show in this subsection is Log-axis. From MathGL's point of view, the log-axis is particular case of general curvilinear coordinates. So, we need first define new coordinates (see also @ref{Curvilinear coordinates}) by help of @code{SetFunc} or @code{SetCoor} functions. At this one should wary about proper axis range. So the code looks as following: +@verbatim +subplot 2 2 0 '<_':title 'Semi-log axis' +ranges 0.01 100 -1 1:axis 'lg(x)' '' '' +axis:grid 'xy' 'g':fplot 'sin(1/x)' +xlabel 'x' 0:ylabel 'y = sin 1/x' 0 + +subplot 2 2 1 '<_':title 'Log-log axis' +ranges 0.01 100 0.1 100:axis 'lg(x)' 'lg(y)' '' +axis:fplot 'sqrt(1+x^2)' +xlabel 'x' 0:ylabel 'y = \sqrt{1+x^2}' 0 + +subplot 2 2 2 '<_':title 'Minus-log axis' +ranges -100 -0.01 -100 -0.1:axis '-lg(-x)' '-lg(-y)' '' +axis:fplot '-sqrt(1+x^2)' +xlabel 'x' 0:ylabel 'y = -\sqrt{1+x^2}' 0 + +subplot 2 2 3 '<_':title 'Log-ticks' +ranges 0.01 100 0 100:axis 'sqrt(x)' '' '' +axis:fplot 'x' +xlabel 'x' 1:ylabel 'y = x' 0 +@end verbatim + +@pfig{loglog, Features of axis ticks.} + +You can see that MathGL automatically switch to log-ticks as we define log-axis formula (in difference from v.1.*). Moreover, it switch to log-ticks for any formula if axis range will be large enough (see right bottom plot). Another interesting feature is that you not necessary define usual log-axis (i.e. when coordinates are positive), but you can define ``minus-log'' axis when coordinate is negative (see left bottom plot). + +@c ------------------------------------------------------------------ +@external{} +@node Curvilinear coordinates, Colorbars, Axis and ticks, Advanced usage +@subsection Curvilinear coordinates +@nav{} + +As I noted in previous subsection, MathGL support curvilinear coordinates. In difference from other plotting programs and libraries, MathGL uses textual formulas for connection of the old (data) and new (output) coordinates. This allows one to plot in arbitrary coordinates. The following code plots the line @var{y}=0, @var{z}=0 in Cartesian, polar, parabolic and spiral coordinates: +@verbatim +origin -1 1 -1 +subplot 2 2 0:title 'Cartesian':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis 'y*sin(pi*x)' 'y*cos(pi*x)' '': +subplot 2 2 1:title 'Cylindrical':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis '2*y*x' 'y*y - x*x' '' +subplot 2 2 2:title 'Parabolic':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid + +axis 'y*sin(pi*x)' 'y*cos(pi*x)' 'x+z' +subplot 2 2 3:title 'Spiral':rotate 50 60 +fplot '2*t-1' '0.5' '0' '2r':axis:grid +@end verbatim + +@pfig{curvcoor, Example of curvilinear coordinates} + + +@c ------------------------------------------------------------------ +@external{} +@node Colorbars, Bounding box, Curvilinear coordinates, Advanced usage +@subsection Colorbars +@nav{} + +MathGL handle @ref{colorbar} as special kind of axis. So, most of functions for axis and ticks setup will work for colorbar too. Colorbars can be in log-scale, and generally as arbitrary function scale; common factor of colorbar labels can be separated; and so on. + +But of course, there are differences -- colorbars usually located out of bounding box. At this, colorbars can be at subplot boundaries (by default), or at bounding box (if symbol @samp{I} is specified). Colorbars can handle sharp colors. And they can be located at arbitrary position too. The sample code, which demonstrate colorbar features is: +@verbatim +call 'prepare2d' +new v 9 'x' + +subplot 2 2 0:title 'Colorbar out of box':box +colorbar '<':colorbar '>':colorbar '_':colorbar '^' + +subplot 2 2 1:title 'Colorbar near box':box +colorbar 'I':colorbar '_I':colorbar '^I' + +subplot 2 2 2:title 'manual colors':box:contd v a +colorbar v '<':colorbar v '>':colorbar v '_':colorbar v '^' + +subplot 2 2 3:title '':text -0.5 1.55 'Color positions' ':C' -2 + +colorbar 'bwr>' 0.25 0:text -0.9 1.2 'Default' +colorbar 'b{w,0.3}r>' 0.5 0:text -0.1 1.2 'Manual' + +crange 0.01 1e3 +colorbar '>' 0.75 0:text 0.65 1.2 'Normal scale' +colorbar '>':text 1.35 1.2 'Log scale' +@end verbatim + +@pfig{colorbar, Example of colorbars} + + +@c ------------------------------------------------------------------ +@external{} +@node Bounding box, Ternary axis, Colorbars, Advanced usage +@subsection Bounding box +@nav{} + +Box around the plot is rather useful thing because it allows one to: see the plot boundaries, and better estimate points position since box contain another set of ticks. MathGL provide special function for drawing such box -- @ref{box} function. By default, it draw black or white box with ticks (color depend on transparency type, see @ref{Types of transparency}). However, you can change the color of box, or add drawing of rectangles at rear faces of box. Also you can disable ticks drawing, but I don't know why anybody will want it. The sample code, which demonstrate @ref{box} features is: +@verbatim +subplot 2 2 0:title 'Box (default)':rotate 50 60:box + +subplot 2 2 1:title 'colored':rotate 50 60:box 'r' + +subplot 2 2 2:title 'with faces':rotate 50 60:box '@' + +subplot 2 2 3:title 'both':rotate 50 60:box '@cm' +@end verbatim + +@pfig{box, Example of Box()} + + +@c ------------------------------------------------------------------ +@external{} +@node Ternary axis, Text features, Bounding box, Advanced usage +@subsection Ternary axis +@nav{} + +There are another unusual axis types which are supported by MathGL. These are ternary and quaternary axis. Ternary axis is special axis of 3 coordinates @var{a}, @var{b}, @var{c} which satisfy relation @var{a}+@var{b}+@var{c}=1. Correspondingly, quaternary axis is special axis of 4 coordinates @var{a}, @var{b}, @var{c}, @var{d} which satisfy relation @var{a}+@var{b}+@var{c}+@var{d}=1. + +Generally speaking, only 2 of coordinates (3 for quaternary) are independent. So, MathGL just introduce some special transformation formulas which treat @var{a} as @samp{x}, @var{b} as @samp{y} (and @var{c} as @samp{z} for quaternary). As result, all plotting functions (curves, surfaces, contours and so on) work as usual, but in new axis. You should use @ref{ternary} function for switching to ternary/quaternary coordinates. The sample code is: +@verbatim +ranges 0 1 0 1 0 1 +new x 50 '0.25*(1+cos(2*pi*x))' +new y 50 '0.25*(1+sin(2*pi*x))' +new z 50 'x' +new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' +new rx 10 'rnd':copy ry (1-rx)*rnd +light on + +subplot 2 2 0:title 'Ordinary axis 3D':rotate 50 60 +box:axis:grid +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':zlabel 'Z' + +subplot 2 2 1:title 'Ternary axis (x+y+t=1)':ternary 1 +box:axis:grid 'xyz' 'B;' +plot x y 'r2':plot rx ry 'q^ ':cont a:line 0.5 0 0 0.75 'g2' +xlabel 'B':ylabel 'C':tlabel 'A' + +subplot 2 2 2:title 'Quaternary axis 3D':rotate 50 60:ternary 2 +box:axis:grid 'xyz' 'B;' +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':tlabel 'A':zlabel 'D' + +subplot 2 2 3:title 'Ternary axis 3D':rotate 50 60:ternary 1 +box:axis:grid 'xyz' 'B;' +plot x y z 'r2':surf a '#' +xlabel 'B':ylabel 'C':tlabel 'A':zlabel 'Z' +@end verbatim + +@pfig{ternary, Ternary and Quaternary axis} + +@c ------------------------------------------------------------------ +@external{} +@node Text features, Legend sample, Ternary axis, Advanced usage +@subsection Text features +@nav{} + +MathGL prints text by vector font. There are functions for manual specifying of text position (like @code{Puts}) and for its automatic selection (like @code{Label}, @code{Legend} and so on). MathGL prints text always in specified position even if it lies outside the bounding box. The default size of font is specified by functions @var{SetFontSize*} (see @ref{Font settings}). However, the actual size of output string depends on subplot size (depends on functions @code{SubPlot}, @code{InPlot}). The switching of the font style (italic, bold, wire and so on) can be done for the whole string (by function parameter) or inside the string. By default MathGL parses TeX-like commands for symbols and indexes (see @ref{Font styles}). + +Text can be printed as usual one (from left to right), along some direction (rotated text), or along a curve. Text can be printed on several lines, divided by new line symbol @samp{\n}. + +Example of MathGL font drawing is: +@verbatim +call 'prepare1d' + +subplot 2 2 0 '' +text 0 1 'Text can be in ASCII and in Unicode' +text 0 0.6 'It can be \wire{wire}, \big{big} or #r{colored}' +text 0 0.2 'One can change style in string: \b{bold}, \i{italic, \b{both}}' +text 0 -0.2 'Easy to \a{overline} or \u{underline}' +text 0 -0.6 'Easy to change indexes ^{up} _{down} @{center}' +text 0 -1 'It parse TeX: \int \alpha \cdot \ +\sqrt3{sin(\pi x)^2 + \gamma_{i_k}} dx' + +subplot 2 2 1 '' + text 0 0.5 '\sqrt{\frac{\alpha^{\gamma^2}+\overset 1{\big\infty}}{\sqrt3{2+b}}}' '@' -2 +text 0 -0.5 'Text can be printed\n{}on several lines' + +subplot 2 2 2 '':box:plot y(:,0) +text y 'This is very very long string drawn along a curve' 'k' +text y 'Another string drawn above a curve' 'Tr' + +subplot 2 2 3 '':line -1 -1 1 -1 'rA':text 0 -1 1 -1 'Horizontal' +line -1 -1 1 1 'rA':text 0 0 1 1 'At angle' '@' +line -1 -1 -1 1 'rA':text -1 0 -1 1 'Vertical' +@end verbatim + +@pfig{text, Example of text printing} + +You can change font faces by loading font files by function @ref{loadfont}. Note, that this is long-run procedure. Font faces can be downloaded from @uref{http://mathgl.sourceforge.net/download.html, MathGL website} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. The sample code is: +@verbatim +define d 0.25 +loadfont 'STIX':text 0 1.1 'default font (STIX)' +loadfont 'adventor':text 0 1.1-d 'adventor font' +loadfont 'bonum':text 0 1.1-2*d 'bonum font' +loadfont 'chorus':text 0 1.1-3*d 'chorus font' +loadfont 'cursor':text 0 1.1-4*d 'cursor font' +loadfont 'heros':text 0 1.1-5*d 'heros font' +loadfont 'heroscn':text 0 1.1-6*d 'heroscn font' +loadfont 'pagella':text 0 1.1-7*d 'pagella font' +loadfont 'schola':text 0 1.1-8*d 'schola font' +loadfont 'termes':text 0 1.1-9*d 'termes font' +@end verbatim + +@pfig{fonts, Example of font faces} + +@c ------------------------------------------------------------------ +@external{} +@node Legend sample, Cutting sample, Text features, Advanced usage +@subsection Legend sample +@nav{} + +Legend is one of standard ways to show plot annotations. Basically you need to connect the plot style (line style, marker and color) with some text. In MathGL, you can do it by 2 methods: manually using @ref{addlegend} function; or use @samp{legend} option (see @ref{Command options}), which will use last plot style. In both cases, legend entries will be added into internal accumulator, which later used for legend drawing itself. @ref{clearlegend} function allow you to remove all saved legend entries. + +There are 2 features. If plot style is empty then text will be printed without indent. If you want to plot the text with indent but without plot sample then you need to use space @samp{ } as plot style. Such style @samp{ } will draw a plot sample (line with marker(s)) which is invisible line (i.e. nothing) and print the text with indent as usual one. + +Command @ref{legend} draw legend on the plot. The position of the legend can be selected automatic or manually. You can change the size and style of text labels, as well as setup the plot sample. The sample code demonstrating legend features is: +@verbatim +addlegend 'sin(\pi {x^2})' 'b' +addlegend 'sin(\pi x)' 'g*' +addlegend 'sin(\pi \sqrt{x})' 'rd' +addlegend 'jsut text' ' ' +addlegend 'no indent for this' '' + +subplot 2 2 0 '':title 'Legend (default)':box +legend + +text 0.75 0.65 'Absolute position' 'A' +legend 3 'A#' + +subplot 2 2 2 '':title 'coloring':box +legend 0 'r#':legend 1 'Wb#':legend 2 'ygr#' + +subplot 2 2 3 '':title 'manual position':box +legend 0.5 1:text 0.5 0.55 'at x=0.5, y=1' 'a' +legend 1 '#-':text 0.75 0.25 'Horizontal legend' 'a' +@end verbatim + +@pfig{legend, Example of legend} + +@c ------------------------------------------------------------------ +@external{} +@node Cutting sample, , Legend sample, Advanced usage +@subsection Cutting sample +@nav{} + +The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that. +@itemize @bullet +@item +You can set one of coordinate to NAN value. All points with NAN values will be omitted. + +@item +You can enable cutting at edges by @code{SetCut} function. As result all points out of bounding box will be omitted. + +@item +You can set cutting box by @code{SetCutBox} function. All points inside this box will be omitted. + +@item +You can define cutting formula by @code{SetCutOff} function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant. +@end itemize + +Below I place the code which demonstrate last 3 possibilities: +@verbatim +call 'prepare2d' +call 'prepare3d' + +subplot 2 2 0:title 'Cut on (default)':rotate 50 60 +light on:box:surf a; zrange -1 0.5 + +subplot 2 2 1:title 'Cut off':rotate 50 60 +box:surf a; zrange -1 0.5; cut off + +subplot 2 2 2:title 'Cut in box':rotate 50 60:box:alpha on +cut 0 -1 -1 1 0 1.1:surf3 c +cut 0 0 0 0 0 0 # restore back + +subplot 2 2 3:title 'Cut by formula':rotate 50 60:box +cut '(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)':surf3 c +@end verbatim + +@pfig{cut, Example of point cutting} + + + +@c ------------------------------------------------------------------ +@external{} +@node Data handling, Data plotting, Advanced usage, Examples +@section Data handling +@nav{} + +Class @code{mglData} contains all functions for the data handling in MathGL (@pxref{Data processing}). There are several matters why I use class @code{mglData} but not a single array: it does not depend on type of data (mreal or double), sizes of data arrays are kept with data, memory working is simpler and safer. + +@menu +* Array creation:: +* Change data:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Array creation, Change data, , Data handling +@subsection Array creation +@nav{} + +One can put numbers into the data instance by several ways. Let us do it for square function: +@itemize @bullet +@item +one can create array by @code{list} command +@verbatim +list a 0 0.04 0.16 0.36 0.64 1 +@end verbatim + +@item +another way is to copy from ``inline'' array +@verbatim +copy a [0,0.04,0.16,0.36,0.64,1] +@end verbatim + +@item +next way is to fill the data by textual formula with the help of @code{modify} function +@verbatim +new a 6 +modify a 'x^2' +@end verbatim + +@item +or one may fill the array in some interval and modify it later +@verbatim +new a 6 +fill a 0 1 +modify a 'u^2' +@end verbatim + +@item +or fill the array using current axis range +@verbatim +new a 6 +fill a '(x+1)^2/4' +@end verbatim +or use single line +@verbatim +new a 6 '(x+1)^2/4' +@end verbatim + +@item +finally it can be loaded from file +@verbatim +new s 6 '(x+1)^2/4' +save s 'sqr.dat' # create file first +read a 'sqr.dat' # load it +@end verbatim + +@item +at this one can read only part of data +@verbatim +new s 6 '(x+1)^2/4' +save s 'sqr.dat' # create file first +read a 'sqr.dat' 5 # load it +@end verbatim +@end itemize + +Creation of 2d- and 3d-arrays is mostly the same. One can use direct data filling by @code{list} command +@verbatim +list a 11 12 13 | 21 22 23 | 31 32 33 +@end verbatim +or by inline arrays +@verbatim +copy a [[11,12,13],[21,22,23],[31,32,33]] +@end verbatim +Also data can be filled by formula +@verbatim +new z 30 40 'sin(pi*x)*cos(pi*y)' +@end verbatim +or loaded from a file. + +@c ------------------------------------------------------------------ +@external{} +@node Change data, , Array creation, Data handling +@subsection Change data +@nav{} + +MathGL has functions for data processing: differentiating, integrating, smoothing and so on (for more detail, see @ref{Data processing}). Let us consider some examples. The simplest ones are integration and differentiation. The direction in which operation will be performed is specified by textual string, which may contain symbols @samp{x}, @samp{y} or @samp{z}. For example, the call of @code{diff 'x'} will differentiate data along @samp{x} direction; the call of @code{integrate 'xy'} perform the double integration of data along @samp{x} and @samp{y} directions; the call of @code{diff2 'xyz'} will apply 3d Laplace operator to data and so on. Example of this operations on 2d array a=x*y is presented in code: +@verbatim +ranges 0 1 0 1 0 1:new a 30 40 'x*y' +subplot 2 2 0:title 'a(x,y)':rotate 60 40 +surf a:box + +subplot 2 2 1:title 'da/dx':rotate 60 40 +diff a 'x':surf a:box + +subplot 2 2 2:title '\int da/dx dxdy':rotate 60 40 +integrate a 'xy':surf a:box + +subplot 2 2 3:title '\int {d^2}a/dxdy dx':rotate 60 40 +diff2 a 'y':surf a:box +@end verbatim + +@pfig{dat_diff, Example of data differentiation and integration} + +Data smoothing (command @ref{smooth}) is more interesting and important. This function has single argument which define type of smoothing and its direction. Now 3 methods are supported: @samp{3} -- linear averaging by 3 points, @samp{5} -- linear averaging by 5 points, and default one -- quadratic averaging by 5 points. + +MathGL also have some amazing functions which is not so important for data processing as useful for data plotting. There are functions for finding envelope (useful for plotting rapidly oscillating data), for data sewing (useful to removing jumps on the phase), for data resizing (interpolation). Let me demonstrate it: +@verbatim +subplot 2 2 0 '':title 'Envelop sample' +new d1 1000 'exp(-8*x^2)*sin(10*pi*x)' +axis:plot d1 'b' +envelop d1 'x' +plot d1 'r' + +subplot 2 2 1 '':title 'Smooth sample':ranges 0 1 0 1 +new y0 30 '0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd' +copy y1 y0:smooth y1 'x3':plot y1 'r';legend '"3" style' +copy y2 y0:smooth y2 'x5':plot y2 'g';legend '"5" style' +copy y3 y0:smooth y3 'x':plot y3 'b';legend 'default' +plot y0 '{m7}:s';legend 'none':legend:box + +subplot 2 2 2:title 'Sew sample':rotate 50 60:light on:alpha on +new d2 100 100 'mod((y^2-(1-x)^2)/2,0.1)' +box:surf d2 'b' +sew d2 'xy' 0.1 +surf d2 'r' + +subplot 2 2 3:title 'Resize sample (interpolation)' +new x0 10 'rnd':new v0 10 'rnd' +resize x1 x0 100:resize v1 v0 100 +plot x0 v0 'b+ ':plot x1 v1 'r-':label x0 v0 '%n' +@end verbatim + +@pfig{dat_extra, Example of data smoothing} + +Finally one can create new data arrays on base of the existing one: extract slice, row or column of data (@ref{subdata}), summarize along a direction(s) (@ref{sum}), find distribution of data elements (@ref{hist}) and so on. + +@anchor{Solve sample} +Another interesting feature of MathGL is interpolation and root-finding. There are several functions for linear and cubic spline interpolation (see @ref{Interpolation}). Also there is a function @ref{evaluate} which do interpolation of data array for values of each data element of index data. It look as indirect access to the data elements. + +This function have inverse function @ref{solve} which find array of indexes at which data array is equal to given value (i.e. work as root finding). But @ref{solve} function have the issue -- usually multidimensional data (2d and 3d ones) have an infinite number of indexes which give some value. This is contour lines for 2d data, or isosurface(s) for 3d data. So, @ref{solve} function will return index only in given direction, assuming that other index(es) are the same as equidistant index(es) of original data. Let me demonstrate this on the following sample. + +@verbatim +zrange 0 1 +new x 20 30 '(x+2)/3*cos(pi*y)' +new y 20 30 '(x+2)/3*sin(pi*y)' +new z 20 30 'exp(-6*x^2-2*sin(pi*y)^2)' + +subplot 2 1 0:title 'Cartesian space':rotate 30 -40 +axis 'xyzU':box +xlabel 'x':ylabel 'y'origin 1 1:grid 'xy' +mesh x y z + +# section along 'x' direction +solve u x 0.5 'x' +var v u.nx 0 1 +evaluate yy y u v +evaluate xx x u v +evaluate zz z u v +plot xx yy zz 'k2o' + +# 1st section along 'y' direction +solve u1 x -0.5 'y' +var v1 u1.nx 0 1 +evaluate yy y v1 u1 +evaluate xx x v1 u1 +evaluate zz z v1 u1 +plot xx yy zz 'b2^' + +# 2nd section along 'y' direction +solve u2 x -0.5 'y' u1 +evaluate yy y v1 u2 +evaluate xx x v1 u2 +evaluate zz z v1 u2 +plot xx yy zz 'r2v' + +subplot 2 1 1:title 'Accompanied space' +ranges 0 1 0 1:origin 0 0 +axis:box:xlabel 'i':ylabel 'j':grid2 z 'h' + +plot u v 'k2o':line 0.4 0.5 0.8 0.5 'kA' +plot v1 u1 'b2^':line 0.5 0.15 0.5 0.3 'bA' +plot v1 u2 'r2v':line 0.5 0.7 0.5 0.85 'rA' +@end verbatim + +@pfig{solve, Example of data interpolation and root finding} + +@c ------------------------------------------------------------------ +@external{} +@node Data plotting, 1D samples, Data handling, Examples +@section Data plotting +@nav{} + +Let me now show how to plot the data. Next section will give much more examples for all plotting functions. Here I just show some basics. MathGL generally has 2 types of plotting functions. Simple variant requires a single data array for plotting, other data (coordinates) are considered uniformly distributed in axis range. Second variant requires data arrays for all coordinates. It allows one to plot rather complex multivalent curves and surfaces (in case of parametric dependencies). Usually each function have one textual argument for plot style and accept options (see @ref{Command options}). + +Note, that the call of drawing function adds something to picture but does not clear the previous plots (as it does in Matlab). Another difference from Matlab is that all setup (like transparency, lightning, axis borders and so on) must be specified @strong{before} plotting functions. + +Let start for plots for 1D data. Term ``1D data'' means that data depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. The textual argument allow you specify styles of line and marks (see @ref{Line styles}). If this parameter is empty @code{''} then solid line with color from palette is used (see @ref{Palette and colors}). + +Below I shall show the features of 1D plotting on base of @ref{plot} function. Let us start from sinus plot: +@verbatim +new y0 50 'sin(pi*x)' +subplot 2 2 0 +plot y0:box +@end verbatim +Style of line is not specified in @ref{plot} function. So MathGL uses the solid line with first color of palette (this is blue). Next subplot shows array @var{y1} with 2 rows: +@verbatim +subplot 2 2 1 +new y1 50 2 +fill y1 'cos(pi*(x+y/4))*2/(y+3)' +plot y1:box +@end verbatim +As previously I did not specify the style of lines. As a result, MathGL again uses solid line with next colors in palette (there are green and red). Now let us plot a circle on the same subplot. The circle is parametric curve @math{x=cos(\pi t), y=sin(\pi t)}. I will set the color of the circle (dark yellow, @samp{Y}) and put marks @samp{+} at point position: +@verbatim +new x 50 'cos(pi*x)' +plot x y0 'Y+' +@end verbatim +Note that solid line is used because I did not specify the type of line. The same picture can be achieved by @ref{plot} and @ref{subdata} functions. Let us draw ellipse by orange dash line: +@verbatim +plot y1(:,0) y1(:,1) 'q|' +@end verbatim + +Drawing in 3D space is mostly the same. Let us draw spiral with default line style. Now its color is 4-th color from palette (this is cyan): +@verbatim +subplot 2 2 2:rotate 60 40 +new z 50 'x' +plot x y0 z:box +@end verbatim +Functions @ref{plot} and @ref{subdata} make 3D curve plot but for single array. Use it to put circle marks on the previous plot: +@verbatim +new y2 10 3 'cos(pi*(x+y/2))' +modify y2 '2*x-1' 2 +plot y2(:,0) y2(:,1) y2(:,2) 'bo ' +@end verbatim +Note that line style is empty @samp{ } here. Usage of other 1D plotting functions looks similar: +@verbatim +subplot 2 2 3:rotate 60 40 +bars x y0 z 'r':box +@end verbatim + +Surfaces @ref{surf} and other 2D plots (@pxref{2D plotting}) are drown the same simpler as 1D one. The difference is that the string parameter specifies not the line style but the color scheme of the plot (see @ref{Color scheme}). Here I draw attention on 4 most interesting color schemes. There is gray scheme where color is changed from black to white (string @samp{kw}) or from white to black (string @samp{wk}). Another scheme is useful for accentuation of negative (by blue color) and positive (by red color) regions on plot (string @samp{"BbwrR"}). Last one is the popular ``jet'' scheme (string @samp{"BbcyrR"}). + +Now I shall show the example of a surface drawing. At first let us switch lightning on +@verbatim +light on +@end verbatim +and draw the surface, considering coordinates x,y to be uniformly distributed in interval @var{Min}*@var{Max} +@verbatim +new a0 50 40 '0.6*sin(pi*(x+1))*sin(1.5*pi*(y+1))+0.4*cos(0.75*pi*(x+1)*(y+1))' +subplot 2 2 0:rotate 60 40 +surf a0:box +@end verbatim +Color scheme was not specified. So previous color scheme is used. In this case it is default color scheme (``jet'') for the first plot. Next example is a sphere. The sphere is parametrically specified surface: +@verbatim +new x 50 40 '0.8*sin(pi*x)*cos(pi*y/2)' +new y 50 40 '0.8*cos(pi*x)*cos(pi*y/2)' +new z 50 40 '0.8*sin(pi*y/2)' +subplot 2 2 1:rotate 60 40 +surf x y z 'BbwrR':box +@end verbatim +I set color scheme to @code{"BbwrR"} that corresponds to red top and blue bottom of the sphere. + +Surfaces will be plotted for each of slice of the data if @var{nz}>1. Next example draws surfaces for data arrays with @var{nz}=3: +@verbatim +new a1 50 40 3 +modify a1 '0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))' +modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*sin(3*pi*(x*y))' 1 +modify a1 '0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))' 2 +subplot 2 2 2:rotate 60 40 +alpha on +surf a1:box +@end verbatim +Note, that it may entail a confusion. However, if one will use density plot then the picture will look better: +@verbatim +subplot 2 2 3:rotate 60 40 +dens a1:box +@end verbatim + +Drawing of other 2D plots is analogous. The only peculiarity is the usage of flag @samp{#}. By default this flag switches on the drawing of a grid on plot (@ref{grid} or @ref{mesh} for plots in plain or in volume). However, for isosurfaces (including surfaces of rotation @ref{axial}) this flag switches the face drawing off and figure becomes wired. +@c ------------------------------------------------------------------ +@external{} +@node 1D samples, 2D samples, Data plotting, Examples +@section 1D samples +@nav{} + +This section is devoted to visualization of 1D data arrays. 1D means the data which depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +func 'prepare1d' +new y 50 3 +modify y '0.7*sin(2*pi*x)+0.5*cos(3*pi*x)+0.2*sin(pi*x)' +modify y 'sin(2*pi*x)' 1 +modify y 'cos(2*pi*x)' 2 +new x1 50 'x' +new x2 50 '0.05-0.03*cos(pi*x)' +new y1 50 '0.5-0.3*cos(pi*x)' +new y2 50 '-0.3*sin(pi*x)' +return +@end verbatim +Basically, you can put this text after the script. Note, that you need to terminate main script by @ref{stop} command before defining a function. + +@menu +* Plot sample:: +* Radar sample:: +* Step sample:: +* Tens sample:: +* Area sample:: +* Region sample:: +* Stem sample:: +* Bars sample:: +* Barh sample:: +* Cones sample:: +* Chart sample:: +* BoxPlot sample:: +* Candle sample:: +* OHLC sample:: +* Error sample:: +* Mark sample:: +* TextMark sample:: +* Label sample:: +* Table sample:: +* Tube sample:: +* Tape sample:: +* Torus sample:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node Plot sample, Radar sample, , 1D samples +@subsection Plot sample +@nav{} + +Command @ref{plot} is most standard way to visualize 1D data array. By default, @code{Plot} use colors from palette. However, you can specify manual color/palette, and even set to use new color for each points by using @samp{!} style. Another feature is @samp{ } style which draw only markers without line between points. The sample code is: +@verbatim +call 'prepare1d' +subplot 2 2 0 '':title 'Plot plot (default)':box +plot y + +subplot 2 2 2 '':title ''!' style; 'rgb' palette':box +plot y 'o!rgb' + +subplot 2 2 3 '':title 'just markers':box +plot y ' +' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +plot xc yc z 'rs' +@end verbatim + +@pfig{plot, Example of Plot()} + + +@c ------------------------------------------------------------------ +@external{} +@node Radar sample, Step sample, Plot sample, 1D samples +@subsection Radar sample +@nav{} + +Command @ref{radar} plot is variant of @code{Plot} one, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use @ref{Curvilinear coordinates} or @code{Plot} in parabolic form with @code{x=r*cos(fi); y=r*sin(fi);}. The sample code is: +@verbatim +new yr 10 3 '0.4*sin(pi*(x+1.5+y/2)+0.1*rnd)' +subplot 1 1 0 '':title 'Radar plot (with grid, "\#")' +radar yr '#' +@end verbatim + +@pfig{radar, Example of Radar()} + +@c ------------------------------------------------------------------ +@external{} +@node Step sample, Tens sample, Radar sample, 1D samples +@subsection Step sample +@nav{} + +Command @ref{step} plot data as stairs. It have the same options as @code{Plot}. The sample code is: +@verbatim +call 'prepare1d' +origin 0 0 0:subplot 2 2 0 '':title 'Step plot (default)':box +step y + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +step xc yc z 'r' + +subplot 2 2 2 '':title '"!" style':box +step y 's!rgb' +@end verbatim + +@pfig{step, Example of Step()} + +@c ------------------------------------------------------------------ +@external{} +@node Tens sample, Area sample, Step sample, 1D samples +@subsection Tens sample +@nav{} + +Command @ref{tens} is variant of @ref{plot} with smooth coloring along the curves. At this, color is determined as for surfaces (see @ref{Color scheme}). The sample code is: +@verbatim +call 'prepare1d' +subplot 2 2 0 '':title 'Tens plot (default)':box +tens y(:,0) y(:,1) + +subplot 2 2 2 '':title ' style':box +tens y(:,0) y(:,1) 'o ' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 1:title '3d variant':rotate 50 60:box +tens xc yc z z 's' +@end verbatim + +@pfig{tens, Example of Tens()} + +@c ------------------------------------------------------------------ +@external{} +@node Area sample, Region sample, Tens sample, 1D samples +@subsection Area sample +@nav{} + +Command @ref{area} fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified. The sample code is: +@verbatim +call 'prepare1d' +origin 0 0 0 +subplot 2 2 0 '':title 'Area plot (default)':box +area y + +subplot 2 2 1 '':title '2 colors':box +area y 'cbgGyr' + +subplot 2 2 2 '':title '"!" style':box +area y '!' + +new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x' +subplot 2 2 3:title '3d variant':rotate 50 60:box +area xc yc z 'r':area xc -yc z 'b#' +@end verbatim + +@pfig{area, Example of Area()} + +@c ------------------------------------------------------------------ +@external{} +@node Region sample, Stem sample, Area sample, 1D samples +@subsection Region sample +@nav{} + +Command @ref{region} fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1" style':box +vect a b '>' + +subplot 3 2 4 '':title '"<" style':box +vect a b '<' + +call 'prepare3v' +subplot 3 2 5:title '3d variant':rotate 50 60:box +vect ex ey ez +@end verbatim + +@pfig{vect, Example of Vect()} + +@c ------------------------------------------------------------------ +@external{} +@node Vect3 sample, Traj sample, Vect sample, Vector field samples +@subsection Vect3 sample +@nav{} + +Command @ref{vect3} draw just usual vector field plot but at slices of 3D data. The sample code is: +@verbatim +origin 0 0 0:call 'prepare3v' +subplot 2 1 0:title 'Vect3 sample':rotate 50 60 +box:axis '_xyz' +vect3 ex ey ez 'x':vect3 ex ey ez:vect3 ex ey ez 'z' + +subplot 2 1 1:title '"f" style':rotate 50 60 +box:axis '_xyz' +vect3 ex ey ez 'fx':vect3 ex ey ez 'f':vect3 ex ey ez 'fz' +grid3 ex 'Wx':grid3 ex 'W':grid3 ex 'Wz' +@end verbatim + +@pfig{vecta, Example of Vect3()} + +@c ------------------------------------------------------------------ +@external{} +@node Traj sample, Flow sample, Vect3 sample, Vector field samples +@subsection Traj sample +@nav{} + +Command @ref{traj} is 1D analogue of @code{Vect}. It draw vectors from specified points. The sample code is: +@verbatim +call 'prepare1d' +subplot 1 1 0 '':title 'Traj plot':box +plot x1 y:traj x1 y y1 y2 +@end verbatim + +@pfig{traj, Example of Traj()} + + +@c ------------------------------------------------------------------ +@external{} +@node Flow sample, Pipe sample, Traj sample, Vector field samples +@subsection Flow sample +@nav{} + +Command @ref{flow} is another standard way to visualize vector fields -- it draw lines (threads) which is tangent to local vector field direction. MathGL draw threads from edges of bounding box and from central slices. Sometimes it is not most appropriate variant -- you may want to use @code{FlowP} to specify manual position of threads. @code{Flow} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +call 'prepare2v' +subplot 2 2 0 '':title 'Flow plot (default)':box +flow a b + +subplot 2 2 1 '':title '"v" style':box +flow a b 'v' + +subplot 2 2 2 '':title 'from edges only':box +flow a b '#' + +call 'prepare3v' +subplot 2 2 3:title '3d variant':rotate 50 60:box +flow ex ey ez +@end verbatim + +@pfig{flow, Example of Flow()} + +@c ------------------------------------------------------------------ +@external{} +@node Pipe sample, Dew sample, Flow sample, Vector field samples +@subsection Pipe sample +@nav{} + +Command @ref{pipe} is similar to @ref{flow} but draw pipes (tubes) which radius is proportional to the amplitude of vector field. @code{Pipe} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +call 'prepare2v' +subplot 2 2 0 '':title 'Pipe plot (default)':light on:box +pipe a b + +subplot 2 2 1 '':title '"i" style':box +pipe a b 'i' + +subplot 2 2 2 '':title 'from edges only':box +pipe a b '#' + +call 'prepare3v' +subplot 2 2 3:title '3d variant':rotate 50 60:box +pipe ex ey ez '' 0.1 +@end verbatim + +@pfig{pipe, Example of Pipe()} + +@c ------------------------------------------------------------------ +@external{} +@node Dew sample, , Pipe sample, Vector field samples +@subsection Dew sample +@nav{} + +Command @ref{dew} is similar to @code{Vect} but use drops instead of arrows. The sample code is: +@verbatim +call 'prepare2v' +subplot 1 1 0 '':title 'Dew plot':light on:box +dew a b +@end verbatim + +@pfig{dew, Example of Dew()} + + +@c ------------------------------------------------------------------ +@external{} +@node Hints, FAQ, Vector field samples, Examples +@section Hints +@nav{} + +In this section I've included some small hints and advices for the improving of the quality of plots and for the demonstration of some non-trivial features of MathGL library. In contrast to previous examples I showed mostly the idea but not the whole drawing function. + +@menu +* ``Compound'' graphics:: +* Transparency and lighting:: +* Types of transparency:: +* Axis projection:: +* Adding fog:: +* Lighting sample:: +* Using primitives:: +* STFA sample:: +* Mapping visualization:: +* Making regular data:: +* Making histogram:: +* Nonlinear fitting hints:: +* PDE solving hints:: +* MGL parser using:: +* Using options:: +* ``Templates'':: +* Stereo image:: +* Reduce memory usage:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node ``Compound'' graphics, Transparency and lighting, , Hints +@subsection ``Compound'' graphics +@nav{} + +As I noted above, MathGL functions (except the special one, like Clf()) do not erase the previous plotting but just add the new one. It allows one to draw ``compound'' plots easily. For example, popular Matlab command @code{surfc} can be emulated in MathGL by 2 calls: +@verbatim + Surf(a); + Cont(a, "_"); // draw contours at bottom +@end verbatim +Here @var{a} is 2-dimensional data for the plotting, @code{-1} is the value of z-coordinate at which the contour should be plotted (at the bottom in this example). Analogously, one can draw density plot instead of contour lines and so on. + +Another nice plot is contour lines plotted directly on the surface: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "BbcyrR"); // select 'jet' colormap for the surface + Cont(a, "y"); // and yellow color for contours +@end verbatim +The possible difficulties arise in black&white case, when the color of the surface can be close to the color of a contour line. In that case I may suggest the following code: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "kw"); // select 'gray' colormap for the surface + CAxis(-1,0); // first draw for darker surface colors + Cont(a, "w"); // white contours + CAxis(0,1); // now draw for brighter surface colors + Cont(a, "k"); // black contours + CAxis(-1,1); // return color range to original state +@end verbatim +The idea is to divide the color range on 2 parts (dark and bright) and to select the contrasting color for contour lines for each of part. + +Similarly, one can plot flow thread over density plot of vector field amplitude (this is another amusing plot from Matlab) and so on. The list of compound graphics can be prolonged but I hope that the general idea is clear. + +Just for illustration I put here following sample code: +@verbatim +call 'prepare2v' +call 'prepare3d' +new v 10:fill v -0.5 1:copy d sqrt(a^2+b^2) +subplot 2 2 0:title 'Surf + Cont':rotate 50 60:light on:box +surf a:cont a 'y' + +subplot 2 2 1 '':title 'Flow + Dens':light off:box +flow a b 'br':dens d + +subplot 2 2 2:title 'Mesh + Cont':rotate 50 60:box +mesh a:cont a '_' + +subplot 2 2 3:title 'Surf3 + ContF3':rotate 50 60:light on +box:contf3 v c 'z' 0:contf3 v c 'x':contf3 v c +cut 0 -1 -1 1 0 1.1 +contf3 v c 'z' c.nz-1:surf3 c -0.5 +@end verbatim + +@pfig{combined, Example of ``combined'' plots} + +@c ------------------------------------------------------------------ +@external{} +@node Transparency and lighting, Types of transparency, ``Compound'' graphics, Hints +@subsection Transparency and lighting +@nav{} + +Here I want to show how transparency and lighting both and separately change the look of a surface. So, there is code and picture for that: +@verbatim +call 'prepare2d' +subplot 2 2 0:title 'default':rotate 50 60:box +surf a + +subplot 2 2 1:title 'light on':rotate 50 60:box +light on:surf a + +subplot 2 2 3:title 'light on; alpha on':rotate 50 60:box +alpha on:surf a + +subplot 2 2 2:title 'alpha on':rotate 50 60:box +light off:surf a +@end verbatim + +@pfig{alpha, Example of transparency and lightings} + +@c ------------------------------------------------------------------ +@external{} +@node Types of transparency, Axis projection, Transparency and lighting, Hints +@subsection Types of transparency +@nav{} + +MathGL library has advanced features for setting and handling the surface transparency. The simplest way to add transparency is the using of command @ref{alpha}. As a result, all further surfaces (and isosurfaces, density plots and so on) become transparent. However, their look can be additionally improved. + +The value of transparency can be different from surface to surface. To do it just use @code{SetAlphaDef} before the drawing of the surface, or use option @code{alpha} (see @ref{Command options}). If its value is close to 0 then the surface becomes more and more transparent. Contrary, if its value is close to 1 then the surface becomes practically non-transparent. + +Also you can change the way how the light goes through overlapped surfaces. The function @code{SetTranspType} defines it. By default the usual transparency is used (@samp{0}) -- surfaces below is less visible than the upper ones. A ``glass-like'' transparency (@samp{1}) has a different look -- each surface just decreases the background light (the surfaces are commutable in this case). + +A ``neon-like'' transparency (@samp{2}) has more interesting look. In this case a surface is the light source (like a lamp on the dark background) and just adds some intensity to the color. At this, the library sets automatically the black color for the background and changes the default line color to white. + +As example I shall show several plots for different types of transparency. The code is the same except the values of @code{SetTranspType} function: +@verbatim +call 'prepare2d' +alpha on:light on +transptype 0:clf +subplot 2 2 0:rotate 50 60:surf a:box +subplot 2 2 1:rotate 50 60:dens a:box +subplot 2 2 2:rotate 50 60:cont a:box +subplot 2 2 3:rotate 50 60:axial a:box +@end verbatim + +@pfig{type0, Example of @code{SetTranspType(0)}.} +@pfig{type1, Example of @code{SetTranspType(1)}.} +@pfig{type2, Example of @code{SetTranspType(2)}.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis projection, Adding fog, Ternary axis, Hints +@subsection Axis projection +@nav{} + +You can easily make 3D plot and draw its x-,y-,z-projections (like in CAD) by using @ref{ternary} function with arguments: 4 for Cartesian, 5 for Ternary and 6 for Quaternary coordinates. The sample code is: +@verbatim +ranges 0 1 0 1 0 1 +new x 50 '0.25*(1+cos(2*pi*x))' +new y 50 '0.25*(1+sin(2*pi*x))' +new z 50 'x' +new a 20 30 '30*x*y*(1-x-y)^2*(x+y<1)' +new rx 10 'rnd':new ry 10:fill ry '(1-v)*rnd' rx +light on + +title 'Projection sample':ternary 4:rotate 50 60 +box:axis:grid +plot x y z 'r2':surf a '#' +xlabel 'X':ylabel 'Y':zlabel 'Z' +@end verbatim + +@pfig{projection, Example of axis projections} + +@c ------------------------------------------------------------------ +@external{} +@node Adding fog, Lighting sample, Axis projection, Hints +@subsection Adding fog +@nav{} + +MathGL can add a fog to the image. Its switching on is rather simple -- just use @ref{fog} function. There is the only feature -- fog is applied for whole image. Not to particular subplot. The sample code is: +@verbatim +call 'prepare2d' +title 'Fog sample':rotate 50 60:light on +fog 1 +box:surf a +@end verbatim + +@pfig{fog, Example of @code{Fog()}.} + +@c ------------------------------------------------------------------ +@external{} +@node Lighting sample, Using primitives, Adding fog, Hints +@subsection Lighting sample +@nav{} + +In contrast to the most of other programs, MathGL supports several (up to 10) light sources. Moreover, the color each of them can be different: white (this is usual), yellow, red, cyan, green and so on. The use of several light sources may be interesting for the highlighting of some peculiarities of the plot or just to make an amusing picture. Note, each light source can be switched on/off individually. The sample code is: +@verbatim +call 'prepare2d' +title 'Several light sources':rotate 50 60:light on +light 1 0 1 0 'c':light 2 1 0 0 'y':light 3 0 -1 0 'm' +box:surf a 'h' +@end verbatim + +@pfig{several_light, Example of several light sources.} + +Additionally, you can use local light sources and set to use diffise reflection instead of specular one (by default) or both kinds. +@verbatim +# use Quality=6 because need lighting in placed +light on:quality 6 +call 'prepare2d' +subplot 2 2 0:title 'Default':rotate 50 60:box:surf a +line -1 -0.7 1.7 -1 -0.7 0.7 'BA' + +light 0 1 0 1 -2 -1 -1 +subplot 2 2 1:title 'Local':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' + +diffuse 0 +subplot 2 2 2:title 'no diffuse':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' + +diffuse 0.5:light 0 1 0 1 -2 -1 -1 'w' 0 +subplot 2 2 3:title 'diffusive only':rotate 50 60:box:surf a +line 1 0 1 -1 -1 0 'BAO' +@end verbatim + +@pfig{light, Example of different types of lighting.} + +@c ------------------------------------------------------------------ +@external{} +@node Using primitives, STFA sample, Lighting sample, Hints +@subsection Using primitives +@nav{} + +MathGL provide a set of functions for drawing primitives (see @ref{Primitives}). Primitives are low level object, which used by most of plotting functions. Picture below demonstrate some of commonly used primitives. +@verbatim +subplot 2 2 0 '':title 'Line, Curve, Rhomb, Ellipse' '' -1.5 +line -1 -1 -0.5 1 'qAI' +curve -0.6 -1 1 1 0 1 1 1 'rA' +ball 0 -0.5 '*':ball 1 -0.1 '*' +rhomb 0 0.4 1 0.9 0.2 'b#' +rhomb 0 0 1 0.4 0.2 'cg@' +ellipse 0 -0.5 1 -0.1 0.2 'u#' +ellipse 0 -1 1 -0.6 0.2 'm@' + +light on +subplot 2 2 1:title 'Face[xyz]':rotate 50 60:box +facex 1 0 -1 1 1 'r':facey -1 -1 -1 1 1 'g':facez 1 -1 -1 -1 1 'b' +face -1 -1 1 -1 1 1 1 -1 0 1 1 1 'bmgr' + +subplot 2 2 3 '':title 'Cone' +cone -0.7 -0.3 0 -0.7 0.7 0.5 0.2 0.1 'b':text -0.7 -0.7 'no edges\n(default)' +cone 0 -0.3 0 0 0.7 0.5 0.2 0.1 'g@':text 0 -0.7 'with edges\n('\@' style)' +cone 0.7 -0.3 0 0.7 0.7 0.5 0.2 0.1 'ry':text 0.7 -0.7 '"arrow" with\n{}gradient' + +subplot 2 2 2 '':title 'Sphere and Drop' +line -0.9 0 1 0.9 0 1 +text -0.9 -0.7 'sh=0':drop -0.9 0 0 1 0.5 'r' 0:ball -0.9 0 1 'k' +text -0.3 -0.7 'sh=0.33':drop -0.3 0 0 1 0.5 'r' 0.33:ball -0.3 0 1 'k' +text 0.3 -0.7 'sh=0.67':drop 0.3 0 0 1 0.5 'r' 0.67:ball 0.3 0 1 'k' +text 0.9 -0.7 'sh=1':drop 0.9 0 0 1 0.5 'r' 1:ball 0.9 0 1 'k' +@end verbatim + +@pfig{primitives, Primitives in MathGL.} + +Generally, you can create arbitrary new kind of plot using primitives. For example, MathGL don't provide any special functions for drawing molecules. However, you can do it using only one type of primitives @ref{drop}. The sample code is: +@verbatim +alpha on:light on +subplot 2 2 0 '':title 'Methane, CH_4':rotate 60 120 +sphere 0 0 0 0.25 'k':drop 0 0 0 0 0 1 0.35 'h' 1 2:sphere 0 0 0.7 0.25 'g' +drop 0 0 0 -0.94 0 -0.33 0.35 'h' 1 2:sphere -0.66 0 -0.23 0.25 'g' +drop 0 0 0 0.47 0.82 -0.33 0.35 'h' 1 2:sphere 0.33 0.57 -0.23 0.25 'g' +drop 0 0 0 0.47 -0.82 -0.33 0.35 'h' 1 2:sphere 0.33 -0.57 -0.23 0.25 'g' + +subplot 2 2 1 '':title 'Water, H{_2}O':rotate 60 100 +sphere 0 0 0 0.25 'r':drop 0 0 0 0.3 0.5 0 0.3 'm' 1 2:sphere 0.3 0.5 0 0.25 'g' +drop 0 0 0 0.3 -0.5 0 0.3 'm' 1 2:sphere 0.3 -0.5 0 0.25 'g' + +subplot 2 2 2 '':title 'Oxygen, O_2':rotate 60 120 +drop 0 0.5 0 0 -0.3 0 0.3 'm' 1 2:sphere 0 0.5 0 0.25 'r' +drop 0 -0.5 0 0 0.3 0 0.3 'm' 1 2:sphere 0 -0.5 0 0.25 'r' + +subplot 2 2 3 '':title 'Ammonia, NH_3':rotate 60 120 +sphere 0 0 0 0.25 'b':drop 0 0 0 0.33 0.57 0 0.32 'n' 1 2 +sphere 0.33 0.57 0 0.25 'g':drop 0 0 0 0.33 -0.57 0 0.32 'n' 1 2 +sphere 0.33 -0.57 0 0.25 'g':drop 0 0 0 -0.65 0 0 0.32 'n' 1 2 +sphere -0.65 0 0 0.25 'g' +@end verbatim + +@pfig{molecule, Example of molecules drawing.} + +Moreover, some of special plots can be more easily produced by primitives rather than by specialized function. For example, Venn diagram can be produced by @code{Error} plot: +@verbatim +list x -0.3 0 0.3:list y 0.3 -0.3 0.3:list e 0.7 0.7 0.7 +title 'Venn-like diagram':alpha on +error x y e e '!rgb@#o' +@end verbatim +You see that you have to specify and fill 3 data arrays. The same picture can be produced by just 3 calls of @ref{circle} function: +@verbatim +title 'Venn-like diagram':alpha on +circle -0.3 0.3 0.7 'rr@' +circle 0 -0.3 0.7 'gg@' +circle 0.3 0.3 0.7 'bb@' +@end verbatim +Of course, the first variant is more suitable if you need to plot a lot of circles. But for few ones the usage of primitives looks easy. + +@pfig{venn, Example of Venn diagram.} + +@c ------------------------------------------------------------------ +@external{} +@node STFA sample, Mapping visualization, Using primitives, Hints +@subsection STFA sample +@nav{} + +Short-time Fourier Analysis (@ref{stfa}) is one of informative method for analyzing long rapidly oscillating 1D data arrays. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. + +MathGL can find and draw STFA result. Just to show this feature I give following sample. Initial data arrays is 1D arrays with step-like frequency. Exactly this you can see at bottom on the STFA plot. The sample code is: +@verbatim +new a 2000:new b 2000 +fill a 'cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\ +cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)' + +subplot 1 2 0 '<_':title 'Initial signal' +plot a:axis:xlabel '\i t' + +subplot 1 2 1 '<_':title 'STFA plot' +stfa a b 64:axis:ylabel '\omega' 0:xlabel '\i t' +@end verbatim + +@pfig{stfa, Example of STFA().} + +@c ------------------------------------------------------------------ +@external{} +@node Mapping visualization, Making regular data, STFA sample, Hints +@subsection Mapping visualization +@nav{} + +Sometime ago I worked with mapping and have a question about its visualization. Let me remember you that mapping is some transformation rule for one set of number to another one. The 1d mapping is just an ordinary function -- it takes a number and transforms it to another one. The 2d mapping (which I used) is a pair of functions which take 2 numbers and transform them to another 2 ones. Except general plots (like @ref{surfc}, @ref{surfa}) there is a special plot -- Arnold diagram. It shows the area which is the result of mapping of some initial area (usually square). + +I tried to make such plot in @ref{map}. It shows the set of points or set of faces, which final position is the result of mapping. At this, the color gives information about their initial position and the height describes Jacobian value of the transformation. Unfortunately, it looks good only for the simplest mapping but for the real multivalent quasi-chaotic mapping it produces a confusion. So, use it if you like :). + +The sample code for mapping visualization is: +@verbatim +new a 50 40 'x':new b 50 40 'y':zrange -2 2:text 0 0 '\to' +subplot 2 1 0:text 0 1.1 '\{x, y\}' '' -2:box +map a b 'brgk' + +subplot 2 1 1:box +text 0 1.1 '\{\frac{x^3+y^3}{2}, \frac{x-y}{2}\}' '' -2 +fill a '(x^3+y^3)/2':fill b '(x-y)/2':map a b 'brgk' +@end verbatim + +@pfig{map, Example of Map().} + +@c ------------------------------------------------------------------ +@external{} +@node Making regular data, Making histogram, Mapping visualization, Hints +@subsection Making regular data +@nav{} + +Sometimes, one have only unregular data, like as data on triangular grids, or experimental results and so on. Such kind of data cannot be used as simple as regular data (like matrices). Only few functions, like @ref{dots}, can handle unregular data as is. + +However, one can use built in triangulation functions for interpolating unregular data points to a regular data grids. There are 2 ways. First way, one can use @ref{triangulation} function to obtain list of vertexes for triangles. Later this list can be used in functions like @ref{triplot} or @ref{tricont}. Second way consist in usage of @ref{datagrid} function, which fill regular data grid by interpolated values, assuming that coordinates of the data grid is equidistantly distributed in axis range. Note, you can use options (see @ref{Command options}) to change default axis range as well as in other plotting functions. +@verbatim +new x 100 '2*rnd-1':new y 100 '2*rnd-1':copy z x^2-y^2 +# first way - plot triangular surface for points +triangulate d x y +title 'Triangulation' +rotate 50 60:box:light on +triplot d x y z:triplot d x y z '#k' +# second way - make regular data and plot it +new g 30 30:datagrid g x y z:mesh g 'm' +@end verbatim + +@pfig{triangulation, Example of triangulation.} + +@c ------------------------------------------------------------------ +@external{} +@node Making histogram, Nonlinear fitting hints, Making regular data, Hints +@subsection Making histogram +@nav{} + +Using the @ref{hist} function(s) for making regular distributions is one of useful fast methods to process and plot irregular data. @code{Hist} can be used to find some momentum of set of points by specifying weight function. It is possible to create not only 1D distributions but also 2D and 3D ones. Below I place the simplest sample code which demonstrate @ref{hist} usage: +@verbatim +new x 10000 '2*rnd-1':new y 10000 '2*rnd-1':copy z exp(-6*(x^2+y^2)) +hist xx x z:norm xx 0 1:hist yy y z:norm yy 0 1 +multiplot 3 3 3 2 2 '':ranges -1 1 -1 1 0 1:box:dots x y z 'wyrRk' +multiplot 3 3 0 2 1 '':ranges -1 1 0 1:box:bars xx +multiplot 3 3 5 1 2 '':ranges 0 1 -1 1:box:barh yy +subplot 3 3 2:text 0.5 0.5 'Hist and\n{}MultiPlot\n{}sample' 'a' -3 +@end verbatim + +@pfig{hist, Example of Hist().} + + +@c ------------------------------------------------------------------ +@external{} +@node Nonlinear fitting hints, PDE solving hints, Making histogram, Hints +@subsection Nonlinear fitting hints +@nav{} + +Nonlinear fitting is rather simple. All that you need is the data to fit, the approximation formula and the list of coefficients to fit (better with its initial guess values). Let me demonstrate it on the following simple example. First, let us use sin function with some random noise: +@verbatim +new rnd 100 '0.4*rnd+0.1+sin(2*pi*x)' +new in 100 '0.3+sin(2*pi*x)' +@end verbatim +and plot it to see that data we will fit +@verbatim +title 'Fitting sample':yrange -2 2:box:axis:plot rnd '. ' +@end verbatim + +The next step is the fitting itself. For that let me specify an initial values @var{ini} for coefficients @samp{abc} and do the fitting for approximation formula @samp{a+b*sin(c*x)} +@verbatim +list ini 1 1 3:fit res rnd 'a+b*sin(c*x)' 'abc' ini +@end verbatim +Now display it +@verbatim +plot res 'r':plot in 'b' +text -0.9 -1.3 'fitted:' 'r:L' +putsfit 0 -1.8 'y = ' 'r' +text 0 2.2 'initial: y = 0.3+sin(2\pi x)' 'b' +@end verbatim + +NOTE! the fitting results may have strong dependence on initial values for coefficients due to algorithm features. The problem is that in general case there are several local "optimums" for coefficients and the program returns only first found one! There are no guaranties that it will be the best. Try for example to set @code{ini[3] = @{0, 0, 0@}} in the code above. + +The full sample code for nonlinear fitting is: +@verbatim +new rnd 100 '0.4*rnd+0.1+sin(2*pi*x)' +new in 100 '0.3+sin(2*pi*x)' +list ini 1 1 3:fit res rnd 'a+b*sin(c*x)' 'abc' ini +title 'Fitting sample':yrange -2 2:box:axis:plot rnd '. ' +plot res 'r':plot in 'b' +text -0.9 -1.3 'fitted:' 'r:L' +putsfit 0 -1.8 'y = ' 'r' +text 0 2.2 'initial: y = 0.3+sin(2\pi x)' 'b' +@end verbatim + +@pfig{fit, Example of nonlinear fitting.} + +@c ------------------------------------------------------------------ +@external{} +@node PDE solving hints, MGL parser using, Nonlinear fitting hints, Hints +@subsection PDE solving hints +@nav{} + +Solving of Partial Differential Equations (PDE, including beam tracing) and ray tracing (or finding particle trajectory) are more or less common task. So, MathGL have several functions for that. There are @code{mglRay()} for ray tracing, @code{mglPDE()} for PDE solving, @code{mglQO2d()} for beam tracing in 2D case (see @ref{Global functions}). Note, that these functions take ``Hamiltonian'' or equations as string values. And I don't plan now to allow one to use user-defined functions. There are 2 reasons: the complexity of corresponding interface; and the basic nature of used methods which are good for samples but may not good for serious scientific calculations. + +The ray tracing can be done by @code{mglRay()} function. Really ray tracing equation is Hamiltonian equation for 3D space. So, the function can be also used for finding a particle trajectory (i.e. solve Hamiltonian ODE) for 1D, 2D or 3D cases. The function have a set of arguments. First of all, it is Hamiltonian which defined the media (or the equation) you are planning to use. The Hamiltonian is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z}, time @samp{t} (for particle dynamics) and momentums @samp{p}=@math{p_x}, @samp{q}=@math{p_y}, @samp{v}=@math{p_z}. Next, you have to define the initial conditions for coordinates and momentums at @samp{t}=0 and set the integrations step (default is 0.1) and its duration (default is 10). The Runge-Kutta method of 4-th order is used for integration. +@verbatim + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + mglData r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); +@end verbatim +This example calculate the reflection from linear layer (media with Hamiltonian @samp{p^2+q^2-x-1}=@math{p_x^2+p_y^2-x-1}). This is parabolic curve. The resulting array have 7 columns which contain data for @{x,y,z,p,q,v,t@}. + +The solution of PDE is a bit more complicated. As previous you have to specify the equation as pseudo-differential operator @math{\hat H(x, \nabla)} which is called sometime as ``Hamiltonian'' (for example, in beam tracing). As previously, it is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z} (but not time!), momentums @samp{p}=@math{(d/dx)/i k_0}, @samp{q}=@math{(d/dy)/i k_0} and field amplitude @samp{u}=@math{|u|}. The evolutionary coordinate is @samp{z} in all cases. So that, the equation look like @math{du/dz = ik_0 H(x,y,\hat p, \hat q, |u|)[u]}. Dependence on field amplitude @samp{u}=@math{|u|} allows one to solve nonlinear problems too. For example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. Also you may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{H = Hre+i*Him}). + +Next step is specifying the initial conditions at @samp{z}=@code{Min.z}. The function need 2 arrays for real and for imaginary part. Note, that coordinates x,y,z are supposed to be in specified range [Min, Max]. So, the data arrays should have corresponding scales. Finally, you may set the integration step and parameter k0=@math{k_0}. Also keep in mind, that internally the 2 times large box is used (for suppressing numerical reflection from boundaries) and the equation should well defined even in this extended range. + +Final comment is concerning the possible form of pseudo-differential operator @math{H}. At this moment, simplified form of operator @math{H} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this operator is effectively @math{H = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed for 3D case. + +So, for example let solve the equation for beam deflected from linear layer and absorbed later. The operator will have the form @samp{"p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)"} that correspond to equation @math{ik_0 \partial_z u + \Delta u + x \cdot u + i (x+z)/2 \cdot u = 0}. This is typical equation for Electron Cyclotron (EC) absorption in magnetized plasmas. For initial conditions let me select the beam with plane phase front @math{exp(-48*(x+0.7)^2)}. The corresponding code looks like this: +@verbatim +new re 128 'exp(-48*(x+0.7)^2)':new im 128 +pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30 +transpose a +subplot 1 1 0 '<_':title 'PDE solver' +axis:xlabel '\i x':ylabel '\i z' +crange 0 1:dens a 'wyrRk' +fplot '-x' 'k|' +text 0 0.95 'Equation: ik_0\partial_zu + \Delta u + x\cdot u +\ + i \frac{x+z}{2}\cdot u = 0\n{}absorption: (x+z)/2 for x+z>0' +@end verbatim + +@pfig{pde, Example of PDE solving.} + +The last example is example of beam tracing. Beam tracing equation is special kind of PDE equation written in coordinates accompanied to a ray. Generally this is the same parameters and limitation as for PDE solving but the coordinates are defined by the ray and by parameter of grid width @var{w} in direction transverse the ray. So, you don't need to specify the range of coordinates. @strong{BUT} there is limitation. The accompanied coordinates are well defined only for smooth enough rays, i.e. then the ray curvature @math{K} (which is defined as @math{1/K^2 = (|\ddot r|^2 |\dot r|^2 - (\ddot r, \dot r)^2)/|\dot r|^6}) is much large then the grid width: @math{K>>w}. So, you may receive incorrect results if this condition will be broken. + +You may use following code for obtaining the same solution as in previous example: +@verbatim +define $1 'p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)' +subplot 1 1 0 '<_':title 'Beam and ray tracing' +ray r $1 -0.7 -1 0 0 0.5 0 0.02 2:plot r(0) r(1) 'k' +axis:xlabel '\i x':ylabel '\i z' +new re 128 'exp(-48*x^2)':new im 128 +new xx 1:new yy 1 +qo2d a $1 re im r 1 30 xx yy +crange 0 1:dens xx yy a 'wyrRk':fplot '-x' 'k|' +text 0 0.85 'absorption: (x+y)/2 for x+y>0' +text 0.7 -0.05 'central ray' +@end verbatim + +@pfig{qo2d, Example of beam tracing.} + + +@c ------------------------------------------------------------------ +@external{} +@node MGL parser using, Using options, PDE solving hints, Hints +@subsection MGL parser using +@nav{} + +MGL scripts can contain loops, conditions and user-defined functions. Below I show very simple example of its usage: +@verbatim +title 'MGL parser sample' +call 'sample' +stop + +func 'sample' +new dat 100 'sin(2*pi*(x+1))' +plot dat; xrange 0 1 +box:axis:xlabel 'x':ylabel 'y' +for $0 -1 1 0.1 +if $0<0 +line 0 0 -1 $0 'r' +else +line 0 0 -1 $0 'r' +endif +next +@end verbatim + +@pfig{parser, Example of MGL script parsing.} + +@c ------------------------------------------------------------------ +@external{} +@node Using options, ``Templates'', MGL parser using, Hints +@subsection Using options +@nav{} + +@ref{Command options} allow the easy setup of the selected plot by changing global settings only for this plot. Often, options are used for specifying the range of automatic variables (coordinates). However, options allows easily change plot transparency, numbers of line or faces to be drawn, or add legend entries. The sample function for options usage is: +@verbatim +new a 31 41 '-pi*x*exp(-(y+1)^2-4*x^2)' +alpha on:light on +subplot 2 2 0:title 'Options for coordinates':rotate 40 60:box +surf a 'r';yrange 0 1 +surf a 'b';yrange 0 -1 + +subplot 2 2 1:title 'Option "meshnum"':rotate 40 60:box +mesh a 'r'; yrange 0 1 +mesh a 'b';yrange 0 -1; meshnum 5 + +subplot 2 2 2:title 'Option "alpha"':rotate 40 60:box +surf a 'r';yrange 0 1; alpha 0.7 +surf a 'b';yrange 0 -1; alpha 0.3 + +subplot 2 2 3 '<_':title 'Option "legend"' +fplot 'x^3' 'r'; legend 'y = x^3' +fplot 'cos(pi*x)' 'b'; legend 'y = cos \pi x' +box:axis:legend 2 +@end verbatim + +@pfig{mirror, Example of options usage.} + +@c ------------------------------------------------------------------ +@external{} +@node ``Templates'', Nonlinear fitting hints, Using options, Hints +@subsection ``Templates'' +@nav{} + +As I have noted before, the change of settings will influence only for the further plotting commands. This allows one to create ``template'' function which will contain settings and primitive drawing for often used plots. Correspondingly one may call this template-function for drawing simplification. + +For example, let one has a set of points (experimental or numerical) and wants to compare it with theoretical law (for example, with exponent law @math{\exp(-x/2), x \in [0, 20]}). The template-function for this task is: +@verbatim +void template(mglGraph *gr) +{ + mglData law(100); // create the law + law.Modify("exp(-10*x)"); + gr->SetRanges(0,20, 0.0001,1); + gr->SetFunc(0,"lg(y)",0); + gr->Plot(law,"r2"); + gr->Puts(mglPoint(10,0.2),"Theoretical law: e^x","r:L"); + gr->Label('x',"x val."); gr->Label('y',"y val."); + gr->Axis(); gr->Grid("xy","g;"); gr->Box(); +} +@end verbatim +At this, one will only write a few lines for data drawing: +@verbatim + template(gr); // apply settings and default drawing from template + mglData dat("fname.dat"); // load the data + // and draw it (suppose that data file have 2 columns) + gr->Plot(dat.SubData(0),dat.SubData(1),"bx "); +@end verbatim +A template-function can also contain settings for font, transparency, lightning, color scheme and so on. + +I understand that this is obvious thing for any professional programmer, but I several times receive suggestion about ``templates'' ... So, I decide to point out it here. + +@c ------------------------------------------------------------------ +@external{} +@node Stereo image, Reduce memory usage, ``Templates'', Hints +@subsection Stereo image +@nav{} + +One can easily create stereo image in MathGL. Stereo image can be produced by making two subplots with slightly different rotation angles. The corresponding code looks like this: +@verbatim +call 'prepare2d' +light on +subplot 2 1 0:rotate 50 60+1:box:surf a +subplot 2 1 1:rotate 50 60-1:box:surf a +@end verbatim + +@pfig{stereo, Example of stereo image.} + +@c ------------------------------------------------------------------ +@external{} +@node Reduce memory usage, , Stereo image, Hints +@subsection Reduce memory usage +@nav{} + +By default MathGL save all primitives in memory, rearrange it and only later draw them on bitmaps. Usually, this speed up drawing, but may require a lot of memory for plots which contain a lot of faces (like @ref{cloud}, @ref{dew}). You can use @ref{quality} function for setting to use direct drawing on bitmap and bypassing keeping any primitives in memory. This function also allow you to decrease the quality of the resulting image but increase the speed of the drawing. + +The code for lower memory usage looks like this: +@verbatim +quality 6 # firstly, set to draw directly on bitmap +for $1 0 1000 + sphere 2*rnd-1 2*rnd-1 0.05 +next +@end verbatim + +@c ================================================================== + +@external{} +@node FAQ, , Hints, Examples +@section FAQ +@nav{} + +@table @strong +@item The plot does not appear +Check that points of the plot are located inside the bounding box and resize the bounding box using @ref{ranges} function. Check that the data have correct dimensions for selected type of plot. Sometimes the light reflection from flat surfaces (like, @ref{dens}) can look as if the plot were absent. + +@item I can not find some special kind of plot. +Most ``new'' types of plots can be created by using the existing drawing functions. For example, the surface of curve rotation can be created by a special function @ref{torus}, or as a parametrically specified surface by @ref{surf}. See also, @ref{Hints}. If you can not find a specific type of plot, please e-mail me and this plot will appear in the next version of MathGL library. + +@item How can I print in Russian/Spanish/Arabic/Japanese, and so on? +The standard way is to use Unicode encoding for the text output. But the MathGL library also has interface for 8-bit (char *) strings with internal conversion to Unicode. This conversion depends on the current locale OS. + +@item How can I exclude a point or a region of plot from the drawing? +There are 3 general ways. First, the point with @code{nan} value as one of the coordinates (including color/alpha range) will never be plotted. Second, special functions define the condition when the points should be omitted (see @ref{Cutting}). Last, you may change the transparency of a part of the plot by the help of functions @ref{surfa}, @ref{surf3a} (see @ref{Dual plotting}). In last case the transparency is switched on smoothly. + +@item How many people write this library? +Most of the library was written by one person. This is a result of nearly a year of work (mostly in the evening and on holidays): I spent half a year to write the kernel and half a year to a year on extending, improving the library and writing documentation. This process continues now :). The build system (cmake files) was written mostly by D.Kulagin, and the export to PRC/PDF was written mostly by M.Vidassov. + +@item How can I display a bitmap on the figure? +You can import data by command @ref{import} and display it by @ref{dens} function. For example, for black-and-white bitmap you can use the code: @code{import bmp 'fname.png' 'wk':dens bmp 'wk'}. + + +@item How can I create 3D in PDF? +Just use command @code{write fname.pdf}, which create PDF file if enable-pdf=ON at MathGL configure. + +@item How can I create TeX figure? +Just use command @code{write fname.tex}, which create LaTeX files with figure itself @samp{@var{fname}.tex}, with MathGL colors @samp{mglcolors.tex} and main file @samp{mglmain.tex}. Last one can be used for viewing image by command like @code{pdflatex mglmain.tex}. + + +@item How I can change the font family? +First, you should download new font files from @uref{http://mathgl.sourceforge.net/download.html, here} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. Next, you should load the font files into by the following command: @code{loadfont 'fontname'}. Here @var{fontname} is the base font name like @samp{STIX}. Use @code{loadfont ''} to start using the default font. + +@item How can I draw tick out of a bounding box? +Just set a negative value in @ref{ticklen}. For example, use @code{ticklen -0.1}. + +@item How can I prevent text rotation? +Just use @code{rotatetext off}. Also you can use axis style @samp{U} for disable only tick labels rotation. + +@item How can I draw equal axis range even for rectangular image? +Just use @code{aspect nan nan} for each subplot, or at the beginning of the drawing. + +@end table + +@external{} diff --git a/texinfo/example_en.texi b/texinfo/example_en.texi new file mode 100644 index 0000000..a5dca99 --- /dev/null +++ b/texinfo/example_en.texi @@ -0,0 +1,4138 @@ +@c ------------------------------------------------------------------ +@chapter MathGL examples +@nav{} + +This chapter contain information about basic and advanced MathGL, hints and samples for all types of graphics. I recommend you read first 2 sections one after another and at least look on @ref{Hints} section. Also I recommend you to look at @ref{General concepts} and @ref{FAQ}. + +Note, that MathGL v.2.* have only 2 end-user interfaces: one for C/Fortran and similar languages which don't support classes, another one for C++/Python/Octave and similar languages which support classes. So, most of samples placed in this chapter can be run as is (after minor changes due to different syntaxes for different languages). For example, the C++ code +@verbatim +#include +int main() +{ + mglGraph gr; + gr.FPlot("sin(pi*x)"); + gr.WriteFrame("test.png"); +} +@end verbatim +in Python will be as +@verbatim +from mathgl import * +gr = mglGraph(); +gr.FPlot("sin(pi*x)"); +gr.WriteFrame("test.png"); +@end verbatim +in Octave will be as (you need first install MathGL package by command @code{octave:1> pkg install /usr/share/mathgl/octave/mathgl.tar.gz} from @code{sudo octave}) +@verbatim +gr = mglGraph(); +gr.FPlot("sin(pi*x)"); +gr.WriteFrame("test.png"); +@end verbatim +in C will be as +@verbatim +#include +int main() +{ + HMGL gr = mgl_create_graph(600,400); + mgl_fplot(gr,"sin(pi*x)","",""); + mgl_write_frame(gr,"test.png",""); + mgl_delete_graph(gr); +} +@end verbatim +in Fortran will be as +@verbatim +integer gr, mgl_create_graph +gr = mgl_create_graph(600,400); +call mgl_fplot(gr,'sin(pi*x)','',''); +call mgl_write_frame(gr,'test.png',''); +call mgl_delete_graph(gr); +@end verbatim +and so on. + + + +@menu +* Basic usage:: +* Advanced usage:: +* Data handling:: +* Data plotting:: +* 1D samples:: +* 2D samples:: +* 3D samples:: +* Vector field samples:: +* Hints:: +* FAQ:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Basic usage, Advanced usage, , Examples +@section Basic usage +@nav{} + +MathGL library can be used by several manners. Each has positive and negative sides: +@itemize @bullet +@item +@emph{Using of MathGL library features for creating graphical window (requires FLTK, Qt or GLUT libraries).} + +Positive side is the possibility to view the plot at once and to modify it (rotate, zoom or switch on transparency or lighting) by hand or by mouse. Negative sides are: the need of X-terminal and limitation consisting in working with the only one set of data at a time. + +@item +@emph{Direct writing to file in bitmap or vector format without creation of graphical window.} + +Positive aspects are: batch processing of similar data set (for example, a set of resulting data files for different calculation parameters), running from the console program (including the cluster calculation), fast and automated drawing, saving pictures for further analysis (or demonstration). Negative sides are: the usage of the external program for picture viewing. Also, the data plotting is non-visual. So, you have to imagine the picture (view angles, lighting and so on) before the plotting. I recommend to use graphical window for determining the optimal parameters of plotting on the base of some typical data set. And later use these parameters for batch processing in console program. + +@item +@emph{Drawing in memory with the following displaying by other graphical program.} + +In this case the programmer has more freedom in selecting the window libraries (not only FLTK, Qt or GLUT), in positioning and surroundings control and so on. I recommend to use such way for ``stand alone'' programs. + +@item +@emph{Using FLTK or Qt widgets provided by MathGL} + +Here one can use a set of standard widgets which support export to many file formats, copying to clipboard, handle mouse and so on. +@end itemize + +MathGL drawing can be created not only by object oriented languages (like, C++ or Python), but also by pure C or Fortran-like languages. The usage of last one is mostly identical to usage of classes (except the different function names). But there are some differences. C functions must have argument HMGL (for graphics) and/or HMDT (for data arrays) which specifies the object for drawing or manipulating (changing). Fortran users may regard these variables as integer. So, firstly the user has to create this object by function mgl_create_*() and has to delete it after the using by function mgl_delete_*(). +@c Also, all arguments of C function have to be defined. So there are several functions with practically identical names doing practically the same. But some of them have simplified interface for the quick plotting and some of them have access to all plotting parameters for manual tunning. + +Let me consider the aforesaid in more detail. + +@menu +* Using MathGL window:: +* Drawing to file:: +* Animation:: +* Drawing in memory:: +* Using QMathGL:: +* MathGL and PyQt:: +* MathGL and MPI:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node Using MathGL window, Drawing to file, , Basic usage +@subsection Using MathGL window +@nav{} +@cindex window +@cindex widgets + +The ``interactive'' way of drawing in MathGL consists in window creation with help of class @code{mglQT}, @code{mglFLTK} or @code{mglGLUT} (see @ref{Widget classes}) and the following drawing in this window. There is a corresponding code: +@verbatim +#include +int sample(mglGraph *gr) +{ + gr->Rotate(60,40); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + mglQT gr(sample,"MathGL examples"); + return gr.Run(); +} +@end verbatim +Here callback function @code{sample} is defined. This function does all drawing. Other function @code{main} is entry point function for console program. For compilation, just execute the command +@verbatim +gcc test.cpp -lmgl-qt -lmgl +@end verbatim + +Alternatively you can create yours own class inherited from class @code{mglDraw} and re-implement the function @code{Draw()} in it: +@verbatim +#include +class Foo : public mglDraw +{ +public: + int Draw(mglGraph *gr); +}; +//----------------------------------------------------- +int Foo::Draw(mglGraph *gr) +{ + gr->Rotate(60,40); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + Foo foo; + mglQT gr(&foo,"MathGL examples"); + return gr.Run(); +} +@end verbatim +Or use pure C-functions: +@verbatim +#include +int sample(HMGL gr, void *) +{ + mgl_rotate(gr,60,40,0); + mgl_box(gr); +} +int main(int argc,char **argv) +{ + HMGL gr; + gr = mgl_create_graph_qt(sample,"MathGL examples",0,0); + return mgl_qt_run(); +/* generally I should call mgl_delete_graph() here, + * but I omit it in main() function. */ +} +@end verbatim + +The similar code can be written for @code{mglGLUT} window (function @code{sample()} is the same): +@verbatim +#include +int main(int argc,char **argv) +{ + mglGLUT gr(sample,"MathGL examples"); + return 0; +} +@end verbatim + +The rotation, shift, zooming, switching on/off transparency and lighting can be done with help of tool-buttons (for @code{mglQT, mglFLTK}) or by hot-keys: @samp{a}, @samp{d}, @samp{w}, @samp{s} for plot rotation, @samp{r} and @samp{f} switching on/off transparency and lighting. Press @samp{x} for exit (or closing the window). + +In this example function @code{sample} rotates axes (@code{Rotate()}, @pxref{Subplots and rotation}) and draws the bounding box (@code{Box()}). Drawing is placed in separate function since it will be used on demand when window canvas needs to be redrawn. + +@c ------------------------------------------------------------------ +@external{} +@node Drawing to file, Animation, Using MathGL window, Basic usage +@subsection Drawing to file +@nav{} + +Another way of using MathGL library is the direct writing of the picture to the file. It is most usable for plot creation during long calculation or for using of small programs (like Matlab or Scilab scripts) for visualizing repetitive sets of data. But the speed of drawing is much higher in comparison with a script language. + +The following code produces a bitmap PNG picture: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + gr.Alpha(true); gr.Light(true); + sample(&gr); // The same drawing function. + gr.WritePNG("test.png"); // Don't forget to save the result! + return 0; +} +@end verbatim + For compilation, you need only libmgl library not the one with widgets +@verbatim +gcc test.cpp -lmgl +@end verbatim +This can be important if you create a console program in computer/cluster where X-server (and widgets) is inaccessible. + +The only difference from the previous variant (using windows) is manual switching on the transparency @code{Alpha} and lightning @code{Light}, if you need it. The usage of frames (see @ref{Animation}) is not advisable since the whole image is prepared each time. If function @code{sample} contains frames then only last one will be saved to the file. In principle, one does not need to separate drawing functions in case of direct file writing in consequence of the single calling of this function for each picture. However, one may use the same drawing procedure to create a plot with changeable parameters, to export in different file types, to emphasize the drawing code and so on. So, in future I will put the drawing in the separate function. + +The code for export into other formats (for example, into vector EPS file) looks the same: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + gr.Light(true); + sample(&gr); // The same drawing function. + gr.WriteEPS("test.eps"); // Don't forget to save the result! + return 0; +} +@end verbatim +The difference from the previous one is using other function @code{WriteEPS()} for EPS format instead of function @code{WritePNG()}. Also, there is no switching on of the plot transparency @code{Alpha} since EPS format does not support it. + +@c ------------------------------------------------------------------ +@external{} +@node Animation, Drawing in memory, Drawing to file, Basic usage +@subsection Animation +@nav{} + +Widget classes (@code{mglWindow}, @code{mglGLUT}) support a delayed drawing, when all plotting functions are called once at the beginning of writing to memory lists. Further program displays the saved lists faster. Resulting redrawing will be faster but it requires sufficient memory. Several lists (frames) can be displayed one after another (by pressing @samp{,}, @samp{.}) or run as cinema. To switch these feature on one needs to modify function @code{sample}: +@verbatim +int sample(mglGraph *gr) +{ + gr->NewFrame(); // the first frame + gr->Rotate(60,40); + gr->Box(); + gr->EndFrame(); // end of the first frame + gr->NewFrame(); // the second frame + gr->Box(); + gr->Axis("xy"); + gr->EndFrame(); // end of the second frame + return gr->GetNumFrame(); // returns the frame number +} +@end verbatim +First, the function creates a frame by calling @code{NewFrame()} for rotated axes and draws the bounding box. The function @code{EndFrame()} @strong{must be} called after the frame drawing! The second frame contains the bounding box and axes @code{Axis("xy")} in the initial (unrotated) coordinates. Function @code{sample} returns the number of created frames @code{GetNumFrame()}. + +Note, that such kind of animation is rather slow and not well suitable for visualization of running calculations. For the last case one can use @code{Update()} function. The most simple case for doing this is running yours calculations firstly in separate thread and later start MathGL window (QT or FLTK) creation. +@verbatim +#include +mglWindow *gr=NULL; +void *calc(void *) +{ + mglPoint pnt; + for(int i=0;i<10;i++) // do calculation + { + sleep(2); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + if(gr) // be sure that window is ready + { + gr->Clf(); // make new drawing + gr->Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr->Puts(mglPoint(),str); + gr->Update(); // update window + } + } + exit(0); +} +int main(int argc,char **argv) +{ + static pthread_t thr; + // first run yours routine in separate thread + pthread_create(&thr,0,calc,0); + pthread_detach(thr); + gr = new mglWindow; + gr->Run(); return 0; +} +@end verbatim +Note, that such method looks as not working for GLUT windows due to limitation of @code{glutMainLoop()} function. + +Another ways use built-in MathGL feature to run a member function @code{mglDraw::Calc()} separate thread, which work only if pthread support is enabled. For this, you just need to use @code{mglDraw} class and reimplement its @code{Calc()} method. +@verbatim +#include +class Foo : public mglDraw +{ + mglPoint pnt; // some result of calculation +public: + mglWindow *Gr; // graphics to be updated + int Draw(mglGraph *gr); + void Calc(); +} foo; +//----------------------------------------------------- +void Foo::Calc() +{ + for(int i=0;i<30;i++) // do calculation + { + sleep(2); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + Gr->Update(); // update window + } +} +//----------------------------------------------------- +int Foo::Draw(mglGraph *gr) +{ + gr->Line(mglPoint(),pnt,"Ar2"); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + mglWindow gr(&foo,"MathGL examples"); + foo.Gr = &gr; foo.Run(); + return gr.Run(); +} +@end verbatim + +Finally, you can put the event-handling loop in separate instead of yours code by using @code{RunThr()} function instead of @code{Run()} one. Unfortunately, such method work well only for FLTK windows and only if pthread support was enabled. Such limitation come from the Qt requirement to be run in the primary thread only. The sample code will be: +@verbatim +#include +int main(int argc,char **argv) +{ + mglFLTK gr("test"); // create window + gr.RunThr(); // run event loop in separate thread + for(int i=0;i<10;i++) // do calculation + { + sleep(1); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + gr.Clf(); // make new drawing + gr.Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr.Puts(mglPoint(),str); + gr.Update(); // update window when you need it + } + return 0; // finish calculations and close the window +} +@end verbatim + +Pictures with @strong{animation can be saved in file(s)} as well. You can: export in animated GIF, or save each frame in separate file (usually JPEG) and convert these files into the movie (for example, by help of ImageMagic). Let me show both methods. + +@anchor{GIF} +The simplest methods is making animated GIF. There are 3 steps: (1) open GIF file by @code{StartGIF()} function; (2) create the frames by calling @code{NewFrame()} before and @code{EndFrame()} after plotting; (3) close GIF by @code{CloseGIF()} function. So the simplest code for ``running'' sinusoid will look like this: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + mglData dat(100); + char str[32]; + gr.StartGIF("sample.gif"); + for(int i=0;i<40;i++) + { + gr.NewFrame(); // start frame + gr.Box(); // some plotting + for(int j=0;j +int main(int ,char **) +{ + mglGraph gr; + mglData dat(100); + char str[32]; + for(int i=0;i<40;i++) + { + gr.NewFrame(); // start frame + gr.Box(); // some plotting + for(int j=0;jGetSize(&x,&y); // gets a height of the toolbar if any + wxPaintDC dc(this); // and draws it + dc.DrawBitmap(wxBitmap(img),0,y); +} +@end verbatim +The drawing in other libraries is most the same. + +For example, FLTK code will look like +@verbatim +void Fl_MyWidget::draw() +{ + mglGraph gr(w(),h()); + gr.Alpha(true); // draws something using MathGL + gr.Light(true); + sample(&gr,NULL); + fl_draw_image(gr.GetRGB(), x(), y(), gr.GetWidth(), gr.GetHeight(), 3); +} +@end verbatim +Qt code will look like +@verbatim +void MyWidget::paintEvent(QPaintEvent *) +{ + mglGraph gr(w(),h()); + + gr.Alpha(true); // draws something using MathGL + gr.Light(true); gr.Light(0,mglPoint(1,0,-1)); + sample(&gr,NULL); + + // Qt don't support RGB format as is. So, let convert it to BGRN. + long w=gr.GetWidth(), h=gr.GetHeight(); + unsigned char *buf = new uchar[4*w*h]; + gr.GetBGRN(buf, 4*w*h) + QPixmap pic = QPixmap::fromImage(QImage(*buf, w, h, QImage::Format_RGB32)); + + QPainter paint; + paint.begin(this); paint.drawPixmap(0,0,pic); paint.end(); + delete []buf; +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node Using QMathGL, MathGL and PyQt, Drawing in memory, Basic usage +@subsection Using QMathGL +@nav{} + +MathGL have several interface widgets for different widget libraries. There are QMathGL for Qt, Fl_MathGL for FLTK. These classes provide control which display MathGL graphics. Unfortunately there is no uniform interface for widget classes because all libraries have slightly different set of functions, features and so on. However the usage of MathGL widgets is rather simple. Let me show it on the example of QMathGL. + +First of all you have to define the drawing function or inherit a class from @code{mglDraw} class. After it just create a window and setup QMathGL instance as any other Qt widget: +@verbatim +#include +#include +#include +#include +int main(int argc,char **argv) +{ + QApplication a(argc,argv); + QMainWindow *Wnd = new QMainWindow; + Wnd->resize(810,610); // for fill up the QMGL, menu and toolbars + Wnd->setWindowTitle("QMathGL sample"); + // here I allow to scroll QMathGL -- the case + // then user want to prepare huge picture + QScrollArea *scroll = new QScrollArea(Wnd); + + // Create and setup QMathGL + QMathGL *QMGL = new QMathGL(Wnd); +//QMGL->setPopup(popup); // if you want to setup popup menu for QMGL + QMGL->setDraw(sample); + // or use QMGL->setDraw(foo); for instance of class Foo:public mglDraw + QMGL->update(); + + // continue other setup (menu, toolbar and so on) + scroll->setWidget(QMGL); + Wnd->setCentralWidget(scroll); + Wnd->show(); + return a.exec(); +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node MathGL and PyQt, MathGL and MPI, Using QMathGL, Basic usage +@subsection MathGL and PyQt +@nav{} + +Generally SWIG based classes (including the Python one) are the same as C++ classes. However, there are few tips for using MathGL with PyQt. Below I place a very simple python code which demonstrate how MathGL can be used with PyQt. This code is mostly written by Prof. Dr. Heino Falcke. You can just copy it to a file @code{mgl-pyqt-test.py} and execute it from python shell by command @code{execfile("mgl-pyqt-test.py")} + +@verbatim +from PyQt4 import QtGui,QtCore +from mathgl import * +import sys +app = QtGui.QApplication(sys.argv) +qpointf=QtCore.QPointF() + +class hfQtPlot(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.img=(QtGui.QImage()) + def setgraph(self,gr): + self.buffer='\t' + self.buffer=self.buffer.expandtabs(4*gr.GetWidth()*gr.GetHeight()) + gr.GetBGRN(self.buffer,len(self.buffer)) + self.img=QtGui.QImage(self.buffer, gr.GetWidth(),gr.GetHeight(),QtGui.QImage.Format_ARGB32) + self.update() + def paintEvent(self, event): + paint = QtGui.QPainter() + paint.begin(self) + paint.drawImage(qpointf,self.img) + paint.end() + +BackgroundColor=[1.0,1.0,1.0] +size=100 +gr=mglGraph() +y=mglData(size) +#y.Modify("((0.7*cos(2*pi*(x+.2)*500)+0.3)*(rnd*0.5+0.5)+362.135+10000.)") +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +x=mglData(size) +x.Modify("x^2"); + +def plotpanel(gr,x,y,n): + gr.SubPlot(2,2,n) + gr.SetXRange(x) + gr.SetYRange(y) + gr.AdjustTicks() + gr.Axis() + gr.Box() + gr.Label("x","x-Axis",1) + gr.Label("y","y-Axis",1) + gr.ClearLegend() + gr.AddLegend("Legend: "+str(n),"k") + gr.Legend() + gr.Plot(x,y) + + +gr.Clf(BackgroundColor[0],BackgroundColor[1],BackgroundColor[2]) +gr.SetPlotFactor(1.5) +plotpanel(gr,x,y,0) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,1) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,2) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,3) + +gr.WritePNG("test.png","Test Plot") + +qw = hfQtPlot() +qw.show() +qw.setgraph(gr) +qw.raise_() +@end verbatim + + +@c ------------------------------------------------------------------ +@external{} +@node MathGL and MPI, , MathGL and PyQt, Basic usage +@subsection MathGL and MPI +@nav{} + +For using MathGL in MPI program you just need to: (1) plot its own part of data for each running node; (2) collect resulting graphical information in a single program (for example, at node with rank=0); (3) save it. The sample code below demonstrate this for very simple sample of surface drawing. + +First you need to initialize MPI +@verbatim +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // initialize MPI + int rank=0, numproc=1; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD,&numproc); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + if(rank==0) printf("Use %d processes.\n", numproc); +@end verbatim + +Next step is data creation. For simplicity, I create data arrays with the same sizes for all nodes. At this, you have to create @code{mglGraph} object too. + +@verbatim + // initialize data similarly for all nodes + mglData a(128,256); + mglGraphMPI gr; +@end verbatim + +Now, data should be filled by numbers. In real case, it should be some kind of calculations. But I just fill it by formula. + +@verbatim + // do the same plot for its own range + char buf[64]; + sprintf(buf,"xrange %g %g",2.*rank/numproc-1,2.*(rank+1)/numproc-1); + gr.Fill(a,"sin(2*pi*x)",buf); +@end verbatim + +It is time to plot the data. Don't forget to set proper axis range(s) by using parametric form or by using options (as in the sample). + +@verbatim + // plot data in each node + gr.Clf(); // clear image before making the image + gr.Rotate(40,60); + gr.Surf(a,"",buf); +@end verbatim + +Finally, let send graphical information to node with rank=0. + +@verbatim + // collect information + if(rank!=0) gr.MPI_Send(0); + else for(int i=1;iSubPlot(2,2,0); gr->Box(); + gr->Puts(mglPoint(-1,1.1),"Just box",":L"); + gr->InPlot(0.2,0.5,0.7,1,false); gr->Box(); + gr->Puts(mglPoint(0,1.2),"InPlot example"); + gr->SubPlot(2,2,1); gr->Title("Rotate only"); + gr->Rotate(50,60); gr->Box(); + gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); + gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); + gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); + return 0; +} +@end verbatim +Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. + +@pfig{aspect, Example of several subplots on the single picture.} + +More complicated sample show how to use most of positioning functions: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("StickPlot"); + gr->StickPlot(3, 0, 20, 30); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->StickPlot(3, 1, 20, 30); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->StickPlot(3, 2, 20, 30); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,3,""); gr->Title("ColumnPlot"); + gr->ColumnPlot(3, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ColumnPlot(3, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ColumnPlot(3, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,4,""); gr->Title("GridPlot"); + gr->GridPlot(2, 2, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->GridPlot(2, 2, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->GridPlot(2, 2, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); + gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); + gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); + return 0; +} +@end verbatim + +@pfig{inplot, Example for most of positioning functions.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis and ticks, Curvilinear coordinates, Subplots, Advanced usage +@subsection Axis and ticks +@nav{} + +MathGL library can draw not only the bounding box but also the axes, grids, labels and so on. The ranges of axes and their origin (the point of intersection) are determined by functions @code{SetRange()}, @code{SetRanges()}, @code{SetOrigin()} (see @ref{Ranges (bounding box)}). Ticks on axis are specified by function @code{SetTicks}, @code{SetTicksVal}, @code{SetTicksTime} (see @ref{Ticks}). But usually + +Function @ref{axis} draws axes. Its textual string shows in which directions the axis or axes will be drawn (by default @code{"xyz"}, function draws axes in all directions). Function @ref{grid} draws grid perpendicularly to specified directions. Example of axes and grid drawing is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Axis origin, Grid"); gr->SetOrigin(0,0); + gr->Axis(); gr->Grid(); gr->FPlot("x^3"); + + gr->SubPlot(2,2,1); gr->Title("2 axis"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1,-1,-1); // first axis + gr->Axis(); gr->Label('y',"axis 1",0); gr->FPlot("sin(pi*x)"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(1,1,1); // second axis + gr->Axis(); gr->Label('y',"axis 2",0); gr->FPlot("cos(pi*x)"); + + gr->SubPlot(2,2,3); gr->Title("More axis"); + gr->SetOrigin(NAN,NAN); gr->SetRange('x',-1,1); + gr->Axis(); gr->Label('x',"x",0); gr->Label('y',"y_1",0); + gr->FPlot("x^2","k"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1.3,-1); // second axis + gr->Axis("y","r"); gr->Label('y',"#r{y_2}",0.2); + gr->FPlot("x^3","r"); + + gr->SubPlot(2,2,2); gr->Title("4 segments, inverted axis"); + gr->SetOrigin(0,0); + gr->InPlot(0.5,1,0.5,1); gr->SetRanges(0,10,0,2); gr->Axis(); + gr->FPlot("sqrt(x/2)"); gr->Label('x',"W",1); gr->Label('y',"U",1); + gr->InPlot(0,0.5,0.5,1); gr->SetRanges(1,0,0,2); gr->Axis("x"); + gr->FPlot("sqrt(x)+x^3"); gr->Label('x',"\\tau",-1); + gr->InPlot(0.5,1,0,0.5); gr->SetRanges(0,10,4,0); gr->Axis("y"); + gr->FPlot("x/4"); gr->Label('y',"L",-1); + gr->InPlot(0,0.5,0,0.5); gr->SetRanges(1,0,4,0); gr->FPlot("4*x^2"); + return 0; +} +@end verbatim + +Note, that MathGL can draw not only single axis (which is default). But also several axis on the plot (see right plots). The idea is that the change of settings does not influence on the already drawn graphics. So, for 2-axes I setup the first axis and draw everything concerning it. Then I setup the second axis and draw things for the second axis. Generally, the similar idea allows one to draw rather complicated plot of 4 axis with different ranges (see bottom left plot). + +At this inverted axis can be created by 2 methods. First one is used in this sample -- just specify minimal axis value to be large than maximal one. This method work well for 2D axis, but can wrongly place labels in 3D case. Second method is more general and work in 3D case too -- just use @ref{aspect} function with negative arguments. For example, following code will produce exactly the same result for 2D case, but 2nd variant will look better in 3D. +@verbatim +// variant 1 +gr->SetRanges(0,10,4,0); gr->Axis(); + +// variant 2 +gr->SetRanges(0,10,0,4); gr->Aspect(1,-1); gr->Axis(); +@end verbatim + +@pfig{axis, Example of axis.} + +Another MathGL feature is fine ticks tunning. By default (if it is not changed by @code{SetTicks} function), MathGL try to adjust ticks positioning, so that they looks most human readable. At this, MathGL try to extract common factor for too large or too small axis ranges, as well as for too narrow ranges. Last one is non-common notation and can be disabled by @code{SetTuneTicks} function. + +Also, one can specify its own ticks with arbitrary labels by help of @code{SetTicksVal} function. Or one can set ticks in time format. In last case MathGL will try to select optimal format for labels with automatic switching between years, months/days, hours/minutes/seconds or microseconds. However, you can specify its own time representation using formats described in @url{http://www.manpagez.com/man/3/strftime/}. Most common variants are @samp{%X} for national representation of time, @samp{%x} for national representation of date, @samp{%Y} for year with century. + +The sample code, demonstrated ticks feature is +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("Usual axis"); gr->Axis(); + gr->SubPlot(3,2,1); gr->Title("Too big/small range"); + gr->SetRanges(-1000,1000,0,0.001); gr->Axis(); + gr->SubPlot(3,2,3); gr->Title("Too narrow range"); + gr->SetRanges(100,100.1,10,10.01); gr->Axis(); + gr->SubPlot(3,2,4); gr->Title("Disable ticks tuning"); + gr->SetTuneTicks(0); gr->Axis(); + + gr->SubPlot(3,2,2); gr->Title("Manual ticks"); gr->SetRanges(-M_PI,M_PI, 0, 2); + mreal val[]={-M_PI, -M_PI/2, 0, 0.886, M_PI/2, M_PI}; + gr->SetTicksVal('x', mglData(6,val), "-\\pi\n-\\pi/2\n0\nx^*\n\\pi/2\n\\pi"); + gr->Axis(); gr->Grid(); gr->FPlot("2*cos(x^2)^2", "r2"); + + gr->SubPlot(3,2,5); gr->Title("Time ticks"); gr->SetRange('x',0,3e5); + gr->SetTicksTime('x',0); gr->Axis(); + return 0; +} +@end verbatim + +@pfig{ticks, Features of axis ticks.} + +The last sample I want to show in this subsection is Log-axis. From MathGL's point of view, the log-axis is particular case of general curvilinear coordinates. So, we need first define new coordinates (see also @ref{Curvilinear coordinates}) by help of @code{SetFunc} or @code{SetCoor} functions. At this one should wary about proper axis range. So the code looks as following: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,"<_"); gr->Title("Semi-log axis"); + gr->SetRanges(0.01,100,-1,1); gr->SetFunc("lg(x)",""); + gr->Axis(); gr->Grid("xy","g"); gr->FPlot("sin(1/x)"); + gr->Label('x',"x",0); gr->Label('y', "y = sin 1/x",0); + + gr->SubPlot(2,2,1,"<_"); gr->Title("Log-log axis"); + gr->SetRanges(0.01,100,0.1,100); gr->SetFunc("lg(x)","lg(y)"); + gr->Axis(); gr->FPlot("sqrt(1+x^2)"); gr->Label('x',"x",0); + gr->Label('y', "y = \\sqrt{1+x^2}",0); + + gr->SubPlot(2,2,2,"<_"); gr->Title("Minus-log axis"); + gr->SetRanges(-100,-0.01,-100,-0.1); gr->SetFunc("-lg(-x)","-lg(-y)"); + gr->Axis(); gr->FPlot("-sqrt(1+x^2)"); + gr->Label('x',"x",0); gr->Label('y', "y = -\\sqrt{1+x^2}",0); + + gr->SubPlot(2,2,3,"<_"); gr->Title("Log-ticks"); + gr->SetRanges(0.1,100,0,100); gr->SetFunc("sqrt(x)",""); + gr->Axis(); gr->FPlot("x"); + gr->Label('x',"x",1); gr->Label('y', "y = x",0); + return 0; +} +@end verbatim + +@pfig{loglog, Features of axis ticks.} + +You can see that MathGL automatically switch to log-ticks as we define log-axis formula (in difference from v.1.*). Moreover, it switch to log-ticks for any formula if axis range will be large enough (see right bottom plot). Another interesting feature is that you not necessary define usual log-axis (i.e. when coordinates are positive), but you can define ``minus-log'' axis when coordinate is negative (see left bottom plot). + +@c ------------------------------------------------------------------ +@external{} +@node Curvilinear coordinates, Colorbars, Axis and ticks, Advanced usage +@subsection Curvilinear coordinates +@nav{} + +As I noted in previous subsection, MathGL support curvilinear coordinates. In difference from other plotting programs and libraries, MathGL uses textual formulas for connection of the old (data) and new (output) coordinates. This allows one to plot in arbitrary coordinates. The following code plots the line @var{y}=0, @var{z}=0 in Cartesian, polar, parabolic and spiral coordinates: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetOrigin(-1,1,-1); + + gr->SubPlot(2,2,0); gr->Title("Cartesian"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)",0); + gr->SubPlot(2,2,1); gr->Title("Cylindrical"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("2*y*x","y*y - x*x",0); + gr->SubPlot(2,2,2); gr->Title("Parabolic"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z"); + gr->SubPlot(2,2,3); gr->Title("Spiral"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + gr->SetFunc(0,0,0); // set to default Cartesian + return 0; +} +@end verbatim + +@pfig{curvcoor, Example of curvilinear coordinates} + + +@c ------------------------------------------------------------------ +@external{} +@node Colorbars, Bounding box, Curvilinear coordinates, Advanced usage +@subsection Colorbars +@nav{} + +MathGL handle @ref{colorbar} as special kind of axis. So, most of functions for axis and ticks setup will work for colorbar too. Colorbars can be in log-scale, and generally as arbitrary function scale; common factor of colorbar labels can be separated; and so on. + +But of course, there are differences -- colorbars usually located out of bounding box. At this, colorbars can be at subplot boundaries (by default), or at bounding box (if symbol @samp{I} is specified). Colorbars can handle sharp colors. And they can be located at arbitrary position too. The sample code, which demonstrate colorbar features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Colorbar out of box"); gr->Box(); + gr->Colorbar("<"); gr->Colorbar(">"); + gr->Colorbar("_"); gr->Colorbar("^"); + + gr->SubPlot(2,2,1); gr->Title("Colorbar near box"); gr->Box(); + gr->Colorbar("Colorbar(">I"); + gr->Colorbar("_I"); gr->Colorbar("^I"); + + gr->SubPlot(2,2,2); gr->Title("manual colors"); + mglData a,v; mgls_prepare2d(&a,0,&v); + gr->Box(); gr->ContD(v,a); + gr->Colorbar(v,"<"); gr->Colorbar(v,">"); + gr->Colorbar(v,"_"); gr->Colorbar(v,"^"); + + gr->SubPlot(2,2,3); gr->Title(" "); + gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2); + gr->Colorbar("bwr>",0.25,0); gr->Puts(mglPoint(-0.9,1.2),"Default"); + gr->Colorbar("b{w,0.3}r>",0.5,0); gr->Puts(mglPoint(-0.1,1.2),"Manual"); + + gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2); + gr->SetRange('c',0.01,1e3); + gr->Colorbar(">",0.75,0); gr->Puts(mglPoint(0.65,1.2),"Normal scale"); + gr->SetFunc("","","","lg(c)"); + gr->Colorbar(">"); gr->Puts(mglPoint(1.35,1.2),"Log scale"); + return 0; +} +@end verbatim + +@pfig{colorbar, Example of colorbars} + + +@c ------------------------------------------------------------------ +@external{} +@node Bounding box, Ternary axis, Colorbars, Advanced usage +@subsection Bounding box +@nav{} + +Box around the plot is rather useful thing because it allows one to: see the plot boundaries, and better estimate points position since box contain another set of ticks. MathGL provide special function for drawing such box -- @ref{box} function. By default, it draw black or white box with ticks (color depend on transparency type, see @ref{Types of transparency}). However, you can change the color of box, or add drawing of rectangles at rear faces of box. Also you can disable ticks drawing, but I don't know why anybody will want it. The sample code, which demonstrate @ref{box} features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Box (default)"); gr->Rotate(50,60); + gr->Box(); + gr->SubPlot(2,2,1); gr->Title("colored"); gr->Rotate(50,60); + gr->Box("r"); + gr->SubPlot(2,2,2); gr->Title("with faces"); gr->Rotate(50,60); + gr->Box("@"); + gr->SubPlot(2,2,3); gr->Title("both"); gr->Rotate(50,60); + gr->Box("@cm"); + return 0; +} +@end verbatim + +@pfig{box, Example of Box()} + + +@c ------------------------------------------------------------------ +@external{} +@node Ternary axis, Text features, Bounding box, Advanced usage +@subsection Ternary axis +@nav{} + +There are another unusual axis types which are supported by MathGL. These are ternary and quaternary axis. Ternary axis is special axis of 3 coordinates @var{a}, @var{b}, @var{c} which satisfy relation @var{a}+@var{b}+@var{c}=1. Correspondingly, quaternary axis is special axis of 4 coordinates @var{a}, @var{b}, @var{c}, @var{d} which satisfy relation @var{a}+@var{b}+@var{c}+@var{d}=1. + +Generally speaking, only 2 of coordinates (3 for quaternary) are independent. So, MathGL just introduce some special transformation formulas which treat @var{a} as @samp{x}, @var{b} as @samp{y} (and @var{c} as @samp{z} for quaternary). As result, all plotting functions (curves, surfaces, contours and so on) work as usual, but in new axis. You should use @ref{ternary} function for switching to ternary/quaternary coordinates. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + gr->SubPlot(2,2,0); gr->Title("Ordinary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"B",1); gr->Label('y',"C",1); gr->Label('z',"Z",1); + + gr->SubPlot(2,2,1); gr->Title("Ternary axis (x+y+t=1)"); + gr->Ternary(1); + gr->Plot(x,y,"r2"); gr->Plot(rx,ry,"q^ "); gr->Cont(a,"BbcyrR"); + gr->Line(mglPoint(0.5,0), mglPoint(0,0.75), "g2"); + gr->Axis(); gr->Grid("xyz","B;"); + gr->Label('x',"B"); gr->Label('y',"C"); gr->Label('t',"A"); + + gr->SubPlot(2,2,2); gr->Title("Quaternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(2); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"D",1); + + gr->SubPlot(2,2,3); gr->Title("Ternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(1); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"Z",1); + return 0; +} +@end verbatim + +@pfig{ternary, Example of colorbars} + +@c ------------------------------------------------------------------ +@external{} +@node Text features, Legend sample, Ternary axis, Advanced usage +@subsection Text features +@nav{} + +MathGL prints text by vector font. There are functions for manual specifying of text position (like @code{Puts}) and for its automatic selection (like @code{Label}, @code{Legend} and so on). MathGL prints text always in specified position even if it lies outside the bounding box. The default size of font is specified by functions @var{SetFontSize*} (see @ref{Font settings}). However, the actual size of output string depends on subplot size (depends on functions @code{SubPlot}, @code{InPlot}). The switching of the font style (italic, bold, wire and so on) can be done for the whole string (by function parameter) or inside the string. By default MathGL parses TeX-like commands for symbols and indexes (see @ref{Font styles}). + +Text can be printed as usual one (from left to right), along some direction (rotated text), or along a curve. Text can be printed on several lines, divided by new line symbol @samp{\n}. + +Example of MathGL font drawing is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,""); + gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode"); + gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}"); + gr->Puts(mglPoint(0,0.2),"One can change style in string: " + "\\b{bold}, \\i{italic, \\b{both}}"); + gr->Puts(mglPoint(0,-0.2),"Easy to \\a{overline} or " + "\\u{underline}"); + gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}"); + gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot " + "\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx"); + + gr->SubPlot(2,2,1,""); + gr->Puts(mglPoint(0,0.5), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", "@", -4); + gr->Puts(mglPoint(0,-0.5),"Text can be printed\non several lines"); + + gr->SubPlot(2,2,2,""); + mglData y; mgls_prepare1d(&y); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve",":k"); + gr->Text(y,"Another string drawn above a curve","T:r"); + + gr->SubPlot(2,2,3,""); + gr->Line(mglPoint(-1,-1),mglPoint(1,-1),"rA"); + gr->Puts(mglPoint(0,-1),mglPoint(1,-1),"Horizontal"); + gr->Line(mglPoint(-1,-1),mglPoint(1,1),"rA"); + gr->Puts(mglPoint(0,0),mglPoint(1,1),"At angle","@"); + gr->Line(mglPoint(-1,-1),mglPoint(-1,1),"rA"); + gr->Puts(mglPoint(-1,0),mglPoint(-1,1),"Vertical"); + return 0; +} +@end verbatim + +@pfig{text, Example of text printing} + +You can change font faces by loading font files by function @ref{loadfont}. Note, that this is long-run procedure. Font faces can be downloaded from @uref{http://mathgl.sourceforge.net/download.html, MathGL website} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + double h=1.1, d=0.25; + gr->LoadFont("STIX"); gr->Puts(mglPoint(0,h), "default font (STIX)"); + gr->LoadFont("adventor"); gr->Puts(mglPoint(0,h-d), "adventor font"); + gr->LoadFont("bonum"); gr->Puts(mglPoint(0,h-2*d), "bonum font"); + gr->LoadFont("chorus"); gr->Puts(mglPoint(0,h-3*d), "chorus font"); + gr->LoadFont("cursor"); gr->Puts(mglPoint(0,h-4*d), "cursor font"); + gr->LoadFont("heros"); gr->Puts(mglPoint(0,h-5*d), "heros font"); + gr->LoadFont("heroscn"); gr->Puts(mglPoint(0,h-6*d), "heroscn font"); + gr->LoadFont("pagella"); gr->Puts(mglPoint(0,h-7*d), "pagella font"); + gr->LoadFont("schola"); gr->Puts(mglPoint(0,h-8*d), "schola font"); + gr->LoadFont("termes"); gr->Puts(mglPoint(0,h-9*d), "termes font"); + return 0; +} +@end verbatim + +@pfig{fonts, Example of font faces} + + +@c ------------------------------------------------------------------ +@external{} +@node Legend sample, Cutting sample, Text features, Advanced usage +@subsection Legend sample +@nav{} + +Legend is one of standard ways to show plot annotations. Basically you need to connect the plot style (line style, marker and color) with some text. In MathGL, you can do it by 2 methods: manually using @ref{addlegend} function; or use @samp{legend} option (see @ref{Command options}), which will use last plot style. In both cases, legend entries will be added into internal accumulator, which later used for legend drawing itself. @ref{clearlegend} function allow you to remove all saved legend entries. + +There are 2 features. If plot style is empty then text will be printed without indent. If you want to plot the text with indent but without plot sample then you need to use space @samp{ } as plot style. Such style @samp{ } will draw a plot sample (line with marker(s)) which is invisible line (i.e. nothing) and print the text with indent as usual one. + +Function @ref{legend} draw legend on the plot. The position of the legend can be selected automatic or manually. You can change the size and style of text labels, as well as setup the plot sample. The sample code demonstrating legend features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->AddLegend("sin(\\pi {x^2})","b"); + gr->AddLegend("sin(\\pi x)","g*"); + gr->AddLegend("sin(\\pi \\sqrt{x})","rd"); + gr->AddLegend("just text"," "); + gr->AddLegend("no indent for this",""); + + gr->SubPlot(2,2,0,""); gr->Title("Legend (default)"); + gr->Box(); gr->Legend(); + + gr->Legend(3,"A#"); + gr->Puts(mglPoint(0.75,0.65),"Absolute position","A"); + + gr->SubPlot(2,2,2,""); gr->Title("coloring"); gr->Box(); + gr->Legend(0,"r#"); gr->Legend(1,"Wb#"); gr->Legend(2,"ygr#"); + + gr->SubPlot(2,2,3,""); gr->Title("manual position"); gr->Box(); + gr->Legend(0.5,1); gr->Puts(mglPoint(0.5,0.55),"at x=0.5, y=1","a"); + gr->Legend(1,"#-"); gr->Puts(mglPoint(0.75,0.25),"Horizontal legend","a"); + return 0; +} +@end verbatim + +@pfig{legend, Example of legend} + +@c ------------------------------------------------------------------ +@external{} +@node Cutting sample, , Legend sample, Advanced usage +@subsection Cutting sample +@nav{} + +The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that. +@itemize @bullet +@item +You can set one of coordinate to NAN value. All points with NAN values will be omitted. + +@item +You can enable cutting at edges by @code{SetCut} function. As result all points out of bounding box will be omitted. + +@item +You can set cutting box by @code{SetCutBox} function. All points inside this box will be omitted. + +@item +You can define cutting formula by @code{SetCutOff} function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant. +@end itemize + +Below I place the code which demonstrate last 3 possibilities: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,c,v(1); mgls_prepare2d(&a); mgls_prepare3d(&c); v.a[0]=0.5; + gr->SubPlot(2,2,0); gr->Title("Cut on (default)"); + gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Surf(a,"","zrange -1 0.5"); + + gr->SubPlot(2,2,1); gr->Title("Cut off"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a,"","zrange -1 0.5; cut off"); + + gr->SubPlot(2,2,2); gr->Title("Cut in box"); gr->Rotate(50,60); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->Alpha(true); gr->Box(); gr->Surf3(c); + gr->SetCutBox(mglPoint(0), mglPoint(0)); // switch it off + + gr->SubPlot(2,2,3); gr->Title("Cut by formula"); gr->Rotate(50,60); + gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)"); + gr->Box(); gr->Surf3(c); gr->CutOff(""); // switch it off + return 0; +} +@end verbatim + +@pfig{cut, Example of point cutting} + + + +@c ------------------------------------------------------------------ +@external{} +@node Data handling, Data plotting, Advanced usage, Examples +@section Data handling +@nav{} + +Class @code{mglData} contains all functions for the data handling in MathGL (@pxref{Data processing}). There are several matters why I use class @code{mglData} but not a single array: it does not depend on type of data (mreal or double), sizes of data arrays are kept with data, memory working is simpler and safer. + +@menu +* Array creation:: +* Linking array:: +* Change data:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Array creation, Linking array, , Data handling +@subsection Array creation +@nav{} + +There are many ways in MathGL how data arrays can be created and filled. + +One can put the data in @code{mglData} instance by several ways. Let us do it for sinus function: +@itemize @bullet +@item +one can create external array, fill it and put to @code{mglData} variable +@verbatim + double *a = new double[50]; + for(int i=0;i<50;i++) a[i] = sin(M_PI*i/49.); + + mglData y; + y.Set(a,50); +@end verbatim + +@item +another way is to create @code{mglData} instance of the desired size and then to work directly with data in this variable +@verbatim + mglData y(50); + for(int i=0;i<50;i++) y.a[i] = sin(M_PI*i/49.); +@end verbatim + +@item +next way is to fill the data in @code{mglData} instance by textual formula with the help of @code{Modify()} function +@verbatim + mglData y(50); + y.Modify("sin(pi*x)"); +@end verbatim + +@item +or one may fill the array in some interval and modify it later +@verbatim + mglData y(50); + y.Fill(0,M_PI); + y.Modify("sin(u)"); +@end verbatim + +@item +finally it can be loaded from file +@verbatim + FILE *fp=fopen("sin.dat","wt"); // create file first + for(int i=0;i<50;i++) fprintf(fp,"%g\n",sin(M_PI*i/49.)); + fclose(fp); + + mglData y("sin.dat"); // load it +@end verbatim +At this you can use textual or HDF files, as well as import values from bitmap image (PNG is supported right now). + +@item +at this one can read only part of data +@verbatim + FILE *fp-fopen("sin.dat","wt"); // create large file first + for(int i=0;i<70;i++) fprintf(fp,"%g\n",sin(M_PI*i/49.)); + fclose(fp); + + mglData y; + y.Read("sin.dat",50); // load it +@end verbatim +@end itemize + +Creation of 2d- and 3d-arrays is mostly the same. But one should keep in mind that class @code{mglData} uses flat data representation. For example, matrix 30*40 is presented as flat (1d-) array with length 30*40=1200 (nx=30, ny=40). The element with indexes @{i,j@} is a[i+nx*j]. So for 2d array we have: +@verbatim + mglData z(30,40); + for(int i=0;i<30;i++) for(int j=0;j<40;j++) + z.a[i+30*j] = sin(M_PI*i/29.)*sin(M_PI*j/39.); +@end verbatim +or by using @code{Modify()} function +@verbatim + mglData z(30,40); + z.Modify("sin(pi*x)*cos(pi*y)"); +@end verbatim + +The only non-obvious thing here is using multidimensional arrays in C/C++, i.e. arrays defined like @code{mreal dat[40][30];}. Since, formally these elements @code{dat[i]} can address the memory in arbitrary place you should use the proper function to convert such arrays to @code{mglData} object. For C++ this is functions like @code{mglData::Set(mreal **dat, int N1, int N2);}. For C this is functions like @code{mgl_data_set_mreal2(HMDT d, const mreal **dat, int N1, int N2);}. At this, you should keep in mind that @code{nx=N2} and @code{ny=N1} after conversion. + +@c ------------------------------------------------------------------ +@external{} +@node Linking array, Change data, Array creation, Data handling +@subsection Linking array +@nav{} + +Sometimes the data arrays are so large, that one couldn't' copy its values to another array (i.e. into mglData). In this case, he can define its own class derived from @code{mglDataA} (see @ref{mglDataA class}) or can use @code{Link} function. + +In last case, MathGL just save the link to an external data array, but not copy it. You should provide the existence of this data array for whole time during which MathGL can use it. Another point is that MathGL will automatically create new array if you'll try to modify data values by any of @code{mglData} functions. So, you should use only function with @code{const} modifier if you want still using link to the original data array. + +Creating the link is rather simple -- just the same as using @code{Set} function +@verbatim + double *a = new double[50]; + for(int i=0;i<50;i++) a[i] = sin(M_PI*i/49.); + + mglData y; + y.Link(a,50); +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node Change data, , Linking array, Data handling +@subsection Change data +@nav{} + +MathGL has functions for data processing: differentiating, integrating, smoothing and so on (for more detail, see @ref{Data processing}). Let us consider some examples. The simplest ones are integration and differentiation. The direction in which operation will be performed is specified by textual string, which may contain symbols @samp{x}, @samp{y} or @samp{z}. For example, the call of @code{Diff("x")} will differentiate data along @samp{x} direction; the call of @code{Integral("xy")} perform the double integration of data along @samp{x} and @samp{y} directions; the call of @code{Diff2("xyz")} will apply 3d Laplace operator to data and so on. Example of this operations on 2d array a=x*y is presented in code: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData a(30,40); a.Modify("x*y"); + gr->SubPlot(2,2,0); gr->Rotate(60,40); + gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"a(x,y)"); + gr->SubPlot(2,2,1); gr->Rotate(60,40); + a.Diff("x"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"da/dx"); + gr->SubPlot(2,2,2); gr->Rotate(60,40); + a.Integral("xy"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"\\int da/dx dxdy"); + gr->SubPlot(2,2,3); gr->Rotate(60,40); + a.Diff2("y"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"\\int {d^2}a/dxdy dx"); + return 0; +} +@end verbatim + +@pfig{dat_diff, Example of data differentiation and integration} + +Data smoothing (function @ref{smooth}) is more interesting and important. This function has single argument which define type of smoothing and its direction. Now 3 methods are supported: @samp{3} -- linear averaging by 3 points, @samp{5} -- linear averaging by 5 points, and default one -- quadratic averaging by 5 points. + +MathGL also have some amazing functions which is not so important for data processing as useful for data plotting. There are functions for finding envelope (useful for plotting rapidly oscillating data), for data sewing (useful to removing jumps on the phase), for data resizing (interpolation). Let me demonstrate it: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,""); gr->Title("Envelop sample"); + mglData d1(1000); gr->Fill(d1,"exp(-8*x^2)*sin(10*pi*x)"); + gr->Axis(); gr->Plot(d1, "b"); + d1.Envelop('x'); gr->Plot(d1, "r"); + + gr->SubPlot(2,2,1,""); gr->Title("Smooth sample"); + mglData y0(30),y1,y2,y3; + gr->SetRanges(0,1,0,1); + gr->Fill(y0, "0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd"); + + y1=y0; y1.Smooth("x3"); + y2=y0; y2.Smooth("x5"); + y3=y0; y3.Smooth("x"); + + gr->Plot(y0,"{m7}:s", "legend 'none'"); //gr->AddLegend("none","k"); + gr->Plot(y1,"r", "legend ''3' style'"); + gr->Plot(y2,"g", "legend ''5' style'"); + gr->Plot(y3,"b", "legend 'default'"); + gr->Legend(); gr->Box(); + + gr->SubPlot(2,2,2); gr->Title("Sew sample"); + mglData d2(100, 100); gr->Fill(d2, "mod((y^2-(1-x)^2)/2,0.1)"); + gr->Rotate(50, 60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf(d2, "b"); + d2.Sew("xy", 0.1); gr->Surf(d2, "r"); + + gr->SubPlot(2,2,3); gr->Title("Resize sample (interpolation)"); + mglData x0(10), v0(10), x1, v1; + gr->Fill(x0,"rnd"); gr->Fill(v0,"rnd"); + x1 = x0.Resize(100); v1 = v0.Resize(100); + gr->Plot(x0,v0,"b+ "); gr->Plot(x1,v1,"r-"); + gr->Label(x0,v0,"%n"); + return 0; +} +@end verbatim + +@pfig{dat_extra, Example of data manipulation} + +Also one can create new data arrays on base of the existing one: extract slice, row or column of data (@ref{subdata}), summarize along a direction(s) (@ref{sum}), find distribution of data elements (@ref{hist}) and so on. + +@anchor{Solve sample} +Another interesting feature of MathGL is interpolation and root-finding. There are several functions for linear and cubic spline interpolation (see @ref{Interpolation}). Also there is a function @ref{evaluate} which do interpolation of data array for values of each data element of index data. It look as indirect access to the data elements. + +This function have inverse function @ref{solve} which find array of indexes at which data array is equal to given value (i.e. work as root finding). But @ref{solve} function have the issue -- usually multidimensional data (2d and 3d ones) have an infinite number of indexes which give some value. This is contour lines for 2d data, or isosurface(s) for 3d data. So, @ref{solve} function will return index only in given direction, assuming that other index(es) are the same as equidistant index(es) of original data. If data have multiple roots then second (and later) branches can be found by consecutive call(s) of @ref{solve} function. Let me demonstrate this on the following sample. + +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRange('z',0,1); + mglData x(20,30), y(20,30), z(20,30), xx,yy,zz; + gr->Fill(x,"(x+2)/3*cos(pi*y)"); + gr->Fill(y,"(x+2)/3*sin(pi*y)"); + gr->Fill(z,"exp(-6*x^2-2*sin(pi*y)^2)"); + + gr->SubPlot(2,1,0); gr->Title("Cartesian space"); gr->Rotate(30,-40); + gr->Axis("xyzU"); gr->Box(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->SetOrigin(1,1); gr->Grid("xy"); + gr->Mesh(x,y,z); + + // section along 'x' direction + mglData u = x.Solve(0.5,'x'); + mglData v(u.nx); v.Fill(0,1); + xx = x.Evaluate(u,v); yy = y.Evaluate(u,v); zz = z.Evaluate(u,v); + gr->Plot(xx,yy,zz,"k2o"); + + // 1st section along 'y' direction + mglData u1 = x.Solve(-0.5,'y'); + mglData v1(u1.nx); v1.Fill(0,1); + xx = x.Evaluate(v1,u1); yy = y.Evaluate(v1,u1); zz = z.Evaluate(v1,u1); + gr->Plot(xx,yy,zz,"b2^"); + + // 2nd section along 'y' direction + mglData u2 = x.Solve(-0.5,'y',u1); + xx = x.Evaluate(v1,u2); yy = y.Evaluate(v1,u2); zz = z.Evaluate(v1,u2); + gr->Plot(xx,yy,zz,"r2v"); + + gr->SubPlot(2,1,1); gr->Title("Accompanied space"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(0,0); + gr->Axis(); gr->Box(); gr->Label('x',"i"); gr->Label('y',"j"); + gr->Grid(z,"h"); + + gr->Plot(u,v,"k2o"); gr->Line(mglPoint(0.4,0.5),mglPoint(0.8,0.5),"kA"); + gr->Plot(v1,u1,"b2^"); gr->Line(mglPoint(0.5,0.15),mglPoint(0.5,0.3),"bA"); + gr->Plot(v1,u2,"r2v"); gr->Line(mglPoint(0.5,0.7),mglPoint(0.5,0.85),"rA"); +} +@end verbatim + +@pfig{solve, Example of data interpolation and root finding} + +@c ------------------------------------------------------------------ +@external{} +@node Data plotting, 1D samples, Data handling, Examples +@section Data plotting +@nav{} + +Let me now show how to plot the data. Next section will give much more examples for all plotting functions. Here I just show some basics. MathGL generally has 2 types of plotting functions. Simple variant requires a single data array for plotting, other data (coordinates) are considered uniformly distributed in axis range. Second variant requires data arrays for all coordinates. It allows one to plot rather complex multivalent curves and surfaces (in case of parametric dependencies). Usually each function have one textual argument for plot style and another textual argument for options (see @ref{Command options}). + +Note, that the call of drawing function adds something to picture but does not clear the previous plots (as it does in Matlab). Another difference from Matlab is that all setup (like transparency, lightning, axis borders and so on) must be specified @strong{before} plotting functions. + +Let start for plots for 1D data. Term ``1D data'' means that data depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. The textual argument allow you specify styles of line and marks (see @ref{Line styles}). If this parameter is @code{NULL} or empty then solid line with color from palette is used (see @ref{Palette and colors}). + +Below I shall show the features of 1D plotting on base of @ref{plot} function. Let us start from sinus plot: +@verbatim +int sample(mglGraph *gr) +{ + mglData y0(50); y0.Modify("sin(pi*(2*x-1))"); + gr->SubPlot(2,2,0); + gr->Plot(y0); gr->Box(); +@end verbatim +Style of line is not specified in @ref{plot} function. So MathGL uses the solid line with first color of palette (this is blue). Next subplot shows array @var{y1} with 2 rows: +@verbatim + gr->SubPlot(2,2,1); + mglData y1(50,2); + y1.Modify("sin(pi*2*x-pi)"); + y1.Modify("cos(pi*2*x-pi)/2",1); + gr->Plot(y1); gr->Box(); +@end verbatim +As previously I did not specify the style of lines. As a result, MathGL again uses solid line with next colors in palette (there are green and red). Now let us plot a circle on the same subplot. The circle is parametric curve @math{x=cos(\pi t), y=sin(\pi t)}. I will set the color of the circle (dark yellow, @samp{Y}) and put marks @samp{+} at point position: +@verbatim + mglData x(50); x.Modify("cos(pi*2*x-pi)"); + gr->Plot(x,y0,"Y+"); +@end verbatim +Note that solid line is used because I did not specify the type of line. The same picture can be achieved by @ref{plot} and @ref{subdata} functions. Let us draw ellipse by orange dash line: +@verbatim + gr->Plot(y1.SubData(-1,0),y1.SubData(-1,1),"q|"); +@end verbatim + +Drawing in 3D space is mostly the same. Let us draw spiral with default line style. Now its color is 4-th color from palette (this is cyan): +@verbatim + gr->SubPlot(2,2,2); gr->Rotate(60,40); + mglData z(50); z.Modify("2*x-1"); + gr->Plot(x,y0,z); gr->Box(); +@end verbatim +Functions @ref{plot} and @ref{subdata} make 3D curve plot but for single array. Use it to put circle marks on the previous plot: +@verbatim + mglData y2(10,3); y2.Modify("cos(pi*(2*x-1+y))"); + y2.Modify("2*x-1",2); + gr->Plot(y2.SubData(-1,0),y2.SubData(-1,1),y2.SubData(-1,2),"bo "); +@end verbatim +Note that line style is empty @samp{ } here. Usage of other 1D plotting functions looks similar: +@verbatim + gr->SubPlot(2,2,3); gr->Rotate(60,40); + gr->Bars(x,y0,z,"r"); gr->Box(); + return 0; +} +@end verbatim + +Surfaces @ref{surf} and other 2D plots (@pxref{2D plotting}) are drown the same simpler as 1D one. The difference is that the string parameter specifies not the line style but the color scheme of the plot (see @ref{Color scheme}). Here I draw attention on 4 most interesting color schemes. There is gray scheme where color is changed from black to white (string @samp{kw}) or from white to black (string @samp{wk}). Another scheme is useful for accentuation of negative (by blue color) and positive (by red color) regions on plot (string @samp{"BbwrR"}). Last one is the popular ``jet'' scheme (string @samp{"BbcyrR"}). + +Now I shall show the example of a surface drawing. At first let us switch lightning on +@verbatim +int sample(mglGraph *gr) +{ + gr->Light(true); gr->Light(0,mglPoint(0,0,1)); +@end verbatim +and draw the surface, considering coordinates x,y to be uniformly distributed in interval @var{Min}*@var{Max} +@verbatim + mglData a0(50,40); + a0.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))"); + gr->SubPlot(2,2,0); gr->Rotate(60,40); + gr->Surf(a0); gr->Box(); +@end verbatim +Color scheme was not specified. So previous color scheme is used. In this case it is default color scheme (``jet'') for the first plot. Next example is a sphere. The sphere is parametrically specified surface: +@verbatim + mglData x(50,40),y(50,40),z(50,40); + x.Modify("0.8*sin(2*pi*x)*sin(pi*y)"); + y.Modify("0.8*cos(2*pi*x)*sin(pi*y)"); + z.Modify("0.8*cos(pi*y)"); + gr->SubPlot(2,2,1); gr->Rotate(60,40); + gr->Surf(x,y,z,"BbwrR");gr->Box(); +@end verbatim +I set color scheme to @code{"BbwrR"} that corresponds to red top and blue bottom of the sphere. + +Surfaces will be plotted for each of slice of the data if @var{nz}>1. Next example draws surfaces for data arrays with @var{nz}=3: +@verbatim + mglData a1(50,40,3); + a1.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))"); + a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*sin(3*pi*(x*y))",1); + a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))",2); + gr->SubPlot(2,2,2); gr->Rotate(60,40); + gr->Alpha(true); + gr->Surf(a1); gr->Box(); +@end verbatim +Note, that it may entail a confusion. However, if one will use density plot then the picture will look better: +@verbatim + gr->SubPlot(2,2,3); gr->Rotate(60,40); + gr->Dens(a1); gr->Box(); + return 0; +} +@end verbatim + +Drawing of other 2D plots is analogous. The only peculiarity is the usage of flag @samp{#}. By default this flag switches on the drawing of a grid on plot (@ref{grid} or @ref{mesh} for plots in plain or in volume). However, for isosurfaces (including surfaces of rotation @ref{axial}) this flag switches the face drawing off and figure becomes wired. The following code gives example of flag @samp{#} using (compare with normal function drawing as in its description): +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); gr->Light(0,mglPoint(0,0,1)); + mglData a(30,20); + a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))"); + + gr->SubPlot(2,2,0); gr->Rotate(40,60); + gr->Surf(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(40,60); + gr->Dens(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(40,60); + gr->Cont(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(40,60); + gr->Axial(a,"BbcyrR#"); gr->Box(); + return 0; +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node 1D samples, 2D samples, Data plotting, Examples +@section 1D samples +@nav{} + +This section is devoted to visualization of 1D data arrays. 1D means the data which depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0) +{ + register long i,n=50; + if(y) y->Create(n,3); + if(x1) x1->Create(n); if(x2) x2->Create(n); + if(y1) y1->Create(n); if(y2) y2->Create(n); + mreal xx; + for(i=0;ia[i] = 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx); + y->a[i+n] = sin(2*M_PI*xx); + y->a[i+2*n] = cos(2*M_PI*xx); + } + if(y1) y1->a[i] = 0.5+0.3*cos(2*M_PI*xx); + if(y2) y2->a[i] = 0.3*sin(2*M_PI*xx); + if(x1) x1->a[i] = xx*2-1; + if(x2) x2->a[i] = 0.05+0.03*cos(2*M_PI*xx); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare1d(HMDT y, HMDT y1=0, HMDT y2=0, HMDT x1=0, HMDT x2=0) +{ + register long i,n=50; + if(y) mgl_data_create(y,n,3,1); + if(x1) mgl_data_create(x1,n,1,1); + if(x2) mgl_data_create(x2,n,1,1); + if(y1) mgl_data_create(y1,n,1,1); + if(y2) mgl_data_create(y2,n,1,1); + mreal xx; + for(i=0;iSetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)"); + gr->Box(); gr->Plot(y); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style; 'rgb' palette"); + gr->Box(); gr->Plot(y,"o!rgb"); + + gr->SubPlot(2,2,3,""); gr->Title("just markers"); + gr->Box(); gr->Plot(y," +"); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Plot(xc,yc,z,"rs"); + return 0; +} +@end verbatim + +@pfig{plot, Example of Plot()} + + +@c ------------------------------------------------------------------ +@external{} +@node Radar sample, Step sample, Plot sample, 1D samples +@subsection Radar sample +@nav{} + +Function @ref{radar} plot is variant of @code{Plot} one, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use @ref{Curvilinear coordinates} or @code{Plot} in parabolic form with @code{x=r*cos(fi); y=r*sin(fi);}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData yr(10,3); yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd"); + gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')"); + gr->Radar(yr,"#"); + return 0; +} +@end verbatim + +@pfig{radar, Example of Radar()} + +@c ------------------------------------------------------------------ +@external{} +@node Step sample, Tens sample, Radar sample, 1D samples +@subsection Step sample +@nav{} + +Function @ref{step} plot data as stairs. It have the same options as @code{Plot}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + + gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)"); + gr->Box(); gr->Step(y); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Step(xc,yc,z,"r"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Step(y,"s!rgb"); + return 0; +} +@end verbatim + +@pfig{step, Example of Step()} + +@c ------------------------------------------------------------------ +@external{} +@node Tens sample, Area sample, Step sample, 1D samples +@subsection Tens sample +@nav{} + +Function @ref{tens} is variant of @ref{plot} with smooth coloring along the curves. At this, color is determined as for surfaces (see @ref{Color scheme}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)"); + gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1)); + + gr->SubPlot(2,2,2,""); gr->Title("' ' style"); + gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o "); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Tens(xc,yc,z,z,"s"); + return 0; +} +@end verbatim + +@pfig{tens, Example of Tens()} + +@c ------------------------------------------------------------------ +@external{} +@node Area sample, Region sample, Tens sample, 1D samples +@subsection Area sample +@nav{} + +Function @ref{area} fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)"); + gr->Box(); gr->Area(y); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Area(y,"cbgGyr"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Area(y,"!"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Area(xc,yc,z,"r"); + yc.Modify("-sin(pi*(2*x-1))"); gr->Area(xc,yc,z,"b#"); + return 0; +} +@end verbatim + +@pfig{area, Example of Area()} + +@c ------------------------------------------------------------------ +@external{} +@node Region sample, Stem sample, Area sample, 1D samples +@subsection Region sample +@nav{} + +Function @ref{region} fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)"); + gr->Box(); gr->Region(y1,y2); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Region(y1,y2,"yr"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Region(y1,y2,"!"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,3,""); gr->Title("'i' style"); + gr->Box(); gr->Region(y1,y2,"ir"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + return 0; +} +@end verbatim + +@pfig{region, Example of Region()} + +@c ------------------------------------------------------------------ +@external{} +@node Stem sample, Bars sample, Region sample, 1D samples +@subsection Stem sample +@nav{} + +Function @ref{stem} draw vertical bars. It is most attractive if markers are drawn too. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)"); + gr->Box(); gr->Stem(y); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Stem(xc,yc,z,"rx"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Stem(y,"o!rgb"); + return 0; +} +@end verbatim + +@pfig{stem, Example of Stem()} + +@c ------------------------------------------------------------------ +@external{} +@node Bars sample, Barh sample, Stem sample, 1D samples +@subsection Bars sample +@nav{} + +Function @ref{bars} draw vertical bars. It have a lot of options: bar-above-bar (@samp{a} style), fall like (@samp{f} style), 2 colors for positive and negative values, wired bars (@samp{#} style), 3D variant. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)"); + gr->Box(); gr->Bars(ys); + + gr->SubPlot(3,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Bars(ys,"cbgGyr"); + + gr->SubPlot(3,2,4,""); gr->Title("'\\#' style"); + gr->Box(); gr->Bars(ys,"#"); + + gr->SubPlot(3,2,5); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Bars(xc,yc,z,"r"); + + gr->SetRanges(-1,1,-3,3); + gr->SubPlot(3,2,2,""); gr->Title("'a' style"); + gr->Box(); gr->Bars(ys,"a"); + + gr->SubPlot(3,2,3,""); gr->Title("'f' style"); + gr->Box(); gr->Bars(ys,"f"); + return 0; +} +@end verbatim + +@pfig{bars, Example of Bars()} + +@c ------------------------------------------------------------------ +@external{} +@node Barh sample, Cones sample, Bars sample, 1D samples +@subsection Barh sample +@nav{} + +Function @ref{barh} is the similar to @code{Bars} but draw horizontal bars. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); + gr->Box(); gr->Barh(ys); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Barh(ys,"cbgGyr"); + + gr->SetRanges(-3,3,-1,1); + gr->SubPlot(2,2,2,""); gr->Title("'a' style"); + gr->Box(); gr->Barh(ys,"a"); + + gr->SubPlot(2,2,3,""); gr->Title("'f' style"); + gr->Box(); gr->Barh(ys,"f"); + return 0; +} +@end verbatim + +@pfig{barh, Example of Barh()} + +@c ------------------------------------------------------------------ +@external{} +@node Cones sample, Chart sample, Barh sample, 1D samples +@subsection Cones sample +@nav{} + +Function @ref{cones} is similar to @code{Bars} but draw cones. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->Light(true); gr->SetOrigin(0,0,0); + gr->SubPlot(3,2,0); gr->Title("Cones plot"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys); + + gr->SubPlot(3,2,1); gr->Title("2 colors"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"cbgGyr"); + + gr->SubPlot(3,2,2); gr->Title("'#' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"#"); + + gr->SubPlot(3,2,3); gr->Title("'a' style"); + gr->SetRange('z',-2,2); // increase range since summation can exceed [-1,1] + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"a"); + + gr->SubPlot(3,2,4); gr->Title("'t' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"t"); + + gr->SubPlot(3,2,5); gr->Title("'4' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"4"); + return 0; +} +@end verbatim + +@pfig{cones, Example of Cones()} + +@c ------------------------------------------------------------------ +@external{} +@node Chart sample, BoxPlot sample, Cones sample, 1D samples +@subsection Chart sample +@nav{} + +Function @ref{chart} draw colored boxes with width proportional to data values. Use @samp{ } for empty box. Plot looks most attractive in polar coordinates -- well known pie chart. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ch(7,2); for(int i=0;i<7*2;i++) ch.a[i]=mgl_rnd()+0.1; + gr->SubPlot(2,2,0); gr->Title("Chart plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Chart(ch); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"#"); + + gr->SubPlot(2,2,2); gr->Title("Pie chart; ' ' color"); + gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); + + gr->SubPlot(2,2,3); gr->Title("Ring chart; ' ' color"); + gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); + return 0; +} +@end verbatim + +@pfig{chart, Example of Chart()} + +@c ------------------------------------------------------------------ +@external{} +@node BoxPlot sample, Candle sample, Chart sample, 1D samples +@subsection BoxPlot sample +@nav{} + +Function @ref{boxplot} draw box-and-whisker diagram. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(10,7); a.Modify("(2*rnd-1)^3/2"); + gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot"); + gr->Box(); gr->BoxPlot(a); + return 0; +} +@end verbatim + +@pfig{boxplot, Example of BoxPlot()} + +@c ------------------------------------------------------------------ +@external{} +@node Candle sample, OHLC sample, BoxPlot sample, 1D samples +@subsection Candle sample +@nav{} + +Function @ref{candle} draw candlestick chart. This is a combination of a line-chart and a bar-chart, in that each bar represents the range of price movement over a given time interval. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y(30); gr->Fill(y,"sin(pi*x/2)^2"); + mglData y1(30); gr->Fill(y1,"v/2",y); + mglData y2(30); gr->Fill(y2,"(1+v)/2",y); + gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)"); + gr->SetRange('y',0,1); gr->Box(); gr->Candle(y,y1,y2); + return 0; +} +@end verbatim + +@pfig{candle, Example of Candle()} + +@c ------------------------------------------------------------------ +@external{} +@node OHLC sample, Error sample, Candle sample, 1D samples +@subsection OHLC sample +@nav{} + +Function @ref{ohlc} draw Open-High-Low-Close diagram. This diagram show vertical line for between maximal(high) and minimal(low) values, as well as horizontal lines before/after vertical line for initial(open)/final(close) values of some process. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData o(10), h(10), l(10), c(10); + gr->Fill(o,"0.5*sin(pi*x)"); gr->Fill(c,"0.5*sin(pi*(x+2/9))"); + gr->Fill(l,"0.3*rnd-0.8"); gr->Fill(h,"0.3*rnd+0.5"); + gr->SubPlot(1,1,0,""); gr->Title("OHLC plot"); + gr->Box(); gr->OHLC(o,h,l,c); + return 0; +} +@end verbatim + +@pfig{ohlc, Example of OHLC()} + +@c ------------------------------------------------------------------ +@external{} +@node Error sample, Mark sample, OHLC sample, 1D samples +@subsection Error sample +@nav{} + +Function @ref{error} draw error boxes around the points. You can draw default boxes or semi-transparent symbol (like marker, see @ref{Line styles}). Also you can set individual color for each box. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData x0(10), y0(10), ex0(10), ey0(10); + mreal x; + for(int i=0;i<10;i++) + { + x = i/9.; + x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05; + y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1; + ey0.a[i]=0.2; ex0.a[i]=0.1; + } + + gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"ko"); + + gr->SubPlot(2,2,1,""); gr->Title("'!' style; no e_x"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ey0,"o!rgb"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\@' style"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + for(int i=0;i<10;i++) + gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1), + mglPoint(0.2,0.2,0.2),"bo"); + gr->Axis(); + return 0; +} +@end verbatim + +@pfig{error, Example of Error()} + +Additionally, you can use solid large "marks" instead of error boxes by selecting proper style. +@verbatim +int sample(mglGraph *gr) +{ + mglData x0(10), y0(10), ex(10), ey(10); + for(int i=0;i<10;i++) + { x0.a[i] = mgl_rnd(); y0.a[i] = mgl_rnd(); ey.a[i] = ex.a[i] = 0.1; } + gr->SetRanges(0,1,0,1); gr->Alpha(true); + gr->SubPlot(4,3,0,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#+@"); + gr->SubPlot(4,3,1,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#x@"); + gr->SubPlot(4,3,2,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#s@","alpha 0.5"); + gr->SubPlot(4,3,3,""); gr->Box(); gr->Error(x0,y0,ex,ey,"s@"); + gr->SubPlot(4,3,4,""); gr->Box(); gr->Error(x0,y0,ex,ey,"d@"); + gr->SubPlot(4,3,5,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#d@","alpha 0.5"); + gr->SubPlot(4,3,6,""); gr->Box(); gr->Error(x0,y0,ex,ey,"+@"); + gr->SubPlot(4,3,7,""); gr->Box(); gr->Error(x0,y0,ex,ey,"x@"); + gr->SubPlot(4,3,8,""); gr->Box(); gr->Error(x0,y0,ex,ey,"o@"); + gr->SubPlot(4,3,9,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#o@","alpha 0.5"); + gr->SubPlot(4,3,10,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#.@"); + gr->SubPlot(4,3,11,""); gr->Box(); gr->Error(x0,y0,ex,ey); +} +@end verbatim + +@pfig{error2, Example of Error() with marks} + + +@c ------------------------------------------------------------------ +@external{} +@node Mark sample, TextMark sample, Error sample, 1D samples +@subsection Mark sample +@nav{} + +Function @ref{mark} draw markers at points. It is mostly the same as @code{Plot} but marker size can be variable. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)"); + gr->Box(); gr->Mark(y,y1,"s"); + return 0; +} +@end verbatim + +@pfig{mark, Example of Mark()} + +@c ------------------------------------------------------------------ +@external{} +@node TextMark sample, Label sample, Mark sample, 1D samples +@subsection TextMark sample +@nav{} + +Function @ref{textmark} like @code{Mark} but draw text instead of markers. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)"); + gr->Box(); gr->TextMark(y,y1,"\\gamma","r"); + return 0; +} +@end verbatim + +@pfig{textmark, Example of TextMark()} + +@c ------------------------------------------------------------------ +@external{} +@node Label sample, Table sample, TextMark sample, 1D samples +@subsection Label sample +@nav{} + +Function @ref{label} print text at data points. The string may contain @samp{%x}, @samp{%y}, @samp{%z} for x-, y-, z-coordinates of points, @samp{%n} for point index. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10); ys.Modify("0.8*sin(pi*2*x)+0.2*rnd"); + gr->SubPlot(1,1,0,""); gr->Title("Label plot"); + gr->Box(); gr->Plot(ys," *"); gr->Label(ys,"y=%y"); + return 0; +} +@end verbatim + +@pfig{label, Example of Label()} + +@c ------------------------------------------------------------------ +@external{} +@node Table sample, Tube sample, Label sample, 1D samples +@subsection Table sample +@nav{} + +Function @ref{table} draw table with data values. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SubPlot(2,2,0); gr->Title("Table plot"); + gr->Table(ys,"y_1\ny_2\ny_3"); gr->Box(); + gr->SubPlot(2,2,1); gr->Title("no borders, colored"); + gr->Table(ys,"y_1\ny_2\ny_3","r|"); + gr->SubPlot(2,2,2); gr->Title("no font decrease"); + gr->Table(ys,"y_1\ny_2\ny_3","#"); + gr->SubPlot(2,2,3); gr->Title("manual width, position"); + gr->Table(0.5, 0.95, ys,"y_1\ny_2\ny_3","#", "value 0.7"); gr->Box(); + return 0; +} +@end verbatim + +@pfig{table, Example of Table()} + + +@c ------------------------------------------------------------------ +@external{} +@node Tube sample, Tape sample, Table sample, 1D samples +@subsection Tube sample +@nav{} + +Function @ref{tube} draw tube with variable radius. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1,y2; mgls_prepare1d(&y,&y1,&y2); y1/=20; + gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)"); + gr->Light(true); gr->Box(); gr->Tube(y,0.05); + + gr->SubPlot(2,2,1,""); gr->Title("variable radius"); + gr->Box(); gr->Tube(y,y1); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Tube(y,0.05,"#"); + mglData yc(50), xc(50), z(50); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Tube(xc,yc,z,y2,"r"); + return 0; +} +@end verbatim + +@pfig{tube, Example of Tube()} + + +@c ------------------------------------------------------------------ +@external{} +@node Tape sample, Torus sample, Tube sample, 1D samples +@subsection Tape sample +@nav{} + +Function @ref{tape} draw tapes which rotate around the curve as normal and binormal. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData xc(50), yc(50), z(50); + yc.Modify("sin(pi*(2*x-1))"); + xc.Modify("cos(pi*2*x-pi)"); z.Fill(-1,1); + gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)"); + gr->Box(); gr->Tape(y); gr->Plot(y,"k"); + + gr->SubPlot(2,2,1); gr->Title("3d variant, 2 colors"); + gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"rg"); + + gr->SubPlot(2,2,2); gr->Title("3d variant, x only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); + gr->Tape(xc,yc,z,"xr"); gr->Tape(xc,yc,z,"xr#"); + + gr->SubPlot(2,2,3); gr->Title("3d variant, z only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); + gr->Tape(xc,yc,z,"zg"); gr->Tape(xc,yc,z,"zg#"); + return 0; +} +@end verbatim + +@pfig{tape, Example of Tape()} + + +@c ------------------------------------------------------------------ +@external{} +@node Torus sample, , Tape sample, 1D samples +@subsection Torus sample +@nav{} + +Function @ref{torus} draw surface of the curve rotation. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y1,y2; mgls_prepare1d(0,&y1,&y2); + gr->SubPlot(2,2,0); gr->Title("Torus plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2); + if(mini) return; + + gr->SubPlot(2,2,1); gr->Title("'x' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"x"); + + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"z"); + + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"#"); + return 0; +} +@end verbatim + +@pfig{torus, Example of Torus()} + + +@c ------------------------------------------------------------------ +@external{} +@node 2D samples, 3D samples, 1D samples, Examples +@section 2D samples +@nav{} + +This section is devoted to visualization of 2D data arrays. 2D means the data which depend on 2 indexes (parameters) like matrix z(i,j)=z(x(i),y(j)), i=1...n, j=1...m or in parametric form @{x(i,j),y(i,j),z(i,j)@}. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0) +{ + register long i,j,n=50,m=40,i0; + if(a) a->Create(n,m); if(b) b->Create(n,m); + if(v) { v->Create(9); v->Fill(-1,1); } + mreal x,y; + for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare2d(HMDT a, HMDT b=0, HMDT v=0) +{ + register long i,j,n=50,m=40,i0; + if(a) mgl_data_create(a,n,m,1); + if(b) mgl_data_create(b,n,m,1); + if(v) { mgl_data_create(v,9,1,1); mgl_data_fill(v,-1,1,'x'); } + mreal x,y; + for(i=0;iSubPlot(2,2,0); gr->Title("Surf plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style; meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"#","meshnum 10"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"."); + + gr->SubPlot(2,2,3); gr->Title("parametric form"); + mglData x(50,40),y(50,40),z(50,40); + gr->Fill(x,"0.8*sin(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(y,"0.8*cos(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(z,"0.8*cos(pi*(y+1)/2)"); + gr->Rotate(50,60); gr->Box(); gr->Surf(x,y,z,"BbwrR"); + return 0; +} +@end verbatim + +@pfig{surf, Example of Surf()} + +@c ------------------------------------------------------------------ +@external{} +@node SurfC sample, SurfA sample, Surf sample, 2D samples +@subsection SurfC sample +@nav{} + +Function @ref{surfc} is similar to @ref{surf} but its coloring is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->Title("SurfC plot"); gr->Rotate(50,60); + gr->Light(true); gr->Box(); gr->SurfC(a,b); + return 0; +} +@end verbatim + +@pfig{surfc, Example of SurfC()} + +@c ------------------------------------------------------------------ +@external{} +@node SurfA sample, Mesh sample, SurfC sample, 2D samples +@subsection SurfA sample +@nav{} + +Function @ref{surfa} is similar to @ref{surf} but its transparency is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->Title("SurfA plot"); gr->Rotate(50,60); + gr->Alpha(true); gr->Light(true); + gr->Box(); gr->SurfA(a,b); + return 0; +} +@end verbatim + +@pfig{surfa, Example of SurfA()} + + +@c ------------------------------------------------------------------ +@external{} +@node Mesh sample, Fall sample, SurfA sample, 2D samples +@subsection Mesh sample +@nav{} + +Function @ref{mesh} draw wired surface. You can use @ref{meshnum} for changing number of lines to be drawn. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Mesh plot"); gr->Rotate(50,60); + gr->Box(); gr->Mesh(a); + return 0; +} +@end verbatim + +@pfig{mesh, Example of Mesh()} + +@c ------------------------------------------------------------------ +@external{} +@node Fall sample, Belt sample, Mesh sample, 2D samples +@subsection Fall sample +@nav{} + +Function @ref{fall} draw waterfall surface. You can use @ref{meshnum} for changing number of lines to be drawn. Also you can use @samp{x} style for drawing lines in other direction. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Fall plot"); gr->Rotate(50,60); + gr->Box(); gr->Fall(a); + return 0; +} +@end verbatim + +@pfig{fall, Example of Fall()} + +@c ------------------------------------------------------------------ +@external{} +@node Belt sample, Boxs sample, Fall sample, 2D samples +@subsection Belt sample +@nav{} + +Function @ref{belt} draw surface by belts. You can use @samp{x} style for drawing lines in other direction. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Belt plot"); gr->Rotate(50,60); + gr->Box(); gr->Belt(a); + return 0; +} +@end verbatim + +@pfig{belt, Example of Belt()} + +@c ------------------------------------------------------------------ +@external{} +@node Boxs sample, Tile sample, Belt sample, 2D samples +@subsection Boxs sample +@nav{} + +Function @ref{boxs} draw surface by boxes. You can use @samp{#} for drawing wire plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SetOrigin(0,0,0); gr->Light(true); + gr->SubPlot(2,2,0); gr->Title("Boxs plot (default)"); + gr->Rotate(40,60); gr->Box(); gr->Boxs(a); + + gr->SubPlot(2,2,1); gr->Title("'\\@' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"@"); + + gr->SubPlot(2,2,2); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"#"); + + gr->SubPlot(2,2,3); gr->Title("compare with Tile"); + gr->Rotate(50,60); gr->Box(); gr->Tile(a); + return 0; +} +@end verbatim + +@pfig{boxs, Example of Boxs()} + +@c ------------------------------------------------------------------ +@external{} +@node Tile sample, TileS sample, Boxs sample, 2D samples +@subsection Tile sample +@nav{} + +Function @ref{tile} draw surface by tiles. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Tile plot"); + gr->Rotate(40,60); gr->Box(); gr->Tile(a); + return 0; +} +@end verbatim + +@pfig{tile, Example of Tile()} + +@c ------------------------------------------------------------------ +@external{} +@node TileS sample, Dens sample, Tile sample, 2D samples +@subsection TileS sample +@nav{} + +Function @ref{tiles} is similar to @ref{tile} but tile sizes is determined by another data. This allows one to simulate transparency of the plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->SubPlot(1,1,0,""); gr->Title("TileS plot"); + gr->Box(); gr->TileS(a,b); + return 0; +} +@end verbatim + +@pfig{tiles, Example of TileS()} + + +@c ------------------------------------------------------------------ +@external{} +@node Dens sample, Cont sample, TileS sample, 2D samples +@subsection Dens sample +@nav{} + +Function @ref{dens} draw density plot for surface. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,a1(30,40,3); mgls_prepare2d(&a); + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,0,""); gr->Title("Dens plot (default)"); + gr->Box(); gr->Dens(a); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style; meshnum 10"); + gr->Box(); gr->Dens(a,"#","meshnum 10"); + + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a1); + return 0; +} +@end verbatim + +@pfig{dens, Example of Dens()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont sample, ContF sample, Dens sample, 2D samples +@subsection Cont sample +@nav{} + +Function @ref{cont} draw contour lines for surface. You can select automatic (default) or manual levels for contours, print contour labels, draw it on the surface (default) or at plane (as @code{Dens}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("Cont plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->Cont(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->Cont(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->Cont(a,"_"); + + gr->SubPlot(2,2,3,""); gr->Title("'t' style"); + gr->Box(); gr->Cont(a,"t"); + return 0; +} +@end verbatim + +@pfig{cont, Example of Cont()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF sample, ContD sample, Cont sample, 2D samples +@subsection ContF sample +@nav{} + +Function @ref{contf} draw filled contours. You can select automatic (default) or manual levels for contours. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContF plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContF(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a,"_"); + + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a1); + return 0; +} +@end verbatim + +@pfig{contf, Example of ContF()} + +@c ------------------------------------------------------------------ +@external{} +@node ContD sample, ContV sample, ContF sample, 2D samples +@subsection ContD sample +@nav{} + +Function @ref{contd} is similar to @code{ContF} but with manual contour colors. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContD plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContD(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a,"_"); + + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a1); + return 0; +} +@end verbatim + +@pfig{contd, Example of ContD()} + +@c ------------------------------------------------------------------ +@external{} +@node ContV sample, Axial sample, ContD sample, 2D samples +@subsection ContV sample +@nav{} + +Function @ref{contv} draw vertical cylinders (belts) at contour lines. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContV plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContV(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContV(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContV(a,"_"); + + gr->SubPlot(2,2,3); gr->Title("ContV and ContF"); + gr->Rotate(50,60); gr->Box(); gr->Light(true); + gr->ContV(a); gr->ContF(a); gr->Cont(a,"k"); + return 0; +} +@end verbatim + +@pfig{contv, Example of ContV()} + +@c ------------------------------------------------------------------ +@external{} +@node Axial sample, Grad sample, ContV sample, 2D samples +@subsection Axial sample +@nav{} + +Function @ref{axial} draw surfaces of rotation for contour lines. You can draw wire surfaces (@samp{#} style) or ones rotated in other directions (@samp{x}, @samp{z} styles). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("Axial plot (default)"); + gr->Light(true); gr->Alpha(true); gr->Rotate(50,60); + gr->Box(); gr->Axial(a); + + gr->SubPlot(2,2,1); gr->Title("'x' style;'.' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"x."); + + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"z"); + + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"#"); + return 0; +} +@end verbatim + +@pfig{axial, Example of Axial()} + +@c ------------------------------------------------------------------ +@external{} +@node Grad sample, , Axial sample, 2D samples +@subsection Grad sample +@nav{} + +Function @ref{grad} draw gradient lines for matrix. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(1,1,0,""); gr->Title("Grad plot"); + gr->Box(); gr->Grad(a); gr->Dens(a,"{u8}w{q8}"); + return 0; +} +@end verbatim + +@pfig{grad, Example of Grad()} + + +@c ------------------------------------------------------------------ +@external{} +@node 3D samples, Vector field samples, 2D samples, Examples +@section 3D samples +@nav{} + +This section is devoted to visualization of 3D data arrays. 3D means the data which depend on 3 indexes (parameters) like tensor a(i,j,k)=a(x(i),y(j),x(k)), i=1...n, j=1...m, k=1...l or in parametric form @{x(i,j,k),y(i,j,k),z(i,j,k),a(i,j,k)@}. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare3d(mglData *a, mglData *b=0) +{ + register long i,j,k,n=61,m=50,l=40,i0; + if(a) a->Create(n,m,l); if(b) b->Create(n,m,l); + mreal x,y,z; + for(i=0;ia[i0] = -2*(x*x + y*y + z*z*z*z - z*z - 0.1); + if(b) b->a[i0] = 1-2*tanh((x+y)*(x+y)); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare3d(HMDT a, HMDT b=0) +{ + register long i,j,k,n=61,m=50,l=40,i0; + if(a) mgl_data_create(a,n,m,l); + if(b) mgl_data_create(b,n,m,l); + mreal x,y,z; + for(i=0;iLight(true); gr->Alpha(true); + gr->SubPlot(2,2,0); gr->Title("Surf3 plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"#"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"."); + return 0; +} +@end verbatim + +@pfig{surf3, Example of Surf3()} + +@c ------------------------------------------------------------------ +@external{} +@node Surf3C sample, Surf3A sample, Surf3 sample, 3D samples +@subsection Surf3C sample +@nav{} + +Function @ref{surf3c} is similar to @ref{surf3} but its coloring is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + gr->Title("Surf3C plot"); gr->Rotate(50,60); + gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3C(c,d); + return 0; +} +@end verbatim + +@pfig{surf3c, Example of Surf3C()} + +@c ------------------------------------------------------------------ +@external{} +@node Surf3A sample, Cloud sample, Surf3C sample, 3D samples +@subsection Surf3A sample +@nav{} + +Function @ref{surf3a} is similar to @ref{surf3} but its transparency is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + gr->Title("Surf3A plot"); gr->Rotate(50,60); + gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3A(c,d); + return 0; +} +@end verbatim + +@pfig{surf3a, Example of Surf3A()} + +@c ------------------------------------------------------------------ +@external{} +@node Cloud sample, Dens3 sample, Surf3A sample, 3D samples +@subsection Cloud sample +@nav{} + +Function @ref{cloud} draw cloud-like object which is less transparent for higher data values. Similar plot can be created using many (about 10-20) @code{Surf3A(a,a)} isosurfaces. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->SubPlot(2,2,0); gr->Title("Cloud plot"); + gr->Rotate(50,60); gr->Alpha(true); + gr->Box(); gr->Cloud(c,"wyrRk"); + + gr->SubPlot(2,2,1); gr->Title("'i' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"iwyrRk"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,".wyrRk"); + + gr->SubPlot(2,2,3); gr->Title("meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"wyrRk","meshnum 10"); + return 0; +} +@end verbatim + +@pfig{cloud, Example of Cloud()} + +@c ------------------------------------------------------------------ +@external{} +@node Dens3 sample, Cont3 sample, Cloud sample, 3D samples +@subsection Dens3 sample +@nav{} + +Function @ref{dens3} draw just usual density plot but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Dens3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Dens3(c,"x"); gr->Dens3(c); gr->Dens3(c,"z"); + return 0; +} +@end verbatim + +@pfig{densa, Example of Dens3()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont3 sample, ContF3 sample, Dens3 sample, 3D samples +@subsection Cont3 sample +@nav{} + +Function @ref{cont3} draw just usual contour lines but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Cont3(c,"x"); gr->Cont3(c); gr->Cont3(c,"z"); + return 0; +} +@end verbatim + +@pfig{conta, Example of Cont3()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF3 sample, Dens projection sample, Cont3 sample, 3D samples +@subsection ContF3 sample +@nav{} + +Function @ref{contf3} draw just usual filled contours but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("ContF3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->ContF3(c,"x"); gr->ContF3(c); gr->ContF3(c,"z"); + gr->Cont3(c,"kx"); gr->Cont3(c,"k"); gr->Cont3(c,"kz"); + return 0; +} +@end verbatim + +@pfig{contfa, Example of ContF3()} + +@c ------------------------------------------------------------------ +@external{} +@node Dens projection sample, Cont projection sample, ContF3 sample, 3D samples +@subsection Dens projection sample +@nav{} + +Functions @ref{densz}, @ref{densy}, @ref{densx} draw density plot on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Dens[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->DensX(c.Sum("x"),0,-1); + gr->DensY(c.Sum("y"),0,1); gr->DensZ(c.Sum("z"),0,-1); + return 0; +} +@end verbatim + +@pfig{dens_xyz, Example of DensX() DensY() DensZ()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont projection sample, ContF projection sample, Dens projection sample, 3D samples +@subsection Cont projection sample +@nav{} + +Functions @ref{contz}, @ref{conty}, @ref{contx} draw contour lines on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->ContX(c.Sum("x"),"",-1); + gr->ContY(c.Sum("y"),"",1); gr->ContZ(c.Sum("z"),"",-1); + return 0; +} +@end verbatim + +@pfig{cont_xyz, Example of ContX() ContY() ContZ()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF projection sample, TriPlot and QuadPlot, Cont projection sample, 3D samples +@subsection ContF projection sample +@nav{} + +Functions @ref{contfz}, @ref{contfy}, @ref{contfx}, draw filled contours on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->ContFX(c.Sum("x"),"",-1); + gr->ContFY(c.Sum("y"),"",1); gr->ContFZ(c.Sum("z"),"",-1); + return 0; +} +@end verbatim + +@pfig{contf_xyz, Example of ContFX() ContFY() ContFZ()} + +@c ------------------------------------------------------------------ +@external{} +@node TriPlot and QuadPlot, Dots sample, ContF projection sample, 3D samples +@subsection TriPlot and QuadPlot +@nav{} + +Function @ref{triplot} and @ref{quadplot} draw set of triangles (or quadrangles for @code{QuadPlot}) for irregular data arrays. Note, that you have to provide not only vertexes, but also the indexes of triangles or quadrangles. I.e. perform triangulation by some other library. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mreal q[] = {0,1,2,3, 4,5,6,7, 0,2,4,6, 1,3,5,7, 0,4,1,5, 2,6,3,7}; + mreal xc[] = {-1,1,-1,1,-1,1,-1,1}, yc[] = {-1,-1,1,1,-1,-1,1,1}, zc[] = {-1,-1,-1,-1,1,1,1,1}; + mglData qq(6,4,q), xx(8,xc), yy(8,yc), zz(8,zc); + gr->Light(true); //gr->Alpha(true); + gr->SubPlot(2,2,0); gr->Title("QuadPlot sample"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + gr->SubPlot(2,2,2); gr->Title("QuadPlot coloring"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,yy,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + + mreal t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; + mreal xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; + mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); + gr->SubPlot(2,2,1); gr->Title("TriPlot sample"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,"b"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->SubPlot(2,2,3); gr->Title("TriPlot coloring"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,vv,"cb"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->TriCont(tt,uu,vv,ww,"B"); + return 0; +} +@end verbatim + +@pfig{triplot, Example of TriPlot() and QuadPlot()} + +@c ------------------------------------------------------------------ +@external{} +@node Dots sample, , TriPlot and QuadPlot, 3D samples +@subsection Dots sample +@nav{} + +Function @ref{dots} is another way to draw irregular points. @code{Dots} use color scheme for coloring (see @ref{Color scheme}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + int i, n=1000; + mglData x(n),y(n),z(n); + for(i=0;iTitle("Dots sample"); gr->Rotate(50,60); + gr->Box(); gr->Dots(x,y,z); + return 0; +} +@end verbatim + +@pfig{dots, Example of Dots()} + +@c ------------------------------------------------------------------ +@external{} +@node Vector field samples, Hints, 3D samples, Examples +@section Vector field samples +@nav{} + +Vector field visualization (especially in 3d case) is more or less complex task. MathGL provides 3 general types of plots: vector field itself (@code{Vect}), flow threads (@code{Flow}), and flow pipes with radius proportional to field amplitude (@code{Pipe}). + +However, the plot may look tangly -- there are too many overlapping lines. I may suggest 2 ways to solve this problem. The first one is to change @code{SetMeshNum} for decreasing the number of hachures. The second way is to use the flow thread chart @code{Flow}, or possible many flow thread from manual position (@code{FlowP}). Unfortunately, I don't know any other methods to visualize 3d vector field. If you know any, e-mail me and I shall add it to MathGL. + +Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare2v(mglData *a, mglData *b) +{ + register long i,j,n=20,m=30,i0; + if(a) a->Create(n,m); if(b) b->Create(n,m); + mreal x,y; + for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez) +{ + register long i,j,k,n=10,i0; + if(!ex || !ey || !ez) return; + ex->Create(n,n,n); ey->Create(n,n,n); ez->Create(n,n,n); + mreal x,y,z, r1,r2; + for(i=0;ia[i0]=0.2*x/r1 - 0.2*x/r2; + ey->a[i0]=0.2*y/r1 - 0.2*y/r2; + ez->a[i0]=0.2*(z-0.3)/r1 - 0.2*(z+0.3)/r2; + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare2v(HMDT a, HMDT b) +{ + register long i,j,n=20,m=30,i0; + if(a) mgl_data_create(a,n,m,1); + if(b) mgl_data_create(b,n,m,1); + mreal x,y; + for(i=0;iSubPlot(3,2,0,""); gr->Title("Vect plot (default)"); + gr->Box(); gr->Vect(a,b); + + gr->SubPlot(3,2,1,""); gr->Title("'.' style; '=' style"); + gr->Box(); gr->Vect(a,b,"=."); + + gr->SubPlot(3,2,2,""); gr->Title("'f' style"); + gr->Box(); gr->Vect(a,b,"f"); + + gr->SubPlot(3,2,3,""); gr->Title("'>' style"); + gr->Box(); gr->Vect(a,b,">"); + + gr->SubPlot(3,2,4,""); gr->Title("'<' style"); + gr->Box(); gr->Vect(a,b,"<"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(3,2,5); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Vect(ex,ey,ez); + return 0; +} +@end verbatim + +@pfig{vect, Example of Vect()} + +@c ------------------------------------------------------------------ +@external{} +@node Vect3 sample, Traj sample, Vect sample, Vector field samples +@subsection Vect3 sample +@nav{} + +Function @ref{vect3} draw just usual vector field plot but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,1,0); gr->Title("Vect3 sample"); gr->SetOrigin(0,0,0); + gr->Rotate(50,60); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"x"); gr->Vect3(ex,ey,ez); gr->Vect3(ex,ey,ez,"z"); + + gr->SubPlot(2,1,1); gr->Title("'f' style"); + gr->Rotate(50,60); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"fx"); gr->Vect3(ex,ey,ez,"f");gr->Vect3(ex,ey,ez,"fz"); + gr->Grid3(ex,"Wx"); gr->Grid3(ex,"W"); gr->Grid3(ex,"Wz"); + return 0; +} +@end verbatim + +@pfig{vecta, Example of Vect3()} + +@c ------------------------------------------------------------------ +@external{} +@node Traj sample, Flow sample, Vect3 sample, Vector field samples +@subsection Traj sample +@nav{} + +Function @ref{traj} is 1D analogue of @code{Vect}. It draw vectors from specified points. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData x,y,y1,y2; mgls_prepare1d(&y,&y1,&y2,&x); + gr->SubPlot(1,1,0,""); gr->Title("Traj plot"); + gr->Box(); gr->Plot(x,y); gr->Traj(x,y,y1,y2); + return 0; +} +@end verbatim + +@pfig{traj, Example of Traj()} + + +@c ------------------------------------------------------------------ +@external{} +@node Flow sample, Pipe sample, Traj sample, Vector field samples +@subsection Flow sample +@nav{} + +Function @ref{flow} is another standard way to visualize vector fields -- it draw lines (threads) which is tangent to local vector field direction. MathGL draw threads from edges of bounding box and from central slices. Sometimes it is not most appropriate variant -- you may want to use @code{FlowP} to specify manual position of threads. @code{Flow} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(2,2,0,""); gr->Title("Flow plot (default)"); + gr->Box(); gr->Flow(a,b); + + gr->SubPlot(2,2,1,""); gr->Title("'v' style"); + gr->Box(); gr->Flow(a,b,"v"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Flow(a,b,"#"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Flow(ex,ey,ez); + return 0; +} +@end verbatim + +@pfig{flow, Example of Flow()} + +@c ------------------------------------------------------------------ +@external{} +@node Pipe sample, Dew sample, Flow sample, Vector field samples +@subsection Pipe sample +@nav{} + +Function @ref{pipe} is similar to @ref{flow} but draw pipes (tubes) which radius is proportional to the amplitude of vector field. @code{Pipe} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(2,2,0,""); gr->Title("Pipe plot (default)"); + gr->Light(true); gr->Box(); gr->Pipe(a,b); + + gr->SubPlot(2,2,1,""); gr->Title("'i' style"); + gr->Box(); gr->Pipe(a,b,"i"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Pipe(a,b,"#"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Pipe(ex,ey,ez,"",0.1); + return 0; +} +@end verbatim + +@pfig{pipe, Example of Pipe()} + +@c ------------------------------------------------------------------ +@external{} +@node Dew sample, , Pipe sample, Vector field samples +@subsection Dew sample +@nav{} + +Function @ref{dew} is similar to @code{Vect} but use drops instead of arrows. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(1,1,0,""); gr->Title("Dew plot"); + gr->Box(); gr->Light(true); gr->Dew(a,b); + return 0; +} +@end verbatim + +@pfig{dew, Example of Dew()} + + +@c ------------------------------------------------------------------ +@external{} +@node Hints, FAQ, Vector field samples, Examples +@section Hints +@nav{} + +In this section I've included some small hints and advices for the improving of the quality of plots and for the demonstration of some non-trivial features of MathGL library. In contrast to previous examples I showed mostly the idea but not the whole drawing function. + +@menu +* ``Compound'' graphics:: +* Transparency and lighting:: +* Types of transparency:: +* Axis projection:: +* Adding fog:: +* Lighting sample:: +* Using primitives:: +* STFA sample:: +* Mapping visualization:: +* Making regular data:: +* Making histogram:: +* Nonlinear fitting hints:: +* PDE solving hints:: +* MGL parser using:: +* Using options:: +* ``Templates'':: +* Stereo image:: +* Reduce memory usage:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node ``Compound'' graphics, Transparency and lighting, , Hints +@subsection ``Compound'' graphics +@nav{} + +As I noted above, MathGL functions (except the special one, like Clf()) do not erase the previous plotting but just add the new one. It allows one to draw ``compound'' plots easily. For example, popular Matlab command @code{surfc} can be emulated in MathGL by 2 calls: +@verbatim + Surf(a); + Cont(a, "_"); // draw contours at bottom +@end verbatim +Here @var{a} is 2-dimensional data for the plotting, @code{-1} is the value of z-coordinate at which the contour should be plotted (at the bottom in this example). Analogously, one can draw density plot instead of contour lines and so on. + +Another nice plot is contour lines plotted directly on the surface: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "BbcyrR"); // select 'jet' colormap for the surface + Cont(a, "y"); // and yellow color for contours +@end verbatim +The possible difficulties arise in black&white case, when the color of the surface can be close to the color of a contour line. In that case I may suggest the following code: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "kw"); // select 'gray' colormap for the surface + CAxis(-1,0); // first draw for darker surface colors + Cont(a, "w"); // white contours + CAxis(0,1); // now draw for brighter surface colors + Cont(a, "k"); // black contours + CAxis(-1,1); // return color range to original state +@end verbatim +The idea is to divide the color range on 2 parts (dark and bright) and to select the contrasting color for contour lines for each of part. + +Similarly, one can plot flow thread over density plot of vector field amplitude (this is another amusing plot from Matlab) and so on. The list of compound graphics can be prolonged but I hope that the general idea is clear. + +Just for illustration I put here following sample code: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b,d; mgls_prepare2v(&a,&b); d = a; + for(int i=0;iSubPlot(2,2,1,""); gr->Title("Flow + Dens"); + gr->Flow(a,b,"br"); gr->Dens(d,"BbcyrR"); gr->Box(); + + gr->SubPlot(2,2,0); gr->Title("Surf + Cont"); gr->Rotate(50,60); + gr->Light(true); gr->Surf(a); gr->Cont(a,"y"); gr->Box(); + + gr->SubPlot(2,2,2); gr->Title("Mesh + Cont"); gr->Rotate(50,60); + gr->Box(); gr->Mesh(a); gr->Cont(a,"_"); + + gr->SubPlot(2,2,3); gr->Title("Surf3 + ContF3");gr->Rotate(50,60); + gr->Box(); gr->ContF3(v,c,"z",0); gr->ContF3(v,c,"x"); gr->ContF3(v,c); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->ContF3(v,c,"z",c.nz-1); gr->Surf3(-0.5,c); + return 0; +} +@end verbatim + +@pfig{combined, Example of ``combined'' plots} + +@c ------------------------------------------------------------------ +@external{} +@node Transparency and lighting, Types of transparency, ``Compound'' graphics, Hints +@subsection Transparency and lighting +@nav{} + +Here I want to show how transparency and lighting both and separately change the look of a surface. So, there is code and picture for that: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("default"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a); + + gr->SubPlot(2,2,1); gr->Title("light on"); gr->Rotate(50,60); + gr->Box(); gr->Light(true); gr->Surf(a); + + gr->SubPlot(2,2,3); gr->Title("alpha on; light on"); gr->Rotate(50,60); + gr->Box(); gr->Alpha(true); gr->Surf(a); + + gr->SubPlot(2,2,2); gr->Title("alpha on"); gr->Rotate(50,60); + gr->Box(); gr->Light(false); gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{alpha, Example of transparency and lightings} + +@c ------------------------------------------------------------------ +@external{} +@node Types of transparency, Axis projection, Transparency and lighting, Hints +@subsection Types of transparency +@nav{} + +MathGL library has advanced features for setting and handling the surface transparency. The simplest way to add transparency is the using of function @ref{alpha}. As a result, all further surfaces (and isosurfaces, density plots and so on) become transparent. However, their look can be additionally improved. + +The value of transparency can be different from surface to surface. To do it just use @code{SetAlphaDef} before the drawing of the surface, or use option @code{alpha} (see @ref{Command options}). If its value is close to 0 then the surface becomes more and more transparent. Contrary, if its value is close to 1 then the surface becomes practically non-transparent. + +Also you can change the way how the light goes through overlapped surfaces. The function @code{SetTranspType} defines it. By default the usual transparency is used (@samp{0}) -- surfaces below is less visible than the upper ones. A ``glass-like'' transparency (@samp{1}) has a different look -- each surface just decreases the background light (the surfaces are commutable in this case). + +A ``neon-like'' transparency (@samp{2}) has more interesting look. In this case a surface is the light source (like a lamp on the dark background) and just adds some intensity to the color. At this, the library sets automatically the black color for the background and changes the default line color to white. + +As example I shall show several plots for different types of transparency. The code is the same except the values of @code{SetTranspType} function: +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); + mglData a; mgls_prepare2d(&a); + gr->SetTranspType(0); gr->Clf(); + gr->SubPlot(2,2,0); gr->Rotate(50,60); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(50,60); gr->Dens(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(50,60); gr->Cont(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(50,60); gr->Axial(a); gr->Box(); + return 0; +} +@end verbatim + +@pfig{type0, Example of @code{SetTranspType(0)}.} +@pfig{type1, Example of @code{SetTranspType(1)}.} +@pfig{type2, Example of @code{SetTranspType(2)}.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis projection, Adding fog, Types of transparency, Hints +@subsection Axis projection +@nav{} + +You can easily make 3D plot and draw its x-,y-,z-projections (like in CAD) by using @ref{ternary} function with arguments: 4 for Cartesian, 5 for Ternary and 6 for Quaternary coordinates. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + gr->Title("Projection sample"); + gr->Ternary(4); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"X",1); gr->Label('y',"Y",1); gr->Label('z',"Z",1); +} +@end verbatim + +@pfig{projection, Example of axis projections} +@pfig{projection5, Example of ternary axis projections} +@c @pfig{projection6, Example of quaternary axis projections} + +@c ------------------------------------------------------------------ +@external{} +@node Adding fog, Lighting sample, Axis projection, Hints +@subsection Adding fog +@nav{} + +MathGL can add a fog to the image. Its switching on is rather simple -- just use @ref{fog} function. There is the only feature -- fog is applied for whole image. Not to particular subplot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Fog sample"); + gr->Light(true); gr->Rotate(50,60); gr->Fog(1); gr->Box(); + gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{fog, Example of @code{Fog()}.} + +@c ------------------------------------------------------------------ +@external{} +@node Lighting sample, Using primitives, Adding fog, Hints +@subsection Lighting sample +@nav{} + +In contrast to the most of other programs, MathGL supports several (up to 10) light sources. Moreover, the color each of them can be different: white (this is usual), yellow, red, cyan, green and so on. The use of several light sources may be interesting for the highlighting of some peculiarities of the plot or just to make an amusing picture. Note, each light source can be switched on/off individually. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Several light sources"); + gr->Rotate(50,60); gr->Light(true); + gr->AddLight(1,mglPoint(0,1,0),'c'); + gr->AddLight(2,mglPoint(1,0,0),'y'); + gr->AddLight(3,mglPoint(0,-1,0),'m'); + gr->Box(); gr->Surf(a,"h"); + return 0; +} +@end verbatim + +@pfig{several_light, Example of several light sources.} + +Additionally, you can use local light sources and set to use diffise reflection instead of specular one (by default) or both kinds. +@verbatim +int sample(mglGraph *gr) +{ + // use Quality=6 because need lighting in placed + int qual = gr->GetQuality(); + gr->Light(true); gr->SetQuality(6); + + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("Default"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(-1,-0.7,1.7),mglPoint(-1,-0.7,0.7),"BA"); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1)); + gr->SubPlot(2,2,1); gr->Title("Local"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0); + gr->SubPlot(2,2,2); gr->Title("no diffuse"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0.5); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1),'w',0); + gr->SubPlot(2,2,3); gr->Title("diffusive only"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetQuality(qual); +} +@end verbatim + +@pfig{light, Example of different types of lighting.} + +@c ------------------------------------------------------------------ +@external{} +@node Using primitives, STFA sample, Lighting sample, Hints +@subsection Using primitives +@nav{} + +MathGL provide a set of functions for drawing primitives (see @ref{Primitives}). Primitives are low level object, which used by most of plotting functions. Picture below demonstrate some of commonly used primitives. + +@pfig{primitives, Primitives in MathGL.} + +Generally, you can create arbitrary new kind of plot using primitives. For example, MathGL don't provide any special functions for drawing molecules. However, you can do it using only one type of primitives @ref{drop}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); + + gr->SubPlot(2,2,0,""); gr->Title("Methane, CH_4"); + gr->StartGroup("Methane"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"k"); + gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2); + gr->Sphere(mglPoint(0,0,0.7),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g"); + gr->EndGroup(); + + gr->SubPlot(2,2,1,""); gr->Title("Water, H_{2}O"); + gr->StartGroup("Water"); + gr->Rotate(60,100); + gr->StartGroup("Water_O"); + gr->Sphere(mglPoint(0,0,0),0.25,"r"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_1"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_1"); + gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_2"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_2"); + gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g"); + gr->EndGroup(); + gr->EndGroup(); + + gr->SubPlot(2,2,2,""); gr->Title("Oxygen, O_2"); + gr->StartGroup("Oxygen"); + gr->Rotate(60,120); + gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,0.5,0),0.25,"r"); + gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,-0.5,0),0.25,"r"); + gr->EndGroup(); + + gr->SubPlot(2,2,3,""); gr->Title("Ammonia, NH_3"); + gr->StartGroup("Ammonia"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"b"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2); + gr->Sphere(mglPoint(-0.65,0,0),0.25,"g"); + gr->EndGroup(); + return 0; +} +@end verbatim + +@pfig{molecule, Example of molecules drawing.} + +Moreover, some of special plots can be more easily produced by primitives rather than by specialized function. For example, Venn diagram can be produced by @code{Error} plot: +@verbatim +int sample(mglGraph *gr) +{ + double xx[3]={-0.3,0,0.3}, yy[3]={0.3,-0.3,0.3}, ee[3]={0.7,0.7,0.7}; + mglData x(3,xx), y(3,yy), e(3,ee); + gr->Title("Venn-like diagram"); gr->Alpha(true); + gr->Error(x,y,e,e,"!rgb@#o"); + return 0; +} +@end verbatim +You see that you have to specify and fill 3 data arrays. The same picture can be produced by just 3 calls of @ref{circle} function: +@verbatim +int sample(mglGraph *gr) +{ + gr->Title("Venn-like diagram"); gr->Alpha(true); + gr->Circle(mglPoint(-0.3,0.3),0.7,"rr@"); + gr->Circle(mglPoint(0,-0.3),0.7,"gg@"); + gr->Circle(mglPoint( 0.3,0.3),0.7,"bb@"); + return 0; +} +@end verbatim +Of course, the first variant is more suitable if you need to plot a lot of circles. But for few ones the usage of primitives looks easy. + +@pfig{venn, Example of Venn diagram.} + +@c ------------------------------------------------------------------ +@external{} +@node STFA sample, Mapping visualization, Using primitives, Hints +@subsection STFA sample +@nav{} + +Short-time Fourier Analysis (@ref{stfa}) is one of informative method for analyzing long rapidly oscillating 1D data arrays. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. + +MathGL can find and draw STFA result. Just to show this feature I give following sample. Initial data arrays is 1D arrays with step-like frequency. Exactly this you can see at bottom on the STFA plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(2000), b(2000); + gr->Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\ + cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)"); + gr->SubPlot(1, 2, 0,"<_"); gr->Title("Initial signal"); + gr->Plot(a); + gr->Axis(); + gr->Label('x', "\\i t"); + + gr->SubPlot(1, 2, 1,"<_"); gr->Title("STFA plot"); + gr->STFA(a, b, 64); + gr->Axis(); + gr->Label('x', "\\i t"); + gr->Label('y', "\\omega", 0); + return 0; +} +@end verbatim + +@pfig{stfa, Example of STFA().} + +@c ------------------------------------------------------------------ +@external{} +@node Mapping visualization, Making regular data, STFA sample, Hints +@subsection Mapping visualization +@nav{} + +Sometime ago I worked with mapping and have a question about its visualization. Let me remember you that mapping is some transformation rule for one set of number to another one. The 1d mapping is just an ordinary function -- it takes a number and transforms it to another one. The 2d mapping (which I used) is a pair of functions which take 2 numbers and transform them to another 2 ones. Except general plots (like @ref{surfc}, @ref{surfa}) there is a special plot -- Arnold diagram. It shows the area which is the result of mapping of some initial area (usually square). + +I tried to make such plot in @ref{map}. It shows the set of points or set of faces, which final position is the result of mapping. At this, the color gives information about their initial position and the height describes Jacobian value of the transformation. Unfortunately, it looks good only for the simplest mapping but for the real multivalent quasi-chaotic mapping it produces a confusion. So, use it if you like :). + +The sample code for mapping visualization is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(50, 40), b(50, 40); + gr->Puts(mglPoint(0, 0), "\\to", ":C", -1.4); + gr->SetRanges(-1,1,-1,1,-2,2); + + gr->SubPlot(2, 1, 0); + gr->Fill(a,"x"); gr->Fill(b,"y"); + gr->Puts(mglPoint(0, 1.1), "\\{x, y\\}", ":C", -2); gr->Box(); + gr->Map(a, b, "brgk"); + + gr->SubPlot(2, 1, 1); + gr->Fill(a,"(x^3+y^3)/2"); gr->Fill(b,"(x-y)/2"); + gr->Puts(mglPoint(0, 1.1), "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", ":C", -2); + gr->Box(); + gr->Map(a, b, "brgk"); + return 0; +} +@end verbatim + +@pfig{map, Example of Map().} + +@c ------------------------------------------------------------------ +@external{} +@node Making regular data, Making histogram, Mapping visualization, Hints +@subsection Making regular data +@nav{} + +Sometimes, one have only unregular data, like as data on triangular grids, or experimental results and so on. Such kind of data cannot be used as simple as regular data (like matrices). Only few functions, like @ref{dots}, can handle unregular data as is. + +However, one can use built in triangulation functions for interpolating unregular data points to a regular data grids. There are 2 ways. First way, one can use @ref{triangulation} function to obtain list of vertexes for triangles. Later this list can be used in functions like @ref{triplot} or @ref{tricont}. Second way consist in usage of @ref{datagrid} function, which fill regular data grid by interpolated values, assuming that coordinates of the data grid is equidistantly distributed in axis range. Note, you can use options (see @ref{Command options}) to change default axis range as well as in other plotting functions. +@verbatim +int sample(mglGraph *gr) +{ + mglData x(100), y(100), z(100); + gr->Fill(x,"2*rnd-1"); gr->Fill(y,"2*rnd-1"); gr->Fill(z,"v^2-w^2",x,y); + // first way - plot triangular surface for points + mglData d = mglTriangulation(x,y); + gr->Title("Triangulation"); + gr->Rotate(40,60); gr->Box(); gr->Light(true); + gr->TriPlot(d,x,y,z); gr->TriPlot(d,x,y,z,"#k"); + // second way - make regular data and plot it + mglData g(30,30); + gr->DataGrid(g,x,y,z); gr->Mesh(g,"m"); +} +@end verbatim + +@pfig{triangulation, Example of triangulation.} + +@c ------------------------------------------------------------------ +@external{} +@node Making histogram, Nonlinear fitting hints, Making regular data, Hints +@subsection Making histogram +@nav{} + +Using the @ref{hist} function(s) for making regular distributions is one of useful fast methods to process and plot irregular data. @code{Hist} can be used to find some momentum of set of points by specifying weight function. It is possible to create not only 1D distributions but also 2D and 3D ones. Below I place the simplest sample code which demonstrate @ref{hist} usage: +@verbatim +int sample(mglGraph *gr) +{ + mglData x(10000), y(10000), z(10000); gr->Fill(x,"2*rnd-1"); + gr->Fill(y,"2*rnd-1"); gr->Fill(z,"exp(-6*(v^2+w^2))",x,y); + mglData xx=gr->Hist(x,z), yy=gr->Hist(y,z); xx.Norm(0,1); + yy.Norm(0,1); + gr->MultiPlot(3,3,3,2,2,""); gr->SetRanges(-1,1,-1,1,0,1); + gr->Box(); gr->Dots(x,y,z,"wyrRk"); + gr->MultiPlot(3,3,0,2,1,""); gr->SetRanges(-1,1,0,1); + gr->Box(); gr->Bars(xx); + gr->MultiPlot(3,3,5,1,2,""); gr->SetRanges(0,1,-1,1); + gr->Box(); gr->Barh(yy); + gr->SubPlot(3,3,2); + gr->Puts(mglPoint(0.5,0.5),"Hist and\nMultiPlot\nsample","a",-6); + return 0; +} +@end verbatim + +@pfig{hist, Example of Hist().} + + +@c ------------------------------------------------------------------ +@external{} +@node Nonlinear fitting hints, PDE solving hints, Making histogram, Hints +@subsection Nonlinear fitting hints +@nav{} + +Nonlinear fitting is rather simple. All that you need is the data to fit, the approximation formula and the list of coefficients to fit (better with its initial guess values). Let me demonstrate it on the following simple example. First, let us use sin function with some random noise: +@verbatim + mglData rnd(100), in(100); //data to be fitted and ideal data + gr->Fill(rnd,"0.4*rnd+0.1+sin(2*pi*x)"); + gr->Fill(in,"0.3+sin(2*pi*x)"); +@end verbatim +and plot it to see that data we will fit +@verbatim + gr->Title("Fitting sample"); + gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); + gr->Axis(); gr->Plot(in, "b"); + gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b"); +@end verbatim + +The next step is the fitting itself. For that let me specify an initial values @var{ini} for coefficients @samp{abc} and do the fitting for approximation formula @samp{a+b*sin(c*x)} +@verbatim + mreal ini[3] = {1,1,3}; + mglData Ini(3,ini); + mglData res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); +@end verbatim +Now display it +@verbatim + gr->Plot(res, "r"); + gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); + gr->PutsFit(mglPoint(0, -1.8), "y = ", "r"); +@end verbatim + +NOTE! the fitting results may have strong dependence on initial values for coefficients due to algorithm features. The problem is that in general case there are several local "optimums" for coefficients and the program returns only first found one! There are no guaranties that it will be the best. Try for example to set @code{ini[3] = @{0, 0, 0@}} in the code above. + +The full sample code for nonlinear fitting is: +@verbatim +int sample(mglGraph *gr) +{ + mglData rnd(100), in(100); + gr->Fill(rnd,"0.4*rnd+0.1+sin(2*pi*x)"); + gr->Fill(in,"0.3+sin(2*pi*x)"); + mreal ini[3] = {1,1,3}; + mglData Ini(3,ini); + + mglData res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); + + gr->Title("Fitting sample"); + gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); + gr->Axis(); gr->Plot(res, "r"); gr->Plot(in, "b"); + gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); + gr->PutsFit(mglPoint(0, -1.8), "y = ", "r"); + gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b"); + return 0; +} +@end verbatim + +@pfig{fit, Example of nonlinear fitting.} + +@c ------------------------------------------------------------------ +@external{} +@node PDE solving hints, MGL parser using, Nonlinear fitting hints, Hints +@subsection PDE solving hints +@nav{} + +Solving of Partial Differential Equations (PDE, including beam tracing) and ray tracing (or finding particle trajectory) are more or less common task. So, MathGL have several functions for that. There are @code{mglRay()} for ray tracing, @code{mglPDE()} for PDE solving, @code{mglQO2d()} for beam tracing in 2D case (see @ref{Global functions}). Note, that these functions take ``Hamiltonian'' or equations as string values. And I don't plan now to allow one to use user-defined functions. There are 2 reasons: the complexity of corresponding interface; and the basic nature of used methods which are good for samples but may not good for serious scientific calculations. + +The ray tracing can be done by @code{mglRay()} function. Really ray tracing equation is Hamiltonian equation for 3D space. So, the function can be also used for finding a particle trajectory (i.e. solve Hamiltonian ODE) for 1D, 2D or 3D cases. The function have a set of arguments. First of all, it is Hamiltonian which defined the media (or the equation) you are planning to use. The Hamiltonian is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z}, time @samp{t} (for particle dynamics) and momentums @samp{p}=@math{p_x}, @samp{q}=@math{p_y}, @samp{v}=@math{p_z}. Next, you have to define the initial conditions for coordinates and momentums at @samp{t}=0 and set the integrations step (default is 0.1) and its duration (default is 10). The Runge-Kutta method of 4-th order is used for integration. +@verbatim + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + mglData r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); +@end verbatim +This example calculate the reflection from linear layer (media with Hamiltonian @samp{p^2+q^2-x-1}=@math{p_x^2+p_y^2-x-1}). This is parabolic curve. The resulting array have 7 columns which contain data for @{x,y,z,p,q,v,t@}. + +The solution of PDE is a bit more complicated. As previous you have to specify the equation as pseudo-differential operator @math{\hat H(x, \nabla)} which is called sometime as ``Hamiltonian'' (for example, in beam tracing). As previously, it is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z} (but not time!), momentums @samp{p}=@math{(d/dx)/i k_0}, @samp{q}=@math{(d/dy)/i k_0} and field amplitude @samp{u}=@math{|u|}. The evolutionary coordinate is @samp{z} in all cases. So that, the equation look like @math{du/dz = ik_0 H(x,y,\hat p, \hat q, |u|)[u]}. Dependence on field amplitude @samp{u}=@math{|u|} allows one to solve nonlinear problems too. For example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. Also you may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{H = Hre+i*Him}). + +Next step is specifying the initial conditions at @samp{z}=@code{Min.z}. The function need 2 arrays for real and for imaginary part. Note, that coordinates x,y,z are supposed to be in specified range [Min, Max]. So, the data arrays should have corresponding scales. Finally, you may set the integration step and parameter k0=@math{k_0}. Also keep in mind, that internally the 2 times large box is used (for suppressing numerical reflection from boundaries) and the equation should well defined even in this extended range. + +Final comment is concerning the possible form of pseudo-differential operator @math{H}. At this moment, simplified form of operator @math{H} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this operator is effectively @math{H = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed for 3D case. + +So, for example let solve the equation for beam deflected from linear layer and absorbed later. The operator will have the form @samp{"p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)"} that correspond to equation @math{ik_0 \partial_z u + \Delta u + x \cdot u + i (x+z)/2 \cdot u = 0}. This is typical equation for Electron Cyclotron (EC) absorption in magnetized plasmas. For initial conditions let me select the beam with plane phase front @math{exp(-48*(x+0.7)^2)}. The corresponding code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,re(128),im(128); + gr->Fill(re,"exp(-48*(x+0.7)^2)"); + a = gr->PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30); + a.Transpose("yxz"); + gr->SubPlot(1,1,0,"<_"); gr->Title("PDE solver"); + gr->SetRange('c',0,1); gr->Dens(a,"wyrRk"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.85), "absorption: (x+z)/2 for x+z>0"); + gr->Puts(mglPoint(0,1.1),"Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0"); + return 0; +} +@end verbatim + +@pfig{pde, Example of PDE solving.} + +The last example is example of beam tracing. Beam tracing equation is special kind of PDE equation written in coordinates accompanied to a ray. Generally this is the same parameters and limitation as for PDE solving but the coordinates are defined by the ray and by parameter of grid width @var{w} in direction transverse the ray. So, you don't need to specify the range of coordinates. @strong{BUT} there is limitation. The accompanied coordinates are well defined only for smooth enough rays, i.e. then the ray curvature @math{K} (which is defined as @math{1/K^2 = (|\ddot r|^2 |\dot r|^2 - (\ddot r, \dot r)^2)/|\dot r|^6}) is much large then the grid width: @math{K>>w}. So, you may receive incorrect results if this condition will be broken. + +You may use following code for obtaining the same solution as in previous example: +@verbatim +int sample(mglGraph *gr) +{ + mglData r, xx, yy, a, im(128), re(128); + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); + gr->SubPlot(1,1,0,"<_"); gr->Title("Beam and ray tracing"); + gr->Plot(r.SubData(0), r.SubData(1), "k"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); + + // now start beam tracing + gr->Fill(re,"exp(-48*x^2)"); + a = mglQO2d(ham, re, im, r, xx, yy, 1, 30); + gr->SetRange('c',0, 1); + gr->Dens(xx, yy, a, "wyrRk"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.85), "absorption: (x+y)/2 for x+y>0"); + gr->Puts(mglPoint(0.7, -0.05), "central ray"); + return 0; +} +@end verbatim + +@pfig{qo2d, Example of beam tracing.} + + +@c ------------------------------------------------------------------ +@external{} +@node MGL parser using, Using options, PDE solving hints, Hints +@subsection MGL parser using +@nav{} + +Sometimes you may prefer to use MGL scripts in yours code. It is simpler (especially in comparison with C/Fortran interfaces) and provide faster way to plot the data with annotations, labels and so on. Class @code{mglParse} (@pxref{mglParse class} parse MGL scripts in C++. It have also the corresponding interface for C/Fortran. + +The key function here is @code{mglParse::Parse()} (or @code{mgl_parse()} for C/Fortran) which execute one command per string. At this the detailed information about the possible errors or warnings is passed as function value. Or you may execute the whole script as long string with lines separated by @samp{\n}. Functions @code{mglParse::Execute()} and @code{mgl_parse_text()} perform it. Also you may set the values of parameters @samp{$0}...@samp{$9} for the script by functions @code{mglParse::AddParam()} or @code{mgl_add_param()}, allow/disable picture resizing, check ``once'' status and so on. The usage is rather straight-forward. + +The only non-obvious thing is data transition between script and yours program. There are 2 stages: add or find variable; and set data to variable. In C++ you may use functions @code{mglParse::AddVar()} and @code{mglParse::FindVar()} which return pointer to @code{mglData}. In C/Fortran the corresponding functions are @code{mgl_add_var()}, @code{mgl_find_var()}. This data pointer is valid until next @code{Parse()} or @code{Execute()} call. Note, you @strong{must not delete or free} the data obtained from these functions! + +So, some simple example at the end. Here I define a data array, create variable, put data into it and plot it. The C++ code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + gr->Title("MGL parser sample"); + mreal a[100]; // let a_i = sin(4*pi*x), x=0...1 + for(int i=0;i<100;i++)a[i]=sin(4*M_PI*i/99); + mglParse *parser = new mglParse; + mglData *d = parser->AddVar("dat"); + d->Set(a,100); // set data to variable + parser->Execute(gr, "plot dat; xrange 0 1\nbox\naxis"); + // you may break script at any line do something + // and continue after that + parser->Execute(gr, "xlabel 'x'\nylabel 'y'\nbox"); + // also you may use cycles or conditions in script + parser->Execute(gr, "for $0 -1 1 0.1\nif $0<0\n" + "line 0 0 -1 $0 'r':else:line 0 0 -1 $0 'g'\n" + "endif\nnext"); + delete parser; + return 0; +} +@end verbatim +The code in C/Fortran looks practically the same: +@verbatim +int sample(HMGL gr) +{ + mgl_title(gr, "MGL parser sample", "", -2); + double a[100]; // let a_i = sin(4*pi*x), x=0...1 + int i; + for(i=0;i<100;i++) a[i]=sin(4*M_PI*i/99); + HMPR parser = mgl_create_parser(); + HMDT d = mgl_parser_add_var(parser, "dat"); + mgl_data_set_double(d,a,100,1,1); // set data to variable + mgl_parse_text(gr, parser, "plot dat; xrange 0 1\nbox\naxis"); + // you may break script at any line do something + // and continue after that + mgl_parse_text(gr, parser, "xlabel 'x'\nylabel 'y'"); + // also you may use cycles or conditions in script + mgl_parse_text(gr, parser, "for $0 -1 1 0.1\nif $0<0\n" + "line 0 0 -1 $0 'r':else:line 0 0 -1 $0 'g'\n" + "endif\nnext"); + mgl_write_png(gr, "test.png", ""); // don't forgot to save picture + return 0; +} +@end verbatim + +@pfig{parser, Example of MGL script parsing.} + +@c ------------------------------------------------------------------ +@external{} +@node Using options, ``Templates'', MGL parser using, Hints +@subsection Using options +@nav{} + +@ref{Command options} allow the easy setup of the selected plot by changing global settings only for this plot. Often, options are used for specifying the range of automatic variables (coordinates). However, options allows easily change plot transparency, numbers of line or faces to be drawn, or add legend entries. The sample function for options usage is: +@verbatim +void template(mglGraph *gr) +{ + mglData a(31,41); + gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)"); + + gr->SubPlot(2,2,0); gr->Title("Options for coordinates"); + gr->Alpha(true); gr->Light(true); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1"); + if(mini) return; + gr->SubPlot(2,2,1); gr->Title("Option 'meshnum'"); + gr->Rotate(40,60); gr->Box(); + gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5"); + gr->SubPlot(2,2,2); gr->Title("Option 'alpha'"); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1; alpha 0.7"); + gr->Surf(a,"b","yrange 0 -1; alpha 0.3"); + gr->SubPlot(2,2,3,"<_"); gr->Title("Option 'legend'"); + gr->FPlot("x^3","r","legend 'y = x^3'"); + gr->FPlot("cos(pi*x)","b","legend 'y = cos \\pi x'"); + gr->Box(); gr->Axis(); gr->Legend(2,""); +} +@end verbatim + +@pfig{mirror, Example of options usage.} + +@c ------------------------------------------------------------------ +@external{} +@node ``Templates'', Stereo image, Using options, Hints +@subsection ``Templates'' +@nav{} + +As I have noted before, the change of settings will influence only for the further plotting commands. This allows one to create ``template'' function which will contain settings and primitive drawing for often used plots. Correspondingly one may call this template-function for drawing simplification. + +For example, let one has a set of points (experimental or numerical) and wants to compare it with theoretical law (for example, with exponent law @math{\exp(-x/2), x \in [0, 20]}). The template-function for this task is: +@verbatim +void template(mglGraph *gr) +{ + mglData law(100); // create the law + law.Modify("exp(-10*x)"); + gr->SetRanges(0,20, 0.0001,1); + gr->SetFunc(0,"lg(y)",0); + gr->Plot(law,"r2"); + gr->Puts(mglPoint(10,0.2),"Theoretical law: e^x","r:L"); + gr->Label('x',"x val."); gr->Label('y',"y val."); + gr->Axis(); gr->Grid("xy","g;"); gr->Box(); +} +@end verbatim +At this, one will only write a few lines for data drawing: +@verbatim + template(gr); // apply settings and default drawing from template + mglData dat("fname.dat"); // load the data + // and draw it (suppose that data file have 2 columns) + gr->Plot(dat.SubData(0),dat.SubData(1),"bx "); +@end verbatim +A template-function can also contain settings for font, transparency, lightning, color scheme and so on. + +I understand that this is obvious thing for any professional programmer, but I several times receive suggestion about ``templates'' ... So, I decide to point out it here. + +@c ------------------------------------------------------------------ +@external{} +@node Stereo image, Reduce memory usage, ``Templates'', Hints +@subsection Stereo image +@nav{} + +One can easily create stereo image in MathGL. Stereo image can be produced by making two subplots with slightly different rotation angles. The corresponding code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Light(true); + + gr->SubPlot(2,1,0); gr->Rotate(50,60+1); + gr->Box(); gr->Surf(a); + + gr->SubPlot(2,1,1); gr->Rotate(50,60-1); + gr->Box(); gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{stereo, Example of stereo image.} + +@c ------------------------------------------------------------------ +@external{} +@node Reduce memory usage, , Stereo image, Hints +@subsection Reduce memory usage +@nav{} + +By default MathGL save all primitives in memory, rearrange it and only later draw them on bitmaps. Usually, this speed up drawing, but may require a lot of memory for plots which contain a lot of faces (like @ref{cloud}, @ref{dew}). You can use @ref{quality} function for setting to use direct drawing on bitmap and bypassing keeping any primitives in memory. This function also allow you to decrease the quality of the resulting image but increase the speed of the drawing. + +The code for lowest memory usage looks like this: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetQuality(6); // firstly, set to draw directly on bitmap + for(i=0;i<1000;i++) + gr->Sphere(mglPoint(mgl_rnd()*2-1,mgl_rnd()*2-1),0.05); + return 0; +} +@end verbatim + +@c ================================================================== +@external{} +@node FAQ, , Hints, Examples +@section FAQ +@nav{} + +@table @strong +@item The plot does not appear +Check that points of the plot are located inside the bounding box and resize the bounding box using @ref{ranges} function. Check that the data have correct dimensions for selected type of plot. Be sure that @code{Finish()} is called after the plotting functions (or be sure that the plot is saved to a file). Sometimes the light reflection from flat surfaces (like, @ref{dens}) can look as if the plot were absent. + +@item I can not find some special kind of plot. +Most ``new'' types of plots can be created by using the existing drawing functions. For example, the surface of curve rotation can be created by a special function @ref{torus}, or as a parametrically specified surface by @ref{surf}. See also, @ref{Hints}. If you can not find a specific type of plot, please e-mail me and this plot will appear in the next version of MathGL library. + +@item Should I know some graphical libraries (like OpenGL) before using the MathGL library? +No. The MathGL library is self-contained and does not require the knowledge of external libraries. + +@item In which language is the library written? For which languages does it have an interface? +The core of the MathGL library is written in C++. But there are interfaces for: pure C, Fortran, Pascal, Forth, and its own command language MGL. Also there is a large set of interpreted languages, which are supported (Python, Java, ALLEGROCL, CHICKEN, Lisp, CFFI, C#, Guile, Lua, Modula 3, Mzscheme, Ocaml, Octave, Perl, PHP, Pike, R, Ruby, Tcl). These interfaces are written using SWIG (both pure C functions and classes) but only the interface for Python and Octave is included in the build system. The reason is that I don't know any other interpreted languages :(. Note that most other languages can use (link to) the pure C functions. + +@item How can I use MathGL with Fortran? +You can use MathGL as is with @code{gfortran} because it uses by default the AT&T notation for external functions. For other compilers (like Visual Fortran) you have to switch on the AT&T notation manually. The AT&T notation requires that the symbol @samp{_} is added at the end of each function name, function argument(s) is passed by pointers and the string length(s) is passed at the end of the argument list. For example: + +@emph{C function} -- @code{void mgl_fplot(HMGL graph, const char *fy, const char *stl, int n);} + +@emph{AT&T function} -- @code{void mgl_fplot_(uintptr_t *graph, const char *fy, const char *stl, int *n, int ly, int ls);} + +Fortran users also should add C++ library by the option @code{-lstdc++}. If library was built with @code{enable-double=ON} (this default for v.2.1 and later) then all real numbers must be @code{real*8}. You can make it automatic if use option @code{-fdefault-real-8}. + +@item How can I print in Russian/Spanish/Arabic/Japanese, and so on? +The standard way is to use Unicode encoding for the text output. But the MathGL library also has interface for 8-bit (char *) strings with internal conversion to Unicode. This conversion depends on the current locale OS. You may change it by @code{setlocale()} function. For example, for Russian text in CP1251 encoding you may use @code{setlocale(LC_CTYPE, "ru_RU.cp1251");} (under MS Windows the name of locale may differ -- @code{setlocale(LC_CTYPE, "russian_russia.1251")}). I strongly recommend not to use the constant @code{LC_ALL} in the conversion. Since it also changes the number format, it may lead to mistakes in formula writing and reading of the text in data files. For example, the program will await a @samp{,} as a decimal point but the user will enter @samp{.}. + +@item How can I exclude a point or a region of plot from the drawing? +There are 3 general ways. First, the point with @code{NAN} value as one of the coordinates (including color/alpha range) will never be plotted. Second, special functions @code{SetCutBox}() and @code{CutOff}() define the condition when the points should be omitted (see @ref{Cutting}). Last, you may change the transparency of a part of the plot by the help of functions @ref{surfa}, @ref{surf3a} (see @ref{Dual plotting}). In last case the transparency is switched on smoothly. + +@item I use VisualStudio, CBuilder or some other compiler (not MinGW/gcc). How can I link the MathGL library? +In version 2.0, main classes (@code{mglGraph} and @code{mglData}) contains only @code{inline} functions and are acceptable for any compiler with the same binary files. However, if you plan to use widget classes (QMathGL, Fl_MathGL, ...) or to access low-level features (mglBase, mglCanvas, ...) then you have to recompile MathGL by yours compiler. + +Note, that you have to make import library(-ies) *.lib for provided binary *.dll. This procedure depend on used compiler -- please read documentation for yours compiler. For VisualStudio, it can be done by command @code{lib.exe /DEF:libmgl.def /OUT:libmgl.lib}. + +@item How make FLTK/GLUT/Qt window which will display result of my calculations? + +You need to put yours calculations or main event-handling loop in the separate thread. For static image you can give @code{NULL} as drawing function and call @code{Update()} function when you need to redraw it. For more details see @ref{Animation}. + +@item How I can build MathGL under Windows? +Generally, it is the same procedure as for Linux or MacOS -- see section @ref{Installation}. The simplest way is using the combination CMake+MinGW. Also you may need some extra libraries like GSL, PNG, JPEG and so on. All of them can be found at @url{http://gnuwin32.sourceforge.net/packages.html}. After installing all components, just run @uref{http://www.cmake.org/cmake/help/runningcmake.html, cmake-gui} configurator and build the MathGL itself. + +@item How many people write this library? +Most of the library was written by one person. This is a result of nearly a year of work (mostly in the evening and on holidays): I spent half a year to write the kernel and half a year to a year on extending, improving the library and writing documentation. This process continues now :). The build system (cmake files) was written mostly by D.Kulagin, and the export to PRC/PDF was written mostly by M.Vidassov. + +@item How can I display a bitmap on the figure? +You can import data into a @code{mglData} instance by function @ref{import} and display it by @ref{dens} function. For example, for black-and-white bitmap you can use the code: @code{mglData bmp; bmp.Import("fname.png","wk"); gr->Dens(bmp,"wk");}. + +@item How can I use MathGL in Qt, FLTK, wxWidgets etc.? +There are special classes (widgets) for these libraries: QMathGL for Qt, Fl_MathGL for FLTK and so on. If you don't find the appropriate class then you can create your own widget that displays a bitmap using mglCanvas::GetRGB(). + +@item How can I create 3D in PDF? +Just use @code{WritePRC}() method which also create PDF file if enable-pdf=ON at MathGL configure. + +@item How can I create TeX figure? +Just use @code{WriteTEX}() method which create LaTeX files with figure itself @samp{@var{fname}.tex}, with MathGL colors @samp{mglcolors.tex} and main file @samp{mglmain.tex}. Last one can be used for viewing image by command like @code{pdflatex mglmain.tex}. + +@item Can I use MathGL in JavaScript? +Yes, sample JavaScript file is located in texinfo/ folder of sources. You should provide JSON data with 3d image for it (can be created by @code{WriteJSON}() method). Script allows basic manipulation with plot: zoom, rotation, shift. Sample of JavaScript pictures can be found in @url{http://mathgl.sf.net/json.html}. + + + + +@item How I can change the font family? +First, you should download new font files from @uref{http://mathgl.sourceforge.net/download.html, here} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. Next, you should load the font files into mglGraph class instance @var{gr} by the following command: @code{gr->LoadFont(fontname,path);}. Here @var{fontname} is the base font name like @samp{STIX} and @var{path} sets the location of font files. Use @code{gr->RestoreFont();} to start using the default font. + +@item How can I draw tick out of a bounding box? +Just set a negative value in @ref{ticklen}. For example, use @code{gr->SetTickLen(-0.1);}. + +@item How can I prevent text rotation? +Just use @code{SetRotatedText(false)}. Also you can use axis style @samp{U} for disable only tick labels rotation. + +@item What is @code{*.so}? What is @code{gcc}? How I can use @code{make}? +They are standard GNU tools. There is special FAQ about its usage under Windows -- @uref{http://www.mingw.org/wiki/FAQ}. + +@item How can I draw equal axis range even for rectangular image? +Just use @code{Aspect(NAN,NAN)} for each subplot, or at the beginning of the drawing. + + +@end table + +@external{} diff --git a/texinfo/example_ru.texi b/texinfo/example_ru.texi new file mode 100644 index 0000000..f6001f1 --- /dev/null +++ b/texinfo/example_ru.texi @@ -0,0 +1,4138 @@ +@c ------------------------------------------------------------------ +@chapter Примеры MathGL +@nav{} + +В данной главе рассмотрены базовые и продвинутые возможности MathGL, даны советы по использованию и примеры для всех типов графиков. Я рекомендую прочитать вначале первые 2 раздела и посмотреть на раздел @ref{Hints}. Также рекомендую прочитать @ref{General concepts} и @ref{FAQ}. + +Отмечу, что MathGL v.2.* имеет только пользовательских 2 интерфейса: один для языков подобных C или Fortran (не поддерживающих классы), другой для языков подобных C++/Python/Octave, которые поддерживают классы. При этом все классы являются "оберткой" С-ого интерфейсы, а функции-члены классов -- inline вызовами функций С. Поэтому, в большинстве примеров в этой главе я буду приводить только один вариант кода, который после минимальных изменений синтаксиса может быть применен для других языков. Например, код на языке C++ +@verbatim +#include +int main() +{ + mglGraph gr; + gr.FPlot("sin(pi*x)"); + gr.WriteFrame("test.png"); +} +@end verbatim +на Python будет выглядеть как +@verbatim +from mathgl import * +gr = mglGraph(); +gr.FPlot("sin(pi*x)"); +gr.WriteFrame("test.png"); +@end verbatim +в Octave он будет почти тем же +@verbatim +gr = mglGraph(); +gr.FPlot("sin(pi*x)"); +gr.WriteFrame("test.png"); +@end verbatim +в C необходимо будет найти С-ые аналоги функций (из документации) и указать все их аргументы явно +@verbatim +#include +int main() +{ + HMGL gr = mgl_create_graph(600,400); + mgl_fplot(gr,"sin(pi*x)","",""); + mgl_write_frame(gr,"test.png",""); + mgl_delete_graph(gr); +} +@end verbatim +в Fortran помимо этого придется определить функции возвращающие указатели на объекты как функции возвращающие целое +@verbatim +integer gr, mgl_create_graph +gr = mgl_create_graph(600,400); +call mgl_fplot(gr,'sin(pi*x)','',''); +call mgl_write_frame(gr,'test.png',''); +call mgl_delete_graph(gr); +@end verbatim +и т.д. + + + +@menu +* Basic usage:: +* Advanced usage:: +* Data handling:: +* Data plotting:: +* 1D samples:: +* 2D samples:: +* 3D samples:: +* Vector field samples:: +* Hints:: +* FAQ:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Basic usage, Advanced usage, , Examples +@section Основы использования +@nav{} + +Библиотеку MathGL можно использовать несколькими способами, каждый из которых имеет свои достоинства и недостатки: +@itemize @bullet +@item +@emph{Использовать возможности MathGL для создания графического окна (требуется FLTK, Qt или GLUT библиотеки).} + +Положительная сторона состоит в возможности сразу увидеть график и быстро его мышкой поправить (повернуть, приблизить, выключить прозрачность или освещение и т.д.). Однако, в этом случае требуется наличие графической системы (нельзя запускать на удаленной машине), и работать можно только с одним набором данных одновременно. + +@item +@emph{Прямой вывод в файл в растровом или векторном формате, без создания графического окна.} + +Достоинства такого подхода: пакетная обработка похожих данных (например, набора расчетных файлов при различных условиях), возможность запуска из консольной программы (включая запуск на удаленном компьютере/сервере/кластере), более быстрая и автоматизированная отрисовка, сохранение графиков для последующего анализа непосредственно во время расчета. К недостаткам подхода можно отнести: использование внешней программы просмотра для построенных графиков, необходимость заранее представить картинку (углы просмотра, освещение и пр.). Я рекомендую вначале использовать графическое окно для выбора оптимальных параметров графика, а потом использовать их для пакетной обработки. + +@item +@emph{Рисовать график в памяти с последующим выводом на экран другой графической программой.} + +В этом случае программист имеет максимум свободы в выборе графической библиотеки (не только FLTK, Qt или GLUT), в расположении и выборе элементов управления графиком и т.д. Я рекомендую этот вариант для "самодостаточного" приложения. + +@item +@emph{Использовать FLTK или Qt виджеты, предоставляемые MathGL} + +Вы также можете использовать ряд элементов управления (виджетов), которые позволяют отобразить график, сохранить его в файл в различных форматах или скопировать в буфер обмена, обработать движение/клики мышкой и пр. +@end itemize + +Графики MathGL могут быть созданы не только с помощью объектно-ориентированных языков (например, C++ или Python), но и на C или Fortran подобных языках. Использование последних в основном идентичны использованию классов (за исключением различных имен функций). Различие состоит в обязательном предварительном создании (и удалении после использования) объектов типа HMGL (для графики) и/или HMDT (для данных). Пользователи Fortran могут считать эти переменные целочисленными с достаточной разрядностью для используемой операционной системы. + +Рассмотрим вышесказанное подробно. + +@menu +* Using MathGL window:: +* Drawing to file:: +* Animation:: +* Drawing in memory:: +* Using QMathGL:: +* MathGL and PyQt:: +* MathGL and MPI:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node Using MathGL window, Drawing to file, , Basic usage +@subsection Использование окон MathGL +@nav{} +@cindex window +@cindex widgets + +``Интерактивный'' способ использования MathGL состоит в создании окна с помощью классов @code{mglQT}, @code{mglFLTK} или @code{mglGLUT} (см. @ref{Widget classes}) и последующем рисовании в этом окне. Соответствующий код выглядит так: +@verbatim +#include +int sample(mglGraph *gr) +{ + gr->Rotate(60,40); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + mglQT gr(sample,"MathGL examples"); + return gr.Run(); +} +@end verbatim +Здесь используется callback функция @code{sample}, выполняющая собственно рисование. Функция @code{main} -- точка входа в программу -- создает окно (объект @var{gr} типа @code{mglQT}) и запускает цикл обработки сообщений (вызов @code{gr.Run()}). Для компиляции достаточно выполнить команду +@verbatim +gcc test.cpp -lmgl-qt -lmgl +@end verbatim + +Альтернативный способ состоит в использовании класса, производного от @code{mglDraw} с переопределенной функцией @code{Draw()}: +@verbatim +#include +class Foo : public mglDraw +{ +public: + int Draw(mglGraph *gr); +}; +//----------------------------------------------------- +int Foo::Draw(mglGraph *gr) +{ + gr->Rotate(60,40); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + Foo foo; + mglQT gr(&foo,"MathGL examples"); + return gr.Run(); +} +@end verbatim +Или в использовании функций С: +@verbatim +#include +int sample(HMGL gr, void *) +{ + mgl_rotate(gr,60,40,0); + mgl_box(gr); +} +int main(int argc,char **argv) +{ + HMGL gr; + gr = mgl_create_graph_qt(sample,"MathGL examples",0,0); + return mgl_qt_run(); +/* generally I should call mgl_delete_graph() here, + * but I omit it in main() function. */ +} +@end verbatim + +Похожий код получается и при использовании окон @code{mglFLTK}, @code{mglGLUT} (функция @code{sample()} та же): +@verbatim +#include +int main(int argc,char **argv) +{ + mglGLUT gr(sample,"MathGL examples"); + return 0; +} +@end verbatim + +The rotation, shift, zooming, switching on/off transparency and lighting can be done with help of tool-buttons (for @code{mglWindow}) or by hot-keys: @samp{a}, @samp{d}, @samp{w}, @samp{s} for plot rotation, @samp{r} and @samp{f} switching on/off transparency and lighting. Press @samp{x} for exit (or closing the window). + +In this example function @code{sample} rotates axes (@code{Rotate()}, @pxref{Subplots and rotation}) and draws the bounding box (@code{Box()}). Drawing is placed in separate function since it will be used on demand when window canvas needs to be redrawn. + +@c ------------------------------------------------------------------ +@external{} +@node Drawing to file, Animation, Using MathGL window, Basic usage +@subsection Drawing to file +@nav{} + +Another way of using MathGL library is the direct writing of the picture to the file. It is most usable for plot creation during long calculation or for using of small programs (like Matlab or Scilab scripts) for visualizing repetitive sets of data. But the speed of drawing is much higher in comparison with a script language. + +The following code produces a bitmap PNG picture: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + gr.Alpha(true); gr.Light(true); + sample(&gr); // The same drawing function. + gr.WritePNG("test.png"); // Don't forget to save the result! + return 0; +} +@end verbatim + For compilation, you need only libmgl library not the one with widgets +@verbatim +gcc test.cpp -lmgl +@end verbatim +This can be important if you create a console program in computer/cluster where X-server (and widgets) is inaccessible. + +The only difference from the previous variant (using windows) is manual switching on the transparency @code{Alpha} and lightning @code{Light}, if you need it. The usage of frames (see @ref{Animation}) is not advisable since the whole image is prepared each time. If function @code{sample} contains frames then only last one will be saved to the file. In principle, one does not need to separate drawing functions in case of direct file writing in consequence of the single calling of this function for each picture. However, one may use the same drawing procedure to create a plot with changeable parameters, to export in different file types, to emphasize the drawing code and so on. So, in future I will put the drawing in the separate function. + +The code for export into other formats (for example, into vector EPS file) looks the same: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + gr.Light(true); + sample(&gr); // The same drawing function. + gr.WriteEPS("test.eps"); // Don't forget to save the result! + return 0; +} +@end verbatim +The difference from the previous one is using other function @code{WriteEPS()} for EPS format instead of function @code{WritePNG()}. Also, there is no switching on of the plot transparency @code{Alpha} since EPS format does not support it. + +@c ------------------------------------------------------------------ +@external{} +@node Animation, Drawing in memory, Drawing to file, Basic usage +@subsection Animation +@nav{} + +Widget classes (@code{mglWindow}, @code{mglGLUT}) support a delayed drawing, when all plotting functions are called once at the beginning of writing to memory lists. Further program displays the saved lists faster. Resulting redrawing will be faster but it requires sufficient memory. Several lists (frames) can be displayed one after another (by pressing @samp{,}, @samp{.}) or run as cinema. To switch these feature on one needs to modify function @code{sample}: +@verbatim +int sample(mglGraph *gr) +{ + gr->NewFrame(); // the first frame + gr->Rotate(60,40); + gr->Box(); + gr->EndFrame(); // end of the first frame + gr->NewFrame(); // the second frame + gr->Box(); + gr->Axis("xy"); + gr->EndFrame(); // end of the second frame + return gr->GetNumFrame(); // returns the frame number +} +@end verbatim +First, the function creates a frame by calling @code{NewFrame()} for rotated axes and draws the bounding box. The function @code{EndFrame()} @strong{must be} called after the frame drawing! The second frame contains the bounding box and axes @code{Axis("xy")} in the initial (unrotated) coordinates. Function @code{sample} returns the number of created frames @code{GetNumFrame()}. + +Note, that such kind of animation is rather slow and not well suitable for visualization of running calculations. For the last case one can use @code{Update()} function. The most simple case for doing this is running yours calculations firstly in separate thread and later start MathGL window (QT or FLTK) creation. +@verbatim +#include +mglWindow *gr=NULL; +void *calc(void *) +{ + mglPoint pnt; + for(int i=0;i<10;i++) // do calculation + { + sleep(2); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + if(gr) // be sure that window is ready + { + gr->Clf(); // make new drawing + gr->Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr->Puts(mglPoint(),str); + gr->Update(); // update window + } + } + exit(0); +} +int main(int argc,char **argv) +{ + static pthread_t thr; + // first run yours routine in separate thread + pthread_create(&thr,0,calc,0); + pthread_detach(thr); + gr = new mglWindow; + gr->Run(); return 0; +} +@end verbatim +Note, that such method looks as not working for GLUT windows due to limitation of @code{glutMainLoop()} function. + +Another ways use built-in MathGL feature to run a member function @code{mglDraw::Calc()} separate thread, which work only if pthread support is enabled. For this, you just need to use @code{mglDraw} class and reimplement its @code{Calc()} method. +@verbatim +#include +class Foo : public mglDraw +{ + mglPoint pnt; // some result of calculation +public: + mglWindow *Gr; // graphics to be updated + int Draw(mglGraph *gr); + void Calc(); +} foo; +//----------------------------------------------------- +void Foo::Calc() +{ + for(int i=0;i<30;i++) // do calculation + { + sleep(2); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + Gr->Update(); // update window + } +} +//----------------------------------------------------- +int Foo::Draw(mglGraph *gr) +{ + gr->Line(mglPoint(),pnt,"Ar2"); + gr->Box(); + return 0; +} +//----------------------------------------------------- +int main(int argc,char **argv) +{ + mglWindow gr(&foo,"MathGL examples"); + foo.Gr = &gr; foo.Run(); + return gr.Run(); +} +@end verbatim + +Finally, you can put the event-handling loop in separate instead of yours code by using @code{RunThr()} function instead of @code{Run()} one. Unfortunately, such method work well only for FLTK windows and only if pthread support was enabled. Such limitation come from the Qt requirement to be run in the primary thread only. The sample code will be: +@verbatim +#include +int main(int argc,char **argv) +{ + mglFLTK gr("test"); // create window + gr.RunThr(); // run event loop in separate thread + for(int i=0;i<10;i++) // do calculation + { + sleep(1); // which can be very long + pnt = mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1); + gr.Clf(); // make new drawing + gr.Line(mglPoint(),pnt,"Ar2"); + char str[10] = "i=0"; str[2] = '0'+i; + gr.Puts(mglPoint(),str); + gr.Update(); // update window when you need it + } + return 0; // finish calculations and close the window +} +@end verbatim + + +Pictures with @strong{animation can be saved in file(s)} as well. You can: export in animated GIF, or save each frame in separate file (usually JPEG) and convert these files into the movie (for example, by help of ImageMagic). Let me show both methods. + +@anchor{GIF} +The simplest methods is making animated GIF. There are 3 steps: (1) open GIF file by @code{StartGIF()} function; (2) create the frames by calling @code{NewFrame()} before and @code{EndFrame()} after plotting; (3) close GIF by @code{CloseGIF()} function. So the simplest code for ``running'' sinusoid will look like this: +@verbatim +#include +int main(int ,char **) +{ + mglGraph gr; + mglData dat(100); + char str[32]; + gr.StartGIF("sample.gif"); + for(int i=0;i<40;i++) + { + gr.NewFrame(); // start frame + gr.Box(); // some plotting + for(int j=0;j +int main(int ,char **) +{ + mglGraph gr; + mglData dat(100); + char str[32]; + for(int i=0;i<40;i++) + { + gr.NewFrame(); // start frame + gr.Box(); // some plotting + for(int j=0;jGetSize(&x,&y); // gets a height of the toolbar if any + wxPaintDC dc(this); // and draws it + dc.DrawBitmap(wxBitmap(img),0,y); +} +@end verbatim +The drawing in other libraries is most the same. + +For example, FLTK code will look like +@verbatim +void Fl_MyWidget::draw() +{ + mglGraph gr(w(),h()); + gr.Alpha(true); // draws something using MathGL + gr.Light(true); + sample(&gr,NULL); + fl_draw_image(gr.GetRGB(), x(), y(), gr.GetWidth(), gr.GetHeight(), 3); +} +@end verbatim +Qt code will look like +@verbatim +void MyWidget::paintEvent(QPaintEvent *) +{ + mglGraph gr(w(),h()); + + gr.Alpha(true); // draws something using MathGL + gr.Light(true); gr.Light(0,mglPoint(1,0,-1)); + sample(&gr,NULL); + + // Qt don't support RGB format as is. So, let convert it to BGRN. + long w=gr.GetWidth(), h=gr.GetHeight(); + unsigned char *buf = new uchar[4*w*h]; + gr.GetBGRN(buf, 4*w*h) + QPixmap pic = QPixmap::fromImage(QImage(*buf, w, h, QImage::Format_RGB32)); + + QPainter paint; + paint.begin(this); paint.drawPixmap(0,0,pic); paint.end(); + delete []buf; +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node Using QMathGL, MathGL and PyQt, Drawing in memory, Basic usage +@subsection Using QMathGL +@nav{} + +MathGL have several interface widgets for different widget libraries. There are QMathGL for Qt, Fl_MathGL for FLTK. These classes provide control which display MathGL graphics. Unfortunately there is no uniform interface for widget classes because all libraries have slightly different set of functions, features and so on. However the usage of MathGL widgets is rather simple. Let me show it on the example of QMathGL. + +First of all you have to define the drawing function or inherit a class from @code{mglDraw} class. After it just create a window and setup QMathGL instance as any other Qt widget: +@verbatim +#include +#include +#include +#include +int main(int argc,char **argv) +{ + QApplication a(argc,argv); + QMainWindow *Wnd = new QMainWindow; + Wnd->resize(810,610); // for fill up the QMGL, menu and toolbars + Wnd->setWindowTitle("QMathGL sample"); + // here I allow to scroll QMathGL -- the case + // then user want to prepare huge picture + QScrollArea *scroll = new QScrollArea(Wnd); + + // Create and setup QMathGL + QMathGL *QMGL = new QMathGL(Wnd); +//QMGL->setPopup(popup); // if you want to setup popup menu for QMGL + QMGL->setDraw(sample); + // or use QMGL->setDraw(foo); for instance of class Foo:public mglDraw + QMGL->update(); + + // continue other setup (menu, toolbar and so on) + scroll->setWidget(QMGL); + Wnd->setCentralWidget(scroll); + Wnd->show(); + return a.exec(); +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node MathGL and PyQt, MathGL and MPI, Using QMathGL, Basic usage +@subsection MathGL and PyQt +@nav{} + +Generally SWIG based classes (including the Python one) are the same as C++ classes. However, there are few tips for using MathGL with PyQt. Below I place a very simple python code which demonstrate how MathGL can be used with PyQt. This code is mostly written by Prof. Dr. Heino Falcke. You can just copy it to a file @code{mgl-pyqt-test.py} and execute it from python shell by command @code{execfile("mgl-pyqt-test.py")} + +@verbatim +from PyQt4 import QtGui,QtCore +from mathgl import * +import sys +app = QtGui.QApplication(sys.argv) +qpointf=QtCore.QPointF() + +class hfQtPlot(QtGui.QWidget): + def __init__(self, parent=None): + QtGui.QWidget.__init__(self, parent) + self.img=(QtGui.QImage()) + def setgraph(self,gr): + self.buffer='\t' + self.buffer=self.buffer.expandtabs(4*gr.GetWidth()*gr.GetHeight()) + gr.GetBGRN(self.buffer,len(self.buffer)) + self.img=QtGui.QImage(self.buffer, gr.GetWidth(),gr.GetHeight(),QtGui.QImage.Format_ARGB32) + self.update() + def paintEvent(self, event): + paint = QtGui.QPainter() + paint.begin(self) + paint.drawImage(qpointf,self.img) + paint.end() + +BackgroundColor=[1.0,1.0,1.0] +size=100 +gr=mglGraph() +y=mglData(size) +#y.Modify("((0.7*cos(2*pi*(x+.2)*500)+0.3)*(rnd*0.5+0.5)+362.135+10000.)") +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +x=mglData(size) +x.Modify("x^2"); + +def plotpanel(gr,x,y,n): + gr.SubPlot(2,2,n) + gr.SetXRange(x) + gr.SetYRange(y) + gr.AdjustTicks() + gr.Axis() + gr.Box() + gr.Label("x","x-Axis",1) + gr.Label("y","y-Axis",1) + gr.ClearLegend() + gr.AddLegend("Legend: "+str(n),"k") + gr.Legend() + gr.Plot(x,y) + + +gr.Clf(BackgroundColor[0],BackgroundColor[1],BackgroundColor[2]) +gr.SetPlotFactor(1.5) +plotpanel(gr,x,y,0) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,1) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,2) +y.Modify("(cos(2*pi*x*10)+1.1)*1000.*rnd-501") +plotpanel(gr,x,y,3) + +gr.WritePNG("test.png","Test Plot") + +qw = hfQtPlot() +qw.show() +qw.setgraph(gr) +qw.raise_() +@end verbatim + + + +@c ------------------------------------------------------------------ +@external{} +@node MathGL and MPI, , MathGL and PyQt, Basic usage +@subsection MathGL and MPI +@nav{} + +For using MathGL in MPI program you just need to: (1) plot its own part of data for each running node; (2) collect resulting graphical information in a single program (for example, at node with rank=0); (3) save it. The sample code below demonstrate this for very simple sample of surface drawing. + +First you need to initialize MPI +@verbatim +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // initialize MPI + int rank=0, numproc=1; + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD,&numproc); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + if(rank==0) printf("Use %d processes.\n", numproc); +@end verbatim + +Next step is data creation. For simplicity, I create data arrays with the same sizes for all nodes. At this, you have to create @code{mglGraph} object too. + +@verbatim + // initialize data similarly for all nodes + mglData a(128,256); + mglGraphMPI gr; +@end verbatim + +Now, data should be filled by numbers. In real case, it should be some kind of calculations. But I just fill it by formula. + +@verbatim + // do the same plot for its own range + char buf[64]; + sprintf(buf,"xrange %g %g",2.*rank/numproc-1,2.*(rank+1)/numproc-1); + gr.Fill(a,"sin(2*pi*x)",buf); +@end verbatim + +It is time to plot the data. Don't forget to set proper axis range(s) by using parametric form or by using options (as in the sample). + +@verbatim + // plot data in each node + gr.Clf(); // clear image before making the image + gr.Rotate(40,60); + gr.Surf(a,"",buf); +@end verbatim + +Finally, let send graphical information to node with rank=0. + +@verbatim + // collect information + if(rank!=0) gr.MPI_Send(0); + else for(int i=1;iSubPlot(2,2,0); gr->Box(); + gr->Puts(mglPoint(-1,1.1),"Just box",":L"); + gr->InPlot(0.2,0.5,0.7,1,false); gr->Box(); + gr->Puts(mglPoint(0,1.2),"InPlot example"); + gr->SubPlot(2,2,1); gr->Title("Rotate only"); + gr->Rotate(50,60); gr->Box(); + gr->SubPlot(2,2,2); gr->Title("Rotate and Aspect"); + gr->Rotate(50,60); gr->Aspect(1,1,2); gr->Box(); + gr->SubPlot(2,2,3); gr->Title("Aspect in other direction"); + gr->Rotate(50,60); gr->Aspect(1,2,2); gr->Box(); + return 0; +} +@end verbatim +Here I used function @code{Puts} for printing the text in arbitrary position of picture (see @ref{Text printing}). Text coordinates and size are connected with axes. However, text coordinates may be everywhere, including the outside the bounding box. I'll show its features later in @ref{Text features}. + +@pfig{aspect, Example of several subplots on the single picture.} + +More complicated sample show how to use most of positioning functions: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("StickPlot"); + gr->StickPlot(3, 0, 20, 30); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->StickPlot(3, 1, 20, 30); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->StickPlot(3, 2, 20, 30); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,3,""); gr->Title("ColumnPlot"); + gr->ColumnPlot(3, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->ColumnPlot(3, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->ColumnPlot(3, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->SubPlot(3,2,4,""); gr->Title("GridPlot"); + gr->GridPlot(2, 2, 0); gr->Box("r"); gr->Puts(mglPoint(0),"0","r"); + gr->GridPlot(2, 2, 1); gr->Box("g"); gr->Puts(mglPoint(0),"1","g"); + gr->GridPlot(2, 2, 2); gr->Box("b"); gr->Puts(mglPoint(0),"2","b"); + gr->GridPlot(2, 2, 3); gr->Box("m"); gr->Puts(mglPoint(0),"3","m"); + gr->SubPlot(3,2,5,""); gr->Title("InPlot"); gr->Box(); + gr->InPlot(0.4, 1, 0.6, 1, true); gr->Box("r"); + gr->MultiPlot(3,2,1, 2, 1,""); gr->Title("MultiPlot"); gr->Box(); + return 0; +} +@end verbatim + +@pfig{inplot, Example for most of positioning functions.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis and ticks, Curvilinear coordinates, Subplots, Advanced usage +@subsection Axis and ticks +@nav{} + +MathGL library can draw not only the bounding box but also the axes, grids, labels and so on. The ranges of axes and their origin (the point of intersection) are determined by functions @code{SetRange()}, @code{SetRanges()}, @code{SetOrigin()} (see @ref{Ranges (bounding box)}). Ticks on axis are specified by function @code{SetTicks}, @code{SetTicksVal}, @code{SetTicksTime} (see @ref{Ticks}). But usually + +Function @ref{axis} draws axes. Its textual string shows in which directions the axis or axes will be drawn (by default @code{"xyz"}, function draws axes in all directions). Function @ref{grid} draws grid perpendicularly to specified directions. Example of axes and grid drawing is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Axis origin, Grid"); gr->SetOrigin(0,0); + gr->Axis(); gr->Grid(); gr->FPlot("x^3"); + + gr->SubPlot(2,2,1); gr->Title("2 axis"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1,-1,-1); // first axis + gr->Axis(); gr->Label('y',"axis 1",0); gr->FPlot("sin(pi*x)"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(1,1,1); // second axis + gr->Axis(); gr->Label('y',"axis 2",0); gr->FPlot("cos(pi*x)"); + + gr->SubPlot(2,2,3); gr->Title("More axis"); + gr->SetOrigin(NAN,NAN); gr->SetRange('x',-1,1); + gr->Axis(); gr->Label('x',"x",0); gr->Label('y',"y_1",0); + gr->FPlot("x^2","k"); + gr->SetRanges(-1,1,-1,1); gr->SetOrigin(-1.3,-1); // second axis + gr->Axis("y","r"); gr->Label('y',"#r{y_2}",0.2); + gr->FPlot("x^3","r"); + + gr->SubPlot(2,2,2); gr->Title("4 segments, inverted axis"); + gr->SetOrigin(0,0); + gr->InPlot(0.5,1,0.5,1); gr->SetRanges(0,10,0,2); gr->Axis(); + gr->FPlot("sqrt(x/2)"); gr->Label('x',"W",1); gr->Label('y',"U",1); + gr->InPlot(0,0.5,0.5,1); gr->SetRanges(1,0,0,2); gr->Axis("x"); + gr->FPlot("sqrt(x)+x^3"); gr->Label('x',"\\tau",-1); + gr->InPlot(0.5,1,0,0.5); gr->SetRanges(0,10,4,0); gr->Axis("y"); + gr->FPlot("x/4"); gr->Label('y',"L",-1); + gr->InPlot(0,0.5,0,0.5); gr->SetRanges(1,0,4,0); gr->FPlot("4*x^2"); + return 0; +} +@end verbatim + +Note, that MathGL can draw not only single axis (which is default). But also several axis on the plot (see right plots). The idea is that the change of settings does not influence on the already drawn graphics. So, for 2-axes I setup the first axis and draw everything concerning it. Then I setup the second axis and draw things for the second axis. Generally, the similar idea allows one to draw rather complicated plot of 4 axis with different ranges (see bottom left plot). + +At this inverted axis can be created by 2 methods. First one is used in this sample -- just specify minimal axis value to be large than maximal one. This method work well for 2D axis, but can wrongly place labels in 3D case. Second method is more general and work in 3D case too -- just use @ref{aspect} function with negative arguments. For example, following code will produce exactly the same result for 2D case, but 2nd variant will look better in 3D. +@verbatim +// variant 1 +gr->SetRanges(0,10,4,0); gr->Axis(); + +// variant 2 +gr->SetRanges(0,10,0,4); gr->Aspect(1,-1); gr->Axis(); +@end verbatim + +@pfig{axis, Example of axis.} + +Another MathGL feature is fine ticks tunning. By default (if it is not changed by @code{SetTicks} function), MathGL try to adjust ticks positioning, so that they looks most human readable. At this, MathGL try to extract common factor for too large or too small axis ranges, as well as for too narrow ranges. Last one is non-common notation and can be disabled by @code{SetTuneTicks} function. + +Also, one can specify its own ticks with arbitrary labels by help of @code{SetTicksVal} function. Or one can set ticks in time format. In last case MathGL will try to select optimal format for labels with automatic switching between years, months/days, hours/minutes/seconds or microseconds. However, you can specify its own time representation using formats described in @url{http://www.manpagez.com/man/3/strftime/}. Most common variants are @samp{%X} for national representation of time, @samp{%x} for national representation of date, @samp{%Y} for year with century. + +The sample code, demonstrated ticks feature is +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(3,2,0); gr->Title("Usual axis"); gr->Axis(); + gr->SubPlot(3,2,1); gr->Title("Too big/small range"); + gr->SetRanges(-1000,1000,0,0.001); gr->Axis(); + gr->SubPlot(3,2,3); gr->Title("Too narrow range"); + gr->SetRanges(100,100.1,10,10.01); gr->Axis(); + gr->SubPlot(3,2,4); gr->Title("Disable ticks tuning"); + gr->SetTuneTicks(0); gr->Axis(); + + gr->SubPlot(3,2,2); gr->Title("Manual ticks"); gr->SetRanges(-M_PI,M_PI, 0, 2); + mreal val[]={-M_PI, -M_PI/2, 0, 0.886, M_PI/2, M_PI}; + gr->SetTicksVal('x', mglData(6,val), "-\\pi\n-\\pi/2\n0\nx^*\n\\pi/2\n\\pi"); + gr->Axis(); gr->Grid(); gr->FPlot("2*cos(x^2)^2", "r2"); + + gr->SubPlot(3,2,5); gr->Title("Time ticks"); gr->SetRange('x',0,3e5); + gr->SetTicksTime('x',0); gr->Axis(); + return 0; +} +@end verbatim + +@pfig{ticks, Features of axis ticks.} + +The last sample I want to show in this subsection is Log-axis. From MathGL's point of view, the log-axis is particular case of general curvilinear coordinates. So, we need first define new coordinates (see also @ref{Curvilinear coordinates}) by help of @code{SetFunc} or @code{SetCoor} functions. At this one should wary about proper axis range. So the code looks as following: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,"<_"); gr->Title("Semi-log axis"); + gr->SetRanges(0.01,100,-1,1); gr->SetFunc("lg(x)",""); + gr->Axis(); gr->Grid("xy","g"); gr->FPlot("sin(1/x)"); + gr->Label('x',"x",0); gr->Label('y', "y = sin 1/x",0); + + gr->SubPlot(2,2,1,"<_"); gr->Title("Log-log axis"); + gr->SetRanges(0.01,100,0.1,100); gr->SetFunc("lg(x)","lg(y)"); + gr->Axis(); gr->FPlot("sqrt(1+x^2)"); gr->Label('x',"x",0); + gr->Label('y', "y = \\sqrt{1+x^2}",0); + + gr->SubPlot(2,2,2,"<_"); gr->Title("Minus-log axis"); + gr->SetRanges(-100,-0.01,-100,-0.1); gr->SetFunc("-lg(-x)","-lg(-y)"); + gr->Axis(); gr->FPlot("-sqrt(1+x^2)"); + gr->Label('x',"x",0); gr->Label('y', "y = -\\sqrt{1+x^2}",0); + + gr->SubPlot(2,2,3,"<_"); gr->Title("Log-ticks"); + gr->SetRanges(0.1,100,0,100); gr->SetFunc("sqrt(x)",""); + gr->Axis(); gr->FPlot("x"); + gr->Label('x',"x",1); gr->Label('y', "y = x",0); + return 0; +} +@end verbatim + +@pfig{loglog, Features of axis ticks.} + +You can see that MathGL automatically switch to log-ticks as we define log-axis formula (in difference from v.1.*). Moreover, it switch to log-ticks for any formula if axis range will be large enough (see right bottom plot). Another interesting feature is that you not necessary define usual log-axis (i.e. when coordinates are positive), but you can define ``minus-log'' axis when coordinate is negative (see left bottom plot). + +@c ------------------------------------------------------------------ +@external{} +@node Curvilinear coordinates, Colorbars, Axis and ticks, Advanced usage +@subsection Curvilinear coordinates +@nav{} + +As I noted in previous subsection, MathGL support curvilinear coordinates. In difference from other plotting programs and libraries, MathGL uses textual formulas for connection of the old (data) and new (output) coordinates. This allows one to plot in arbitrary coordinates. The following code plots the line @var{y}=0, @var{z}=0 in Cartesian, polar, parabolic and spiral coordinates: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetOrigin(-1,1,-1); + + gr->SubPlot(2,2,0); gr->Title("Cartesian"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)",0); + gr->SubPlot(2,2,1); gr->Title("Cylindrical"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("2*y*x","y*y - x*x",0); + gr->SubPlot(2,2,2); gr->Title("Parabolic"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + + gr->SetFunc("y*sin(pi*x)","y*cos(pi*x)","x+z"); + gr->SubPlot(2,2,3); gr->Title("Spiral"); gr->Rotate(50,60); + gr->FPlot("2*t-1","0.5","0","r2"); + gr->Axis(); gr->Grid(); + gr->SetFunc(0,0,0); // set to default Cartesian + return 0; +} +@end verbatim + +@pfig{curvcoor, Example of curvilinear coordinates} + + +@c ------------------------------------------------------------------ +@external{} +@node Colorbars, Bounding box, Curvilinear coordinates, Advanced usage +@subsection Colorbars +@nav{} + +MathGL handle @ref{colorbar} as special kind of axis. So, most of functions for axis and ticks setup will work for colorbar too. Colorbars can be in log-scale, and generally as arbitrary function scale; common factor of colorbar labels can be separated; and so on. + +But of course, there are differences -- colorbars usually located out of bounding box. At this, colorbars can be at subplot boundaries (by default), or at bounding box (if symbol @samp{I} is specified). Colorbars can handle sharp colors. And they can be located at arbitrary position too. The sample code, which demonstrate colorbar features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Colorbar out of box"); gr->Box(); + gr->Colorbar("<"); gr->Colorbar(">"); + gr->Colorbar("_"); gr->Colorbar("^"); + + gr->SubPlot(2,2,1); gr->Title("Colorbar near box"); gr->Box(); + gr->Colorbar("Colorbar(">I"); + gr->Colorbar("_I"); gr->Colorbar("^I"); + + gr->SubPlot(2,2,2); gr->Title("manual colors"); + mglData a,v; mgls_prepare2d(&a,0,&v); + gr->Box(); gr->ContD(v,a); + gr->Colorbar(v,"<"); gr->Colorbar(v,">"); + gr->Colorbar(v,"_"); gr->Colorbar(v,"^"); + + gr->SubPlot(2,2,3); gr->Title(" "); + gr->Puts(mglPoint(-0.5,1.55),"Color positions",":C",-2); + gr->Colorbar("bwr>",0.25,0); gr->Puts(mglPoint(-0.9,1.2),"Default"); + gr->Colorbar("b{w,0.3}r>",0.5,0); gr->Puts(mglPoint(-0.1,1.2),"Manual"); + + gr->Puts(mglPoint(1,1.55),"log-scale",":C",-2); + gr->SetRange('c',0.01,1e3); + gr->Colorbar(">",0.75,0); gr->Puts(mglPoint(0.65,1.2),"Normal scale"); + gr->SetFunc("","","","lg(c)"); + gr->Colorbar(">"); gr->Puts(mglPoint(1.35,1.2),"Log scale"); + return 0; +} +@end verbatim + +@pfig{colorbar, Example of colorbars} + + +@c ------------------------------------------------------------------ +@external{} +@node Bounding box, Ternary axis, Colorbars, Advanced usage +@subsection Bounding box +@nav{} + +Box around the plot is rather useful thing because it allows one to: see the plot boundaries, and better estimate points position since box contain another set of ticks. MathGL provide special function for drawing such box -- @ref{box} function. By default, it draw black or white box with ticks (color depend on transparency type, see @ref{Types of transparency}). However, you can change the color of box, or add drawing of rectangles at rear faces of box. Also you can disable ticks drawing, but I don't know why anybody will want it. The sample code, which demonstrate @ref{box} features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0); gr->Title("Box (default)"); gr->Rotate(50,60); + gr->Box(); + gr->SubPlot(2,2,1); gr->Title("colored"); gr->Rotate(50,60); + gr->Box("r"); + gr->SubPlot(2,2,2); gr->Title("with faces"); gr->Rotate(50,60); + gr->Box("@"); + gr->SubPlot(2,2,3); gr->Title("both"); gr->Rotate(50,60); + gr->Box("@cm"); + return 0; +} +@end verbatim + +@pfig{box, Example of Box()} + + +@c ------------------------------------------------------------------ +@external{} +@node Ternary axis, Text features, Bounding box, Advanced usage +@subsection Ternary axis +@nav{} + +There are another unusual axis types which are supported by MathGL. These are ternary and quaternary axis. Ternary axis is special axis of 3 coordinates @var{a}, @var{b}, @var{c} which satisfy relation @var{a}+@var{b}+@var{c}=1. Correspondingly, quaternary axis is special axis of 4 coordinates @var{a}, @var{b}, @var{c}, @var{d} which satisfy relation @var{a}+@var{b}+@var{c}+@var{d}=1. + +Generally speaking, only 2 of coordinates (3 for quaternary) are independent. So, MathGL just introduce some special transformation formulas which treat @var{a} as @samp{x}, @var{b} as @samp{y} (and @var{c} as @samp{z} for quaternary). As result, all plotting functions (curves, surfaces, contours and so on) work as usual, but in new axis. You should use @ref{ternary} function for switching to ternary/quaternary coordinates. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + gr->SubPlot(2,2,0); gr->Title("Ordinary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"B",1); gr->Label('y',"C",1); gr->Label('z',"Z",1); + + gr->SubPlot(2,2,1); gr->Title("Ternary axis (x+y+t=1)"); + gr->Ternary(1); + gr->Plot(x,y,"r2"); gr->Plot(rx,ry,"q^ "); gr->Cont(a,"BbcyrR"); + gr->Line(mglPoint(0.5,0), mglPoint(0,0.75), "g2"); + gr->Axis(); gr->Grid("xyz","B;"); + gr->Label('x',"B"); gr->Label('y',"C"); gr->Label('t',"A"); + + gr->SubPlot(2,2,2); gr->Title("Quaternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(2); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"D",1); + + gr->SubPlot(2,2,3); gr->Title("Ternary axis 3D"); + gr->Rotate(50,60); gr->Light(true); + gr->Ternary(1); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"BbcyrR#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('t',"A",1); gr->Label('x',"B",1); + gr->Label('y',"C",1); gr->Label('z',"Z",1); + return 0; +} +@end verbatim + +@pfig{ternary, Example of colorbars} + +@c ------------------------------------------------------------------ +@external{} +@node Text features, Legend sample, Ternary axis, Advanced usage +@subsection Text features +@nav{} + +MathGL prints text by vector font. There are functions for manual specifying of text position (like @code{Puts}) and for its automatic selection (like @code{Label}, @code{Legend} and so on). MathGL prints text always in specified position even if it lies outside the bounding box. The default size of font is specified by functions @var{SetFontSize*} (see @ref{Font settings}). However, the actual size of output string depends on subplot size (depends on functions @code{SubPlot}, @code{InPlot}). The switching of the font style (italic, bold, wire and so on) can be done for the whole string (by function parameter) or inside the string. By default MathGL parses TeX-like commands for symbols and indexes (see @ref{Font styles}). + +Text can be printed as usual one (from left to right), along some direction (rotated text), or along a curve. Text can be printed on several lines, divided by new line symbol @samp{\n}. + +Example of MathGL font drawing is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,""); + gr->Putsw(mglPoint(0,1),L"Text can be in ASCII and in Unicode"); + gr->Puts(mglPoint(0,0.6),"It can be \\wire{wire}, \\big{big} or #r{colored}"); + gr->Puts(mglPoint(0,0.2),"One can change style in string: " + "\\b{bold}, \\i{italic, \\b{both}}"); + gr->Puts(mglPoint(0,-0.2),"Easy to \\a{overline} or " + "\\u{underline}"); + gr->Puts(mglPoint(0,-0.6),"Easy to change indexes ^{up} _{down} @{center}"); + gr->Puts(mglPoint(0,-1),"It parse TeX: \\int \\alpha \\cdot " + "\\sqrt3{sin(\\pi x)^2 + \\gamma_{i_k}} dx"); + + gr->SubPlot(2,2,1,""); + gr->Puts(mglPoint(0,0.5), "\\sqrt{\\frac{\\alpha^{\\gamma^2}+\\overset 1{\\big\\infty}}{\\sqrt3{2+b}}}", "@", -4); + gr->Puts(mglPoint(0,-0.5),"Text can be printed\non several lines"); + + gr->SubPlot(2,2,2,""); + mglData y; mgls_prepare1d(&y); + gr->Box(); gr->Plot(y.SubData(-1,0)); + gr->Text(y,"This is very very long string drawn along a curve",":k"); + gr->Text(y,"Another string drawn above a curve","T:r"); + + gr->SubPlot(2,2,3,""); + gr->Line(mglPoint(-1,-1),mglPoint(1,-1),"rA"); + gr->Puts(mglPoint(0,-1),mglPoint(1,-1),"Horizontal"); + gr->Line(mglPoint(-1,-1),mglPoint(1,1),"rA"); + gr->Puts(mglPoint(0,0),mglPoint(1,1),"At angle","@"); + gr->Line(mglPoint(-1,-1),mglPoint(-1,1),"rA"); + gr->Puts(mglPoint(-1,0),mglPoint(-1,1),"Vertical"); + return 0; +} +@end verbatim + +@pfig{text, Example of text printing} + +You can change font faces by loading font files by function @ref{loadfont}. Note, that this is long-run procedure. Font faces can be downloaded from @uref{http://mathgl.sourceforge.net/download.html, MathGL website} or from @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, here}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + double h=1.1, d=0.25; + gr->LoadFont("STIX"); gr->Puts(mglPoint(0,h), "default font (STIX)"); + gr->LoadFont("adventor"); gr->Puts(mglPoint(0,h-d), "adventor font"); + gr->LoadFont("bonum"); gr->Puts(mglPoint(0,h-2*d), "bonum font"); + gr->LoadFont("chorus"); gr->Puts(mglPoint(0,h-3*d), "chorus font"); + gr->LoadFont("cursor"); gr->Puts(mglPoint(0,h-4*d), "cursor font"); + gr->LoadFont("heros"); gr->Puts(mglPoint(0,h-5*d), "heros font"); + gr->LoadFont("heroscn"); gr->Puts(mglPoint(0,h-6*d), "heroscn font"); + gr->LoadFont("pagella"); gr->Puts(mglPoint(0,h-7*d), "pagella font"); + gr->LoadFont("schola"); gr->Puts(mglPoint(0,h-8*d), "schola font"); + gr->LoadFont("termes"); gr->Puts(mglPoint(0,h-9*d), "termes font"); + return 0; +} +@end verbatim + +@pfig{fonts, Example of font faces} + +@c ------------------------------------------------------------------ +@external{} +@node Legend sample, Cutting sample, Text features, Advanced usage +@subsection Legend sample +@nav{} + +Legend is one of standard ways to show plot annotations. Basically you need to connect the plot style (line style, marker and color) with some text. In MathGL, you can do it by 2 methods: manually using @ref{addlegend} function; or use @samp{legend} option (see @ref{Command options}), which will use last plot style. In both cases, legend entries will be added into internal accumulator, which later used for legend drawing itself. @ref{clearlegend} function allow you to remove all saved legend entries. + +There are 2 features. If plot style is empty then text will be printed without indent. If you want to plot the text with indent but without plot sample then you need to use space @samp{ } as plot style. Such style @samp{ } will draw a plot sample (line with marker(s)) which is invisible line (i.e. nothing) and print the text with indent as usual one. + +Function @ref{legend} draw legend on the plot. The position of the legend can be selected automatic or manually. You can change the size and style of text labels, as well as setup the plot sample. The sample code demonstrating legend features is: +@verbatim +int sample(mglGraph *gr) +{ + gr->AddLegend("sin(\\pi {x^2})","b"); + gr->AddLegend("sin(\\pi x)","g*"); + gr->AddLegend("sin(\\pi \\sqrt{x})","rd"); + gr->AddLegend("just text"," "); + gr->AddLegend("no indent for this",""); + + gr->SubPlot(2,2,0,""); gr->Title("Legend (default)"); + gr->Box(); gr->Legend(); + + gr->Legend(3,"A#"); + gr->Puts(mglPoint(0.75,0.65),"Absolute position","A"); + + gr->SubPlot(2,2,2,""); gr->Title("coloring"); gr->Box(); + gr->Legend(0,"r#"); gr->Legend(1,"Wb#"); gr->Legend(2,"ygr#"); + + gr->SubPlot(2,2,3,""); gr->Title("manual position"); gr->Box(); + gr->Legend(0.5,1); gr->Puts(mglPoint(0.5,0.55),"at x=0.5, y=1","a"); + gr->Legend(1,"#-"); gr->Puts(mglPoint(0.75,0.25),"Horizontal legend","a"); + return 0; +} +@end verbatim + +@pfig{legend, Example of legend} + +@c ------------------------------------------------------------------ +@external{} +@node Cutting sample, , Legend sample, Advanced usage +@subsection Cutting sample +@nav{} + +The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that. +@itemize @bullet +@item +You can set one of coordinate to NAN value. All points with NAN values will be omitted. + +@item +You can enable cutting at edges by @code{SetCut} function. As result all points out of bounding box will be omitted. + +@item +You can set cutting box by @code{SetCutBox} function. All points inside this box will be omitted. + +@item +You can define cutting formula by @code{SetCutOff} function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant. +@end itemize + +Below I place the code which demonstrate last 3 possibilities: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,c,v(1); mgls_prepare2d(&a); mgls_prepare3d(&c); v.a[0]=0.5; + gr->SubPlot(2,2,0); gr->Title("Cut on (default)"); + gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Surf(a,"","zrange -1 0.5"); + + gr->SubPlot(2,2,1); gr->Title("Cut off"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a,"","zrange -1 0.5; cut off"); + + gr->SubPlot(2,2,2); gr->Title("Cut in box"); gr->Rotate(50,60); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->Alpha(true); gr->Box(); gr->Surf3(c); + gr->SetCutBox(mglPoint(0), mglPoint(0)); // switch it off + + gr->SubPlot(2,2,3); gr->Title("Cut by formula"); gr->Rotate(50,60); + gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)"); + gr->Box(); gr->Surf3(c); gr->CutOff(""); // switch it off + return 0; +} +@end verbatim + +@pfig{cut, Example of point cutting} + + + +@c ------------------------------------------------------------------ +@external{} +@node Data handling, Data plotting, Advanced usage, Examples +@section Data handling +@nav{} + +Class @code{mglData} contains all functions for the data handling in MathGL (@pxref{Data processing}). There are several matters why I use class @code{mglData} but not a single array: it does not depend on type of data (mreal or double), sizes of data arrays are kept with data, memory working is simpler and safer. + +@menu +* Array creation:: +* Linking array:: +* Change data:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Array creation, Linking array, , Data handling +@subsection Array creation +@nav{} + +There are many ways in MathGL how data arrays can be created and filled. + +One can put the data in @code{mglData} instance by several ways. Let us do it for sinus function: +@itemize @bullet +@item +one can create external array, fill it and put to @code{mglData} variable +@verbatim + double *a = new double[50]; + for(int i=0;i<50;i++) a[i] = sin(M_PI*i/49.); + + mglData y; + y.Set(a,50); +@end verbatim + +@item +another way is to create @code{mglData} instance of the desired size and then to work directly with data in this variable +@verbatim + mglData y(50); + for(int i=0;i<50;i++) y.a[i] = sin(M_PI*i/49.); +@end verbatim + +@item +next way is to fill the data in @code{mglData} instance by textual formula with the help of @code{Modify()} function +@verbatim + mglData y(50); + y.Modify("sin(pi*x)"); +@end verbatim + +@item +or one may fill the array in some interval and modify it later +@verbatim + mglData y(50); + y.Fill(0,M_PI); + y.Modify("sin(u)"); +@end verbatim + +@item +finally it can be loaded from file +@verbatim + FILE *fp=fopen("sin.dat","wt"); // create file first + for(int i=0;i<50;i++) fprintf(fp,"%g\n",sin(M_PI*i/49.)); + fclose(fp); + + mglData y("sin.dat"); // load it +@end verbatim +At this you can use textual or HDF files, as well as import values from bitmap image (PNG is supported right now). + +@item +at this one can read only part of data +@verbatim + FILE *fp-fopen("sin.dat","wt"); // create large file first + for(int i=0;i<70;i++) fprintf(fp,"%g\n",sin(M_PI*i/49.)); + fclose(fp); + + mglData y; + y.Read("sin.dat",50); // load it +@end verbatim +@end itemize + +Creation of 2d- and 3d-arrays is mostly the same. But one should keep in mind that class @code{mglData} uses flat data representation. For example, matrix 30*40 is presented as flat (1d-) array with length 30*40=1200 (nx=30, ny=40). The element with indexes @{i,j@} is a[i+nx*j]. So for 2d array we have: +@verbatim + mglData z(30,40); + for(int i=0;i<30;i++) for(int j=0;j<40;j++) + z.a[i+30*j] = sin(M_PI*i/29.)*sin(M_PI*j/39.); +@end verbatim +or by using @code{Modify()} function +@verbatim + mglData z(30,40); + z.Modify("sin(pi*x)*cos(pi*y)"); +@end verbatim + +The only non-obvious thing here is using multidimensional arrays in C/C++, i.e. arrays defined like @code{mreal dat[40][30];}. Since, formally these elements @code{dat[i]} can address the memory in arbitrary place you should use the proper function to convert such arrays to @code{mglData} object. For C++ this is functions like @code{mglData::Set(mreal **dat, int N1, int N2);}. For C this is functions like @code{mgl_data_set_mreal2(HMDT d, const mreal **dat, int N1, int N2);}. At this, you should keep in mind that @code{nx=N2} and @code{ny=N1} after conversion. + +@c ------------------------------------------------------------------ +@external{} +@node Linking array, Change data, Array creation, Data handling +@subsection Linking array +@nav{} + +Sometimes the data arrays are so large, that one couldn't' copy its values to another array (i.e. into mglData). In this case, he can define its own class derived from @code{mglDataA} (see @ref{mglDataA class}) or can use @code{Link} function. + +In last case, MathGL just save the link to an external data array, but not copy it. You should provide the existence of this data array for whole time during which MathGL can use it. Another point is that MathGL will automatically create new array if you'll try to modify data values by any of @code{mglData} functions. So, you should use only function with @code{const} modifier if you want still using link to the original data array. + +Creating the link is rather simple -- just the same as using @code{Set} function +@verbatim + double *a = new double[50]; + for(int i=0;i<50;i++) a[i] = sin(M_PI*i/49.); + + mglData y; + y.Link(a,50); +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node Change data, , Linking array, Data handling +@subsection Change data +@nav{} + +MathGL has functions for data processing: differentiating, integrating, smoothing and so on (for more detail, see @ref{Data processing}). Let us consider some examples. The simplest ones are integration and differentiation. The direction in which operation will be performed is specified by textual string, which may contain symbols @samp{x}, @samp{y} or @samp{z}. For example, the call of @code{Diff("x")} will differentiate data along @samp{x} direction; the call of @code{Integral("xy")} perform the double integration of data along @samp{x} and @samp{y} directions; the call of @code{Diff2("xyz")} will apply 3d Laplace operator to data and so on. Example of this operations on 2d array a=x*y is presented in code: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData a(30,40); a.Modify("x*y"); + gr->SubPlot(2,2,0); gr->Rotate(60,40); + gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"a(x,y)"); + gr->SubPlot(2,2,1); gr->Rotate(60,40); + a.Diff("x"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"da/dx"); + gr->SubPlot(2,2,2); gr->Rotate(60,40); + a.Integral("xy"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"\\int da/dx dxdy"); + gr->SubPlot(2,2,3); gr->Rotate(60,40); + a.Diff2("y"); gr->Surf(a); gr->Box(); + gr->Puts(mglPoint(0.7,1,1.2),"\\int {d^2}a/dxdy dx"); + return 0; +} +@end verbatim + +@pfig{dat_diff, Example of data differentiation and integration} + +Data smoothing (function @ref{smooth}) is more interesting and important. This function has single argument which define type of smoothing and its direction. Now 3 methods are supported: @samp{3} -- linear averaging by 3 points, @samp{5} -- linear averaging by 5 points, and default one -- quadratic averaging by 5 points. + +MathGL also have some amazing functions which is not so important for data processing as useful for data plotting. There are functions for finding envelope (useful for plotting rapidly oscillating data), for data sewing (useful to removing jumps on the phase), for data resizing (interpolation). Let me demonstrate it: +@verbatim +int sample(mglGraph *gr) +{ + gr->SubPlot(2,2,0,""); gr->Title("Envelop sample"); + mglData d1(1000); gr->Fill(d1,"exp(-8*x^2)*sin(10*pi*x)"); + gr->Axis(); gr->Plot(d1, "b"); + d1.Envelop('x'); gr->Plot(d1, "r"); + + gr->SubPlot(2,2,1,""); gr->Title("Smooth sample"); + mglData y0(30),y1,y2,y3; + gr->SetRanges(0,1,0,1); + gr->Fill(y0, "0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd"); + + y1=y0; y1.Smooth("x3"); + y2=y0; y2.Smooth("x5"); + y3=y0; y3.Smooth("x"); + + gr->Plot(y0,"{m7}:s", "legend 'none'"); //gr->AddLegend("none","k"); + gr->Plot(y1,"r", "legend ''3' style'"); + gr->Plot(y2,"g", "legend ''5' style'"); + gr->Plot(y3,"b", "legend 'default'"); + gr->Legend(); gr->Box(); + + gr->SubPlot(2,2,2); gr->Title("Sew sample"); + mglData d2(100, 100); gr->Fill(d2, "mod((y^2-(1-x)^2)/2,0.1)"); + gr->Rotate(50, 60); gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf(d2, "b"); + d2.Sew("xy", 0.1); gr->Surf(d2, "r"); + + gr->SubPlot(2,2,3); gr->Title("Resize sample (interpolation)"); + mglData x0(10), v0(10), x1, v1; + gr->Fill(x0,"rnd"); gr->Fill(v0,"rnd"); + x1 = x0.Resize(100); v1 = v0.Resize(100); + gr->Plot(x0,v0,"b+ "); gr->Plot(x1,v1,"r-"); + gr->Label(x0,v0,"%n"); + return 0; +} +@end verbatim + +@pfig{dat_extra, Example of data smoothing} + +Also one can create new data arrays on base of the existing one: extract slice, row or column of data (@ref{subdata}), summarize along a direction(s) (@ref{sum}), find distribution of data elements (@ref{hist}) and so on. + +@anchor{Solve sample} +Another interesting feature of MathGL is interpolation and root-finding. There are several functions for linear and cubic spline interpolation (see @ref{Interpolation}). Also there is a function @ref{evaluate} which do interpolation of data array for values of each data element of index data. It look as indirect access to the data elements. + +This function have inverse function @ref{solve} which find array of indexes at which data array is equal to given value (i.e. work as root finding). But @ref{solve} function have the issue -- usually multidimensional data (2d and 3d ones) have an infinite number of indexes which give some value. This is contour lines for 2d data, or isosurface(s) for 3d data. So, @ref{solve} function will return index only in given direction, assuming that other index(es) are the same as equidistant index(es) of original data. If data have multiple roots then second (and later) branches can be found by consecutive call(s) of @ref{solve} function. Let me demonstrate this on the following sample. + +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRange('z',0,1); + mglData x(20,30), y(20,30), z(20,30), xx,yy,zz; + gr->Fill(x,"(x+2)/3*cos(pi*y)"); + gr->Fill(y,"(x+2)/3*sin(pi*y)"); + gr->Fill(z,"exp(-6*x^2-2*sin(pi*y)^2)"); + + gr->SubPlot(2,1,0); gr->Title("Cartesian space"); gr->Rotate(30,-40); + gr->Axis("xyzU"); gr->Box(); gr->Label('x',"x"); gr->Label('y',"y"); + gr->SetOrigin(1,1); gr->Grid("xy"); + gr->Mesh(x,y,z); + + // section along 'x' direction + mglData u = x.Solve(0.5,'x'); + mglData v(u.nx); v.Fill(0,1); + xx = x.Evaluate(u,v); yy = y.Evaluate(u,v); zz = z.Evaluate(u,v); + gr->Plot(xx,yy,zz,"k2o"); + + // 1st section along 'y' direction + mglData u1 = x.Solve(-0.5,'y'); + mglData v1(u1.nx); v1.Fill(0,1); + xx = x.Evaluate(v1,u1); yy = y.Evaluate(v1,u1); zz = z.Evaluate(v1,u1); + gr->Plot(xx,yy,zz,"b2^"); + + // 2nd section along 'y' direction + mglData u2 = x.Solve(-0.5,'y',u1); + xx = x.Evaluate(v1,u2); yy = y.Evaluate(v1,u2); zz = z.Evaluate(v1,u2); + gr->Plot(xx,yy,zz,"r2v"); + + gr->SubPlot(2,1,1); gr->Title("Accompanied space"); + gr->SetRanges(0,1,0,1); gr->SetOrigin(0,0); + gr->Axis(); gr->Box(); gr->Label('x',"i"); gr->Label('y',"j"); + gr->Grid(z,"h"); + + gr->Plot(u,v,"k2o"); gr->Line(mglPoint(0.4,0.5),mglPoint(0.8,0.5),"kA"); + gr->Plot(v1,u1,"b2^"); gr->Line(mglPoint(0.5,0.15),mglPoint(0.5,0.3),"bA"); + gr->Plot(v1,u2,"r2v"); gr->Line(mglPoint(0.5,0.7),mglPoint(0.5,0.85),"rA"); +} +@end verbatim + +@pfig{solve, Example of data interpolation and root finding} + +@c ------------------------------------------------------------------ +@external{} +@node Data plotting, 1D samples, Data handling, Examples +@section Data plotting +@nav{} + +Let me now show how to plot the data. Next section will give much more examples for all plotting functions. Here I just show some basics. MathGL generally has 2 types of plotting functions. Simple variant requires a single data array for plotting, other data (coordinates) are considered uniformly distributed in axis range. Second variant requires data arrays for all coordinates. It allows one to plot rather complex multivalent curves and surfaces (in case of parametric dependencies). Usually each function have one textual argument for plot style and another textual argument for options (see @ref{Command options}). + +Note, that the call of drawing function adds something to picture but does not clear the previous plots (as it does in Matlab). Another difference from Matlab is that all setup (like transparency, lightning, axis borders and so on) must be specified @strong{before} plotting functions. + +Let start for plots for 1D data. Term ``1D data'' means that data depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. The textual argument allow you specify styles of line and marks (see @ref{Line styles}). If this parameter is @code{NULL} or empty then solid line with color from palette is used (see @ref{Palette and colors}). + +Below I shall show the features of 1D plotting on base of @ref{plot} function. Let us start from sinus plot: +@verbatim +int sample(mglGraph *gr) +{ + mglData y0(50); y0.Modify("sin(pi*(2*x-1))"); + gr->SubPlot(2,2,0); + gr->Plot(y0); gr->Box(); +@end verbatim +Style of line is not specified in @ref{plot} function. So MathGL uses the solid line with first color of palette (this is blue). Next subplot shows array @var{y1} with 2 rows: +@verbatim + gr->SubPlot(2,2,1); + mglData y1(50,2); + y1.Modify("sin(pi*2*x-pi)"); + y1.Modify("cos(pi*2*x-pi)/2",1); + gr->Plot(y1); gr->Box(); +@end verbatim +As previously I did not specify the style of lines. As a result, MathGL again uses solid line with next colors in palette (there are green and red). Now let us plot a circle on the same subplot. The circle is parametric curve @math{x=cos(\pi t), y=sin(\pi t)}. I will set the color of the circle (dark yellow, @samp{Y}) and put marks @samp{+} at point position: +@verbatim + mglData x(50); x.Modify("cos(pi*2*x-pi)"); + gr->Plot(x,y0,"Y+"); +@end verbatim +Note that solid line is used because I did not specify the type of line. The same picture can be achieved by @ref{plot} and @ref{subdata} functions. Let us draw ellipse by orange dash line: +@verbatim + gr->Plot(y1.SubData(-1,0),y1.SubData(-1,1),"q|"); +@end verbatim + +Drawing in 3D space is mostly the same. Let us draw spiral with default line style. Now its color is 4-th color from palette (this is cyan): +@verbatim + gr->SubPlot(2,2,2); gr->Rotate(60,40); + mglData z(50); z.Modify("2*x-1"); + gr->Plot(x,y0,z); gr->Box(); +@end verbatim +Functions @ref{plot} and @ref{subdata} make 3D curve plot but for single array. Use it to put circle marks on the previous plot: +@verbatim + mglData y2(10,3); y2.Modify("cos(pi*(2*x-1+y))"); + y2.Modify("2*x-1",2); + gr->Plot(y2.SubData(-1,0),y2.SubData(-1,1),y2.SubData(-1,2),"bo "); +@end verbatim +Note that line style is empty @samp{ } here. Usage of other 1D plotting functions looks similar: +@verbatim + gr->SubPlot(2,2,3); gr->Rotate(60,40); + gr->Bars(x,y0,z,"r"); gr->Box(); + return 0; +} +@end verbatim + +Surfaces @ref{surf} and other 2D plots (@pxref{2D plotting}) are drown the same simpler as 1D one. The difference is that the string parameter specifies not the line style but the color scheme of the plot (see @ref{Color scheme}). Here I draw attention on 4 most interesting color schemes. There is gray scheme where color is changed from black to white (string @samp{kw}) or from white to black (string @samp{wk}). Another scheme is useful for accentuation of negative (by blue color) and positive (by red color) regions on plot (string @samp{"BbwrR"}). Last one is the popular ``jet'' scheme (string @samp{"BbcyrR"}). + +Now I shall show the example of a surface drawing. At first let us switch lightning on +@verbatim +int sample(mglGraph *gr) +{ + gr->Light(true); gr->Light(0,mglPoint(0,0,1)); +@end verbatim +and draw the surface, considering coordinates x,y to be uniformly distributed in interval @var{Min}*@var{Max} +@verbatim + mglData a0(50,40); + a0.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))"); + gr->SubPlot(2,2,0); gr->Rotate(60,40); + gr->Surf(a0); gr->Box(); +@end verbatim +Color scheme was not specified. So previous color scheme is used. In this case it is default color scheme (``jet'') for the first plot. Next example is a sphere. The sphere is parametrically specified surface: +@verbatim + mglData x(50,40),y(50,40),z(50,40); + x.Modify("0.8*sin(2*pi*x)*sin(pi*y)"); + y.Modify("0.8*cos(2*pi*x)*sin(pi*y)"); + z.Modify("0.8*cos(pi*y)"); + gr->SubPlot(2,2,1); gr->Rotate(60,40); + gr->Surf(x,y,z,"BbwrR");gr->Box(); +@end verbatim +I set color scheme to @code{"BbwrR"} that corresponds to red top and blue bottom of the sphere. + +Surfaces will be plotted for each of slice of the data if @var{nz}>1. Next example draws surfaces for data arrays with @var{nz}=3: +@verbatim + mglData a1(50,40,3); + a1.Modify("0.6*sin(2*pi*x)*sin(3*pi*y)+0.4*cos(3*pi*(x*y))"); + a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*sin(3*pi*(x*y))",1); + a1.Modify("0.6*cos(2*pi*x)*cos(3*pi*y)+0.4*cos(3*pi*(x*y))",2); + gr->SubPlot(2,2,2); gr->Rotate(60,40); + gr->Alpha(true); + gr->Surf(a1); gr->Box(); +@end verbatim +Note, that it may entail a confusion. However, if one will use density plot then the picture will look better: +@verbatim + gr->SubPlot(2,2,3); gr->Rotate(60,40); + gr->Dens(a1); gr->Box(); + return 0; +} +@end verbatim + +Drawing of other 2D plots is analogous. The only peculiarity is the usage of flag @samp{#}. By default this flag switches on the drawing of a grid on plot (@ref{grid} or @ref{mesh} for plots in plain or in volume). However, for isosurfaces (including surfaces of rotation @ref{axial}) this flag switches the face drawing off. Figure becomes wired. The following code gives example of flag @samp{#} using (compare with normal function drawing as in its description): +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); gr->Light(0,mglPoint(0,0,1)); + mglData a(30,20); + a.Modify("0.6*sin(2*pi*x)*sin(3*pi*y) + 0.4*cos(3*pi*(x*y))"); + + gr->SubPlot(2,2,0); gr->Rotate(40,60); + gr->Surf(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(40,60); + gr->Dens(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(40,60); + gr->Cont(a,"BbcyrR#"); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(40,60); + gr->Axial(a,"BbcyrR#"); gr->Box(); + return 0; +} +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node 1D samples, 2D samples, Data plotting, Examples +@section 1D samples +@nav{} + +This section is devoted to visualization of 1D data arrays. 1D means the data which depend on single index (parameter) like curve in parametric form @{x(i),y(i),z(i)@}, i=1...n. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0) +{ + register long i,n=50; + if(y) y->Create(n,3); + if(x1) x1->Create(n); if(x2) x2->Create(n); + if(y1) y1->Create(n); if(y2) y2->Create(n); + mreal xx; + for(i=0;ia[i] = 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx); + y->a[i+n] = sin(2*M_PI*xx); + y->a[i+2*n] = cos(2*M_PI*xx); + } + if(y1) y1->a[i] = 0.5+0.3*cos(2*M_PI*xx); + if(y2) y2->a[i] = 0.3*sin(2*M_PI*xx); + if(x1) x1->a[i] = xx*2-1; + if(x2) x2->a[i] = 0.05+0.03*cos(2*M_PI*xx); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare1d(HMDT y, HMDT y1=0, HMDT y2=0, HMDT x1=0, HMDT x2=0) +{ + register long i,n=50; + if(y) mgl_data_create(y,n,3,1); + if(x1) mgl_data_create(x1,n,1,1); + if(x2) mgl_data_create(x2,n,1,1); + if(y1) mgl_data_create(y1,n,1,1); + if(y2) mgl_data_create(y2,n,1,1); + mreal xx; + for(i=0;iSetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)"); + gr->Box(); gr->Plot(y); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style; 'rgb' palette"); + gr->Box(); gr->Plot(y,"o!rgb"); + + gr->SubPlot(2,2,3,""); gr->Title("just markers"); + gr->Box(); gr->Plot(y," +"); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Plot(xc,yc,z,"rs"); + return 0; +} +@end verbatim + +@pfig{plot, Example of Plot()} + + +@c ------------------------------------------------------------------ +@external{} +@node Radar sample, Step sample, Plot sample, 1D samples +@subsection Radar sample +@nav{} + +Function @ref{radar} plot is variant of @code{Plot} one, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use @ref{Curvilinear coordinates} or @code{Plot} in parabolic form with @code{x=r*cos(fi); y=r*sin(fi);}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData yr(10,3); yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd"); + gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')"); + gr->Radar(yr,"#"); + return 0; +} +@end verbatim + +@pfig{radar, Example of Radar()} + +@c ------------------------------------------------------------------ +@external{} +@node Step sample, Tens sample, Radar sample, 1D samples +@subsection Step sample +@nav{} + +Function @ref{step} plot data as stairs. It have the same options as @code{Plot}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + + gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)"); + gr->Box(); gr->Step(y); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Step(xc,yc,z,"r"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Step(y,"s!rgb"); + return 0; +} +@end verbatim + +@pfig{step, Example of Step()} + +@c ------------------------------------------------------------------ +@external{} +@node Tens sample, Area sample, Step sample, 1D samples +@subsection Tens sample +@nav{} + +Function @ref{tens} is variant of @ref{plot} with smooth coloring along the curves. At this, color is determined as for surfaces (see @ref{Color scheme}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)"); + gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1)); + + gr->SubPlot(2,2,2,""); gr->Title("' ' style"); + gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o "); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Tens(xc,yc,z,z,"s"); + return 0; +} +@end verbatim + +@pfig{tens, Example of Tens()} + +@c ------------------------------------------------------------------ +@external{} +@node Area sample, Region sample, Tens sample, 1D samples +@subsection Area sample +@nav{} + +Function @ref{area} fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)"); + gr->Box(); gr->Area(y); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Area(y,"cbgGyr"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Area(y,"!"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Area(xc,yc,z,"r"); + yc.Modify("-sin(pi*(2*x-1))"); gr->Area(xc,yc,z,"b#"); + return 0; +} +@end verbatim + +@pfig{area, Example of Area()} + +@c ------------------------------------------------------------------ +@external{} +@node Region sample, Stem sample, Area sample, 1D samples +@subsection Region sample +@nav{} + +Function @ref{region} fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)"); + gr->Box(); gr->Region(y1,y2); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Region(y1,y2,"yr"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Region(y1,y2,"!"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + + gr->SubPlot(2,2,3,""); gr->Title("'i' style"); + gr->Box(); gr->Region(y1,y2,"ir"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2"); + return 0; +} +@end verbatim + +@pfig{region, Example of Region()} + +@c ------------------------------------------------------------------ +@external{} +@node Stem sample, Bars sample, Region sample, 1D samples +@subsection Stem sample +@nav{} + +Function @ref{stem} draw vertical bars. It is most attractive if markers are drawn too. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)"); + gr->Box(); gr->Stem(y); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Stem(xc,yc,z,"rx"); + + gr->SubPlot(2,2,2,""); gr->Title("'!' style"); + gr->Box(); gr->Stem(y,"o!rgb"); + return 0; +} +@end verbatim + +@pfig{stem, Example of Stem()} + +@c ------------------------------------------------------------------ +@external{} +@node Bars sample, Barh sample, Stem sample, 1D samples +@subsection Bars sample +@nav{} + +Function @ref{bars} draw vertical bars. It have a lot of options: bar-above-bar (@samp{a} style), fall like (@samp{f} style), 2 colors for positive and negative values, wired bars (@samp{#} style), 3D variant. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)"); + gr->Box(); gr->Bars(ys); + + gr->SubPlot(3,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Bars(ys,"cbgGyr"); + + gr->SubPlot(3,2,4,""); gr->Title("'\\#' style"); + gr->Box(); gr->Bars(ys,"#"); + + gr->SubPlot(3,2,5); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); + mglData yc(30), xc(30), z(30); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + gr->Bars(xc,yc,z,"r"); + + gr->SetRanges(-1,1,-3,3); + gr->SubPlot(3,2,2,""); gr->Title("'a' style"); + gr->Box(); gr->Bars(ys,"a"); + + gr->SubPlot(3,2,3,""); gr->Title("'f' style"); + gr->Box(); gr->Bars(ys,"f"); + return 0; +} +@end verbatim + +@pfig{bars, Example of Bars()} + +@c ------------------------------------------------------------------ +@external{} +@node Barh sample, Cones sample, Bars sample, 1D samples +@subsection Barh sample +@nav{} + +Function @ref{barh} is the similar to @code{Bars} but draw horizontal bars. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SetOrigin(0,0,0); + gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)"); + gr->Box(); gr->Barh(ys); + + gr->SubPlot(2,2,1,""); gr->Title("2 colors"); + gr->Box(); gr->Barh(ys,"cbgGyr"); + + gr->SetRanges(-3,3,-1,1); + gr->SubPlot(2,2,2,""); gr->Title("'a' style"); + gr->Box(); gr->Barh(ys,"a"); + + gr->SubPlot(2,2,3,""); gr->Title("'f' style"); + gr->Box(); gr->Barh(ys,"f"); + return 0; +} +@end verbatim + +@pfig{barh, Example of Barh()} + +@c ------------------------------------------------------------------ +@external{} +@node Cones sample, Chart sample, Barh sample, 1D samples +@subsection Cones sample +@nav{} + +Function @ref{cones} is similar to @code{Bars} but draw cones. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->Light(true); gr->SetOrigin(0,0,0); + gr->SubPlot(3,2,0); gr->Title("Cones plot"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys); + + gr->SubPlot(3,2,1); gr->Title("2 colors"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"cbgGyr"); + + gr->SubPlot(3,2,2); gr->Title("'#' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"#"); + + gr->SubPlot(3,2,3); gr->Title("'a' style"); + gr->SetRange('z',-2,2); // increase range since summation can exceed [-1,1] + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"a"); + + gr->SubPlot(3,2,4); gr->Title("'t' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"t"); + + gr->SubPlot(3,2,5); gr->Title("'4' style"); + gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"4"); + return 0; +} +@end verbatim + +@pfig{cones, Example of Cones()} + +@c ------------------------------------------------------------------ +@external{} +@node Chart sample, BoxPlot sample, Cones sample, 1D samples +@subsection Chart sample +@nav{} + +Function @ref{chart} draw colored boxes with width proportional to data values. Use @samp{ } for empty box. Plot looks most attractive in polar coordinates -- well known pie chart. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ch(7,2); for(int i=0;i<7*2;i++) ch.a[i]=mgl_rnd()+0.1; + gr->SubPlot(2,2,0); gr->Title("Chart plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Chart(ch); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"#"); + + gr->SubPlot(2,2,2); gr->Title("Pie chart; ' ' color"); + gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); + + gr->SubPlot(2,2,3); gr->Title("Ring chart; ' ' color"); + gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)",""); + gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#"); + return 0; +} +@end verbatim + +@pfig{chart, Example of Chart()} + +@c ------------------------------------------------------------------ +@external{} +@node BoxPlot sample, Candle sample, Chart sample, 1D samples +@subsection BoxPlot sample +@nav{} + +Function @ref{boxplot} draw box-and-whisker diagram. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(10,7); a.Modify("(2*rnd-1)^3/2"); + gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot"); + gr->Box(); gr->BoxPlot(a); + return 0; +} +@end verbatim + +@pfig{boxplot, Example of BoxPlot()} + +@c ------------------------------------------------------------------ +@external{} +@node Candle sample, OHLC sample, BoxPlot sample, 1D samples +@subsection Candle sample +@nav{} + +Function @ref{candle} draw candlestick chart. This is a combination of a line-chart and a bar-chart, in that each bar represents the range of price movement over a given time interval. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y(30); gr->Fill(y,"sin(pi*x/2)^2"); + mglData y1(30); gr->Fill(y1,"v/2",y); + mglData y2(30); gr->Fill(y2,"(1+v)/2",y); + gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)"); + gr->SetRange('y',0,1); gr->Box(); gr->Candle(y,y1,y2); + return 0; +} +@end verbatim + +@pfig{candle, Example of Candle()} + +@c ------------------------------------------------------------------ +@external{} +@node OHLC sample, Error sample, Candle sample, 1D samples +@subsection OHLC sample +@nav{} + +Function @ref{ohlc} draw Open-High-Low-Close diagram. This diagram show vertical line for between maximal(high) and minimal(low) values, as well as horizontal lines before/after vertical line for initial(open)/final(close) values of some process. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData o(10), h(10), l(10), c(10); + gr->Fill(o,"0.5*sin(pi*x)"); gr->Fill(c,"0.5*sin(pi*(x+2/9))"); + gr->Fill(l,"0.3*rnd-0.8"); gr->Fill(h,"0.3*rnd+0.5"); + gr->SubPlot(1,1,0,""); gr->Title("OHLC plot"); + gr->Box(); gr->OHLC(o,h,l,c); + return 0; +} +@end verbatim + +@pfig{ohlc, Example of OHLC()} + +@c ------------------------------------------------------------------ +@external{} +@node Error sample, Mark sample, OHLC sample, 1D samples +@subsection Error sample +@nav{} + +Function @ref{error} draw error boxes around the points. You can draw default boxes or semi-transparent symbol (like marker, see @ref{Line styles}). Also you can set individual color for each box. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData x0(10), y0(10), ex0(10), ey0(10); + mreal x; + for(int i=0;i<10;i++) + { + x = i/9.; + x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05; + y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1; + ey0.a[i]=0.2; ex0.a[i]=0.1; + } + + gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"ko"); + + gr->SubPlot(2,2,1,""); gr->Title("'!' style; no e_x"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ey0,"o!rgb"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\@' style"); + gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + for(int i=0;i<10;i++) + gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1), + mglPoint(0.2,0.2,0.2),"bo"); + gr->Axis(); + return 0; +} +@end verbatim + +@pfig{error, Example of Error()} + +Additionally, you can use solid large "marks" instead of error boxes by selecting proper style. +@verbatim +int sample(mglGraph *gr) +{ + mglData x0(10), y0(10), ex(10), ey(10); + for(int i=0;i<10;i++) + { x0.a[i] = mgl_rnd(); y0.a[i] = mgl_rnd(); ey.a[i] = ex.a[i] = 0.1; } + gr->SetRanges(0,1,0,1); gr->Alpha(true); + gr->SubPlot(4,3,0,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#+@"); + gr->SubPlot(4,3,1,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#x@"); + gr->SubPlot(4,3,2,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#s@","alpha 0.5"); + gr->SubPlot(4,3,3,""); gr->Box(); gr->Error(x0,y0,ex,ey,"s@"); + gr->SubPlot(4,3,4,""); gr->Box(); gr->Error(x0,y0,ex,ey,"d@"); + gr->SubPlot(4,3,5,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#d@","alpha 0.5"); + gr->SubPlot(4,3,6,""); gr->Box(); gr->Error(x0,y0,ex,ey,"+@"); + gr->SubPlot(4,3,7,""); gr->Box(); gr->Error(x0,y0,ex,ey,"x@"); + gr->SubPlot(4,3,8,""); gr->Box(); gr->Error(x0,y0,ex,ey,"o@"); + gr->SubPlot(4,3,9,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#o@","alpha 0.5"); + gr->SubPlot(4,3,10,""); gr->Box(); gr->Error(x0,y0,ex,ey,"#.@"); + gr->SubPlot(4,3,11,""); gr->Box(); gr->Error(x0,y0,ex,ey); +} +@end verbatim + +@pfig{error2, Example of Error() with marks} + +@c ------------------------------------------------------------------ +@external{} +@node Mark sample, TextMark sample, Error sample, 1D samples +@subsection Mark sample +@nav{} + +Function @ref{mark} draw markers at points. It is mostly the same as @code{Plot} but marker size can be variable. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)"); + gr->Box(); gr->Mark(y,y1,"s"); + return 0; +} +@end verbatim + +@pfig{mark, Example of Mark()} + +@c ------------------------------------------------------------------ +@external{} +@node TextMark sample, Label sample, Mark sample, 1D samples +@subsection TextMark sample +@nav{} + +Function @ref{textmark} like @code{Mark} but draw text instead of markers. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1; mgls_prepare1d(&y,&y1); + gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)"); + gr->Box(); gr->TextMark(y,y1,"\\gamma","r"); + return 0; +} +@end verbatim + +@pfig{textmark, Example of TextMark()} + +@c ------------------------------------------------------------------ +@external{} +@node Label sample, Table sample, TextMark sample, 1D samples +@subsection Label sample +@nav{} + +Function @ref{label} print text at data points. The string may contain @samp{%x}, @samp{%y}, @samp{%z} for x-, y-, z-coordinates of points, @samp{%n} for point index. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10); ys.Modify("0.8*sin(pi*2*x)+0.2*rnd"); + gr->SubPlot(1,1,0,""); gr->Title("Label plot"); + gr->Box(); gr->Plot(ys," *"); gr->Label(ys,"y=%y"); + return 0; +} +@end verbatim + +@pfig{label, Example of Label()} + +@c ------------------------------------------------------------------ +@external{} +@node Table sample, Tube sample, Label sample, 1D samples +@subsection Table sample +@nav{} + +Function @ref{table} draw table with data values. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd"); + gr->SubPlot(2,2,0); gr->Title("Table plot"); + gr->Table(ys,"y_1\ny_2\ny_3"); gr->Box(); + gr->SubPlot(2,2,1); gr->Title("no borders, colored"); + gr->Table(ys,"y_1\ny_2\ny_3","r|"); + gr->SubPlot(2,2,2); gr->Title("no font decrease"); + gr->Table(ys,"y_1\ny_2\ny_3","#"); + gr->SubPlot(2,2,3); gr->Title("manual width, position"); + gr->Table(0.5, 0.95, ys,"y_1\ny_2\ny_3","#", "value 0.7"); gr->Box(); + return 0; +} +@end verbatim + +@pfig{table, Example of Table()} + + +@c ------------------------------------------------------------------ +@external{} +@node Tube sample, Tape sample, Table sample, 1D samples +@subsection Tube sample +@nav{} + +Function @ref{tube} draw tube with variable radius. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y,y1,y2; mgls_prepare1d(&y,&y1,&y2); y1/=20; + gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)"); + gr->Light(true); gr->Box(); gr->Tube(y,0.05); + + gr->SubPlot(2,2,1,""); gr->Title("variable radius"); + gr->Box(); gr->Tube(y,y1); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Tube(y,0.05,"#"); + mglData yc(50), xc(50), z(50); z.Modify("2*x-1"); + yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)"); + + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Tube(xc,yc,z,y2,"r"); + return 0; +} +@end verbatim + +@pfig{tube, Example of Tube()} + + +@c ------------------------------------------------------------------ +@external{} +@node Tape sample, Torus sample, Tube sample, 1D samples +@subsection Tape sample +@nav{} + +Function @ref{tape} draw tapes which rotate around the curve as normal and binormal. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y; mgls_prepare1d(&y); + mglData xc(50), yc(50), z(50); + yc.Modify("sin(pi*(2*x-1))"); + xc.Modify("cos(pi*2*x-pi)"); z.Fill(-1,1); + gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)"); + gr->Box(); gr->Tape(y); gr->Plot(y,"k"); + + gr->SubPlot(2,2,1); gr->Title("3d variant, 2 colors"); + gr->Rotate(50,60); gr->Light(true); + gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"rg"); + + gr->SubPlot(2,2,2); gr->Title("3d variant, x only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); + gr->Tape(xc,yc,z,"xr"); gr->Tape(xc,yc,z,"xr#"); + + gr->SubPlot(2,2,3); gr->Title("3d variant, z only"); gr->Rotate(50,60); + gr->Box(); gr->Plot(xc,yc,z,"k"); + gr->Tape(xc,yc,z,"zg"); gr->Tape(xc,yc,z,"zg#"); + return 0; +} +@end verbatim + +@pfig{tape, Example of Tape()} + + +@c ------------------------------------------------------------------ +@external{} +@node Torus sample, , Tape sample, 1D samples +@subsection Torus sample +@nav{} + +Function @ref{torus} draw surface of the curve rotation. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData y1,y2; mgls_prepare1d(0,&y1,&y2); + gr->SubPlot(2,2,0); gr->Title("Torus plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2); + if(mini) return; + + gr->SubPlot(2,2,1); gr->Title("'x' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"x"); + + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"z"); + + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); + gr->Box(); gr->Torus(y1,y2,"#"); + return 0; +} +@end verbatim + +@pfig{torus, Example of Torus()} + + +@c ------------------------------------------------------------------ +@external{} +@node 2D samples, 3D samples, 1D samples, Examples +@section 2D samples +@nav{} + +This section is devoted to visualization of 2D data arrays. 2D means the data which depend on 2 indexes (parameters) like matrix z(i,j)=z(x(i),y(j)), i=1...n, j=1...m or in parametric form @{x(i,j),y(i,j),z(i,j)@}. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare2d(mglData *a, mglData *b=0, mglData *v=0) +{ + register long i,j,n=50,m=40,i0; + if(a) a->Create(n,m); if(b) b->Create(n,m); + if(v) { v->Create(9); v->Fill(-1,1); } + mreal x,y; + for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare2d(HMDT a, HMDT b=0, HMDT v=0) +{ + register long i,j,n=50,m=40,i0; + if(a) mgl_data_create(a,n,m,1); + if(b) mgl_data_create(b,n,m,1); + if(v) { mgl_data_create(v,9,1,1); mgl_data_fill(v,-1,1,'x'); } + mreal x,y; + for(i=0;iSubPlot(2,2,0); gr->Title("Surf plot (default)"); + gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Surf(a); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style; meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"#","meshnum 10"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a,"."); + + gr->SubPlot(2,2,3); gr->Title("parametric form"); + mglData x(50,40),y(50,40),z(50,40); + gr->Fill(x,"0.8*sin(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(y,"0.8*cos(pi*x)*sin(pi*(y+1)/2)"); + gr->Fill(z,"0.8*cos(pi*(y+1)/2)"); + gr->Rotate(50,60); gr->Box(); gr->Surf(x,y,z,"BbwrR"); + return 0; +} +@end verbatim + +@pfig{surf, Example of Surf()} + +@c ------------------------------------------------------------------ +@external{} +@node SurfC sample, SurfA sample, Surf sample, 2D samples +@subsection SurfC sample +@nav{} + +Function @ref{surfc} is similar to @ref{surf} but its coloring is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->Title("SurfC plot"); gr->Rotate(50,60); + gr->Light(true); gr->Box(); gr->SurfC(a,b); + return 0; +} +@end verbatim + +@pfig{surfc, Example of SurfC()} + +@c ------------------------------------------------------------------ +@external{} +@node SurfA sample, Mesh sample, SurfC sample, 2D samples +@subsection SurfA sample +@nav{} + +Function @ref{surfa} is similar to @ref{surf} but its transparency is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->Title("SurfA plot"); gr->Rotate(50,60); + gr->Alpha(true); gr->Light(true); + gr->Box(); gr->SurfA(a,b); + return 0; +} +@end verbatim + +@pfig{surfa, Example of SurfA()} + + +@c ------------------------------------------------------------------ +@external{} +@node Mesh sample, Fall sample, SurfA sample, 2D samples +@subsection Mesh sample +@nav{} + +Function @ref{mesh} draw wired surface. You can use @ref{meshnum} for changing number of lines to be drawn. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Mesh plot"); gr->Rotate(50,60); + gr->Box(); gr->Mesh(a); + return 0; +} +@end verbatim + +@pfig{mesh, Example of Mesh()} + +@c ------------------------------------------------------------------ +@external{} +@node Fall sample, Belt sample, Mesh sample, 2D samples +@subsection Fall sample +@nav{} + +Function @ref{fall} draw waterfall surface. You can use @ref{meshnum} for changing number of lines to be drawn. Also you can use @samp{x} style for drawing lines in other direction. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Fall plot"); gr->Rotate(50,60); + gr->Box(); gr->Fall(a); + return 0; +} +@end verbatim + +@pfig{fall, Example of Fall()} + +@c ------------------------------------------------------------------ +@external{} +@node Belt sample, Boxs sample, Fall sample, 2D samples +@subsection Belt sample +@nav{} + +Function @ref{belt} draw surface by belts. You can use @samp{x} style for drawing lines in other direction. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Belt plot"); gr->Rotate(50,60); + gr->Box(); gr->Belt(a); + return 0; +} +@end verbatim + +@pfig{belt, Example of Belt()} + +@c ------------------------------------------------------------------ +@external{} +@node Boxs sample, Tile sample, Belt sample, 2D samples +@subsection Boxs sample +@nav{} + +Function @ref{boxs} draw surface by boxes. You can use @samp{#} for drawing wire plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SetOrigin(0,0,0); gr->Light(true); + gr->SubPlot(2,2,0); gr->Title("Boxs plot (default)"); + gr->Rotate(40,60); gr->Box(); gr->Boxs(a); + + gr->SubPlot(2,2,1); gr->Title("'\\@' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"@"); + + gr->SubPlot(2,2,2); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Boxs(a,"#"); + + gr->SubPlot(2,2,3); gr->Title("compare with Tile"); + gr->Rotate(50,60); gr->Box(); gr->Tile(a); + return 0; +} +@end verbatim + +@pfig{boxs, Example of Boxs()} + +@c ------------------------------------------------------------------ +@external{} +@node Tile sample, TileS sample, Boxs sample, 2D samples +@subsection Tile sample +@nav{} + +Function @ref{tile} draw surface by tiles. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Tile plot"); + gr->Rotate(40,60); gr->Box(); gr->Tile(a); + return 0; +} +@end verbatim + +@pfig{tile, Example of Tile()} + +@c ------------------------------------------------------------------ +@external{} +@node TileS sample, Dens sample, Tile sample, 2D samples +@subsection TileS sample +@nav{} + +Function @ref{tiles} is similar to @code{Tile} but tile sizes is determined by another data. This allows one to simulate transparency of the plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2d(&a,&b); + gr->SubPlot(1,1,0,""); gr->Title("TileS plot"); + gr->Box(); gr->TileS(a,b); + return 0; +} +@end verbatim + +@pfig{tiles, Example of TileS()} + + +@c ------------------------------------------------------------------ +@external{} +@node Dens sample, Cont sample, TileS sample, 2D samples +@subsection Dens sample +@nav{} + +Function @ref{dens} draw density plot for surface. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,a1(30,40,3); mgls_prepare2d(&a); + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,0,""); gr->Title("Dens plot (default)"); + gr->Box(); gr->Dens(a); + + gr->SubPlot(2,2,1); gr->Title("3d variant"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style; meshnum 10"); + gr->Box(); gr->Dens(a,"#","meshnum 10"); + + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->Dens(a1); + return 0; +} +@end verbatim + +@pfig{dens, Example of Dens()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont sample, ContF sample, Dens sample, 2D samples +@subsection Cont sample +@nav{} + +Function @ref{cont} draw contour lines for surface. You can select automatic (default) or manual levels for contours, print contour labels, draw it on the surface (default) or at plane (as @code{Dens}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("Cont plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->Cont(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->Cont(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->Cont(a,"_"); + + gr->SubPlot(2,2,3,""); gr->Title("'t' style"); + gr->Box(); gr->Cont(a,"t"); + return 0; +} +@end verbatim + +@pfig{cont, Example of Cont()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF sample, ContD sample, Cont sample, 2D samples +@subsection ContF sample +@nav{} + +Function @ref{contf} draw filled contours. You can select automatic (default) or manual levels for contours. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContF plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContF(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a,"_"); + + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContF(a1); + return 0; +} +@end verbatim + +@pfig{contf, Example of ContF()} + +@c ------------------------------------------------------------------ +@external{} +@node ContD sample, ContV sample, ContF sample, 2D samples +@subsection ContD sample +@nav{} + +Function @ref{contd} is similar to @code{ContF} but with manual contour colors. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5),a1(30,40,3); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContD plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContD(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a,"_"); + + gr->Fill(a1,"0.6*sin(2*pi*x+pi*(z+1)/2)*sin(3*pi*y+pi*z) + 0.4*cos(3*pi*(x*y)+pi*(z+1)^2/2)"); + gr->SubPlot(2,2,3); gr->Title("several slices"); + gr->Rotate(50,60); gr->Box(); gr->ContD(a1); + return 0; +} +@end verbatim + +@pfig{contd, Example of ContD()} + +@c ------------------------------------------------------------------ +@external{} +@node ContV sample, Axial sample, ContD sample, 2D samples +@subsection ContV sample +@nav{} + +Function @ref{contv} draw vertical cylinders (belts) at contour lines. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,v(5); mgls_prepare2d(&a); v.a[0]=-0.5; + v.a[1]=-0.15; v.a[2]=0; v.a[3]=0.15; v.a[4]=0.5; + gr->SubPlot(2,2,0); gr->Title("ContV plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->ContV(a); + + gr->SubPlot(2,2,1); gr->Title("manual levels"); + gr->Rotate(50,60); gr->Box(); gr->ContV(v,a); + + gr->SubPlot(2,2,2); gr->Title("'\\_' style"); + gr->Rotate(50,60); gr->Box(); gr->ContV(a,"_"); + + gr->SubPlot(2,2,3); gr->Title("ContV and ContF"); + gr->Rotate(50,60); gr->Box(); gr->Light(true); + gr->ContV(a); gr->ContF(a); gr->Cont(a,"k"); + return 0; +} +@end verbatim + +@pfig{contv, Example of ContV()} + +@c ------------------------------------------------------------------ +@external{} +@node Axial sample, Grad sample, ContV sample, 2D samples +@subsection Axial sample +@nav{} + +Function @ref{axial} draw surfaces of rotation for contour lines. You can draw wire surfaces (@samp{#} style) or ones rotated in other directions (@samp{x}, @samp{z} styles). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("Axial plot (default)"); + gr->Light(true); gr->Alpha(true); gr->Rotate(50,60); + gr->Box(); gr->Axial(a); + + gr->SubPlot(2,2,1); gr->Title("'x' style;'.' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"x."); + + gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"z"); + + gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60); + gr->Box(); gr->Axial(a,"#"); + return 0; +} +@end verbatim + +@pfig{axial, Example of Axial()} + +@c ------------------------------------------------------------------ +@external{} +@node Grad sample, , Axial sample, 2D samples +@subsection Grad sample +@nav{} + +Function @ref{grad} draw gradient lines for matrix. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(1,1,0,""); gr->Title("Grad plot"); + gr->Box(); gr->Grad(a); gr->Dens(a,"{u8}w{q8}"); + return 0; +} +@end verbatim + +@pfig{grad, Example of Grad()} + + +@c ------------------------------------------------------------------ +@external{} +@node 3D samples, Vector field samples, 2D samples, Examples +@section 3D samples +@nav{} + +This section is devoted to visualization of 3D data arrays. 3D means the data which depend on 3 indexes (parameters) like tensor a(i,j,k)=a(x(i),y(j),x(k)), i=1...n, j=1...m, k=1...l or in parametric form @{x(i,j,k),y(i,j,k),z(i,j,k),a(i,j,k)@}. Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare3d(mglData *a, mglData *b=0) +{ + register long i,j,k,n=61,m=50,l=40,i0; + if(a) a->Create(n,m,l); if(b) b->Create(n,m,l); + mreal x,y,z; + for(i=0;ia[i0] = -2*(x*x + y*y + z*z*z*z - z*z - 0.1); + if(b) b->a[i0] = 1-2*tanh((x+y)*(x+y)); + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare3d(HMDT a, HMDT b=0) +{ + register long i,j,k,n=61,m=50,l=40,i0; + if(a) mgl_data_create(a,n,m,l); + if(b) mgl_data_create(b,n,m,l); + mreal x,y,z; + for(i=0;iLight(true); gr->Alpha(true); + gr->SubPlot(2,2,0); gr->Title("Surf3 plot (default)"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c); + + gr->SubPlot(2,2,1); gr->Title("'\\#' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"#"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Surf3(c,"."); + return 0; +} +@end verbatim + +@pfig{surf3, Example of Surf3()} + +@c ------------------------------------------------------------------ +@external{} +@node Surf3C sample, Surf3A sample, Surf3 sample, 3D samples +@subsection Surf3C sample +@nav{} + +Function @ref{surf3c} is similar to @ref{surf3} but its coloring is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + gr->Title("Surf3C plot"); gr->Rotate(50,60); + gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3C(c,d); + return 0; +} +@end verbatim + +@pfig{surf3c, Example of Surf3C()} + +@c ------------------------------------------------------------------ +@external{} +@node Surf3A sample, Cloud sample, Surf3C sample, 3D samples +@subsection Surf3A sample +@nav{} + +Function @ref{surf3a} is similar to @ref{surf3} but its transparency is determined by another data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c,d; mgls_prepare3d(&c,&d); + gr->Title("Surf3A plot"); gr->Rotate(50,60); + gr->Light(true); gr->Alpha(true); + gr->Box(); gr->Surf3A(c,d); + return 0; +} +@end verbatim + +@pfig{surf3a, Example of Surf3A()} + +@c ------------------------------------------------------------------ +@external{} +@node Cloud sample, Dens3 sample, Surf3A sample, 3D samples +@subsection Cloud sample +@nav{} + +Function @ref{cloud} draw cloud-like object which is less transparent for higher data values. Similar plot can be created using many (about 10-20) @code{Surf3A(a,a)} isosurfaces. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->SubPlot(2,2,0); gr->Title("Cloud plot"); + gr->Rotate(50,60); gr->Alpha(true); + gr->Box(); gr->Cloud(c,"wyrRk"); + + gr->SubPlot(2,2,1); gr->Title("'i' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"iwyrRk"); + + gr->SubPlot(2,2,2); gr->Title("'.' style"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,".wyrRk"); + + gr->SubPlot(2,2,3); gr->Title("meshnum 10"); + gr->Rotate(50,60); gr->Box(); gr->Cloud(c,"wyrRk","meshnum 10"); + return 0; +} +@end verbatim + +@pfig{cloud, Example of Cloud()} + +@c ------------------------------------------------------------------ +@external{} +@node Dens3 sample, Cont3 sample, Cloud sample, 3D samples +@subsection Dens3 sample +@nav{} + +Function @ref{dens3} draw just usual density plot but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Dens3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Dens3(c,"x"); gr->Dens3(c); gr->Dens3(c,"z"); + return 0; +} +@end verbatim + +@pfig{densa, Example of Dens3()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont3 sample, ContF3 sample, Dens3 sample, 3D samples +@subsection Cont3 sample +@nav{} + +Function @ref{cont3} draw just usual contour lines but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->Cont3(c,"x"); gr->Cont3(c); gr->Cont3(c,"z"); + return 0; +} +@end verbatim + +@pfig{conta, Example of Cont3()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF3 sample, Dens projection sample, Cont3 sample, 3D samples +@subsection ContF3 sample +@nav{} + +Function @ref{contf3} draw just usual filled contours but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("ContF3 sample"); gr->Rotate(50,60); + gr->Alpha(true); gr->SetAlphaDef(0.7); + gr->SetOrigin(0,0,0); gr->Axis("_xyz"); gr->Box(); + gr->ContF3(c,"x"); gr->ContF3(c); gr->ContF3(c,"z"); + gr->Cont3(c,"kx"); gr->Cont3(c,"k"); gr->Cont3(c,"kz"); + return 0; +} +@end verbatim + +@pfig{contfa, Example of ContF3()} + +@c ------------------------------------------------------------------ +@external{} +@node Dens projection sample, Cont projection sample, ContF3 sample, 3D samples +@subsection Dens projection sample +@nav{} + +Functions @ref{densz}, @ref{densy}, @ref{densx} draw density plot on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Dens[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->DensX(c.Sum("x"),0,-1); + gr->DensY(c.Sum("y"),0,1); gr->DensZ(c.Sum("z"),0,-1); + return 0; +} +@end verbatim + +@pfig{dens_xyz, Example of DensX() DensY() DensZ()} + +@c ------------------------------------------------------------------ +@external{} +@node Cont projection sample, ContF projection sample, Dens projection sample, 3D samples +@subsection Cont projection sample +@nav{} + +Functions @ref{contz}, @ref{conty}, @ref{contx} draw contour lines on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->ContX(c.Sum("x"),"",-1); + gr->ContY(c.Sum("y"),"",1); gr->ContZ(c.Sum("z"),"",-1); + return 0; +} +@end verbatim + +@pfig{cont_xyz, Example of ContX() ContY() ContZ()} + +@c ------------------------------------------------------------------ +@external{} +@node ContF projection sample, TriPlot and QuadPlot, Cont projection sample, 3D samples +@subsection ContF projection sample +@nav{} + +Functions @ref{contfz}, @ref{contfy}, @ref{contfx} draw filled contours on plane perpendicular to corresponding axis. One of possible application is drawing projections of 3D field. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData c; mgls_prepare3d(&c); + gr->Title("Cont[XYZ] sample"); gr->Rotate(50,60); + gr->Box(); gr->ContFX(c.Sum("x"),"",-1); + gr->ContFY(c.Sum("y"),"",1); gr->ContFZ(c.Sum("z"),"",-1); + return 0; +} +@end verbatim + +@pfig{contf_xyz, Example of ContFX() ContFY() ContFZ()} + +@c ------------------------------------------------------------------ +@external{} +@node TriPlot and QuadPlot, Dots sample, ContF projection sample, 3D samples +@subsection TriPlot and QuadPlot +@nav{} + +Function @ref{triplot} and @ref{quadplot} draw set of triangles (or quadrangles for @code{QuadPlot}) for irregular data arrays. Note, that you have to provide not only vertexes, but also the indexes of triangles or quadrangles. I.e. perform triangulation by some other library. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mreal q[] = {0,1,2,3, 4,5,6,7, 0,2,4,6, 1,3,5,7, 0,4,1,5, 2,6,3,7}; + mreal xc[] = {-1,1,-1,1,-1,1,-1,1}, yc[] = {-1,-1,1,1,-1,-1,1,1}, zc[] = {-1,-1,-1,-1,1,1,1,1}; + mglData qq(6,4,q), xx(8,xc), yy(8,yc), zz(8,zc); + gr->Light(true); //gr->Alpha(true); + gr->SubPlot(2,2,0); gr->Title("QuadPlot sample"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + gr->SubPlot(2,2,2); gr->Title("QuadPlot coloring"); gr->Rotate(50,60); + gr->QuadPlot(qq,xx,yy,zz,yy,"yr"); + gr->QuadPlot(qq,xx,yy,zz,"k#"); + + mreal t[] = {0,1,2, 0,1,3, 0,2,3, 1,2,3}; + mreal xt[] = {-1,1,0,0}, yt[] = {-1,-1,1,0}, zt[] = {-1,-1,-1,1}; + mglData tt(4,3,t), uu(4,xt), vv(4,yt), ww(4,zt); + gr->SubPlot(2,2,1); gr->Title("TriPlot sample"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,"b"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->SubPlot(2,2,3); gr->Title("TriPlot coloring"); gr->Rotate(50,60); + gr->TriPlot(tt,uu,vv,ww,vv,"cb"); + gr->TriPlot(tt,uu,vv,ww,"k#"); + gr->TriCont(tt,uu,vv,ww,"B"); + return 0; +} +@end verbatim + +@pfig{triplot, Example of TriPlot() and QuadPlot()} + +@c ------------------------------------------------------------------ +@external{} +@node Dots sample, , TriPlot and QuadPlot, 3D samples +@subsection Dots sample +@nav{} + +Function @ref{dots} is another way to draw irregular points. @code{Dots} use color scheme for coloring (see @ref{Color scheme}). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + int i, n=1000; + mglData x(n),y(n),z(n); + for(i=0;iTitle("Dots sample"); gr->Rotate(50,60); + gr->Box(); gr->Dots(x,y,z); + return 0; +} +@end verbatim + +@pfig{dots, Example of Dots()} + +@c ------------------------------------------------------------------ +@external{} +@node Vector field samples, Hints, 3D samples, Examples +@section Vector field samples +@nav{} + +Vector field visualization (especially in 3d case) is more or less complex task. MathGL provides 3 general types of plots: vector field itself (@code{Vect}), flow threads (@code{Flow}), and flow pipes with radius proportional to field amplitude (@code{Pipe}). + +However, the plot may look tangly -- there are too many overlapping lines. I may suggest 2 ways to solve this problem. The first one is to change @code{SetMeshNum} for decreasing the number of hachures. The second way is to use the flow thread chart @code{Flow}, or possible many flow thread from manual position (@code{FlowP}). Unfortunately, I don't know any other methods to visualize 3d vector field. If you know any, e-mail me and I shall add it to MathGL. + +Most of samples will use the same data for plotting. So, I put its initialization in separate function +@verbatim +void mgls_prepare2v(mglData *a, mglData *b) +{ + register long i,j,n=20,m=30,i0; + if(a) a->Create(n,m); if(b) b->Create(n,m); + mreal x,y; + for(i=0;ia[i0] = 0.6*sin(2*M_PI*x)*sin(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + if(b) b->a[i0] = 0.6*cos(2*M_PI*x)*cos(3*M_PI*y)+0.4*cos(3*M_PI*x*y); + } +} +void mgls_prepare3v(mglData *ex, mglData *ey, mglData *ez) +{ + register long i,j,k,n=10,i0; + if(!ex || !ey || !ez) return; + ex->Create(n,n,n); ey->Create(n,n,n); ez->Create(n,n,n); + mreal x,y,z, r1,r2; + for(i=0;ia[i0]=0.2*x/r1 - 0.2*x/r2; + ey->a[i0]=0.2*y/r1 - 0.2*y/r2; + ez->a[i0]=0.2*(z-0.3)/r1 - 0.2*(z+0.3)/r2; + } +} +@end verbatim +or using C functions +@verbatim +void mgls_prepare2v(HMDT a, HMDT b) +{ + register long i,j,n=20,m=30,i0; + if(a) mgl_data_create(a,n,m,1); + if(b) mgl_data_create(b,n,m,1); + mreal x,y; + for(i=0;iSubPlot(3,2,0,""); gr->Title("Vect plot (default)"); + gr->Box(); gr->Vect(a,b); + + gr->SubPlot(3,2,1,""); gr->Title("'.' style; '=' style"); + gr->Box(); gr->Vect(a,b,"=."); + + gr->SubPlot(3,2,2,""); gr->Title("'f' style"); + gr->Box(); gr->Vect(a,b,"f"); + + gr->SubPlot(3,2,3,""); gr->Title("'>' style"); + gr->Box(); gr->Vect(a,b,">"); + + gr->SubPlot(3,2,4,""); gr->Title("'<' style"); + gr->Box(); gr->Vect(a,b,"<"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(3,2,5); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Vect(ex,ey,ez); + return 0; +} +@end verbatim + +@pfig{vect, Example of Vect()} + +@c ------------------------------------------------------------------ +@external{} +@node Vect3 sample, Traj sample, Vect sample, Vector field samples +@subsection Vect3 sample +@nav{} + +Function @ref{vect3} draw just usual vector field plot but at slices of 3D data. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,1,0); gr->Title("Vect3 sample"); gr->SetOrigin(0,0,0); + gr->Rotate(50,60); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"x"); gr->Vect3(ex,ey,ez); gr->Vect3(ex,ey,ez,"z"); + + gr->SubPlot(2,1,1); gr->Title("'f' style"); + gr->Rotate(50,60); gr->Axis("_xyz"); gr->Box(); + gr->Vect3(ex,ey,ez,"fx"); gr->Vect3(ex,ey,ez,"f");gr->Vect3(ex,ey,ez,"fz"); + gr->Grid3(ex,"Wx"); gr->Grid3(ex,"W"); gr->Grid3(ex,"Wz"); + return 0; +} +@end verbatim + +@pfig{vecta, Example of Vect3()} + +@c ------------------------------------------------------------------ +@external{} +@node Traj sample, Flow sample, Vect3 sample, Vector field samples +@subsection Traj sample +@nav{} + +Function @ref{traj} is 1D analogue of @code{Vect}. It draw vectors from specified points. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData x,y,y1,y2; mgls_prepare1d(&y,&y1,&y2,&x); + gr->SubPlot(1,1,0,""); gr->Title("Traj plot"); + gr->Box(); gr->Plot(x,y); gr->Traj(x,y,y1,y2); + return 0; +} +@end verbatim + +@pfig{traj, Example of Traj()} + + +@c ------------------------------------------------------------------ +@external{} +@node Flow sample, Pipe sample, Traj sample, Vector field samples +@subsection Flow sample +@nav{} + +Function @ref{flow} is another standard way to visualize vector fields -- it draw lines (threads) which is tangent to local vector field direction. MathGL draw threads from edges of bounding box and from central slices. Sometimes it is not most appropriate variant -- you may want to use @code{FlowP} to specify manual position of threads. @code{Flow} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(2,2,0,""); gr->Title("Flow plot (default)"); + gr->Box(); gr->Flow(a,b); + + gr->SubPlot(2,2,1,""); gr->Title("'v' style"); + gr->Box(); gr->Flow(a,b,"v"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Flow(a,b,"#"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Flow(ex,ey,ez); + return 0; +} +@end verbatim + +@pfig{flow, Example of Flow()} + +@c ------------------------------------------------------------------ +@external{} +@node Pipe sample, Dew sample, Flow sample, Vector field samples +@subsection Pipe sample +@nav{} + +Function @ref{pipe} is similar to @ref{flow} but draw pipes (tubes) which radius is proportional to the amplitude of vector field. @code{Pipe} use color scheme for coloring (see @ref{Color scheme}). At this warm color corresponds to normal flow (like attractor), cold one corresponds to inverse flow (like source). The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(2,2,0,""); gr->Title("Pipe plot (default)"); + gr->Light(true); gr->Box(); gr->Pipe(a,b); + + gr->SubPlot(2,2,1,""); gr->Title("'i' style"); + gr->Box(); gr->Pipe(a,b,"i"); + + gr->SubPlot(2,2,2,""); gr->Title("'\\#' style"); + gr->Box(); gr->Pipe(a,b,"#"); + + mglData ex,ey,ez; mgls_prepare3v(&ex,&ey,&ez); + gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60); + gr->Box(); gr->Pipe(ex,ey,ez,"",0.1); + return 0; +} +@end verbatim + +@pfig{pipe, Example of Pipe()} + +@c ------------------------------------------------------------------ +@external{} +@node Dew sample, , Pipe sample, Vector field samples +@subsection Dew sample +@nav{} + +Function @ref{dew} is similar to @code{Vect} but use drops instead of arrows. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b; mgls_prepare2v(&a,&b); + gr->SubPlot(1,1,0,""); gr->Title("Dew plot"); + gr->Box(); gr->Light(true); gr->Dew(a,b); + return 0; +} +@end verbatim + +@pfig{dew, Example of Dew()} + + +@c ------------------------------------------------------------------ +@external{} +@node Hints, FAQ, Vector field samples, Examples +@section Hints +@nav{} + +In this section I've included some small hints and advices for the improving of the quality of plots and for the demonstration of some non-trivial features of MathGL library. In contrast to previous examples I showed mostly the idea but not the whole drawing function. + +@menu +* ``Compound'' graphics:: +* Transparency and lighting:: +* Types of transparency:: +* Axis projection:: +* Adding fog:: +* Lighting sample:: +* Using primitives:: +* STFA sample:: +* Mapping visualization:: +* Making regular data:: +* Making histogram:: +* Nonlinear fitting hints:: +* PDE solving hints:: +* MGL parser using:: +* Using options:: +* ``Templates'':: +* Stereo image:: +* Reduce memory usage:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node ``Compound'' graphics, Transparency and lighting, , Hints +@subsection ``Compound'' graphics +@nav{} + +As I noted above, MathGL functions (except the special one, like Clf()) do not erase the previous plotting but just add the new one. It allows one to draw ``compound'' plots easily. For example, popular Matlab command @code{surfc} can be emulated in MathGL by 2 calls: +@verbatim + Surf(a); + Cont(a, "_"); // draw contours at bottom +@end verbatim +Here @var{a} is 2-dimensional data for the plotting, @code{-1} is the value of z-coordinate at which the contour should be plotted (at the bottom in this example). Analogously, one can draw density plot instead of contour lines and so on. + +Another nice plot is contour lines plotted directly on the surface: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "BbcyrR"); // select 'jet' colormap for the surface + Cont(a, "y"); // and yellow color for contours +@end verbatim +The possible difficulties arise in black&white case, when the color of the surface can be close to the color of a contour line. In that case I may suggest the following code: +@verbatim + Light(true); // switch on light for the surface + Surf(a, "kw"); // select 'gray' colormap for the surface + CAxis(-1,0); // first draw for darker surface colors + Cont(a, "w"); // white contours + CAxis(0,1); // now draw for brighter surface colors + Cont(a, "k"); // black contours + CAxis(-1,1); // return color range to original state +@end verbatim +The idea is to divide the color range on 2 parts (dark and bright) and to select the contrasting color for contour lines for each of part. + +Similarly, one can plot flow thread over density plot of vector field amplitude (this is another amusing plot from Matlab) and so on. The list of compound graphics can be prolonged but I hope that the general idea is clear. + +Just for illustration I put here following sample code: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,b,d; mgls_prepare2v(&a,&b); d = a; + for(int i=0;iSubPlot(2,2,1,""); gr->Title("Flow + Dens"); + gr->Flow(a,b,"br"); gr->Dens(d,"BbcyrR"); gr->Box(); + + gr->SubPlot(2,2,0); gr->Title("Surf + Cont"); gr->Rotate(50,60); + gr->Light(true); gr->Surf(a); gr->Cont(a,"y"); gr->Box(); + + gr->SubPlot(2,2,2); gr->Title("Mesh + Cont"); gr->Rotate(50,60); + gr->Box(); gr->Mesh(a); gr->Cont(a,"_"); + + gr->SubPlot(2,2,3); gr->Title("Surf3 + ContF3");gr->Rotate(50,60); + gr->Box(); gr->ContF3(v,c,"z",0); gr->ContF3(v,c,"x"); gr->ContF3(v,c); + gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); + gr->ContF3(v,c,"z",c.nz-1); gr->Surf3(-0.5,c); + return 0; +} +@end verbatim + +@pfig{combined, Example of ``combined'' plots} + +@c ------------------------------------------------------------------ +@external{} +@node Transparency and lighting, Types of transparency, ``Compound'' graphics, Hints +@subsection Transparency and lighting +@nav{} + +Here I want to show how transparency and lighting both and separately change the look of a surface. So, there is code and picture for that: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("default"); gr->Rotate(50,60); + gr->Box(); gr->Surf(a); + + gr->SubPlot(2,2,1); gr->Title("light on"); gr->Rotate(50,60); + gr->Box(); gr->Light(true); gr->Surf(a); + + gr->SubPlot(2,2,3); gr->Title("alpha on; light on"); gr->Rotate(50,60); + gr->Box(); gr->Alpha(true); gr->Surf(a); + + gr->SubPlot(2,2,2); gr->Title("alpha on"); gr->Rotate(50,60); + gr->Box(); gr->Light(false); gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{alpha, Example of transparency and lightings} + +@c ------------------------------------------------------------------ +@external{} +@node Types of transparency, Axis projection, Transparency and lighting, Hints +@subsection Types of transparency +@nav{} + +MathGL library has advanced features for setting and handling the surface transparency. The simplest way to add transparency is the using of function @ref{alpha}. As a result, all further surfaces (and isosurfaces, density plots and so on) become transparent. However, their look can be additionally improved. + +The value of transparency can be different from surface to surface. To do it just use @code{SetAlphaDef} before the drawing of the surface, or use option @code{alpha} (see @ref{Command options}). If its value is close to 0 then the surface becomes more and more transparent. Contrary, if its value is close to 1 then the surface becomes practically non-transparent. + +Also you can change the way how the light goes through overlapped surfaces. The function @code{SetTranspType} defines it. By default the usual transparency is used (@samp{0}) -- surfaces below is less visible than the upper ones. A ``glass-like'' transparency (@samp{1}) has a different look -- each surface just decreases the background light (the surfaces are commutable in this case). + +A ``neon-like'' transparency (@samp{2}) has more interesting look. In this case a surface is the light source (like a lamp on the dark background) and just adds some intensity to the color. At this, the library sets automatically the black color for the background and changes the default line color to white. + +As example I shall show several plots for different types of transparency. The code is the same except the values of @code{SetTranspType} function: +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); + mglData a; mgls_prepare2d(&a); + gr->SetTranspType(0); gr->Clf(); + gr->SubPlot(2,2,0); gr->Rotate(50,60); gr->Surf(a); gr->Box(); + gr->SubPlot(2,2,1); gr->Rotate(50,60); gr->Dens(a); gr->Box(); + gr->SubPlot(2,2,2); gr->Rotate(50,60); gr->Cont(a); gr->Box(); + gr->SubPlot(2,2,3); gr->Rotate(50,60); gr->Axial(a); gr->Box(); + return 0; +} +@end verbatim + +@pfig{type0, Example of @code{SetTranspType(0)}.} +@pfig{type1, Example of @code{SetTranspType(1)}.} +@pfig{type2, Example of @code{SetTranspType(2)}.} + + +@c ------------------------------------------------------------------ +@external{} +@node Axis projection, Adding fog, Types of transparency, Hints +@subsection Axis projection +@nav{} + +You can easily make 3D plot and draw its x-,y-,z-projections (like in CAD) by using @ref{ternary} function with arguments: 4 for Cartesian, 5 for Ternary and 6 for Quaternary coordinates. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetRanges(0,1,0,1,0,1); + mglData x(50),y(50),z(50),rx(10),ry(10), a(20,30); + a.Modify("30*x*y*(1-x-y)^2*(x+y<1)"); + x.Modify("0.25*(1+cos(2*pi*x))"); + y.Modify("0.25*(1+sin(2*pi*x))"); + rx.Modify("rnd"); ry.Modify("(1-v)*rnd",rx); + z.Modify("x"); + + gr->Title("Projection sample"); + gr->Ternary(4); + gr->Rotate(50,60); gr->Light(true); + gr->Plot(x,y,z,"r2"); gr->Surf(a,"#"); + gr->Axis(); gr->Grid(); gr->Box(); + gr->Label('x',"X",1); gr->Label('y',"Y",1); gr->Label('z',"Z",1); +} +@end verbatim + +@pfig{projection, Example of axis projections} +@pfig{projection5, Example of ternary axis projections} +@c @pfig{projection6, Example of quaternary axis projections} + +@c ------------------------------------------------------------------ +@external{} +@node Adding fog, Lighting sample, Axis projection, Hints +@subsection Adding fog +@nav{} + +MathGL can add a fog to the image. Its switching on is rather simple -- just use @ref{fog} function. There is the only feature -- fog is applied for whole image. Not to particular subplot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Fog sample"); + gr->Light(true); gr->Rotate(50,60); gr->Fog(1); gr->Box(); + gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{fog, Example of @code{Fog()}.} + +@c ------------------------------------------------------------------ +@external{} +@node Lighting sample, Using primitives, Adding fog, Hints +@subsection Lighting sample +@nav{} + +In contrast to the most of other programs, MathGL supports several (up to 10) light sources. Moreover, the color each of them can be different: white (this is usual), yellow, red, cyan, green and so on. The use of several light sources may be interesting for the highlighting of some peculiarities of the plot or just to make an amusing picture. Note, each light source can be switched on/off individually. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Title("Several light sources"); + gr->Rotate(50,60); gr->Light(true); + gr->AddLight(1,mglPoint(0,1,0),'c'); + gr->AddLight(2,mglPoint(1,0,0),'y'); + gr->AddLight(3,mglPoint(0,-1,0),'m'); + gr->Box(); gr->Surf(a,"h"); + return 0; +} +@end verbatim + +@pfig{several_light, Example of several light sources.} + +Additionally, you can use local light sources and set to use diffise reflection instead of specular one (by default) or both kinds. +@verbatim +int sample(mglGraph *gr) +{ + // use Quality=6 because need lighting in placed + int qual = gr->GetQuality(); + gr->Light(true); gr->SetQuality(6); + + mglData a; mgls_prepare2d(&a); + gr->SubPlot(2,2,0); gr->Title("Default"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(-1,-0.7,1.7),mglPoint(-1,-0.7,0.7),"BA"); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1)); + gr->SubPlot(2,2,1); gr->Title("Local"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0); + gr->SubPlot(2,2,2); gr->Title("no diffuse"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetDiffuse(0.5); + gr->AddLight(0,mglPoint(1,0,1),mglPoint(-2,-1,-1),'w',0); + gr->SubPlot(2,2,3); gr->Title("diffusive only"); + gr->Rotate(50,60); gr->Box(); gr->Surf(a); + gr->Line(mglPoint(1,0,1),mglPoint(-1,-1,0),"BAO"); + gr->SetQuality(qual); +} +@end verbatim + +@pfig{light, Example of different types of lighting.} + +@c ------------------------------------------------------------------ +@external{} +@node Using primitives, STFA sample, Lighting sample, Hints +@subsection Using primitives +@nav{} + +MathGL provide a set of functions for drawing primitives (see @ref{Primitives}). Primitives are low level object, which used by most of plotting functions. Picture below demonstrate some of commonly used primitives. + +@pfig{primitives, Primitives in MathGL.} + +Generally, you can create arbitrary new kind of plot using primitives. For example, MathGL don't provide any special functions for drawing molecules. However, you can do it using only one type of primitives @ref{drop}. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + gr->Alpha(true); gr->Light(true); + + gr->SubPlot(2,2,0,""); gr->Title("Methane, CH_4"); + gr->StartGroup("Methane"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"k"); + gr->Drop(mglPoint(0,0,0),mglPoint(0,0,1),0.35,"h",1,2); + gr->Sphere(mglPoint(0,0,0.7),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.94,0,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(-0.66,0,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,0.57,-0.23),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.47,-0.82,-0.33),0.35,"h",1,2); + gr->Sphere(mglPoint(0.33,-0.57,-0.23),0.25,"g"); + gr->EndGroup(); + + gr->SubPlot(2,2,1,""); gr->Title("Water, H_{2}O"); + gr->StartGroup("Water"); + gr->Rotate(60,100); + gr->StartGroup("Water_O"); + gr->Sphere(mglPoint(0,0,0),0.25,"r"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_1"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_1"); + gr->Sphere(mglPoint(0.3,0.5,0),0.25,"g"); + gr->EndGroup(); + gr->StartGroup("Water_Bond_2"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.3,-0.5,0),0.3,"m",1,2); + gr->EndGroup(); + gr->StartGroup("Water_H_2"); + gr->Sphere(mglPoint(0.3,-0.5,0),0.25,"g"); + gr->EndGroup(); + gr->EndGroup(); + + gr->SubPlot(2,2,2,""); gr->Title("Oxygen, O_2"); + gr->StartGroup("Oxygen"); + gr->Rotate(60,120); + gr->Drop(mglPoint(0,0.5,0),mglPoint(0,-0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,0.5,0),0.25,"r"); + gr->Drop(mglPoint(0,-0.5,0),mglPoint(0,0.3,0),0.3,"m",1,2); + gr->Sphere(mglPoint(0,-0.5,0),0.25,"r"); + gr->EndGroup(); + + gr->SubPlot(2,2,3,""); gr->Title("Ammonia, NH_3"); + gr->StartGroup("Ammonia"); + gr->Rotate(60,120); + gr->Sphere(mglPoint(0,0,0),0.25,"b"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(0.33,-0.57,0),0.32,"n",1,2); + gr->Sphere(mglPoint(0.33,-0.57,0),0.25,"g"); + gr->Drop(mglPoint(0,0,0),mglPoint(-0.65,0,0),0.32,"n",1,2); + gr->Sphere(mglPoint(-0.65,0,0),0.25,"g"); + gr->EndGroup(); + return 0; +} +@end verbatim + +@pfig{molecule, Example of molecules drawing.} + +Moreover, some of special plots can be more easily produced by primitives rather than by specialized function. For example, Venn diagram can be produced by @code{Error} plot: +@verbatim +int sample(mglGraph *gr) +{ + double xx[3]={-0.3,0,0.3}, yy[3]={0.3,-0.3,0.3}, ee[3]={0.7,0.7,0.7}; + mglData x(3,xx), y(3,yy), e(3,ee); + gr->Title("Venn-like diagram"); gr->Alpha(true); + gr->Error(x,y,e,e,"!rgb@#o"); + return 0; +} +@end verbatim +You see that you have to specify and fill 3 data arrays. The same picture can be produced by just 3 calls of @ref{circle} function: +@verbatim +int sample(mglGraph *gr) +{ + gr->Title("Venn-like diagram"); gr->Alpha(true); + gr->Circle(mglPoint(-0.3,0.3),0.7,"rr@"); + gr->Circle(mglPoint(0,-0.3),0.7,"gg@"); + gr->Circle(mglPoint( 0.3,0.3),0.7,"bb@"); + return 0; +} +@end verbatim +Of course, the first variant is more suitable if you need to plot a lot of circles. But for few ones the usage of primitives looks easy. + +@pfig{venn, Example of Venn diagram.} + +@c ------------------------------------------------------------------ +@external{} +@node STFA sample, Mapping visualization, Using primitives, Hints +@subsection STFA sample +@nav{} + +Short-time Fourier Analysis (@ref{stfa}) is one of informative method for analyzing long rapidly oscillating 1D data arrays. It is used to determine the sinusoidal frequency and phase content of local sections of a signal as it changes over time. + +MathGL can find and draw STFA result. Just to show this feature I give following sample. Initial data arrays is 1D arrays with step-like frequency. Exactly this you can see at bottom on the STFA plot. The sample code is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(2000), b(2000); + gr->Fill(a,"cos(50*pi*x)*(x<-.5)+cos(100*pi*x)*(x<0)*(x>-.5)+\ + cos(200*pi*x)*(x<.5)*(x>0)+cos(400*pi*x)*(x>.5)"); + gr->SubPlot(1, 2, 0,"<_"); gr->Title("Initial signal"); + gr->Plot(a); + gr->Axis(); + gr->Label('x', "\\i t"); + + gr->SubPlot(1, 2, 1,"<_"); gr->Title("STFA plot"); + gr->STFA(a, b, 64); + gr->Axis(); + gr->Label('x', "\\i t"); + gr->Label('y', "\\omega", 0); + return 0; +} +@end verbatim + +@pfig{stfa, Example of STFA().} + +@c ------------------------------------------------------------------ +@external{} +@node Mapping visualization, Making regular data, STFA sample, Hints +@subsection Mapping visualization +@nav{} + +Sometime ago I worked with mapping and have a question about its visualization. Let me remember you that mapping is some transformation rule for one set of number to another one. The 1d mapping is just an ordinary function -- it takes a number and transforms it to another one. The 2d mapping (which I used) is a pair of functions which take 2 numbers and transform them to another 2 ones. Except general plots (like @ref{surfc}, @ref{surfa}) there is a special plot -- Arnold diagram. It shows the area which is the result of mapping of some initial area (usually square). + +I tried to make such plot in @ref{map}. It shows the set of points or set of faces, which final position is the result of mapping. At this, the color gives information about their initial position and the height describes Jacobian value of the transformation. Unfortunately, it looks good only for the simplest mapping but for the real multivalent quasi-chaotic mapping it produces a confusion. So, use it if you like :). + +The sample code for mapping visualization is: +@verbatim +int sample(mglGraph *gr) +{ + mglData a(50, 40), b(50, 40); + gr->Puts(mglPoint(0, 0), "\\to", ":C", -1.4); + gr->SetRanges(-1,1,-1,1,-2,2); + + gr->SubPlot(2, 1, 0); + gr->Fill(a,"x"); gr->Fill(b,"y"); + gr->Puts(mglPoint(0, 1.1), "\\{x, y\\}", ":C", -2); gr->Box(); + gr->Map(a, b, "brgk"); + + gr->SubPlot(2, 1, 1); + gr->Fill(a,"(x^3+y^3)/2"); gr->Fill(b,"(x-y)/2"); + gr->Puts(mglPoint(0, 1.1), "\\{\\frac{x^3+y^3}{2}, \\frac{x-y}{2}\\}", ":C", -2); + gr->Box(); + gr->Map(a, b, "brgk"); + return 0; +} +@end verbatim + +@pfig{map, Example of Map().} + +@c ------------------------------------------------------------------ +@external{} +@node Making regular data, Making histogram, Mapping visualization, Hints +@subsection Making regular data +@nav{} + +Sometimes, one have only unregular data, like as data on triangular grids, or experimental results and so on. Such kind of data cannot be used as simple as regular data (like matrices). Only few functions, like @ref{dots}, can handle unregular data as is. + +However, one can use built in triangulation functions for interpolating unregular data points to a regular data grids. There are 2 ways. First way, one can use @ref{triangulation} function to obtain list of vertexes for triangles. Later this list can be used in functions like @ref{triplot} or @ref{tricont}. Second way consist in usage of @ref{datagrid} function, which fill regular data grid by interpolated values, assuming that coordinates of the data grid is equidistantly distributed in axis range. Note, you can use options (see @ref{Command options}) to change default axis range as well as in other plotting functions. +@verbatim +int sample(mglGraph *gr) +{ + mglData x(100), y(100), z(100); + gr->Fill(x,"2*rnd-1"); gr->Fill(y,"2*rnd-1"); gr->Fill(z,"v^2-w^2",x,y); + // first way - plot triangular surface for points + mglData d = mglTriangulation(x,y); + gr->Title("Triangulation"); + gr->Rotate(40,60); gr->Box(); gr->Light(true); + gr->TriPlot(d,x,y,z); gr->TriPlot(d,x,y,z,"#k"); + // second way - make regular data and plot it + mglData g(30,30); + gr->DataGrid(g,x,y,z); gr->Mesh(g,"m"); +} +@end verbatim + +@pfig{triangulation, Example of triangulation.} + +@c ------------------------------------------------------------------ +@external{} +@node Making histogram, Nonlinear fitting hints, Making regular data, Hints +@subsection Making histogram +@nav{} + +Using the @ref{hist} function(s) for making regular distributions is one of useful fast methods to process and plot irregular data. @code{Hist} can be used to find some momentum of set of points by specifying weight function. It is possible to create not only 1D distributions but also 2D and 3D ones. Below I place the simplest sample code which demonstrate @ref{hist} usage: +@verbatim +int sample(mglGraph *gr) +{ + mglData x(10000), y(10000), z(10000); gr->Fill(x,"2*rnd-1"); + gr->Fill(y,"2*rnd-1"); gr->Fill(z,"exp(-6*(v^2+w^2))",x,y); + mglData xx=gr->Hist(x,z), yy=gr->Hist(y,z); xx.Norm(0,1); + yy.Norm(0,1); + gr->MultiPlot(3,3,3,2,2,""); gr->SetRanges(-1,1,-1,1,0,1); + gr->Box(); gr->Dots(x,y,z,"wyrRk"); + gr->MultiPlot(3,3,0,2,1,""); gr->SetRanges(-1,1,0,1); + gr->Box(); gr->Bars(xx); + gr->MultiPlot(3,3,5,1,2,""); gr->SetRanges(0,1,-1,1); + gr->Box(); gr->Barh(yy); + gr->SubPlot(3,3,2); + gr->Puts(mglPoint(0.5,0.5),"Hist and\nMultiPlot\nsample","a",-6); + return 0; +} +@end verbatim + +@pfig{hist, Example of Hist().} + + +@c ------------------------------------------------------------------ +@external{} +@node Nonlinear fitting hints, PDE solving hints, Making histogram, Hints +@subsection Nonlinear fitting hints +@nav{} + +Nonlinear fitting is rather simple. All that you need is the data to fit, the approximation formula and the list of coefficients to fit (better with its initial guess values). Let me demonstrate it on the following simple example. First, let us use sin function with some random noise: +@verbatim + mglData rnd(100), in(100); //data to be fitted and ideal data + gr->Fill(rnd,"0.4*rnd+0.1+sin(2*pi*x)"); + gr->Fill(in,"0.3+sin(2*pi*x)"); +@end verbatim +and plot it to see that data we will fit +@verbatim + gr->Title("Fitting sample"); + gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); + gr->Axis(); gr->Plot(in, "b"); + gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b"); +@end verbatim + +The next step is the fitting itself. For that let me specify an initial values @var{ini} for coefficients @samp{abc} and do the fitting for approximation formula @samp{a+b*sin(c*x)} +@verbatim + mreal ini[3] = {1,1,3}; + mglData Ini(3,ini); + mglData res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); +@end verbatim +Now display it +@verbatim + gr->Plot(res, "r"); + gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); + gr->PutsFit(mglPoint(0, -1.8), "y = ", "r"); +@end verbatim + +NOTE! the fitting results may have strong dependence on initial values for coefficients due to algorithm features. The problem is that in general case there are several local "optimums" for coefficients and the program returns only first found one! There are no guaranties that it will be the best. Try for example to set @code{ini[3] = @{0, 0, 0@}} in the code above. + +The full sample code for nonlinear fitting is: +@verbatim +int sample(mglGraph *gr) +{ + mglData rnd(100), in(100); + gr->Fill(rnd,"0.4*rnd+0.1+sin(2*pi*x)"); + gr->Fill(in,"0.3+sin(2*pi*x)"); + mreal ini[3] = {1,1,3}; + mglData Ini(3,ini); + + mglData res = gr->Fit(rnd, "a+b*sin(c*x)", "abc", Ini); + + gr->Title("Fitting sample"); + gr->SetRange('y',-2,2); gr->Box(); gr->Plot(rnd, ". "); + gr->Axis(); gr->Plot(res, "r"); gr->Plot(in, "b"); + gr->Puts(mglPoint(-0.9, -1.3), "fitted:", "r:L"); + gr->PutsFit(mglPoint(0, -1.8), "y = ", "r"); + gr->Puts(mglPoint(0, 2.2), "initial: y = 0.3+sin(2\\pi x)", "b"); + return 0; +} +@end verbatim + +@pfig{fit, Example of nonlinear fitting.} + +@c ------------------------------------------------------------------ +@external{} +@node PDE solving hints, MGL parser using, Nonlinear fitting hints, Hints +@subsection PDE solving hints +@nav{} + +Solving of Partial Differential Equations (PDE, including beam tracing) and ray tracing (or finding particle trajectory) are more or less common task. So, MathGL have several functions for that. There are @code{mglRay()} for ray tracing, @code{mglPDE()} for PDE solving, @code{mglQO2d()} for beam tracing in 2D case (see @ref{Global functions}). Note, that these functions take ``Hamiltonian'' or equations as string values. And I don't plan now to allow one to use user-defined functions. There are 2 reasons: the complexity of corresponding interface; and the basic nature of used methods which are good for samples but may not good for serious scientific calculations. + +The ray tracing can be done by @code{mglRay()} function. Really ray tracing equation is Hamiltonian equation for 3D space. So, the function can be also used for finding a particle trajectory (i.e. solve Hamiltonian ODE) for 1D, 2D or 3D cases. The function have a set of arguments. First of all, it is Hamiltonian which defined the media (or the equation) you are planning to use. The Hamiltonian is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z}, time @samp{t} (for particle dynamics) and momentums @samp{p}=@math{p_x}, @samp{q}=@math{p_y}, @samp{v}=@math{p_z}. Next, you have to define the initial conditions for coordinates and momentums at @samp{t}=0 and set the integrations step (default is 0.1) and its duration (default is 10). The Runge-Kutta method of 4-th order is used for integration. +@verbatim + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + mglData r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); +@end verbatim +This example calculate the reflection from linear layer (media with Hamiltonian @samp{p^2+q^2-x-1}=@math{p_x^2+p_y^2-x-1}). This is parabolic curve. The resulting array have 7 columns which contain data for @{x,y,z,p,q,v,t@}. + +The solution of PDE is a bit more complicated. As previous you have to specify the equation as pseudo-differential operator @math{\hat H(x, \nabla)} which is called sometime as ``Hamiltonian'' (for example, in beam tracing). As previously, it is defined by string which may depend on coordinates @samp{x}, @samp{y}, @samp{z} (but not time!), momentums @samp{p}=@math{(d/dx)/i k_0}, @samp{q}=@math{(d/dy)/i k_0} and field amplitude @samp{u}=@math{|u|}. The evolutionary coordinate is @samp{z} in all cases. So that, the equation look like @math{du/dz = ik_0 H(x,y,\hat p, \hat q, |u|)[u]}. Dependence on field amplitude @samp{u}=@math{|u|} allows one to solve nonlinear problems too. For example, for nonlinear Shrodinger equation you may set @code{ham="p^2 + q^2 - u^2"}. Also you may specify imaginary part for wave absorption, like @code{ham = "p^2 + i*x*(x>0)"}, but only if dependence on variable @samp{i} is linear (i.e. @math{H = Hre+i*Him}). + +Next step is specifying the initial conditions at @samp{z}=@code{Min.z}. The function need 2 arrays for real and for imaginary part. Note, that coordinates x,y,z are supposed to be in specified range [Min, Max]. So, the data arrays should have corresponding scales. Finally, you may set the integration step and parameter k0=@math{k_0}. Also keep in mind, that internally the 2 times large box is used (for suppressing numerical reflection from boundaries) and the equation should well defined even in this extended range. + +Final comment is concerning the possible form of pseudo-differential operator @math{H}. At this moment, simplified form of operator @math{H} is supported -- all ``mixed'' terms (like @samp{x*p}->x*d/dx) are excluded. For example, in 2D case this operator is effectively @math{H = f(p,z) + g(x,z,u)}. However commutable combinations (like @samp{x*q}->x*d/dy) are allowed for 3D case. + +So, for example let solve the equation for beam deflected from linear layer and absorbed later. The operator will have the form @samp{"p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)"} that correspond to equation @math{ik_0 \partial_z u + \Delta u + x \cdot u + i (x+z)/2 \cdot u = 0}. This is typical equation for Electron Cyclotron (EC) absorption in magnetized plasmas. For initial conditions let me select the beam with plane phase front @math{exp(-48*(x+0.7)^2)}. The corresponding code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + mglData a,re(128),im(128); + gr->Fill(re,"exp(-48*(x+0.7)^2)"); + a = gr->PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30); + a.Transpose("yxz"); + gr->SubPlot(1,1,0,"<_"); gr->Title("PDE solver"); + gr->SetRange('c',0,1); gr->Dens(a,"wyrRk"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.85), "absorption: (x+z)/2 for x+z>0"); + gr->Puts(mglPoint(0,1.1),"Equation: ik_0\\partial_zu + \\Delta u + x\\cdot u + i \\frac{x+z}{2}\\cdot u = 0"); + return 0; +} +@end verbatim + +@pfig{pde, Example of PDE solving.} + +The last example is example of beam tracing. Beam tracing equation is special kind of PDE equation written in coordinates accompanied to a ray. Generally this is the same parameters and limitation as for PDE solving but the coordinates are defined by the ray and by parameter of grid width @var{w} in direction transverse the ray. So, you don't need to specify the range of coordinates. @strong{BUT} there is limitation. The accompanied coordinates are well defined only for smooth enough rays, i.e. then the ray curvature @math{K} (which is defined as @math{1/K^2 = (|\ddot r|^2 |\dot r|^2 - (\ddot r, \dot r)^2)/|\dot r|^6}) is much large then the grid width: @math{K>>w}. So, you may receive incorrect results if this condition will be broken. + +You may use following code for obtaining the same solution as in previous example: +@verbatim +int sample(mglGraph *gr) +{ + mglData r, xx, yy, a, im(128), re(128); + const char *ham = "p^2+q^2-x-1+i*0.5*(y+x)*(y>-x)"; + r = mglRay(ham, mglPoint(-0.7, -1), mglPoint(0, 0.5), 0.02, 2); + gr->SubPlot(1,1,0,"<_"); gr->Title("Beam and ray tracing"); + gr->Plot(r.SubData(0), r.SubData(1), "k"); + gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); + + // now start beam tracing + gr->Fill(re,"exp(-48*x^2)"); + a = mglQO2d(ham, re, im, r, xx, yy, 1, 30); + gr->SetRange('c',0, 1); + gr->Dens(xx, yy, a, "wyrRk"); + gr->FPlot("-x", "k|"); + gr->Puts(mglPoint(0, 0.85), "absorption: (x+y)/2 for x+y>0"); + gr->Puts(mglPoint(0.7, -0.05), "central ray"); + return 0; +} +@end verbatim + +@pfig{qo2d, Example of beam tracing.} + + +@c ------------------------------------------------------------------ +@external{} +@node MGL parser using, Using options, PDE solving hints, Hints +@subsection MGL parser using +@nav{} + +Sometimes you may prefer to use MGL scripts in yours code. It is simpler (especially in comparison with C/Fortran interfaces) and provide faster way to plot the data with annotations, labels and so on. Class @code{mglParse} (@pxref{mglParse class} parse MGL scripts in C++. It have also the corresponding interface for C/Fortran. + +The key function here is @code{mglParse::Parse()} (or @code{mgl_parse()} for C/Fortran) which execute one command per string. At this the detailed information about the possible errors or warnings is passed as function value. Or you may execute the whole script as long string with lines separated by @samp{\n}. Functions @code{mglParse::Execute()} and @code{mgl_parse_text()} perform it. Also you may set the values of parameters @samp{$0}...@samp{$9} for the script by functions @code{mglParse::AddParam()} or @code{mgl_add_param()}, allow/disable picture resizing, check ``once'' status and so on. The usage is rather straight-forward. + +The only non-obvious thing is data transition between script and yours program. There are 2 stages: add or find variable; and set data to variable. In C++ you may use functions @code{mglParse::AddVar()} and @code{mglParse::FindVar()} which return pointer to @code{mglData}. In C/Fortran the corresponding functions are @code{mgl_add_var()}, @code{mgl_find_var()}. This data pointer is valid until next @code{Parse()} or @code{Execute()} call. Note, you @strong{must not delete or free} the data obtained from these functions! + +So, some simple example at the end. Here I define a data array, create variable, put data into it and plot it. The C++ code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + gr->Title("MGL parser sample"); + mreal a[100]; // let a_i = sin(4*pi*x), x=0...1 + for(int i=0;i<100;i++)a[i]=sin(4*M_PI*i/99); + mglParse *parser = new mglParse; + mglData *d = parser->AddVar("dat"); + d->Set(a,100); // set data to variable + parser->Execute(gr, "plot dat; xrange 0 1\nbox\naxis"); + // you may break script at any line do something + // and continue after that + parser->Execute(gr, "xlabel 'x'\nylabel 'y'\nbox"); + // also you may use cycles or conditions in script + parser->Execute(gr, "for $0 -1 1 0.1\nline 0 0 -1 $0 'r'\nnext"); + delete parser; + return 0; +} +@end verbatim +The code in C/Fortran looks practically the same: +@verbatim +int sample(HMGL gr) +{ + mgl_title(gr, "MGL parser sample", "", -2); + double a[100]; // let a_i = sin(4*pi*x), x=0...1 + int i; + for(i=0;i<100;i++) a[i]=sin(4*M_PI*i/99); + HMPR parser = mgl_create_parser(); + HMDT d = mgl_parser_add_var(parser, "dat"); + mgl_data_set_double(d,a,100,1,1); // set data to variable + mgl_parse_text(gr, parser, "plot dat; xrange 0 1\nbox\naxis"); + // you may break script at any line do something + // and continue after that + mgl_parse_text(gr, parser, "xlabel 'x'\nylabel 'y'"); + // also you may use cycles or conditions in script + mgl_parse_text(gr, parser, "for $0 -1 1 0.1\nif $0<0\n" + "line 0 0 -1 $0 'r':else:line 0 0 -1 $0 'g'\n" + "endif\nnext"); + mgl_write_png(gr, "test.png", ""); // don't forgot to save picture + return 0; +} +@end verbatim + +@pfig{parser, Example of MGL script parsing.} + +@c ------------------------------------------------------------------ +@external{} +@node Using options, ``Templates'', MGL parser using, Hints +@subsection Using options +@nav{} + +@ref{Command options} allow the easy setup of the selected plot by changing global settings only for this plot. Often, options are used for specifying the range of automatic variables (coordinates). However, options allows easily change plot transparency, numbers of line or faces to be drawn, or add legend entries. The sample function for options usage is: +@verbatim +void template(mglGraph *gr) +{ + mglData a(31,41); + gr->Fill(a,"-pi*x*exp(-(y+1)^2-4*x^2)"); + + gr->SubPlot(2,2,0); gr->Title("Options for coordinates"); + gr->Alpha(true); gr->Light(true); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1"); gr->Surf(a,"b","yrange 0 -1"); + if(mini) return; + gr->SubPlot(2,2,1); gr->Title("Option 'meshnum'"); + gr->Rotate(40,60); gr->Box(); + gr->Mesh(a,"r","yrange 0 1"); gr->Mesh(a,"b","yrange 0 -1; meshnum 5"); + gr->SubPlot(2,2,2); gr->Title("Option 'alpha'"); + gr->Rotate(40,60); gr->Box(); + gr->Surf(a,"r","yrange 0 1; alpha 0.7"); + gr->Surf(a,"b","yrange 0 -1; alpha 0.3"); + gr->SubPlot(2,2,3,"<_"); gr->Title("Option 'legend'"); + gr->FPlot("x^3","r","legend 'y = x^3'"); + gr->FPlot("cos(pi*x)","b","legend 'y = cos \\pi x'"); + gr->Box(); gr->Axis(); gr->Legend(2,""); +} +@end verbatim + +@pfig{mirror, Example of options usage.} + +@c ------------------------------------------------------------------ +@external{} +@node ``Templates'', Stereo image, Using options, Hints +@subsection ``Templates'' +@nav{} + +As I have noted before, the change of settings will influence only for the further plotting commands. This allows one to create ``template'' function which will contain settings and primitive drawing for often used plots. Correspondingly one may call this template-function for drawing simplification. + +For example, let one has a set of points (experimental or numerical) and wants to compare it with theoretical law (for example, with exponent law @math{\exp(-x/2), x \in [0, 20]}). The template-function for this task is: +@verbatim +void template(mglGraph *gr) +{ + mglData law(100); // create the law + law.Modify("exp(-10*x)"); + gr->SetRanges(0,20, 0.0001,1); + gr->SetFunc(0,"lg(y)",0); + gr->Plot(law,"r2"); + gr->Puts(mglPoint(10,0.2),"Theoretical law: e^x","r:L"); + gr->Label('x',"x val."); gr->Label('y',"y val."); + gr->Axis(); gr->Grid("xy","g;"); gr->Box(); +} +@end verbatim +At this, one will only write a few lines for data drawing: +@verbatim + template(gr); // apply settings and default drawing from template + mglData dat("fname.dat"); // load the data + // and draw it (suppose that data file have 2 columns) + gr->Plot(dat.SubData(0),dat.SubData(1),"bx "); +@end verbatim +A template-function can also contain settings for font, transparency, lightning, color scheme and so on. + +I understand that this is obvious thing for any professional programmer, but I several times receive suggestion about ``templates'' ... So, I decide to point out it here. + +@c ------------------------------------------------------------------ +@external{} +@node Stereo image, Reduce memory usage, ``Templates'', Hints +@subsection Stereo image +@nav{} + +One can easily create stereo image in MathGL. Stereo image can be produced by making two subplots with slightly different rotation angles. The corresponding code looks like this: +@verbatim +int sample(mglGraph *gr) +{ + mglData a; mgls_prepare2d(&a); + gr->Light(true); + + gr->SubPlot(2,1,0); gr->Rotate(50,60+1); + gr->Box(); gr->Surf(a); + + gr->SubPlot(2,1,1); gr->Rotate(50,60-1); + gr->Box(); gr->Surf(a); + return 0; +} +@end verbatim + +@pfig{stereo, Example of stereo image.} + +@c ------------------------------------------------------------------ +@external{} +@node Reduce memory usage, , Stereo image, Hints +@subsection Reduce memory usage +@nav{} + +By default MathGL save all primitives in memory, rearrange it and only later draw them on bitmaps. Usually, this speed up drawing, but may require a lot of memory for plots which contain a lot of faces (like @ref{cloud}, @ref{dew}). You can use @ref{quality} function for setting to use direct drawing on bitmap and bypassing keeping any primitives in memory. This function also allow you to decrease the quality of the resulting image but increase the speed of the drawing. + +The code for lowest memory usage looks like this: +@verbatim +int sample(mglGraph *gr) +{ + gr->SetQuality(6); // firstly, set to draw directly on bitmap + for(i=0;i<1000;i++) + gr->Sphere(mglPoint(mgl_rnd()*2-1,mgl_rnd()*2-1),0.05); + return 0; +} +@end verbatim + +@c ================================================================== +@external{} +@node FAQ, , Hints, Examples +@section FAQ +@nav{} + +@table @strong +@item График не рисуется?! +Проверьте, что точки графика находятся внутри ограничивающего параллелепипеда, при необходимости увеличьте его с помощью функции @code{Axis()}. Проверьте, что размерность массива правильная для выбранного типа графика. Убедитесь, что функция @code{Finish()} была вызвана после построения графика (или график был сохранен в файл). Иногда отражение света от плоских поверхностей (типа, @code{Dens()}) может выглядеть как отсутствие графика. + +@item Не нашел нужного графика?! +Многие ``новые'' графики можно строить, используя уже существующие функции. Например, поверхность вращения кривой относительно оси можно построить, используя специальную функцию @code{Torus()}, а можно построить как параметрически заданную поверхность @code{Surf()}. См. также @ref{Hints} и @ref{Examples} MathGL. Если же нужного типа графика все равно нет, то пишите мне @email{mathgl.abalakin@@gmail.com, e-mail} и в следующей версии этот график появится. + +@item Требуется ли знание сторонних библиотек (например, OpenGL) для использования библиотеки MathGL? +Нет. Библиотека MathGL самодостаточна и не требует знания сторонних библиотек. + +@item На каком языке написана библиотека? Для каких языков у нее есть интерфейсы? +Ядро библиотеки написано на С++. Кроме него, есть интерфейсы для чистого С, фортрана, паскаля, форта и собственный командный язык MGL. Также есть поддержка большого числа интерпретируемых языков (Python, Java, ALLEGROCL, CHICKEN, Lisp, CFFI, C#, Guile, Lua, Modula 3, Mzscheme, Ocaml, Octave, Perl, PHP, Pike, R, Ruby, Tcl). Эти интерфейсы написаны с помощью SWIG (и функции чистого С и классы). Однако на данный момент только интерфейсы для Python и Octave включены в скрипты сборки. Причина в том, что я не знаю других языков, чтобы проверить качество интерфейса :(. Замечу, что большинство прочих языков могут использовать С функции напрямую. + +@item Как мне использовать MathGL с Фортраном? +Библиотеку MathGL можно использовать как есть с компилятором @code{gfortran} поскольку он использует по умолчанию AT&T нотацию для внешних функций. Для других компиляторов (например, Visual Fortran) необходимо включить использование AT&T нотации вручную. AT&T нотация требует, чтобы имя функции завершалось символом @samp{_}, аргументы функции передавались по указателю и длины строк передавались в конце списка аргументов. Например: + +@emph{C функция} -- @code{void mgl_fplot(HMGL graph, const char *fy, const char *stl, int n);} + +@emph{AT&T функция} -- @code{void mgl_fplot_(uintptr_t *graph, const char *fy, const char *stl, int *n, int ly, int ls);} + +При использовании фортрана необходимо также включить библиотеку @code{-lstdc++}. Кроме того, если библиотека была собрана с опцией @code{enable-double=ON} (по умолчанию в версии 2.1 и более поздних), то все вещественные числа должны быть типа @code{real*8}. Это можно включить по умолчанию опцией @code{-fdefault-real-8}. + +@item У меня есть класс Foo и в нем метод рисования Foo::draw(mglGraph *gr). Как мне нарисовать что-то в окне FLTK, GLUT или Qt? +Функции-члены класса в С++ имеют ``скрытый'' параметр -- указатель на экземпляр класса и их прямое использование невозможно. Решением будет определение интерфейсной функции: +@example +int foo_draw(mglGraph *gr, void *par) +@{ ((Foo *)foo)->draw(gr); @} +@end example +и подстановка именно ее в вызов функции @code{Window()}: +@example +gr->Window(argc,argv,foo_draw,"Title",this); +@end example + +Можно также наследовать Ваш класс от класса @code{mglDraw} и использовать функцию типа @code{gr->Window(argc, argv, foo, "Title");}. + +@item Как мне вывести текст на русском/испанском/арабском/японском и т.д.? +Стандартный путь состоит в использовании кодировки UTF-8 для вывода текста. Кроме того, все функции вывода текста имеют интерфейс для 8-битных (char *) строк. Однако в последнем случае Вам может потребоваться установить используемую в исходном тексте локаль. Например, для русского языка в кодировке CP1251 можно использовать @code{setlocale(LC_CTYPE, "ru_RU.cp1251");} (под MS Windows имена локали другие -- @code{setlocale(LC_CTYPE, "russian_russia.1251")}). Настоятельно не рекомендую использовать константу @code{LC_ALL}, поскольку при этом меняется и формат чисел (в частности, десятичная точка), что может, например, вызвать сложности (неудобство) при написании формул и чтении текстовых файлов. Например, программа ожидает @samp{,} в качестве разделителя целой и дробной части, а пользователь вводит @samp{.}. + +@item Как мне вырезать (исключить из рисования) точку или область на графике? +Есть три основных способа. Во-первых, можно вырезать точку, задав одну из ее координат равной @code{NAN}. Во-вторых, можно воспользоваться функцией @code{SetCutBox()} или @code{CutOff()} для удаления точек из некоторой области (@pxref{Cutting}). Наконец, можно сделать эти точки прозрачными (невидимыми) с помощью функций @code{SurfA()}, @code{Surf3A()} (@pxref{Dual plotting}). В последнем случае обеспечивается еще и плавность включения прозрачности. + +@item Я использую VisualStudio, CBuilder или другой компилятор (не MinGW/gcc). Как мне подключить библиотеку MathGL? +Начиная с версии 2.0, рекомендуемый к использованию класс mglGraph (заголовочный файл @code{#include }) содержbn только с @code{inline} функции и может использоваться с любым компилятором без перекомпиляции бинарной версии библиотеки. Однако, если Вы планируете использовать низкоуровневые возможности (т.е. классы mglBase, mglCanvas и т.д.), то Вам следует перекомпилировать библиотеку MathGL с использованием Вашего компилятора. + +Отмечу, что использование предоставляемых динамических библиотек *.dll требует создания библиотек импорта (import library *.lib). Эта процедура зависит от используемого компилятора -- обратитесь к документации по Вашему компилятору. Например для VisualStudio это можно сделать командой @code{lib.exe /DEF:libmgl.def /OUT:libmgl.lib}. + +@item Как мне собрать MathGL под Windows? +Простейший путь -- использование комбинации CMake и MinGW. Также Вам может потребоваться дополнительные библиотеки, такие как GSL, PNG, JPEG и пр. Все они могут быть найдены на @url{http://gnuwin32.sourceforge.net/packages.html}. После установки всех компонент, просто запустите конфигуратор CMake и соберите MathGL командой make. + +@item Как создать окно FLTK/GLUT/Qt с текущими результатами параллельно с выполнением основных вычислений? +Следует создать отдельный поток для обработки сообщений в окно. Обновление данных в окне можно выполнить вызовом функции @code{Update()}. Подробнее см. @ref{Animation}. + +@item Сколько человек участвовало в создании библиотеки? +Большую часть библиотеки написал один человек. Это результат примерно года работы на написание ядра библиотеки и базовых функций (в основном вечерами и по выходным). Процесс усовершенствования продолжается и теперь :). Скрипты сборки в основном написаны Д.Кулагиным, а экспорт в PRC/PDF написан М.Видассовым. + +@item Как мне показать растровую картинку на рисунке? +Можно импортировать ее в экземпляр @code{mglData} и построить с помощью функции @code{Dens()}. Например, для черно-белого рисунка можно использовать код: @code{mglData bmp; bmp.Import("fname.png","wk"); gr->Dens(bmp,"wk");}. + +@item Как использовать MathGL в Qt, FLTK, wxWidgets ...? +Есть специальные классы (виджеты) для этих библиотек: QMathGL для Qt, Fl_MathGL для FLTK и т.д. Если Вы не нашли подходящий класс, то можете создать свой собственный виджет, рисующий растровое изображение из mglCanvas::GetBits(). + +@item Как мне создать 3D в PDF? +Используйте функцию @code{WritePRC}(), которая создаст PDF файл если MathGL был собран с enable-pdf=ON. + +@item Как мне создать TeX рисунок? +Используйте функцию @code{WriteTEX}(), которая создаст LaTeX файлы с собственно рисунком @samp{@var{fname}.tex}, с цветами MathGL @samp{mglcolors.tex} и основной файл @samp{mglmain.tex}, который может использоваться для просмотра изображения и/или генерации PDF с помощью команды типа @code{pdflatex mglmain.tex}. + +@item Можно ли использовать MathGL в JavaScript? +Да, пример JavaScript файла находится в папке texinfo/ исходных текстов. Для его работы необходимо предоставить JSON данные с 3d изображением (можно создать с помощью @code{WriteJSON}() функции). Скрипт позволяет выполнять базовые операции: приближение/удаление, вращение и сдвиг. Примеры использования JavaScript можно найти в @url{http://mathgl.sf.net/json.html}. + + + +@item Как сменить шрифт (семейство шрифтов)? +Во-первых, надо загрузить файлы @uref{http://mathgl.sourceforge.net/download.html, отсюда} или @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177, отсюда}. Далее, в экземпляре mglGraph загружаем шрифты: @code{gr->LoadFont(fontname,path);}. Здесь @var{fontname} -- базовое имя шрифта, например @samp{STIX}, и @var{path} -- путь к папке с файлами шрифтов. Вызовите @code{gr->RestoreFont();} для использования шрифта по умолчанию. + +@item Как нарисовать метки оси снаружи от графика? +Просто используйте отрицательные значения длины меток, например @code{gr->SetTickLen(-0.1);}. + +@item Как нарисовать одинаковые оси координат для прямоугольного (не квадратного) рисунка? +Просто используйте @code{Aspect(NAN,NAN)} для каждого подграфика, или в начале рисования. + +@end table + +@external{} diff --git a/texinfo/fdl.texi b/texinfo/fdl.texi new file mode 100644 index 0000000..96ce74e --- /dev/null +++ b/texinfo/fdl.texi @@ -0,0 +1,451 @@ +@c The GNU Free Documentation License. +@center Version 1.2, November 2002 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. +@end enumerate + +@page +@heading ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + diff --git a/texinfo/filter.py b/texinfo/filter.py new file mode 100755 index 0000000..b7bfa28 --- /dev/null +++ b/texinfo/filter.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +import os,string,re,glob + +print 'Tuning resulting html files for Qt\n' + +beginskip=0 +for filename in glob.glob('./*ru.html/*html'): + fpin=open(filename,'r') + fpout=open(filename+'.tmp','w') + for line in fpin.readlines(): + if re.search('',line): + beginskip=1 + fpout.write(line) + continue + if re.search('',line): beginskip=0 + if re.search('',line): continue + if re.search(' + + + + + Page Redirection + + + If you are not redirected automatically, follow the link to English or Russian version. + + \ No newline at end of file diff --git a/texinfo/json.html b/texinfo/json.html new file mode 100644 index 0000000..43bdc56 --- /dev/null +++ b/texinfo/json.html @@ -0,0 +1,124 @@ + + + + + + + + + + + + + +Select sample + + + +

You can use mouse with pressed left button for rotation; with pressed middle button for shift; mouse wheel for zoom in/out. Double click will restore original view.

+
+ +
+ +

+ + + + diff --git a/texinfo/lgplv3-147x51.png b/texinfo/lgplv3-147x51.png new file mode 100644 index 0000000..b7dc74d Binary files /dev/null and b/texinfo/lgplv3-147x51.png differ diff --git a/texinfo/mathgl.js b/texinfo/mathgl.js new file mode 100644 index 0000000..a6112ff --- /dev/null +++ b/texinfo/mathgl.js @@ -0,0 +1,550 @@ +/*************************************************************************** + * mathgl.js is part of Math Graphic Library + * Copyright (C) 2012 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +var obj; +var ctx; +var cw,ch; +var deg = Math.PI/180; //0.017453293; + +var main = function() +{ + ctx = document.getElementById("canvas").getContext("2d"); + cw = document.getElementById("canvas").width; + ch = document.getElementById("canvas").height; + ctx.lineCap="round"; // global setting + + mgl_init("json/alpha.json"); +// mgl_init("json/alpha.jsonz"); + var t1 = new Date(); + mgl_draw_good(obj, ctx); +// draw_fast(obj, ctx); + var t2 = new Date(); + document.getElementById("time").innerHTML = "Drawing time is "+(t2.getTime()-t1.getTime())+" ms. Number of primitives is "+obj.nprim+". Canvas size is "+obj.width+"*"+obj.height+" points."; +}; + +var mglChange = function() +{ + var name = document.getElementById("select").value; + mgl_init("json/"+name+".json"); + var t1 = new Date(); + ctx.clearRect(0,0,cw,ch); + mgl_draw_good(obj, ctx); +// draw_fast(obj, ctx); + var t2 = new Date(); + document.getElementById("time").innerHTML = "Drawing time is "+(t2.getTime()-t1.getTime())+" ms. Number of primitives is "+obj.nprim; +} + +// mouse handling functions +var mglMouseUp = function() +{ obj.button = 0; obj.good = 0; + ctx.clearRect(0,0,cw,ch); + mgl_draw_good(obj, ctx); } +var mglMouseDown = function(event) +{ + obj.good = 1; + obj.mouseX = event.clientX; + obj.mouseY = event.clientY; + obj.button = event.button+1; +} +var mglMouseMove = function(event) +{ + var x = event.clientX-obj.mouseX; + var y = event.clientY-obj.mouseY; + switch(obj.button) + { + case 1: // rotate + mgl_rotate_down(obj, y*180/ch); + mgl_rotate_left(obj, x*180/cw); break; + case 2: // shift + mgl_shift_down(obj, y/ch); + mgl_shift_right(obj, x/cw); break; + case 3: // zoom + mgl_zoom_in(obj, Math.pow(1.003,x)); break; + } + if(obj.button) + { + obj.mouseX += x; obj.mouseY += y; + mgl_draw(obj, ctx); + } +} +var mglMouseWheel = function(event) +{ +// var e = window.event; + var d = event.wheelDelta? event.wheelDelta:event.detail*(-120); + mgl_zoom_in(obj, Math.pow(1.002,d)); + mgl_draw(obj, ctx); +} +var mglRestore = function() +{ + mgl_restore(obj); + ctx.clearRect(0,0,cw,ch); + mgl_draw_good(obj,ctx); +} + +// The function load data and set up rotation/zoom state +var mgl_init = function(name) +{ + // now obtain JSON data + var req = new XMLHttpRequest(), txt; + req.open( "GET", name, false ); + req.overrideMimeType('text\/plain; charset=x-user-defined'); +/* req.responseType = "arraybuffer"; + req.onload = function (oEvent) { + var arrayBuffer = req.response; // Note: not oReq.responseText + console.debug("arrayBuffer=",arrayBuffer); + if (arrayBuffer) { + var compressed = new Uint8Array(arrayBuffer); + console.debug("compressed=",compressed); +// var gunzip = new Zlib.Gunzip(compressed); +// txt = gunzip.decompress(); + var inflate = new Zlib.Inflate(arrayBuffer); + txt = inflate.decompress(); + } + };*/ + req.send(null); +// if(name[name.length-1]!='z') + txt = req.responseText; +// else +// { +// console.debug("compressed=",req.responseText); +// var inflate = new Zlib.Inflate(req.responseText); +// txt = inflate.decompress(); +// } + obj = JSON.parse(txt); + + // copy original data for transformation + obj.pp = new Array(); + for(var i=0;iMath.PI/2) t += Math.PI; + } + else t=0; + var c=Math.cos(t), s=Math.sin(t), d=prim[6]/200; + + var b=[d*c, d*s, d*s, -d*c, obj.pp[n1][0],obj.pp[n1][1]]; + var x=obj.coor[n2][0]*scl/100, y=obj.coor[n2][1]*scl/100, f=prim[8]*scl/1e5; + if(n3&8) + { + if(!(n3&4)) mgl_line_glyph(ctx, x,y, f,1,b); + else mgl_line_glyph(ctx, x,y, f,0,b); + } + else + { + if(!(n3&4)) mgl_fill_glyph(ctx, x,y, f,obj.glfs[n4],b); + else mgl_wire_glyph(ctx, x,y, f,obj.glfs[n4],b); + } + break; + } +} + +// This function change coordinates according current transformations +// Usually this Function is called internally by draw() +var mgl_prepare = function(obj, skip) +{ + // fill transformation matrix + if(!skip) + { + var dx = 1/Math.abs(obj.z[1]-obj.z[0]); + var dy = 1/Math.abs(obj.z[3]-obj.z[2]); + var cx=Math.cos(obj.tet*deg), sx=Math.sin(obj.tet*deg); // tetx + var cy=Math.cos(obj.phi*deg), sy=Math.sin(obj.phi*deg); // tety + var cz=Math.cos(obj.bet*deg), sz=Math.sin(obj.bet*deg); // tetz + obj.b = [obj.dx*dx*cx*cy, -obj.dx*dx*cy*sx, obj.dx*dx*sy, + obj.dy*dy*(cx*sy*sz+cz*sx), obj.dy*dy*(cx*cz-sx*sy*sz), -obj.dy*dy*cy*sz, + sx*sz-cx*cz*sy, cx*sz+cz*sx*sy, cy*cz, + cw/2*(1+dx-obj.z[1]-obj.z[0])/dx, + ch/2*(1+dy-obj.z[3]-obj.z[2])/dy, obj.depth/2, obj.dx*dx,obj.dy*dy,1]; + } + // now transform points for found transformation matrix + var b = obj.b, i; + for(i=0;i' + ctx.moveTo(x-s/2,y-s); ctx.lineTo(x-s/2,y+s); + ctx.lineTo(x+s,y); ctx.closePath(); + ctx.stroke(); break; +// case 46: // '.' + default: + ctx.rect(x,y,1,1); ctx.fill(); break; + } +} + +// This function for internal use only!!! +var mgl_fill_glyph = function(ctx, x,y, f,g,b) +{ + var xx,yy,j; + var np=0; ctx.beginPath(); + for(j=0;jSetWarn(mglWarnNeg,"Circle"); return; } +@end verbatim +Next step is creating a group. Group keep some general setting for plot (like options) and useful for export in 3d files. +@verbatim + static int cgid=1; gr->StartGroup("Circle",cgid++); +@end verbatim +Now let apply options. Options are rather useful things, generally, which allow one easily redefine axis range(s), transparency and other settings (see @ref{Command options}). +@verbatim + gr->SaveState(opt); +@end verbatim +I use global setting for determining the number of points in circle approximation. Note, that user can change @code{MeshNum} by options easily. +@verbatim + const int n = gr->MeshNum>1?gr->MeshNum : 41; +@end verbatim +Let try to determine plot specific flags. MathGL functions expect that most of flags will be sent in string. In our case it is symbol @samp{@@} which set to draw filled circle instead of border only (last will be default). Note, you have to handle @code{NULL} as string pointer. +@verbatim + bool fill = mglchr(stl,'@'); +@end verbatim +Now, time for coloring. I use palette mechanism because circle have few colors: one for filling and another for border. @code{SetPenPal()} function parse input string and write resulting texture index in @var{pal}. Function return the character for marker, which can be specified in string @var{str}. Marker will be plotted at the center of circle. I'll show on next sample how you can use color schemes (smooth colors) too. +@verbatim + long pal=0; + char mk=gr->SetPenPal(stl,&pal); +@end verbatim +Next step, is determining colors for filling and for border. First one for filling. +@verbatim + mreal c=gr->NextColor(pal), d; +@end verbatim +Second one for border. I use black color (call @code{gr->AddTexture('k')}) if second color is not specified. +@verbatim + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); +@end verbatim +If user want draw only border (@code{fill=false}) then I use first color for border. +@verbatim + if(!fill) k=c; +@end verbatim +Now we should reserve space for vertexes. This functions need @code{n} for border, @code{n+1} for filling and @code{1} for marker. So, maximal number of vertexes is @code{2*n+2}. Note, that such reservation is not required for normal work but can sufficiently speed up the plotting. +@verbatim + gr->Reserve(2*n+2); +@end verbatim +We've done with setup and ready to start drawing. First, we need to add vertex(es). Let define NAN as normals, since I don't want handle lighting for this plot, +@verbatim + mglPoint q(NAN,NAN); +@end verbatim +and start adding vertexes. First one for central point of filling. I use @code{-1} if I don't need this point. The arguments of @code{AddPnt()} function is: @code{mglPoint(x,y,z)} -- coordinate of vertex, @code{c} -- vertex color, @code{q} -- normal at vertex, @code{-1} -- vertex transparency (@code{-1} for default), @code{3} bitwise flag which show that coordinates will be scaled (@code{0x1}) and will not be cutted (@code{0x2}). +@verbatim + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; +@end verbatim +Similar for marker, but we use different color @var{k}. +@verbatim + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; +@end verbatim +Draw marker. +@verbatim + if(mk) gr->mark_plot(n2,mk); +@end verbatim +Time for drawing circle itself. I use @code{-1} for @var{m1}, @var{n1} as sign that primitives shouldn't be drawn for first point @code{i=0}. +@verbatim + for(i=0,m1=n1=-1;iStop) return; +@end verbatim +Let find coordinates of vertex. +@verbatim + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); +@end verbatim +Save previous vertex and add next one +@verbatim + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); +@end verbatim +and copy it for border but with different color. Such copying is much faster than adding new vertex using @code{AddPnt()}. +@verbatim + m2 = m1; m1 = gr->CopyNtoC(n1,k); +@end verbatim +Now draw triangle for filling internal part +@verbatim + if(fill) gr->trig_plot(n0,n1,n2); +@end verbatim +and draw line for border. +@verbatim + gr->line_plot(m1,m2); + } +@end verbatim +Drawing is done. Let close group and return. +@verbatim + gr->EndGroup(); +} +@end verbatim + +Another sample I want to show is exactly the same function but with smooth coloring using color scheme. So, I'll add comments only in the place of difference. + +@verbatim +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ +@end verbatim +In this case let allow negative radius too. Formally it is not the problem for plotting (formulas the same) and this allow us to handle all color range. +@verbatim +//if(r<=0) { gr->SetWarn(mglWarnNeg,"Circle"); return; } + + static int cgid=1; gr->StartGroup("CircleCS",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); +@end verbatim +Here is main difference. We need to create texture for color scheme specified by user +@verbatim + long ss = gr->AddTexture(stl); +@end verbatim +But we need also get marker and color for it (if filling is enabled). Let suppose that marker and color is specified after @samp{:}. This is standard delimiter which stop color scheme entering. So, just lets find it and use for setting pen. +@verbatim + const char *pen=0; + if(stl) pen = strchr(stl,':'); + if(pen) pen++; +@end verbatim +The substring is placed in @var{pen} and it will be used as line style. +@verbatim + long pal=0; + char mk=gr->SetPenPal(pen,&pal); +@end verbatim +Next step, is determining colors for filling and for border. First one for filling. +@verbatim + mreal c=gr->GetC(ss,r); +@end verbatim +Second one for border. +@verbatim + mreal k=gr->NextColor(pal); +@end verbatim +The rest part is the same as in previous function. +@verbatim + if(!fill) k=c; + + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +@end verbatim + +The last thing which we can do is derive our own class with new plotting functions. Good idea is to derive it from @code{mglGraph} (if you don't need extended window), or from @code{mglWindow} (if you need to extend window). So, in our case it will be +@verbatim +class MyGraph : public mglGraph +{ +public: + inline void Circle(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle(p.x,p.y,p.z, r, stl, opt); } + inline void CircleCS(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle_cs(p.x,p.y,p.z, r, stl, opt); } +}; +@end verbatim +Note, that I use @code{inline} modifier for using the same binary code with different compilers. + +So, the complete sample will be +@verbatim +#include +//--------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt); +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt); +#ifdef __cplusplus +} +#endif +//--------------------------------------------------------- +class MyGraph : public mglGraph +{ +public: + inline void CircleCF(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle(p.x,p.y,p.z, r, stl, opt); } + inline void CircleCS(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle_cs(p.x,p.y,p.z, r, stl, opt); } +}; +//--------------------------------------------------------- +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ + if(r<=0) { gr->SetWarn(mglWarnNeg,"Circle"); return; } + static int cgid=1; gr->StartGroup("Circle",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); + long pal=0; + char mk=gr->SetPenPal(stl,&pal); + mreal c=gr->NextColor(pal), d; + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); + if(!fill) k=c; + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +//--------------------------------------------------------- +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ + static int cgid=1; gr->StartGroup("CircleCS",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); + long ss = gr->AddTexture(stl); + const char *pen=0; + if(stl) pen = strchr(stl,':'); + if(pen) pen++; + long pal=0; + char mk=gr->SetPenPal(pen,&pal); + mreal c=gr->GetC(ss,r); + mreal k=gr->NextColor(pal); + if(!fill) k=c; + + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +//--------------------------------------------------------- +int main() +{ + MyGraph gr; + gr.Box(); + // first let draw circles with fixed colors + for(int i=0;i<10;i++) + gr.CircleCF(mglPoint(2*mgl_rnd()-1, 2*mgl_rnd()-1), mgl_rnd()); + // now let draw circles with color scheme + for(int i=0;i<10;i++) + gr.CircleCS(mglPoint(2*mgl_rnd()-1, 2*mgl_rnd()-1), 2*mgl_rnd()-1); +} +@end verbatim + + + + +@c ------------------------------------------------------------------ +@external{} +@node mglDataA class, mglColor class, mglBase class, Other classes +@section User defined types (mglDataA class) +@nav{} + +@code{mglData} class have abstract predecessor class @code{mglDataA}. Exactly the pointers to @code{mglDataA} instances are used in all plotting functions and some of data processing functions. This was done for taking possibility to define yours own class, which will handle yours own data (for example, complex numbers, or differently organized data). And this new class will be almost the same as @code{mglData} for plotting purposes. + +However, the most of data processing functions will be slower as if you used @code{mglData} instance. This is more or less understandable -- I don't know how data in yours particular class will be organized, and couldn't optimize the these functions generally. + +There are few virtual functions which must be provided in derived classes. This functions give: +@itemize @bullet +@item +the sizes of the data (@code{GetNx}, @code{GetNy}, @code{GetNz}), +@item +give data value and numerical derivatives for selected cell (@code{v}, @code{dvx}, @code{dvy}, @code{dvz}), +@item +give maximal and minimal values (@code{Maximal}, @code{Minimal}) -- you can use provided functions (like @code{mgl_data_max} and @code{mgl_data_min}), but yours own realization can be more efficient, +@item +give access to all element as in single array (@code{vthr}) -- you need this only if you want using MathGL's data processing functions. +@end itemize + +Let me, for example define class @code{mglComplex} which will handle complex number and draw its amplitude or phase, depending on flag @var{use_abs}: +@verbatim +#include +#include +#define dual std::complex +class mglComplex : public mglDataA +{ +public: + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + dual *a; ///< data array + bool use_abs; ///< flag to use abs() or arg() + + inline mglComplex(long xx=1,long yy=1,long zz=1) + { a=0; use_abs=true; Create(xx,yy,zz); } + virtual ~mglComplex() { if(a) delete []a; } + + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + /// Create or recreate the array with specified size and fill it by zero + inline void Create(long mx,long my=1,long mz=1) + { nx=mx; ny=my; nz=mz; if(a) delete []a; + a = new dual[nx*ny*nz]; } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + +protected: + inline mreal v(long i,long j=0,long k=0) const + { return use_abs ? abs(a[i+nx*(j+ny*k)]) : arg(a[i+nx*(j+ny*k)]); } + inline mreal vthr(long i) const + { return use_abs ? abs(a[i]) : arg(a[i]); } + inline mreal dvx(long i,long j=0,long k=0) const + { register long i0=i+nx*(j+ny*k); + std::complex res=i>0? (i res=j>0? (j res=k>0? (k}. + +There are two ways to set the color in MathGL. First one is using of mreal values of red, green and blue channels for precise color definition. The second way is the using of character id. There are a set of characters specifying frequently used colors. Normally capital letter gives more dark color than lowercase one. @xref{Line styles}. + +@deftypecv {Parameter} mglColor @code{mreal} {r, g, b, a} +Reg, green and blue component of color. +@end deftypecv + +@deftypemethod mglColor @code{} mglColor (@code{mreal} R, @code{mreal} G, @code{mreal} B, @code{mreal} A=@code{1}) +Constructor sets the color by mreal values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod +@deftypemethod mglColor @code{} mglColor (@code{char} c=@code{'k'}, @code{mreal} bright=@code{1}) +Constructor sets the color from character id. The black color is used by default. Parameter @var{br} set additional ``lightness'' of color. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{mreal} R, @code{mreal} G, @code{mreal} B, @code{mreal} A=@code{1}) +Sets color from values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{mglColor} c, @code{mreal} bright=@code{1}) +Sets color as ``lighted'' version of color @var{c}. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{char} p, @code{mreal} bright=@code{1}) +Sets color from symbolic id. +@end deftypemethod +@deftypemethod mglColor @code{bool} Valid () +Checks correctness of the color. +@end deftypemethod +@deftypemethod mglColor @code{mreal} Norm () +Gets maximal of spectral component. +@end deftypemethod +@deftypemethod mglColor @code{bool} operator== (@code{const mglColor &}c) +@deftypemethodx mglColor @code{bool} operator!= (@code{const mglColor &}c) +Compare with another color +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator*= (@code{mreal} v) +Multiplies color components by number @var{v}. +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator+= (@code{const mglColor &}c) +Adds color @var{c} component by component. +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator-= (@code{const mglColor &}c) +Subtracts color @var{c} component by component. +@end deftypemethod + + +@deftypefn {Library Function} {mglColor} operator+ (@code{const mglColor &}a, @code{const mglColor &}b) +Adds colors by its RGB values. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator- (@code{const mglColor &}a, @code{const mglColor &}b) +Subtracts colors by its RGB values. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator* (@code{const mglColor &}a, @code{mreal} b) +@deftypefnx {Library Function} @code{mglColor} operator* (@code{mreal} a, @code{const mglColor &}b) +Multiplies color by number. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator/ (@code{const mglColor &}a, @code{mreal} b) +Divide color by number. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator! (@code{const mglColor &}a) +Return inverted color. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node mglPoint class, , mglColor class, Other classes +@section mglPoint class +@nav{} +@cindex mglPoint + +Structure describes point in space. This structure is defined in @code{#include } + +@deftypecv {Parameter} mglPoint @code{mreal} {x, y, z, c} +Point coordinates @{x,y,z@} and one extra value @var{c} used for amplitude, transparency and so on. By default all values are zero. +@end deftypecv + +@deftypemethod mglPoint @code{} mglPoint (@code{mreal} X=@code{0}, @code{mreal} Y=@code{0}, @code{mreal} Z=@code{0}, @code{mreal} C=@code{0}) +Constructor sets the color by mreal values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod + +@deftypemethod mglPoint @code{bool} IsNAN () +Returns @code{true} if point contain NAN values. +@end deftypemethod +@deftypemethod mglPoint @code{mreal} norm () +Returns the norm @math{\sqrt@{x^2+y^2+z^2@}} of vector. +@end deftypemethod +@deftypemethod mglPoint @code{void} Normalize () +Normalizes vector to be unit vector. +@end deftypemethod +@deftypemethod mglPoint @code{mreal} val (@code{int} i) +Returns point component: @var{x} for @var{i}=0, @var{y} for @var{i}=1, @var{z} for @var{i}=2, @var{c} for @var{i}=3. +@end deftypemethod + + +@deftypefn {Library Function} @code{mglPoint} operator+ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Point of summation (summation of vectors). +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator- (@code{const mglPoint &}a, @code{const mglPoint &}b) +Point of difference (difference of vectors). +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator* (@code{mreal} a, @code{const mglPoint &}b) +@deftypefnx {Library Function} @code{mglPoint} operator* (@code{const mglPoint &}a, @code{mreal} b) +Multiplies (scale) points by number. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator/ (@code{const mglPoint &}a, @code{mreal} b) +Multiplies (scale) points by number 1/b. +@end deftypefn +@deftypefn {Library Function} @code{mreal} operator* (@code{const mglPoint &}a, @code{const mglPoint &}b) +Scalar product of vectors. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator/ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return vector of element-by-element product. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator^ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Cross-product of vectors. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator& (@code{const mglPoint &}a, @code{const mglPoint &}b) +The part of @var{a} which is perpendicular to vector @var{b}. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator| (@code{const mglPoint &}a, @code{const mglPoint &}b) +The part of @var{a} which is parallel to vector @var{b}. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator! (@code{const mglPoint &}a) +Return vector perpendicular to vector @var{a}. +@end deftypefn +@deftypefn {Library Function} @code{mreal} mgl_norm (@code{const mglPoint &}a) +Return the norm sqrt(|@var{a}|^2) of vector @var{a}. +@end deftypefn + +@deftypefn {Library Function} @code{bool} operator== (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return true if points are the same. +@end deftypefn +@deftypefn {Library Function} @code{bool} operator!= (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return true if points are different. +@end deftypefn + +@external{} + diff --git a/texinfo/other_ru.texi b/texinfo/other_ru.texi new file mode 100644 index 0000000..038903f --- /dev/null +++ b/texinfo/other_ru.texi @@ -0,0 +1,565 @@ +@c ------------------------------------------------------------------ +@chapter Other classes +@nav{} + +There are few end-user classes: @code{mglGraph} (see @ref{MathGL core}), @code{mglWindow} and @code{mglGLUT} (see @ref{Widget classes}), @code{mglData} (see @ref{Data processing}), @code{mglParse} (see @ref{MGL scripts}). Exactly these classes I recommend to use in most of user programs. All methods in all of these classes are inline and have exact C/Fortran analogue functions. This give compiler independent binary libraries for MathGL. + +However, sometimes you may need to extend MathGL by writing yours own plotting functions or handling yours own data structures. In these cases you may need to use low-level API. This chapter describes it. + +@fig{classes, Class diagram for MathGL} + +The internal structure of MathGL is rather complicated. There are C++ classes @code{mglBase}, @code{mglCanvas}, ... for drawing primitives and positioning the plot (blue ones in the figure). There is a layer of C functions, which include interface for most important methods of these classes. Also most of plotting functions are implemented as C functions. After it, there are ``inline'' front-end classes which are created for user convenience (yellow ones in the figure). Also there are widgets for FLTK, Qt and other libraries (green ones in the figure). + +Below I show how this internal classes can be used. + +@menu +* mglBase class:: +* mglDataA class:: +* mglColor class:: +* mglPoint class:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node mglBase class, mglDataA class, , Other classes +@section Define new kind of plot (mglBase class) +@nav{} + +Basically most of new kinds of plot can be created using just MathGL primitives (see @ref{Primitives}). However the usage of @code{mglBase} methods can give you higher speed of drawing and better control of plot settings. + +All plotting functions should use a pointer to @code{mglBase} class (or @code{HMGL} type in C functions) due to compatibility issues. Exactly such type of pointers are used in front-end classes (@code{mglGraph, mglWindow}) and in widgets (@code{QMathGL, Fl_MathGL}). + +MathGL tries to remember all vertexes and all primitives and plot creation stage, and to use them for making final picture by demand. Basically for making plot, you need to add vertexes by @code{AddPnt()} function, which return index for new vertex, and call one of primitive drawing function (like @code{mark_plot(), arrow_plot(), line_plot(), trig_plot(), quad_plot(), text_plot()}), using vertex indexes as argument(s). @code{AddPnt()} function use 2 mreal numbers for color specification. First one is positioning in textures -- integer part is texture index, fractional part is relative coordinate in the texture. Second number is like a transparency of plot (or second coordinate in the 2D texture). + +I don't want to put here detailed description of @code{mglBase} class. It was rather well documented in @code{mgl2/base.h} file. I just show and example of its usage on the base of circle drawing. + +First, we should prototype new function @code{circle()} as C function. +@verbatim +#ifdef __cplusplus +extern "C" { +#endif +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt); +#ifdef __cplusplus +} +#endif +@end verbatim +This is done for generating compiler independent binary. Because only C-functions have standard naming mechanism, the same for any compilers. + +Now, we create a C++ file and put the code of function. I'll write it line by line and try to comment all important points. +@verbatim +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ +@end verbatim +First, we need to check all input arguments and send warnings if something is wrong. In our case it is negative value of @var{r} argument. We just send warning, since it is not critical situation -- other plot still can be drawn. +@verbatim + if(r<=0) { gr->SetWarn(mglWarnNeg,"Circle"); return; } +@end verbatim +Next step is creating a group. Group keep some general setting for plot (like options) and useful for export in 3d files. +@verbatim + static int cgid=1; gr->StartGroup("Circle",cgid++); +@end verbatim +Now let apply options. Options are rather useful things, generally, which allow one easily redefine axis range(s), transparency and other settings (see @ref{Command options}). +@verbatim + gr->SaveState(opt); +@end verbatim +I use global setting for determining the number of points in circle approximation. Note, that user can change @code{MeshNum} by options easily. +@verbatim + const int n = gr->MeshNum>1?gr->MeshNum : 41; +@end verbatim +Let try to determine plot specific flags. MathGL functions expect that most of flags will be sent in string. In our case it is symbol @samp{@@} which set to draw filled circle instead of border only (last will be default). Note, you have to handle @code{NULL} as string pointer. +@verbatim + bool fill = mglchr(stl,'@'); +@end verbatim +Now, time for coloring. I use palette mechanism because circle have few colors: one for filling and another for border. @code{SetPenPal()} function parse input string and write resulting texture index in @var{pal}. Function return the character for marker, which can be specified in string @var{str}. Marker will be plotted at the center of circle. I'll show on next sample how you can use color schemes (smooth colors) too. +@verbatim + long pal=0; + char mk=gr->SetPenPal(stl,&pal); +@end verbatim +Next step, is determining colors for filling and for border. First one for filling. +@verbatim + mreal c=gr->NextColor(pal), d; +@end verbatim +Second one for border. I use black color (call @code{gr->AddTexture('k')}) if second color is not specified. +@verbatim + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); +@end verbatim +If user want draw only border (@code{fill=false}) then I use first color for border. +@verbatim + if(!fill) k=c; +@end verbatim +Now we should reserve space for vertexes. This functions need @code{n} for border, @code{n+1} for filling and @code{1} for marker. So, maximal number of vertexes is @code{2*n+2}. Note, that such reservation is not required for normal work but can sufficiently speed up the plotting. +@verbatim + gr->Reserve(2*n+2); +@end verbatim +We've done with setup and ready to start drawing. First, we need to add vertex(es). Let define NAN as normals, since I don't want handle lighting for this plot, +@verbatim + mglPoint q(NAN,NAN); +@end verbatim +and start adding vertexes. First one for central point of filling. I use @code{-1} if I don't need this point. The arguments of @code{AddPnt()} function is: @code{mglPoint(x,y,z)} -- coordinate of vertex, @code{c} -- vertex color, @code{q} -- normal at vertex, @code{-1} -- vertex transparency (@code{-1} for default), @code{3} bitwise flag which show that coordinates will be scaled (@code{0x1}) and will not be cutted (@code{0x2}). +@verbatim + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; +@end verbatim +Similar for marker, but we use different color @var{k}. +@verbatim + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; +@end verbatim +Draw marker. +@verbatim + if(mk) gr->mark_plot(n2,mk); +@end verbatim +Time for drawing circle itself. I use @code{-1} for @var{m1}, @var{n1} as sign that primitives shouldn't be drawn for first point @code{i=0}. +@verbatim + for(i=0,m1=n1=-1;iStop) return; +@end verbatim +Let find coordinates of vertex. +@verbatim + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); +@end verbatim +Save previous vertex and add next one +@verbatim + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); +@end verbatim +and copy it for border but with different color. Such copying is much faster than adding new vertex using @code{AddPnt()}. +@verbatim + m2 = m1; m1 = gr->CopyNtoC(n1,k); +@end verbatim +Now draw triangle for filling internal part +@verbatim + if(fill) gr->trig_plot(n0,n1,n2); +@end verbatim +and draw line for border. +@verbatim + gr->line_plot(m1,m2); + } +@end verbatim +Drawing is done. Let close group and return. +@verbatim + gr->EndGroup(); +} +@end verbatim + +Another sample I want to show is exactly the same function but with smooth coloring using color scheme. So, I'll add comments only in the place of difference. + +@verbatim +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ +@end verbatim +In this case let allow negative radius too. Formally it is not the problem for plotting (formulas the same) and this allow us to handle all color range. +@verbatim +//if(r<=0) { gr->SetWarn(mglWarnNeg,"Circle"); return; } + + static int cgid=1; gr->StartGroup("CircleCS",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); +@end verbatim +Here is main difference. We need to create texture for color scheme specified by user +@verbatim + long ss = gr->AddTexture(stl); +@end verbatim +But we need also get marker and color for it (if filling is enabled). Let suppose that marker and color is specified after @samp{:}. This is standard delimiter which stop color scheme entering. So, just lets find it and use for setting pen. +@verbatim + const char *pen=0; + if(stl) pen = strchr(stl,':'); + if(pen) pen++; +@end verbatim +The substring is placed in @var{pen} and it will be used as line style. +@verbatim + long pal=0; + char mk=gr->SetPenPal(pen,&pal); +@end verbatim +Next step, is determining colors for filling and for border. First one for filling. +@verbatim + mreal c=gr->GetC(ss,r); +@end verbatim +Second one for border. +@verbatim + mreal k=gr->NextColor(pal); +@end verbatim +The rest part is the same as in previous function. +@verbatim + if(!fill) k=c; + + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +@end verbatim + +The last thing which we can do is derive our own class with new plotting functions. Good idea is to derive it from @code{mglGraph} (if you don't need extended window), or from @code{mglWindow} (if you need to extend window). So, in our case it will be +@verbatim +class MyGraph : public mglGraph +{ +public: + inline void Circle(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle(p.x,p.y,p.z, r, stl, opt); } + inline void CircleCS(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle_cs(p.x,p.y,p.z, r, stl, opt); } +}; +@end verbatim +Note, that I use @code{inline} modifier for using the same binary code with different compilers. + +So, the complete sample will be +@verbatim +#include +//--------------------------------------------------------- +#ifdef __cplusplus +extern "C" { +#endif +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt); +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt); +#ifdef __cplusplus +} +#endif +//--------------------------------------------------------- +class MyGraph : public mglGraph +{ +public: + inline void CircleCF(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle(p.x,p.y,p.z, r, stl, opt); } + inline void CircleCS(mglPoint p, mreal r, const char *stl="", const char *opt="") + { circle_cs(p.x,p.y,p.z, r, stl, opt); } +}; +//--------------------------------------------------------- +void circle(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ + if(r<=0) { gr->SetWarn(mglWarnNeg,"Circle"); return; } + static int cgid=1; gr->StartGroup("Circle",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); + long pal=0; + char mk=gr->SetPenPal(stl,&pal); + mreal c=gr->NextColor(pal), d; + mreal k=(gr->GetNumPal(pal)>1)?gr->NextColor(pal):gr->AddTexture('k'); + if(!fill) k=c; + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +//--------------------------------------------------------- +void circle_cs(HMGL gr, mreal x, mreal y, mreal z, mreal r, const char *stl, const char *opt) +{ + static int cgid=1; gr->StartGroup("CircleCS",cgid++); + gr->SaveState(opt); + const int n = gr->MeshNum>1?gr->MeshNum : 41; + bool fill = mglchr(stl,'@'); + long ss = gr->AddTexture(stl); + const char *pen=0; + if(stl) pen = strchr(stl,':'); + if(pen) pen++; + long pal=0; + char mk=gr->SetPenPal(pen,&pal); + mreal c=gr->GetC(ss,r); + mreal k=gr->NextColor(pal); + if(!fill) k=c; + + gr->Reserve(2*n+2); + mglPoint q(NAN,NAN); + long n0,n1,n2,m1,m2,i; + n0 = fill ? gr->AddPnt(mglPoint(x,y,z),c,q,-1,3):-1; + n2 = mk ? gr->AddPnt(mglPoint(x,y,z),k,q,-1,3):-1; + if(mk) gr->mark_plot(n2,mk); + for(i=0,m1=n1=-1;iStop) return; + mreal t = i*2*M_PI/(n-1.); + mglPoint p(x+r*cos(t), y+r*sin(t), z); + n2 = n1; n1 = gr->AddPnt(p,c,q,-1,3); + m2 = m1; m1 = gr->CopyNtoC(n1,k); + if(fill) gr->trig_plot(n0,n1,n2); + gr->line_plot(m1,m2); + } + gr->EndGroup(); +} +//--------------------------------------------------------- +int main() +{ + MyGraph gr; + gr.Box(); + // first let draw circles with fixed colors + for(int i=0;i<10;i++) + gr.CircleCF(mglPoint(2*mgl_rnd()-1, 2*mgl_rnd()-1), mgl_rnd()); + // now let draw circles with color scheme + for(int i=0;i<10;i++) + gr.CircleCS(mglPoint(2*mgl_rnd()-1, 2*mgl_rnd()-1), 2*mgl_rnd()-1); +} +@end verbatim + + + + +@c ------------------------------------------------------------------ +@external{} +@node mglDataA class, mglColor class, mglBase class, Other classes +@section User defined types (mglDataA class) +@nav{} + +@code{mglData} class have abstract predecessor class @code{mglDataA}. Exactly the pointers to @code{mglDataA} instances are used in all plotting functions and some of data processing functions. This was done for taking possibility to define yours own class, which will handle yours own data (for example, complex numbers, or differently organized data). And this new class will be almost the same as @code{mglData} for plotting purposes. + +However, the most of data processing functions will be slower as if you used @code{mglData} instance. This is more or less understandable -- I don't know how data in yours particular class will be organized, and couldn't optimize the these functions generally. + +There are few virtual functions which must be provided in derived classes. This functions give: +@itemize @bullet +@item +the sizes of the data (@code{GetNx}, @code{GetNy}, @code{GetNz}), +@item +give data value and numerical derivatives for selected cell (@code{v}, @code{dvx}, @code{dvy}, @code{dvz}), +@item +give maximal and minimal values (@code{Maximal}, @code{Minimal}) -- you can use provided functions (like @code{mgl_data_max} and @code{mgl_data_min}), but yours own realization can be more efficient, +@item +give access to all element as in single array (@code{vthr}) -- you need this only if you want using MathGL's data processing functions. +@end itemize + +Let me, for example define class @code{mglComplex} which will handle complex number and draw its amplitude or phase, depending on flag @var{use_abs}: +@verbatim +#include +#include +#define dual std::complex +class mglComplex : public mglDataA +{ +public: + long nx; ///< number of points in 1st dimensions ('x' dimension) + long ny; ///< number of points in 2nd dimensions ('y' dimension) + long nz; ///< number of points in 3d dimensions ('z' dimension) + dual *a; ///< data array + bool use_abs; ///< flag to use abs() or arg() + + inline mglComplex(long xx=1,long yy=1,long zz=1) + { a=0; use_abs=true; Create(xx,yy,zz); } + virtual ~mglComplex() { if(a) delete []a; } + + /// Get sizes + inline long GetNx() const { return nx; } + inline long GetNy() const { return ny; } + inline long GetNz() const { return nz; } + /// Create or recreate the array with specified size and fill it by zero + inline void Create(long mx,long my=1,long mz=1) + { nx=mx; ny=my; nz=mz; if(a) delete []a; + a = new dual[nx*ny*nz]; } + /// Get maximal value of the data + inline mreal Maximal() const { return mgl_data_max(this); } + /// Get minimal value of the data + inline mreal Minimal() const { return mgl_data_min(this); } + +protected: + inline mreal v(long i,long j=0,long k=0) const + { return use_abs ? abs(a[i+nx*(j+ny*k)]) : arg(a[i+nx*(j+ny*k)]); } + inline mreal vthr(long i) const + { return use_abs ? abs(a[i]) : arg(a[i]); } + inline mreal dvx(long i,long j=0,long k=0) const + { register long i0=i+nx*(j+ny*k); + std::complex res=i>0? (i res=j>0? (j res=k>0? (k}. + +There are two ways to set the color in MathGL. First one is using of mreal values of red, green and blue channels for precise color definition. The second way is the using of character id. There are a set of characters specifying frequently used colors. Normally capital letter gives more dark color than lowercase one. @xref{Line styles}. + +@deftypecv {Parameter} mglColor @code{mreal} {r, g, b, a} +Reg, green and blue component of color. +@end deftypecv + +@deftypemethod mglColor @code{} mglColor (@code{mreal} R, @code{mreal} G, @code{mreal} B, @code{mreal} A=@code{1}) +Constructor sets the color by mreal values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod +@deftypemethod mglColor @code{} mglColor (@code{char} c=@code{'k'}, @code{mreal} bright=@code{1}) +Constructor sets the color from character id. The black color is used by default. Parameter @var{br} set additional ``lightness'' of color. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{mreal} R, @code{mreal} G, @code{mreal} B, @code{mreal} A=@code{1}) +Sets color from values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{mglColor} c, @code{mreal} bright=@code{1}) +Sets color as ``lighted'' version of color @var{c}. +@end deftypemethod +@deftypemethod mglColor @code{void} Set (@code{char} p, @code{mreal} bright=@code{1}) +Sets color from symbolic id. +@end deftypemethod +@deftypemethod mglColor @code{bool} Valid () +Checks correctness of the color. +@end deftypemethod +@deftypemethod mglColor @code{mreal} Norm () +Gets maximal of spectral component. +@end deftypemethod +@deftypemethod mglColor @code{bool} operator== (@code{const mglColor &}c) +@deftypemethodx mglColor @code{bool} operator!= (@code{const mglColor &}c) +Compare with another color +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator*= (@code{mreal} v) +Multiplies color components by number @var{v}. +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator+= (@code{const mglColor &}c) +Adds color @var{c} component by component. +@end deftypemethod + +@deftypemethod mglColor @code{bool} operator-= (@code{const mglColor &}c) +Subtracts color @var{c} component by component. +@end deftypemethod + + +@deftypefn {Library Function} {mglColor} operator+ (@code{const mglColor &}a, @code{const mglColor &}b) +Adds colors by its RGB values. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator- (@code{const mglColor &}a, @code{const mglColor &}b) +Subtracts colors by its RGB values. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator* (@code{const mglColor &}a, @code{mreal} b) +@deftypefnx {Library Function} @code{mglColor} operator* (@code{mreal} a, @code{const mglColor &}b) +Multiplies color by number. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator/ (@code{const mglColor &}a, @code{mreal} b) +Divide color by number. +@end deftypefn +@deftypefn {Library Function} @code{mglColor} operator! (@code{const mglColor &}a) +Return inverted color. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node mglPoint class, , mglColor class, Other classes +@section mglPoint class +@nav{} +@cindex mglPoint + +Structure describes point in space. This structure is defined in @code{#include } + +@deftypecv {Parameter} mglPoint @code{mreal} {x, y, z, c} +Point coordinates @{x,y,z@} and one extra value @var{c} used for amplitude, transparency and so on. By default all values are zero. +@end deftypecv + +@deftypemethod mglPoint @code{} mglPoint (@code{mreal} X=@code{0}, @code{mreal} Y=@code{0}, @code{mreal} Z=@code{0}, @code{mreal} C=@code{0}) +Constructor sets the color by mreal values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1]. +@end deftypemethod + +@deftypemethod mglPoint @code{bool} IsNAN () +Returns @code{true} if point contain NAN values. +@end deftypemethod +@deftypemethod mglPoint @code{mreal} norm () +Returns the norm @math{\sqrt@{x^2+y^2+z^2@}} of vector. +@end deftypemethod +@deftypemethod mglPoint @code{void} Normalize () +Normalizes vector to be unit vector. +@end deftypemethod +@deftypemethod mglPoint @code{mreal} val (@code{int} i) +Returns point component: @var{x} for @var{i}=0, @var{y} for @var{i}=1, @var{z} for @var{i}=2, @var{c} for @var{i}=3. +@end deftypemethod + + +@deftypefn {Library Function} @code{mglPoint} operator+ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Point of summation (summation of vectors). +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator- (@code{const mglPoint &}a, @code{const mglPoint &}b) +Point of difference (difference of vectors). +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator* (@code{mreal} a, @code{const mglPoint &}b) +@deftypefnx {Library Function} @code{mglPoint} operator* (@code{const mglPoint &}a, @code{mreal} b) +Multiplies (scale) points by number. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator/ (@code{const mglPoint &}a, @code{mreal} b) +Multiplies (scale) points by number 1/b. +@end deftypefn +@deftypefn {Library Function} @code{mreal} operator* (@code{const mglPoint &}a, @code{const mglPoint &}b) +Scalar product of vectors. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator/ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return vector of element-by-element product. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator^ (@code{const mglPoint &}a, @code{const mglPoint &}b) +Cross-product of vectors. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator& (@code{const mglPoint &}a, @code{const mglPoint &}b) +The part of @var{a} which is perpendicular to vector @var{b}. +@end deftypefn +@deftypefn {Library Function} @code{mglPoint} operator| (@code{const mglPoint &}a, @code{const mglPoint &}b) +The part of @var{a} which is parallel to vector @var{b}. +@end deftypefn + +@deftypefn {Library Function} @code{mglPoint} operator! (@code{const mglPoint &}a) +Return vector perpendicular to vector @var{a}. +@end deftypefn +@deftypefn {Library Function} @code{mreal} mgl_norm (@code{const mglPoint &}a) +Return the norm sqrt(|@var{a}|^2) of vector @var{a}. +@end deftypefn + +@deftypefn {Library Function} @code{bool} operator== (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return true if points are the same. +@end deftypefn +@deftypefn {Library Function} @code{bool} operator!= (@code{const mglPoint &}a, @code{const mglPoint &}b) +Return true if points are different. +@end deftypefn + +@external{} + diff --git a/texinfo/overview_en.texi b/texinfo/overview_en.texi new file mode 100644 index 0000000..ca0e512 --- /dev/null +++ b/texinfo/overview_en.texi @@ -0,0 +1,232 @@ +@chapter Overview +@nav{} + +@cindex MathGL overview + +MathGL is ... +@itemize @bullet +@item +a library for making high-quality scientific graphics under Linux and Windows; +@item +a library for the fast data plotting and handling of large data arrays; +@item +a library for working in window and console modes and for easy embedding into other programs; +@item +a library with large and growing set of graphics. +@end itemize + +@menu +* What is MathGL?:: +* MathGL features:: +* Installation:: +* Quick guide:: +* Changes from v.1:: +* Utilities:: +* Thanks:: +@end menu + +@external{} +@node What is MathGL?, MathGL features, , Overview +@section What is MathGL? +@nav{} + +A code for making high-quality scientific graphics under Linux and Windows. A code for the fast handling and plotting of large data arrays. A code for working in window and console regimes and for easy including into another program. A code with large and renewal set of graphics. Exactly such a code I tried to put in MathGL library. + +At this version (@value{VERSION}) MathGL has more than 50 general types of graphics for 1d, 2d and 3d data arrays. It can export graphics to bitmap and vector (EPS or SVG) files. It has OpenGL interface and can be used from console programs. It has functions for data handling and script MGL language for simplification of data plotting. It also has several types of transparency and smoothed lighting, vector fonts and TeX-like symbol parsing, arbitrary curvilinear coordinate system and many other useful things (see pictures section at @uref{http://mathgl.sf.net/, homepage}). Finally it is platform-independent and free (under GPL v.2.0 or later license). + +@external{} +@node MathGL features, Installation, What is MathGL?, Overview +@section MathGL features +@nav{} + +MathGL can plot a wide range of graphics. It includes: +@itemize @bullet +@item +one-dimensional (Plot, Area, Bars, Step, Stem, Torus, Chart, Error, Tube, Mark, @pxref{1D plotting}); + +@item +two-dimensional plots (Mesh, Surf, Dens, Cont, ContF, Boxs, Axial, Fall, Belt, Tile, @pxref{2D plotting}); + +@item +three-dimensional plots (Surf3, Dens3, Cont3, ContF3, Cloud-like, @pxref{3D plotting}); + +@item +dual data plots: vector fields Vect, flow threads Flow, mapping chart Map, surfaces and isosurfaces, transparent or colored (i.e. with transparency or color varied) by other data SurfA, SurfC, Surf3A, Surf3C (@pxref{Dual plotting}); + +@item +and so on. For details see @pxref{MathGL core}. +@end itemize + +In fact, I created the functions for drawing of all the types of scientific plots that I know. The list of plots is growing; if you need some special type of a plot then please email me @email{mathgl.abalakin@@gmail.com, e-mail} and it will appear in the new version. + +I tried to make plots as nice looking as possible: e.g., a surface can be transparent and highlighted by several (up to 10) light sources. Most of the drawing functions have 2 variants: simple one for the fast plotting of data, complex one for specifying of the exact position of the plot (including parametric representation). Resulting image can be saved in bitmap PNG, JPEG, GIF, TGA, BMP format, or in vector EPS, SVG or TeX format, or in 3D formats OBJ, OFF, STL, or in PRC format which can be converted into U3D. + +All texts are drawn by vector fonts, which allows for high scalability and portability. Texts may contain commands for: some of the TeX-like symbols, changing index (upper or lower indexes) and the style of font inside the text string (@pxref{Font styles}). Texts of ticks are rotated with axis rotation. It is possible to create a legend of plot and put text in an arbitrary position on the plot. Arbitrary text encoding (by the help of function @code{setlocale()}) and UTF-16 encoding are supported. + +Special class mglData is used for data encapsulation (@pxref{Data processing}). In addition to a safe creation and deletion of data arrays it includes functions for data processing (smoothing, differentiating, integrating, interpolating and so on) and reading of data files with automatic size determination. Class mglData can handle arrays with up to three dimensions (arrays which depend on up to 3 independent indexes @math{a_@{ijk@}}). Using an array with higher number of dimensions is not meaningful, because I do not know how it can be plotted. Data filling and modification may be done manually or by textual formulas. + +There is fast evaluation of a textual mathematical expression (@pxref{Textual formulas}). It is based on string precompilation to tree-like code at the creation of class instance. At evaluation stage code performs only fast tree-walk and returns the value of the expression. In addition to changing data values, textual formulas are also used for drawing in @emph{arbitrary} curvilinear coordinates. A set of such curvilinear coordinates is limited only by user's imagination rather than a fixed list like: polar, parabolic, spherical, and so on. + +@external{} +@node Installation, Quick guide, MathGL features, Overview +@section Installation +@nav{} + +MathGL can be installed in 4 different ways. +@enumerate +@item +Compile from sources. The cmake build system is useded in the library. To run it, one should execute commands: @code{cmake .} twice, after it @code{make} and @code{make install} with root/sudo rights. Sometimes after installation you may need to update the library list -- just execute @code{ldconfig} with root/sudo rights. + +There are several additional options which are switched off by default. They are: @code{enable-fltk, enable-glut, enable-qt} for ebabling FLTK, GLUT and/or Qt windows; @code{enable-jpeg, enable-gif, enable-hdf5} and so on for enabling corresponding file formats; @code{enable-all} for enabling all additional features. For using @code{double} as base internal data type use option @code{enable-double}. For enabling language interfaces use @code{enable-python, enable-octave} or @code{enable-all-swig} for all languages. You can use WYSIWYG tool (@code{cmake-gui}) to view all of them, or type @code{cmake -D enable-all=on -D enable-all-widgets=on -D enable-all-swig=on .} in command line for enabling all features. + +There is known bug for building in MinGW -- you need to manually add linker option @code{-fopenmp} (i.e. @code{CMAKE_EXE_LINKER_FLAGS:STRING='-fopenmp'} and @code{CMAKE_SHARED_LINKER_FLAGS:STRING='-fopenmp'}) if you enable OpenMP support (i.e. if @code{enable-openmp=ON}). + +@item +Use a precompiled binary. There are binaries for MinGW (platform Win32). For a precompiled variant one needs only to unpack the archive to the location of the compiler (i.e. mathgl/lib in mingw/lib, mathgl/include in mingw/include and so on) or in arbitrary other folder and setup paths in compiler. By default, precompiled versions include the support of GSL (www.gsl.org) and PNG. So, one needs to have these libraries installed on system (it can be found, for example, at @uref{http://gnuwin32.sourceforge.net/packages.html}). + +@item +Install precompiled versions from standard packages (RPM, deb, DevPak and so on). +@end enumerate + +Note, you can download the latest sources (which can be not stable) from sourceforge.net SVN by command +@verbatim +svn checkout http://svn.code.sf.net/p/mathgl/code/mathgl-2x mathgl-code +@end verbatim + +@c ------------------------------------------------------------------ +@external{} +@node Quick guide, Changes from v.1, Installation, Overview +@section Quick guide +@nav{} + +There are 3 steps to prepare the plot in MathGL: (1) prepare data to be plotted, (2) setup plot, (3) plot data. Let me show this on the example of surface plotting. + +First we need the data. MathGL use its own class @code{mglData} to handle data arrays (see @ref{Data processing}). This class give ability to handle data arrays by more or less format independent way. So, create it +@verbatim + int main() + { + mglData dat(30,40); // data to for plotting + for(long i=0;i<30;i++) for(long j=0;j<40;j++) + dat.a[i+30*j] = 1/(1+(i-15)*(i-15)/225.+(j-20)*(j-20)/400.); +@end verbatim +Here I create matrix 30*40 and initialize it by formula. Note, that I use @code{long} type for indexes @var{i}, @var{j} because data arrays can be really large and @code{long} type will automatically provide proper indexing. + +Next step is setup of the plot. The only setup I need is axis rotation and lighting. +@verbatim + mglGraph gr; // class for plot drawing + gr.Rotate(50,60); // rotate axis + gr.Light(true); // enable lighting +@end verbatim + +Everything is ready. And surface can be plotted. +@verbatim + gr.Surf(dat); // plot surface +@end verbatim +Basically plot is done. But I decide to add yellow (@samp{y} color, see @ref{Color styles}) contour lines on the surface. To do it I can just add: +@verbatim + gr.Cont(dat,"y"); // plot yellow contour lines +@end verbatim +This demonstrate one of base MathGL concept (see, @ref{General concepts}) -- ``new drawing never clears things drawn already''. So, you can just consequently call different plotting functions to obtain ``combined'' plot. For example, if one need to draw axis then he can just call one more plotting function +@verbatim + gr.Axis(); // draw axis +@end verbatim + +Now picture is ready and we can save it in a file. +@verbatim + gr.WriteFrame("sample.png"); // save it + } +@end verbatim + +To compile your program, you need to specify the linker option @code{-lmgl}. + +This is enough for a compilation of console program or with external (non-MathGL) window library. If you want to use FLTK or Qt windows provided by MathGL then you need to add the option @code{-lmgl-wnd}. + +Fortran users also should add C++ library by the option @code{-lstdc++}. If library was built with @code{enable-double=ON} (this default for v.2.1 and later) then all real numbers must be real*8. You can make it automatic if use option @code{-fdefault-real-8}. + +@c ------------------------------------------------------------------ +@external{} +@node Changes from v.1, Utilities, Quick guide, Overview +@section Changes from v.1.* +@nav{} + +There are a lot of changes for v.2. Here I denote only main of them. +@itemize @bullet +@item +mglGraph class is single plotter class instead of mglGraphZB, mglGraphPS and so on. +@item +Text style and text color positions are swapped. I.e. text style @samp{r:C} give red centered text, but not roman dark cyan text as for v.1.*. +@item +ColumnPlot() indexing is reverted. +@item +Move most of arguments of plotting functions into the string parameter and/or options. +@item +``Bright'' colors (like @{b8@}) can be used in color schemes and line styles. +@item +Intensively use pthread internally for parallelization of drawing and data processing. +@item +Add tick labels rotation and skipping. Add ticks in time/date format. +@item +New kinds of plots (Tape(), Label(), Cones(), ContV()). Extend existing plots. New primitives (Circle(), Ellipse(), Rhomb(), ...). New plot positioning (MultiPlot(), GridPlot()) +@item +Improve MGL scripts. Add 'ask' command and allow string concatenation from different lines. +@item +Export to LaTeX and to 3D formats (OBJ, OFF, STL). +@item +Add pipes support in utilities (@code{mglconv, mglview}). +@end itemize + +@c ------------------------------------------------------------------ +@external{} +@node Utilities, Thanks, Changes from v.1, Overview +@section Utilities for parsing MGL +@nav{} + +MathGL library provides several tools for parsing MGL scripts. There is tools saving it to bitmap or vectorial images (@code{mglconv}). Tool @code{mglview} show MGL script and allow to rotate and setup the image. Another feature of @code{mglview} is loading *.mgld files (see @code{ExportMGLD()}) for quick viewing 3d pictures. + +Both tools have similar set of arguments. They can be name of script file or options. You can use @samp{-} as script name for using standard input (i.e. pipes). Options are: +@itemize +@item @strong{-1} @var{str} +set @var{str} as argument $1 for script; +@item ... +... +@item @strong{-9} @var{str} +set @var{str} as argument $9 for script; +@item @strong{-A} @var{val} +add @var{val} into the list of animation parameters; +@item @strong{-C} @var{v1}:@var{v2}[:@var{dv}] +add values from @var{v1} ot @var{v2} with step @var{dv} (default is 1) into the list of animation parameters; +@item @strong{-L} @var{loc} +set locale to @var{loc}; +@item @strong{-o} @var{name} +set output file name; +@item @strong{-h} +print help message. +@end itemize + +Additionally you can create animated GIF file or a set of JPEG files with names @samp{frameNNNN.jpg} (here @samp{NNNN} is frame index). Values of the parameter @code{$0} for making animation can be specified inside the script by comment @code{##a val} for each value @code{val} (one comment for one value) or by option(s) @samp{-A val}. Also you can specify a cycle for animation by comment @code{##c v1 v2 dv} or by option @code{-C v1:v2:dv}. In the case of found/specified animation parameters, tool will execute script several times -- once for each value of @code{$0}. + + +MathGL also provide another simple tool @code{mgl.cgi} which parse MGL script from CGI request and send back produced PNG file. Usually this program should be placed in @code{/usr/lib/cgi-bin/}. But you need to put this program by yourself due to possible security issues and difference of Apache server settings. + +@c ------------------------------------------------------------------ +@external{} +@node Thanks, , Utilities, Overview +@section Thanks +@nav{} + +@itemize @bullet +@item +My special thanks to my wife for the patience during the writing of this library and for the help in documentation writing and spelling. +@item +I'm thankful to my coauthors D. Kulagin and M. Vidassov for help in developing MathGL. +@item +I'm thankful to D. Eftaxiopoulos, V. Lipatov and S.M. Plis for making binary packages for Linux. +@item +I'm thankful to S. Skobelev, C. Mikhailenko, M. Veysman, A. Prokhorov, A. Korotkevich, V. Onuchin, S.M. Plis, R. Kiselev, A. Ivanov, N. Troickiy and V. Lipatov for fruitful comments. +@item +I'm thankful to sponsors M. Veysman (@uref{http://jiht.ru/en/about/structure.php?set_filter_structure=Y&structure_UF_DEPARTMENT=241&filter=Y&set_filter=Y, IHED RAS}) and A. Prokhorov (@url{www.datadvance.net, DATADVANCE}). +@end itemize + +Javascript interface was developed with support of @url{www.datadvance.net, DATADVANCE} company. + +@external{} diff --git a/texinfo/overview_ru.texi b/texinfo/overview_ru.texi new file mode 100644 index 0000000..8d86cba --- /dev/null +++ b/texinfo/overview_ru.texi @@ -0,0 +1,236 @@ +@chapter Обзор MathGL +@nav{} + +@cindex Обзор MathGL + +MathGL это ... +@itemize @bullet +@item +библиотека для создания высококачественной научной графики под Linux и Windows; +@item +библиотека для быстрого обработки и отображения больших массивов данных; +@item +библиотека для работы в оконном и консольном режимах; +@item +библиотека с большим набором базовых типов графиков. +@end itemize + +@menu +* What is MathGL?:: +* MathGL features:: +* Installation:: +* Quick guide:: +* Changes from v.1:: +* Utilities:: +* Thanks:: +@end menu + +@external{} +@node What is MathGL?, MathGL features, , Overview +@section Что такое MathGL? +@nav{} + +Код для создания качественной научной графики на различных платформах. Код для быстрой обработки и отображения больших массивов данных. Код для работы в графическом и консольном режимах и легкого интегрирования в другие программы. Код с большим обновляемым набором графиков и инструментами обработки данных. Именно такого кода мне не хватало в последние годы при работе на персональных компьютерах и на кластерах. И именно такой код я постарался создать в библиотеке MathGL. + +На данный момент (версия @value{VERSION}) MathGL это более 50 основных типов графиков для одно-, двух- и трехмерных массивов, возможность экспорта в растровые и векторные (EPS или SVG) файлы, интерфейс для OpenGL и возможность запуска в консольном режиме, функции для обработки данных и даже простейший командный (интерпретируемый) язык MGL для упрощения построения графиков. Кроме того, есть несколько типов прозрачности, гладкое освещение, векторные шрифты, TeX-ие команды в надписях, произвольные криволинейные системы координат и прочие полезные мелочи (см. раздел pictures на @uref{http://mathgl.sf.net/, домашней странице}). Ну, и, естественно, полная переносимость библиотеки и ее свободное распространение под лицензией GPL v.2.0 или более поздней. + +@external{} +@node MathGL features, Installation, What is MathGL?, Overview +@section Возможности MathGL +@nav{} + +Библиотека MathGL позволяет строить широкий класс графиков, включая: +@itemize @bullet +@item +рисование одномерных массивов (Plot, Area, Bars, Step, Stem, Torus, Chart, Error, Tube, Mark, @pxref{1D plotting}); + +@item +рисование двумерных массивов (Mesh, Surf, Dens, Cont, ContF, Boxs, Axial, Fall, Belt, Tile, @pxref{2D plotting}); + +@item +рисование трехмерных массивов (Surf3, Dens3, Cont3, ContF3, Cloud-like, @pxref{3D plotting}); + +@item +рисование нескольких связанных массивов: векторные поля Vect, линии тока Flow, точечное отображение Map, поверхности с прозрачностью или цветом, определяемым другим массивом SurfA, SurfC, Surf3A, Surf3C (@pxref{Dual plotting}); + +@item +и другие (см. @pxref{MathGL core}). +@end itemize + +Фактически, я постарался реализовать все известные мне типы научных графиков. Список графиков постоянно пополняется, и если Вам нужен какой-то новый вариант, пишите на @email{mathgl.abalakin@@gmail.com, e-mail}, и в новой версии библиотеки этот график появится. + +Я постарался сделать графики максимально красивыми -- поверхности могут быть прозрачными и освещены произвольно расположенными источниками света (максимальное их количество 10). Большинство функций рисования имеет два варианта: простой для быстрого построения картинки и более сложный для детальной настройки отображения, включающего в том числе возможность параметрического задания всех массивов. Получившееся изображение можно сохранить в растровом формате PNG, JPEG, GIF, TGA или BMP; в векторном EPS, SVG или TeX формате, или в 3D формате OBJ, OFF, STL, или в PRC формате, который может быть конвертирован U3D. + +Все надписи выводятся векторным шрифтом, что обеспечивает их хорошую масштабируемость и переносимость. Текст может содержать команды для большинства ТеХ-их символов, изменения положения (верхний и нижний индексы) и стиля шрифта внутри строки текста (@pxref{Font styles}). Текст меток поворачивается вместе с осями. На график можно вывести описание кривых (легенду) и поместить надпись в произвольную точку экрана или пустить ее вдоль кривой. Поддерживаются произвольные кодировки текста (с помощью стандартной функции @code{setlocale()}) и текст в кодировке UTF-16. + +Для представления данных используется специальный класс mglData (@pxref{Data processing}). Помимо безопасного создания и удаления массивов, он включает функции по их обработке (дифференцированию, интегрированию, сглаживанию, интерполяции и т.д.) и чтению текстового файла с автоматическим определением размеров данных. Класс mglData позволяет работать с массивами размерности вплоть до 3 (массивы, зависящие от трех независимых индексов @math{a_@{ijk@}}). Использование массивов с большим числом размерностей нецелесообразно, поскольку я не представляю, как их можно отобразить на экране. Заполнение или изменение значений массива можно выполнить как вручную, так и по формуле, заданной текстовой строкой. + +Для @emph{быстрого} вычисления значения выражения, заданного текстовой строкой (@pxref{Textual formulas}). Он основан на компиляции строки в древоподобную структуру при создании экземпляра класса. На этапе вычисления происходит быстрый обход дерева с выдачей результата для конкретных значений переменных. Помимо изменения значений массива данных, текстовые формулы используются для рисования в @emph{произвольной} криволинейной системе координат. Набор таких координат ограничивается только фантазией пользователя, а не фиксированным числом (типа полярной, параболической, цилиндрической и т.д.). + +@external{} +@node Installation, Quick guide, MathGL features, Overview +@section Установка MathGL +@nav{} + +Установка библиотеки возможна 4-мя способами. +@enumerate +@item +Скомпилировать библиотеку непосредственно из исходных файлов. С библиотекой поставляется файлы для системы сборки CMake. Для его запуска достаточно в командной строке выполнить 3 команды: сначала @code{cmake .} дважды, далее @code{make} и, наконец, с правами суперпользователя @code{make install}. Иногда после компиляции библиотеки может потребоваться обновление списка библиотека в системе -- выполните команду @code{ldconfig} с правами суперпользователя. + +Есть несколько дополнительных опций, которые по умолчанию отключены. К их числу относятся: @code{enable-fltk, enable-glut, enable-qt} для поддержки FLTK, GLUT и/или Qt окон; @code{enable-jpeg, enable-gif, enable-hdf5} для поддержки соответствующих форматов; @code{enable-all} для включения всех возможностей. Для использования типа @code{double} для внутреннего хранения данных используйте опцию @code{enable-double}. Для создания интерфейсов к другим языкам (кроме С/Фортран/MGL) используйте опции @code{enable-python, enable-octave} или @code{enable-all-swig} для всех поддерживаемых языков. Вы можете воспользоваться WYSIWYG утилитой (@code{cmake-gui}) для просмотра и изменения всех опций, или выполнить @code{cmake -D enable-all=on -D enable-all-widgets=on -D enable-all-swig=on .} в командной строке для включения всех опций. + +При сборке с помощью MinGW необходимо дополнительно установить опцию сборки @code{-fopenmp} (т.е. @code{CMAKE_EXE_LINKER_FLAGS:STRING='-fopenmp'} и @code{CMAKE_SHARED_LINKER_FLAGS:STRING='-fopenmp'}) если включена поддержка OpenMP (@code{enable-openmp=ON}). + + +@item +Использовать предварительно скомпилированные файлы -- с библиотекой поставляются файлы для MinGW (платформа Win32). В скомпилированной версии достаточно распаковать заголовочные файлы в папку с заголовочными файлами и библиотеку libmgl.a в папку с библиотеками. По умолчанию, скомпилированная версия включают поддержку GSL (www.gsl.org), PNG, GIF и JPEG. Соответственно, при сборке программы эти библиотеки должны быть установлены (их можно найти на @uref{http://gnuwin32.sourceforge.net/packages.html}). +@item +Установить из стандартных пакетов (RPM, deb, DevPak и пр.). +@end enumerate + +Последнюю версию (которая может быть не стабильна) можно загрузить с sourceforge.net SVN с помощью команды +@verbatim +svn checkout http://svn.code.sf.net/p/mathgl/code/mathgl-2x mathgl-code +@end verbatim + +@c TODO Translate it! + +@c ------------------------------------------------------------------ +@external{} +@node Quick guide, Changes from v.1, Installation, Overview +@section Quick guide +@nav{} + +There are 3 steps to prepare the plot in MathGL: (1) prepare data to be plotted, (2) setup plot, (3) plot data. Let me show this on the example of surface plotting. + +First we need the data. MathGL use its own class @code{mglData} to handle data arrays (see @ref{Data processing}). This class give ability to handle data arrays by more or less format independent way. So, create it +@verbatim + int main() + { + mglData dat(30,40); // data to for plotting + for(long i=0;i<30;i++) for(long j=0;j<40;j++) + dat.a[i+30*j] = 1/(1+(i-15)*(i-15)/225.+(j-20)*(j-20)/400.); +@end verbatim +Here I create matrix 30*40 and initialize it by formula. Note, that I use @code{long} type for indexes @var{i}, @var{j} because data arrays can be really large and @code{long} type will automatically provide proper indexing. + +Next step is setup of the plot. The only setup I need is axis rotation and lighting. +@verbatim + mglGraph gr; // class for plot drawing + gr.Rotate(50,60); // rotate axis + gr.Light(true); // enable lighting +@end verbatim + +Everything is ready. And surface can be plotted. +@verbatim + gr.Surf(dat); // plot surface +@end verbatim +Basically plot is done. But I decide to add yellow (@samp{y} color, see @ref{Color styles}) contour lines on the surface. To do it I can just add: +@verbatim + gr.Cont(dat,"y"); // plot yellow contour lines +@end verbatim +This demonstrate one of base MathGL concept (see, @ref{General concepts}) -- ``new drawing never clears things drawn already''. So, you can just consequently call different plotting functions to obtain ``combined'' plot. For example, if one need to draw axis then he can just call one more plotting function +@verbatim + gr.Axis(); // draw axis +@end verbatim + +Now picture is ready and we can save it in a file. +@verbatim + gr.WriteFrame("sample.png"); // save it + } +@end verbatim + +To compile your program, you need to specify the linker option @code{-lmgl}. + +This is enough for a compilation of console program or with external (non-MathGL) window library. If you want to use FLTK or Qt windows provided by MathGL then you need to add the option @code{-lmgl-wnd}. + +При использовании фортрана необходимо также включить библиотеку @code{-lstdc++}. Кроме того, если библиотека была собрана с опцией @code{enable-double=ON} (по умолчанию в версии 2.1 и более поздних), то все вещественные числа должны быть типа real*8. Это можно включить по умолчанию опцией @code{-fdefault-real-8}. + +@c ------------------------------------------------------------------ +@external{} +@node Changes from v.1, Utilities, Quick guide, Overview +@section Changes from v.1.* +@nav{} + +There are a lot of changes for v.2. Here I denote only main of them. +@itemize @bullet +@item +mglGraph class is single plotter class instead of mglGraphZB, mglGraphPS and so on. +@item +Text style and text color positions are swapped. I.e. text style @samp{r:C} give red centered text, but not roman dark cyan text as for v.1.*. +@item +ColumnPlot() indexing is reverted. +@item +Move most of arguments of plotting functions into the string parameter and/or options. +@item +``Bright'' colors (like @{b8@}) can be used in color schemes and line styles. +@item +Intensively use pthread internally for parallelization of drawing and data processing. +@item +Add tick labels rotation and skipping. Add ticks in time/date format. +@item +New kinds of plots (Tape(), Label(), Cones(), ContV()). Extend existing plots. New primitives (Circle(), Ellipse(), Rhomb(), ...). New plot positioning (MultiPlot(), GridPlot()) +@item +Improve MGL scripts. Add 'ask' command and allow string concatenation from different lines. +@item +Export to LaTeX and to 3D formats (OBJ, OFF, STL). +@item +Add pipes support in utilities (@code{mglconv, mglview}). +@end itemize + +@c ------------------------------------------------------------------ +@external{} +@node Utilities, Thanks, Changes from v.1, Overview +@section Utilities for parsing MGL +@nav{} + +MathGL library provides several tools for parsing MGL scripts. There is tools saving it to bitmap or vectorial images (@code{mglconv}). Tool @code{mglview} show MGL script and allow to rotate and setup the image. Another feature of @code{mglview} is loading *.mgld files (see @code{ExportMGLD()}) for quick viewing 3d pictures. + +Both tools have similar set of arguments. They can be name of script file or options. You can use @samp{-} as script name for using standard input (i.e. pipes). Options are: +@itemize +@item @strong{-1} @var{str} +set @var{str} as argument $1 for script; +@item ... +... +@item @strong{-9} @var{str} +set @var{str} as argument $9 for script; +@item @strong{-A} @var{val} +add @var{val} into the list of animation parameters; +@item @strong{-C} @var{v1}:@var{v2}[:@var{dv}] +add values from @var{v1} ot @var{v2} with step @var{dv} (default is 1) into the list of animation parameters; +@item @strong{-L} @var{loc} +set locale to @var{loc}; +@item @strong{-o} @var{name} +set output file name; +@item @strong{-h} +print help message. +@end itemize + +Additionally you can create animated GIF file or a set of JPEG files with names @samp{frameNNNN.jpg} (here @samp{NNNN} is frame index). Values of the parameter @code{$0} for making animation can be specified inside the script by comment @code{##a val} for each value @code{val} (one comment for one value) or by option(s) @samp{-A val}. Also you can specify a cycle for animation by comment @code{##c v1 v2 dv} or by option @code{-C v1:v2:dv}. In the case of found/specified animation parameters, tool will execute script several times -- once for each value of @code{$0}. + + +MathGL also provide another simple tool @code{mgl.cgi} which parse MGL script from CGI request and send back produced PNG file. Usually this program should be placed in @code{/usr/lib/cgi-bin/}. But you need to put this program by yourself due to possible security issues and difference of Apache server settings. + +@c ------------------------------------------------------------------ +@external{} +@node Thanks, , Utilities, Overview +@section Благодарности +@nav{} + + +@itemize @bullet +@item +Моя специальная благодарность моей жене за терпение во время написания библиотеки. +@item +Я благодарен моим соавторам Д. Кулагину и М. Видассову за помощь в разработке MathGL. +@item +Я благодарен D. Eftaxiopoulos, В. Липатову и С. Плису за создание бинарных пакетов для Linux. +@item +Я благодарен С. Скобелеву, К. Михайленко, М. Вейсману, A. Прохорову, A. Короткевичу, В. Онучину, С. Плису, Р. Киселеву, A. Иванову, Н. Троицкому and В. Липатову за продуктивные предложения и обсуждения. +@item +Я благодарен спонсорам М. Вейсману (@url{http://www.jiht.ru/about/structure.php?set_filter_structure=Y&structure_UF_DEPARTMENT=241&filter=Y&set_filter=Y, ОИВТ РАН}) и A. Прохорову (@url{www.datadvance.net, DATADVANCE}). +@end itemize + +Javascript интерфейс был разработан при поддержке компании @url{www.datadvance.net, DATADVANCE}. + + +@external{} diff --git a/texinfo/parse_en.texi b/texinfo/parse_en.texi new file mode 100644 index 0000000..21b0e7b --- /dev/null +++ b/texinfo/parse_en.texi @@ -0,0 +1,319 @@ + +@c ------------------------------------------------------------------ +@chapter MGL scripts +@nav{} + +MathGL library supports the simplest scripts for data handling and plotting. These scripts can be used independently (with the help of UDAV, mglconv, mglview programs and others +@ifclear UDAV +, @pxref{Utilities}) or in the frame of the library using. +@end ifclear + +@menu +* MGL definition:: +* Program flow commands:: +@ifclear UDAV +* mglParse class:: +@end ifclear +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node MGL definition, Program flow commands, , MGL scripts +@section MGL definition +@nav{} + +MGL script language is rather simple. Each string is a command. First word of string is the name of command. Other words are command arguments. Command may have up to 1000 arguments (at least for now). Words are separated from each other by space or tabulation symbol. The upper or lower case of words is important, i.e. variables @var{a} and @var{A} are different variables. Symbol @samp{#} starts the comment (all characters after # will be ignored). The exception is situation when @samp{#} is a part of some string. Also options can be specified after symbol @samp{;} (@pxref{Command options}). Symbol @samp{:} starts new command (like new line character) if it is not placed inside a string or inside brackets. + +If string contain references to external parameters (substrings @samp{$0}, @samp{$1} ... @samp{$9}) or definitions (substrings @samp{$a}, @samp{$b} ... @samp{$z}) then before execution the values of parameter/definition will be substituted instead of reference. It allows to use the same MGL script for different parameters (filenames, paths, condition and so on). + +Argument can be a string, a variable (data arrays) or a number (scalars). +@itemize @bullet +@item +The string is any symbols between ordinary marks @samp{'}. Long strings can be concatenated from several lines by @samp{\} symbol. I.e. the string @samp{'a +'\
' b'} will give string @samp{'a + b'} (here @samp{
} is newline). Also you can concatenate strings and numbers using @samp{,} with out spaces (for example, @samp{'max(u)=',u.max,' a.u.'}). + +@item +Usually variable have a name which is arbitrary combination of symbols (except spaces and @samp{'}) started from a letter and with length less than 64. A temporary array can be used as variable: +@itemize @bullet +@item +sub-arrays (like in @ref{subdata} command) as command argument. For example, @code{a(1)} or @code{a(1,:)} or @code{a(1,:,:)} is second row, @code{a(:,2)} or @code{a(:,2,:)} is third column, @code{a(:,:,0)} is first slice and so on. Also you can extract a part of array from m-th to n-th element by code @code{a(m:n,:,:)} or just @code{a(m:n)}. + +@item +any column combinations defined by formulas, like @code{a('n*w^2/exp(t)')} if names for data columns was specified (by @ref{idset} command or in the file at string started with @code{##}). + +@item +any expression (without spaces) of existed variables produce temporary variable. For example, @samp{sqrt(dat(:,5)+1)} will produce temporary variable with data values equal to @code{tmp[i,j] = sqrt(dat[i,5,j]+1)}. + +@item +temporary variable of higher dimensions by help of []. For example, @samp{[1,2,3]} will produce a temporary vector of 3 elements @{1, 2, 3@}; @samp{[[11,12],[21,22]]} will produce matrix 2*2 and so on. Here you can join even an arrays of the same dimensions by construction like @samp{[v1,v2,...,vn]}. + +@item +result of code for making new data (@pxref{Make another data}) inside @{@}. For example, @samp{@{sum dat 'x'@}} produce temporary variable which contain result of summation of @var{dat} along direction 'x'. This is the same array @var{tmp} as produced by command @samp{sum tmp dat 'x'}. You can use nested constructions, like @samp{@{sum @{max dat 'z'@} 'x'@}}. +@end itemize +Temporary variables can not be used as 1st argument for commands which create (return) the data (like @samp{new}, @samp{read}, @samp{hist} and so on). + +@item +Special names @code{nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1} are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers (@pxref{Data information}). Names defined by @ref{define} command are treated as number. Also results of formulas with sizes 1x1x1 are treated as number (for example, @samp{pi/dat.nx}). +@end itemize +Before the first using all variables must be defined with the help of commands, like, @ref{new}, @ref{var}, @ref{list}, @ref{copy}, @ref{read}, @ref{hist}, @ref{sum} and so on (see sections @ref{Data constructor}, @ref{Data filling} and @ref{Make another data}). + +Command may have several set of possible arguments (for example, @code{plot ydat} and @code{plot xdat ydat}). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like @code{text ydat ['stl'='']} or @code{text x y 'txt' ['fnt'='' size=-1]}. At this, the record @code{[arg1 arg2 arg3 ...]} means @code{[arg1 [arg2 [arg3 ...]]]}, i.e. you can omit only tailing arguments if you agree with its default values. For example, @code{text x y 'txt' '' 1} or @code{text x y 'txt' ''} is correct, but @code{text x y 'txt' 1} is incorrect (argument @code{'fnt'} is missed). + + +@c ------------------------------------------------------------------ +@external{} +@ifclear UDAV +@node Program flow commands, mglParse class, MGL definition, MGL scripts +@end ifclear +@ifset UDAV +@node Program flow commands, , MGL definition, MGL scripts +@end ifset +@section Program flow commands +@nav{} + +Below I show commands to control program flow, like, conditions, loops, define script arguments and so on. Other commands can be found in chapters @ref{MathGL core} and @ref{Data processing}. Note, that some of program flow commands (like @ref{define}, @ref{ask}, @ref{call}, @ref{for}, @ref{func}) should be placed alone in the string. + +@cindex chdir +@anchor{chdir} +@deftypefn {MGL command} {} chdir 'path' +Changes the current directory to @var{path}. +@end deftypefn + +@cindex ask +@anchor{ask} +@deftypefn {MGL command} {} ask $N 'question' +Sets @var{N}-th script argument to answer which give the user on the @var{question}. Usually this show dialog with question where user can enter some text as answer. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn + +@cindex define +@anchor{define} +@deftypefn {MGL command} {} define $N smth +Sets @var{N}-th script argument to @var{smth}. Note, that @var{smth} is used as is (with @samp{'} symbols if present). Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn +@deftypefn {MGL command} {} define name smth +Create scalar variable @code{name} which have the numeric value of @code{smth}. Later you can use this variable as usual number. +@end deftypefn +@cindex defchr +@anchor{defchr} +@deftypefn {MGL command} {} defchr $N smth +Sets @var{N}-th script argument to character with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn +@cindex defnum +@anchor{defnum} +@deftypefn {MGL command} {} defnum $N smth +Sets @var{N}-th script argument to number with value evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn +@cindex defpal +@anchor{defpal} +@deftypefn {MGL command} {} defpal $N smth +Sets @var{N}-th script argument to palette character at position evaluated from @var{smth}. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn + +@cindex call +@anchor{call} +@deftypefn {MGL command} {} call 'fname' [ARG1 ARG2 ... ARG9] +Executes function @var{fname} (or script if function is not found). Optional arguments will be passed to functions. See also @ref{func}. +@end deftypefn +@cindex func +@anchor{func} +@deftypefn {MGL command} {} func 'fname' [narg=0] +Define the function @var{fname} and number of required arguments. The arguments will be placed in script parameters $1, $2, ... $9. Note, you should stop script execution before function definition(s) by command @ref{stop}. See also @ref{return}. +@end deftypefn +@cindex return +@anchor{return} +@deftypefn {MGL command} {} return +Return from the function. See also @ref{func}. +@end deftypefn + + +@cindex if +@anchor{if} +@deftypefn {MGL command} {} if dat 'cond' +Starts block which will be executed if @var{dat} satisfy to @var{cond}. +@end deftypefn +@deftypefn {MGL command} {} if @code{val} +Starts block which will be executed if @code{val} is nonzero. +@end deftypefn +@cindex elseif +@anchor{elseif} +@deftypefn {MGL command} {} elseif dat 'cond' +Starts block which will be executed if previous @code{if} or @code{elseif} is false and @var{dat} satisfy to @var{cond}. +@end deftypefn +@deftypefn {MGL command} {} elseif @code{val} +Starts block which will be executed if previous @code{if} or @code{elseif} is false and @code{val} is nonzero. +@end deftypefn +@cindex else +@anchor{else} +@deftypefn {MGL command} {} else +Starts block which will be executed if previous @code{if} or @code{elseif} is false. +@end deftypefn +@cindex endif +@anchor{endif} +@deftypefn {MGL command} {} endif +Finishes @code{if/elseif/else} block. +@end deftypefn + +@cindex for +@anchor{for} +@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]} +Starts cycle with $@var{N}-th argument changing from @var{v1} to @var{v2} with the step @var{dv}. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn +@deftypefn {MGL command} {} for $N dat +Starts cycle with $@var{N}-th argument changing for @var{dat} values. Here @var{N} is digit (0...9) or alpha (a...z). +@end deftypefn +@cindex next +@anchor{next} +@deftypefn {MGL command} {} next +Finishes @code{for} cycle. +@end deftypefn + +@cindex once +@anchor{once} +@deftypefn {MGL command} {} once @code{val} +The code between @code{once on} and @code{once off} will be executed only once. Useful for large data manipulation in programs like UDAV. +@end deftypefn +@cindex stop +@anchor{stop} +@deftypefn {MGL command} {} stop +Terminate execution. +@end deftypefn + +@ifclear UDAV +@c ------------------------------------------------------------------ +@external{} +@node mglParse class, , Program flow commands, MGL scripts +@section mglParse class +@nav{} +@cindex mglParse + +Class for parsing and executing MGL script. This class is defined in @code{#include }. + +The main function of mglParse class is @code{Execute()}. Exactly this function parses and executes the script string-by-string. Also there are subservient functions for the finding and creation of a variable (object derived from @code{mglData} class, see @ref{MGL variables}). These functions can be useful for displaying values of variables (arrays) in some external object (like, window) or for providing access to internal data. Function @code{AllowSetSize()} allows one to prevent changing the size of the picture inside the script (forbids the MGL command @code{setsize}). + +@c Note an important feature -- if user defines function @var{func} in variable then it will be called before the destroying of this variable (@pxref{mglVar class}). + +@deftypefn {Constructor on @code{mglParse}} @code{} mglParse (@code{bool} setsize=@code{false}) +@deftypefnx {Constructor on @code{mglParse}} @code{} mglParse (@code{HMPR} pr) +@deftypefnx {Constructor on @code{mglParse}} @code{} mglParse (@code{mglParse &}pr) +@deftypefnx {C function} @code{HMPR} mgl_create_parser () +Constructor initializes all values with zero and set @var{AllowSetSize} value. +@end deftypefn + +@deftypefn {Destructor on @code{mglParse}} @code{} ~mglParse () +@deftypefnx {C function} @code{void} mgl_delete_parser (@code{HMPR} p) +Destructor delete parser +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{HMPR} Self () +Returns the pointer to internal object of type @code{HMPR}. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const char *}text) +@deftypefnx{Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const wchar_t *}text) +@deftypefnx {C function} @code{void} mgl_parse_text (@code{HMGL} gr, @code{HMPR} p, @code{const char *}text) +@deftypefnx {C function} @code{void} mgl_parse_textw (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}text) +Main function in the class. Function parse and execute line-by-line MGL script in array @var{text}. Lines are separated by newline symbol @samp{\n} as usual. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{FILE *}fp, @code{bool} print=@code{false}) +@deftypefnx {C function} @code{void} mgl_parse_file (@code{HMGL} gr, @code{HMPR} p, @code{FILE *}fp, @code{int} print) +The same as previous but read script from the file @var{fp}. If @var{print}=@code{true} then all warnings and information will be printed in stdout. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const char *}str, @code{long} pos=@code{0}) +@deftypefnx {Method on @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const wchar_t *}str, @code{long} pos=@code{0}) +@deftypefnx {C function} @code{int} mgl_parse_line (@code{HMGL} gr, @code{HMPR} p, @code{const char *}str, @code{int} pos) +@deftypefnx {C function} @code{int} mgl_parse_linew (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}str, @code{int} pos) +Function parses the string @var{str} and executes it by using @var{gr} as a graphics plotter. Returns the value depending on an error presence in the string @var{str}: 0 -- no error, 1 -- wrong command argument(s), 2 -- unknown command, 3 -- string is too long. Optional argument @var{pos} allows to save the string position in the document (or file) for using @code{for|next} command. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{mglData} Calc (@code{const char *}formula) +@deftypefnx {Method on @code{mglParse}} @code{mglData} Calc (@code{const wchar_t *}formula) +@deftypefnx {C function} @code{HMDT} mgl_parser_calc (@code{HMPR} p, @code{const char *}formula) +@deftypefnx {C function} @code{HMDT} mgl_parser_calcw (@code{HMPR} p, @code{const wchar_t *}formula) +Function parses the string @var{formula} and return resulting data array. In difference to @code{AddVar()} or @code{FindVar()}, it is usual data array which should be deleted after usage. +@end deftypefn + + +@deftypefn {Method on @code{mglParse}} @code{void} AddParam (@code{int} n, @code{const char *}str) +@deftypefnx {Method on @code{mglParse}} @code{void} AddParam (@code{int} n, @code{const wchar_t *}str) +@deftypefnx {C function} @code{void} mgl_parser_add_param (@code{HMPR} p, @code{int} id, @code{const char *}val) +@deftypefnx {C function} @code{void} mgl_parser_add_paramw (@code{HMPR} p, @code{int} id, @code{const wchar_t *}val) +Function set the value of @var{n}-th parameter as string @var{str} (@var{n}=0, 1 ... 'z'-'a'+10). String @var{str} shouldn't contain @samp{$} symbol. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{mglVar *} FindVar (@code{const char *}name) +@deftypefnx {Method on @code{mglParse}} @code{mglVar *} FindVar (@code{const wchar_t *}name) +@deftypefnx {C function} @code{HMDT} mgl_parser_find_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {C function} @code{HMDT} mgl_parser_find_varw (@code{HMPR} p, @code{const wchar_t *}name) +Function returns the pointer to variable with name @var{name} or zero if variable is absent. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays! +@end deftypefn +@deftypefn {Method on @code{mglParse}} @code{mglVar *} AddVar (@code{const char *}name) +@deftypefnx {Method on @code{mglParse}} @code{mglVar *} AddVar (@code{const wchar_t *}name) +@deftypefnx {C function} @code{HMDT} mgl_parser_add_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {C function} @code{HMDT} mgl_parser_add_varw (@code{HMPR} p, @code{const wchar_t *}name) +Function returns the pointer to variable with name @var{name}. If variable is absent then new variable is created with name @var{name}. Use this function to put external data array to the script or get the data from the script. You must @strong{not delete} obtained data arrays! +@end deftypefn + +@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteVar (@code{const char *}name) +@deftypefnx{Method on @code{mglParse} (C++)} @code{void} DeleteVar (@code{const wchar_t *}name) +@deftypefnx {C function} @code{void} mgl_parser_del_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {C function} @code{void} mgl_parser_del_varw (@code{HMPR} p, @code{const wchar_t *}name) +Function delete the variable with given @var{name}. +@end deftypefn + +@deftypefn{Method on @code{mglParse} (C++)} @code{void} DeleteAll () +@deftypefnx {C function} @code{void} mgl_parser_del_all (@code{HMPR} p) +Function delete all variables in this parser. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} RestoreOnce () +@deftypefnx {C function} @code{void} mgl_parser_restore_once (@code{HMPR} p) +Restore Once flag. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} AllowSetSize (@code{bool} a) +@deftypefnx {C function} @code{void} mgl_parser_allow_setsize (@code{HMPR} p, @code{int} a) +Allow to parse 'setsize' command or not. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} AllowFileIO (@code{bool} a) +@deftypefnx {C function} @code{void} mgl_parser_allow_file_io (@code{HMPR} p, @code{int} a) +Allow reading/saving files or not. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{void} Stop () +@deftypefnx {C function} @code{void} mgl_parser_stop (@code{HMPR} p) +Sends stop signal which terminate execution at next command. +@end deftypefn + + +@deftypefn {Method on @code{mglParse}} @code{long} GetCmdNum () +@deftypefnx {C function} @code{long} mgl_parser_cmd_num (@code{HMPR} p) +Return the number of registered MGL commands. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{const char *} GetCmdName (@code{long} id) +@deftypefnx {C function} @code{const char *} mgl_parser_cmd_name (@code{HMPR} p, @code{long} id) +Return the name of command with given @var{id}. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{int} CmdType (@code{const char *}name) +@deftypefnx {C function} @code{int} mgl_parser_cmd_type (@code{HMPR} p, @code{const char *}name) +Return the type of MGL command @var{name}. Type of commands are: 0 -- not the command, 1 - data plot, 2 - other plot, 3 - setup, 4 - data handle, 5 - data create, 6 - subplot, 7 - program, 8 - 1d plot, 9 - 2d plot, 10 - 3d plot, 11 - dd plot, 12 - vector plot, 13 - axis, 14 - primitives, 15 - axis setup, 16 - text/legend, 17 - data transform. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{const char *} CmdFormat (@code{const char *}name) +@deftypefnx {C function} @code{const char *} mgl_parser_cmd_frmt (@code{HMPR} p, @code{const char *}name) +Return the format of arguments for MGL command @var{name}. +@end deftypefn + +@deftypefn {Method on @code{mglParse}} @code{const char *} CmdDesc (@code{const char *}name) +@deftypefnx {C function} @code{const char *} mgl_parser_cmd_desc (@code{HMPR} p, @code{const char *}name) +Return the description of MGL command @var{name}. +@end deftypefn + +@end ifclear + +@external{} + diff --git a/texinfo/parse_ru.texi b/texinfo/parse_ru.texi new file mode 100644 index 0000000..52769c9 --- /dev/null +++ b/texinfo/parse_ru.texi @@ -0,0 +1,322 @@ + +@c ------------------------------------------------------------------ +@chapter Скрипты MGL +@nav{} + +MathGL имеет встроенный скриптовый язык MGL для обработки и отображения данных. Скрипты MGL могут быть выполнены независимо (с помощью программ UDAV, mglconv, mglview и др. +@ifclear UDAV +, см. @ref{Utilities}) или с использованием вызовов библиотеки. +@end ifclear + +@menu +* MGL definition:: +* Program flow commands:: +@ifclear UDAV +* mglParse class:: +@end ifclear +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node MGL definition, Program flow commands, , MGL scripts +@section Основы MGL +@nav{} + +Язык MGL достаточно простой. Каждая строка -- отдельная команда. Первое слово -- имя команды, а все остальные ее аргументы. Команда может иметь до 1000 аргументов (по крайней мере сейчас). Слова разделяются одно от другого пробелом или символом табуляции. Различий между верхним и нижним индексом нет, т.е. переменные @var{a} и @var{A} идентичны. Символ @samp{#} начинает комментарий -- все символы после него игнорируются до конца строки. Исключением является случай, когда @samp{#} входит в строку. Опции команды указываются после символа @samp{;} (@pxref{Command options}). Символ @samp{:} начинает новую команду (подобно переводу строки) если он расположен не внутри скобок или строки. + +Если строка содержит ссылки на внешние параметры (@samp{$0}, @samp{$1} ... @samp{$9}) или макроопределения (@samp{$a}, @samp{$b} ... @samp{$z}), то текущие значения параметров/макроопределений подставляются в строку вместо ссылки до выполнением команды. Это позволяет использовать один и тот же скрипт при различных входных параметрах командной строки или вводить макроопределения по ходу исполнения команд скрипта. + +Аргументы команды могут быть строками, переменными или числами. +@itemize @bullet +@item +Строка -- произвольный набор символов между метками @samp{'}. Длинные строки могут быть соединены из нескольких линий файла символом @samp{\}. Т.е. строки файла @samp{'a +'\
' b'} дадут строку @samp{'a + b'} (здесь @samp{
} -- перевод строки). Также можно использовать соединение строк и чисел, используя символ @samp{,} без пробелов (например, @samp{'max(u)=',u.max,' a.u.'}). + +@item +Обычно переменная имеет имя, состоящее из букв и чисел (должно начинаться с буквы и не быть длиннее 64 символов). В качестве переменной можно использовать временные массивы, включающие в себя: +@itemize @bullet +@item +срезы (``подмассивы'') массивов данных (подобно команде @ref{subdata}). Например, @code{a(1)} или @code{a(1,:)} или @code{a(1,:,:)} -- вторая строка массива @var{a}, @code{a(:,2)} или @code{a(:,2,:)} -- третий столбец, @code{a(:,:,0)} -- первый срез и т.д. Также можно выделить часть массива с m-го по n-ый элемент @code{a(m:n,:,:)} или просто @code{a(m:n)}. + +@item +произвольные комбинации столбцов данных (например, @code{a('n*w^2/exp(t)')}), если столбцы данных были именованы командой @ref{idset} или в файле данных (в строке начинающейся с @code{##}). + +@item +произвольное выражение из существующих переменных и констант. Например, @samp{sqrt(dat(:,5)+1)} даст временный массив данных с элементами равными @code{tmp[i,j] = sqrt(dat[i,5,j]+1)}. + +@item +массивы с элементами заданными в квадратных скобках [], разделенные @samp{,}. При этом внутри выражения не должно быть пробелов! Например, @samp{[1,2,3]} даст временный массив из 3 элементов @{1, 2, 3@}; @samp{[[11,12],[21,22]]} даст матрицу 2*2 и т.д. Элементами такой конструкции могут быть и массивы если их размерности одинаковые, например @samp{[v1,v2,...,vn]}. + +@item +результат команд построения новых данных (@pxref{Make another data}), если они заключены в фигурные скобки @{@}. Например, @samp{@{sum dat 'x'@}} даст временный массив, который есть результат суммирования @var{dat} вдоль 'x'. Это такой же массив как и @var{tmp}, полученный командой @samp{sum tmp dat 'x'}. При этом можно использовать вложенные конструкции, например @samp{@{sum @{max dat 'z'@} 'x'@}}. +@end itemize +Временные массивы не могут стоять в качестве первого аргумента команд, создающих массивы (например, @samp{new}, @samp{read}, @samp{hist} и т.д.). + +@item +К скалярным переменным, кроме собственно чисел, относятся: специальные переменные @code{nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1}, переменные с суффиксами (@pxref{Data information}), переменные определенные командой @ref{define}. Также массивы размером 1x1x1 считаются скалярами (например, @samp{pi/dat.nx}). +@end itemize +Перед первым использованием все переменные должны быть определены с помощью команд, создающих массивы (@ref{new}, @ref{var}, @ref{list}, @ref{copy}, @ref{read}, @ref{hist}, @ref{sum} и др., см. @ref{Data constructor}, @ref{Data filling} и @ref{Make another data}). + +Команды могут иметь несколько наборов аргументов (например, @code{plot ydat} и @code{plot xdat ydat}). Все аргументы команды для выбранного набора должны быть указаны, однако часть из них могут иметь значения по умолчанию. Такие аргументы в описании команд будут помещены в квадратные скобки [], например @code{plot ydat ['stl'='' zval=nan]}. При этом запись @code{[arg1 arg2 arg3 ...]} подразумевает @code{[arg1 [arg2 [arg3 ...]]]}, т.е. опускать можно только аргументы с конца, если вы согласны с их значениями по умолчанию. Например, @code{plot ydat '' 1} или @code{plot ydat ''} правильно, а @code{plot ydat 1} не правильно (аргумент @code{'stl'} пропущен). + + + +@c TODO Translate it! + +@c ------------------------------------------------------------------ +@external{} +@ifclear UDAV +@node Program flow commands, mglParse class, MGL definition, MGL scripts +@end ifclear +@ifset UDAV +@node Program flow commands, , MGL definition, MGL scripts +@end ifset +@section Управление ходом выполнения +@nav{} + +Ниже собраны команды, управляющие порядком выполнения других команд (условия, циклы, подпрограммы), (пере-)определяют аргументы скрипта и пр. Прочие команды могут быть найдены в главах @ref{MathGL core} и @ref{Data processing}. Отмечу, что некоторые из команд (например, @ref{define}, @ref{ask}, @ref{call}, @ref{for}, @ref{func}) должны быть расположены на отдельной строке. + +@cindex chdir +@anchor{chdir} +@deftypefn {MGL command} {} chdir 'path' +Переходит в папку @var{path}. +@end deftypefn + +@cindex ask +@anchor{ask} +@deftypefn {MGL command} {} ask $N 'question' +Задает @var{N}-ый аргумент скрипта равным ответу пользователя на вопрос @var{question}. Обычно команда показывает диалог с вопросом и полем ввода текста ответа. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn + +@cindex define +@anchor{define} +@deftypefn {MGL command} {} define $N smth +Задает @var{N}-ый аргумент скрипта равным @var{smth}. Отмечу, что @var{smth} используется как есть (с символами @samp{'} если присутствуют). Выполняется только подстановка других макроопределений $0...$9, $a...$z. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn +@deftypefn {MGL command} {} define name smth +Определяет константу (скаляр) с именем @code{name} и числовым значением @code{smth}. Позднее она может быть использована как обычное число. +@end deftypefn +@cindex defchr +@anchor{defchr} +@deftypefn {MGL command} {} defchr $N smth +Задает @var{N}-ый аргумент скрипта равным символу с UTF кодом @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn +@cindex defnum +@anchor{defnum} +@deftypefn {MGL command} {} defnum $N smth +Задает @var{N}-ый аргумент скрипта равным числовому значению @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn +@cindex defpal +@anchor{defpal} +@deftypefn {MGL command} {} defpal $N smth +Задает @var{N}-ый аргумент скрипта равным символу палитры с индексом, найденным из @var{smth}. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn + +@cindex call +@anchor{call} +@deftypefn {MGL command} {} call 'fname' [ARG1 ARG2 ... ARG9] +Переходит к выполнению (вызывает) подпрограммы @var{fname} (или внешнего скрипта, если функция не была найдена). Опциональные аргументы передаются в подпрограмму. См. также @ref{func}. +@end deftypefn +@cindex func +@anchor{func} +@deftypefn {MGL command} {} func 'fname' [narg=0] +Определяет подпрограмму с именем @var{fname} и задает число требуемых аргументов. Аргументы будут помещены в параметры скрипта $1, $2, ... $9. Отмечу, что выполнение основной программы должно быть остановлено до начала определений подпрограмм. См. также @ref{stop}, @ref{return}. + +@end deftypefn +@cindex return +@anchor{return} +@deftypefn {MGL command} {} return +Возвращается из подпрограммы. См. также @ref{func}. +@end deftypefn + + +@cindex if +@anchor{if} +@deftypefn {MGL command} {} if dat 'cond' +Начинает блок команд, выполняемый если каждый элемент @var{dat} удовлетворяет условию @var{cond}. +@end deftypefn +@deftypefn {MGL command} {} if @code{val} +Начинает блок команд, выполняемый если @code{val} не ноль. +@end deftypefn +@cindex elseif +@anchor{elseif} +@deftypefn {MGL command} {} elseif dat 'cond' +Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и каждый элемент @var{dat} удовлетворяет условию @var{cond}. +@end deftypefn +@deftypefn {MGL command} {} elseif @code{val} +Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен и @code{val} не ноль. +@end deftypefn +@cindex else +@anchor{else} +@deftypefn {Команда MGL} {} else +Начинает блок команд, выполняемый если предыдущий @code{if} или @code{elseif} не был выполнен. +@end deftypefn +@cindex endif +@anchor{endif} +@deftypefn {Команда MGL} {} endif +Заканчивает определение блока @code{if/elseif/else}. +@end deftypefn + +@cindex for +@anchor{for} +@deftypefn {MGL command} {} for $N @code{v1 v2 [dv=1]} +Начинает блок команд, выполняемый в цикле с $@var{N}-ым аргументом изменяющимся от @var{v1} до @var{v2} с шагом @var{dv}. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn +@deftypefn {Команда MGL} {} for $N dat +Начинает блок команд, выполняемый в цикле с $@var{N}-ым аргументом пробегающим значения массива @var{dat}. Здесь @var{N} это цифра (0...9) или буква (a...z). +@end deftypefn +@cindex next +@anchor{next} +@deftypefn {Команда MGL} {} next +Заканчивает блок цикла @code{for}. +@end deftypefn + +@cindex once +@anchor{once} +@deftypefn {MGL command} {} once @code{val} +Определяет код (между @code{once on} и @code{once off}) который будет выполнен только один раз. Полезно для работы с большими данными в программах типа UDAV. +@end deftypefn +@cindex stop +@anchor{stop} +@deftypefn {MGL command} {} stop +Останавливает выполнение скрипта. +@end deftypefn + +@ifclear UDAV +@c ------------------------------------------------------------------ +@external{} +@node mglParse class, , Program flow commands, MGL scripts +@section mglParse class +@nav{} +@cindex mglParse + +Класс разбирает и выполняет скрипты MGL. Он определен в @code{#include }. + +Основная функция класса mglParse -- @code{Execute()}, выполняющая построчный разбор скрипта. Также есть вспомогательные функции для поиска и создания переменных MGL (объектов, производных от @code{mglData}, см. @ref{MGL variables}). Эти функции полезны для отображения значений массивов во внешних объектах (например, в отдельном окне) или для предоставления доступа к внутренним массивам. Функция @code{AllowSetSize()} позволяет запретить изменение размера картинки (запрещает команду @code{setsize}). Функция @code{AllowFileIO()} позволяет запретить доступ к файлам на диске. + +@c Note an important feature -- if user defines function @var{func} in variable then it will be called before the destroying of this variable (@pxref{mglVar class}). + +@deftypefn {Конструктор класса @code{mglParse}} @code{} mglParse (@code{bool} setsize=@code{false}) +@deftypefnx {Конструктор класса @code{mglParse}} @code{} mglParse (@code{HMPR} pr) +@deftypefnx {Конструктор класса @code{mglParse}} @code{} mglParse (@code{mglParse &}pr) +@deftypefnx {Функция С} @code{HMPR} mgl_create_parser () +Создает экземпляр класса @code{mglParse} и устанавливает значение @var{AllowSetSize}. +@end deftypefn + +@deftypefn {Деструктор класса @code{mglParse}} @code{} ~mglParse () +@deftypefnx {Функция С} @code{void} mgl_delete_parser (@code{HMPR} p) +Удаляет экземпляр класса. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{HMPR} Self () +Возвращает указатель на используемый объект типа @code{HMPR}. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const char *}text) +@deftypefnx{Метод класса @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{const wchar_t *}text) +@deftypefnx {Функция С} @code{void} mgl_parse_text (@code{HMGL} gr, @code{HMPR} p, @code{const char *}text) +@deftypefnx {Функция С} @code{void} mgl_parse_textw (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}text) +Выполняет построчно скрипт MGL, содержащийся в @var{text}. Строки считаются разделенными символом @samp{\n}. Это основная функция класса. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} Execute (@code{mglGraph *}gr, @code{FILE *}fp, @code{bool} print=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_parse_file (@code{HMGL} gr, @code{HMPR} p, @code{FILE *}fp, @code{int} print) +Аналогично предыдущему, но скрипт читается из файла @var{fp}. Если @var{print}=@code{true}, то предупреждения и информационные сообщения печатаются в stdout. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const char *}str, @code{long} pos=@code{0}) +@deftypefnx {Метод класса @code{mglParse}} @code{int} Parse (@code{mglGraph *}gr, @code{const wchar_t *}str, @code{long} pos=@code{0}) +@deftypefnx {Функция С} @code{int} mgl_parse_line (@code{HMGL} gr, @code{HMPR} p, @code{const char *}str, @code{int} pos) +@deftypefnx {Функция С} @code{int} mgl_parse_linew (@code{HMGL} gr, @code{HMPR} p, @code{const wchar_t *}str, @code{int} pos) +Выполняет строку @var{str} с выводом графики на @var{gr}. Возвращает код ошибки: 0 -- нет ошибок, 1 -- неправильные аргументы, 2 -- неизвестная команда, 3 -- строка слишком длинная. Аргумент @var{pos} задает позицию строки в документе/файле для использования в команде @ref{for}. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{mglData} Calc (@code{const char *}formula) +@deftypefnx {Метод класса @code{mglParse}} @code{mglData} Calc (@code{const wchar_t *}formula) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_calc (@code{HMPR} p, @code{const char *}formula) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_calcw (@code{HMPR} p, @code{const wchar_t *}formula) +Разбирает строку @var{formula} и возвращает полученный массив. В отличие от @code{AddVar()} или @code{FindVar()}, это обычный массив данных, который следует удалить после использования. +@end deftypefn + + +@deftypefn {Метод класса @code{mglParse}} @code{void} AddParam (@code{int} n, @code{const char *}str) +@deftypefnx {Метод класса @code{mglParse}} @code{void} AddParam (@code{int} n, @code{const wchar_t *}str) +@deftypefnx {Функция С} @code{void} mgl_parser_add_param (@code{HMPR} p, @code{int} id, @code{const char *}val) +@deftypefnx {Функция С} @code{void} mgl_parser_add_paramw (@code{HMPR} p, @code{int} id, @code{const wchar_t *}val) +Устанавливает значение @var{n}-го параметра строкой @var{str} (@var{n}=0, 1 ... 'z'-'a'+10). Строка @var{str} не должна содержать символ @samp{$}. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{mglVar *} FindVar (@code{const char *}name) +@deftypefnx {Метод класса @code{mglParse}} @code{mglVar *} FindVar (@code{const wchar_t *}name) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_find_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_find_varw (@code{HMPR} p, @code{const wchar_t *}name) +Возвращает указатель на переменную с именем @var{name} или @code{NULL} если переменная отсутствует. Используйте эту функцию для добавления внешних массивов в скрипт. @strong{Не удаляйте} полученный массив! +@end deftypefn +@deftypefn {Метод класса @code{mglParse}} @code{mglVar *} AddVar (@code{const char *}name) +@deftypefnx {Метод класса @code{mglParse}} @code{mglVar *} AddVar (@code{const wchar_t *}name) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_add_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {Функция С} @code{HMDT} mgl_parser_add_varw (@code{HMPR} p, @code{const wchar_t *}name) +Возвращает указатель на переменную с именем @var{name}. Если переменная отсутствует, то она будет создана. Используйте эту функцию для добавления внешних массивов в скрипт. @strong{Не удаляйте} полученный массив! +@end deftypefn + +@deftypefn{Метод класса @code{mglParse} (C++)} @code{void} DeleteVar (@code{const char *}name) +@deftypefnx{Метод класса @code{mglParse} (C++)} @code{void} DeleteVar (@code{const wchar_t *}name) +@deftypefnx {Функция С} @code{void} mgl_parser_del_var (@code{HMPR} p, @code{const char *}name) +@deftypefnx {Функция С} @code{void} mgl_parser_del_varw (@code{HMPR} p, @code{const wchar_t *}name) +Удаляет переменную по имени @var{name}. +@end deftypefn + +@deftypefn{Метод класса @code{mglParse} (C++)} @code{void} DeleteAll () +@deftypefnx {Функция С} @code{void} mgl_parser_del_all (@code{HMPR} p) +Удаляет все переменные в данном классе. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} RestoreOnce () +@deftypefnx {Функция С} @code{void} mgl_parser_restore_once (@code{HMPR} p) +Восстанавливает состояние флага Once. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} AllowSetSize (@code{bool} a) +@deftypefnx {Функция С} @code{void} mgl_parser_allow_setsize (@code{HMPR} p, @code{int} a) +Разрешает/запрещает команду 'setsize'. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} AllowFileIO (@code{bool} a) +@deftypefnx {Функция С} @code{void} mgl_parser_allow_file_io (@code{HMPR} p, @code{int} a) +Разрешает/запрещает команды чтения файлов. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{void} Stop () +@deftypefnx {Функция С} @code{void} mgl_parser_stop (@code{HMPR} p) +Посылает сигнал завершения выполнения для следующей команды. +@end deftypefn + + +@deftypefn {Метод класса @code{mglParse}} @code{long} GetCmdNum () +@deftypefnx {Функция С} @code{long} mgl_parser_cmd_num (@code{HMPR} p) +Возвращает число зарегистрированных команд MGL. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{const char *} GetCmdName (@code{long} id) +@deftypefnx {Функция С} @code{const char *} mgl_parser_cmd_name (@code{HMPR} p, @code{long} id) +Возвращает имя команды MGL с заданным номером @var{id}. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{int} CmdType (@code{const char *}name) +@deftypefnx {Функция С} @code{int} mgl_parser_cmd_type (@code{HMPR} p, @code{const char *}name) +Возвращает тип команды MGL с именем @var{name}. Типы команд: 0 -- не команда, 1 - графики по данным, 2 - прочие графики, 3 - настройка, 4 - обработка данных, 5 - создание данных, 6 - трансформация, 7 - ход выполнения, 8 - 1d графики, 9 - 2d графики, 10 - 3d графики, 11 - двойные графики, 12 - векторные поля, 13 - оси координат, 14 - примитивы, 15 - настройка осей, 16 - текст/легенда, 17 - изменение данных. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{const char *} CmdFormat (@code{const char *}name) +@deftypefnx {Функция С} @code{const char *} mgl_parser_cmd_frmt (@code{HMPR} p, @code{const char *}name) +Возвращает формат аргументов команды MGL с именем @var{name}. +@end deftypefn + +@deftypefn {Метод класса @code{mglParse}} @code{const char *} CmdDesc (@code{const char *}name) +@deftypefnx {Функция С} @code{const char *} mgl_parser_cmd_desc (@code{HMPR} p, @code{const char *}name) +Возвращает описание команды MGL с именем @var{name}. +@end deftypefn + +@end ifclear + +@external{} diff --git a/texinfo/qt.png b/texinfo/qt.png new file mode 100644 index 0000000..0fc0f8e Binary files /dev/null and b/texinfo/qt.png differ diff --git a/texinfo/symbols_en.texi b/texinfo/symbols_en.texi new file mode 100644 index 0000000..6b440b0 --- /dev/null +++ b/texinfo/symbols_en.texi @@ -0,0 +1,732 @@ +@nav{} + +This appendix contain the full list of symbols (characters) used by MathGL for setting up plot. Also it contain sections for full list of hot-keys supported by mglview tool and by UDAV program. + +@menu +* Symbols for styles:: +* Hot-keys for mglview:: +* Hot-keys for UDAV:: +@end menu + +@c ------------------------------------------------------------------ +@external{} +@node Symbols for styles, Hot-keys for mglview, , Symbols and hot-keys +@section Symbols for styles +@nav{} + +Below is full list of all characters (symbols) which MathGL use for setting up the plot. + +@table @samp +@item space ' ' +empty line style (see @ref{Line styles}); + +empty color in @ref{chart}. + +@item ! +set to use new color from palette for each point (not for each curve, as default) in @ref{1D plotting}. + +@item # +set to use solid marks (see @ref{Line styles}) or solid @ref{error} boxes; + +set to draw wired plot for @ref{axial}, @ref{surf3}, @ref{surf3a}, @ref{surf3c}, @ref{triplot}, @ref{quadplot}, @ref{area}, @ref{bars}, @ref{barh}, @ref{tube}, @ref{tape}, @ref{cone}, @ref{boxs} and draw boundary only for @ref{circle}, @ref{ellipse}, @ref{rhomb}; + +set to draw also mesh lines for @ref{surf}, @ref{surfc}, @ref{surfa}, @ref{dens}, @ref{densx}, @ref{densy}, @ref{densz}, @ref{dens3}, or boundary for @ref{chart}, @ref{facex}, @ref{facey}, @ref{facez}, @ref{rect}; + +set to draw boundary and box for @ref{legend}, @ref{title}, or grid lines for @ref{table}; + +set to draw grid for @ref{radar}; + +set to start flow threads and pipes from edges only for @ref{flow}, @ref{pipe}; + +set to use whole are for axis range in @ref{subplot}, @ref{inplot}; + +change text color inside a string (see @ref{Font styles}); + +start comment in @ref{MGL scripts} or in @ref{Command options}. + +@item $ +denote parameter of @ref{MGL scripts}. + +@item & +operation in @ref{Textual formulas}. + +@item @quoteright{} +denote string in @ref{MGL scripts} or in @ref{Command options}. + +@item * +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +operation in @ref{Textual formulas}. + +@item + +one of marks (see @ref{Line styles}) or kind of @ref{error} boxes; + +one of mask for face filling (see @ref{Color scheme}); + +operation in @ref{Textual formulas}. + +@item , +separator for color positions (see @ref{Color styles}) or items in a list. + +@item - +solid line style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +place entries horizontally in @ref{legend}; + +operation in @ref{Textual formulas}. + +@item . +one of marks (see @ref{Line styles}) or kind of @ref{error} boxes; + +set to draw hachures instead of arrows for @ref{vect}, @ref{vect3}; + +set to use dots instead of faces for @ref{cloud}, @ref{torus}, @ref{axial}, @ref{surf3}, @ref{surf3a}, @ref{surf3c}, @ref{surf}, @ref{surfa}, @ref{surfc}, @ref{dens}, @ref{map}; + +delimiter of fractional parts for numbers. + +@item / +operation in @ref{Textual formulas}. + +@item : +line dashing style (see @ref{Line styles}); + +stop color scheme parsing (see @ref{Color scheme}); + +range operation in @ref{MGL scripts}. + +@item ; +line dashing style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +end of an option in @ref{MGL scripts} or in @ref{Command options}. + +@item < +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +style of @ref{vect}, @ref{vect3}; + +align left in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}, @ref{candle}, @ref{ohlc}; + +operation in @ref{Textual formulas}. + + +@item > +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +style of @ref{vect}, @ref{vect3}; + +align right in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}, @ref{candle}, @ref{ohlc}; + +operation in @ref{Textual formulas}. + +@item = +line dashing style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +set to use equidistant columns for @ref{table}; + +set to use color gradient for @ref{vect}, @ref{vect3}; + +operation in @ref{Textual formulas}. + +@item @@ +set to draw box around text for @ref{text} and similar functions; + +set to draw boundary and fill it for @ref{circle}, @ref{ellipse}, @ref{rhomb}; + +set to fill faces for @ref{box}; + +set to draw large semitransparent mark instead of error box for @ref{error}; + +set to draw edges for @ref{cone}; + +set to draw filled boxes for @ref{boxs}; + +reduce text size inside a string (see @ref{Font styles}). + +@item ^ +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +set outer position for @ref{legend}; + +inverse default position for @ref{axis}; + +switch to upper index inside a string (see @ref{Font styles}); + +align center in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}, @ref{candle}, @ref{ohlc}; + +operation in @ref{Textual formulas}. + +@item _ +empty arrow style (see @ref{Line styles}); + +disable drawing of tick labels for @ref{axis}; + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +set to draw contours at bottom for @ref{cont}, @ref{contf}, @ref{contd}, @ref{contv}, @ref{tricont}; + +switch to lower index inside a string (see @ref{Font styles}). + +@item [] +contain symbols excluded from color scheme parsing (see @ref{Color scheme}). + +@item @{@} +contain extended color specification (see @ref{Color styles}); + +denote special operation in @ref{MGL scripts}; + +denote 'meta-symbol' for LaTeX like string parsing (see @ref{Font styles}). + +@item | +line dashing style (see @ref{Line styles}); + +set to use sharp color scheme (see @ref{Color scheme}); + +set to limit width by subplot width for @ref{table}; + +delimiter in @ref{list} command; + +operation in @ref{Textual formulas}. + +@item \ +string continuation symbol on next line for @ref{MGL scripts}. + +@item ~ +disable drawing of tick labels for @ref{axis} and @ref{colorbar}; + +one of mask for face filling (see @ref{Color scheme}). + +@item 0,1,2,3,4,5,6,7,8,9 +line width (see @ref{Line styles}); + +brightness of a color (see @ref{Color styles}); + +kind of smoothing (for digits 1,3,5) in @ref{smooth}; + +digits for a value. + +@item 4,6,8 +draw square, hex- or octo-pyramids instead of cones in @ref{cone}, @ref{cones}. + +@item A,B,C,D,E,F,a,b,c,d,e,f +can be hex-digit for color specification if placed inside @{@} (see @ref{Color styles}). + +@item A +arrow style (see @ref{Line styles}); + +set to use absolute position in whole picture for @ref{text}, @ref{colorbar}, @ref{legend}. + +@item a +set to use absolute position in subplot for @ref{text}; + +style of @ref{bars}, @ref{barh}, @ref{cones}. + +@item B +dark blue color (see @ref{Color styles}). + +@item b +blue color (see @ref{Color styles}); + +bold font face if placed after @samp{:} (see @ref{Font styles}). + +@item C +dark cyan color (see @ref{Color styles}); + +align text to center if placed after @samp{:} (see @ref{Font styles}). + +@item c +cyan color (see @ref{Color styles}); + +name of color axis; + +cosine transform for @ref{transform}. + +@item D +arrow style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}). + +@item d +one of marks (see @ref{Line styles}) or kind of @ref{error} boxes; + +one of mask for face filling (see @ref{Color scheme}). + +@item E +dark green-yellow color (see @ref{Color styles}). + +@item e +green-yellow color (see @ref{Color styles}). + +@item f +style of @ref{bars}, @ref{barh}; + +style of @ref{vect}, @ref{vect3}; + +Fourier transform for @ref{transform}. + +@item G +dark green color (see @ref{Color styles}). + +@item g +green color (see @ref{Color styles}). + +@item H +dark gray color (see @ref{Color styles}). + +@item h +gray color (see @ref{Color styles}); + +Hankel transform for @ref{transform}. + +@item I +arrow style (see @ref{Line styles}); + +set @ref{colorbar} position near boundary. + +@item i +line dashing style (see @ref{Line styles}); + +italic font face if placed after @samp{:} (see @ref{Font styles}). + +set to use inverse values for @ref{cloud}, @ref{pipe}, @ref{dew}; + +set to fill only area with y1 +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +style of @ref{vect}, @ref{vect3}; + +align right in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}, @ref{candle}, @ref{ohlc}; + +operation in @ref{Textual formulas}. + +@item = +line dashing style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +set to use equidistant columns for @ref{table}; + +set to use color gradient for @ref{vect}, @ref{vect3}; + +operation in @ref{Textual formulas}. + +@item @@ +set to draw box around text for @ref{text} and similar functions; + +set to draw boundary and fill it for @ref{circle}, @ref{ellipse}, @ref{rhomb}; + +set to fill faces for @ref{box}; + +set to draw large semitransparent mark instead of error box for @ref{error}; + +set to draw edges for @ref{cone}; + +set to draw filled boxes for @ref{boxs}; + +reduce text size inside a string (see @ref{Font styles}). + +@item ^ +one of marks (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}); + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +set outer position for @ref{legend}; + +inverse default position for @ref{axis}; + +switch to upper index inside a string (see @ref{Font styles}); + +align center in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}, @ref{candle}, @ref{ohlc}; + +operation in @ref{Textual formulas}. + +@item _ +empty arrow style (see @ref{Line styles}); + +disable drawing of tick labels for @ref{axis}; + +style of @ref{subplot} and @ref{inplot}; + +set position of @ref{colorbar}; + +set to draw contours at bottom for @ref{cont}, @ref{contf}, @ref{contd}, @ref{contv}, @ref{tricont}; + +switch to lower index inside a string (see @ref{Font styles}). + +@item [] +contain symbols excluded from color scheme parsing (see @ref{Color scheme}). + +@item @{@} +contain extended color specification (see @ref{Color styles}); + +denote special operation in @ref{MGL scripts}; + +denote 'meta-symbol' for LaTeX like string parsing (see @ref{Font styles}). + +@item | +line dashing style (see @ref{Line styles}); + +set to use sharp color scheme (see @ref{Color scheme}); + +set to limit width by subplot width for @ref{table}; + +delimiter in @ref{list} command; + +operation in @ref{Textual formulas}. + +@item \ +string continuation symbol on next line for @ref{MGL scripts}. + +@item ~ +disable drawing of tick labels for @ref{axis} and @ref{colorbar}; + +one of mask for face filling (see @ref{Color scheme}). + +@item 0,1,2,3,4,5,6,7,8,9 +line width (see @ref{Line styles}); + +brightness of a color (see @ref{Color styles}); + +kind of smoothing (for digits 1,3,5) in @ref{smooth}; + +digits for a value. + +@item 4,6,8 +draw square, hex- or octo-pyramids instead of cones in @ref{cone}, @ref{cones}. + +@item A,B,C,D,E,F,a,b,c,d,e,f +can be hex-digit for color specification if placed inside @{@} (see @ref{Color styles}). + +@item A +arrow style (see @ref{Line styles}); + +set to use absolute position in whole picture for @ref{text}, @ref{colorbar}, @ref{legend}. + +@item a +set to use absolute position in subplot for @ref{text}; + +style of @ref{bars}, @ref{barh}, @ref{cones}. + +@item B +dark blue color (see @ref{Color styles}). + +@item b +blue color (see @ref{Color styles}); + +bold font face if placed after @samp{:} (see @ref{Font styles}). + +@item C +dark cyan color (see @ref{Color styles}); + +align text to center if placed after @samp{:} (see @ref{Font styles}). + +@item c +cyan color (see @ref{Color styles}); + +name of color axis; + +cosine transform for @ref{transform}. + +@item D +arrow style (see @ref{Line styles}); + +one of mask for face filling (see @ref{Color scheme}). + +@item d +one of marks (see @ref{Line styles}) or kind of @ref{error} boxes; + +one of mask for face filling (see @ref{Color scheme}). + +@item E +dark green-yellow color (see @ref{Color styles}). + +@item e +green-yellow color (see @ref{Color styles}). + +@item f +style of @ref{bars}, @ref{barh}; + +style of @ref{vect}, @ref{vect3}; + +Fourier transform for @ref{transform}. + +@item G +dark green color (see @ref{Color styles}). + +@item g +green color (see @ref{Color styles}). + +@item H +dark gray color (see @ref{Color styles}). + +@item h +gray color (see @ref{Color styles}); + +Hankel transform for @ref{transform}. + +@item I +arrow style (see @ref{Line styles}); + +set @ref{colorbar} position near boundary. + +@item i +line dashing style (see @ref{Line styles}); + +italic font face if placed after @samp{:} (see @ref{Font styles}). + +set to use inverse values for @ref{cloud}, @ref{pipe}, @ref{dew}; + +set to fill only area with y1Surface in fog +@end html +@end ifhtml +@itemize @bullet +@item +a library for making high-quality scientific graphics under Linux and Windows; +@item +a library for the fast data plotting and data processing of large data arrays; +@item +a library for working in window and console modes and for easy embedding into other programs; +@item +a library with large and growing set of graphics. +@end itemize + +Now MathGL has more than 35000 lines of code, more than 55 general types of graphics for 1d, 2d and 3d data arrays, including special ones for chemical and statistical graphics. It can export graphics to raster and vector (EPS or SVG) formats. It has Qt, FLTK, OpenGL interfaces and can be used even from console programs. It has functions for data processing and script MGL language for simplification of data plotting. Also it has several types of transparency and smoothed lightning, vector fonts and TeX-like symbol parsing, arbitrary curvilinear coordinate system and many over useful things. It can be used from code written on C++/C/Fortran/Python/Octave and many other languages. Finally it is platform independent and free (under GPL v.2.0 license). + +There is a @uref{http://sourceforge.net/forum/?group_id=152187, forum} where you can ask a question or suggest an improvement. However the @uref{http://groups.google.com/group/mathgl, MathGL group} is preferable for quicker answer. + +For subscribing to @uref{http://groups.google.com/group/mathgl, MathGL group} you can use form below +@ifhtml +@html +
+Email: +
+@end html +@end ifhtml + +@strong{About LGPL and GPL licenses.} +Generally, MathGL is GPL library. However, you can use LGPL license for MathGL core and widgets if you don't use SWIG-based interfaces and disable GSL features. This can be done by using @code{lgpl} option at build time. According this, I've added the LGPL win32 binaries into @ref{Download} page. + +@strong{Latest news} +@itemize +@item @emph{19 March 2014.} +New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early, and documentation update. +@item @emph{10 March 2014.} +New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are extend of 'region' plot, improve export to TeX, add missing Fortran functions, bugfixes, and other improvements, which denoted @ref{News, here}. Note, this release looks as bug free, but next release (v.2.3) will introduce a set of improvements which may not so stable at first time. +@item @emph{22 January 2014.} +New version (v.@value{VERSION}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are support of Qt5 and Pascal, improvements in JavaScript interface, bugfixes, and other improvements, which denoted @ref{News, here}. +@item @emph{11 November 2013.} +New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up, new plot kinds and data handling functions, new plot styles, masks for bitmap output, wx-widget, Lua interface, and many other improvements, which denoted @ref{News, here}. +@end itemize + +There is detailed @ref{News, news list}. Sourceforge project page @uref{http://sourceforge.net/projects/mathgl/, here}. + +@ifhtml +@html +DATADVANCE +@end html +@end ifhtml +Javascript interface was developed with support of @url{http://www.datadvance.net, DATADVANCE} company. + +@external{} + +@node News, Features, Main, Website +@section News +@nav{} + +@itemize +@item +@strong{19 March 2014.} +New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early. +@itemize @bullet +@item Compatibility changes for MS VisualStudio 2010 and early. +@item Function SetRange(v1,v2) ignore NAN values now. +@item Add enable-json-sample for building json-samples on demand only. +@item Update documentation. +@end itemize + +@item +@strong{10 March 2014.} +New version (v.2.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes: +@itemize @bullet +@item Add mgl_region_3d() to draw region (or ribbon) between 2 curves. Correspondingly extend mglGraph::Region() function and MGL command 'region'. +@item Allow LGPL for MathGL widgets. +@item Improve export to TeX. +@item Add missing functions to Fortran interface. +@item Bugfix for legend with enabled lighting. +@item Minor bugfixes and memory leaks. +@end itemize + +@item +@strong{22 January 2014.} +New version (v.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes: +@itemize @bullet +@item Add Qt5 support. +@item Add Pascal interface. +@item Improve JavaScript interface. +@item Add function mglGraph::AddRange(char dir, mreal v1, mreal v2) and extend corresponding MGL commands '[xyzc]range'. +@item Add 'hypot(x,y)' function for known functions in formula parsing. +@item Add style '~' to disable colorbar or axis labels. NOTE, axis style '_' is obsolete and should be replaced by '~'. +@item Change Aspect() if Ax=NAN. Now, Ay and Az set the ratio to optimal aspect (not exact value as previously). +@item Disable changes by View(),Zoom(),Perspective() for position of Title(), Legend(), Colorbar(). +@item Partial support of perspective in CalcXYZ(). +@item Speed up PDE solving. +@item Add complex versions of PDE, QO2d, QO3d. +@item Correct filled background for Box() in curved coordinates. +@item Allow nx=1 for Stem and Error. +@item Bugfix for drawing single axis. +@item Bugfix for missing options parsing for some of MGL commands. +@item Bugfix for .pmin suffix in MGL. Add mglData::MaximalNeg() and mglData::MinimalPos() functions. Add .nmin and .nmax suffixes. +@item Bugfix for colorbar labels. +@item Force using python 2.7 by default due to bug in Ubuntu. Debian sid works well with python 3.* too. +@item Other minor bugfixes and memory leaks. +@end itemize + +@item +@strong{11 November 2013.} +New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized). +@item Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data. +@item Add @ref{ohlc} plot for drawing Open-High-Low-Close diagram +@item Add wxMathGL widget. See @ref{wxMathGL class}. +@item Add interface for Lua v.5.1. +@item Add @ref{mask} for face drawing if one of symbols @samp{-+=;oOsS~<>jdD*^} is specified in color scheme. This work only for export in bitmap images. +@item Add @ref{quality}=8 for dots drawing (extremely fast). +@item Add styles '4','6','8' for @ref{cone} and @ref{cones} to produce square, hex-, octo-prism. +@item Add style 't' for @ref{cones} to produce tubes (cylinders). +@item Add style '^' for @ref{legend} to left/right align legend if its coordinates are right/left from the center +@item Add style '<', '^', '>' for aligning/centering boxes in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}. Also this plots become centered by default if nx sizes are the same for all data. +@item Add @ref{dots} function which set independently both color and transparency of dots. +@item Improve automatic axis position. Add style '^' for inverse automatic axis position. +@item Improve tick labeling. Add style @ref{tuneticks}&4 for zero filling of tick labels. +@item Add @ref{refill} for filling by interpolation of parametrically dependent data +@item Add transparency for @ref{area} and @ref{region} plots. +@item Add mgl_clf_chr() function and extend @ref{clf} command. +@item Fourier now perform true inverse Fourier transform (instead of backward one). +@item Improve/change lighting from local sources. Add @ref{diffuse} function. +@item C functions now return NULL if HMDT data cannot be created for given input argument(s). +@item Enable line width for @ref{mesh} and @ref{fall} plots. +@item Replace +INF and -INF by NAN in textual formula output. +@item Add manual compression of JSON. +@item Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev). +@item Bugfix for cleaning unused points. +@item Fix 'setsize' command at UDAV starting. +@item Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions. +@item Minor bugfixes. +@item Update docs. +@end itemize + +@item +@strong{8 May 2013.} +New version (v.2.1.3.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Compatibility changes for MS VS. +@item Bugfixes for cmake options @code{enable-double=OFF, enable-zlib=OFF}. +@item Enable mouse actions for Firefox in JS sample. +@end itemize + +@item +@strong{2 May 2013.} +New version (v.2.1.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Functions @ref{sinfft}, @ref{cosfft}, @ref{hankel} and so on, become multi-threaded. +@item Use DFT instead of FFT if GSL support is disabled (much slow!). +@item Add Join() function for joining mglData arrays (see @ref{join}) +@item Add Roots() function for root finding of nonlinear equation (see @ref{roots}) +@item Add class mglExprC for parsing formula with complex numbers (see @ref{Evaluate expression}) +@item Correctly read #QNAN values in data files +@item Speed up @ref{dots} drawing +@item Add flag to disable tick labels at axis origin (see SetOriginTick()) +@item Add MGL commands @ref{origintick}, @ref{tickshift} +@item WriteJSON now use zlib if filename end at 'z' (like "test.jsonz") +@item Make separate libmgl-mpi +@item Add SetAutoRanges() function (duplicate corresponding options) +@item Add JSON sample usage via QtWebKit (thanks to DATADVANCE) +@item Bugfixes and memory leaks +@end itemize + +@item +@strong{28 January 2013.} +New version (v.2.1.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Exclude "local" functions from resulting library. +@item String in MGL script now can be concatenated with another string or data/numbers (like @samp{'max(u)=',u.max,' a.u.'}). +@item Bugfix for colors in 3D PDF. +@item Bugfix for drawing in MPI mode. +@item If Aspect() function have NAN argument(s) then it try to select optimal aspect ratio. +@item Option 'size' in Legend() now change only text size (not mark size). +@item Option 'meshnum' now influence on Boxs() and Belt() functions +@item Adjust marks drawing (line width and dots). +@item Minor improvements and bugfixes. +@end itemize + +@item +@strong{24 December 2012.} +New version (v.2.1.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Bugfix for SetRange(val,val) function +@item Exclude export MGL to CPP +@item MGL parsing now produce errors for any wrong list of arguments +@item Add help message to mgl.cgi +@item Improve text rotation at View() +@item Make compatible with GIF library v.5.0. +@item Bugfix for making MPI interface. +@item Bugfix for running in Win32 mode. +@item Update docs and MGL samples +@end itemize + +@item +@strong{13 December 2012.} +New version (v.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up and many improvements and bugfixes: +@itemize @bullet +@item +Add class mglDataC for complex data arrays. +@item +Add Vect3() plot for drawing vectors on slice of 3d vector field. See @ref{Vect3 sample}. +@item +Add Table() function for drawing table with data values. See @ref{Table sample}. +@item +Add ZoomAxis() for zooming/shifting axis range as whole. +@item +Add WriteJSON() function for exporting in JSON format suitable for later drawing by JavaScript +@item +Add JavaScript code for visualizing JSON data. See @uref{../json.html, samples}. +@item +Add mgl.cgi tool which return PNG image for CGI request in form of MGL script. +@item +Add mglData::Solve() for finding x-value where dat(x)=val. See @ref{Solve sample}. +@item +Add mglData::Clean() for removing rows with duplicate values for given column. +@item +Add MGL commands 'errbox', 'face' + +@item +Color can be specified as its RGB[A] values, i.e. like @samp{@{xFFFFFF@}} or @samp{@{xFFFFFFFF@}}. See @ref{Line styles}. +@item +Color in color scheme may have position in range [0,1]. Format is @samp{@{CN,pos@}} or @samp{@{xFFFFFF,pos@}}. See @ref{Color scheme}. +@item +Now pen width for marks is proportional to pen width of line multiplied by size of marks. +@item +Now you can use different font-faces in the plot simultaneously. See @ref{Text features}. +@item +Now Legend() automatically use several columns if it contain too many legend entries. +@item +Add style '-' for legend for drawing them horizontally. See @ref{Legend sample}. +@item +Vectors is drawn now even if only starting or ending points are placed in bounding box. +@item +Strongly rewrite the algorithm of vector field plotting. + +@item +Grid lines for NAN origin values are always located at far-away edges. +@item +Try correctly place axis and tick labels even for axis with inverse range (i.e. for v2 +@comment +@comment +@comment
+@html + + +SourceForge.net Logo + + thefreecountry.com: Free Programmers' Resources, Free Webmasters' Resources, Free Security Resources, Free Software + +Support This Project +@end html +@end macro + +@macro fig {plot,text} +@uref{../\text\, @image{../small/\plot\-sm,3cm, , , .png}} +@end macro +@end ifhtml + +@ifnothtml +@macro external {} +@end macro +@macro fig {plot,text} +@uref{http://mathgl.sourceforge.net/\text\, @image{small/\plot\-sm,3cm, , , .png}} +@end macro +@end ifnothtml + +@node Main, News, , Top +@section MathGL is ... + +@ifhtml +@html +Surface in fog +@end html +@end ifhtml +@itemize @bullet +@item +a library for making high-quality scientific graphics under Linux and Windows; +@item +a library for the fast data plotting and data processing of large data arrays; +@item +a library for working in window and console modes and for easy embedding into other programs; +@item +a library with large and growing set of graphics. +@end itemize + +Now MathGL has more than 35000 lines of code, more than 55 general types of graphics for 1d, 2d and 3d data arrays, including special ones for chemical and statistical graphics. It can export graphics to raster and vector (EPS or SVG) formats. It has Qt, FLTK, OpenGL interfaces and can be used even from console programs. It has functions for data processing and script MGL language for simplification of data plotting. Also it has several types of transparency and smoothed lightning, vector fonts and TeX-like symbol parsing, arbitrary curvilinear coordinate system and many over useful things. It can be used from code written on C++/C/Fortran/Python/Octave and many other languages. Finally it is platform independent and free (under GPL v.2.0 license). + +There is a @uref{http://sourceforge.net/forum/?group_id=152187, forum} where you can ask a question or suggest an improvement. However the @uref{http://groups.google.com/group/mathgl, MathGL group} is preferable for quicker answer. + +For subscribing to @uref{http://groups.google.com/group/mathgl, MathGL group} you can use form below +@ifhtml +@html +
+Email: +
+@end html +@end ifhtml + +@strong{About LGPL and GPL licenses.} +Generally, MathGL is GPL library. However, you can use LGPL license for MathGL core and widgets if you don't use SWIG-based interfaces and disable GSL features. This can be done by using @code{lgpl} option at build time. According this, I've added the LGPL win32 binaries into @ref{Download} page. + +@strong{Latest news} +@itemize +@item @emph{13 December 2012.} +New version (v.@value{VERSION}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are new plots, advanced color schemes, @uref{../json.html, JavaScript drawing}, and many other improvements in both MathGL core and UDAV, which partially denoted @ref{News, here}. Note, there are @strong{incompatible with v.2.0.* changes} in the arguments of some functions. +@item @emph{I'm sorry for making incompatible changes in v.2.1. It was done for introducing unified interface for all functions. I promise that I will not break API for v.2.* later, i.e. I'll only add new features or bug fixes.} +@end itemize + +There is detailed @ref{News, news list}. Sourceforge project page @uref{http://sourceforge.net/projects/mathgl/, here}. + +@ifhtml +@html +DATADVANCE +@end html +@end ifhtml +Javascript interface was developed with support of @url{http://www.datadvance.net, DATADVANCE} company. + +@external{} + +@node News, Features, Main, Top +@section News + +@itemize + +@item +@strong{13 December 2012.} +New version (v.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up and many improvements and bugfixes: +@itemize @bullet +@item +Add class mglDataC for complex data arrays. +@item +Add Vect3() plot for drawing vectors on slice of 3d vector field. See @url{../doc_en/doc_en_17.html#Vect3-sample, sample}. +@item +Add Table() function for drawing table with data values. See @url{../doc_en/doc_en_14.html#Table-sample, sample}. +@item +Add ZoomAxis() for zooming/shifting axis range as whole. +@item +Add WriteJSON() function for exporting in JSON format suitable for later drawing by JavaScript +@item +Add JavaScript code for visualizing JSON data. See @uref{../json.html, samples}. +@item +Add mgl.cgi tool which return PNG image for CGI request in form of MGL script. +@item +Add mglData::Solve() for finding x-value where dat(x)=val. See @url{../doc_en/doc_en_12.html#Solve-sample, sample}. +@item +Add mglData::Clean() for removing rows with duplicate values for given column. +@item +Add MGL commands 'errbox', 'face' + +@item +Color can be specified as its RGB[A] values, i.e. like @samp{@{xFFFFFF@}} or @samp{@{xFFFFFFFF@}}. See @url{../doc_en/doc_en_23.html#Line-styles, sample}. +@item +Color in color scheme may have position in range [0,1]. Format is @samp{@{CN,pos@}} or @samp{@{xFFFFFF,pos@}}. See @url{../doc_en/doc_en_24.html#Color-scheme, sample}. +@item +Now pen width for marks is proportional to pen width of line multiplied by size of marks. +@item +Now you can use different font-faces in the plot simultaneously. See @url{../doc_en/doc_en_11.html#Text-features, sample}. +@item +Now Legend() automatically use several columns if it contain too many legend entries. +@item +Add style '-' for legend for drawing them horizontally. See @url{../doc_en/doc_en_11.html#Legend-sample, sample}. +@item +Vectors is drawn now even if only starting or ending points are placed in bounding box. +@item +Strongly rewrite the algorithm of vector field plotting. + +@item +Grid lines for NAN origin values are always located at far-away edges. +@item +Try correctly place axis and tick labels even for axis with inverse range (i.e. for v2' b'} will give string @samp{'a + b'} (here @samp{
} is newline). + +@item +Usually variable have a name which is arbitrary combination of symbols (except spaces and @samp{'}) started from a letter and with length less than 64. A temporary array can be used as variable: +@itemize @bullet +@item +sub-arrays (like in @code{subdata} command) as command argument. For example, @code{a(1)} or @code{a(1,:)} or @code{a(1,:,:)} is second row, @code{a(:,2)} or @code{a(:,2,:)} is third column, @code{a(:,:,0)} is first slice and so on. Also you can extract a part of array from m-th to n-th element by code @code{a(m:n,:,:)} or just @code{a(m:n)}. + +@item +any column combinations defined by formulas, like @code{a('n*w^2/exp(t)')} if names for data columns was specified (by @code{idset} command or in the file at string started with @code{##}). + +@item +any expression (without spaces) of existed variables produce temporary variable. For example, @samp{sqrt(dat(:,5)+1)} will produce temporary variable with data values equal to @code{tmp[i,j] = sqrt(dat[i,5,j]+1)}. + +@item +temporary variable of higher dimensions by help of []. For example, @samp{[1,2,3]} will produce a temporary vector of 3 elements @{1, 2, 3@}; @samp{[[11,12],[21,22]]} will produce matrix 2*2 and so on. Here you can join even an arrays of the same dimensions by construction like @samp{[v1,v2,...,vn]}. + +@item +result of code for making new data inside @{@}. For example, @samp{@{sum dat 'x'@}} produce temporary variable which contain result of summation of @var{dat} along direction 'x'. This is the same array @var{tmp} as produced by command @samp{sum tmp dat 'x'}. You can use nested constructions, like @samp{@{sum @{max dat 'z'@} 'x'@}}. +@end itemize +Temporary variables can not be used as 1st argument for commands which create (return) the data (like @samp{new}, @samp{read}, @samp{hist} and so on). + +@item +Special names @code{nan=#QNAN, pi=3.1415926..., on=1, off=0, :=-1} are treated as number if they were not redefined by user. Variables with suffixes are treated as numbers. Names defined by @code{define} command are treated as number. Also results of formulas with sizes 1x1x1 are treated as number (for example, @samp{pi/dat.nx}). +@end itemize +Before the first using all variables must be defined with the help of commands, like, @code{new}, @code{var}, @code{list}, @code{copy}, @code{read}, @code{hist}, @code{sum} and so on. + +Command may have several set of possible arguments (for example, @code{plot ydat} and @code{plot xdat ydat}). All command arguments for a selected set must be specified. However, some arguments can have default values. These argument are printed in [], like @code{text ydat ['stl'='']} or @code{text x y 'txt' ['fnt'='' size=-1]}. At this, the record @code{[arg1 arg2 arg3 ...]} means @code{[arg1 [arg2 [arg3 ...]]]}, i.e. you can omit only tailing arguments if you agree with its default values. For example, @code{text x y 'txt' '' 1} or @code{text x y 'txt' ''} is correct, but @code{text x y 'txt' 1} is incorrect (argument @code{'fnt'} is missed). + +For more details see @uref{../doc_en/doc_en_64.html#MGL-scripts, MathGL documentation} + +@external{} + +@node Download, Other projects, MGL scripts, Top +@section Download + +@strong{Stable version (v.@value{VERSION})} + +You may download current version of MathGL for following configurations: +@itemize @bullet +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}.tar.gz,source} file with cmake build system. +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}-mingw.i686.7z,Win32 GPL} binaries for MinGW (build for i686) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}.LGPL-mingw.i686.7z,Win32 LGPL} binaries for MinGW (build for i686, no GSL and HDF5 support) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}.LGPL-win64.7z,Win64 LGPL} binaries for MSVS 2010 (no GSL and HDF5 support) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}-1.DevPack,DevPak} package for Dev-C++ or Code::Blocks (GPL version) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-@value{VERSION}.eng.pdf,PDF} documentation in English +@item +@uref{http://downloads.sourceforge.net/mathgl/mgl_scripts-@value{VERSION}.7z,utilities} with all required DLL files (build for i686) +@c HTML documentation in English +@c HTML documentation in Russian +@c @item +@c @uref{http://downloads.sourceforge.net/mathgl/mathgl_slides-1.9.pdf,PDF} slideshow of main features +@end itemize + +@strong{Previous version (v.1.11.2)} + +You may download current version of MathGL for following configurations: +@itemize @bullet +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-1.11.2.tar.gz,source} file with autoconf/automake script. +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-1.11.2-mingw.i686.zip,Win32 GPL} binaries for MinGW (build for i686) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-1.11.1.1.LGPL-mingw.i686.zip,Win32 LGPL} binaries for MinGW (build for i686, no GSL and HDF5 support) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-1.11.2-1.DevPack,DevPak} package for Dev-C++ or Code::Blocks (GPL version) +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl-1.11.2.eng.pdf,PDF} documentation in English +@c HTML documentation in English +@c HTML documentation in Russian +@item +@uref{http://downloads.sourceforge.net/mathgl/mathgl_slides-1.9.pdf,PDF} slideshow of main features +@end itemize + +@strong{Font files} + +There are a set of @uref{http://sourceforge.net/project/showfiles.php?group_id=152187&package_id=267177,font files} for MathGL with following typefaces. Note, that the set of glyphs can be less than in default font. As result not all TeX symbols can be displayed. +@itemize @bullet +@item +@uref{http://downloads.sourceforge.net/mathgl/STIX_font.tgz,STIX} font -- default font for MathGL. +@item +@uref{http://downloads.sourceforge.net/mathgl/adventor_font.tgz,Adventor font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} sansserif font based on the URW Gothic L family (like Avant Garde Gothic). +@item +@uref{http://downloads.sourceforge.net/mathgl/bonum_font.tgz,Bonum font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} serif font based on the URW Bookman L family. +@item +@uref{http://downloads.sourceforge.net/mathgl/chorus_font.tgz,Chorus font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} font based on the URW Chancery L Medium Italic. +@item +@uref{http://downloads.sourceforge.net/mathgl/cursor_font.tgz,Cursor font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} monospaced serif font based on the URW Nimbus Mono L (like Courier). +@item +@uref{http://downloads.sourceforge.net/mathgl/heros_font.tgz,Heros font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} sansserif font based on the URW Nimbus Sans L (like Helvetica). +@item +@uref{http://downloads.sourceforge.net/mathgl/heroscn_font.tgz,HerosCN font} -- the "compressed" version of previous one. +@item +@uref{http://downloads.sourceforge.net/mathgl/pagella_font.tgz,Pagella font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} serif font based on the URW Palladio L (like Palatino). +@item +@uref{http://downloads.sourceforge.net/mathgl/schola_font.tgz,Schola font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} serif fonts is based on the URW Century Schoolbook L. +@item +@uref{http://downloads.sourceforge.net/mathgl/termes_font.tgz,Termes font} -- the @uref{http://www.gust.org.pl/projects/e-foundry/tex-gyre/index_html,TeX Gyre} serif fonts is based on the Nimbus Roman No9 L (like Times). +@end itemize + +@external{} + +@node Other projects, , Download, Top +@section Other projects + +Except scientific (non public) projects I also have some general interest projects: +@itemize @bullet +@item +@uref{http://sourceforge.net/projects/pocketmk/, PocketMK} is small program for PocketPC which simulate famous Russian calculators MK-61 and slightly extend it. +@item +@uref{http://udav.sourceforge.net/,UDAV} is front-end for MGL scripts. It has windows interface for data viewing, changing and plotting. Also it can execute MGL scripts, setup and rotating graphics and so on. +@end itemize + +Also I recommend to look at: +@itemize @bullet +@item +@uref{http://englab.bugfest.net/,EngLab} is a cross-compile mathematical platform with a C like syntax intended to be used both by engineers and users with small programming knowledge. It is extremely scalable and allows users and the community to easily compile their own functions as shared objects. +@item +@uref{http://threedepict.sourceforge.net/,3Depict} is software for analysis of scientific datasets commonly encountered in atom probe tomography. You can manipulate, interact with and analyse point based datasets. +@item +@uref{http://www.sourceforge.net/projects/graphplot/,Graphplot} is function plotter based on MathGL. +@item +@uref{http://www.sourceforge.net/projects/graphplot/,OscillViewer} is oscilloscope monitoring program. Working with L-Card 14-140 AD-Convertor. Based on Qt and MathGL libraries. +@end itemize + +Finally, few links to free software and libraries: +@itemize @bullet +@item +@uref{http://www.thefreecountry.com/,thefreecountry.com} have a lot of Free Programmers', Webmasters' and Security Resources +@item +@uref{http://gnuwin32.sourceforge.net/,GnuWin} provides ports of tools with a GNU or similar open source license, to modern MS-Windows. +@item +@uref{http://loll.sourceforge.net/,LLoL} is project collecting, organising, classifying, and maintaining important URLs about Linux and the Open Source movement for all levels of Linux users. The LoLL project now has 4000+ links which are updated usually on a daily basis. +@end itemize + +@external{} + +@bye diff --git a/texinfo/web_ru.texi b/texinfo/web_ru.texi new file mode 100644 index 0000000..cc07e7e --- /dev/null +++ b/texinfo/web_ru.texi @@ -0,0 +1,623 @@ +@c ------------------------------------------------------------------ +@chapter Website +@nav{} + +@menu +* Main:: +* News:: +* Features:: +* Pictures:: +@c * MGL scripts:: +* Download:: +* Other projects:: +@end menu + +@external{} + +@node Main, News, , Website +@section MathGL is ... +@nav{} + +@ifhtml +@html +Surface in fog +@end html +@end ifhtml +@itemize @bullet +@item +a library for making high-quality scientific graphics under Linux and Windows; +@item +a library for the fast data plotting and data processing of large data arrays; +@item +a library for working in window and console modes and for easy embedding into other programs; +@item +a library with large and growing set of graphics. +@end itemize + +Now MathGL has more than 35000 lines of code, more than 55 general types of graphics for 1d, 2d and 3d data arrays, including special ones for chemical and statistical graphics. It can export graphics to raster and vector (EPS or SVG) formats. It has Qt, FLTK, OpenGL interfaces and can be used even from console programs. It has functions for data processing and script MGL language for simplification of data plotting. Also it has several types of transparency and smoothed lightning, vector fonts and TeX-like symbol parsing, arbitrary curvilinear coordinate system and many over useful things. It can be used from code written on C++/C/Fortran/Python/Octave and many other languages. Finally it is platform independent and free (under GPL v.2.0 license). + +There is a @uref{http://sourceforge.net/forum/?group_id=152187, forum} where you can ask a question or suggest an improvement. However the @uref{http://groups.google.com/group/mathgl, MathGL group} is preferable for quicker answer. + +For subscribing to @uref{http://groups.google.com/group/mathgl, MathGL group} you can use form below +@ifhtml +@html +
+Email: +
+@end html +@end ifhtml + +@strong{About LGPL and GPL licenses.} +Generally, MathGL is GPL library. However, you can use LGPL license for MathGL core and widgets if you don't use SWIG-based interfaces and disable GSL features. This can be done by using @code{lgpl} option at build time. According this, I've added the LGPL win32 binaries into @ref{Download} page. + +@strong{Latest news} +@itemize +@item @emph{19 March 2014.} +New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early, and documentation update. +@item @emph{10 March 2014.} +New version (v.@value{VERSION}@value{MINVER}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are extend of 'region' plot, improve export to TeX, add missing Fortran functions, bugfixes, and other improvements, which denoted @ref{News, here}. Note, this release looks as bug free, but next release (v.2.3) will introduce a set of improvements which may not so stable at first time. +@item @emph{22 January 2014.} +New version (v.@value{VERSION}) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are support of Qt5 and Pascal, improvements in JavaScript interface, bugfixes, and other improvements, which denoted @ref{News, here}. +@item @emph{11 November 2013.} +New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up, new plot kinds and data handling functions, new plot styles, masks for bitmap output, wx-widget, Lua interface, and many other improvements, which denoted @ref{News, here}. +@end itemize + +There is detailed @ref{News, news list}. Sourceforge project page @uref{http://sourceforge.net/projects/mathgl/, here}. + +@ifhtml +@html +DATADVANCE +@end html +@end ifhtml +Javascript interface was developed with support of @url{http://www.datadvance.net, DATADVANCE} company. + +@external{} + +@node News, Features, Main, Website +@section News +@nav{} + +@itemize +@item +@strong{19 March 2014.} +New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early. +New version (v.2.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are compatibility changes for MS VisualStudio 2010 and early. +@itemize @bullet +@item Compatibility changes for MS VisualStudio 2010 and early. +@item Function SetRange(v1,v2) ignore NAN values now. +@item Add enable-json-sample for building json-samples on demand only. +@item Update documentation. +@end itemize + +@item +@strong{10 March 2014.} +New version (v.2.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes: +@itemize @bullet +@item Add mgl_region_3d() to draw region (or ribbon) between 2 curves. Correspondingly extend mglGraph::Region() function and MGL command 'region'. +@item Allow LGPL for MathGL widgets. +@item Improve export to TeX. +@item Add missing functions to Fortran interface. +@item Bugfix for legend with enabled lighting. +@item Minor bugfixes and memory leaks. +@end itemize + +@item +@strong{22 January 2014.} +New version (v.2.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor improvements and bugfixes: +@itemize @bullet +@item Add Qt5 support. +@item Add Pascal interface. +@item Improve JavaScript interface. +@item Add function mglGraph::AddRange(char dir, mreal v1, mreal v2) and extend corresponding MGL commands '[xyzc]range'. +@item Add 'hypot(x,y)' function for known functions in formula parsing. +@item Add style '~' to disable colorbar or axis labels. NOTE, axis style '_' is obsolete and should be replaced by '~'. +@item Change Aspect() if Ax=NAN. Now, Ay and Az set the ratio to optimal aspect (not exact value as previously). +@item Disable changes by View(),Zoom(),Perspective() for position of Title(), Legend(), Colorbar(). +@item Partial support of perspective in CalcXYZ(). +@item Speed up PDE solving. +@item Add complex versions of PDE, QO2d, QO3d. +@item Correct filled background for Box() in curved coordinates. +@item Allow nx=1 for Stem and Error. +@item Bugfix for drawing single axis. +@item Bugfix for missing options parsing for some of MGL commands. +@item Bugfix for .pmin suffix in MGL. Add mglData::MaximalNeg() and mglData::MinimalPos() functions. Add .nmin and .nmax suffixes. +@item Bugfix for colorbar labels. +@item Force using python 2.7 by default due to bug in Ubuntu. Debian sid works well with python 3.* too. +@item Other minor bugfixes and memory leaks. +@end itemize + +@item +@strong{11 November 2013.} +New version (v.2.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Add OpenMP calls mostly everywhere (can work as replacement of pthreads - a bit faster since more loops is parallelized). +@item Greatly speed up consequent FFT and Hankel transforms. Add mgl_clear_fft() function for manual clearing of saved FFT/Hankel data. +@item Add @ref{ohlc} plot for drawing Open-High-Low-Close diagram +@item Add wxMathGL widget. See @ref{wxMathGL class}. +@item Add interface for Lua v.5.1. +@item Add @ref{mask} for face drawing if one of symbols @samp{-+=;oOsS~<>jdD*^} is specified in color scheme. This work only for export in bitmap images. +@item Add @ref{quality}=8 for dots drawing (extremely fast). +@item Add styles '4','6','8' for @ref{cone} and @ref{cones} to produce square, hex-, octo-prism. +@item Add style 't' for @ref{cones} to produce tubes (cylinders). +@item Add style '^' for @ref{legend} to left/right align legend if its coordinates are right/left from the center +@item Add style '<', '^', '>' for aligning/centering boxes in @ref{bars}, @ref{barh}, @ref{boxplot}, @ref{cones}. Also this plots become centered by default if nx sizes are the same for all data. +@item Add @ref{dots} function which set independently both color and transparency of dots. +@item Improve automatic axis position. Add style '^' for inverse automatic axis position. +@item Improve tick labeling. Add style @ref{tuneticks}&4 for zero filling of tick labels. +@item Add @ref{refill} for filling by interpolation of parametrically dependent data +@item Add transparency for @ref{area} and @ref{region} plots. +@item Add mgl_clf_chr() function and extend @ref{clf} command. +@item Fourier now perform true inverse Fourier transform (instead of backward one). +@item Improve/change lighting from local sources. Add @ref{diffuse} function. +@item C functions now return NULL if HMDT data cannot be created for given input argument(s). +@item Enable line width for @ref{mesh} and @ref{fall} plots. +@item Replace +INF and -INF by NAN in textual formula output. +@item Add manual compression of JSON. +@item Define WORDS_BIGENDIAN and HAVE_MEMRCHR (thanks to Dinar Valeev). +@item Bugfix for cleaning unused points. +@item Fix 'setsize' command at UDAV starting. +@item Rewrite MGL parsing by using std::wstring for avoiding possible bugs of wcs*() functions. +@item Minor bugfixes. +@item Update docs. +@end itemize + +@item +@strong{8 May 2013.} +New version (v.2.1.3.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Compatibility changes for MS VS. +@item Bugfixes for cmake options @code{enable-double=OFF, enable-zlib=OFF}. +@item Enable mouse actions for Firefox in JS sample. +@end itemize + +@item +@strong{2 May 2013.} +New version (v.2.1.3) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Functions @ref{sinfft}, @ref{cosfft}, @ref{hankel} and so on, become multi-threaded. +@item Use DFT instead of FFT if GSL support is disabled (much slow!). +@item Add Join() function for joining mglData arrays (see @ref{join}) +@item Add Roots() function for root finding of nonlinear equation (see @ref{roots}) +@item Add class mglExprC for parsing formula with complex numbers (see @ref{Evaluate expression}) +@item Correctly read #QNAN values in data files +@item Speed up @ref{dots} drawing +@item Add flag to disable tick labels at axis origin (see SetOriginTick()) +@item Add MGL commands @ref{origintick}, @ref{tickshift} +@item WriteJSON now use zlib if filename end at 'z' (like "test.jsonz") +@item Make separate libmgl-mpi +@item Add SetAutoRanges() function (duplicate corresponding options) +@item Add JSON sample usage via QtWebKit (thanks to DATADVANCE) +@item Bugfixes and memory leaks +@end itemize + +@item +@strong{28 January 2013.} +New version (v.2.1.2) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Exclude "local" functions from resulting library. +@item String in MGL script now can be concatenated with another string or data/numbers (like @samp{'max(u)=',u.max,' a.u.'}). +@item Bugfix for colors in 3D PDF. +@item Bugfix for drawing in MPI mode. +@item If Aspect() function have NAN argument(s) then it try to select optimal aspect ratio. +@item Option 'size' in Legend() now change only text size (not mark size). +@item Option 'meshnum' now influence on Boxs() and Belt() functions +@item Adjust marks drawing (line width and dots). +@item Minor improvements and bugfixes. +@end itemize + +@item +@strong{24 December 2012.} +New version (v.2.1.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are minor bugfixes and improvements: +@itemize @bullet +@item Bugfix for SetRange(val,val) function +@item Exclude export MGL to CPP +@item MGL parsing now produce errors for any wrong list of arguments +@item Add help message to mgl.cgi +@item Improve text rotation at View() +@item Make compatible with GIF library v.5.0. +@item Bugfix for making MPI interface. +@item Bugfix for running in Win32 mode. +@item Update docs and MGL samples +@end itemize + +@item +@strong{13 December 2012.} +New version (v.2.1) of @uref{http://sourceforge.net/projects/mathgl, MathGL} is released. There are speeding up and many improvements and bugfixes: +@itemize @bullet +@item +Add class mglDataC for complex data arrays. +@item +Add Vect3() plot for drawing vectors on slice of 3d vector field. See @ref{Vect3 sample}. +@item +Add Table() function for drawing table with data values. See @ref{Table sample}. +@item +Add ZoomAxis() for zooming/shifting axis range as whole. +@item +Add WriteJSON() function for exporting in JSON format suitable for later drawing by JavaScript +@item +Add JavaScript code for visualizing JSON data. See @uref{../json.html, samples}. +@item +Add mgl.cgi tool which return PNG image for CGI request in form of MGL script. +@item +Add mglData::Solve() for finding x-value where dat(x)=val. See @ref{Solve sample}. +@item +Add mglData::Clean() for removing rows with duplicate values for given column. +@item +Add MGL commands 'errbox', 'face' + +@item +Color can be specified as its RGB[A] values, i.e. like @samp{@{xFFFFFF@}} or @samp{@{xFFFFFFFF@}}. See @ref{Line styles}. +@item +Color in color scheme may have position in range [0,1]. Format is @samp{@{CN,pos@}} or @samp{@{xFFFFFF,pos@}}. See @ref{Color scheme}. +@item +Now pen width for marks is proportional to pen width of line multiplied by size of marks. +@item +Now you can use different font-faces in the plot simultaneously. See @ref{Text features}. +@item +Now Legend() automatically use several columns if it contain too many legend entries. +@item +Add style '-' for legend for drawing them horizontally. See @ref{Legend sample}. +@item +Vectors is drawn now even if only starting or ending points are placed in bounding box. +@item +Strongly rewrite the algorithm of vector field plotting. + +@item +Grid lines for NAN origin values are always located at far-away edges. +@item +Try correctly place axis and tick labels even for axis with inverse range (i.e. for v2} and have only 2 methods: +@verbatim +class mglDraw +{ +public: + virtual int Draw(mglGraph *) { return 0; }; + virtual void Reload() {}; +}; +@end verbatim +You should inherit yours class from @code{mglDraw} and re-implement one or both functions for drawing. + +@menu +* mglWindow class:: +* Fl_MathGL class:: +* QMathGL class:: +* wxMathGL class:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node mglWindow class, Fl_MathGL class, , Widget classes +@section mglWindow class +@nav{} +@cindex mglWindow +@cindex window +@c @cindex mglDraw + +This class is derived from mglGraph class (see @ref{MathGL core}). It is defined in @code{#include } and provide methods for handling window with MathGL graphics. Similar classes are exist for QT and FLTK widget libraries: @code{mglQT} in @code{#include }, @code{mglFLTK} in @code{#include }. + +@deftypefn {Constructor on @code{mglWindow}} {} mglWindow (@code{const char *}title=@code{"MathGL"}) +@deftypefnx {Constructor on @code{mglWindow}} {} mglWindow (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title=@code{"MathGL"}, @code{void *}par=@code{NULL}, @code{int} kind=@code{0}, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)=0) +@deftypefnx {Constructor on @code{mglWindow}} {} mglWindow (@code{int} (*draw)(@code{mglGraph *}gr), @code{const char *}title=@code{"MathGL"}, @code{int} kind=@code{0}) +@deftypefnx {Constructor on @code{mglWindow}} {} mglWindow (@code{mglDraw *}draw, @code{const char *}title=@code{"MathGL"}, @code{int} kind=@code{0}) +@deftypefnx {C function} @code{HMGL} mgl_create_graph_qt (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {C function} @code{HMGL} mgl_create_graph_fltk (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {C function} @code{HMGL} mgl_create_graph_glut (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) + +Creates a window for plotting. Parameter @var{draw} sets a pointer to drawing function (this is the name of function) or instance of @code{mglDraw} class. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Note, that @var{draw} can be @code{NULL} for displaying static bitmaps only (no animation or slides). Parameter @var{title} sets the title of the window. Parameter @var{par} contains pointer to data for the plotting function @var{draw}. Parameter @var{kind} may have following values: @samp{0} -- use FLTK window, @samp{1} -- use Qt window. + +There are some keys handles for manipulating by the plot: 'a', 'd', 'w', 's' for the rotating; ',', '.' for viewing of the previous or next frames in the list; 'r' for the switching of transparency; 'f' for the switching of lightning; 'x' for hiding (closing) the window. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{int} RunThr () +@deftypefnx {C function} @code{int} mgl_fltk_thr () +Run main loop for event handling in separate thread. Note, right now it work for FLTK windows only. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{int} Run () +@deftypefnx {C function} @code{int} mgl_qt_run () +@deftypefnx {C function} @code{int} mgl_fltk_run () +Run main loop for event handling. Usually it should be called in a separate thread or as last function call in @code{main()}. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{void} SetClickFunc (@code{void} (*func)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {C function} @code{void} mgl_set_click_func (@code{void} (*func)(@code{HMGL} gr, @code{void *}p)) +Set callback function @code{func} which will be called on mouse click. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{void} ToggleAlpha () +@deftypefnx {C function} @code{void} mgl_wnd_toggle_alpha (@code{HMGL} gr) +Switch on/off transparency but do not overwrite switches in user drawing function. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} ToggleLight () +@deftypefnx {C function} @code{void} mgl_wnd_toggle_light (@code{HMGL} gr) +Switch on/off lighting but do not overwrite switches in user drawing function. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} ToggleRotate () +@deftypefnx {C function} @code{void} mgl_wnd_toggle_rotate (@code{HMGL} gr) +Switch on/off rotation by mouse. Usually, left button is used for rotation, middle button for shift, right button for zoom/perspective. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} ToggleZoom () +@deftypefnx {C function} @code{void} mgl_wnd_toggle_zoom (@code{HMGL} gr) +Switch on/off zooming by mouse. Just select rectangular region by mouse and it will be zoomed in. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} ToggleNo () +@deftypefnx {C function} @code{void} mgl_wnd_toggle_no (@code{HMGL} gr) +Switch off all zooming and rotation and restore initial state. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} Update () +@deftypefnx {C function} @code{void} mgl_wnd_update (@code{HMGL} gr) +Update window contents. This is very useful function for manual updating the plot while long calculation was running in parallel thread. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} ReLoad () +@deftypefnx {C function} @code{void} mgl_wnd_reload (@code{HMGL} gr) +Reload user data and update picture. This function also update number of frames which drawing function can create. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} Adjust () +@deftypefnx {C function} @code{void} mgl_wnd_adjust (@code{HMGL} gr) +Adjust size of bitmap to window size. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} NextFrame () +@deftypefnx {C function} @code{void} mgl_wnd_next_frame (@code{HMGL} gr) +Show next frame if one. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} PrevFrame () +@deftypefnx {C function} @code{void} mgl_wnd_prev_frame (@code{HMGL} gr) +Show previous frame if one. +@end deftypefn +@deftypefn {Method on @code{mglWindow}} @code{void} Animation () +@deftypefnx {C function} @code{void} mgl_wnd_animation (@code{HMGL} gr) +Run/stop slideshow (animation) of frames. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{void} SetDelay (@code{double} dt) +@deftypefnx {C function} @code{void} mgl_wnd_set_delay (@code{HMGL} gr, @code{double} dt) +Sets delay for animation in seconds. Default value is 1 sec. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{double} GetDelay () +@deftypefnx {C function} @code{double} mgl_wnd_get_delay (@code{HMGL} gr) +Gets delay for animation in seconds. +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{void} Setup (@code{bool} clfupd=@code{true}, @code{bool} showpos=@code{false}) +@deftypefnx {C function} @code{void} mgl_setup_window (@code{HMGL} gr, @code{bool} clfupd, @code{bool} showpos) +Enable/disable flags for: +@itemize @bullet +@item +clearing plot before Update(); +@item +showing the last mouse click position in the widget. +@end itemize +@end deftypefn + +@deftypefn {Method on @code{mglWindow}} @code{mglPoint} LastMousePos () +@deftypefnx {C function} @code{void} mgl_get_last_mouse_pos (@code{HMGL} gr, @code{mreal *}x, @code{mreal *}y, @code{mreal *}z) +Gets last position of mouse click. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Fl_MathGL class, QMathGL class, mglWindow class, Widget classes +@section Fl_MathGL class +@nav{} +@cindex Fl_MathGL +@cindex widgets + +Class is FLTK widget which display MathGL graphics. It is defined in @code{#include }. + +@fig{fltk, Example of FLTK window with MathGL plot.} + +@deftypemethod Fl_MathGL @code{void} set_draw (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p)) +@deftypemethodx Fl_MathGL @code{void} set_draw (@code{int} (*draw)(@code{mglGraph *}gr)) +@deftypemethodx Fl_MathGL @code{void} set_draw (@code{mglDraw *}draw) +Sets drawing function as global function or as one from a class @code{mglDraw}. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Parameter @var{par} contains pointer to data for the plotting function @var{draw}. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} update () +Update (redraw) plot. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_angle (@code{mreal} t, @code{mreal} p) +Set angles for additional plot rotation +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_flag (@code{int} f) +Set bitwise flags for general state (1-Alpha, 2-Light) +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_state (@code{bool} r, @code{bool} z) +Set flags for handling mouse: +@var{z}=@code{true} allow zooming, +@var{r}=@code{true} allow rotation/shifting/perspective and so on. +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_zoom (@code{mreal} X1, @code{mreal} Y1, @code{mreal} X2, @code{mreal} Y2) +Set zoom in/out region +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} get_zoom (@code{mreal *}X1, @code{mreal *}Y1, @code{mreal *}X2, @code{mreal *}Y2) +Get zoom in/out region +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_popup (@code{const Fl_Menu_Item *}pmenu, @code{Fl_Widget *}w, @code{void *}v) +Set popup menu pointer +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_graph (@code{HMGL} gr) +@deftypemethodx Fl_MathGL @code{void} set_graph (@code{mglGraph *}gr) +Set new grapher instead of built-in one. Note that Fl_MathGL will automatically delete this object at destruction or at new @code{set_graph()} call. +@end deftypemethod +@deftypemethod Fl_MathGL @code{HMGL} get_graph () +Get pointer to grapher. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} adjust () +Adjust image size to fit whole widget. +@end deftypemethod + +@deftypecv {Fl_MathGL option} Fl_MathGL @code{Fl_Valuator *} tet_val +Pointer to external tet-angle validator. +@end deftypecv +@deftypecv {Fl_MathGL option} Fl_MathGL @code{Fl_Valuator *} phi_val +Pointer to external phi-angle validator. +@end deftypecv + +@c ------------------------------------------------------------------ +@external{} +@node QMathGL class, wxMathGL class, Fl_MathGL class, Widget classes +@section QMathGL class +@nav{} +@cindex QMathGL +@cindex widgets + +Class is Qt widget which display MathGL graphics. It is defined in @code{#include }. + +@fig{qt, Example of Qt window with MathGL plot.} + +@deftypemethod QMathGL @code{void} setDraw (@code{mglDraw *}dr) +Sets drawing functions from a class inherited from @code{mglDraw}. +@end deftypemethod +@deftypemethod QMathGL @code{void} setDraw (@code{int (*}draw@code{)(mglBase *}gr, @code{void *}p@code{)}, @code{void *}par=@code{NULL}) +@deftypemethodx QMathGL @code{void} setDraw (@code{int (*}draw@code{)(mglGraph *}gr@code{)}) +Sets the drawing function @var{draw}. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Parameter @var{par} contains pointer to data for the plotting function @var{draw}. +@end deftypemethod + +@deftypemethod QMathGL @code{void} setGraph (@code{HMGL} gr) +@deftypemethodx QMathGL @code{void} setGraph (@code{mglGraph *}gr) +Set pointer to external grapher (instead of built-in one). Note that QMathGL will automatically delete this object at destruction or at new @code{setGraph()} call. +@end deftypemethod +@deftypemethod QMathGL @code{HMGL} getGraph () +Get pointer to grapher. +@end deftypemethod + +@deftypemethod QMathGL @code{void} setPopup (@code{QMenu *}p) +Set popup menu pointer. +@end deftypemethod +@deftypemethod QMathGL @code{void} setSize (@code{int} w, @code{int} h) +Set widget/picture sizes +@end deftypemethod +@deftypemethod QMathGL @code{double} getRatio () +Return aspect ratio of the picture. +@end deftypemethod + +@deftypemethod QMathGL @code{int} getPer () +Get perspective value in percents. +@end deftypemethod +@deftypemethod QMathGL @code{int} getPhi () +Get Phi-angle value in degrees. +@end deftypemethod +@deftypemethod QMathGL @code{int} getTet () +Get Theta-angle value in degrees. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getAlpha () +Get transparency state. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getLight () +Get lightning state. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getZoom () +Get mouse zooming state. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getRotate () +Get mouse rotation state. +@end deftypemethod + + +@deftypefn {Slot on @code{QMathGL}} @code{void} refresh () +Redraw saved bitmap without executing drawing function. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} update () +Update picture by executing drawing function. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} copy () +Copy graphics to clipboard. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} copyClickCoor () +Copy coordinates of click (as text). +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} print () +Print current picture. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} stop () +Send signal to stop drawing. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} adjust () +Adjust image size to fit whole widget. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} nextSlide () +Show next slide. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} prevSlide () +Show previous slide. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} animation (@code{bool} st=@code{true}) +Start/stop animation. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} setPer (@code{int} val) +Set perspective value. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setPhi (@code{int} val) +Set Phi-angle value. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setTet (@code{int} val) +Set Theta-angle value. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setAlpha (@code{bool} val) +Switch on/off transparency. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setLight (@code{bool} val) +Switch on/off lightning. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setGrid (@code{bool} val) +Switch on/off drawing of grid for absolute coordinates. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setZoom (@code{bool} val) +Switch on/off mouse zooming. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setRotate (@code{bool} val) +Switch on/off mouse rotation. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} zoomIn () +Zoom in graphics. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} zoomOut () +Zoom out graphics. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftLeft () +Shift graphics to left direction. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftRight () +Shift graphics to right direction. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftUp () +Shift graphics to up direction. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftDown () +Shift graphics to down direction. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} restore () +Restore zoom and rotation to default values. +@end deftypefn +@c @deftypefn {Slot on @code{QMathGL}} @code{void} reload () +@c Reload data and redraw graphics. +@c @end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportPNG (@code{QString} fname=@code{""}) +Export current picture to PNG file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportPNGs (@code{QString} fname=@code{""}) +Export current picture to PNG file (no transparency). +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportJPG (@code{QString} fname=@code{""}) +Export current picture to JPEG file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportBPS (@code{QString} fname=@code{""}) +Export current picture to bitmap EPS file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportEPS (@code{QString} fname=@code{""}) +Export current picture to vector EPS file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportSVG (@code{QString} fname=@code{""}) +Export current picture to SVG file. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportGIF (@code{QString} fname=@code{""}) +Export current picture to GIF file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportTEX (@code{QString} fname=@code{""}) +Export current picture to LaTeX/Tikz file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportTGA (@code{QString} fname=@code{""}) +Export current picture to TGA file. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportXYZ (@code{QString} fname=@code{""}) +Export current picture to XYZ/XYZL/XYZF file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportOBJ (@code{QString} fname=@code{""}) +Export current picture to OBJ/MTL file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportSTL (@code{QString} fname=@code{""}) +Export current picture to STL file. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportOFF (@code{QString} fname=@code{""}) +Export current picture to OFF file. +@end deftypefn +@c @deftypefn {Slot on @code{QMathGL}} @code{void} exportX3D (@code{QString} fname=@code{""}) +@c Export current picture to X3D file. +@c @end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void}setUsePrimitives (@code{bool} use) +Enable using list of primitives for frames. This allows frames transformation/zoom but requires much more memory. Default value is @code{true}. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setMGLFont (@code{QString} path) +Restore (@var{path}=@code{""}) or load font for graphics. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} about () +Show about information. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} aboutQt () +Show information about Qt version. +@end deftypefn + +@deftypefn {Signal on @code{QMathGL}} @code{void} phiChanged (@code{int} val) +Phi angle changed (by mouse or by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} tetChanged (@code{int} val) +Tet angle changed (by mouse or by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} perChanged (@code{int} val) +Perspective changed (by mouse or by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} alphaChanged (@code{bool} val) +Transparency changed (by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} lightChanged (@code{bool} val) +Lighting changed (by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} gridChanged (@code{bool} val) +Grid drawing changed (by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} zoomChanged (@code{bool} val) +Zooming changed (by toolbar). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} rotateChanged (@code{bool} val) +Rotation changed (by toolbar). +@end deftypefn + +@deftypefn {Signal on @code{QMathGL}} @code{void} mouseClick (@code{mreal} x, @code{mreal} y, @code{mreal} z) +Mouse click take place at position @{x,y,z@}. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} frameChanged (@code{int} val) +Need another frame to show. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} showWarn (@code{QString} warn) +Need to show warning. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} posChanged (@code{QString} pos) +Position of mouse click is changed. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} objChanged (@code{int} id) +Object id is changed (due to mouse click). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} refreshData () +Data can be changed (drawing is finished). +@end deftypefn + + +@deftypecv {QMathGL option} QMathGL @code{QString} appName +Application name for message boxes. +@end deftypecv +@deftypecv {QMathGL option} QMathGL @code{bool} autoResize +Allow auto resizing (default is false). +@end deftypecv + +@c ------------------------------------------------------------------ +@external{} +@node wxMathGL class, , QMathGL class, Widget classes +@section wxMathGL class +@nav{} +@cindex wxMathGL +@cindex widgets + +Class is WX widget which display MathGL graphics. It is defined in @code{#include }. + +@deftypemethod wxMathGL @code{void} SetDraw (@code{mglDraw *}dr) +Sets drawing functions from a class inherited from @code{mglDraw}. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetDraw (@code{int (*}draw@code{)(mglBase *}gr, @code{void *}p@code{)}, @code{void *}par=@code{NULL}) +@deftypemethodx wxMathGL @code{void} SetDraw (@code{int (*}draw@code{)(mglGraph *}gr@code{)}) +Sets the drawing function @var{draw}. There is support of a list of plots (frames). So as one can prepare a set of frames at first and redraw it fast later (but it requires more memory). Function should return positive number of frames for the list or zero if it will plot directly. Parameter @var{par} contains pointer to data for the plotting function @var{draw}. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetGraph (@code{HMGL} gr) +@deftypemethodx wxMathGL @code{void} SetGraph (@code{mglGraph *}gr) +Set pointer to external grapher (instead of built-in one). Note that wxMathGL will automatically delete this object at destruction or at new @code{setGraph()} call. +@end deftypemethod +@deftypemethod wxMathGL @code{HMGL} GetGraph () +Get pointer to grapher. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetPopup (@code{wxMenu *}p) +Set popup menu pointer. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetSize (@code{int} w, @code{int} h) +Set widget/picture sizes +@end deftypemethod +@deftypemethod wxMathGL @code{double} GetRatio () +Return aspect ratio of the picture. +@end deftypemethod + +@deftypemethod wxMathGL @code{int} GetPer () +Get perspective value in percents. +@end deftypemethod +@deftypemethod wxMathGL @code{int} GetPhi () +Get Phi-angle value in degrees. +@end deftypemethod +@deftypemethod wxMathGL @code{int} GetTet () +Get Theta-angle value in degrees. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetAlpha () +Get transparency state. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetLight () +Get lightning state. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetZoom () +Get mouse zooming state. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetRotate () +Get mouse rotation state. +@end deftypemethod + + +@deftypemethod wxMathGL @code{void} Repaint () +Redraw saved bitmap without executing drawing function. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Update () +Update picture by executing drawing function. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Copy () +Copy graphics to clipboard. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Print () +Print current picture. +@end deftypemethod + +@comment @deftypemethod wxMathGL @code{void} Stop () +@comment Send signal to stop drawing. +@comment @end deftypemethod +@deftypemethod wxMathGL @code{void} Adjust () +Adjust image size to fit whole widget. +@end deftypemethod +@deftypemethod wxMathGL @code{void} NextSlide () +Show next slide. +@end deftypemethod +@deftypemethod wxMathGL @code{void} PrevSlide () +Show previous slide. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Animation (@code{bool} st=@code{true}) +Start/stop animation. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetPer (@code{int} val) +Set perspective value. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetPhi (@code{int} val) +Set Phi-angle value. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetTet (@code{int} val) +Set Theta-angle value. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetAlpha (@code{bool} val) +Switch on/off transparency. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetLight (@code{bool} val) +Switch on/off lightning. +@end deftypemethod +@comment @deftypemethod wxMathGL @code{void} SetGrid (@code{bool} val) +@comment Switch on/off drawing of grid for absolute coordinates. +@comment @end deftypemethod +@deftypemethod wxMathGL @code{void} SetZoom (@code{bool} val) +Switch on/off mouse zooming. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetRotate (@code{bool} val) +Switch on/off mouse rotation. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ZoomIn () +Zoom in graphics. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ZoomOut () +Zoom out graphics. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftLeft () +Shift graphics to left direction. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftRight () +Shift graphics to right direction. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftUp () +Shift graphics to up direction. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftDown () +Shift graphics to down direction. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Restore () +Restore zoom and rotation to default values. +@end deftypemethod +@c @deftypemethod wxMathGL @code{void} reload () +@c Reload data and redraw graphics. +@c @end deftypemethod + +@deftypemethod wxMathGL @code{void} About () +Show about information. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} ExportPNG (@code{QString} fname=@code{""}) +Export current picture to PNG file. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportPNGs (@code{QString} fname=@code{""}) +Export current picture to PNG file (no transparency). +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportJPG (@code{QString} fname=@code{""}) +Export current picture to JPEG file. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportBPS (@code{QString} fname=@code{""}) +Export current picture to bitmap EPS file. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportEPS (@code{QString} fname=@code{""}) +Export current picture to vector EPS file. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportSVG (@code{QString} fname=@code{""}) +Export current picture to SVG file. +@end deftypemethod + +@external{} + diff --git a/texinfo/widget_ru.texi b/texinfo/widget_ru.texi new file mode 100644 index 0000000..e00998c --- /dev/null +++ b/texinfo/widget_ru.texi @@ -0,0 +1,623 @@ + +@c ------------------------------------------------------------------ +@chapter ``Оконные'' классы +@nav{} +@cindex mglWindow +@cindex mglGLUT +@cindex Fl_MathGL +@cindex QMathGL +@cindex window +@cindex widgets + +Есть целый набор ``оконных'' классов для создания окон с графикой MathGL: @code{mglWindow} и @code{mglGLUT} для окон целиком, @code{Fl_MathGL} и @code{QMathGL} для виджетов. Все эти классы позволяют пользователю просмотривать, вращать, экспортировать рисунок. Большинство из них (кроме @code{mglGLUT}) имеют панель инструментов для упрощения изменения графика. Все оконные классы имеют схожий набор функций. Ниже приведен список классов с краткими комментариями. + +Для рисования можно использовать: указатель @code{NULL} если планируется обновлять график вручную, глобальную функцию типа @code{int draw(@code{HMGL} gr, @code{void *}p)} или @code{int draw(@code{mglGraph *}gr)}, или экземпляр класса, производного от @code{mglDraw}. Этот класс определен в @code{#include } и имеет только 2 метода: +@verbatim +class mglDraw +{ +public: + virtual int Draw(mglGraph *) { return 0; }; + virtual void Reload() {}; +}; +@end verbatim +Вам следует наследовать свой класс от @code{mglDraw} и определить один или оба метода. + +@menu +* mglWindow class:: +* Fl_MathGL class:: +* QMathGL class:: +* wxMathGL class:: +@end menu + + +@c ------------------------------------------------------------------ +@external{} +@node mglWindow class, Fl_MathGL class, , Widget classes +@section Класс mglWindow +@nav{} +@cindex mglWindow +@cindex window +@c @cindex mglDraw + +Этот класс производный от класса mglGraph (см. @ref{MathGL core}). Он определен в @code{#include }. Класс содержит методы для создания и управления окном, содержащим графику MathGL. Похожий набор классов существует отдельно для каждой библиотеки виджетов: @code{mglQT} в @code{#include }, @code{mglFLTK} в @code{#include }. + +@deftypefn {Конструктор класса @code{mglWindow}} {} mglWindow (@code{const char *}title=@code{"MathGL"}) +@deftypefnx {Конструктор класса @code{mglWindow}} {} mglWindow (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title=@code{"MathGL"}, @code{void *}par=@code{NULL}, @code{int} kind=@code{0}, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)=0) +@deftypefnx {Конструктор класса @code{mglWindow}} {} mglWindow (@code{int} (*draw)(@code{mglGraph *}gr), @code{const char *}title=@code{"MathGL"}, @code{int} kind=@code{0}) +@deftypefnx {Конструктор класса @code{mglWindow}} {} mglWindow (@code{mglDraw *}draw, @code{const char *}title=@code{"MathGL"}, @code{int} kind=@code{0}) +@deftypefnx {Функция С} @code{HMGL} mgl_create_graph_qt (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {Функция С} @code{HMGL} mgl_create_graph_fltk (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {Функция С} @code{HMGL} mgl_create_graph_glut (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p), @code{const char *}title, @code{void *}par, @code{void} (*reload)(@code{HMGL} gr, @code{void *}p)) + +Создает окно для вывода графика. Параметр @var{draw} -- указатель (имя) функции рисования. Есть возможность создания нескольких кадров вначале (требует больше памяти) и их быстрая анимации в дальнейшем. В этом случае функция @var{draw} должна возвращать число кадров или ноль для рисования по запросу. Замечу, что @var{draw} может быть равна @code{NULL} для отображения статической (текущей) картинки. Параметр @var{title} задает заголовок окна. Параметр @var{par} содержит указатель на данные, передаваемые функции рисования @var{draw}. Параметр @var{kind} может иметь следующие значения: @samp{0} -- использовать окно FLTK, @samp{1} -- использовать окно Qt. + +В окне просмотра можно использовать клавиши: 'a', 'd', 'w', 's' для вращения; ',', '.' для просмотра предыдущего и следующего кадров; 'r' для переключения прозрачности; 'f' для переключения оспещенности; 'x' для закрытия окна. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{int} RunThr () +@deftypefnx {Функция С} @code{int} mgl_fltk_thr () +Запускает цикл обработки сообщений в отдельном потоке. В данный момент работает только для окон FLTK. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{int} Run () +@deftypefnx {Функция С} @code{int} mgl_qt_run () +@deftypefnx {Функция С} @code{int} mgl_fltk_run () +Запускает цикл обработки сообщений. Обычно эта функция должна вызываться в отдельном потоке или последней функцией в @code{main()}. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{void} SetClickFunc (@code{void} (*func)(@code{HMGL} gr, @code{void *}p)) +@deftypefnx {Функция С} @code{void} mgl_set_click_func (@code{void} (*func)(@code{HMGL} gr, @code{void *}p)) +Устанавливает функцию, которая будет вызвана при щелчке мышью. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{void} ToggleAlpha () +@deftypefnx {Функция С} @code{void} mgl_wnd_toggle_alpha (@code{HMGL} gr) +Включает/выключает прозрачность, но не перекрывает ее включение в пользовательской функции рисования. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} ToggleLight () +@deftypefnx {Функция С} @code{void} mgl_wnd_toggle_light (@code{HMGL} gr) +Включает/выключает освещение, но не перекрывает его включение в пользовательской функции рисования. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} ToggleRotate () +@deftypefnx {Функция С} @code{void} mgl_wnd_toggle_rotate (@code{HMGL} gr) +Включает/выключает вращение мышкой. Нажатая левая кнопка используется для вращения, средняя для сдвига, правая для приближения/перспективы. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} ToggleZoom () +@deftypefnx {Функция С} @code{void} mgl_wnd_toggle_zoom (@code{HMGL} gr) +Включает/выключает приближение мышкой. Выделите прямоугольную область и она будет приближена. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} ToggleNo () +@deftypefnx {Функция С} @code{void} mgl_wnd_toggle_no (@code{HMGL} gr) +Выключает вращение и приближение мышкой, а также восстанавливает исходный вид графика. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} Update () +@deftypefnx {Функция С} @code{void} mgl_wnd_update (@code{HMGL} gr) +Обновляет содержимое окна. Функция полезна при ручном обновлении содержимого, пока долгий расчет идет в параллельном потоке. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} ReLoad () +@deftypefnx {Функция С} @code{void} mgl_wnd_reload (@code{HMGL} gr) +Перегружает данные и обновляет рисунок. Функция также обновляет число кадров, которое создает функция рисования. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} Adjust () +@deftypefnx {Функция С} @code{void} mgl_wnd_adjust (@code{HMGL} gr) +Подгоняет размер рисунка под размер окна. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} NextFrame () +@deftypefnx {Функция С} @code{void} mgl_wnd_next_frame (@code{HMGL} gr) +Показывает следующий кадр, если он есть. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} PrevFrame () +@deftypefnx {Функция С} @code{void} mgl_wnd_prev_frame (@code{HMGL} gr) +Показывает предыдущий кадр, если он есть. +@end deftypefn +@deftypefn {Метод класса @code{mglWindow}} @code{void} Animation () +@deftypefnx {Функция С} @code{void} mgl_wnd_animation (@code{HMGL} gr) +Запускает/останавливает анимацию кадров. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{void} SetDelay (@code{double} dt) +@deftypefnx {Функция С} @code{void} mgl_wnd_set_delay (@code{HMGL} gr, @code{double} dt) +Задает задержку при анимации в секундах. По умолчанию интервал -- 1 секунда. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{double} GetDelay () +@deftypefnx {Функция С} @code{double} mgl_wnd_get_delay (@code{HMGL} gr) +Возвращает задержку при анимации в секундах. +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{void} Setup (@code{bool} clfupd=@code{true}, @code{bool} showpos=@code{false}) +@deftypefnx {Функция С} @code{void} mgl_setup_window (@code{HMGL} gr, @code{bool} clfupd, @code{bool} showpos) +Включает/выключает: +@itemize @bullet +@item +очистку рисунка перед Update(); +@item +показ позиции щелчка мыши на рисунке. +@end itemize +@end deftypefn + +@deftypefn {Метод класса @code{mglWindow}} @code{mglPoint} LastMousePos () +@deftypefnx {Функция С} @code{void} mgl_get_last_mouse_pos (@code{HMGL} gr, @code{mreal *}x, @code{mreal *}y, @code{mreal *}z) +Возвращает положение щелчка мыши. +@end deftypefn + +@c ------------------------------------------------------------------ +@external{} +@node Fl_MathGL class, QMathGL class, mglWindow class, Widget classes +@section Класс Fl_MathGL +@nav{} +@cindex Fl_MathGL +@cindex widgets + +Класс реализует элемент интерфейса FLTK для отображения графики MathGL. Он определен в @code{#include }. + +@fig{fltk, Пример окна FLTK с графикой MathGL.} + +@deftypemethod Fl_MathGL @code{void} set_draw (@code{int} (*draw)(@code{HMGL} gr, @code{void *}p)) +@deftypemethodx Fl_MathGL @code{void} set_draw (@code{int} (*draw)(@code{mglGraph *}gr)) +@deftypemethodx Fl_MathGL @code{void} set_draw (@code{mglDraw *}draw) +Устанавливает функцию рисования как глобальную функцию или как функцию член класса, производного от @code{mglDraw}. Поддерживается список графиков (кадров), так что можно вначале их нарисовать (требует довольно много памяти), а потом достаточно быстро отображать. Функция должна возвращать положительное число создаваемых кадров или ноль для непосредственного рисования. Параметр @var{par} содержит указатель на данные пользователя, передаваемый функции рисования @var{draw}. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} update () +Обновляет (перерисовывает) график. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_angle (@code{mreal} t, @code{mreal} p) +Задает углы для дополнительного вращения графика. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_flag (@code{int} f) +Задает битовые флаги для: 1 - прозрачности, 2 - освещения. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} set_state (@code{bool} z, @code{bool} r) +Задает флаги обработки движений мыши: @var{z}=@code{true} -- разрешает приближение выделения, @var{r}=@code{true} разрешает вращение/сдвиг/приближение/перспективу. +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_zoom (@code{mreal} X1, @code{mreal} Y1, @code{mreal} X2, @code{mreal} Y2) +Задает область приближения. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} get_zoom (@code{mreal *}X1, @code{mreal *}Y1, @code{mreal *}X2, @code{mreal *}Y2) +Возвращает область приближения. +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_popup (@code{const Fl_Menu_Item *}pmenu, @code{Fl_Widget *}w, @code{void *}v) +Задает указатель на всплывающее меню. +@end deftypemethod + +@deftypemethod Fl_MathGL @code{void} set_graph (@code{mglCanvas *}gr) +@deftypemethodx Fl_MathGL @code{void} set_graph (@code{mglGraph *}gr) +Задает экземпляр класс для рисования вместо встроеного. Fl_MathGL автоматически удалит его при удалении виджета и при новом вызове @code{set_graph()}. +@end deftypemethod +@deftypemethod Fl_MathGL @code{mglGraph *} get_graph () +Возвращает указатель на объект, строящий графики. +@end deftypemethod +@deftypemethod Fl_MathGL @code{void} adjust () +Подгоняет размер картинки под размер окна. +@end deftypemethod + +@deftypecv {Widget option} Fl_MathGL @code{Fl_Valuator *} tet_val +Указатель на внешний элемент управления для изменения угла tet. +@end deftypecv +@deftypecv {Widget option} Fl_MathGL @code{Fl_Valuator *} phi_val +Указатель на внешний элемент управления для изменения угла phi. +@end deftypecv + +@c ------------------------------------------------------------------ +@external{} +@node QMathGL class, wxMathGL class, Fl_MathGL class, Widget classes +@section Класс QMathGL +@nav{} +@cindex QMathGL +@cindex widgets + +Класс реализует элемент интерфейса Qt для отображения графики MathGL. Он определен в @code{#include }. + +@fig{qt, Пример окна Qt с графикой MathGL.} + +@deftypemethod QMathGL @code{void} setDraw (@code{mglDraw *}dr) +Задает функцию рисования из класса производного от @code{mglDraw}. +@end deftypemethod +@deftypemethod QMathGL @code{void} setDraw (@code{int (*}draw@code{)(mglBase *}gr, @code{void *}p@code{)}, @code{void *}par=@code{NULL}) +@deftypemethodx QMathGL @code{void} setDraw (@code{int (*}draw@code{)(mglGraph *}gr@code{)}) +Задает функцию рисования @var{draw}. Поддерживается список графиков (кадров), так что можно вначале их нарисовать (требует довольно много памяти), а потом достаточно быстро отображать. Функция должна возвращать положительное число создаваемых кадров или ноль для непосредственного рисования. Параметр @var{par} содержит указатель на данные пользователя, передаваемый функции рисования @var{draw}. +@end deftypemethod + +@deftypemethod QMathGL @code{void} setGraph (@code{mglCanvas *}gr) +@deftypemethodx QMathGL @code{void} setGraph (@code{mglGraph *}gr) +Устанавливает указатель на внешний экземпляр класса для рисования (вместо встроенного). Отмечу, что QMathGL автоматически удалит этот объект при удалении элемента интерфейса или при новом вызове @code{setGraph()}. +@end deftypemethod +@deftypemethod QMathGL @code{HMGL} getGraph () +Возвращает указатель на объект, строящий графики. +@end deftypemethod + +@deftypemethod QMathGL @code{void} setPopup (@code{QMenu *}p) +Задает указатель на всплывающее меню. +@end deftypemethod +@deftypemethod QMathGL @code{void} setSize (@code{int} w, @code{int} h) +Задает размеры элемента управления и картинки. +@end deftypemethod +@deftypemethod QMathGL @code{double} getRatio () +Возвращает соотношение сторон рисунка. +@end deftypemethod + +@deftypemethod QMathGL @code{int} getPer () +Возвращает величину перспективы в процентах. +@end deftypemethod +@deftypemethod QMathGL @code{int} getPhi () +Возвращает величину угла Phi в градусах. +@end deftypemethod +@deftypemethod QMathGL @code{int} getTet () +Возвращает величину угла Theta в градусах. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getAlpha () +Возвращает состояние переключателя прозрачности. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getLight () +Возвращает состояние переключателя освещения. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getZoom () +Возвращает состояние переключателя приближения мышью. +@end deftypemethod +@deftypemethod QMathGL @code{bool} getRotate () +Возвращает состояние переключателя вращения мышью. +@end deftypemethod + + +@deftypefn {Slot on @code{QMathGL}} @code{void} refresh () +Перерисовывает (обновляет) элемент управления без вызова функции рисования. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} update () +Обновляет рисунок путем вызова функции рисования. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} copy () +Копирует график в буфер обмена. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} copyClickCoor () +Копирует координаты щелчка мышью (как текст). +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} print () +Печатает текущий рисунок. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} stop () +Посылает сигнал остановки рисования. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} adjust () +Подгоняет размер картинки под размер окна. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} nextSlide () +Показывает следующий кадр. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} prevSlide () +Показывает предыдущий кадр. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} animation (@code{bool} st=@code{true}) +Запускает анимацию. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} setPer (@code{int} val) +Задает величину перспективы. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setPhi (@code{int} val) +Задает величину угла Phi. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setTet (@code{int} val) +Задает величину угла Theta. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setAlpha (@code{bool} val) +Включает/выключает прозрачность. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setLight (@code{bool} val) +Включает/выключает освещение. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setGrid (@code{bool} val) +Включает/выключает рисование сетки абсолютных координат на графике. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setZoom (@code{bool} val) +Включает/выключает приближение мышью. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setRotate (@code{bool} val) +Включает/выключает вращение мышью. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} zoomIn () +Приблиажет график. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} zoomOut () +Отдаляет график. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftLeft () +Сдвигает график влево. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftRight () +Сдвигает график вправо. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftUp () +Сдвигает график вверх. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} shiftDown () +Сдвигает график вниз. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} restore () +Восстанавливает приближение и поворот графика в значения по умолчанию. +@end deftypefn +@c @deftypefn {Slot on @code{QMathGL}} @code{void} reload () +@c Обновляет данные и перерисовывает график. +@c @end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportPNG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в PNG файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportPNGs (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в PNG файл без прозрачности. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportJPG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в JPEG файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportBPS (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в растровый EPS файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportEPS (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный EPS файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportSVG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный SVG файл. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportGIF (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в GIF файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportTEX (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный LaTeX/Tikz файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportTGA (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в TGA файл. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} exportXYZ (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный XYZ/XYZL/XYZF файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportOBJ (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный OBJ/MTL файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportSTL (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный STL файл. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} exportOFF (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный OFF файл. +@end deftypefn +@c @deftypefn {Slot on @code{QMathGL}} @code{void} exportX3D (@code{QString} fname=@code{""}) +@c Сохраняет текущий рисунок в векторный X3D файл. +@c @end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} setUsePrimitives (@code{bool} use) +Разрешает использовать список примитивов для кадров. Это позволяет вращать/масштабировать кадры, но требует значительно больше памяти. По умолчанию разрешено (=@code{true}). +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} setMGLFont (@code{QString} path) +Восстанавливает (@var{path}=@code{""}) или загружает файлы шрифтов. +@end deftypefn + +@deftypefn {Slot on @code{QMathGL}} @code{void} about () +Показывает информацию о программе. +@end deftypefn +@deftypefn {Slot on @code{QMathGL}} @code{void} aboutQt () +Показывает информацию о версии Qt. +@end deftypefn + +@deftypefn {Signal on @code{QMathGL}} @code{void} phiChanged (@code{int} val) +Угол Phi изменен. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} tetChanged (@code{int} val) +Угол Tet изменен. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} perChanged (@code{int} val) +Перспектива изменена. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} alphaChanged (@code{bool} val) +Прозрачность изменена. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} lightChanged (@code{bool} val) +Освещение изменено. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} gridChanged (@code{bool} val) +Рисование сетки изменено. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} zoomChanged (@code{bool} val) +Режим приближения мышью изменен. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} rotateChanged (@code{bool} val) +Режим вращения мышью изменен. +@end deftypefn + +@deftypefn {Signal on @code{QMathGL}} @code{void} mouseClick (@code{mreal} x, @code{mreal} y, @code{mreal} z) +Был щелчок мышью в точке @{x,y,z@}. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} frameChanged (@code{int} val) +Требуется новый кадр для отображения. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} showWarn (@code{QString} warn) +Есть предупреждения. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} posChanged (@code{QString} pos) +Положение щелчка мышью изменилось. +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} objChanged (@code{int} id) +Изменился id объекта на графике (из-за щелчка мышью). +@end deftypefn +@deftypefn {Signal on @code{QMathGL}} @code{void} refreshData () +Данные могли измениться (рисование завершено). +@end deftypefn + + +@deftypecv {QMathGL option} QMathGL @code{QString} appName +Имя приложения для окон сообщений. +@end deftypecv +@deftypecv {QMathGL option} QMathGL @code{bool} autoResize +Разрешить изменять размер рисунка (по умолчанию false). +@end deftypecv + +@external{} + + +@c ------------------------------------------------------------------ +@external{} +@node wxMathGL class, , QMathGL class, Widget classes +@section Класс wxMathGL +@nav{} +@cindex wxMathGL +@cindex widgets + +Класс реализует элемент интерфейса WX для отображения графики MathGL. Он определен в @code{#include }. + +@deftypemethod wxMathGL @code{void} SetDraw (@code{mglDraw *}dr) +Задает функцию рисования из класса производного от @code{mglDraw}. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetDraw (@code{int (*}draw@code{)(mglBase *}gr, @code{void *}p@code{)}, @code{void *}par=@code{NULL}) +@deftypemethodx wxMathGL @code{void} SetDraw (@code{int (*}draw@code{)(mglGraph *}gr@code{)}) +Задает функцию рисования @var{draw}. Поддерживается список графиков (кадров), так что можно вначале их нарисовать (требует довольно много памяти), а потом достаточно быстро отображать. Функция должна возвращать положительное число создаваемых кадров или ноль для непосредственного рисования. Параметр @var{par} содержит указатель на данные пользователя, передаваемый функции рисования @var{draw}. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetGraph (@code{mglCanvas *}gr) +@deftypemethodx wxMathGL @code{void} SetGraph (@code{mglGraph *}gr) +Устанавливает указатель на внешний экземпляр класса для рисования (вместо встроенного). Отмечу, что wxMathGL автоматически удалит этот объект при удалении элемента интерфейса или при новом вызове @code{setGraph()}. +@end deftypemethod +@deftypemethod wxMathGL @code{HMGL} GetGraph () +Возвращает указатель на объект, строящий графики. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetPopup (@code{QMenu *}p) +Задает указатель на всплывающее меню. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetSize (@code{int} w, @code{int} h) +Задает размеры элемента управления и картинки. +@end deftypemethod +@deftypemethod wxMathGL @code{double} GetRatio () +Возвращает соотношение сторон рисунка. +@end deftypemethod + +@deftypemethod wxMathGL @code{int} GetPer () +Возвращает величину перспективы в процентах. +@end deftypemethod +@deftypemethod wxMathGL @code{int} GetPhi () +Возвращает величину угла Phi в градусах. +@end deftypemethod +@deftypemethod wxMathGL @code{int} GetTet () +Возвращает величину угла Theta в градусах. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetAlpha () +Возвращает состояние переключателя прозрачности. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetLight () +Возвращает состояние переключателя освещения. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetZoom () +Возвращает состояние переключателя приближения мышью. +@end deftypemethod +@deftypemethod wxMathGL @code{bool} GetRotate () +Возвращает состояние переключателя вращения мышью. +@end deftypemethod + + +@deftypemethod wxMathGL @code{void} Repaint () +Перерисовывает (обновляет) элемент управления без вызова функции рисования. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Update () +Обновляет рисунок путем вызова функции рисования. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Copy () +Копирует график в буфер обмена. +@end deftypemethod +@comment @deftypemethod wxMathGL @code{void} copyClickCoor () +@comment Копирует координаты щелчка мышью (как текст). +@comment @end deftypemethod +@deftypemethod wxMathGL @code{void} Print () +Печатает текущий рисунок. +@end deftypemethod + +@comment @deftypemethod wxMathGL @code{void} Stop () +@comment Посылает сигнал остановки рисования. +@comment @end deftypemethod +@deftypemethod wxMathGL @code{void} Adjust () +Подгоняет размер картинки под размер окна. +@end deftypemethod +@deftypemethod wxMathGL @code{void} NextSlide () +Показывает следующий кадр. +@end deftypemethod +@deftypemethod wxMathGL @code{void} PrevSlide () +Показывает предыдущий кадр. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Animation (@code{bool} st=@code{true}) +Запускает анимацию. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} SetPer (@code{int} val) +Задает величину перспективы. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetPhi (@code{int} val) +Задает величину угла Phi. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetTet (@code{int} val) +Задает величину угла Theta. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetAlpha (@code{bool} val) +Включает/выключает прозрачность. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetLight (@code{bool} val) +Включает/выключает освещение. +@end deftypemethod +@comment @deftypemethod wxMathGL @code{void} SetGrid (@code{bool} val) +@comment Включает/выключает рисование сетки абсолютных координат на графике. +@comment @end deftypemethod +@deftypemethod wxMathGL @code{void} SetZoom (@code{bool} val) +Включает/выключает приближение мышью. +@end deftypemethod +@deftypemethod wxMathGL @code{void} SetRotate (@code{bool} val) +Включает/выключает вращение мышью. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ZoomIn () +Приблиажет график. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ZoomOut () +Отдаляет график. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftLeft () +Сдвигает график влево. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftRight () +Сдвигает график вправо. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftUp () +Сдвигает график вверх. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ShiftDown () +Сдвигает график вниз. +@end deftypemethod +@deftypemethod wxMathGL @code{void} Restore () +Восстанавливает приближение и поворот графика в значения по умолчанию. +@end deftypemethod +@c @deftypemethod wxMathGL @code{void} reload () +@c Обновляет данные и перерисовывает график. +@c @end deftypemethod + +@deftypemethod wxMathGL @code{void} About () +Показывает информацию о программе. +@end deftypemethod + +@deftypemethod wxMathGL @code{void} ExportPNG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в PNG файл. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportPNGs (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в PNG файл без прозрачности. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportJPG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в JPEG файл. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportBPS (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в растровый EPS файл. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportEPS (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный EPS файл. +@end deftypemethod +@deftypemethod wxMathGL @code{void} ExportSVG (@code{QString} fname=@code{""}) +Сохраняет текущий рисунок в векторный SVG файл. +@end deftypemethod + +@external{} + diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..8cc9bc9 --- /dev/null +++ b/todo.txt @@ -0,0 +1,95 @@ + +============= NEW FOR LATER ============= + +1. Export to COLLADA !!! +2. GTK window/widgets ??? +3. Labels at TriCont() +4. Rewrite glyph drawing for bitmaps (speeding up by excluding boundary checks) ?!? + +5. 2D textures as one of standard way for coloring -- if '%' present in color scheme +6. Graph(mreal x, mreal y, names, styles, font, size); -- names = "node1[node2,node3,node4[node5,node6]]", styles -- the same + apply for subnodes if absent. Styles are colors (fill,border,line), dash (to subnodes), marks "dos^v><", arrows. +7. 3D text (with depth, for Quality=3) +8. Text along 3D curve (for Quality=3) +9. introduce new primitive type=5 -- arrow for Quality&3!=3. for better drawing in projections + json/view ?!? + +10. New tests: + c. Tests for mglDataC arrays (as separate flag) + e. Test for Crop, Momentum, NormSl, Sew, DiffParam, Envelope, STFA for all directions "xyz"; Clean, Last, First, Find, Spline3, FindAny, Insert, Delete, Put, SetId/Column, Squeeze, Extend, Trace, Combine, new Max/Min/Momentum, FillSample, Hist, operators, Sort, Roots, Jacobian + u. Test FlowP + 3d + +11. Check centered curved text (see text2) +12. Export to X3D + +13. Inplot data should have ranges (add mglInPlot{x1,x2,y1,y2,Bp or something like this} which include mglMatrix instead of mglBase::Bp) + calc coor + JS +14. 'perspective' command in UDAV +15. Check octave 3.8 +16. Use mglFormulaCalc() for data transformation/filling (much faster but require more memory) + the same for complex +17. Test mglDataC::Diffraction() + write sample + add rational function??? + +18. Use mglStack instead of std::vector due to multi-threading +19. Get true coordinates in CalcXYZ for curved equations too +20. Add mglDataVar, mglDataCol, mglDataFunc for handling special (temporary) data + add real(), imag(), conj() + accurate types in MGL + add 'expr'/'complex' in MGL + +21. Check if Fortran versions possible for: mgl_data_info, mgl_datas_hdf, mgl_get_fit, mgl_get_mess, mgl_get_plotid +22. Replace pthread by openmp in mgl_draw_thr() and similar +23. Add function Rasterize() -- Finish() + clear points -- m.b. add background image for export, which will be cleared at Clf()??? + +============= DOCUMENTATION ============= + +A. Paper about MathGL!!! +B. Add chapter with real samples +C. Translate to Russian everything + +1. Extend Dots sample (add A, CA, Tens) +2. Extend Refill sample (add 2d) +3. Docs about JS interface + +4. Extend docs about region +5. Docs about mgl_datac_diffr + +============= UDAV ============= + +01. Show plot at creation stage (if option is enabled -- can be long process!!!) + auto axis range or [-1,1] by default + +02. Double click -> setup dialog (optionally -- after QTreeWidgetItem) + +03. Dialog for InPlot(s): +{SubPlot,MultiPlot} -- enable rotate,aspect,title +{ColumnPlot} -- enable rotate,several +{StickPlot} -- enable several +{InPlot} -- enable rotate,aspect,title +Image with gray alternatives and black choice + +04. QTreeWidgetItem -- ICON (func/call,if,for,once,subplot,...); annotation/name; (keep LINE - POS in script). After editing/changing --> put text to editor. +Buttons: new,load,save // newcmd,hide,annotation,collapse on/off,setup // calc. Click on item cause change of line number in editor. +05. Group/ungroup if command in single line, separated by ':' +06. Hide plot/group by putting "#h " at beginning of line +07. Annotation of plot/group -- comment before it +08. Drag&drop plot/group between inplots (in tree widget) + +09. Create default plot dependently of selected row/column/range in data table +10. Data change via menu/toolbar -- save to internal script => enable undo + save initial array(?) + +11. Speed up rotation like as done in JavaScript + +12. Multi-threading for enabling "stop". + +13. Manual rotate (i.e. change rotate arguments) by spinboxes ??? + +14. Close button on data tabs ?!? + +15. Add dialog for mask creation. + +============= UNSURE =========== + +1. Problem with \calB and so on (\calH, ...) -- they are present only in italic font :(. +2. create PWT fonts +3. \dfrac for normal size and centering (sample \big\big{\frac{1}{2}}) ??? +4. "Cut off" curves if text is printed inside it (for contour labels) ?!? +5. String variables in MGL + readstr command. +6. Pool of threads for speeding up ??? or openmp ??? +7. Read DICOM files +8. Check RunThr() in python/octave +9. Try libtcc (TinyCC) as alternative to MGL -- how to handle ^ operator??? +10. Auto axis range for formulas, like AutoRange("y(x)") or AutoRange('x',"x(t)"). +11. Use Hershey as built-in font ??? -- for smaller size only diff --git a/udav/CMakeLists.txt b/udav/CMakeLists.txt new file mode 100644 index 0000000..ce02820 --- /dev/null +++ b/udav/CMakeLists.txt @@ -0,0 +1,60 @@ +if(enable-qt) + +#set(mgl_wnd_src window.cpp) +set(udav_src anim_dlg.cpp find_dlg.cpp mem_pnl.cpp prop_dlg.cpp textedit.cpp args_dlg.cpp + help_pnl.cpp newcmd_dlg.cpp text_pnl.cpp calc_dlg.cpp hint_dlg.cpp + open_dlg.cpp qmglsyntax.cpp udav_wnd.cpp dat_pnl.cpp info_dlg.cpp opt_dlg.cpp setup_dlg.cpp + files_dlg.cpp plot_pnl.cpp style_dlg.cpp data_dlg.cpp tree_pnl.cpp) + +set(udav_moc_hdr anim_dlg.h files_dlg.h info_dlg.h opt_dlg.h text_pnl.h args_dlg.h + find_dlg.h mem_pnl.h plot_pnl.h setup_dlg.h udav_wnd.h calc_dlg.h help_pnl.h newcmd_dlg.h + prop_dlg.h style_dlg.h dat_pnl.h open_dlg.h textedit.h hint_dlg.h data_dlg.h) + +set(udav_rc udav.qrc) + +if(WIN32) + set(udav_src ${udav_src} udav.rc) +endif(WIN32) + +if(MGL_HAVE_HDF5) +# target_link_libraries(mgl ${HDF5_LIBRARIES}) + include_directories(${HDF5_INCLUDE_DIR}) +endif(MGL_HAVE_HDF5) + +if(MGL_HAVE_GSL) +# target_link_libraries(mgl ${GSL_LIB} ${GSL_CBLAS_LIB} ) + include_directories(${GSL_INCLUDE_DIR}) +endif(MGL_HAVE_GSL) + +if(enable-qt5) + include(../cmake-qt5.txt) + qt5_add_resources(udav_rc_src ${udav_rc} ) + qt5_wrap_cpp(udav_moc_src ${udav_moc_hdr} ) +else(enable-qt5) + include(../cmake-qt4.txt) + qt4_add_resources(udav_rc_src ${udav_rc} ) + qt4_wrap_cpp(udav_moc_src ${udav_moc_hdr} ) +endif(enable-qt5) +add_executable(udav ${udav_src} ${udav_moc_src} ${udav_rc_src}) +#set_target_properties(udav PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -pthread") +if(enable-qt5) + target_link_libraries(udav mgl-qt5) + qt5_use_modules(udav Core Widgets Gui PrintSupport) +else(enable-qt5) + target_link_libraries(udav mgl-qt4) + target_link_libraries(udav ${QT_LIBRARIES}) +endif(enable-qt5) + +if(MGL_HAVE_PTHREAD) + target_link_libraries(udav ${CMAKE_THREAD_LIBS_INIT}) +endif(MGL_HAVE_PTHREAD) + +install( + TARGETS udav + RUNTIME DESTINATION bin +) +install(FILES udav.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/) +install(FILES udav.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps/) +install(FILES udav_ru.qm DESTINATION ${CMAKE_INSTALL_PREFIX}/share/udav/) + +endif(enable-qt) diff --git a/udav/anim_dlg.cpp b/udav/anim_dlg.cpp new file mode 100644 index 0000000..99902a9 --- /dev/null +++ b/udav/anim_dlg.cpp @@ -0,0 +1,140 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "anim_dlg.h" +extern int animDelay; +//----------------------------------------------------------------------------- +AnimParam::AnimParam(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Animation setup")); + QHBoxLayout *a; + QVBoxLayout *o, *g; + QLabel *lbl; + QPushButton *b; + o = new QVBoxLayout(this); + lbl = new QLabel(tr("Redraw picture for $0 equal to"),this); + o->addWidget(lbl); + a = new QHBoxLayout(); o->addLayout(a); + g = new QVBoxLayout(); a->addLayout(g); + rbt = new QRadioButton(tr("strings"),this); + connect(rbt, SIGNAL(clicked()),this, SLOT(setRBT())); + g->addWidget(rbt); + text = new QTextEdit(this); g->addWidget(text); + connect(text,SIGNAL(textChanged()),this,SLOT(setRBT())); + + g = new QVBoxLayout(); a->addLayout(g); + rbf = new QRadioButton(tr("values"),this); + connect(rbf, SIGNAL(clicked()),this, SLOT(setRBF())); + g->addWidget(rbf); + lbl = new QLabel(tr("from"),this); + g->addWidget(lbl, Qt::AlignLeft); + p1 = new QLineEdit(this); g->addWidget(p1); + connect(p1,SIGNAL(textChanged(QString)),this,SLOT(setRBF())); + lbl = new QLabel(tr("to"),this); + g->addWidget(lbl, Qt::AlignLeft); + p2 = new QLineEdit(this); g->addWidget(p2); + connect(p2,SIGNAL(textChanged(QString)),this,SLOT(setRBF())); + lbl = new QLabel(tr("with step"),this); + g->addWidget(lbl, Qt::AlignLeft); + dp = new QLineEdit(this); g->addWidget(dp); dp->setText("1"); + connect(dp,SIGNAL(textChanged(QString)),this,SLOT(setRBF())); + b = new QPushButton(tr("Cancel"), this); g->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); g->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(fillRes())); + b->setDefault(true); + // general + a = new QHBoxLayout(); o->addLayout(a); + b = new QPushButton(tr("Put to script"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(putTxt())); + lbl = new QLabel(tr("Delay (in ms)"),this); a->addWidget(lbl); + delay = new QLineEdit(this); a->addWidget(delay); + QString s; s.sprintf("%d",animDelay); delay->setText(s); + // export to gif/jpeg + a = new QHBoxLayout(); o->addLayout(a); +// fname = new QLineEdit(this); a->addWidget(fname); + gif = new QCheckBox(tr("Export to GIF"), this); a->addWidget(gif); + jpg = new QCheckBox(tr("Save JPEG frames"), this); a->addWidget(jpg); +} +//----------------------------------------------------------------------------- +AnimParam::~AnimParam() {} +//----------------------------------------------------------------------------- +void AnimParam::fillRes() +{ +// gifName = fname->text(); + gifOn = gif->isChecked(); + jpgOn = jpg->isChecked(); + animDelay = delay->text().toInt(); + if(rbt->isChecked()) { res = text->toPlainText(); accept(); } + else if(rbf->isChecked()) + { + res = ""; + QString s; + double x, x2=p2->text().toDouble(), dx=dp->text().toDouble(); + for(x=p1->text().toDouble();xtext().isEmpty() && !p2->text().isEmpty() && !dp->text().isEmpty()) + { + s = "##c "+p1->text()+" "+p2->text()+" "+dp->text()+"\n"; + emit putText(s); + } + if(text->toPlainText().isEmpty()) return; + int i, n = text->toPlainText().count('\n')+1; + for(i=0;itoPlainText().section('\n',i,i); + if(!t.isEmpty()) s = s+"##a "+t+"\n"; + } + emit putText(s); +} +//----------------------------------------------------------------------------- +void AnimParam::setRBF() { rbt->setChecked(false); rbf->setChecked(true); } +//----------------------------------------------------------------------------- +void AnimParam::setRBT() { rbf->setChecked(false); rbt->setChecked(true); } +//----------------------------------------------------------------------------- +void AnimParam::setResult(const QString &s) +{ text->setText(s); rbf->setChecked(false); rbt->setChecked(true); } +//----------------------------------------------------------------------------- +void AnimParam::setResult(double a1, double a2, double da) +{ + p1->setText(QString::number(a1)); + p2->setText(QString::number(a2)); + dp->setText(QString::number(da)); + rbt->setChecked(false); rbf->setChecked(true); +} +//----------------------------------------------------------------------------- + diff --git a/udav/anim_dlg.h b/udav/anim_dlg.h new file mode 100644 index 0000000..4a34682 --- /dev/null +++ b/udav/anim_dlg.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef ANIMPARAM_H +#define ANIMPARAM_H +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +class QLineEdit; +class QTextEdit; +class QRadioButton; +class QCheckBox; +/// Setup animation parqmeters +class AnimParam : public QDialog +{ +Q_OBJECT +public: + bool gifOn, jpgOn; + /// string with resulting animation parameters + const QString &getResult() { return res; } + void setResult(const QString &s); + void setResult(double a1,double a2,double da); + AnimParam(QWidget *parent=0); + ~AnimParam(); +signals: + void putText(const QString &par); +private slots: + void fillRes(); + void putTxt(); + void setRBF(); + void setRBT(); +private: + QString res; + QLineEdit *p1, *p2, *dp, *delay;//, *fname; + QTextEdit *text; + QRadioButton *rbt, *rbf; + QCheckBox *gif, *jpg; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/args_dlg.cpp b/udav/args_dlg.cpp new file mode 100644 index 0000000..aa20c48 --- /dev/null +++ b/udav/args_dlg.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include "args_dlg.h" +extern mglParse parser; +//----------------------------------------------------------------------------- +QDialog *createArgsDlg(QWidget *p) { return new ArgsDialog(p); } +//----------------------------------------------------------------------------- +ArgsDialog::ArgsDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Set script arguments")); + QHBoxLayout *h; + QVBoxLayout *v; + QGridLayout *g; + QLabel *l; + QPushButton *b; + + v = new QVBoxLayout(this); + g = new QGridLayout(); v->addLayout(g); + l = new QLabel(tr("String for $1"), this); g->addWidget(l, 0, 0); + a[1] = new QLineEdit(this); g->addWidget(a[1], 1, 0); + l = new QLabel(tr("String for $2"), this); g->addWidget(l, 0, 1); + a[2] = new QLineEdit(this); g->addWidget(a[2], 1, 1); + l = new QLabel(tr("String for $3"), this); g->addWidget(l, 2, 0); + a[3] = new QLineEdit(this); g->addWidget(a[3], 3, 0); + l = new QLabel(tr("String for $4"), this); g->addWidget(l, 2, 1); + a[4] = new QLineEdit(this); g->addWidget(a[4], 3, 1); + l = new QLabel(tr("String for $5"), this); g->addWidget(l, 4, 0); + a[5] = new QLineEdit(this); g->addWidget(a[5], 5, 0); + l = new QLabel(tr("String for $6"), this); g->addWidget(l, 4, 1); + a[6] = new QLineEdit(this); g->addWidget(a[6], 5, 1); + l = new QLabel(tr("String for $7"), this); g->addWidget(l, 6, 0); + a[7] = new QLineEdit(this); g->addWidget(a[7], 7, 0); + l = new QLabel(tr("String for $8"), this); g->addWidget(l, 6, 1); + a[8] = new QLineEdit(this); g->addWidget(a[8], 7, 1); + l = new QLabel(tr("String for $9"), this); g->addWidget(l, 8, 0); + a[9] = new QLineEdit(this); g->addWidget(a[9], 9, 0); + l = new QLabel(tr("String for $0"), this); g->addWidget(l, 8, 1); + a[0] = new QLineEdit(this); g->addWidget(a[0], 9, 1); + + h = new QHBoxLayout(); h->addStretch(1); v->addLayout(h); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(putArguments())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +ArgsDialog::~ArgsDialog() {} +//----------------------------------------------------------------------------- +void ArgsDialog::putArguments() +{ + int len=0, i, j, n; + for(i=0;i<10;i++) + if(a[i]->text().length()>len) + len = a[i]->text().length(); + wchar_t *str = new wchar_t[len+2]; + QString s; + for(i=0;i<10;i++) + { + s = a[i]->text(); n = s.length(); + for(j=0;j +class QLineEdit; +//----------------------------------------------------------------------------- +/// Dialog for enetring script arguments $0...$9 +class ArgsDialog : public QDialog +{ +Q_OBJECT +public: + ArgsDialog(QWidget *parent=0); + ~ArgsDialog(); + +private slots: + void putArguments(); +private: + QLineEdit *a[10]; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/calc_dlg.cpp b/udav/calc_dlg.cpp new file mode 100644 index 0000000..12212f9 --- /dev/null +++ b/udav/calc_dlg.cpp @@ -0,0 +1,264 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include "calc_dlg.h" +extern mglParse parser; +//----------------------------------------------------------------------------- +// +// Calc dialog +// +//----------------------------------------------------------------------------- +QWidget *createCalcDlg(QWidget *p, QTextEdit *e) +{ + CalcDialog *c = new CalcDialog(p); + QObject::connect(c, SIGNAL(putNumber(QString)),e,SLOT(insertPlainText(QString))); + return c; +} +//----------------------------------------------------------------------------- +CalcDialog::CalcDialog(QWidget *parent) : QWidget(parent) +{ + QPushButton *b; + QHBoxLayout *m=new QHBoxLayout(this); + QVBoxLayout *o=new QVBoxLayout; m->addLayout(o); m->setStretchFactor(o,1); +// QStandardItem *it; + + text = new QLineEdit(this); o->addWidget(text); + connect(text,SIGNAL(textChanged(QString)),this,SLOT(evaluate())); + connect(text,SIGNAL(returnPressed()),this,SLOT(addResult())); + hist = new QStandardItemModel(this); +// it = new QStandardItem(tr("Formula")); hist->setHorizontalHeaderItem(0,it); +// it = new QStandardItem(tr("Result")); hist->setHorizontalHeaderItem(1,it); + prev = new QListView(this); o->addWidget(prev); + connect(prev,SIGNAL(clicked(QModelIndex)),this,SLOT(putText(QModelIndex))); + QFont f(font()); f.setPointSize(f.pointSize()*0.75); + prev->setModel(hist); prev->setFont(f); + prev->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); + + + o = new QVBoxLayout; m->addLayout(o); + QLabel *l = new QLabel(tr("Result"),this); o->addWidget(l); + result=new QLineEdit(this); result->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + result->setReadOnly(true); o->addWidget(result); + b = new QPushButton(tr("To script"), this); o->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(keyPut())); + b = new QPushButton(tr("Clear"), this); o->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(clear())); + + QGridLayout *g = new QGridLayout; m->addLayout(g); m->setStretchFactor(g,0); + b = new QPushButton("7", this); g->addWidget(b, 0, 0); + int minw=b->height(); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key7())); + b = new QPushButton("8", this); g->addWidget(b, 0, 1); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key8())); + b = new QPushButton("9", this); g->addWidget(b, 0, 2); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key9())); + b = new QPushButton("+", this); g->addWidget(b, 0, 3); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyAdd())); + b = new QPushButton(QString::fromWCharArray(L"π"), this); g->addWidget(b, 0, 4); + connect(b, SIGNAL(clicked()), this, SLOT(keyPi())); b->setMaximumWidth(minw); + + b = new QPushButton("4", this); g->addWidget(b, 1, 0); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key4())); + b = new QPushButton("5", this); g->addWidget(b, 1, 1); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key5())); + b = new QPushButton("6", this); g->addWidget(b, 1, 2); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key6())); + b = new QPushButton("-", this); g->addWidget(b, 1, 3); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keySub())); + b = new QPushButton(QString::fromWCharArray(L"x²"), this); g->addWidget(b, 1, 4); + connect(b, SIGNAL(clicked()), this, SLOT(keyX2())); b->setMaximumWidth(minw); + + b = new QPushButton("1", this); g->addWidget(b, 2, 0); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key1())); + b = new QPushButton("2", this); g->addWidget(b, 2, 1); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key2())); + b = new QPushButton("3", this); g->addWidget(b, 2, 2); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key3())); + b = new QPushButton("*", this); g->addWidget(b, 2, 3); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyMul())); + b = new QPushButton("(", this); g->addWidget(b, 2, 4); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyBrO())); + + b = new QPushButton("0", this); g->addWidget(b, 3, 0); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(key0())); + b = new QPushButton(".", this); g->addWidget(b, 3, 1); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyDot())); + b = new QPushButton("E", this); g->addWidget(b, 3, 2); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyE())); + b = new QPushButton("/", this); g->addWidget(b, 3, 3); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyDiv())); + b = new QPushButton(")", this); g->addWidget(b, 3, 4); b->setMaximumWidth(minw); + connect(b, SIGNAL(clicked()), this, SLOT(keyBrC())); + + fillFuncName(); + o=new QVBoxLayout; m->addLayout(o); m->setStretchFactor(o,0); + type = new QComboBox(this); o->addWidget(type); + type->addItems(names); type->setCurrentIndex(0); + func = new QComboBox(this); o->addWidget(func); + func->addItems(funcName[0]); type->setCurrentIndex(0); + descr= new QLabel(this); o->addWidget(descr); o->setStretchFactor(descr,0); + descr->setText(funcInfo[0].at(0)); + connect(type, SIGNAL(currentIndexChanged(int)), this, SLOT(typeUpdate(int))); + connect(func, SIGNAL(currentIndexChanged(int)), this, SLOT(funcUpdate(int))); + b = new QPushButton(tr("Put function"), this); o->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(keyFnc())); +} +//----------------------------------------------------------------------------- +CalcDialog::~CalcDialog() {} +void CalcDialog::foc() { text->setFocus(Qt::ActiveWindowFocusReason); } +//----------------------------------------------------------------------------- +void CalcDialog::key1() { text->setText("1"); foc(); } +void CalcDialog::key2() { text->setText("2"); foc(); } +void CalcDialog::key3() { text->setText("3"); foc(); } +void CalcDialog::key4() { text->setText("4"); foc(); } +void CalcDialog::key5() { text->setText("5"); foc(); } +void CalcDialog::key6() { text->setText("6"); foc(); } +void CalcDialog::key7() { text->setText("7"); foc(); } +void CalcDialog::key8() { text->setText("8"); foc(); } +void CalcDialog::key9() { text->setText("9"); foc(); } +void CalcDialog::key0() { text->setText("0"); foc(); } +void CalcDialog::keyE() { text->setText("E"); foc(); } +void CalcDialog::keyPi() { text->setText("pi"); foc(); } +void CalcDialog::keyX2() { text->setText("^2"); foc(); } +void CalcDialog::keyAdd() { text->setText("+"); foc(); } +void CalcDialog::keyMul() { text->setText("*"); foc(); } +void CalcDialog::keySub() { text->setText("-"); foc(); } +void CalcDialog::keyDiv() { text->setText("/"); foc(); } +void CalcDialog::keyBrO() { text->setText("("); foc(); } +void CalcDialog::keyBrC() { text->setText(")"); foc(); } +void CalcDialog::keyDot() { text->setText("."); foc(); } +void CalcDialog::clear() { text->clear(); foc(); } +//----------------------------------------------------------------------------- +void CalcDialog::keyFnc() +{ + text->setText(func->currentText()); + text->setCursorPosition(func->currentText().length()-1); foc(); +} +//----------------------------------------------------------------------------- +void CalcDialog::keyPut() { emit putNumber(result->text()); } +//----------------------------------------------------------------------------- +void CalcDialog::putText(QModelIndex ind) +{ text->setText(hist->data(ind).toString()); } +//----------------------------------------------------------------------------- +void CalcDialog::addResult() +{ + QStandardItem *it; + QFont f(prev->font()); f.setBold(true); + hist->insertRows(0,2); + it = new QStandardItem(text->text()); it->setFont(f); hist->setItem(0,it); + it = new QStandardItem(result->text()); hist->setItem(1,it); +} +//----------------------------------------------------------------------------- +void CalcDialog::evaluate() +{ + QString sel=text->text(); + if(sel.isEmpty()) return; + wchar_t *txt=new wchar_t[sel.length()+1]; + sel.toWCharArray(txt); txt[sel.length()]=0; + setlocale(LC_NUMERIC, "C"); + mglData res=parser.Calc(txt); + setlocale(LC_NUMERIC, ""); +// result->setText(QString::fromWCharArray(txt)); + delete []txt; + result->setText(QString::number(res.GetVal(0))); +} +//----------------------------------------------------------------------------- +void CalcDialog::fillFuncName() +{ + names<9) return; + func->clear(); func->addItems(funcName[s]); func->setCurrentIndex(0); +} +//----------------------------------------------------------------------------- +void CalcDialog::funcUpdate(int f) +{ + int s=type->currentIndex(); + if(s<0 || s>9 || f<0) return; // wrong index + descr->setText(funcInfo[s].at(f)); +} +//----------------------------------------------------------------------------- diff --git a/udav/calc_dlg.h b/udav/calc_dlg.h new file mode 100644 index 0000000..b3d429e --- /dev/null +++ b/udav/calc_dlg.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef CALC_DLG_H +#define CALC_DLG_H +//----------------------------------------------------------------------------- +#include +#include +#include +class QLabel; +class QLineEdit; +class QTextEdit; +class QComboBox; +class QListView; +class QPushButton; +//----------------------------------------------------------------------------- +/// Dialog for finding something in text +class CalcDialog : public QWidget +{ +Q_OBJECT +public: + CalcDialog(QWidget *parent = 0); + ~CalcDialog(); +public slots: + void evaluate(); +signals: + void putNumber(const QString &str); +private slots: + void keyPut(); + void key1(); + void key2(); + void key3(); + void key4(); + void key5(); + void key6(); + void key7(); + void key8(); + void key9(); + void key0(); + void keyE(); + void keyDot(); + void keyMul(); + void keyDiv(); + void keyAdd(); + void keySub(); + void keyBrO(); + void keyBrC(); + void keyFnc(); + void keyPi(); + void keyX2(); + void typeUpdate(int s); + void funcUpdate(int s); + void foc(); + void clear(); + void putText(QModelIndex ind); + void addResult(); + +private: + QLineEdit *text; + QLineEdit *result; + QComboBox *type, *func; + QLabel *descr; + QListView *prev; + QStringList names, funcName[10], funcInfo[10]; + QStandardItemModel *hist; + + void fillFuncName(); +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/dat_pnl.cpp b/udav/dat_pnl.cpp new file mode 100644 index 0000000..ca81add --- /dev/null +++ b/udav/dat_pnl.cpp @@ -0,0 +1,755 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "dat_pnl.h" +#include "info_dlg.h" +#include "xpm/table.xpm" +//----------------------------------------------------------------------------- +extern mglParse parser; +void updateDataItems(); +void addDataPanel(QWidget *wnd, QWidget *w, QString name); +void deleteDat(void *o) { if(o) delete ((DatPanel *)o); } +void refreshData(QWidget *w) { ((DatPanel *)w)->refresh(); } +//----------------------------------------------------------------------------- +QWidget *newDataWnd(InfoDialog *inf, QWidget *wnd, mglVar *v) +{ + DatPanel *t = new DatPanel(inf); + if(v) t->setVar(v); + addDataPanel(wnd,t,t->dataName()); + return t; +} +//----------------------------------------------------------------------------- +DatPanel::DatPanel(InfoDialog *inf, QWidget *parent) : QWidget(parent) +{ + setAttribute(Qt::WA_DeleteOnClose); + kz = nx = ny = nz = 0; var = 0; + ready = false; infoDlg = inf; + QBoxLayout *v,*h,*m; + + menu = new QMenu(tr("Data"),this); + v = new QVBoxLayout(this); + h = new QHBoxLayout(); v->addLayout(h); toolTop(h); + h = new QHBoxLayout(); v->addLayout(h); + m = new QVBoxLayout(); h->addLayout(m); toolLeft(m); + tab = new QTableWidget(this); h->addWidget(tab); + connect(tab, SIGNAL(cellChanged(int,int)), this, SLOT(putValue(int, int))); + + setWindowIcon(QPixmap(table_xpm)); +} +//----------------------------------------------------------------------------- +DatPanel::~DatPanel() { if(var) var->o = 0; } +//----------------------------------------------------------------------------- +void DatPanel::refresh() +{ + bool rc = false; + if(!var) return; + infoDlg->allowRefresh=false; + if(nx!=var->nx) { nx = var->nx; tab->setColumnCount(nx); rc=true; } + if(ny!=var->ny) { ny = var->ny; tab->setRowCount(ny); rc=true; } + if(kz>=var->nz) { kz = 0; emit sliceChanged(0); } + if(nz!=var->ny) { nz = var->nz; emit nzChanged(nz); } + id = QString(var->id.c_str()); + if(nz==1 && ny>1 && !id.isEmpty()) + { + QStringList head; + QString s; + for(int i=0;i='a' && id[i]<='z') s=s+" ("+id[i]+")"; + head<setHorizontalHeaderLabels(head); + } + register long i,j,m=var->s.length(); + register mreal f; + QString s,d; + if(rc) + { + QStringList sh,sv; + for(i=0;isetHorizontalHeaderLabels(sh); + for(i=0;isetVerticalHeaderLabels(sv); + for(i=0;isetItem(j,i,new QTableWidgetItem); + } + for(i=0;iGetVal(i,j,kz); + if(mgl_isnan(f)) s = "nan"; + else s.sprintf("%g",f); + tab->item(j,i)->setText(s); + } + infoDlg->allowRefresh=true; infoDlg->refresh(); + QChar *ss = new QChar[m+1]; + for(i=0;is[i]; + s = QString(ss, m); delete []ss; + d.sprintf("%d * %d * %d", nx, ny, nz); + ready = true; +} +//----------------------------------------------------------------------------- +void DatPanel::setVar(mglVar *v) +{ + ready = false; + if(var) var->o = 0; + var = v; infoDlg->setVar(v); + nx = ny = nz = kz = 0; + if(v) + { + QString s = QString::fromStdWString(v->s); + v->o = this; v->func = deleteDat; + refresh(); + setWindowTitle(s + tr(" - UDAV variable")); + infoDlg->setWindowTitle(s + tr(" - UDAV preview")); + } + else + { tab->setColumnCount(0); tab->setRowCount(0); emit nzChanged(nz); } + emit sliceChanged(0); +} +//----------------------------------------------------------------------------- +void DatPanel::setSlice(int k) +{ + if(k>=nz) k=nz-1; if(k<0) k=0; + if(k!=kz) + { + infoDlg->setSlice(k); + emit sliceChanged(k); + kz = k; refresh(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::putValue(int r, int c) +{ + if(!var || r<0 || c<0 || r>=ny || c>=nx || !ready) return; + QString s = tab->item(r,c)->text().toLower(); + mreal f; + f = s=="nan" ? NAN : s.toDouble(); + if(f!=var->GetVal(c,r,kz)) + { + if(mgl_isnan(f)) s="nan"; else s.sprintf("%g", f); + tab->item(r,c)->setText(s); + } + var->SetVal(f,c,r,kz); + infoDlg->refresh(); +} +//----------------------------------------------------------------------------- +void DatPanel::save() +{ + QString fn = QFileDialog::getSaveFileName(this, tr("UDAV - Save/export data"), "", + tr("Data files (*.dat)\nHDF5 files (*.h5 *.hdf)\nPNG files (*.png)\nAll files (*.*)")); + if(fn.isEmpty()) return; + QString ext = fn.section(".",-1); + if(ext=="png") + { + bool ok; + QString s = QInputDialog::getText(this, tr("UDAV - Export to PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok); + if(ok) var->Export(fn.toStdString().c_str(), s.toStdString().c_str()); + } + else if(ext=="h5" || ext=="hdf") + { + bool ok; + QString s = QInputDialog::getText(this, tr("UDAV - Save to HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok); + if(ok) var->SaveHDF(fn.toStdString().c_str(), s.toStdString().c_str()); + } + else var->Save(fn.toStdString().c_str()); +} +//----------------------------------------------------------------------------- +void DatPanel::load() +{ + QString fn = QFileDialog::getOpenFileName(this, tr("UDAV - Load data"), "", + tr("Data files (*.dat)\nHDF5 files (*.h5 *.hdf)\nPNG files (*.png)\nAll files (*.*)")); + if(fn.isEmpty()) return; + QString ext = fn.section(".",-1); + if(ext=="png") + { + bool ok; + QString s = QInputDialog::getText(this, tr("UDAV - Import PNG"), tr("Enter color scheme for picture"), QLineEdit::Normal, MGL_DEF_SCH, &ok); + if(ok) var->Import(fn.toStdString().c_str(), s.toStdString().c_str()); + } + else if(ext=="h5" || ext=="hdf") + { + bool ok; + QString s = QInputDialog::getText(this, tr("UDAV - Read from HDF"), tr("Enter data name"), QLineEdit::Normal, QString::fromStdWString(var->s), &ok); + if(ok) var->ReadHDF(fn.toStdString().c_str(), s.toStdString().c_str()); + } + else var->Read(fn.toStdString().c_str()); + refresh(); +} +//----------------------------------------------------------------------------- +void DatPanel::copy() +{ + QTableWidgetSelectionRange ts = tab->selectedRanges().first(); + register long i,j; + QString res, s; + for(j=ts.topRow();j<=ts.bottomRow();j++) + { + for(i=ts.leftColumn();i<=ts.rightColumn();i++) + { + res = res + tab->item(j,i)->text(); + if(isetText(res, QClipboard::Clipboard); +} +//----------------------------------------------------------------------------- +void DatPanel::paste() +{ + QString txt = QApplication::clipboard()->text(QClipboard::Clipboard); + QString s, t; + int r = tab->currentRow(), c = tab->currentColumn(), i, j; + for(i=0;iSetVal(t.toDouble(),j+c,i+r,kz); + } + } + refresh(); +} +//----------------------------------------------------------------------------- +void DatPanel::plot() // TODO: plot dialog +{ + +} +//----------------------------------------------------------------------------- +void DatPanel::list() // TODO: in which script insert ??? +{ +/* if(nx*ny+ny > 1020) + { QMessageBox::warning(this, tr("UDAV - To list conversion"), tr("Too many numbers (>1000) on slice"), QMessageBox::Ok, 0, 0); return; } + if(nz > 1) + QMessageBox::information(this, tr("UDAV - To list conversion"), tr("Only current slice will be inserted"), QMessageBox::Ok, 0, 0); + QString res = "list\t", s; + register long i,j; + for(j=0;ja[i+nx*(j+kz*ny)]); + res += s; + } + if(jFill(v1.toDouble(), v2.toDouble(), dir[0].toLatin1()); + refresh(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::norm() +{ + QString v1("0"), v2("1"), how; + if(sizesDialog(tr("UDAV - Normalize data"), tr("Enter range for final data"), tr("From"), tr("To"), tr("Symmetrical?"), v1, v2, how)) + { + var->Norm(v1.toDouble(), v2.toDouble(), (how=="on" || how.contains('s'))); + refresh(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::normsl() +{ + QString v1("0"), v2("1"), dir("z"); + if(sizesDialog(tr("UDAV - Normalize by slice"), tr("Enter range for final data"), tr("From"), tr("To"), tr("Direction"), v1, v2, dir)) + { + var->NormSl(v1.toDouble(), v2.toDouble(), dir[0].toLatin1()); + refresh(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::create() +{ + QString mx, my("1"), mz("1"); + if(sizesDialog(tr("UDAV - Clear data"), tr("Enter new data sizes"), tr("X-size"), tr("Y-size"), tr("Z-size"), mx, my, mz)) + { + var->Create(mx.toInt(), my.toInt(), mz.toInt()); + refresh(); updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::reSize() +{ + QString mx, my, mz; + mx.sprintf("%d",nx); my.sprintf("%d",ny); mz.sprintf("%d",nz); + if(sizesDialog(tr("UDAV - Resize data"), tr("Enter new data sizes"), tr("X-size"), tr("Y-size"), tr("Z-size"), mx, my, mz)) + { + var->Set(var->Resize(mx.toInt(), my.toInt(), mz.toInt())); + refresh(); updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::squize() +{ + QString mx("1"), my("1"), mz("1"); + if(sizesDialog(tr("UDAV - Squeeze data"), tr("Enter step of saved points. For example, '1' save all, '2' save each 2nd point, '3' save each 3d and so on."), tr("X-direction"), tr("Y-direction"), tr("Z-direction"), mx, my, mz)) + { + var->Squeeze(mx.toInt(), my.toInt(), mz.toInt()); + refresh(); updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::crop() +{ + QString n1("1"), n2("1"), dir; + if(sizesDialog(tr("UDAV - Crop data"), tr("Enter range of saved date."), tr("From"), tr("To"), tr("Direction"), n1, n2, dir)) + { + var->Squeeze(n1.toInt(), n2.toInt(), dir[0].toLatin1()); + refresh(); updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::rearrange() +{ + QString mx, my, mz; + mx.sprintf("%d",nx); my.sprintf("%d",ny); mz.sprintf("%d",nz); + if(sizesDialog(tr("UDAV - Rearrange data"), tr("Enter new data sizes"), tr("X-size"), tr("Y-size"), tr("Z-size"), mx, my, mz)) + { + var->Rearrange(mx.toInt(), my.toInt(), mz.toInt()); + refresh(); updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::hist() +{ + QLabel *l; + QLineEdit *id, *v1, *v2; + QSpinBox *nm; + QPushButton *b; + QDialog *d = new QDialog(this); d->setWindowTitle(tr("UDAV - Make histogram")); + QGridLayout *g = new QGridLayout(d); + l = new QLabel(tr("From"), d); g->addWidget(l,0,0); + l = new QLabel(tr("To"), d); g->addWidget(l,0,1); + v1 = new QLineEdit(d); g->addWidget(v1,1,0); + v2 = new QLineEdit(d); g->addWidget(v2,1,1); + l = new QLabel(tr("Number of points"), d); g->addWidget(l,2,0); + l = new QLabel(tr("Put in variable"), d); g->addWidget(l,2,1); + nm = new QSpinBox(d); nm->setRange(2,8192); g->addWidget(nm,3,0); + id = new QLineEdit(d); nm->setSingleStep(10); g->addWidget(id,3,1); + b = new QPushButton(tr("Cancel"), d); g->addWidget(b,4,0); + connect(b, SIGNAL(clicked()), d, SLOT(reject())); + b = new QPushButton(tr("OK"), d); g->addWidget(b,4,1); + connect(b, SIGNAL(clicked()), d, SLOT(accept())); b->setDefault(true); + // now execute dialog and get values + bool res = d->exec(); + if(res && !v1->text().isEmpty() && !v2->text().isEmpty() && !id->text().isEmpty()) + { + mglVar *vv = parser.AddVar(id->text().toStdString().c_str()); + if(!vv) return; + vv->Set(var->Hist(nm->value(), v1->text().toDouble(), v2->text().toDouble())); + updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::first() { setSlice(0); } +//----------------------------------------------------------------------------- +void DatPanel::last() { setSlice(nz-1); } +//----------------------------------------------------------------------------- +void DatPanel::next() { setSlice(kz+1); } +//----------------------------------------------------------------------------- +void DatPanel::prev() { setSlice(kz-1); } +//----------------------------------------------------------------------------- +void DatPanel::gosl() +{ + bool ok; + QString s = QInputDialog::getText(this, tr("UDAV - Go to slice"), tr("Enter slice id:"), QLineEdit::Normal, "0", &ok); + if(ok) setSlice(s.toInt()); +} +//----------------------------------------------------------------------------- +void DatPanel::setNz(int nz) { sb->setMaximum(nz-1); } +//----------------------------------------------------------------------------- +bool DatPanel::sizesDialog(const QString &cap, const QString &lab, const QString &desc1, const QString &desc2, const QString &desc3, QString &val1, QString &val2, QString &val3) +{ + QLabel *l; + QLineEdit *f1, *f2, *f3; + QPushButton *b; + QDialog *d = new QDialog(this); + d->setWindowTitle(cap); + QVBoxLayout *v = new QVBoxLayout(d); + l = new QLabel(lab, d); v->addWidget(l); + l = new QLabel(tr("NOTE: All fields must be filled!"), d); v->addWidget(l); + QGridLayout *g = new QGridLayout(); v->addLayout(g); + l = new QLabel(desc1, d); g->addWidget(l, 0, 0); + l = new QLabel(desc2, d); g->addWidget(l, 0, 1); + l = new QLabel(desc3, d); g->addWidget(l, 0, 2); + f1 = new QLineEdit(val1, d); g->addWidget(f1, 1, 0); + f2 = new QLineEdit(val2, d); g->addWidget(f2, 1, 1); + f3 = new QLineEdit(val3, d); g->addWidget(f3, 1, 2); + QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); + h->addStretch(1); + b = new QPushButton(tr("Cancel"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(reject())); + b = new QPushButton(tr("OK"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(accept())); + b->setDefault(true); + // now execute dialog and get values + bool res = d->exec(); + val1 = f1->text(); val2 = f2->text(); val3 = f3->text(); + if(val1.isEmpty() || val2.isEmpty() || val3.isEmpty()) res = false; + delete d; + return res; +} +//----------------------------------------------------------------------------- +#include "xpm/plot.xpm" +#include "xpm/size.xpm" +//#include "xpm/smth.xpm" +#include "xpm/crop.xpm" +#include "xpm/squize.xpm" +//#include "xpm/sum.xpm" +//#include "xpm/func.xpm" +//#include "xpm/swap.xpm" +#include "xpm/hist.xpm" +#include "xpm/oper_dir.xpm" +#include "xpm/oper_of.xpm" +//----------------------------------------------------------------------------- +void DatPanel::newdat() +{ + QLabel *l; + QLineEdit *f1, *f2; + QPushButton *b; + QDialog *d = new QDialog(this); + d->setWindowTitle(tr("UDAV - make new data")); + QVBoxLayout *v = new QVBoxLayout(d); + QComboBox *c = new QComboBox(d); v->addWidget(c); + c->addItem(tr("Sum along direction(s)")); + c->addItem(tr("Min along direction(s)")); + c->addItem(tr("Max along direction(s)")); + c->addItem(tr("Momentum along 'x' for function")); + c->addItem(tr("Momentum along 'y' for function")); + c->addItem(tr("Momentum along 'z' for function")); + c->setCurrentIndex(0); + + f1 = new QLineEdit("z",d); v->addWidget(f1); + QCheckBox *cb = new QCheckBox(tr("Put into this data array"), d); v->addWidget(cb); + l = new QLabel(tr("or enter name for new variable"), d); v->addWidget(l); + f2 = new QLineEdit(d); v->addWidget(f2); + QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1); + b = new QPushButton(tr("Cancel"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(reject())); + b = new QPushButton(tr("OK"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(accept())); + b->setDefault(true); + // now execute dialog and get values + bool res = d->exec(); + QString val = f1->text(), mgl; + int k = c->currentIndex(); + QString self = QString::fromStdWString(var->s); + if(res) + { + if(k<0) + { + QMessageBox::warning(d, tr("UDAV - make new data"), + tr("No action is selected. Do nothing.")); + return; + } + if(val.isEmpty()) + { + QMessageBox::warning(d, tr("UDAV - make new data"), + tr("No direction/formula is entered. Do nothing.")); + return; + } + if(cb->isChecked()) k += 6; + QString name = f2->text(); + switch(k) + { + case 0: mgl = "sum "+name+" "+self+" '"+val+"'"; break; + case 1: mgl = "min "+name+" "+self+" '"+val+"'"; break; + case 2: mgl = "max "+name+" "+self+" '"+val+"'"; break; + case 3: mgl = "momentum "+name+" "+self+" 'x' '"+val+"'"; break; + case 4: mgl = "momentum "+name+" "+self+" 'y' '"+val+"'"; break; + case 5: mgl = "momentum "+name+" "+self+" 'z' '"+val+"'"; break; + case 6: mgl = "copy "+self+" {sum "+self+" '"+val+"'}"; break; + case 7: mgl = "copy "+self+" {min "+self+" '"+val+"'}"; break; + case 8: mgl = "copy "+self+" {max "+self+" '"+val+"'}"; break; + case 9: mgl = "copy "+self+" {momentum "+self+" 'x' '"+val+"'}"; break; + case 10: mgl = "copy "+self+" {momentum "+self+" 'y' '"+val+"'}"; break; + case 11: mgl = "copy "+self+" {momentum "+self+" 'z' '"+val+"'}"; break; + } + } + if(!mgl.isEmpty()) + { + mglGraph gr; + parser.Execute(&gr,mgl.toStdString().c_str()); + opers += mgl+"\n"; + updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::oper() +{ + QLineEdit *f1; + QPushButton *b; + QDialog *d = new QDialog(this); + d->setWindowTitle(tr("UDAV - change data")); + QVBoxLayout *v = new QVBoxLayout(d); + QComboBox *c = new QComboBox(d); v->addWidget(c); + c->addItem(tr("Fill data by formula")); + c->addItem(tr("Transpose data with new dimensions")); + c->addItem(tr("Smooth data along direction(s)")); + c->addItem(tr("Summarize data along direction(s)")); + c->addItem(tr("Integrate data along direction(s)")); + c->addItem(tr("Differentiate data along direction(s)")); + c->addItem(tr("Laplace transform along direction(s)")); + c->addItem(tr("Swap data along direction(s)")); + c->addItem(tr("Mirror data along direction(s)")); + c->addItem(tr("Sin-Fourier transform along direction(s)")); + c->addItem(tr("Cos-Fourier transform along direction(s)")); + c->addItem(tr("Hankel transform along direction(s)")); + c->addItem(tr("Sew data along direction(s)")); + c->addItem(tr("Find envelope along direction(s)")); + c->setCurrentIndex(0); + + f1 = new QLineEdit("z",d); v->addWidget(f1); + QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1); + b = new QPushButton(tr("Cancel"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(reject())); + b = new QPushButton(tr("OK"), d); h->addWidget(b); + connect(b, SIGNAL(clicked()), d, SLOT(accept())); + b->setDefault(true); + // now execute dialog and get values + bool res = d->exec(); + QString val = f1->text(), mgl; + int k = c->currentIndex(); + QString self = QString::fromStdWString(var->s); + if(res) + { + if(k<0) + { + QMessageBox::warning(d, tr("UDAV - make new data"), + tr("No action is selected. Do nothing.")); + return; + } + switch(k) + { + case 0: mgl = "modify "+self+" '"+val+"'"; break; + case 1: mgl = "transpose "+self+" '"+val+"'"; break; + case 2: mgl = "smooth "+self+" '"+val+"'"; break; + case 3: mgl = "cumsum "+self+" '"+val+"'"; break; + case 4: mgl = "integrate "+self+" '"+val+"'"; break; + case 5: mgl = "diff "+self+" '"+val+"'"; break; + case 6: mgl = "diff2 "+self+" '"+val+"'"; break; + case 7: mgl = "swap "+self+" '"+val+"'"; break; + case 8: mgl = "mirror "+self+" '"+val+"'"; break; + case 9: mgl = "sinfft "+self+" '"+val+"'"; break; + case 10: mgl = "cosfft "+self+" '"+val+"'"; break; + case 11: mgl = "hankel "+self+" '"+val+"'"; break; + case 12: mgl = "sew "+self+" '"+val+"'"; break; + case 13: mgl = "envelop "+self+" '"+val+"'"; break; + } + } + if(!mgl.isEmpty()) + { + mglGraph gr; + parser.Execute(&gr,mgl.toStdString().c_str()); + opers += mgl+"\n"; + updateDataItems(); + } +} +//----------------------------------------------------------------------------- +void DatPanel::toolTop(QBoxLayout *l) +{ + QAction *a; + QMenu *o; + QToolButton *bb; + + // file menu + o = menu->addMenu(tr("File")); + a = new QAction(QPixmap(":/xpm/document-open.png"), tr("Load data"), this); + connect(a, SIGNAL(triggered()), this, SLOT(load())); + a->setToolTip(tr("Load data from file. Data will be deleted only\nat exit but UDAV will not ask to save it (Ctrl+Shift+O).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_O); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/document-save.png"), tr("Save data"), this); + connect(a, SIGNAL(triggered()), this, SLOT(save())); + a->setToolTip(tr("Save data to a file (Ctrl+Shift+S).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_S); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + +// o->addSeparator(); bb->addSeparator(); +// a = new QAction(QPixmap(insert_xpm), tr("Insert as list"), this); +// connect(a, SIGNAL(triggered()), this, SLOT(list())); +// o->addAction(a); +// bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + + a = new QAction(QPixmap(plot_xpm), tr("Plot data"), this); + connect(a, SIGNAL(triggered()), this, SLOT(plot())); + a->setToolTip(tr("Plot data in new script window. You may select the kind\nof plot, its style and so on.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-copy.png"), tr("Copy data"), this); + connect(a, SIGNAL(triggered()), this, SLOT(copy())); + a->setToolTip(tr("Copy range of numbers to clipboard (Ctrl+Shift+C).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_C); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-paste.png"), tr("Paste data"), this); + connect(a, SIGNAL(triggered()), this, SLOT(copy())); + a->setToolTip(tr("Paste range of numbers from clipboard (Ctrl+Shift+P).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_V); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + // navigation menu + o = menu->addMenu(tr("Navigate")); + a = new QAction(QPixmap(":/xpm/go-first.png"), tr("First slice"), this); + connect(a, SIGNAL(triggered()), this, SLOT(first())); + a->setToolTip(tr("Go to the first data slice for 3D data.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/go-previous.png"), tr("Prev. slice"), this); + connect(a, SIGNAL(triggered()), this, SLOT(prev())); + a->setToolTip(tr("Go to the previous data slice for 3D data.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + sb = new QSpinBox(this); + l->addWidget(sb); sb->setRange(0,0); + sb->setToolTip(tr("Go to the specified data slice for 3D data.")); + connect(sb, SIGNAL(valueChanged(int)), this, SLOT(setSlice(int))); + connect(this, SIGNAL(sliceChanged(int)), sb, SLOT(setValue(int))); + connect(this, SIGNAL(nzChanged(int)), this, SLOT(setNz(int))); + + a = new QAction(tr("Go to slice"), this); + connect(a, SIGNAL(triggered()), this, SLOT(gosl())); + a->setToolTip(tr("Go to the specified data slice for 3D data.")); + o->addAction(a); + + a = new QAction(QPixmap(":/xpm/go-next.png"), tr("Next slice"), this); + connect(a, SIGNAL(triggered()), this, SLOT(next())); + a->setToolTip(tr("Go to the next data slice for 3D data.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/go-last.png"), tr("Last slice"), this); + connect(a, SIGNAL(triggered()), this, SLOT(last())); + a->setToolTip(tr("Go to the last data slice for 3D data.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); +} +//----------------------------------------------------------------------------- +void DatPanel::toolLeft(QBoxLayout *l) +{ + QAction *a; + QMenu *o; + QToolButton *bb; + + // size menu + o = menu->addMenu(tr("Sizes")); + a = new QAction(QPixmap(":/xpm/document-new.png"), tr("Create new"), this); + connect(a, SIGNAL(triggered()), this, SLOT(create())); + a->setToolTip(tr("Recreate the data with new sizes and fill it by zeros (Ctrl+Shift+N).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_N); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(size_xpm), tr("Resize"), this); + connect(a, SIGNAL(triggered()), this, SLOT(reSize())); + a->setToolTip(tr("Resize (interpolate) the data to specified sizes (Ctrl+Shift+R).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_R); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(squize_xpm), tr("Squeeze"), this); + connect(a, SIGNAL(triggered()), this, SLOT(squize())); + a->setToolTip(tr("Keep only each n-th element of the data array.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(crop_xpm), tr("Cro&p"), this); + connect(a, SIGNAL(triggered()), this, SLOT(crop())); + a->setToolTip(tr("Crop the data edges. Useful to cut off the zero-filled area.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(oper_of_xpm), tr("Transform"), this); + connect(a, SIGNAL(triggered()), this, SLOT(newdat())); + a->setToolTip(tr("Transform data along dimension(s) (Ctrl+Shift+T).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_T); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(oper_dir_xpm), tr("Make new (Ctrl+Shift+M)"), this); + connect(a, SIGNAL(triggered()), this, SLOT(oper())); + a->setToolTip(tr("Make another data.")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_M); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(hist_xpm), tr("Histogram (Ctrl+Shift+H)"), this); + connect(a, SIGNAL(triggered()), this, SLOT(hist())); + a->setToolTip(tr("Find histogram of data.")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_H); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + +/* a = new QAction(QPixmap(":/xpm/view-refresh.png"), tr("Refresh"), this); + connect(a, SIGNAL(triggered()), this, SLOT(refresh())); + a->setToolTip(tr("Refresh data values.")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a);*/ + +/* a = new QAction(tr("Rearrange"), this); // TODO: move in generalized dialog + connect(a, SIGNAL(triggered()), this, SLOT(rearrange())); + a->setToolTip(tr("Rearrange data sizes without changing data values.")); + o->addAction(a); + a = new QAction(tr("Fill in range"), this); + connect(a, SIGNAL(triggered()), this, SLOT(inrange())); + a->setToolTip(tr("Fill data equidistantly from one value to another.")); + o->addAction(a); + a = new QAction(tr("Normalize"), this); + connect(a, SIGNAL(triggered()), this, SLOT(norm())); + a->setToolTip(tr("Normalize data so that its minimal\nand maximal values be in specified range.")); + o->addAction(a); + a = new QAction(tr("Norm. slices"), this); + connect(a, SIGNAL(triggered()), this, SLOT(normsl())); + a->setToolTip(tr("Normalize each data slice perpendicular to some direction\nso that its minimal and maximal values be in specified range.")); + o->addAction(a);*/ + + l->addStretch(1); +} +//----------------------------------------------------------------------------- +QString DatPanel::dataName() { return QString::fromStdWString(var->s); } +//----------------------------------------------------------------------------- diff --git a/udav/dat_pnl.h b/udav/dat_pnl.h new file mode 100644 index 0000000..28d444f --- /dev/null +++ b/udav/dat_pnl.h @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DAT_PNL_H +#define DAT_PNL_H +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +class mglVar; +class QMenu; +class QBoxLayout; +class QTableWidget; +class QSpinBox; +class InfoDialog; +//----------------------------------------------------------------------------- +/// Window for viewing, handling and editing the data array +class DatPanel : public QWidget +{ +Q_OBJECT +public: + QMenu *menu; + InfoDialog *infoDlg; ///< Reference to dialog !!! + DatPanel(InfoDialog *inf, QWidget *parent = 0); + ~DatPanel(); + + void setVar(mglVar *v); + inline long GetNz() { return nz; } ///< Get number of slices + QString dataName(); + +public slots: + QString dataOper() { return opers; } + void refresh(); ///< Refresh table with new data values + +signals: + void sliceChanged(int); + void nzChanged(int); + +private slots: + void setSlice(int k); + void putValue(int r, int c); + // menu genereal + void load(); + void save(); + void copy(); + void paste(); + void plot(); + void list(); + // menu fill + void inrange(); + void norm(); + void normsl(); + // menu resize + void create(); + void reSize(); + void squize(); + void crop(); + void rearrange(); + // menu change + void oper(); + // menu another + void newdat(); + void hist(); + // menu navigation + void first(); + void last(); + void next(); + void prev(); + void gosl(); + void setNz(int nz); + +private: + int nx,ny,nz; ///< Data sizes + QString id; + QString opers; + QTableWidget *tab; ///< Table itself + int kz; ///< Current z-slice + mglVar *var; ///< Variable with data +// QSpinBox *sb; ///< SpinBox for selecting slice + bool ready; ///< Data is refreshed + QSpinBox *sb; + + bool sizesDialog(const QString &cap, const QString &lab, const QString &desc1, const QString &desc2, const QString &desc3, QString &val1, QString &val2, QString &val3); + void toolTop(QBoxLayout *l); + void toolLeft(QBoxLayout *l); +}; +//----------------------------------------------------------------------------- +#endif // DAT_PNL_H +//----------------------------------------------------------------------------- diff --git a/udav/data_dlg.cpp b/udav/data_dlg.cpp new file mode 100644 index 0000000..379dfa1 --- /dev/null +++ b/udav/data_dlg.cpp @@ -0,0 +1,144 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include +extern mglParse parser; +#include "data_dlg.h" +//----------------------------------------------------------------------------- +DataDialog::DataDialog(QWidget* parent): QDialog(parent) +{ + setWindowTitle(tr("UDAV - Insert style/scheme")); + QHBoxLayout *h; + QVBoxLayout *v; + QGridLayout *g; + QLabel *l; + QPushButton *b; + + v = new QVBoxLayout(this); + h = new QHBoxLayout(); v->addLayout(h); + l = new QLabel(tr("Data name"), this); h->addWidget(l); + name = new QComboBox(this); h->addWidget(name); + + g = new QGridLayout(); v->addLayout(g); + + l = new QLabel("x1", this); g->addWidget(l, 0, 0); + x1 = new QSpinBox(this); x1->setMinimum(-1); g->addWidget(x1, 0, 1); + l = new QLabel("x2", this); g->addWidget(l, 0, 2); + x2 = new QSpinBox(this); x2->setMinimum(-1); g->addWidget(x2, 0, 3); + + l = new QLabel("y1", this); g->addWidget(l, 1, 0); + y1 = new QSpinBox(this); y1->setMinimum(-1); g->addWidget(y1, 1, 1); + l = new QLabel("y2", this); g->addWidget(l, 1, 2); + y2 = new QSpinBox(this); y2->setMinimum(-1); g->addWidget(y2, 1, 3); + + l = new QLabel("z1", this); g->addWidget(l, 2, 0); + z1 = new QSpinBox(this); z1->setMinimum(-1); g->addWidget(z1, 2, 1); + l = new QLabel("z2", this); g->addWidget(l, 2, 2); + z2 = new QSpinBox(this); z2->setMinimum(-1); g->addWidget(z2, 2, 3); + + x1->setValue(-1); y1->setValue(-1); z1->setValue(-1); + x2->setValue(-1); y2->setValue(-1); z2->setValue(-1); + + l = new QLabel(tr("Operation")); g->addWidget(l, 3, 0); + oper = new QComboBox(this); g->addWidget(oper, 3, 1); + oper->addItem(tr("none")); oper->addItem(tr("sum")); + oper->addItem(tr("min")); oper->addItem(tr("max")); + l = new QLabel("along", this); g->addWidget(l, 3, 2); + dirs = new QComboBox(this); g->addWidget(dirs, 3, 3); + dirs->addItem("xyz"); + dirs->addItem("x"); dirs->addItem("y"); dirs->addItem("z"); + dirs->addItem("xy"); dirs->addItem("xz"); dirs->addItem("yz"); + + connect(name, SIGNAL(currentIndexChanged(int)), this, SLOT(nameChanged())); + connect(x1, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(x2, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(y1, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(y2, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(z1, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(z2, SIGNAL(valueChanged(int)), this, SLOT(updateRes())); + connect(oper, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRes())); + connect(dirs, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRes())); + + sizes = new QLabel(tr("Result")); v->addWidget(sizes); + res = new QLineEdit(this); v->addWidget(res); + connect(res, SIGNAL(textChanged(QString)), this, SLOT(userRes())); + + h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(accept())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +void DataDialog::nameChanged() +{ + QString var = name->currentText(); + wchar_t *txt=new wchar_t[var.length()+1]; + var.toWCharArray(txt); txt[var.length()]=0; + mglData dat=parser.Calc(txt); delete []txt; + x1->setMaximum(dat.nx-1); x1->setValue(-1); + x2->setMaximum(dat.nx-1); x2->setValue(-1); + y1->setMaximum(dat.ny-1); y1->setValue(-1); + y2->setMaximum(dat.ny-1); y2->setValue(-1); + z1->setMaximum(dat.nz-1); z1->setValue(-1); + z2->setMaximum(dat.nz-1); z2->setValue(-1); +} +//----------------------------------------------------------------------------- +void DataDialog::updateRes() +{ + result = name->currentText(); + int nx1 = x1->value(), nx2 = x2->value(), ny1 = y1->value(), ny2 = y2->value(), nz1 = z1->value(), nz2 = z2->value(); + if(nx1>=0 || ny1>=0 || nz1>=0 || nx2>=0 || ny2>=0 || nz2>=0) + result += "(" + (nx1<0?"":QString::number(nx1)) + ":" + (nx2<0?"":QString::number(nx2)) + "," + + (ny1<0?"":QString::number(ny1)) + ":" + (ny2<0?"":QString::number(ny2)) + "," + + (nz1<0?"":QString::number(nz1)) + ":" + (nz2<0?"":QString::number(nz2)) + ")"; + if(oper->currentIndex()>0) + result = "{" + oper->currentText() + " " + result + " '" + dirs->currentText() + "'}"; + wchar_t *txt=new wchar_t[result.length()+1]; + result.toWCharArray(txt); txt[result.length()]=0; + mglData dat=parser.Calc(txt); delete []txt; + sizes->setText(tr("Result (will have sizes ") + QString::number(dat.nx)+"*"+QString::number(dat.ny)+"*"+QString::number(dat.nz)+")" ); + res->setText(result); +} +//----------------------------------------------------------------------------- +void DataDialog::updateNames() +{ + name->clear(); + mglVar *v = parser.FindVar(""); + QString s; + while(v) + { name->addItem(QString::fromStdWString(v->s)); v = v->next; } + +} +//----------------------------------------------------------------------------- +void DataDialog::userRes() +{ + QString txt = res->text(); + if(txt != result) + { result = txt; sizes->setText(tr("Result")); } +} +//----------------------------------------------------------------------------- diff --git a/udav/data_dlg.h b/udav/data_dlg.h new file mode 100644 index 0000000..048da95 --- /dev/null +++ b/udav/data_dlg.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef DATADIALOG_H +#define DATADIALOG_H +//----------------------------------------------------------------------------- +#include +class QComboBox; +class QLineEdit; +class QSpinBox; +class QLabel; +class QShowEvent; +//----------------------------------------------------------------------------- +/// Selecting styles of command (like line style, color scheme, font style, axis style) +class DataDialog : public QDialog +{ + Q_OBJECT +public: + QString getData() { return result; }; + void updateNames(); + DataDialog(QWidget *parent = 0); + ~DataDialog(){}; +protected: + virtual void showEvent(QShowEvent *ev) + { updateNames(); QDialog::showEvent(ev); } +private slots: + void nameChanged(); + void updateRes(); + void userRes(); +private: + QString result; + QComboBox *name, *suffix, *oper, *dirs; + QLineEdit *res, *func; + QSpinBox *x1, *y1, *z1, *x2, *y2, *z2; + QLabel *sizes; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/files_dlg.cpp b/udav/files_dlg.cpp new file mode 100644 index 0000000..9be25ee --- /dev/null +++ b/udav/files_dlg.cpp @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include "files_dlg.h" +//----------------------------------------------------------------------------- +FilesDialog::FilesDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Set template parameters")); + QHBoxLayout *h; + QVBoxLayout *v; + QGridLayout *g; + QLabel *l; + QPushButton *b; + + v = new QVBoxLayout(this); + g = new QGridLayout(); v->addLayout(g); + l = new QLabel(tr("String for %1"), this); g->addWidget(l, 0, 0); + a[0] = new QLineEdit(this); g->addWidget(a[0], 1, 0); + l = new QLabel(tr("String for %2"), this); g->addWidget(l, 0, 1); + a[1] = new QLineEdit(this); g->addWidget(a[1], 1, 1); + l = new QLabel(tr("String for %3"), this); g->addWidget(l, 2, 0); + a[2] = new QLineEdit(this); g->addWidget(a[2], 3, 0); + l = new QLabel(tr("String for %4"), this); g->addWidget(l, 2, 1); + a[3] = new QLineEdit(this); g->addWidget(a[3], 3, 1); + l = new QLabel(tr("String for %5"), this); g->addWidget(l, 4, 0); + a[4] = new QLineEdit(this); g->addWidget(a[4], 5, 0); + l = new QLabel(tr("String for %6"), this); g->addWidget(l, 4, 1); + a[5] = new QLineEdit(this); g->addWidget(a[5], 5, 1); + l = new QLabel(tr("String for %7"), this); g->addWidget(l, 6, 0); + a[6] = new QLineEdit(this); g->addWidget(a[6], 7, 0); + l = new QLabel(tr("String for %8"), this); g->addWidget(l, 6, 1); + a[7] = new QLineEdit(this); g->addWidget(a[7], 7, 1); + l = new QLabel(tr("String for %9"), this); g->addWidget(l, 8, 0); + a[8] = new QLineEdit(this); g->addWidget(a[8], 9, 0); + + h = new QHBoxLayout(); h->addStretch(1); v->addLayout(h); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(putArguments())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +FilesDialog::~FilesDialog() {} +//----------------------------------------------------------------------------- +void FilesDialog::putArguments() +{ + for(int i=0;i<9;i++) s[i] = a[i]->text(); + accept(); +} +//----------------------------------------------------------------------------- +void FilesDialog::setNumFiles(int n) +{ + for(int i=0;i<9;i++) a[i]->setEnabled(i9) narg=9; +} +//----------------------------------------------------------------------------- +QString FilesDialog::putFiles(const QString &str) +{ + QString res=str; + switch(narg) + { + case 1: res = str.arg(s[0]); break; + case 2: res = str.arg(s[0],s[1]); break; + case 3: res = str.arg(s[0],s[1],s[2]); break; + case 4: res = str.arg(s[0],s[1],s[2],s[3]); break; + case 5: res = str.arg(s[0],s[1],s[2],s[3],s[4]); break; + case 6: res = str.arg(s[0],s[1],s[2],s[3],s[4],s[5]); break; + case 7: res = str.arg(s[0],s[1],s[2],s[3],s[4],s[5],s[6]); break; + case 8: res = str.arg(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7]); break; + case 9: res = str.arg(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8]); break; + } + return res; +} +//----------------------------------------------------------------------------- diff --git a/udav/files_dlg.h b/udav/files_dlg.h new file mode 100644 index 0000000..2bb3177 --- /dev/null +++ b/udav/files_dlg.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FILES_DLG_H +#define FILES_DLG_H +//----------------------------------------------------------------------------- +#include +class QLineEdit; +class QComboBox; +class QRadioButton; +//----------------------------------------------------------------------------- +/// Dialog for enetring script arguments $0...$9 +class FilesDialog : public QDialog +{ +Q_OBJECT +public: + FilesDialog(QWidget *parent=0); + ~FilesDialog(); + QString putFiles(const QString &str); + void setNumFiles(int n); + +private slots: + void putArguments(); +private: + QLineEdit *a[9]; + QString s[9]; + int narg; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/find_dlg.cpp b/udav/find_dlg.cpp new file mode 100644 index 0000000..56bbaf1 --- /dev/null +++ b/udav/find_dlg.cpp @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "find_dlg.h" +//----------------------------------------------------------------------------- +FindDialog::FindDialog(QWidget *parent) : QDialog(parent) +{ + QLabel *lbl; + QHBoxLayout *a; + setWindowTitle(tr("UDAV - Find")); + QVBoxLayout *o = new QVBoxLayout; + a = new QHBoxLayout; o->addLayout(a); + lbl = new QLabel(tr("Find what:"), this); a->addWidget(lbl); + line = new QLineEdit(this); lbl->setBuddy(line); a->addWidget(line); + a = new QHBoxLayout; o->addLayout(a); + lbl = new QLabel(tr("Replace by:"), this); a->addWidget(lbl); + text = new QLineEdit(this); lbl->setBuddy(text); a->addWidget(text); + + caseUse = new QCheckBox(tr("Match case"), this); o->addWidget(caseUse); + backward = new QCheckBox(tr("Search backward"), this); o->addWidget(backward); + + a = new QHBoxLayout(this); a->setMargin(11); + a->setSpacing(6); a->addLayout(o); + o = new QVBoxLayout; a->addLayout(o); + find = new QPushButton(tr("Find"), this); o->addWidget(find); + find->setDefault(true); find->setEnabled(false); + repl= new QPushButton(tr("Replace"), this); o->addWidget(repl); + repl->setEnabled(false); + cancel = new QPushButton(tr("Close"), this); o->addWidget(cancel); + o->addStretch(1); + connect(line, SIGNAL(textChanged(const QString &)), this, SLOT(enableFind(const QString &))); + connect(find, SIGNAL(clicked()), this, SLOT(findClicked())); + connect(repl, SIGNAL(clicked()), this, SLOT(replClicked())); + connect(cancel, SIGNAL(clicked()),this, SLOT(close())); +} +//----------------------------------------------------------------------------- +FindDialog::~FindDialog() {} +//----------------------------------------------------------------------------- +void FindDialog::findClicked() +{ emit findText(line->text(), caseUse->isChecked(), backward->isChecked()); } +//----------------------------------------------------------------------------- +void FindDialog::replClicked() +{ emit replText(line->text(), text->text(), caseUse->isChecked(), backward->isChecked()); } +//----------------------------------------------------------------------------- +void FindDialog::enableFind(const QString &txt) +{ find->setEnabled(!txt.isEmpty()); repl->setEnabled(!txt.isEmpty()); } +//----------------------------------------------------------------------------- +void FindDialog::closeEvent(QCloseEvent *event) +{ + emit replText("", "", false, false); + event->accept(); +} +//----------------------------------------------------------------------------- diff --git a/udav/find_dlg.h b/udav/find_dlg.h new file mode 100644 index 0000000..921c259 --- /dev/null +++ b/udav/find_dlg.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef FIND_DLG_H +#define FIND_DLG_H +//----------------------------------------------------------------------------- +#include +class QCheckBox; +class QLineEdit; +class QPushButton; +//----------------------------------------------------------------------------- +/// Dialog for finding something in text +class FindDialog : public QDialog +{ +Q_OBJECT +public: + FindDialog(QWidget *parent = 0); + ~FindDialog(); +signals: + void findText(const QString &str, bool cs, bool fw); + void replText(const QString &str, const QString &txt, bool cs, bool fw); +protected: + void closeEvent(QCloseEvent *event); +private slots: + void findClicked(); + void replClicked(); + void enableFind(const QString &text); +private: + QLineEdit *line; + QLineEdit *text; + QCheckBox *caseUse; + QCheckBox *backward; + QPushButton *find; + QPushButton *repl; + QPushButton *cancel; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/help_pnl.cpp b/udav/help_pnl.cpp new file mode 100644 index 0000000..ed5f9b1 --- /dev/null +++ b/udav/help_pnl.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "help_pnl.h" +extern QString pathHelp; +void raisePanel(QWidget *w); +//----------------------------------------------------------------------------- +QWidget *createHlpPanel(QWidget *p) { return new HelpPanel(p); } +void showHelpMGL(QWidget *p,QString s) +{ + HelpPanel *hlp = dynamic_cast(p); + if(hlp) hlp->showHelp(s); +} +//void showExMGL(QWidget *hlp) { ((HelpPanel *)hlp)->showExamples(); } +//----------------------------------------------------------------------------- +HelpPanel::HelpPanel(QWidget *parent) : QWidget(parent) +{ + QPushButton *b; + QToolButton *t; + QVBoxLayout *o = new QVBoxLayout(this); + QHBoxLayout *a = new QHBoxLayout(); o->addLayout(a); + help = new QTextBrowser(this); o->addWidget(help); + help->setOpenExternalLinks(false); + + b = new QPushButton(QPixmap(":/xpm/go-previous.png"), tr("Backward")); + connect(b, SIGNAL(clicked()), help, SLOT(backward())); a->addWidget(b); + entry = new QLineEdit(this); a->addWidget(entry); + connect(entry, SIGNAL(textChanged(const QString &)), this, SLOT(showHelp(const QString &))); + connect(entry, SIGNAL(returnPressed()), this, SLOT(showHelp())); + b = new QPushButton(QPixmap(":/xpm/go-next.png"), tr("Forward")); + connect(b, SIGNAL(clicked()), help, SLOT(forward())); a->addWidget(b); +// b = new QPushButton(QPixmap(":/xpm/help-faq.png"), tr("Examples")); +// connect(b, SIGNAL(clicked()), this, SLOT(showExamples())); a->addWidget(b); + t = new QToolButton(this); t->setIcon(QPixmap(":/xpm/zoom-in.png")); + connect(t, SIGNAL(clicked()), this, SLOT(zoomIn())); a->addWidget(t); + t = new QToolButton(this); t->setIcon(QPixmap(":/xpm/zoom-out.png")); + connect(t, SIGNAL(clicked()), this, SLOT(zoomOut())); a->addWidget(t); + setWindowTitle(tr("Help")); +} +//----------------------------------------------------------------------------- +// void HelpPanel::showExamples() +// { +// QStringList s; s<<(pathHelp); +// help->setSearchPaths(s); +// setWindowTitle("Examples"); raisePanel(this); +// help->setSource(tr("mgl_en")+"_2.html"); +// } +//----------------------------------------------------------------------------- +void HelpPanel::showHelp(const QString &txt) +{ + QString cmd=txt; + raisePanel(this); + QStringList s; s<<(pathHelp); + help->setSearchPaths(s); + if(cmd.isEmpty()) cmd = entry->text().trimmed(); + if(cmd.isEmpty()) help->setSource(tr("mgl_en")+".html"); + else help->setSource(tr("mgl_en")+".html#"+cmd); + setWindowTitle("Help"); +} +//----------------------------------------------------------------------------- +void HelpPanel::zoomIn() +{ QFont f(help->font()); f.setPointSize(f.pointSize()+1); help->setFont(f); } +//----------------------------------------------------------------------------- +void HelpPanel::zoomOut() +{ QFont f(help->font()); f.setPointSize(f.pointSize()-1); help->setFont(f); } +//----------------------------------------------------------------------------- diff --git a/udav/help_pnl.h b/udav/help_pnl.h new file mode 100644 index 0000000..132f7ed --- /dev/null +++ b/udav/help_pnl.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef HELP_PNL_H +#define HELP_PNL_H +//----------------------------------------------------------------------------- +#include +class QTextBrowser; +class QLineEdit; +//----------------------------------------------------------------------------- +class HelpPanel : public QWidget +{ +Q_OBJECT +public: + HelpPanel(QWidget *parent = 0); +public slots: +// void showExamples(); + void showHelp(const QString &cmd=QString::null); + void zoomIn(); + void zoomOut(); +private: + QTextBrowser *help; + QLineEdit *entry; +}; +//----------------------------------------------------------------------------- +#endif // HELP_PNL_H +//----------------------------------------------------------------------------- diff --git a/udav/hint_dlg.cpp b/udav/hint_dlg.cpp new file mode 100644 index 0000000..be555e4 --- /dev/null +++ b/udav/hint_dlg.cpp @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include "hint_dlg.h" +#include "mgl2/data_cf.h" +//----------------------------------------------------------------------------- +#define qtr HintDialog::tr +QString hints[] = { + qtr("You can shift axis range by pressing middle button and moving mouse. Also, you can zoom in/out axis range by using mouse wheel."), + qtr("You can rotate/shift/zoom whole plot by mouse. Just press 'Rotate' toolbutton, click image and hold a mouse button: left button for rotation, right button for zoom/perspective, middle button for shift."), + qtr("You may quickly draw the data from file. Just use: udav 'filename.dat' in command line."), + qtr("You can copy the current image to clipboard by pressing Ctrl-Shift-C. Later you can paste it directly into yours document or presentation."), + qtr("You can export image into a set of format (EPS, SVG, PNG, JPEG) by pressing right mouse button inside image and selecting 'Export as ...'."), + qtr("You can setup colors for script highlighting in Property dialog. Just select menu item 'Settings/Properties'."), + qtr("You can save the parameter of animation inside MGL script by using comment started from '##a ' or '##c ' for loops."), + qtr("New drawing never clears things drawn already. For example, you can make a surface with contour lines by calling commands 'surf' and 'cont' one after another (in any order). "), + qtr("You can put several plots in the same image by help of commands 'subplot' or 'inplot'."), + qtr("All indexes (of data arrays, subplots and so on) are always start from 0."), + qtr("You can edit MGL file in any text editor. Also you can run it in console by help of commands: mglconv, mglview."), + qtr("You can use command 'once on|off' for marking the block which should be executed only once. For example, this can be the block of large data reading/creating/handling. Press F9 (or menu item 'Graphics/Reload') to re-execute this block."), + qtr("You can use command 'stop' for terminating script parsing. It is useful if you don't want to execute a part of script."), + qtr("You can type arbitrary expression as input argument for data or number. In last case (for numbers), the first value of data array is used."), + qtr("There is powerful calculator with a lot of special functions. You can use buttons or keyboard to type the expression. Also you can use existed variables in the expression."), + qtr("The calculator can help you to put complex expression in the script. Just type the expression (which may depend on coordinates x,y,z and so on) and put it into the script."), + qtr("You can easily insert file or folder names, last fitted formula or numerical value of selection by using menu Edit|Insert."), + qtr("The special dialog (Edit|Insert|New Command) help you select the command, fill its arguments and put it into the script."), + qtr("You can put several plotting commands in the same line or in separate function, for highlighting all of them simultaneously."), + qtr("") +}; +//----------------------------------------------------------------------------- +// +// Hint dialog +// +//----------------------------------------------------------------------------- +HintDialog::HintDialog(QWidget *parent) : QDialog(parent) +{ + for(numHints=0;!hints[numHints].isEmpty();numHints++); + cur = int(mgl_rnd()*numHints); + setWindowTitle(tr("UDAV - Hint")); + QHBoxLayout *a; + QPushButton *b; + QVBoxLayout *o = new QVBoxLayout(this); + text = new QTextEdit(this); o->addWidget(text); + text->setReadOnly(true); text->setText(hints[cur]); + + start = new QCheckBox(tr("Show at startup"), this); o->addWidget(start); + start->setChecked(true); + + a = new QHBoxLayout; o->addLayout(a); + b = new QPushButton(tr("Prev"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(prevClicked())); + b = new QPushButton(tr("Next"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(nextClicked())); + b = new QPushButton(tr("Close"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(close())); +} +//----------------------------------------------------------------------------- +void HintDialog::closeEvent(QCloseEvent *) +{ + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + settings.setValue("/showHint", start->isChecked()); + settings.endGroup(); +} +//----------------------------------------------------------------------------- +void udavShowHint(QWidget *p) +{ HintDialog *hd = new HintDialog(p); hd->exec(); } +//----------------------------------------------------------------------------- diff --git a/udav/hint_dlg.h b/udav/hint_dlg.h new file mode 100644 index 0000000..338b222 --- /dev/null +++ b/udav/hint_dlg.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef HINT_DLG_H +#define HINT_DLG_H +//----------------------------------------------------------------------------- +#include +#include +class QCheckBox; +extern QString hints[]; +//----------------------------------------------------------------------------- +/// Dialog for showing hints +class HintDialog : public QDialog +{ +Q_OBJECT +public: + HintDialog(QWidget *parent = 0); + ~HintDialog() {} +protected: + void closeEvent(QCloseEvent *event); +private slots: + void nextClicked() + { cur = (cur+1)%numHints; text->setText(hints[cur]); } + void prevClicked() + { cur = (cur+numHints-1)%numHints; text->setText(hints[cur]); } +private: + int cur; + int numHints; + QTextEdit *text; + QCheckBox *start; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/info_dlg.cpp b/udav/info_dlg.cpp new file mode 100644 index 0000000..9531bb4 --- /dev/null +++ b/udav/info_dlg.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include "mgl2/qmathgl.h" +#include "info_dlg.h" +extern mglParse parser; +//----------------------------------------------------------------------------- +InfoDialog::InfoDialog(QWidget *parent) : QDialog(parent) +{ + var = 0; kz = 0; allowRefresh = true; + QWidget *p; + QVBoxLayout *v, *u; + QLabel *l; + QTabWidget *tab = new QTabWidget(this); + u = new QVBoxLayout(this); u->addWidget(tab); + // graphics + p = new QWidget(this); v = new QVBoxLayout(p); + l = new QLabel(tr("Select kind of plot"),this); v->addWidget(l); + kind = new QComboBox(this); v->addWidget(kind); + mgl = new QMathGL(this); v->addWidget(mgl,1); + mgl->autoResize = true; mgl->appName = tr("Data preview"); + mgl->setToolTip(tr("Data preview for current slice.")); + + draw = new mglDrawScript(parser.Self()); mgl->setDraw(draw); + + kind->addItem(tr("1D plot")); kind->addItem(tr("2D plot")); + kind->setCurrentIndex(0); // kind->addItem(tr("3D plot")); + connect(kind, SIGNAL(currentIndexChanged(int)), this, SLOT(refresh())); + kind->setToolTip(tr("Kind of plots: lines for 1D, density for 2D.")); + tab->addTab(p, tr("Preview")); + // information + info = new QTextEdit(this); + info->setToolTip(tr("Short information about the data.")); + tab->addTab(info, tr("Information")); + connect(mgl,SIGNAL(showWarn(QString)),info,SLOT(setText(QString))); +} +//----------------------------------------------------------------------------- +InfoDialog::~InfoDialog() {} +//----------------------------------------------------------------------------- +#include +void InfoDialog::refresh(bool force) +{ + if(!var || (!force && (!allowRefresh || !isVisible()))) return; + QString text, name, sub; + name = QString::fromStdWString(var->s); + sub = "(:,:,"+QString::number(kz)+")\n"; + int i = kind->currentIndex(); + if(i<1) text = "yrange "+name+"\nplot "+name + sub; + else text = "crange "+name+"\ndens "+name + sub; + text = "zoom 0.15 0.15 0.85 0.85\nbox\n" + text + "\ninfo "+name; + draw->text = text; mgl->update(); +} +//----------------------------------------------------------------------------- +void InfoDialog::setVar(mglVar *v) +{ + var=v; + if(v) kind->setCurrentIndex(v->ny>1 ? 1:0); + refresh(); +} +//----------------------------------------------------------------------------- +void InfoDialog::showEvent(QShowEvent *) +{ refresh(true); } +//----------------------------------------------------------------------------- diff --git a/udav/info_dlg.h b/udav/info_dlg.h new file mode 100644 index 0000000..34113f0 --- /dev/null +++ b/udav/info_dlg.h @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef INFODIALOG_H +#define INFODIALOG_H +//----------------------------------------------------------------------------- +#include +#include +//----------------------------------------------------------------------------- +class QMathGL; +class mglDrawScript; +class mglVar; +class QComboBox; +class QTextEdit; +//----------------------------------------------------------------------------- +/// Display picture and short information about variable +class InfoDialog : public QDialog +{ +Q_OBJECT +public: + InfoDialog(QWidget *parent = 0); + virtual ~InfoDialog(); + void setVar(mglVar *v); + void setSlice(int k) { kz=k; refresh(); } + bool allowRefresh; +// void setName(QString &name); + void showEvent(QShowEvent *ev); + +public slots: + void refresh(bool force=false); + +private: + int kz; + mglVar *var; + QMathGL *mgl; + QTextEdit *info; + QComboBox *kind; + mglDrawScript *draw; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/mem_pnl.cpp b/udav/mem_pnl.cpp new file mode 100644 index 0000000..113540d --- /dev/null +++ b/udav/mem_pnl.cpp @@ -0,0 +1,183 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "mem_pnl.h" +#include "info_dlg.h" +//----------------------------------------------------------------------------- +#include "xpm/table.xpm" +#include "xpm/preview.xpm" +//----------------------------------------------------------------------------- +extern bool mglAutoSave; +extern mglParse parser; +QWidget *newDataWnd(InfoDialog *inf, QWidget *wnd, mglVar *v); +void refreshData(QWidget *w); +//----------------------------------------------------------------------------- +QWidget *createMemPanel(QWidget *p) // NOTE: parent should be MainWindow +{ + MemPanel *m = new MemPanel(p); + m->wnd = p; return m; +} +//----------------------------------------------------------------------------- +void refreshMemPanel(QWidget *p) +{ + MemPanel *m = dynamic_cast(p); + if(m) m->refresh(); +} +//----------------------------------------------------------------------------- +MemPanel::MemPanel(QWidget *parent) : QWidget(parent) +{ + QHBoxLayout *h; + QVBoxLayout *v; + QToolButton *b; + + infoDlg = new InfoDialog(this); + infoDlg->setModal(true); infoDlg->allowRefresh=false; + + v = new QVBoxLayout(this); h = new QHBoxLayout(); v->addLayout(h); + b = new QToolButton(this); b->setIcon(QPixmap(":/xpm/document-new.png")); + b->setToolTip(tr("Create new data array")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(newTable())); + b = new QToolButton(this); b->setIcon(QPixmap(table_xpm)); + b->setToolTip(tr("Edit selected data array")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(editData())); + b = new QToolButton(this); b->setIcon(QPixmap(":/xpm/edit-delete.png")); + b->setToolTip(tr("Delete selected data array")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(delData())); + b = new QToolButton(this); b->setIcon(QPixmap(preview_xpm)); + b->setToolTip(tr("Properties of selected data array")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(infoData())); + b = new QToolButton(this); b->setIcon(QPixmap(":/xpm/view-refresh.png")); + b->setToolTip(tr("Update list of data arrays")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(refresh())); + h->addStretch(1); + b = new QToolButton(this); b->setIcon(QPixmap(":/xpm/edit-delete.png")); + b->setToolTip(tr("Delete ALL data arrays")); h->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(delAllData())); + + colSort = 0; + tab = new QTableWidget(this); tab->setColumnCount(3); v->addWidget(tab); + QStringList sl; sl<setHorizontalHeaderLabels(sl); + connect(tab, SIGNAL(cellClicked(int,int)), this, SLOT(tableClicked(int,int))); + connect(tab, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(tableDClicked(int,int))); + + setWindowTitle(tr("Memory")); +} +//----------------------------------------------------------------------------- +void MemPanel::tableClicked(int, int col) +{ colSort = col; tab->sortItems(col); } +//----------------------------------------------------------------------------- +void MemPanel::tableDClicked(int row, int) { editData(row); } +//----------------------------------------------------------------------------- +void MemPanel::newTable() +{ + bool ok; + QString name = QInputDialog::getText(this, tr("UDAV - New variable"), + tr("Enter name for new variable"), QLineEdit::Normal, "", &ok); + if(!ok || name.isEmpty()) return; + mglVar *v = parser.AddVar(name.toStdString().c_str()); + QWidget *t; + if(v->o) t = (QWidget *)v->o; + else t = newDataWnd(infoDlg,wnd,v); + t->showMaximized(); t->activateWindow(); + refresh(); +} +//----------------------------------------------------------------------------- +void MemPanel::editData(int n) +{ + if(tab->rowCount()<1) return; + if(n<0) n = tab->currentRow(); + if(n<0) n = 0; + mglVar *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + if(!v) return; + QWidget *t; + if(v->o) t = (QWidget *)v->o; + else t = newDataWnd(infoDlg,wnd,v); + t->showMaximized(); t->activateWindow(); +} +//----------------------------------------------------------------------------- +void MemPanel::delData() +{ + if(tab->rowCount()<1) return; + int n = tab->currentRow(); + if(n<0) n = 0; + mglVar *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + if(!v && v->o) ((QWidget *)v->o)->close(); + parser.DeleteVar(tab->item(n,0)->text().toStdString().c_str()); + refresh(); +} +//----------------------------------------------------------------------------- +void MemPanel::delAllData() +{ + if(QMessageBox::information(this, tr("UDAV - delete all data"), + tr("Do you want to delete all data?"), QMessageBox::No, + QMessageBox::Yes)!=QMessageBox::Yes) return; + parser.DeleteAll(); refresh(); +} +//----------------------------------------------------------------------------- +void MemPanel::infoData() +{ + if(tab->rowCount()<1) return; + int n = tab->currentRow(); + if(n<0) n = 0; + mglVar *v = parser.FindVar(tab->item(n,0)->text().toStdString().c_str()); + if(!v) return; + infoDlg->setVar(v); + QString s = QString::fromStdWString(v->s); + infoDlg->setWindowTitle(s + tr(" - UDAV preview")); + infoDlg->refresh(); + infoDlg->show(); +} +//----------------------------------------------------------------------------- +void MemPanel::refresh() +{ + mglVar *v = parser.FindVar(""); + int n = 0; + while(v) { v = v->next; n++; } + tab->setRowCount(n); + v = parser.FindVar(""); n = 0; + QString s; + QTableWidgetItem *it; + Qt::ItemFlags flags=Qt::ItemIsSelectable|Qt::ItemIsEnabled; + while(v) + { + s = QString::fromStdWString(v->s); + it = new QTableWidgetItem(s); + tab->setItem(n,0,it); it->setFlags(flags); + s.sprintf("%ld * %ld * %ld", v->nx, v->ny, v->nz); + it = new QTableWidgetItem(s); + tab->setItem(n,1,it); it->setFlags(flags); + it->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + s.sprintf("%12ld", v->nx*v->ny*v->nz*sizeof(mreal)); + it = new QTableWidgetItem(s); + tab->setItem(n,2,it); it->setFlags(flags); + it->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); + if(v->o) refreshData((QWidget *)v->o); + v = v->next; n++; + } + tab->sortItems(colSort); +} +//----------------------------------------------------------------------------- diff --git a/udav/mem_pnl.h b/udav/mem_pnl.h new file mode 100644 index 0000000..db393ed --- /dev/null +++ b/udav/mem_pnl.h @@ -0,0 +1,50 @@ +#ifndef MEM_PNL_H +#define MEM_PNL_H +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +class mglVar; +class InfoDialog; +class QTableWidget; +//----------------------------------------------------------------------------- +class MemPanel : public QWidget +{ +Q_OBJECT +public: + QWidget *wnd; + MemPanel(QWidget *parent = 0); +public slots: + void refresh(); ///< refresh list of variables +private slots: + void newTable(); + void editData(int n=-1); + void infoData(); + void delAllData(); + void delData(); + void tableClicked(int row, int col); + void tableDClicked(int row, int col); +private: + InfoDialog *infoDlg; ///< Data preview and information + QTableWidget *tab; + int colSort; +}; +//----------------------------------------------------------------------------- +#endif // MEM_PNL_H +//----------------------------------------------------------------------------- diff --git a/udav/newcmd_dlg.cpp b/udav/newcmd_dlg.cpp new file mode 100644 index 0000000..c1799e9 --- /dev/null +++ b/udav/newcmd_dlg.cpp @@ -0,0 +1,357 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "newcmd_dlg.h" +#include "opt_dlg.h" +#include "style_dlg.h" +#include "data_dlg.h" +extern mglParse parser; +extern QString pathHelp; +//----------------------------------------------------------------------------- +NewCmdDialog::NewCmdDialog(QWidget *p) : QDialog(p,Qt::WindowStaysOnTopHint) +{ + fillList(); + QPushButton *b; + QToolButton *t; + QHBoxLayout *m = new QHBoxLayout(this), *a; + QVBoxLayout *o = new QVBoxLayout; m->addLayout(o); + optDialog = new OptionDialog(this); + stlDialog = new StyleDialog(this); + datDialog = new DataDialog(this); + type = new QComboBox(this); o->addWidget(type); + type->setToolTip(tr("Groups of MGL commands")); + name = new QComboBox(this); o->addWidget(name); + name->setToolTip(tr("MGL commands for selected group")); + type->addItems(types); name->addItems(argn[0]); + info = new QLabel(this); o->addWidget(info); + info->setToolTip(tr("Short description of selected command")); + kind= new QComboBox(this); o->addWidget(kind); kind->addItem(""); + kind->setToolTip(tr("Kind of command argument order. The notation is:\n" + " * Capital arguments are data (like, Ydat);\n" + " * Argument in '' are strings (like, 'fmt');\n" + " * Other arguments are numbers (like, zval);\n" + " * Arguments in [] are optional arguments.")); + args = new QTableWidget(this); o->addWidget(args); + args->setToolTip(tr("Command arguments. Bold ones are required arguments.\n" + "Other are optional arguments but its order is required.\n" + "You can use '' for default format. See help at right\nfor default values.")); + QStringList sl; sl<setHorizontalHeaderLabels(sl); + connect(args,SIGNAL(cellDoubleClicked(int,int)), this, SLOT(insertData())); + + a = new QHBoxLayout; o->addLayout(a); + b = new QPushButton(tr("Add style"),this); a->addWidget(b); + b->setToolTip(tr("Here you can select the plot style.\nThe result will be placed in 'fmt' argument.")); + connect(b, SIGNAL(clicked()),this,SLOT(insertStl())); + b = new QPushButton(tr("Add data"),this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this,SLOT(insertData())); + b = new QPushButton(tr("Options"),this); a->addWidget(b); + b->setToolTip(tr("Here you can specify command options.\nOptions are used for additional plot tunning.")); + connect(b, SIGNAL(clicked()),this,SLOT(insertOpt())); + QLabel *l=new QLabel(tr("Options")); o->addWidget(l); + opt = new QLineEdit(this); o->addWidget(opt); + a = new QHBoxLayout; o->addLayout(a); + b = new QPushButton(tr("Cancel"),this); a->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(reject())); + b = new QPushButton(tr("OK"),this); a->addWidget(b); + connect(b, SIGNAL(clicked()), this, SLOT(finish())); + + o = new QVBoxLayout; m->addLayout(o,1); + a = new QHBoxLayout; o->addLayout(a); + help = new QTextBrowser(this); help->setMinimumWidth(500); + help->setOpenExternalLinks(false); o->addWidget(help); + t = new QToolButton(p); t->setIcon(QPixmap(":/xpm/go-previous.png")); + connect(t, SIGNAL(clicked()), help, SLOT(backward())); a->addWidget(t); + t = new QToolButton(p); t->setIcon(QPixmap(":/xpm/go-next.png")); + connect(t, SIGNAL(clicked()), help, SLOT(forward())); a->addWidget(t); + a->addStretch(1); + t = new QToolButton(p); t->setIcon(QPixmap(":/xpm/zoom-in.png")); + connect(t, SIGNAL(clicked()), this, SLOT(zoomIn())); a->addWidget(t); + t = new QToolButton(p); t->setIcon(QPixmap(":/xpm/zoom-out.png")); + connect(t, SIGNAL(clicked()), this, SLOT(zoomOut())); a->addWidget(t); + + connect(type, SIGNAL(currentIndexChanged(int)),this,SLOT(typeChanged(int))); + connect(name, SIGNAL(currentIndexChanged(int)),this,SLOT(nameChanged(int))); + connect(kind, SIGNAL(currentIndexChanged(int)),this,SLOT(kindChanged(int))); + type->setCurrentIndex(0); typeChanged(0); + setWindowTitle(tr("New command")); +} +//----------------------------------------------------------------------------- +void NewCmdDialog::zoomIn() +{ QFont f(help->font()); f.setPointSize(f.pointSize()+1); help->setFont(f); } +//----------------------------------------------------------------------------- +void NewCmdDialog::zoomOut() +{ QFont f(help->font()); f.setPointSize(f.pointSize()-1); help->setFont(f); } +//----------------------------------------------------------------------------- +void NewCmdDialog::parseCmd(const QString &txt) +{ + QString str = txt.trimmed().section(':',0,0); + QRegExp sep("[ \t]"); + QString cmd = str.section(sep,0,0),a,b; + bool opt,var,chr; + for(int i=0;i<17;i++) + { + if(cmds[i].contains(cmd)) // find command first + { + typeChanged(i); + nameChanged(cmds[i].indexOf(cmd)); + register int j,j0,k,k0; + bool ok; + for(j0=k0=-1,j=0;jk0)) { j0=j; k0=k; } + } + if(j0>=0) // best choice + { + kindChanged(j0); + for(k=0;kitem(k,1)->setText(str.section(sep,k+1,k+1).trimmed()); + } + return; // selection is done + } + } +} +//----------------------------------------------------------------------------- +void NewCmdDialog::fillList() +{ + types<16) return; + name->clear(); name->addItems(cmds[s]); name->setCurrentIndex(0); +} +//----------------------------------------------------------------------------- +void parse(QStringList &sl, const QString &s) +{ + sl.clear(); + int i, ex=0, i1=0; + bool op=false, sp=true; + for(i=0;iitemText(s), par, a; + int k; + if(n.isEmpty()) return; + QStringList ss; ss<<(pathHelp); + help->setSearchPaths(ss); + help->setSource(tr("mgl_en")+".html#"+n); + // clear old + kind->clear(); kinds.clear(); for(k=0;ksetText(QString::fromLocal8Bit(parser.CmdDesc(n.toStdString().c_str()))); + + par = QString::fromLocal8Bit(parser.CmdFormat(n.toStdString().c_str())); + int i0 = par.indexOf(' '); // first space if present + if(i0<0) { kind->addItem(par); return; } // no arguments + // parse kind of arguments + par = par.mid(i0); + for(k=0;ksetCurrentIndex(s); + kind->addItems(kinds); kind->setCurrentIndex(0); +} +//----------------------------------------------------------------------------- +void NewCmdDialog::kindChanged(int s) +{ + if(s<0 || s>NUM_CH-1) return; + cmd=""; + int nn = argn[s].count(); + QStringList lst; + for(int i=0;irowCount();i++) + lst<item(i,0)->text()+"~ "+args->item(i,1)->text(); +//return; + args->setRowCount(nn); args->setColumnCount(2); + QTableWidgetItem *it; + QString a; + QFont f; + bool optional; + for(int i=0;isetItem(i,0,it); + it = new QTableWidgetItem; args->setItem(i,1,it); + a = argn[s].at(i); + optional = (a[0]=='_' || a[0]=='+'); if(optional) a=a.mid(1); + f.setItalic(a[0].isUpper()); f.setBold(!optional); + args->item(i,0)->setText(a); args->item(i,0)->setFont(f); + args->item(i,0)->setFlags(Qt::ItemIsEnabled); + args->item(i,1)->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled); + for(int j=0;jitem(i,1)->setText(lst[j].section('~',1).trimmed()); + } +} +//----------------------------------------------------------------------------- +void NewCmdDialog::insertOpt() +{ if(optDialog->exec()) opt->setText(optDialog->getOption()); } +//----------------------------------------------------------------------------- +void NewCmdDialog::insertData() +{ + int row = args->currentRow(); + if(row<0) + { + QMessageBox::warning(this,tr("New command"), tr("No argument is selected")); + return; + } + QString a = args->item(row,0)->text(); + if(a[0].isUpper()) + { + if(datDialog->exec()) args->item(row,1)->setText(datDialog->getData()); + } + else QMessageBox::warning(this,tr("New command"), tr("This argument is not data")); +} +//----------------------------------------------------------------------------- +void NewCmdDialog::insertStl() +{ + int s=kind->currentIndex(); + if(s<0 || s>4) + { QMessageBox::warning(this,tr("New command"), + tr("Select first the proper kind of arguments")); + return; } + if(!argn[s].contains("'fmt'") && !argn[s].contains("_'fmt'")) + { QMessageBox::warning(this,tr("New command"), + tr("There is no 'fmt' argument for this command")); + return; } + int i; + i = argn[s].indexOf("'fmt'"); + if(i<0) i = argn[s].indexOf("_'fmt'"); + if(!stlDialog->exec()) return; + args->item(i,1)->setText(stlDialog->getStyle()); +} +//----------------------------------------------------------------------------- +void NewCmdDialog::finish() +{ + QString txt,cur; + int s = kind->currentIndex(); + if(s<0 || s>4) + { QMessageBox::warning(this,tr("New command"), + tr("Select first the proper kind of arguments")); + cmd=""; return; } + cmd = name->currentText(); + int n = argn[s].count(), i; + bool op=false; + for(i=0;iitem(i,1)->text(); + if(txt.isEmpty()) + { + if(cur[0]!='_' && cur[0]!='+') + { QMessageBox::warning(this,tr("New command"), + tr("You should specify required argument ")+cur); + cmd=""; return; } + if(argn[s].at(i)[0]=='_') op = true; + } + else + { + if(cur[0]=='\'' && txt[0]!='\'') + { QMessageBox::warning(this,tr("New command"), + tr("You should put text inside ' ' for argument ")+cur); + cmd=""; return; } + if(cur[1]=='\'' && txt[0]!='\'') + { QMessageBox::warning(this,tr("New command"), + tr("You should put text inside ' ' for argument ")+cur.mid(1)); + cmd=""; return; } + if(cur[0]=='_' && op) + { QMessageBox::warning(this,tr("New command"), + tr("You should specify all optional arguments before ")+cur.mid(1)); + cmd=""; return; } + cmd = cmd + ' ' + txt; + } + } + cmd = cmd + opt->text(); accept(); emit result(cmd); +} +//----------------------------------------------------------------------------- diff --git a/udav/newcmd_dlg.h b/udav/newcmd_dlg.h new file mode 100644 index 0000000..c8080e1 --- /dev/null +++ b/udav/newcmd_dlg.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef NEWCMDDIALOG_H +#define NEWCMDDIALOG_H +//----------------------------------------------------------------------------- +#include +#include +#define NUM_CH 16 // number of argument sets for a command +class QComboBox; +class QLabel; +class QLineEdit; +class QTableWidget; +class QTextBrowser; +class OptionDialog; +class StyleDialog; +class DataDialog; +//----------------------------------------------------------------------------- +class NewCmdDialog : public QDialog +{ +Q_OBJECT +public: + NewCmdDialog(QWidget *p); + const QString &getCommand() { return cmd; } + +private slots: + void typeChanged(int); + void nameChanged(int); + void kindChanged(int); + void insertData(); + void insertOpt(); + void insertStl(); + void finish(); + void zoomIn(); + void zoomOut(); + +public slots: + void parseCmd(const QString &txt); + +signals: + void result(const QString &txt); + +private: + QTextBrowser *help; + QComboBox *type, *name, *kind; + QLineEdit *opt; + QLabel *info; + QTableWidget *args; + QString cmd; + QStringList types, cmds[17], argn[NUM_CH], kinds; + OptionDialog *optDialog; + StyleDialog *stlDialog; + DataDialog *datDialog; + + void fillList(); +}; +//----------------------------------------------------------------------------- +#endif // NEWCMDDIALOG_H +//----------------------------------------------------------------------------- diff --git a/udav/open_dlg.cpp b/udav/open_dlg.cpp new file mode 100644 index 0000000..87b76e5 --- /dev/null +++ b/udav/open_dlg.cpp @@ -0,0 +1,177 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "open_dlg.h" +int numDataOpened=0; +extern mglParse parser; +QStringList dataScr; +//----------------------------------------------------------------------------- +QWidget *createDataOpenDlg(QWidget *p) { return new DataOpenDialog(p); } +QString getOpenDataFile(QWidget *w, QString filename) +{ + DataOpenDialog *d = dynamic_cast(w); + if(d) + { + d->setFile(filename); + if(d->exec()) return d->getCode(); + } + return QString(); +} +//----------------------------------------------------------------------------- +DataOpenDialog::DataOpenDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Open data file")); + QHBoxLayout *a; + QLabel *l; + QPushButton *b; + QVBoxLayout *o=new QVBoxLayout(this); + + a = new QHBoxLayout; o->addLayout(a); + l = new QLabel(tr("Data name")); a->addWidget(l); + char buf[32]; snprintf(buf,32,"mgl_%d",numDataOpened); + name = new QLineEdit(buf,this); a->addWidget(name); + + rA = new QRadioButton(tr("Auto detect data sizes"), this); + rA->setChecked(true); o->addWidget(rA); + rM = new QRadioButton(tr("Set data sizes manually"), this); + o->addWidget(rM); a = new QHBoxLayout; o->addLayout(a); + l = new QLabel(tr("Nx")); a->addWidget(l); + nx = new QLineEdit("1",this); a->addWidget(nx); + l = new QLabel(tr("Ny")); a->addWidget(l); + ny = new QLineEdit("1",this); a->addWidget(ny); + l = new QLabel(tr("Nz")); a->addWidget(l); + nz = new QLineEdit("1",this); a->addWidget(nz); + r2 = new QRadioButton(tr("Matrix with sizes from file"), this); o->addWidget(r2); + r3 = new QRadioButton(tr("3D data with sizes from file"), this);o->addWidget(r3); + + + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + dataScr = settings.value("/dataScr").toStringList().mid(0,10); + dataScr.removeDuplicates(); + settings.endGroup(); + + a = new QHBoxLayout; o->addLayout(a); + l = new QLabel(tr("Template")); a->addWidget(l,0); + scr = new QComboBox(this); a->addWidget(scr,1); + scr->setEditable(true); scr->lineEdit()->setText(""); + scr->addItem(tr("default")); scr->addItems(dataScr); + b = new QPushButton("...", this); a->addWidget(b,0); + connect(b, SIGNAL(clicked()),this, SLOT(selectScr())); + + a = new QHBoxLayout; o->addLayout(a); a->addStretch(1); + b = new QPushButton(tr("Cancel"),this); a->addWidget(b); + connect(b,SIGNAL(clicked()),this,SLOT(reject())); + b = new QPushButton(tr("OK"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(prepareResult())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +DataOpenDialog::~DataOpenDialog(){} +//----------------------------------------------------------------------------- +void DataOpenDialog::selectScr() +{ + QString str = QFileDialog::getOpenFileName(this, tr("UDAV - Insert filename"), + scr->lineEdit()->text(), tr("MGL files (*.mgl)")); + if(!str.isEmpty()) + { + scr->lineEdit()->setText(str); + scr->insertItem(1,str); + dataScr.insert(0,str); + dataScr.removeDuplicates(); + } +} + +//----------------------------------------------------------------------------- +void DataOpenDialog::prepareResult() +{ + code = ""; numDataOpened++; data = name->text(); + // prepare unique value of name for next time + char buf[32]; snprintf(buf,32,"mgl_%d",numDataOpened); name->setText(buf); + mglVar *v = parser.AddVar(data.toStdString().c_str()); + bool dd=0; + if(rA->isChecked()) // auto sizes + { + setlocale(LC_NUMERIC, "C"); v->Read(file.toStdString().c_str()); setlocale(LC_NUMERIC, ""); + if(v->nx==1) { v->nx = v->ny; v->ny = v->nz; } + code=QString("#read %1 '%2'\n").arg(data).arg(file); + } + else if(rM->isChecked()) // manual sizes + { + int x=nx->text().toInt(), y=ny->text().toInt(), z=nz->text().toInt(); + setlocale(LC_NUMERIC, "C"); v->Read(file.toStdString().c_str(),x,y,z); setlocale(LC_NUMERIC, ""); + code=QString("#read %1 '%2' %3 %4 %5\n").arg(data).arg(file).arg(x).arg(y).arg(z); + } + else if(r2->isChecked()) // matrix + { + setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toStdString().c_str()); setlocale(LC_NUMERIC, ""); + code=QString("#readmat %1 '%2'\n").arg(data).arg(file); dd=1; + } + else if(r3->isChecked()) // 3d-data + { + setlocale(LC_NUMERIC, "C"); v->ReadMat(file.toStdString().c_str(),3); setlocale(LC_NUMERIC, ""); + code=QString("#readmat %1 '%2' 3\n").arg(data).arg(file); dd=2; + } + if(scr->lineEdit()->text().isEmpty() || scr->lineEdit()->text()==tr("default")) + { + if(v->nz>1 || dd==2) + code+=QString("rotate 40 60\ncrange %1:box\nsurf3 %1\n").arg(data); + else if(v->ny>1 || dd==1) + code+=QString("rotate 40 60\ncrange %1:zrange %1:box\nsurf %1\n").arg(data); + else code+=QString("yrange %1:box\nplot %1\n").arg(data); + } + else + { + QString str; + QFile fp(scr->lineEdit()->text()); + if(fp.open(QFile::ReadOnly | QIODevice::Text)) + { + QTextStream in(&fp); + str = in.readAll(); + code += str.arg(data); + } + } + + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + settings.setValue("/dataScr", dataScr); + settings.endGroup(); + + accept(); +} +//----------------------------------------------------------------------------- +void DataOpenDialog::setFile(const QString &fname) +{ + file=fname; + mglData d(file.toStdString().c_str()); + rA->setText(tr("Auto detect data sizes (%1 x %2 x %3)").arg(d.nx).arg(d.ny).arg(d.nz)); +} +//----------------------------------------------------------------------------- diff --git a/udav/open_dlg.h b/udav/open_dlg.h new file mode 100644 index 0000000..9f74c9a --- /dev/null +++ b/udav/open_dlg.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef OPEN_DLG_H +#define OPEN_DLG_H +//----------------------------------------------------------------------------- +#include +class QLineEdit; +class QComboBox; +class QRadioButton; +//----------------------------------------------------------------------------- +/// Dialog for selecting command options +class DataOpenDialog : public QDialog +{ +Q_OBJECT +public: + DataOpenDialog(QWidget *parent=0); + ~DataOpenDialog(); + inline const QString getCode() { return code; } + inline const QString getName() { return data; } + void setFile(const QString &fname); +private slots: + void prepareResult(); + void selectScr(); +private: + QString code, data, file; + QLineEdit *nx, *ny, *nz, *name; + QRadioButton *rA, *rM, *r2, *r3; + QComboBox *scr; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/opt_dlg.cpp b/udav/opt_dlg.cpp new file mode 100644 index 0000000..32a2e7a --- /dev/null +++ b/udav/opt_dlg.cpp @@ -0,0 +1,130 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "opt_dlg.h" +//----------------------------------------------------------------------------- +OptionDialog::OptionDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Add options")); + QHBoxLayout *a; + QGridLayout *g; + QLabel *lbl; + QPushButton *b; + QVBoxLayout *o = new QVBoxLayout(this); //o->setSpacing(6); + g = new QGridLayout(); o->addLayout(g); + lbl = new QLabel(tr("X-range"),this); g->addWidget(lbl,0,0); + x1 = new QLineEdit(this); g->addWidget(x1,0,1); + x2 = new QLineEdit(this); g->addWidget(x2,0,2); + lbl = new QLabel(tr("Y-range"),this); g->addWidget(lbl,0,3); + y1 = new QLineEdit(this); g->addWidget(y1,0,4); + y2 = new QLineEdit(this); g->addWidget(y2,0,5); + lbl = new QLabel(tr("Z-range"),this); g->addWidget(lbl,1,0); + z1 = new QLineEdit(this); g->addWidget(z1,1,1); + z2 = new QLineEdit(this); g->addWidget(z2,1,2); + lbl = new QLabel(tr("C-range"),this); g->addWidget(lbl,1,3); + c1 = new QLineEdit(this); g->addWidget(c1,1,4); + c2 = new QLineEdit(this); g->addWidget(c2,1,5); + + lbl = new QLabel(tr("Alpha"),this); g->addWidget(lbl,2,0); + alpha = new QLineEdit(this); g->addWidget(alpha,2,1); + lbl = new QLabel(tr("Mesh num"),this); g->addWidget(lbl,2,3); + mn = new QLineEdit(this); g->addWidget(mn,2,4); + + lbl = new QLabel(tr("Ambient"),this); g->addWidget(lbl,3,0); + amb = new QLineEdit(this); g->addWidget(amb,3,1); + lbl = new QLabel(tr("Diffuse"),this); g->addWidget(lbl,3,3); + dif = new QLineEdit(this); g->addWidget(dif,3,4); + + lbl = new QLabel(tr("Cutting"),this); g->addWidget(lbl,4,0); + cut = new QComboBox(this); g->addWidget(cut,4,1); + cut->insertItem(0,tr("default")); cut->insertItem(1,tr("on")); cut->insertItem(2,tr("off")); + lbl = new QLabel(tr("Light"),this); g->addWidget(lbl,4,3); + lig = new QComboBox(this); g->addWidget(lig,4,4); + lig->insertItem(0,tr("default")); lig->insertItem(1,tr("on")); lig->insertItem(2,tr("off")); + + lbl = new QLabel(tr("Value"),this); g->addWidget(lbl,5,0); + val = new QLineEdit(this); g->addWidget(val,5,1); + lbl = new QLabel(tr("Size"),this); g->addWidget(lbl,5,3); + fs = new QLineEdit(this); g->addWidget(fs,5,4); + + a = new QHBoxLayout(); o->addLayout(a); + lbl = new QLabel(tr("Legend"),this); a->addWidget(lbl); + leg = new QLineEdit(this); a->addWidget(leg); + a = new QHBoxLayout(); o->addLayout(a); + a->addStretch(1); + b = new QPushButton(tr("Cancel"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); a->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(prepareResult())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +OptionDialog::~OptionDialog() {} +//----------------------------------------------------------------------------- +void OptionDialog::prepareResult() +{ + result = ""; + if(!x1->text().isEmpty() && !x2->text().isEmpty()) + result = result + "; xrange "+x1->text()+" "+x2->text(); + if((x1->text().isEmpty()) ^ (x2->text().isEmpty())) + { + QMessageBox::warning(this,tr("UDAV - command options"), tr("Both fields in xrange must be filled")); + return; + } + if(!y1->text().isEmpty() && !y2->text().isEmpty()) + result = result + "; yrange "+y1->text()+" "+y2->text(); + if((y1->text().isEmpty()) ^ (y2->text().isEmpty())) + { + QMessageBox::warning(this,tr("UDAV - command options"), tr("Both fields in yrange must be filled")); + return; + } + if(!z1->text().isEmpty() && !z2->text().isEmpty()) + result = result + "; zrange "+z1->text()+" "+z2->text(); + if((z1->text().isEmpty()) ^ (z2->text().isEmpty())) + { + QMessageBox::warning(this,tr("UDAV - command options"), tr("Both fields in zrange must be filled")); + return; + } + if(!c1->text().isEmpty() && !c2->text().isEmpty()) + result = result + "; crange "+c1->text()+" "+c2->text(); + if((c1->text().isEmpty()) ^ (c2->text().isEmpty())) + { + QMessageBox::warning(this,tr("UDAV - command options"), tr("Both fields in crange must be filled")); + return; + } + if(!val->text().isEmpty()) result = result+"; value "+val->text(); + if(!alpha->text().isEmpty())result = result+"; alpha "+alpha->text(); + if(!amb->text().isEmpty()) result = result+"; ambient "+amb->text(); + if(!dif->text().isEmpty()) result = result+"; diffuse "+dif->text(); + if(!mn->text().isEmpty()) result = result+"; meshnum "+mn->text(); + if(!fs->text().isEmpty()) result = result+"; size "+fs->text(); + if(cut->currentIndex()==1) result = result+"; cut on"; + if(cut->currentIndex()==2) result = result+"; cut off"; + if(lig->currentIndex()==1) result = result+"; light on"; + if(lig->currentIndex()==2) result = result+"; light off"; + if(!leg->text().isEmpty()) result = result+"; legend '"+leg->text()+"'"; + accept(); +} +//----------------------------------------------------------------------------- diff --git a/udav/opt_dlg.h b/udav/opt_dlg.h new file mode 100644 index 0000000..2e25952 --- /dev/null +++ b/udav/opt_dlg.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef OPTION_DLG_H +#define OPTION_DLG_H +//----------------------------------------------------------------------------- +#include +class QLineEdit; +class QComboBox; +class QRadioButton; +//----------------------------------------------------------------------------- +/// Dialog for selecting command options +class OptionDialog : public QDialog +{ +Q_OBJECT +public: + OptionDialog(QWidget *parent=0); + ~OptionDialog(); + + QString getOption() { return result; } +private slots: + void prepareResult(); +private: + QString result; + QLineEdit *x1, *x2, *y1, *y2, *z1, *z2, *c1, *c2; + QLineEdit *alpha, *amb, *dif, *val, *mn, *fs, *leg; + QComboBox *cut, *lig; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/plot_pnl.cpp b/udav/plot_pnl.cpp new file mode 100644 index 0000000..18e661d --- /dev/null +++ b/udav/plot_pnl.cpp @@ -0,0 +1,529 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "mgl2/qmathgl.h" +#include "plot_pnl.h" +#include "anim_dlg.h" +#include "style_dlg.h" +extern bool mglAutoSave; +extern bool mglHighlight; +extern mglParse parser; +int animDelay=500; +void raisePanel(QWidget *w); +//----------------------------------------------------------------------------- +PlotPanel::PlotPanel(QWidget *parent) : QWidget(parent) +{ + gifOn = jpgOn = false; + animDialog = new AnimParam(this); animPos = -1; + stlDialog = new StyleDialog(this); + printer = new QPrinter; curPos = -1; + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(next())); + connect(animDialog, SIGNAL(putText(const QString &)), this, SLOT(animText(const QString &))); + + menu = new QMenu(tr("Graphics"),this); + popup = new QMenu(this); + mgl = new QMathGL(this); + draw = new mglDrawScript(parser.Self()); + mgl_set_flag(mgl->getGraph(),1,MGL_SHOW_POS); mgl->setDraw(draw); + connect(mgl,SIGNAL(askStyle(int)),this,SLOT(setStyle(int))); + + QBoxLayout *v,*h,*m; + v = new QVBoxLayout(this); + h = new QHBoxLayout(); v->addLayout(h); toolTop(h); + h = new QHBoxLayout(); v->addLayout(h); + m = new QVBoxLayout(); h->addLayout(m); toolLeft(m); + mgl->setPopup(popup); + + sv = new QScrollArea(this); h->addWidget(sv); sv->setWidget(mgl); + emit giveFocus(); +} +//----------------------------------------------------------------------------- +PlotPanel::~PlotPanel() { delete printer; } +//----------------------------------------------------------------------------- +void PlotPanel::setStyle(int id) +{ if(stlDialog->exec()) mgl->setStyle(id, stlDialog->getStyle()); } +//----------------------------------------------------------------------------- +void PlotPanel::animText(const QString &txt) { animPutText(txt); } +//----------------------------------------------------------------------------- +void PlotPanel::setCurPos(int pos) +{ + if(!mglHighlight) pos = -1; + if(curPos!=pos) { curPos = pos; execute(); } +} +//----------------------------------------------------------------------------- +void PlotPanel::stop() { parser.Stop(); mgl->stop(); } +//----------------------------------------------------------------------------- +void PlotPanel::execute() +{ + if(mglAutoSave) save(); + raisePanel(this); + emit clearWarn(); + QTime t; t.start(); + mgl_set_facenum(mgl->getGraph(),0); + draw->text=textMGL->toPlainText(); + draw->line=curPos; + mgl->update(); + setStatus(QString(tr("Drawing time %1 ms")).arg(t.elapsed()*1e-3)); + emit giveFocus(); +} +//----------------------------------------------------------------------------- +void PlotPanel::pressF9() +{ + int l=animParam.length(), i; + wchar_t *str = new wchar_t[l+2]; + animPos = 0; curPos = -1; + QString cur = animParam.section('\n',animPos,animPos); + for(i=0;itext=textMGL->toPlainText(); + draw->line=curPos; mgl->update(); + setStatus(QString(tr("Drawing time %1 ms")).arg(t.elapsed()*1e-3)); + emit giveFocus(); +} +//----------------------------------------------------------------------------- +void PlotPanel::animStart(bool st) +{ + if(!st) + { timer->stop(); if(gifOn) mgl_close_gif(mgl->getGraph()); return; } + if(animParam.isEmpty()) + { + if(animDialog->exec()) + { + animParam = animDialog->getResult(); + gifOn = animDialog->gifOn; + jpgOn = animDialog->jpgOn; + } + else return; + } + timer->start(animDelay); + if(gifOn) + { + mglGraph gr(mgl->getGraph()); + gr.StartGIF("", animDelay); + gr.ResetFrames(); + } + raisePanel(this); +} +//----------------------------------------------------------------------------- +void PlotPanel::nextSlide() +{ + animSwitch(false); + next(); + emit giveFocus(); +} +//----------------------------------------------------------------------------- +void PlotPanel::next() +{ + if(animParam.isEmpty()) + { + if(animDialog->exec()) + { + animParam = animDialog->getResult(); + gifOn = animDialog->gifOn; + jpgOn = animDialog->jpgOn; + } + else return; + } + int l=animParam.length(), n=animParam.count('\n') + (animParam[l-1]=='\n' ? 0:1), i; + wchar_t *str = new wchar_t[l+2]; + animPos = (animPos+1)%n; + QString cur = animParam.section('\n',animPos,animPos); + for(i=0;igetGraph()); + if(gr.GetNumFrame() >= n) execute(); + else + { + gr.NewFrame(); execute(); gr.EndFrame(); + if(jpgOn) gr.WriteFrame(); + QString s; s.sprintf("%d - %d of %d",gr.GetNumFrame(),animPos,n); + setStatus(QString(tr("Frame %1 of %2")).arg(animPos).arg(n)); + } +} +//----------------------------------------------------------------------------- +void PlotPanel::prevSlide() +{ + if(animParam.isEmpty()) + { + if(animDialog->exec()) + { + animParam = animDialog->getResult(); + gifOn = animDialog->gifOn; + jpgOn = animDialog->jpgOn; + } + else return; + } + animSwitch(false); + int l=animParam.length(), n=animParam.count('\n') + (animParam[l-1]=='\n' ? 0:1), i; + wchar_t *str = new wchar_t[l+2]; + animPos = (animPos-1+n)%n; + QString cur = animParam.section('\n',animPos,animPos); + for(i=0;iexec()) + { + animParam = animDialog->getResult(); + gifOn = animDialog->gifOn; + jpgOn = animDialog->jpgOn; + animPos = -1; + } +} +//----------------------------------------------------------------------------- +void PlotPanel::adjust() +{ + mgl->setSize(sv->width()-5, sv->height()-5); + raisePanel(this); emit giveFocus(); +} +//----------------------------------------------------------------------------- +void PlotPanel::setMGLFont(const QString &path) { mgl->setMGLFont(path); } +//----------------------------------------------------------------------------- +void PlotPanel::animParseText(const QString &txt) +{ + int i, n = txt.count('\n')+1; + double a1=0,a2=0,da=0; + QString s, all; + for(i=0;isetResult(a1,a2,da); + } + } + if(!all.isEmpty()) + { + animDialog->setResult(all); + animParam = all; + } + else if(a1!=a2 && da!=0) + { + for(double a=a1;a<=a2;a+=da) all = all + QString::number(a)+"\n"; + animParam = all; + } +} +//----------------------------------------------------------------------------- +#include "xpm/wire.xpm" +#include "xpm/text.xpm" +#include "xpm/line.xpm" +#include "xpm/curve.xpm" +#include "xpm/mark_o.xpm" +#include "xpm/mark_s.xpm" +#include "xpm/mark_a.xpm" +#include "xpm/mark_d.xpm" +//----------------------------------------------------------------------------- +void PlotPanel::toolTop(QBoxLayout *l) +{ + QAction *a; + QMenu *o=menu, *oo; + QToolButton *bb; + + // graphics menu + a = new QAction(QPixmap(":/xpm/alpha.png"), tr("Alpha"), this); + a->setShortcut(Qt::CTRL+Qt::Key_T); a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), mgl, SLOT(setAlpha(bool))); + connect(mgl, SIGNAL(alphaChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(tr("Switch on/off transparency for the graphics (Ctrl+T).")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/weather-clear.png"), tr("Light"), this); + a->setShortcut(Qt::CTRL+Qt::Key_L); a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), mgl, SLOT(setLight(bool))); + connect(mgl, SIGNAL(lightChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(tr("Switch on/off lightning for the graphics (Ctrl+L).")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(wire_xpm), tr("Grid"), this); + a->setShortcut(Qt::CTRL+Qt::Key_G); a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), mgl, SLOT(setGrid(bool))); + a->setToolTip(tr("Switch on/off grid of absolute coordinates (Ctrl+G).")); + o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/object-rotate-right.png"), tr("Rotate by mouse"), this); + a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), mgl, SLOT(setRotate(bool))); + connect(mgl, SIGNAL(rotateChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(tr("Switch on/off mouse handling of the graphics\n(rotation, shifting, zooming and perspective).")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + +/* a = new QAction(QPixmap(":/xpm/zoom-fit-best.png"), tr("Zoom by mouse"), this); + a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), mgl, SLOT(setZoom(bool))); + connect(mgl, SIGNAL(zoomChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(tr("Switch on/off mouse zoom of selected region.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a);*/ + + o->addSeparator(); + a = new QAction(QPixmap(":/xpm/zoom-original.png"), tr("Restore"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(restore())); + a->setToolTip(tr("Restore default graphics rotation, zoom and perspective (Ctrl+Space).")); + a->setShortcut(Qt::CTRL+Qt::Key_Space); + o->addAction(a); popup->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/view-refresh.png"), tr("Redraw"), this); + connect(a, SIGNAL(triggered()), this, SLOT(execute())); + a->setToolTip(tr("Execute script and redraw graphics (F5).")); + a->setShortcut(Qt::Key_F5); + o->addAction(a); popup->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(tr("Adjust size"), this); + connect(a, SIGNAL(triggered()), this, SLOT(adjust())); + a->setToolTip(tr("Change canvas size to fill whole region (F6).")); + a->setShortcut(Qt::Key_F6); o->addAction(a); + + a = new QAction(tr("Reload"), this); + connect(a, SIGNAL(triggered()), this, SLOT(pressF9())); + a->setToolTip(tr("Restore status for 'once' command and reload data (F9).")); + a->setShortcut(Qt::Key_F9); o->addAction(a); popup->addAction(a); + + a = new QAction(QPixmap(":/xpm/process-stop.png"), tr("Stop"), this); + connect(a, SIGNAL(triggered()), this, SLOT(stop())); + a->setToolTip(tr("Stop script execution (F7).")); + a->setShortcut(Qt::Key_F7); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-copy.png"), tr("Copy plot"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(copy())); + a->setToolTip(tr("Copy graphics to clipboard (Ctrl+Shift+G).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_G); + o->addAction(a); popup->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-copy.png"), tr("Copy click coor."), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(copyClickCoor())); + a->setToolTip(tr("Copy coordinates of last mouse click to clipboard.")); + o->addAction(a); popup->addAction(a); + + l->addStretch(1); + oo = new QMenu(tr("Primitives ..."),this); + a = new QAction(QPixmap(line_xpm), tr("Add line"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addLine())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add line which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(curve_xpm), tr("Add curve"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addCurve())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add curve which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(mark_s_xpm), tr("Add rect"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addRect())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add rectangle which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(mark_d_xpm), tr("Add rhombus"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addRhomb())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add rhombus which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(mark_o_xpm), tr("Add ellipse"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addEllipse())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add ellipse which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(mark_a_xpm), tr("Add mark"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addMark())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add marker which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + a = new QAction(QPixmap(text_xpm), tr("Add text"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(addText())); + connect(mgl, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(tr("Add text which properties can be changed later by mouse.")); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); oo->addAction(a); + + o->addMenu(oo); l->addStretch(1); + + tet = new QSpinBox(this); tet->setWrapping(true); + l->addWidget(tet); tet->setRange(-180, 180); tet->setSingleStep(10); + connect(tet, SIGNAL(valueChanged(int)), mgl, SLOT(setTet(int))); + connect(mgl, SIGNAL(tetChanged(int)), tet, SLOT(setValue(int))); + tet->setToolTip(tr("Set value of \\theta angle.\nYou can use keys (Shift+Meta+Up or Shift+Meta+Down).")); + + phi = new QSpinBox(this); phi->setWrapping(true); + l->addWidget(phi); phi->setRange(-180, 180); phi->setSingleStep(10); + connect(phi, SIGNAL(valueChanged(int)), mgl, SLOT(setPhi(int))); + connect(mgl, SIGNAL(phiChanged(int)), phi, SLOT(setValue(int))); + phi->setToolTip(tr("Set value of \\phi angle.\nYou can use keys (Shift+Meta+Left or Shift+Meta+Right).")); + + oo = new QMenu(tr("Export as 2D ..."),this); + oo->addAction(tr("PNG"), mgl, SLOT(exportPNG()),Qt::ALT+Qt::Key_P); + oo->addAction(tr("solid PNG"), mgl, SLOT(exportPNGs()),Qt::ALT+Qt::Key_F); + oo->addAction(tr("JPEG"), mgl, SLOT(exportJPG()),Qt::ALT+Qt::Key_J); + oo->addAction(tr("bitmap EPS"), mgl, SLOT(exportBPS())); + oo->addAction(tr("vector EPS"), mgl, SLOT(exportEPS()),Qt::ALT+Qt::Key_E); + oo->addAction(tr("SVG"), mgl, SLOT(exportSVG()),Qt::ALT+Qt::Key_S); + oo->addAction(tr("LaTeX"), mgl, SLOT(exportTEX()),Qt::ALT+Qt::Key_L); + + o->addMenu(oo); popup->addMenu(oo); + oo = new QMenu(tr("Export as 3D ..."),this); + oo->addAction(tr("MGLD"), mgl, SLOT(exportMGLD()),Qt::ALT+Qt::Key_M); + oo->addAction(tr("PRC"), mgl, SLOT(exportPRC()),Qt::ALT+Qt::Key_D); + oo->addAction(tr("OBJ"), mgl, SLOT(exportOBJ()),Qt::ALT+Qt::Key_O); + oo->addAction(tr("STL"), mgl, SLOT(exportSTL())); + oo->addAction(tr("XYZ"), mgl, SLOT(exportXYZ())); +// oo->addAction(tr("X3D"), QMGL, SLOT(exportX3D()),Qt::ALT+Qt::Key_X); // TODO: Add later + o->addMenu(oo); popup->addMenu(oo); +} +//----------------------------------------------------------------------------- +void PlotPanel::toolLeft(QBoxLayout *l) +{ + QAction *a; + QMenu *o=menu, *oo; + QToolButton *bb; + + // zooming menu + oo = o->addMenu(tr("Zoom/move")); + a = new QAction(QPixmap(":/xpm/go-previous.png"), tr("Move left"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(shiftLeft())); + a->setShortcut(Qt::ALT+Qt::Key_Left); + a->setToolTip(tr("Move graphics left by 1/3 of its width.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/go-up.png"), tr("Move up"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(shiftUp())); + a->setShortcut(Qt::ALT+Qt::Key_Up); + a->setToolTip(tr("Move graphics up by 1/3 of its height.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/zoom-in.png"), tr("Zoom in"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(zoomIn())); + a->setShortcut(Qt::ALT+Qt::Key_Equal); + a->setToolTip(tr("Zoom in graphics.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/zoom-out.png"), tr("Zoom out"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(zoomOut())); + a->setShortcut(Qt::ALT+Qt::Key_Minus); + a->setToolTip(tr("Zoom out graphics.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/go-down.png"), tr("Move down"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(shiftDown())); + a->setShortcut(Qt::ALT+Qt::Key_Down); + a->setToolTip(tr("Move graphics up down 1/3 of its height.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/go-next.png"), tr("Move right"), this); + connect(a, SIGNAL(triggered()), mgl, SLOT(shiftRight())); + a->setShortcut(Qt::ALT+Qt::Key_Right); + a->setToolTip(tr("Move graphics right by 1/3 of its width.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + // rotate menu + oo = o->addMenu(tr("Rotate")); + a = new QAction(tr("Rotate up"), this); + a->setShortcut(Qt::SHIFT+Qt::META+Qt::Key_Up); + connect(a, SIGNAL(triggered()), tet, SLOT(stepUp())); oo->addAction(a); + a->setToolTip(tr("Increase \\theta angle by 10 degrees.")); + a = new QAction(tr("Rotate down"), this); + a->setShortcut(Qt::SHIFT+Qt::META+Qt::Key_Down); + connect(a, SIGNAL(triggered()), tet, SLOT(stepDown())); oo->addAction(a); + a->setToolTip(tr("Decrease \\theta angle by 10 degrees.")); + a = new QAction(tr("Rotate left"), this); + a->setShortcut(Qt::SHIFT+Qt::META+Qt::Key_Right); + connect(a, SIGNAL(triggered()), phi, SLOT(stepUp())); oo->addAction(a); + a->setToolTip(tr("Increase \\phi angle by 10 degrees.")); + a = new QAction(tr("Rotate right"), this); + a->setShortcut(Qt::SHIFT+Qt::META+Qt::Key_Left); + connect(a, SIGNAL(triggered()), phi, SLOT(stepDown())); oo->addAction(a); + a->setToolTip(tr("Decrease \\phi angle by 10 degrees.")); + + // animation menu + oo = o->addMenu(tr("Animation")); + a = new QAction(QPixmap(":/xpm/media-seek-forward.png"), tr("Next slide"), this); + connect(a, SIGNAL(triggered()), this, SLOT(nextSlide())); + a->setShortcut(Qt::CTRL+Qt::Key_Period); + a->setToolTip(tr("Show next slide (Ctrl+.).")); oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/media-seek-backward.png"), tr("Prev slide"), this); + connect(a, SIGNAL(triggered()), this, SLOT(prevSlide())); + a->setShortcut(Qt::CTRL+Qt::Key_Comma); + a->setToolTip(tr("Show previous slide (Ctrl+,).")); oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/film-b.png"), tr("Slideshow"), this); + a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), this, SLOT(animStart(bool))); + connect(this, SIGNAL(animSwitch(bool)),a,SLOT(setChecked(bool))); + a->setToolTip(tr("Run slideshow (Ctrl+F5). If no parameter specified\nthen the dialog with slideshow options will appear.")); + a->setShortcut(Qt::CTRL+Qt::Key_F5); oo->addAction(a); + oo->addAction(tr("Setup show"), this, SLOT(animSetup()), Qt::CTRL+Qt::Key_W); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + l->addStretch(1); +} +//----------------------------------------------------------------------------- +QString PlotPanel::getFit() { return QString(mgl_get_fit(mgl->getGraph())); } +//----------------------------------------------------------------------------- diff --git a/udav/plot_pnl.h b/udav/plot_pnl.h new file mode 100644 index 0000000..41e7997 --- /dev/null +++ b/udav/plot_pnl.h @@ -0,0 +1,97 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PLOT_PNL_H +#define PLOT_PNL_H +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +class QMenu; +class QTimer; +class QSpinBox; +class QPopupMenu; +class QScrollArea; +class QBoxLayout; +class QTextEdit; +class QMathGL; +class mglDrawScript; +class InfoDialog; +class AnimParam; +class DatPanel; +class mglVar; +class StyleDialog; +class QPrinter; +//----------------------------------------------------------------------------- +class PlotPanel : public QWidget +{ +Q_OBJECT +public: + QMenu *menu; + QMathGL *mgl; + mglDrawScript *draw; ///< Class for drawing MGL script + const QTextEdit *textMGL; ///< Editor with MGL script body + PlotPanel(QWidget *wp=0); + ~PlotPanel(); + void setMGLFont(const QString &path); + QString getFit(); + +public slots: + void animParseText(const QString &txt); + void setCurPos(int pos=-1); + void execute(); + +signals: + void save(); + void animPutText(const QString &); + void setStatus(const QString &); + void animSwitch(bool); + void giveFocus(); + void clearWarn(); + +private slots: + void animText(const QString &); + void next(); + void nextSlide(); + void prevSlide(); + void animStart(bool st); + void animSetup(); + void adjust(); + void pressF9(); + void stop(); + void setStyle(int id); + +private: + bool gifOn, jpgOn; + QScrollArea* sv; + QSpinBox *tet, *phi; + // animation + QString animParam; + int animPos; + int curPos; + QTimer *timer; + AnimParam *animDialog; + QMenu *popup; + QPrinter *printer; + StyleDialog *stlDialog; + + void toolTop(QBoxLayout *l); + void toolLeft(QBoxLayout *l); +}; +//----------------------------------------------------------------------------- +#endif // PLOT_PNL_H diff --git a/udav/prop_dlg.cpp b/udav/prop_dlg.cpp new file mode 100644 index 0000000..8efcf3b --- /dev/null +++ b/udav/prop_dlg.cpp @@ -0,0 +1,276 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "prop_dlg.h" +#include "udav_wnd.h" +#include "plot_pnl.h" +#include "text_pnl.h" +//----------------------------------------------------------------------------- +extern QColor mglColorScheme[10]; +extern QString defFontFamily; +extern int defFontSize; +extern QString pathHelp; +extern bool mglAutoExecute; +extern bool mglAutoSave; +extern bool mglAutoPure; +extern bool mglCompleter; +extern bool editPosBottom; +extern bool loadInNewWnd; +extern bool mglHighlight; +int defWidth, defHeight; +QString pathFont; +QString lang[]={"","ru"}; +//----------------------------------------------------------------------------- +PropDialog::PropDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Properties")); + QHBoxLayout *h; + QVBoxLayout *v; + QLabel *l; + QPushButton *b; + + v = new QVBoxLayout(this); + h = new QHBoxLayout(); v->addLayout(h); + lbl = new QLabel(tr("Current font"), this); h->addWidget(lbl); + lbl->setFont(QFont(defFontFamily, defFontSize)); + h->addStretch(1); defFont = QFont(defFontFamily, defFontSize); + b = new QPushButton(tr("Change font"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(setF())); + + cc[0]=mglColorScheme[0]; cc[1]=mglColorScheme[1]; + cc[2]=mglColorScheme[2]; cc[3]=mglColorScheme[3]; + cc[4]=mglColorScheme[4]; cc[5]=mglColorScheme[5]; + cc[6]=mglColorScheme[6]; cc[7]=mglColorScheme[7]; + cc[8]=mglColorScheme[8]; cc[9]=mglColorScheme[9]; + QPixmap pic(16,16); + l = new QLabel(tr("Setup colors for:"), this); v->addWidget(l, Qt::AlignHCenter); + QGridLayout *g = new QGridLayout(); v->addLayout(g); + pic.fill(cc[0]); cb[0] = new QPushButton(pic, tr("Comments"), this); + connect(cb[0], SIGNAL(clicked()),this, SLOT(setC0())); + g->addWidget(cb[0], 0, 0); + pic.fill(cc[1]); cb[1] = new QPushButton(pic, tr("Strings"), this); + connect(cb[1], SIGNAL(clicked()),this, SLOT(setC1())); + g->addWidget(cb[1], 0, 1); + pic.fill(cc[2]); cb[2] = new QPushButton(pic, tr("Keywords"), this); + connect(cb[2], SIGNAL(clicked()),this, SLOT(setC2())); + g->addWidget(cb[2], 0, 2); + pic.fill(cc[3]); cb[3] = new QPushButton(pic, tr("Options"), this); + connect(cb[3], SIGNAL(clicked()),this, SLOT(setC3())); + g->addWidget(cb[3], 1, 0); + pic.fill(cc[4]); cb[4] = new QPushButton(pic, tr("Suffixes"), this); + connect(cb[4], SIGNAL(clicked()),this, SLOT(setC4())); + g->addWidget(cb[4], 1, 1); + pic.fill(cc[5]); cb[5] = new QPushButton(pic, tr("Numbers"), this); + connect(cb[5], SIGNAL(clicked()),this, SLOT(setC5())); + g->addWidget(cb[5], 1, 2); + pic.fill(cc[6]); cb[6] = new QPushButton(pic, tr("AutoKey"), this); + connect(cb[6], SIGNAL(clicked()),this, SLOT(setC6())); + g->addWidget(cb[6], 2, 0); + pic.fill(cc[7]); cb[7] = new QPushButton(pic, tr("FlowKey"), this); + connect(cb[7], SIGNAL(clicked()),this, SLOT(setC7())); + g->addWidget(cb[7], 2, 1); + pic.fill(cc[9]); cb[9] = new QPushButton(pic, tr("CurrLine"), this); + connect(cb[9], SIGNAL(clicked()),this, SLOT(setC9())); + g->addWidget(cb[9], 2, 2); + + l = new QLabel(tr("Path for help files"), this); v->addWidget(l); + h = new QHBoxLayout(); v->addLayout(h); + hlp = new QLineEdit(pathHelp, this); h->addWidget(hlp,1); + b = new QPushButton("...", this); h->addWidget(b,0); + connect(b,SIGNAL(clicked()),this,SLOT(getPathH())); + + QStringList paths, files, filter; + paths << "." << QDir::homePath() << QDir::rootPath() + << QCoreApplication::applicationDirPath()+"/fonts"; + filter << "*.vfm"; +#ifndef WIN32 + paths << "/usr/local/share/mathgl/fonts/" << "/usr/local/mathgl/fonts/"; +#endif + QFileInfoList info; + for(int i=0;iaddWidget(l); + h = new QHBoxLayout(); v->addLayout(h); + fnt = new QComboBox(this); h->addWidget(fnt,1); + fnt->addItems(files); fnt->setEditable(true); + fnt->lineEdit()->setText(pathFont); + b = new QPushButton("...", this); h->addWidget(b,0); + connect(b,SIGNAL(clicked()),this,SLOT(getPathF())); + + h = new QHBoxLayout(); v->addLayout(h); + l = new QLabel(tr("Language for UDAV"), this); h->addWidget(l,0); + lng = new QComboBox(this); h->addWidget(lng,1); + lng->addItem(tr("English")); lng->addItem(tr("Russian")); + + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + QString prev = settings.value("/udavLang", "").toString(); + if(prev==lang[1]) lng->setCurrentIndex(1); + defWidth = settings.value("/defWidth", 640).toInt(); + defHeight = settings.value("/defHeight", 480).toInt(); + settings.endGroup(); + + h = new QHBoxLayout(); v->addLayout(h); + l = new QLabel(tr("Image size"), this); h->addWidget(l,0); + defW = new QLineEdit(QString::number(defWidth),this); h->addWidget(defW,1); + l = new QLabel("x", this); h->addWidget(l,0); + defH = new QLineEdit(QString::number(defHeight),this); h->addWidget(defH,1); + + run = new QCheckBox(tr("Automatically execute script after loading"), this); + run->setChecked(mglAutoExecute); v->addWidget(run); + edt = new QCheckBox(tr("Place editor at top"), this); + edt->setChecked(editPosBottom); v->addWidget(edt); + load = new QCheckBox(tr("Load script to new window"), this); + load->setChecked(loadInNewWnd); v->addWidget(load); + save = new QCheckBox(tr("Automatically save before redrawing (F5)"), this); + save->setChecked(mglAutoSave); v->addWidget(save); + pure = new QCheckBox(tr("Disable face drawing (faster) for mouse rotation/shift/zoom."), this); + pure->setChecked(mglAutoPure); v->addWidget(pure); pure->setEnabled(false); + cmpl = new QCheckBox(tr("Enable keywords completition"), this); + cmpl->setChecked(mglCompleter); v->addWidget(cmpl); + high = new QCheckBox(tr("Highlight current object(s)"), this); + high->setChecked(mglHighlight); v->addWidget(high); + + h = new QHBoxLayout(); v->addLayout(h); + h->addStretch(1); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(applyChanges())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +PropDialog::~PropDialog() {} +//----------------------------------------------------------------------------- +void PropDialog::getPathH() +{ + QString str = QFileDialog::getExistingDirectory(this, + tr("UDAV - Insert filename"), hlp->text()); + if(!str.isEmpty()) hlp->setText(str+'/'); +} +//----------------------------------------------------------------------------- +void PropDialog::getPathF() +{ + QString str = QFileDialog::getOpenFileName(this, tr("UDAV - Insert filename"), + fnt->lineEdit()->text(), tr("Font files (*.vfm)")); +// if(str.contains(".vfm")) str = str.left(str.length()-4); + if(!str.isEmpty()) fnt->lineEdit()->setText(str); +} +//----------------------------------------------------------------------------- +void PropDialog::setC(int k) +{ + if(k<0 || k>9) return; + QColor c = QColorDialog::getColor(cc[k], this); + if(c.isValid()) + { + QPixmap p(16,16); p.fill(c); + cb[k]->setIcon(p); cc[k] = c; + } +} +//----------------------------------------------------------------------------- +void PropDialog::setF() +{ + bool ok; + QFont f = QFontDialog::getFont(&ok, defFont, this); + if(ok) { defFont = f; lbl->setFont(f); } +} +//----------------------------------------------------------------------------- +void PropDialog::applyChanges() +{ + // defFont editPosBottom pathFont + mglColorScheme[0]=cc[0]; mglColorScheme[1]=cc[1]; + mglColorScheme[2]=cc[2]; mglColorScheme[3]=cc[3]; + mglColorScheme[4]=cc[4]; mglColorScheme[5]=cc[5]; + mglColorScheme[6]=cc[6]; mglColorScheme[7]=cc[7]; + mglColorScheme[8]=cc[8]; mglColorScheme[9]=cc[9]; + mglAutoExecute = run->isChecked(); + editPosBottom = edt->isChecked(); + pathHelp = hlp->text(); pathFont = fnt->lineEdit()->text(); + if(pathHelp.isEmpty()) pathHelp=MGL_DOC_DIR; + defFontFamily = defFont.family(); + defFontSize = defFont.pointSize(); + loadInNewWnd = load->isChecked(); + mglAutoSave = save->isChecked(); + mglHighlight = high->isChecked(); + mglAutoPure = pure->isChecked(); + mglCompleter = cmpl->isChecked(); + + // apply changes for all windows +#ifdef WIN32 + pathFont = pathFont.replace('/','\\'); +#endif + bool ok=true; + foreach(QWidget *w, QApplication::topLevelWidgets()) + { + if(w->inherits("MainWindow")) + { + MainWindow *s = (MainWindow *)w; + if(ok) { s->writeSettings(); ok = false; } + s->edit->setEditorFont(); + s->graph->setMGLFont(pathFont); + s->setEditPos(editPosBottom); + s->edit->setCompleter(mglCompleter); + s->update(); + } + } + + if(defWidth!=defW->text().toInt() || defHeight!=defH->text().toInt()) + { + defWidth = defW->text().toInt(); + defHeight = defH->text().toInt(); + sizeChanged(defWidth, defHeight); + } + + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + QString prev = settings.value("/udavLang", "").toString(); + int cur=lng->currentIndex(); + if(cur>=0 && prev!=lang[cur]) + { + settings.setValue("/udavLang", lang[lng->currentIndex()]); + QMessageBox::critical(this,tr("UDAV - Properties"),tr("You have to restart UDAV for applying the cahnges.")); + } + settings.setValue("/defWidth", defWidth); + settings.setValue("/defHeight", defHeight); + settings.endGroup(); + + accept(); emit propUpdated(); +} +//----------------------------------------------------------------------------- diff --git a/udav/prop_dlg.h b/udav/prop_dlg.h new file mode 100644 index 0000000..8f0e126 --- /dev/null +++ b/udav/prop_dlg.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef PROPDIALOG_H +#define PROPDIALOG_H +//----------------------------------------------------------------------------- +#include +class QLabel; +class QPushButton; +class QCheckBox; +class QLineEdit; +class QComboBox; +//----------------------------------------------------------------------------- +/// Set UDAV general properties +class PropDialog : public QDialog +{ +Q_OBJECT +public: + PropDialog(QWidget *parent = 0); + ~PropDialog(); +signals: + void sizeChanged(int w, int h); + void propUpdated(); +private slots: + void applyChanges(); + void setC0() { setC(0); } + void setC1() { setC(1); } + void setC2() { setC(2); } + void setC3() { setC(3); } + void setC4() { setC(4); } + void setC5() { setC(5); } + void setC6() { setC(6); } + void setC7() { setC(7); } + void setC8() { setC(8); } + void setC9() { setC(9); } + void setF(); + void getPathH(); + void getPathF(); +private: + void setC(int k); + QLabel *lbl; + QPushButton *cb[10]; + QCheckBox *run, *edt, *load, *save, *pure, *cmpl, *high; + QLineEdit *hlp, *defW, *defH; + QFont defFont; + QColor cc[10]; + QComboBox *lng, *fnt; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/qmglsyntax.cpp b/udav/qmglsyntax.cpp new file mode 100644 index 0000000..20efa2b --- /dev/null +++ b/udav/qmglsyntax.cpp @@ -0,0 +1,120 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include "qmglsyntax.h" +#include +mglParse parser; +int mgl_cmd_cmp(const void *a, const void *b); +// comment string keyword option suffix number +QColor mglColorScheme[10] = {QColor(0,127,0), QColor(255,0,0), QColor(0,0,127), QColor(127,0,0), QColor(127,0,0), QColor(0,0,255), QColor(127,0,127), QColor(0,127,127), QColor(0,0,127), QColor(255,255,204)}; +//----------------------------------------------------------------------------- +QMGLSyntax::QMGLSyntax(QTextEdit *textEdit) : QSyntaxHighlighter(textEdit) {} +//----------------------------------------------------------------------------- +void QMGLSyntax::highlightBlock(const QString &text) +{ + register int i, j, m = text.length(),s=0; + bool arg = false, nl = true; + QString num("+-.0123456789:"); + i=0; + setCurrentBlockState(-1); + if(previousBlockState()==1) + { + bool cont=false; + j=i; i++; + for(;i' ') cont=false; + if(text[i]=='\\') cont=true; + } + setFormat(j,i-j+1,mglColorScheme[1]); + if(cont && i==m) setCurrentBlockState(1); + } + for(;i' ') cont=false; + if(text[i]=='\\') cont=true; + } + setFormat(j,i-j+1,mglColorScheme[1]); + if(cont && i==m) setCurrentBlockState(1); + } + else if(nl) // keyword + { + char *s = new char[m+1]; + for(j=i;j +#include +#include +#include +//----------------------------------------------------------------------------- +///Syntax highlighter for MGL script language. +class QMGLSyntax : public QSyntaxHighlighter +{ +public: + QMGLSyntax(QTextEdit *textEdit); + void highlightBlock(const QString &text); +}; +//----------------------------------------------------------------------------- +///Syntax highlighter for messages window. +class MessSyntax : public QSyntaxHighlighter +{ +public: + MessSyntax(QTextEdit *textEdit); + void highlightBlock(const QString &text); +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/setup_dlg.cpp b/udav/setup_dlg.cpp new file mode 100644 index 0000000..a730c62 --- /dev/null +++ b/udav/setup_dlg.cpp @@ -0,0 +1,298 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "setup_dlg.h" +void fillColors(QComboBox *cb); +//----------------------------------------------------------------------------- +SetupDialog::SetupDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Setup plot")); + QWidget *p; + QGridLayout *g; + QLabel *l; + QPushButton *b; + QTabWidget *tab = new QTabWidget(this); + // line style + p = new QWidget(this); + g = new QGridLayout(p); g->setAlignment(Qt::AlignTop); + l = new QLabel(tr("X axis"), p); g->addWidget(l,0,1); + l = new QLabel(tr("Y axis"), p); g->addWidget(l,0,2); + l = new QLabel(tr("Z axis"), p); g->addWidget(l,0,3); + l = new QLabel(tr("C axis"), p); g->addWidget(l,0,4); + l = new QLabel(tr("Minimal"), p); g->addWidget(l,1,0); + xmin = new QLineEdit(p); g->addWidget(xmin,1,1); + ymin = new QLineEdit(p); g->addWidget(ymin,1,2); + zmin = new QLineEdit(p); g->addWidget(zmin,1,3); + cmin = new QLineEdit(p); g->addWidget(cmin,1,4); + l = new QLabel(tr("Maximal"), p); g->addWidget(l,2,0); + xmax = new QLineEdit(p); g->addWidget(xmax,2,1); + ymax = new QLineEdit(p); g->addWidget(ymax,2,2); + zmax = new QLineEdit(p); g->addWidget(zmax,2,3); + cmax = new QLineEdit(p); g->addWidget(cmax,2,4); + l = new QLabel(tr("Origin"), p); g->addWidget(l,3,0); + xorg = new QLineEdit(p); g->addWidget(xorg,3,1); + yorg = new QLineEdit(p); g->addWidget(yorg,3,2); + zorg = new QLineEdit(p); g->addWidget(zorg,3,3); + l = new QLabel(tr("Label"), p); g->addWidget(l,4,0); + xlbl = new QLineEdit(p); g->addWidget(xlbl,4,1); + ylbl = new QLineEdit(p); g->addWidget(ylbl,4,2); + zlbl = new QLineEdit(p); g->addWidget(zlbl,4,3); + l = new QLabel(tr("at position"), p); g->addWidget(l,5,0); + QStringList lpos; + lpos.append(tr("at minimum")); lpos += tr("at center"); lpos += tr("at maximum"); + xpos = new QComboBox(p); g->addWidget(xpos,5,1); xpos->addItems(lpos); + ypos = new QComboBox(p); g->addWidget(ypos,5,2); ypos->addItems(lpos); + zpos = new QComboBox(p); g->addWidget(zpos,5,3); zpos->addItems(lpos); + l = new QLabel(tr("Ticks"), p); g->addWidget(l,6,0); + xtck = new QLineEdit(p); g->addWidget(xtck,6,1); + ytck = new QLineEdit(p); g->addWidget(ytck,6,2); + ztck = new QLineEdit(p); g->addWidget(ztck,6,3); + l = new QLabel(tr("SubTicks"), p); g->addWidget(l,7,0); + xsub = new QLineEdit(p); g->addWidget(xsub,7,1); + ysub = new QLineEdit(p); g->addWidget(ysub,7,2); + zsub = new QLineEdit(p); g->addWidget(zsub,7,3); + l = new QLabel(tr("Start"), p); g->addWidget(l,8,0); + xort = new QLineEdit(p); g->addWidget(xort,8,1); + yort = new QLineEdit(p); g->addWidget(yort,8,2); + zort = new QLineEdit(p); g->addWidget(zort,8,3); + l = new QLabel(tr("Template"), p); g->addWidget(l,9,0); + xtt = new QLineEdit(p); g->addWidget(xtt,9,1); + ytt = new QLineEdit(p); g->addWidget(ytt,9,2); + ztt = new QLineEdit(p); g->addWidget(ztt,9,3); + ctt = new QLineEdit(p); g->addWidget(ctt,9,4); + l = new QLabel(tr("AlphaDef"), p); g->addWidget(l,10,0); + aldef = new QLineEdit(p); g->addWidget(aldef,11,0); + l = new QLabel(tr("Ambient"), p); g->addWidget(l,10,1); + amb = new QLineEdit(p); g->addWidget(amb,11,1); + l = new QLabel(tr("BaseWidth"), p); g->addWidget(l,10,2); + basew = new QLineEdit(p); g->addWidget(basew,11,2); + l = new QLabel(tr("MeshNum"), p); g->addWidget(l,10,3); + mesh = new QLineEdit(p); g->addWidget(mesh,11,3); + l = new QLabel(tr("AxialDir"), p); g->addWidget(l,10,4); + axial = new QComboBox(p); g->addWidget(axial,11,4); + axial->addItem("none"); axial->addItem("x"); + axial->addItem("y"); axial->addItem("z"); + l = new QLabel(tr("Font"), p); g->addWidget(l,12,0); + font = new QLineEdit(p); g->addWidget(font,13,0); + l = new QLabel(tr("FontSize"), p); g->addWidget(l,12,1); + fsize = new QLineEdit(p); g->addWidget(fsize,13,1); + alpha = new QCheckBox(tr("Alpha on"),p); g->addWidget(alpha, 13,2); + light = new QCheckBox(tr("Light on"),p); g->addWidget(light, 13,3); + rotate = new QCheckBox(tr("No text rotation"),p); g->addWidget(rotate, 13,4); + tab->addTab(p, tr("General settings")); + + p = new QWidget(this); + g = new QGridLayout(p); g->setAlignment(Qt::AlignTop); + l = new QLabel(tr("ID"), p); g->addWidget(l,0,0); + l = new QLabel(tr("State"), p); g->addWidget(l,0,1); + l = new QLabel(tr("X pos"), p); g->addWidget(l,0,2); + l = new QLabel(tr("Y pos"), p); g->addWidget(l,0,3); + l = new QLabel(tr("Z pos"), p); g->addWidget(l,0,4); + l = new QLabel(tr("Color"), p); g->addWidget(l,0,5); + l = new QLabel(tr("Brightness"), p); g->addWidget(l,0,6); + char s[3] = "0:"; + for(int i=0;i<10;i++) + { + s[0] = char(i+'0'); + l = new QLabel(s, p); g->addWidget(l,i+1,0); + slight[i] = new QCheckBox(tr("on"),p); g->addWidget(slight[i], i+1, 1); + xlight[i] = new QLineEdit(p); g->addWidget(xlight[i], i+1, 2); + ylight[i] = new QLineEdit(p); g->addWidget(ylight[i], i+1, 3); + zlight[i] = new QLineEdit(p); g->addWidget(zlight[i], i+1, 4); + clight[i] = new QComboBox(p); g->addWidget(clight[i], i+1, 5); + fillColors(clight[i]); + blight[i] = new QLineEdit(p); g->addWidget(blight[i], i+1, 6); + } + tab->addTab(p, tr("Light settings")); + + QVBoxLayout *v = new QVBoxLayout(this); v->addWidget(tab); + QHBoxLayout *h = new QHBoxLayout(); v->addLayout(h); + l = new QLabel(tr("Template name"), this); h->addWidget(l); + fname = new QLineEdit("template.mgl", this); h->addWidget(fname); + h->addStretch(1); + b = new QPushButton(tr("Save"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(saveTmpl())); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("To script"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(toScript())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +SetupDialog::~SetupDialog() {} +//----------------------------------------------------------------------------- +void SetupDialog::saveTmpl() +{ + if(!convert()) return; + QFile f(fname->text()); + if(!f.open(QIODevice::WriteOnly)) + QMessageBox::warning(this, tr("UDAV - Save template"), tr("Could not write to file"), QMessageBox::Ok, 0); + else + { + QTextStream t(&f); t << res; f.close(); + QMessageBox::information(this, tr("UDAV - Save template"), tr("Template saved"), QMessageBox::Ok); + emit putText(QString("#call %1").arg(fname->text())); + } + +} +//----------------------------------------------------------------------------- +void SetupDialog::toScript() +{ + if(!convert()) return; + emit putText(res); + accept(); +} +//----------------------------------------------------------------------------- +bool SetupDialog::convert() +{ + // TODO: add error (missing values) parsing + int i,j; + double x1=0,y1=0,z1=0,x2=0,y2=0,z2=0; + bool u1,v1,w1,u2,v2,w2; + + QString s, col="wwbgrcmylenuqphkWBGRCMYLENUQPH"; + res = ""; + for(i=0;i<10;i++) // set light sources + { + if(!slight[i]->isChecked()) continue; + if(xlight[i]->text().isEmpty() || ylight[i]->text().isEmpty() || zlight[i]->text().isEmpty()) + { + QMessageBox::information(this, tr("UDAV - Setup plot"), tr("Light position should be filled. Ignore it."), QMessageBox::Ok); + continue; + } + x1=xlight[i]->text().toDouble(); y1=ylight[i]->text().toDouble(); + z1=zlight[i]->text().toDouble(); j = clight[i]->currentIndex(); + if(blight[i]->text().isEmpty()) + s.sprintf("light %d %g %g %g '%c'\n", i,x1,y1,z1, col[j].toLatin1()); + else + s.sprintf("light %d %g %g %g '%c' %g\n", i,x1,y1,z1, col[j].toLatin1(), blight[i]->text().toDouble()); + res += s; + } + u1 = !xmin->text().isEmpty(); if(u1) x1 = xmin->text().toDouble(); + u2 = !xmax->text().isEmpty(); if(u2) x2 = xmax->text().toDouble(); + v1 = !ymin->text().isEmpty(); if(v1) y1 = ymin->text().toDouble(); + v2 = !ymin->text().isEmpty(); if(v2) y2 = ymax->text().toDouble(); + w1 = !zmin->text().isEmpty(); if(w1) z1 = zmin->text().toDouble(); + w2 = !zmin->text().isEmpty(); if(w2) z2 = zmax->text().toDouble(); + if(u1&&v1&&w1&&u2&&v2&&w2) + { s.sprintf("axis %g %g %g %g %g %g\n",x1,y1,z1,x2,y2,z2); res += s; } + else + { + if(u1 && u2) {s.sprintf("xrange %g %g\n",x1,x2); res += s;} + if(v1 && v2) {s.sprintf("yrange %g %g\n",y1,y2); res += s;} + if(w1 && w2) {s.sprintf("zrange %g %g\n",z1,z2); res += s;} + } + u1 = !cmin->text().isEmpty(); if(u1) x1 = cmin->text().toDouble(); + u2 = !cmax->text().isEmpty(); if(u2) x2 = cmax->text().toDouble(); + if(u1&&u2) {s.sprintf("crange %g %g\n",x1,x2); res += s;} + + u1 = !xmin->text().isEmpty(); if(u1) x1 = xorg->text().toDouble(); + v1 = !yorg->text().isEmpty(); if(v1) y1 = yorg->text().toDouble(); + w1 = !zorg->text().isEmpty(); if(w1) z1 = zorg->text().toDouble(); + if(u1&&v1&&w1) {s.sprintf("origin %g %g %g\n",x1,y1,z1); res += s;} + + u1 = !xtck->text().isEmpty(); if(u1) x1 = xtck->text().toDouble(); + u2 = !xsub->text().isEmpty(); if(u2) x2 = xsub->text().toDouble(); + v1 = !ytck->text().isEmpty(); if(v1) y1 = ytck->text().toDouble(); + v2 = !ysub->text().isEmpty(); if(v2) y2 = ysub->text().toDouble(); + w1 = !ztck->text().isEmpty(); if(w1) z1 = ztck->text().toDouble(); + w2 = !zsub->text().isEmpty(); if(w2) z2 = zsub->text().toDouble(); + if(u1 && u2) + { + if(xort->text().isEmpty()) s.sprintf("xtick %g %g\n",x1,x2); + else s.sprintf("xtick %g %g %g\n",x1,x2,xort->text().toDouble()); + res += s; + } + if(v1 && v2) + { + if(yort->text().isEmpty()) s.sprintf("ytick %g %g\n",y1,y2); + else s.sprintf("ytick %g %g %g\n",y1,y2,yort->text().toDouble()); + res += s; + } + if(w1 && w2) + { + if(zort->text().isEmpty()) s.sprintf("ztick %g %g\n",z1,z2); + else s.sprintf("ztick %g %g %g\n",z1,z2,zort->text().toDouble()); + res += s; + } + if(u1 && !u2) {s.sprintf("xtick %g\n",x1); res += s;} + if(v1 && !v2) {s.sprintf("ytick %g\n",y1); res += s;} + if(w1 && !w2) {s.sprintf("ztick %g\n",z1); res += s;} + if(!xtt->text().isEmpty()) res = res + "xtick '" + xtt->text() + "'\n"; + if(!ytt->text().isEmpty()) res = res + "ytick '" + ytt->text() + "'\n"; + if(!ztt->text().isEmpty()) res = res + "ztick '" + ztt->text() + "'\n"; + if(!ctt->text().isEmpty()) res = res + "ctick '" + ctt->text() + "'\n"; + + if(!xlbl->text().isEmpty()) + { + s.sprintf("' %d\n", xpos->currentIndex()-1); + res = res + "xlabel '"+ xlbl->text() + s; + } + if(!ylbl->text().isEmpty()) + { + s.sprintf("' %d\n", ypos->currentIndex()-1); + res = res + "ylabel '"+ ylbl->text() + s; + } + if(!zlbl->text().isEmpty()) + { + s.sprintf("' %d\n", zpos->currentIndex()-1); + res = res + "zlabel '"+ zlbl->text() + s; + } + + if(!aldef->text().isEmpty()) + { s.sprintf("alphadef %g\n",aldef->text().toDouble()); res += s; } + if(!amb->text().isEmpty()) + { s.sprintf("ambient %g\n",amb->text().toDouble()); res += s; } + + if(!basew->text().isEmpty()) + { s.sprintf("baselinewidth %g\n",basew->text().toDouble()); res += s; } + if(!mesh->text().isEmpty()) + { s.sprintf("meshnum %d\n",mesh->text().toInt()); res += s; } + if(axial->currentIndex()>0) + { + s.sprintf("axialdir '%c'\n",char('x'+axial->currentIndex()-1)); + res += s; + } + + if(!font->text().isEmpty()) + { + res = res + "font '" + font->text(); + if(!fsize->text().isEmpty()) s.sprintf("' %g\n",fsize->text().toDouble()); + else s.sprintf("'\n"); + res += s; + } + if(rotate->isChecked()) res = res + "rotatetext off\n"; + + if(alpha->isChecked()) res = res + "alpha on\n"; + if(light->isChecked()) res = res + "light on\n"; + return true; +} +//----------------------------------------------------------------------------- diff --git a/udav/setup_dlg.h b/udav/setup_dlg.h new file mode 100644 index 0000000..5b501a9 --- /dev/null +++ b/udav/setup_dlg.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef SETUPDIALOG_H +#define SETUPDIALOG_H +//----------------------------------------------------------------------------- +#include +class QLineEdit; +class QCheckBox; +class QComboBox; +//----------------------------------------------------------------------------- +/// Add setup code to script or save it to file (template) +class SetupDialog : public QDialog +{ +Q_OBJECT +public: + SetupDialog(QWidget *parent = 0); + ~SetupDialog(); + +signals: + void putText(const QString &par); + +private slots: + void saveTmpl(); + void toScript(); + +private: + QString res; + QLineEdit *xmin, *xmax, *xorg, *xlbl, *xtck, *xsub, *xort, *xtt; + QLineEdit *ymin, *ymax, *yorg, *ylbl, *ytck, *ysub, *yort, *ytt; + QLineEdit *zmin, *zmax, *zorg, *zlbl, *ztck, *zsub, *zort, *ztt; + QLineEdit *cmin, *cmax, *aldef,*amb, *basew,*mesh, *font, *fsize, *fname, *ctt; + QLineEdit *xlight[10], *ylight[10], *zlight[10], *blight[10]; + QCheckBox *slight[10], *alpha, *light, *rotate; + QComboBox *clight[10], *xpos, *ypos, *zpos, *axial; + + bool convert(); +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/style_dlg.cpp b/udav/style_dlg.cpp new file mode 100644 index 0000000..0f4c918 --- /dev/null +++ b/udav/style_dlg.cpp @@ -0,0 +1,386 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#include "xpm/none.xpm" +#include "xpm/mark_.xpm" +#include "xpm/mark_cf.xpm" +#include "xpm/mark_x.xpm" +#include "xpm/mark_p.xpm" +#include "xpm/mark_pf.xpm" +#include "xpm/mark_o.xpm" +#include "xpm/mark_of.xpm" +#include "xpm/mark_s.xpm" +#include "xpm/mark_sf.xpm" +#include "xpm/mark_d.xpm" +#include "xpm/mark_df.xpm" +#include "xpm/mark_v.xpm" +#include "xpm/mark_vf.xpm" +#include "xpm/mark_t.xpm" +#include "xpm/mark_tf.xpm" +#include "xpm/mark_l.xpm" +#include "xpm/mark_lf.xpm" +#include "xpm/mark_r.xpm" +#include "xpm/mark_rf.xpm" +#include "xpm/mark_y.xpm" +#include "xpm/mark_a.xpm" +#include "xpm/mark_n.xpm" +#include "xpm/dash_e.xpm" +#include "xpm/dash_s.xpm" +#include "xpm/dash_l.xpm" +#include "xpm/dash_m.xpm" +#include "xpm/dash_d.xpm" +#include "xpm/dash_i.xpm" +#include "xpm/dash_j.xpm" +#include "xpm/arrow_n.xpm" +#include "xpm/arrow_a.xpm" +#include "xpm/arrow_v.xpm" +#include "xpm/arrow_i.xpm" +#include "xpm/arrow_k.xpm" +#include "xpm/arrow_t.xpm" +#include "xpm/arrow_s.xpm" +#include "xpm/arrow_d.xpm" +#include "xpm/arrow_o.xpm" +//----------------------------------------------------------------------------- +#include "style_dlg.h" +void fillColors(QComboBox *cb); +void fillArrows(QComboBox *cb); +void fillDashes(QComboBox *cb); +void fillMarkers(QComboBox *cb); +void convertFromGraph(QPixmap &pic, mglGraph *gr, uchar **buf); +//----------------------------------------------------------------------------- +StyleDialog::StyleDialog(QWidget *parent) : QDialog(parent) +{ + setWindowTitle(tr("UDAV - Insert style/scheme")); + QWidget *p; + QHBoxLayout *h; + QVBoxLayout *v, *u, *vv; + QGridLayout *g; + QLabel *l; + QPushButton *b; + grBuf = 0; + tab = new QTabWidget(this); + // line style + p = new QWidget(this); + g = new QGridLayout(p); g->setAlignment(Qt::AlignTop); +// g->setColStretch(0, 1); g->setColStretch(1, 1); g->setColStretch(2, 1); + l = new QLabel(tr("Arrow at start"), p); g->addWidget(l, 0, 0); + l = new QLabel(tr("Dashing"), p); g->addWidget(l, 0, 1); + l = new QLabel(tr("Arrow at end"), p); g->addWidget(l, 0, 2); + a1 = new QComboBox(p); g->addWidget(a1, 1, 0); fillArrows(a1); + dash = new QComboBox(p); g->addWidget(dash, 1, 1); fillDashes(dash); + a2 = new QComboBox(p); g->addWidget(a2, 1, 2); fillArrows(a2); + l = new QLabel(tr("Color"), p); g->addWidget(l, 2, 0, Qt::AlignRight); + cline=new QComboBox(p); g->addWidget(cline, 2, 1); fillColors(cline); + + nline = new QSlider(p); g->addWidget(nline, 2, 2); + nline->setRange(1, 9); nline->setValue(5); + nline->setTickPosition(QSlider::TicksBothSides); + nline->setTickInterval(1); nline->setPageStep(2); + nline->setOrientation(Qt::Horizontal); + + l = new QLabel(tr("Marks"), p); g->addWidget(l, 3, 0, Qt::AlignRight); + mark = new QComboBox(p); g->addWidget(mark, 3, 1); fillMarkers(mark); + l = new QLabel(tr("Line width"), p); g->addWidget(l, 4, 0, Qt::AlignRight); + width = new QSpinBox(p); g->addWidget(width, 4, 1); + width->setRange(1,9); width->setValue(1); + connect(a1,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(a2,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(dash,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(mark,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(cline,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(nline,SIGNAL(valueChanged(int)), this, SLOT(updatePic())); + connect(width,SIGNAL(valueChanged(int)), this, SLOT(updatePic())); + tab->addTab(p, tr("Line style")); + // color scheme + p = new QWidget(this); + v = new QVBoxLayout(p); v->setAlignment(Qt::AlignTop); + g = new QGridLayout(); v->addLayout(g); +// g->setColStretch(0, 1); g->setColStretch(1, 1); + l = new QLabel(tr("Color order"), p); g->addWidget(l, 0, 0); + l = new QLabel(tr("Saturation"),p); g->addWidget(l, 0, 1); + for(int i=0;i<7;i++) + { + cc[i] = new QComboBox(p); g->addWidget(cc[i], i+1, 0); + fillColors(cc[i]); + nn[i] = new QSlider(p); g->addWidget(nn[i], i+1, 1); + nn[i]->setRange(1, 9); nn[i]->setValue(5); + nn[i]->setTickPosition(QSlider::TicksBothSides); + nn[i]->setTickInterval(1); nn[i]->setPageStep(2); + nn[i]->setOrientation(Qt::Horizontal); + connect(cc[i],SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(nn[i],SIGNAL(valueChanged(int)), this, SLOT(updatePic())); + } + swire = new QCheckBox(tr("Wire or mesh plot"),p); v->addWidget(swire); + g = new QGridLayout(); v->addLayout(g); + l = new QLabel(tr("Axial direction"), p); g->addWidget(l, 0, 0, Qt::AlignRight); + l = new QLabel(tr("Text on contours"), p); g->addWidget(l, 1, 0, Qt::AlignRight); + axial = new QComboBox(p); g->addWidget(axial, 0, 1); + axial->addItem(tr("none")); axial->addItem("x"); + axial->addItem("y"); axial->addItem("z"); + ctext = new QComboBox(p); g->addWidget(ctext, 1, 1); + ctext->addItem(tr("none")); ctext->addItem(tr("under")); ctext->addItem(tr("above")); + connect(axial,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(ctext,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(swire,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + tab->addTab(p, tr("Color scheme")); + // font style + p = new QWidget(this); + v = new QVBoxLayout(p); v->setAlignment(Qt::AlignTop); + h = new QHBoxLayout(); v->addLayout(h); + u = new QVBoxLayout(); h->addLayout(u); + bold = new QCheckBox(tr("Bold style"), p); u->addWidget(bold); + ital = new QCheckBox(tr("Italic style"), p);u->addWidget(ital); + wire = new QCheckBox(tr("Wire style"), p); u->addWidget(wire); + uline = new QCheckBox(tr("Underline"), p); u->addWidget(uline); + oline = new QCheckBox(tr("Overline"), p); u->addWidget(oline); + u = new QVBoxLayout(); h->addLayout(u); + l = new QLabel(tr("Text color"), p); u->addWidget(l); + cfont = new QComboBox(p); fillColors(cfont); u->addWidget(cfont); + u->addSpacing(6); + align = new QGroupBox(tr("Text align"), p); u->addWidget(align); + vv = new QVBoxLayout(align); //vv->addSpacing(11); + rbL = new QRadioButton(tr("left"), align); vv->addWidget(rbL); + rbC = new QRadioButton(tr("at center"), align); + vv->addWidget(rbC); rbC->setChecked(true); + rbR = new QRadioButton(tr("right"), align); vv->addWidget(rbR); + connect(bold,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(ital,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(wire,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(uline,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(oline,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(cfont,SIGNAL(activated(int)), this, SLOT(updatePic())); + connect(rbL,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(rbC,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + connect(rbR,SIGNAL(toggled(bool)), this, SLOT(updatePic())); + tab->addTab(p, tr("Font style")); + connect(tab,SIGNAL(currentChanged(int)), this, SLOT(updatePic())); + + // dialog itself + v = new QVBoxLayout(this); v->addWidget(tab); + h = new QHBoxLayout(); v->addLayout(h); + l = new QLabel(tr("Resulting string"), this); h->addWidget(l); h->addStretch(1); + pic = new QLabel(this); pic->setMinimumSize(QSize(128,30)); h->addWidget(pic); + res = new QLineEdit(this); res->setReadOnly(true); v->addWidget(res); + + h = new QHBoxLayout(); v->addLayout(h); h->addStretch(1); + b = new QPushButton(tr("Cancel"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(reject())); + b = new QPushButton(tr("OK"), this); h->addWidget(b); + connect(b, SIGNAL(clicked()),this, SLOT(accept())); + b->setDefault(true); +} +//----------------------------------------------------------------------------- +StyleDialog::~StyleDialog() { if(grBuf) delete []grBuf; } +//----------------------------------------------------------------------------- +void fillColors(QComboBox *cb) +{ +// string id : "wbgrcmylenuqphkWBGRCMYLENUQPH" + QPixmap pic(16,16); + cb->addItem(QPixmap(none_xpm), QObject::tr("none or default")); + pic.fill(QColor(255,255,255)); cb->addItem(pic, QObject::tr("w - white")); + pic.fill(QColor(0,0,255)); cb->addItem(pic, QObject::tr("b - blue")); + pic.fill(QColor(0,255,0)); cb->addItem(pic, QObject::tr("g - lime")); + pic.fill(QColor(255,0,0)); cb->addItem(pic, QObject::tr("r - red")); + pic.fill(QColor(0,255,255)); cb->addItem(pic, QObject::tr("c - cyan")); + pic.fill(QColor(255,0,255)); cb->addItem(pic, QObject::tr("m - magenta")); + pic.fill(QColor(255,255,0)); cb->addItem(pic, QObject::tr("y - yellow")); + pic.fill(QColor(0,255,127)); cb->addItem(pic, QObject::tr("l - springgreen")); + pic.fill(QColor(127,255,0)); cb->addItem(pic, QObject::tr("e - lawngreen")); + pic.fill(QColor(0,127,255)); cb->addItem(pic, QObject::tr("n - skyblue")); + pic.fill(QColor(127,0,255)); cb->addItem(pic, QObject::tr("u - blueviolet")); + pic.fill(QColor(255,127,0)); cb->addItem(pic, QObject::tr("q - orange")); + pic.fill(QColor(255,0,127)); cb->addItem(pic, QObject::tr("p - deeppink")); + pic.fill(QColor(127,127,127)); cb->addItem(pic, QObject::tr("h - gray")); + pic.fill(QColor(0,0,0)); cb->addItem(pic, QObject::tr("k - black")); + pic.fill(QColor(179,179,179)); cb->addItem(pic, QObject::tr("W - lightgray")); + pic.fill(QColor(0,0,127)); cb->addItem(pic, QObject::tr("B - navy")); + pic.fill(QColor(0,127,0)); cb->addItem(pic, QObject::tr("G - green")); + pic.fill(QColor(127,0,0)); cb->addItem(pic, QObject::tr("R - maroon")); + pic.fill(QColor(0,127,127)); cb->addItem(pic, QObject::tr("C - teal")); + pic.fill(QColor(127,0,127)); cb->addItem(pic, QObject::tr("M - purple")); + pic.fill(QColor(127,127,0)); cb->addItem(pic, QObject::tr("Y - olive")); + pic.fill(QColor(0,127,77)); cb->addItem(pic, QObject::tr("L - seagreen")); + pic.fill(QColor(77,127,0)); cb->addItem(pic, QObject::tr("E - darklawn")); + pic.fill(QColor(0,77,127)); cb->addItem(pic, QObject::tr("N - darkskyblue")); + pic.fill(QColor(77,0,127)); cb->addItem(pic, QObject::tr("U - indigo")); + pic.fill(QColor(127,77,0)); cb->addItem(pic, QObject::tr("Q - brown")); + pic.fill(QColor(127,0,77)); cb->addItem(pic, QObject::tr("P - darkpink")); + pic.fill(QColor(77,77,77)); cb->addItem(pic, QObject::tr("H - darkgray")); +} +//----------------------------------------------------------------------------- +void fillArrows(QComboBox *cb) +{ + // "AVIKTSDO" + cb->addItem(QPixmap(arrow_n_xpm), QObject::tr("none")); + cb->addItem(QPixmap(arrow_a_xpm), QObject::tr("arrow")); + cb->addItem(QPixmap(arrow_v_xpm), QObject::tr("back arrow")); + cb->addItem(QPixmap(arrow_i_xpm), QObject::tr("stop")); + cb->addItem(QPixmap(arrow_k_xpm), QObject::tr("size")); + cb->addItem(QPixmap(arrow_t_xpm), QObject::tr("triangle")); + cb->addItem(QPixmap(arrow_s_xpm), QObject::tr("square")); + cb->addItem(QPixmap(arrow_d_xpm), QObject::tr("rhomb")); + cb->addItem(QPixmap(arrow_o_xpm), QObject::tr("circle")); +} +//----------------------------------------------------------------------------- +void fillDashes(QComboBox *cb) +{ + // "-|;=ji: " + cb->addItem(QPixmap(dash_s_xpm), QObject::tr("solid")); + cb->addItem(QPixmap(dash_l_xpm), QObject::tr("long dash")); + cb->addItem(QPixmap(dash_m_xpm), QObject::tr("dash")); + cb->addItem(QPixmap(dash_e_xpm), QObject::tr("small dash")); + cb->addItem(QPixmap(dash_j_xpm), QObject::tr("dash dot")); + cb->addItem(QPixmap(dash_i_xpm), QObject::tr("small dash dot")); + cb->addItem(QPixmap(dash_d_xpm), QObject::tr("dots")); + cb->addItem(QPixmap(mark_n_xpm), QObject::tr("none")); +} +//----------------------------------------------------------------------------- +void fillMarkers(QComboBox *cb) +{ + // ".+x*sdv^<>o.*+xsdv^<>o" : nf = 10 + cb->addItem(QPixmap(mark_n_xpm), QObject::tr("none")); + cb->addItem(QPixmap(mark__xpm), QObject::tr("dot")); + cb->addItem(QPixmap(mark_p_xpm), QObject::tr("plus")); + cb->addItem(QPixmap(mark_x_xpm), QObject::tr("skew cross")); + cb->addItem(QPixmap(mark_a_xpm), QObject::tr("asterix")); + cb->addItem(QPixmap(mark_s_xpm), QObject::tr("square")); + cb->addItem(QPixmap(mark_d_xpm), QObject::tr("rhomb")); + cb->addItem(QPixmap(mark_v_xpm), QObject::tr("triangle down")); + cb->addItem(QPixmap(mark_t_xpm), QObject::tr("triangle up")); + cb->addItem(QPixmap(mark_l_xpm), QObject::tr("triangle left")); + cb->addItem(QPixmap(mark_r_xpm), QObject::tr("triangle right")); + cb->addItem(QPixmap(mark_o_xpm), QObject::tr("circle")); + + cb->addItem(QPixmap(mark_cf_xpm), QObject::tr("circled dot")); + cb->addItem(QPixmap(mark_y_xpm), QObject::tr("Y-sign")); + cb->addItem(QPixmap(mark_pf_xpm), QObject::tr("squared plus")); + cb->addItem(QPixmap(none_xpm), QObject::tr("squared cross")); + + cb->addItem(QPixmap(mark_sf_xpm), QObject::tr("solid square")); + cb->addItem(QPixmap(mark_df_xpm), QObject::tr("solid rhomb")); + cb->addItem(QPixmap(mark_vf_xpm), QObject::tr("solid triangle down")); + cb->addItem(QPixmap(mark_tf_xpm), QObject::tr("solid triangle up")); + cb->addItem(QPixmap(mark_lf_xpm), QObject::tr("solid triangle left")); + cb->addItem(QPixmap(mark_rf_xpm), QObject::tr("solid triangle right")); + cb->addItem(QPixmap(mark_of_xpm), QObject::tr("solid circle")); +} +//----------------------------------------------------------------------------- +void StyleDialog::updatePic() +{ + static mglGraph gr(0,128,30); + static bool f = true; + mglData x(3), y(3), a(32,2); + x.Fill(-1,1); a.Fill(-1,1); + if(!f) gr.Clf(); + if(f) + { + gr.SubPlot(1,1,0,""); + gr.SetMarkSize(20); + gr.SetArrowSize(20); + f = false; + } + result = ""; + int i,j; + QString col="wbgrcmylenuqphkWBGRCMYLENUQPH", mrk=".+x*sdv^<>o.*+xsdv^<>o", dsh="|;=ji: ", arw="AVIKTSDO", s; + switch(tab->currentIndex()) + { + case 0: // line style + i = a2->currentIndex(); if(i>0) result += arw[i-1]; + j = a1->currentIndex(); if(j>0) + { + if(i==0) result += '_'; + result += arw[j-1]; + } + i = dash->currentIndex(); if(i>0) result += dsh[i-1]; + i = mark->currentIndex(); if(i>0) result += mrk[i-1]; + if(i>11) result += '#'; + i = cline->currentIndex(); + if(i>0) + { + j = nline->value(); + if(j!=5) result += "{"+col[i-1]+char('0'+j)+"}"; + else result += col[i-1]; + } + i = width->value(); if(i>1) result += char('0'+i); + gr.Plot(x,y,result.toStdString().c_str()); + break; + case 1: // color sceheme + for(j=0;j<7;j++) + { + i = cc[j]->currentIndex(); + if(i<1) break; + QCharRef c = col[i-1]; + i = nn[j]->value(); + if(i!=5) result += "{"+c+char('0'+i)+"}"; + else result += c; + } + if(swire->isChecked()) result += '#'; + i = ctext->currentIndex(); + if(i==1) result += 't'; + if(i==2) result += 'T'; + i = axial->currentIndex(); + if(i>0) result = result+':'+char('x'+i-1); + gr.Surf(a,result.toStdString().c_str()); + break; + case 2: // text style + i = cfont->currentIndex(); + if(i>1) result += col[i-1]; + result += ':'; + if(bold->isChecked()) result += 'b'; + if(ital->isChecked()) result += 'i'; + if(wire->isChecked()) result += 'w'; + if(uline->isChecked()) result += 'u'; + if(oline->isChecked()) result += 'o'; + if(rbL->isChecked()) result += 'L'; + if(rbC->isChecked()) result += 'C'; + if(rbR->isChecked()) result += 'R'; + gr.Puts(mglPoint(0,-0.5),"Font test",result.toStdString().c_str(),-10); + break; + } + result = "'" + result + "'"; + res->setText(result); + QPixmap p; + convertFromGraph(p, &gr, &grBuf); + pic->setPixmap(p); +} +//----------------------------------------------------------------------------- +void convertFromGraph(QPixmap &pic, mglGraph *gr, uchar **buf) +{ + register long w=gr->GetWidth(), h=gr->GetHeight(); + if(*buf) delete [](*buf); + *buf = new uchar[4*w*h]; + gr->GetBGRN(*buf,4*w*h); + QImage img(*buf, w, h, QImage::Format_RGB32); + pic = QPixmap::fromImage(img); +} +//----------------------------------------------------------------------------- diff --git a/udav/style_dlg.h b/udav/style_dlg.h new file mode 100644 index 0000000..fd7fe96 --- /dev/null +++ b/udav/style_dlg.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef STYLEDIALOG_H +#define STYLEDIALOG_H +//----------------------------------------------------------------------------- +#include +class QComboBox; +class QSlider; +class QSpinBox; +class QGroupBox; +class QTabWidget; +class QCheckBox; +class QLabel; +class QLineEdit; +class QRadioButton; +//----------------------------------------------------------------------------- +/// Selecting styles of command (like line style, color scheme, font style, axis style) +class StyleDialog : public QDialog +{ +Q_OBJECT +public: + QString getStyle() { return result; }; + StyleDialog(QWidget *parent = 0); + ~StyleDialog(); +private slots: + void updatePic(); +private: + QString result; + QComboBox *cc[8], *cline, *cfont; + QSlider *nn[8], *nline; + QComboBox *axial, *ctext, *a1, *a2, *dash, *mark; + QCheckBox *swire, *upd; + QCheckBox *ital, *bold, *wire, *uline, *oline; + QSpinBox *width; + QGroupBox *align; + QTabWidget *tab; + QLabel *box, *pic; + QLineEdit *res; + QRadioButton *rbL, *rbC, *rbR; + uchar *grBuf; +}; +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/text_pnl.cpp b/udav/text_pnl.cpp new file mode 100644 index 0000000..8bc78ab --- /dev/null +++ b/udav/text_pnl.cpp @@ -0,0 +1,567 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mgl2/qmathgl.h" +//----------------------------------------------------------------------------- +#include "udav_wnd.h" +#include "qmglsyntax.h" +#include "find_dlg.h" +#include "opt_dlg.h" +#include "style_dlg.h" +#include "files_dlg.h" +#include "newcmd_dlg.h" +#include "setup_dlg.h" +#include "text_pnl.h" +#include "plot_pnl.h" +//----------------------------------------------------------------------------- +FilesDialog *files_dlg=0; +QString defFontFamily; +int defFontSize; +bool mglAutoExecute = true; +extern mglParse parser; +extern bool mglCompleter; +QWidget *createDataOpenDlg(QWidget *p); +QString getOpenDataFile(QWidget *w, QString filename); +//----------------------------------------------------------------------------- +TextPanel::TextPanel(QWidget *parent) : QWidget(parent) +{ + printer = new QPrinter; + findDialog = new FindDialog(this); + optDialog = new OptionDialog(this); + stlDialog = new StyleDialog(this); + newCmdDlg = new NewCmdDialog(this); + setupDlg = new SetupDialog(this); + dataOpenDlg = createDataOpenDlg(this); + if(!files_dlg) files_dlg= new FilesDialog; + + register int i,n=parser.GetCmdNum(); + for(i=0;isetAcceptRichText(false); + new QMGLSyntax(edit); + defFontFamily = edit->fontFamily(); + defFontSize = int(edit->fontPointSize()); + edit->setLineWrapMode(QTextEdit::NoWrap); + setCompleter(mglCompleter); + + QBoxLayout *v,*h; + menu = new QMenu(tr("Edit"),this); + v = new QVBoxLayout(this); + h = new QHBoxLayout(); v->addLayout(h); + toolTop(h); v->addWidget(edit); +} +//----------------------------------------------------------------------------- +TextPanel::~TextPanel() { delete printer; } +//----------------------------------------------------------------------------- +void TextPanel::setCompleter(bool en) +{ + if(en) + { + QCompleter *completer = new QCompleter(vars, this); + completer->setCaseSensitivity(Qt::CaseInsensitive); + completer->setCompletionMode(QCompleter::PopupCompletion); + edit->setCompleter(completer); + } + else edit->setCompleter(0); +// completer->setCompletionMode(en ? QCompleter::PopupCompletion : QCompleter::InlineCompletion); +} +//----------------------------------------------------------------------------- +void TextPanel::insNVal() +{ + QString sel=edit->textCursor().selectedText(); + if(sel.isEmpty()) + { + QMessageBox::warning(this,tr("UDAV"),tr("There is no selection to evaluate.")); + return; + } + wchar_t *txt=new wchar_t[sel.length()+1]; + sel.toWCharArray(txt); txt[sel.length()]=0; + mglData res=parser.Calc(txt); + delete []txt; + edit->textCursor().insertText(QString::number(res.GetVal(0))); +} +//----------------------------------------------------------------------------- +void TextPanel::insFitF() +{ + QString str(graph->getFit()); + if(str.isEmpty()) + { + QMessageBox::warning(this,tr("UDAV"),tr("There is no fitted formula.")); + return; + } + edit->textCursor().insertText("'"+str+"'"); +} +//----------------------------------------------------------------------------- +void TextPanel::insFile() +{ + QString str = QFileDialog::getOpenFileName(this, tr("UDAV - Insert filename")); + if(str.isEmpty()) return; + edit->textCursor().insertText("'"+str+"'"); +} +//----------------------------------------------------------------------------- +void TextPanel::insPath() +{ + QString str = QFileDialog::getExistingDirectory(this, tr("UDAV - Insert filename")); + if(str.isEmpty()) return; + edit->textCursor().insertText("'"+str+"'"); +} +//----------------------------------------------------------------------------- +void TextPanel::refreshData() +{ + vars=words; + mglVar *v = parser.FindVar(""); + while(v) + { + if(v->s.length()>2) vars<s); + v = v->next; + } + setCompleter(mglCompleter); +} +//----------------------------------------------------------------------------- +void TextPanel::printText() +{ + QPrintDialog printDlg(printer, this); + if (printDlg.exec() == QDialog::Accepted) + { + setStatus(tr("Printing...")); + edit->print(printer); + setStatus(tr("Printing completed")); + } + else setStatus(tr("Printing aborted")); +} +//----------------------------------------------------------------------------- +void TextPanel::find() +{ + findDialog->show(); + findDialog->raise(); + findDialog->activateWindow(); +} +//----------------------------------------------------------------------------- +bool TextPanel::findText(const QString &str, bool cs, bool fw) +{ +// static int para=0, index=0; + static QTextDocument::FindFlags f; + static QString stri=""; + if(!str.isEmpty()) + { + stri = str; + f = QTextDocument::FindFlags(); + if(fw) f = f|QTextDocument::FindBackward; + if(cs) f = f|QTextDocument::FindCaseSensitively; + } + bool res = edit->find(stri, f); + if(!res) + QMessageBox::information(this, tr("UDAV - find text"), tr("No string occurrence is found")); + return res; +} +//----------------------------------------------------------------------------- +void TextPanel::replText(const QString &str, const QString &txt, bool cs, bool fw) +{ + static bool res=false; + if(str.isEmpty()) { res = false; return; } + if(res) edit->textCursor().insertText(txt); + res = findText(str, cs, fw); +} +//----------------------------------------------------------------------------- +void TextPanel::addOptions() +{ + if(optDialog->exec()==QDialog::Accepted) + { + edit->moveCursor(QTextCursor::EndOfLine); + edit->insertPlainText(optDialog->getOption()); + } +} +//----------------------------------------------------------------------------- +void TextPanel::animPutText(const QString &s) +{ edit->moveCursor(QTextCursor::Start); edit->insertPlainText(s); } +//----------------------------------------------------------------------------- +//void TextPanel::putText(const QString &txt) { edit->insertPlainText(txt); } +//----------------------------------------------------------------------------- +void TextPanel::putLine(const QString &txt) +{ edit->moveCursor(QTextCursor::StartOfLine); + edit->insertPlainText(txt+"\n"); } +//----------------------------------------------------------------------------- +void TextPanel::addStyle() +{ + if(stlDialog->exec()==QDialog::Accepted) + { + QString s = edit->textCursor().block().text(); + int i = s.indexOf(';'); + if(i<0) edit->moveCursor(QTextCursor::EndOfLine); + else + { + edit->moveCursor(QTextCursor::StartOfBlock); + // foolish way :( + for(;i>0;i--) edit->moveCursor(QTextCursor::Left); + } + edit->insertPlainText(stlDialog->getStyle()); + } +} +//----------------------------------------------------------------------------- +void TextPanel::setEditorFont(QFont *f) +{ edit->setFont(f ? *f : QFont(defFontFamily, defFontSize)); } +//----------------------------------------------------------------------------- +QString TextPanel::selection() +{ return edit->textCursor().block().text(); } +//----------------------------------------------------------------------------- +void TextPanel::setCursorPosition(int n) +{ + graph->setCurPos(n); + if(n<0) return; + edit->moveCursor(QTextCursor::Start); + for(int i=0;imoveCursor(QTextCursor::NextBlock); + edit->setFocus(); +} +//----------------------------------------------------------------------------- +void TextPanel::newCmd(int n) +{ + if(n>0) setCursorPosition(n-1); + else if(n==0) return; + newCmdDlg->parseCmd(edit->textCursor().block().text()); + newCmdDlg->show(); +} +//----------------------------------------------------------------------------- +#if MGL_HAVE_HDF5 +#define H5_USE_16_API +#include +void TextPanel::loadHDF5(const QString &fileName) +{ + // H5T_C_S1 - C string + hid_t hf,hg,hd,hs,ht; + hsize_t dims[3]; + long rank; + hf = H5Fopen(fileName.toStdString().c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); + if(!hf) return; + hg = H5Gopen(hf, "/"); + hsize_t num, nx, ny, nz, i; + char name[256]; + H5Gget_num_objs(hg, &num); + for(i=0;imgl->primitives = str.section("#----- End of QMathGL block -----\n",0,0); + str = str.section("#----- End of QMathGL block -----\n",1); + } + edit->setText(str); + graph->animParseText(edit->toPlainText()); + setCurrentFile(fileName); + delete []buf; + setStatus(tr("Loaded document %1").arg(fileName)); + if(mglAutoExecute) graph->execute(); + } + else if(H5Tget_class(ht)==H5T_FLOAT || H5Tget_class(ht)==H5T_INTEGER) + { + for(int j=0;name[j];j++) if(!isalnum(name[j])) name[j]='_'; + mglVar *v = parser.AddVar(name); + nx = ny = nz = 1; + if(rank>0 && rank<=3) + { + H5Sget_simple_extent_dims(hs,dims,0); + switch(rank) + { + case 1: nx=dims[0]; break; + case 2: nx=dims[1]; ny=dims[0]; break; + case 3: nx=dims[2]; ny=dims[1]; nz=dims[0]; break; + } + v->Create(nx, ny, nz); +#if MGL_USE_DOUBLE + H5Dread(hd, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, v->a); +#else + H5Dread(hd, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, v->a); +#endif + } + } + H5Dclose(hd); H5Sclose(hs); H5Tclose(ht); + } + H5Gclose(hg); H5Fclose(hf); +} +//----------------------------------------------------------------------------- +void TextPanel::saveHDF5(const QString &fileName) +{ + hid_t hf,hd,hs; + hsize_t dims[3]; + long rank = 3; + + H5Eset_auto(0,0); + hf = H5Fcreate(fileName.toStdString().c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if(hf<0) + { + setStatus(tr("Could not write to %1").arg(fileName)); + return; + } + { // save script + QString txt; + if(!graph->mgl->primitives.isEmpty()) + txt += graph->mgl->primitives + "#----- End of QMathGL block -----"; + txt += edit->toPlainText(); + dims[0] = txt.length()+1; + char *buf = new char[dims[0]+1]; + memcpy(buf, txt.toStdString().c_str(), dims[0]); + buf[dims[0]]=0; + hs = H5Screate_simple(1, dims, 0); + hd = H5Dcreate(hf, "mgl_script", H5T_C_S1, hs, H5P_DEFAULT); + H5Dwrite(hd, H5T_C_S1, hs, hs, H5P_DEFAULT, buf); + H5Dclose(hd); H5Sclose(hs); + delete []buf; + } + mglVar *v = parser.FindVar(""); + char name[256]; + while(v) + { + wcstombs(name,v->s.c_str(),v->s.length()+1); + if(v->nz==1 && v->ny == 1) + { rank = 1; dims[0] = v->nx; } + else if(v->nz==1) + { rank = 2; dims[0] = v->ny; dims[1] = v->nx; } + else + { rank = 3; dims[0] = v->nz; dims[1] = v->ny; dims[2] = v->nx; } + hs = H5Screate_simple(rank, dims, 0); + hd = H5Dcreate(hf, name, H5T_IEEE_F32LE, hs, H5P_DEFAULT); + + H5Dwrite(hd, H5T_NATIVE_FLOAT, hs, hs, H5P_DEFAULT, v->a); + H5Dclose(hd); H5Sclose(hs); + v = v->next; + } + H5Fclose(hf); + setCurrentFile(fileName); + setStatus(tr("File %1 saved").arg(fileName)); + return; +} +#else +void TextPanel::saveHDF5(const QString &fileName){} +void TextPanel::loadHDF5(const QString &fileName){} +#endif +//----------------------------------------------------------------------------- +void TextPanel::load(const QString &fileName) +{ + if(fileName.right(4).toLower()==".dat") + { + QString code = getOpenDataFile(dataOpenDlg, fileName); + if(!code.isEmpty()) + { + setCurrentFile(fileName.left(fileName.length()-3)+"mgl"); + edit->setText(code); + } + } + else if(fileName.right(4).toLower()==".hdf" || fileName.right(3).toLower()==".h5") + loadHDF5(fileName); + else + { + QFile f(fileName); + if(!f.open(QIODevice::ReadOnly)) + { + QMessageBox::warning(this,tr("UDAV - open file"), + tr("Couldn't open file ")+"'"+fileName+"'", + QMessageBox::Ok,0,0); + return; + } + + QTextStream ts(&f); + ts.setAutoDetectUnicode(true); +// ts.setCodec(QTextCodec::codecForLocale()); + + QString str=ts.readAll(); + int narg=0,i=-1; + if(str.contains('%')) + { + while((i = str.indexOf('%',i+1))>0) + { + char ch = str.at(i+1).toLatin1(); + if(ch>='1' && ch<='9' && ch-'0'>narg) + narg = ch-'0'; + } + if(narg>0) + { + files_dlg->setNumFiles(narg); + if(!files_dlg->exec()) return; // nothing to do + str = files_dlg->putFiles(str); + } + } + if(str.contains("#----- End of QMathGL block -----\n")) + { + graph->mgl->primitives = str.section("#----- End of QMathGL block -----\n",0,0); + str = str.section("#----- End of QMathGL block -----\n",1); + } + + if(narg>0) setCurrentFile(fileName.left(fileName.length()-3)+"mgl"); + edit->setText(str); + graph->animParseText(edit->toPlainText()); + if(narg==0) setCurrentFile(fileName); + } + setStatus(tr("Loaded document ")+fileName); + if(mglAutoExecute) graph->execute(); +} +//----------------------------------------------------------------------------- +void TextPanel::save(const QString &fileName) +{ + if(fileName.right(4)==".hdf" || fileName.right(3)==".h5") + { saveHDF5(fileName); return; } + QString text; + if(!graph->mgl->primitives.isEmpty()) + text += graph->mgl->primitives + "#----- End of QMathGL block -----\n"; + text += edit->toPlainText(); + QFile f(fileName); + if(!f.open(QIODevice::WriteOnly)) + { + setStatus(tr("Could not write to %1").arg(fileName)); + return; + } + QTextStream t(&f); + t.setAutoDetectUnicode(true); + t << text; f.close(); + setCurrentFile(fileName); + setStatus(tr("File %1 saved").arg(fileName)); +} +//----------------------------------------------------------------------------- +void TextPanel::addSetup() { setupDlg->exec(); } +//----------------------------------------------------------------------------- +#include "xpm/option.xpm" +#include "xpm/style.xpm" +//----------------------------------------------------------------------------- +void TextPanel::toolTop(QBoxLayout *l) +{ + QAction *a; + QMenu *o=menu, *oo; + QToolButton *bb; + const MainWindow *mw=findMain(this); + + // general buttons + if(mw) + { + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(mw->aload); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(mw->asave); + } + // edit menu + a = new QAction(QPixmap(":/xpm/edit-undo.png"), tr("Undo"), this); + connect(a, SIGNAL(triggered()), edit, SLOT(undo())); + a->setToolTip(tr("Undo editor change (Ctrl+Z).")); + a->setShortcut(Qt::CTRL+Qt::Key_Z); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-redo.png"), tr("Redo"), this); + connect(a, SIGNAL(triggered()), edit, SLOT(redo())); + a->setToolTip(tr("Redo editor change (Ctrl+Shift+Z).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_Z); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + o->addSeparator(); + o->addAction(tr("Clear all"), edit, SLOT(clear())); + a = new QAction(QPixmap(":/xpm/edit-cut.png"), tr("Cut text"), this); + connect(a, SIGNAL(triggered()), edit, SLOT(cut())); + a->setToolTip(tr("Cut selected text to clipboard (Ctrl+X).")); + a->setShortcut(Qt::CTRL+Qt::Key_X); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-copy.png"), tr("Copy text"), this); + connect(a, SIGNAL(triggered()), edit, SLOT(copy())); + a->setToolTip(tr("Copy selected text or data to clipboard (Ctrl+C).")); + a->setShortcut(Qt::CTRL+Qt::Key_C); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(QPixmap(":/xpm/edit-paste.png"), tr("Paste text"), this); + connect(a, SIGNAL(triggered()), edit, SLOT(paste())); + a->setToolTip(tr("Paste text or data from clipboard (Ctrl+V).")); + a->setShortcut(Qt::CTRL+Qt::Key_V); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + o->addAction(QPixmap(":/xpm/edit-select-all.png"), tr("Select all"), edit, SLOT(selectAll()), Qt::CTRL+Qt::Key_A); + o->addSeparator(); + + a = new QAction(QPixmap(":/xpm/edit-find.png"), tr("Find/Replace"), this); + connect(a, SIGNAL(triggered()), this, SLOT(find())); + a->setToolTip(tr("Show dialog for text finding (Ctrl+F).")); + a->setShortcut(Qt::CTRL+Qt::Key_F); o->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(tr("Find next"), this); + connect(a, SIGNAL(triggered()), this, SLOT(findText())); + a->setShortcut(Qt::Key_F3); o->addAction(a); + o->addSeparator(); + + // insert menu + oo = o->addMenu(tr("Insert")); + a = new QAction(QPixmap(":/xpm/format-indent-more.png"), tr("New command"), this); + a->setShortcut(Qt::META+Qt::Key_C); connect(a, SIGNAL(triggered()), this, SLOT(newCmd())); + a->setToolTip(tr("Show dialog for new command and put it into the script.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + a = new QAction(tr("Fitted formula"), this); + a->setShortcut(Qt::META+Qt::Key_F); connect(a, SIGNAL(triggered()), this, SLOT(insFitF())); + a->setToolTip(tr("Insert last fitted formula with found coefficients.")); + oo->addAction(a); + a = new QAction(QPixmap(style_xpm), tr("Plot style"), this); + a->setShortcut(Qt::META+Qt::Key_S); connect(a, SIGNAL(triggered()), this, SLOT(addStyle())); + a->setToolTip(tr("Show dialog for styles and put it into the script.\nStyles define the plot view (color scheme, marks, dashing and so on).")); + oo->addAction(a); + a = new QAction(QPixmap(option_xpm), tr("Command options"), this); + a->setShortcut(Qt::META+Qt::Key_O); connect(a, SIGNAL(triggered()), this, SLOT(addOptions())); + a->setToolTip(tr("Show dialog for options and put it into the script.\nOptions are used for additional setup the plot.")); + oo->addAction(a); + a = new QAction(tr("Numeric value"), this); + a->setShortcut(Qt::META+Qt::Key_N); connect(a, SIGNAL(triggered()), this, SLOT(insNVal())); + a->setToolTip(tr("Replace expression by its numerical value.")); + oo->addAction(a); + a = new QAction(QPixmap(":/xpm/x-office-spreadsheet.png"), tr("File name"), this); + a->setShortcut(Qt::META+Qt::Key_P); connect(a, SIGNAL(triggered()), this, SLOT(insFile())); + a->setToolTip(tr("Select and insert file name.")); + oo->addAction(a); + a = new QAction(QPixmap(":/xpm/folder.png"), tr("Folder path"), this); + connect(a, SIGNAL(triggered()), this, SLOT(insPath())); + a->setToolTip(tr("Select and insert folder name.")); + oo->addAction(a); + + a = new QAction(QPixmap(":/xpm/document-properties.png"), tr("Graphics setup"), this); + a->setShortcut(Qt::META+Qt::Key_G); connect(a, SIGNAL(triggered()), this, SLOT(addSetup())); + a->setToolTip(tr("Show dialog for plot setup and put code into the script.\nThis dialog setup axis, labels, lighting and other general things.")); + oo->addAction(a); + bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(a); + + l->addStretch(1); + if(mw) bb = new QToolButton(this); l->addWidget(bb); bb->setDefaultAction(mw->acalc); +} +//----------------------------------------------------------------------------- diff --git a/udav/text_pnl.h b/udav/text_pnl.h new file mode 100644 index 0000000..5d86d49 --- /dev/null +++ b/udav/text_pnl.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef TEXT_PNL_H +#define TEXT_PNL_H +//----------------------------------------------------------------------------- +#include +#include +#include "textedit.h" +//----------------------------------------------------------------------------- +class QMenu; +class QPrinter; +class QBoxLayout; +class FindDialog; +class OptionDialog; +class StyleDialog; +class SetupDialog; +class NewCmdDialog; +class PlotPanel; +//----------------------------------------------------------------------------- +class TextPanel : public QWidget +{ +Q_OBJECT +public: + QMenu *menu; + TextEdit *edit; ///< script itself + PlotPanel *graph; ///< NOTE: have to be filled!!! + NewCmdDialog *newCmdDlg; + + TextPanel(QWidget *parent = 0); + ~TextPanel(); + void load(const QString &fileName); + void save(const QString &fileName); + inline bool isModified() { return edit->document()->isModified(); } + inline void setModified(bool m) { edit->document()->setModified(m); } + inline void moveCursor(QTextCursor::MoveOperation c) + { edit->moveCursor(c); } + void setCompleter(bool en); + QString selection(); + +signals: + void setCurrentFile(const QString &s); + void setStatus(const QString &s); + +public slots: + void setEditorFont(QFont *f=0); +// void setEditPos(bool bottom); + void animPutText(const QString &); +// void putText(const QString &txt); + void putLine(const QString &txt); + void setCursorPosition(int); + + void addOptions(); + void addStyle(); + void insNVal(); + void insFile(); + void insPath(); + void insFitF(); + void newCmd(int n=-1); + void addSetup(); + + void refreshData(); + void printText(); + void find(); + bool findText(const QString &str="", bool cs=false, bool fw=true); + void replText(const QString &str, const QString &txt, bool cs=false, bool fw=true); + +private: + + QStringList words, vars; + QPrinter *printer; + + FindDialog *findDialog; + OptionDialog *optDialog; + StyleDialog *stlDialog; + QWidget *dataOpenDlg; + SetupDialog *setupDlg; + + void toolTop(QBoxLayout *l); +// void toolLeft(QBoxLayout *l); + + void saveHDF5(const QString &fileName); + void loadHDF5(const QString &fileName); +}; +//----------------------------------------------------------------------------- +#endif // TEXT_PNL_H +//----------------------------------------------------------------------------- diff --git a/udav/textedit.cpp b/udav/textedit.cpp new file mode 100644 index 0000000..ff16d95 --- /dev/null +++ b/udav/textedit.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** + ** + ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include "textedit.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +extern QColor mglColorScheme[10]; +//----------------------------------------------------------------------------- +TextEdit::TextEdit(QWidget *parent) : QTextEdit(parent) +{ + c=0; + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlight())); +} +//----------------------------------------------------------------------------- +void TextEdit::highlight() +{ + QList extraSelections; + if (!isReadOnly()) + { + QTextEdit::ExtraSelection selection; + selection.format.setBackground(mglColorScheme[9]); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + setExtraSelections(extraSelections); +} +//----------------------------------------------------------------------------- +void TextEdit::setCompleter(QCompleter *completer) +{ + if(c && c!=completer) + { QObject::disconnect(c); c->setWidget(0); delete c; c=0; } + if(!completer) return; + c = completer; + c->setWidget(this); + c->setCompletionMode(QCompleter::PopupCompletion); + c->setCaseSensitivity(Qt::CaseInsensitive); + QObject::connect(c, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString))); +} +//----------------------------------------------------------------------------- +void TextEdit::insertCompletion(const QString& completion) +{ + if (!c || c->widget() != this) return; + QTextCursor tc = textCursor(); + int extra = completion.length() - c->completionPrefix().length(); + tc.movePosition(QTextCursor::Left); + tc.movePosition(QTextCursor::EndOfWord); + tc.insertText(completion.right(extra)); + setTextCursor(tc); +} +//----------------------------------------------------------------------------- +QString TextEdit::textUnderCursor() const +{ + QTextCursor tc = textCursor(); + tc.select(QTextCursor::WordUnderCursor); + return tc.selectedText(); +} +//----------------------------------------------------------------------------- +void TextEdit::focusInEvent(QFocusEvent *e) +{ if (c) c->setWidget(this); QTextEdit::focusInEvent(e); } +//----------------------------------------------------------------------------- +void TextEdit::keyPressEvent(QKeyEvent *e) +{ + if (c && c->popup()->isVisible()) + { + // The following keys are forwarded by the completer to the widget + switch (e->key()) + { + case Qt::Key_Enter: + case Qt::Key_Return: + case Qt::Key_Escape: + case Qt::Key_Tab: + case Qt::Key_Backtab: + e->ignore(); return; // let the completer do default behavior + default: + break; + } + } + + bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E + if (!c || !isShortcut) // do not process the shortcut when we have a completer + QTextEdit::keyPressEvent(e); + + const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); + if (!c || (ctrlOrShift && e->text().isEmpty())) + return; + + static QString eow("~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word + bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; + QString completionPrefix = textUnderCursor(); + + if (!isShortcut && (hasModifier || e->text().isEmpty()|| completionPrefix.length() < 3 + || eow.contains(e->text().right(1)))) + { c->popup()->hide(); return; } + + if (completionPrefix != c->completionPrefix()) + { + c->setCompletionPrefix(completionPrefix); + c->popup()->setCurrentIndex(c->completionModel()->index(0, 0)); + } + QRect cr = cursorRect(); + cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width()); + c->complete(cr); // popup it up! +} +//----------------------------------------------------------------------------- diff --git a/udav/textedit.h b/udav/textedit.h new file mode 100644 index 0000000..3f45770 --- /dev/null +++ b/udav/textedit.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TEXTEDIT_H +#define TEXTEDIT_H +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +class QCompleter; +class Numb; +//----------------------------------------------------------------------------- +class TextEdit : public QTextEdit +{ Q_OBJECT +public: + TextEdit(QWidget *parent = 0); + void setCompleter(QCompleter *c); + QCompleter *completer() const { return c; } + +protected: + void keyPressEvent(QKeyEvent *e); + void focusInEvent(QFocusEvent *e); + +private slots: + void insertCompletion(const QString &completion); + void highlight(); + +private: + QString textUnderCursor() const; + QCompleter *c; +}; +//----------------------------------------------------------------------------- +#endif // TEXTEDIT_H +//----------------------------------------------------------------------------- diff --git a/udav/tree_pnl.cpp b/udav/tree_pnl.cpp new file mode 100644 index 0000000..e69de29 diff --git a/udav/tree_pnl.h b/udav/tree_pnl.h new file mode 100644 index 0000000..26a1186 --- /dev/null +++ b/udav/tree_pnl.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef TREE_PNL_H +#define TREE_PNL_H +//----------------------------------------------------------------------------- +#include +#include +//----------------------------------------------------------------------------- +class QMenu; +class QBoxLayout; +class OptionDialog; +class NewCmdDialog; +class PlotPanel; +class TextEdit; +//----------------------------------------------------------------------------- +class TreePanel : public QWidget +{ +Q_OBJECT +public: + // NOTE: these 3 pointers have to be filled!!! + TextEdit *edit; ///< script itself + PlotPanel *graph; + NewCmdDialog *newCmdDlg; + + TreePanel(QWidget *parent = 0); + ~TreePanel(); + +public slots: + void refresh(); ///< refresh tree according new script + void setPosition(int); ///< select item for given line number + void hidePlot(int); ///< hide plot for given item + void annotatePlot(int); ///< add annotation for given item + void newCmd(); ///< add new command + refresh tree + +private: + void toolTop(QBoxLayout *l); +}; +//----------------------------------------------------------------------------- +#endif // TREE_PNL_H +//----------------------------------------------------------------------------- diff --git a/udav/udav.desktop b/udav/udav.desktop new file mode 100755 index 0000000..582d950 --- /dev/null +++ b/udav/udav.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Icon=udav +Name=UDAV +Exec=udav +Comment=Data handling and plotting tool +Comment[en_US]=Data handling and plotting tool +Comment[ru_RU]=Обработка и отображение данных +Categories=Education;Science;Math; diff --git a/udav/udav.ico b/udav/udav.ico new file mode 100644 index 0000000..27423de Binary files /dev/null and b/udav/udav.ico differ diff --git a/udav/udav.png b/udav/udav.png new file mode 100644 index 0000000..76ba7d9 Binary files /dev/null and b/udav/udav.png differ diff --git a/udav/udav.qrc b/udav/udav.qrc new file mode 100644 index 0000000..6771737 --- /dev/null +++ b/udav/udav.qrc @@ -0,0 +1,48 @@ + + + udav.png + xpm/document-new.png + xpm/document-open.png + xpm/document-print.png + xpm/document-save.png + xpm/document-properties.png + xpm/document-export.png + xpm/document-import.png + xpm/alpha.png + xpm/preferences-system.png + xpm/edit-cut.png + xpm/edit-copy.png + xpm/edit-delete.png + xpm/edit-paste.png + xpm/edit-select-all.png + xpm/edit-find.png + xpm/edit-redo.png + xpm/edit-undo.png + xpm/process-stop.png + xpm/zoom-out.png + xpm/zoom-in.png + xpm/zoom-original.png + xpm/zoom-fit-best.png + xpm/view-refresh.png + xpm/weather-clear.png + xpm/help-contents.png + xpm/help-faq.png + xpm/go-first.png + xpm/go-last.png + xpm/go-previous.png + xpm/go-next.png + xpm/go-down.png + xpm/go-up.png + xpm/media-seek-backward.png + xpm/media-seek-forward.png + xpm/film-b.png + xpm/object-rotate-right.png + xpm/accessories-calculator.png + xpm/format-indent-more.png + xpm/x-office-spreadsheet.png + xpm/folder.png + xpm/text-x-generic.png + xpm/x-office-presentation.png + xpm/system-file-manager.png + + diff --git a/udav/udav.rc b/udav/udav.rc new file mode 100644 index 0000000..d12f614 --- /dev/null +++ b/udav/udav.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "udav.ico" diff --git a/udav/udav_ru.qm b/udav/udav_ru.qm new file mode 100644 index 0000000..7319dfd Binary files /dev/null and b/udav/udav_ru.qm differ diff --git a/udav/udav_ru.ts b/udav/udav_ru.ts new file mode 100644 index 0000000..529a9fc --- /dev/null +++ b/udav/udav_ru.ts @@ -0,0 +1,4425 @@ + + + + + AnimParam + + UDAV - Animation setup + UDAV - Параметры анимации + + + Redraw picture for $0 equal to + Перерисовать для $0 равного + + + strings + strings in lines + строкам + + + values + числам + + + from + от + + + to + до + + + with step + с шагом + + + Cancel + Отмена + + + OK + OK + + + Put to script + Вставить в код + + + Delay (in ms) + Задержка (в мсек) + + + Export to GIF + Экспорт в GIF + + + Save JPEG frames + Сохранить кадры в JPEG + + + UDAV - animation + UDAV - анимация + + + You should select one of case + Вы должны выбрать строки или числа + + + + ArgsDialog + + UDAV - Set script arguments + UDAV - Аргументы программы + + + String for $1 + Строка для $1 + + + String for $2 + Строка для $2 + + + String for $3 + Строка для $3 + + + String for $4 + Строка для $4 + + + String for $5 + Строка для $5 + + + String for $6 + Строка для $6 + + + String for $7 + Строка для $7 + + + String for $8 + Строка для $8 + + + String for $9 + Строка для $9 + + + String for $0 + Строка для $0 + + + Cancel + Отмена + + + OK + OK + + + + CalcDialog + + Result + Результат + + + To script + В код + + + Clear + Очистить + + + Put function + Вставить функцию + + + Basic + Базовые + + + Exp and log + Exp и log + + + Trigonometric + Тригонометрические + + + Hyperbolic + Гиперболические + + + Bessel + Бесселя + + + Elliptic + Эллиптические + + + Jacobi + Якоби + + + Airy and Gamma + Airy и Gamma + + + Exp-integrals + Exp-интегралы + + + Special + Специальные + + + + DatPanel + + &Data + &Данные + + + - UDAV variable + - UDAV переменная + + + - UDAV preview + - UDAV просмотр + + + UDAV - Import PNG + UDAV - Импорт PNG + + + Data files (*.dat) +All files (*.*) + Файлы данных (*.dat) +Все файлы (*.*) + + + UDAV - Export to PNG + UDAV - Экспорт в PNG + + + Enter color scheme for picture. +Note that data will be normalized in range [0,1]. + Введите цветовую схему рисунка. +Данные будут нормированы в [0,1]. + + + PNG files (*.png) +All files (*.*) + PNG файлы (*.png) +Все файлы (*.*) + + + Enter color scheme for picture + Введите цветовую схему рисунка + + + UDAV - Save data + UDAV - Сохранить данные + + + UDAV - Load data + UDAV - Загрузить данные + + + UDAV - Fill data + UDAV - Заполнить данные + + + Enter formula for data filling. +Note that variables x,y,z supposed to be in range [0,1]. + Введите формулу для данных. +Переменные x,y,z меняются в интервале [0,1]. + + + Enter range for data and direction of filling + Введите диапазон и направление заполнения + + + From + От + + + To + До + + + Direction + Направление + + + UDAV - Normalize data + UDAV - Нормировать данные + + + Enter range for final data + Введите диапазон результата + + + Symmetrical? + Симметрично? + + + UDAV - Normalize by slice + UDAV - Нормировать по срезам + + + UDAV - Clear data + UDAV - Очистить данные + + + Enter new data sizes + Введите новые размеры + + + X-size + Размер по X + + + Y-size + Размер по Y + + + Z-size + Размер по Z + + + UDAV - Resize data + UDAV - Изменить размер данных + + + UDAV - Squeeze data + UDAV - Сжать данные + + + Enter step of saved points. For example, '1' save all, '2' save each 2nd point, '3' save each 3d and so on. + Введите шаг сохраняемых точек. Например, '1' сохранить все, '2' каждую вторую точку, '3' каждую третью и т.д. + + + X-direction + X направление + + + Y-direction + Y направление + + + Z-direction + Z направление + + + UDAV - Crop data + UDAV - Обрезать данные + + + Enter range of saved date. + Введите интервал сохраняемых данных. + + + UDAV - Rearrange data + UDAV - Поменять размеры данных + + + UDAV - Transpose data + UDAV - Транспонировать данные + + + Enter new order of dimensions. +For example, 'yx' or 'yxz' for transpose x-y, 'zyx' for transposing x-z and so on. + Введите новый порядок размерностей. +Например, 'yx' или 'yxz' для транспонирования x-y, 'zyx' для транспонирования x-z и т.д. + + + UDAV - Smooth data + UDAV - Сгладить данные + + + Enter direction(s) for smoothing. +Optionally you may enter the kind of smoothing by 3 or by 5 points. For example 'xy3' - smooth only in x and y directions and use 3-points scheme. + Введите направление(я) сглаживания. +Можно также ввести тип сглаживания по 3 или по 5 точкам. Например 'xy3' - сгладит только в x и y направлениях по 3-точечной схеме. + + + UDAV - Summarize data + UDAV - Суммировать данные + + + Enter direction(s) for cumulative summation. +For example 'xy' - summate along x and y directions. + Введите направление(я) для суммирования. +Например 'xy' - суммировать вдоль x и y направлений. + + + UDAV - Integrate data + UDAV - Интегрировать данные + + + Enter direction(s) for integration. +For example 'xy' - integrate along x and y directions. + Введите направление(я) для инткгрирования. +Например 'xy' - интегрировать вдоль x и y направлений. + + + UDAV - Differentiate data + UDAV - Дифференцировать данные + + + Enter direction(s) for differentiation. +For example 'xy' - differentiate along x and y directions. + Введите направление(я) для дифференцирования. +Например 'xy' - дифференцировать вдоль x и y направлений. + + + UDAV - Laplace transform + UDAV - Преобразование Лапласа + + + Enter direction(s) for laplace transform. +For example 'xy' - do transform along x and y directions. + Введите направление(я) для преобразования Лапласа. +Например 'xy' - преобразовать вдоль x и y направлений. + + + UDAV - Swap data + UDAV - Поменять местами + + + Enter direction(s) for swapping (exchange left and right parts). +For example 'xy' - swap along x and y directions. Useful for Fourier spectrum. + Введите направление(я) для обмена левой и правой частями данных. +Например 'xy' - меняет вдоль x и y направлений. Полезно для Фурье спектров. + + + UDAV - Mirror data + UDAV - Отразить данные + + + Enter direction(s) for mirroring. +For example 'xy' - mirror along x and y directions. + Введите направление(я) для отражения. +Например 'xy' - отразить по x и y направлениям. + + + UDAV - Sum along ... + UDAV - Сумма по ... + + + Specify direction(s) of summation + Введите направление(я) суммирования + + + UDAV - Max along ... + UDAV - Максимум по ... + + + Specify direction(s) of maximal values + Введите направление(я) поиска максимумов + + + UDAV - Min along ... + UDAV - Минимум по ... + + + Specify direction(s) of minimal values + Введите направление(я) поиска минимумов + + + UDAV - Momentum along 'x' + UDAV - Момент по 'x' + + + Specify which momentum evaluate. +The momentum is res_i = sum_jk how(x_i,y_j,z_k) a_jk/ sum_jk a_jk. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_i = Σ_jk how(x_i,y_j,z_k) a_jk/ Σ_jk a_jk. +Координаты x, y, z находятся в диапазоне [0,1]. + + + UDAV - Momentum along 'y' + UDAV - Момент по 'y' + + + Specify which momentum evaluate. +The momentum is res_j = sum_ik how(x_i,y_j,z_k) a_ik/ sum_ik a_ik. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_j = Σ_ik how(x_i,y_j,z_k) a_ik/ Σ_ik a_ik. +Координаты x, y, z находятся в диапазоне [0,1]. + + + UDAV - Momentum along 'z' + UDAV - Момент по 'z' + + + Specify which momentum evaluate. +The momentum is res_k = sum_ij how(x_i,y_j,z_k) a_ij/ sum_ij a_ij. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_k = Σ_ij how(x_i,y_j,z_k) a_ij/ Σ_ij a_ij. +Координаты x, y, z находятся в диапазоне [0,1]. + + + UDAV - Make histogram + UDAV - Найти гистограмму + + + Number of points + Число точек + + + Put in variable + Поместить в переменную + + + Cancel + Отмена + + + OK + OK + + + UDAV - Change data + UDAV - Изменить данные + + + Enter number for adding to data elements: + Введите число для добавления к элементам массива: + + + Enter number for subtraction from data elements: + Введите число для вычитания из элементов массива: + + + Enter number for division of data elements: + Введите число для деления элементов массива: + + + Enter number for multiplication of data elements: + Введите число для умножения элементов массива: + + + UDAV - Go to slice + UDAV - Перейти к срезу + + + Enter slice id: + Введите номер среза: + + + NOTE: All fields must be filled! + Все поля должны быть заполнены! + + + Enter the name for new variable + Введите имя новой переменной + + + &File + &Файл + + + &Load data + &Загрузить данные + + + Load data from file. Data will be deleted only +at exit but UDAV will not ask to save it. + Загрузить данные из файла. Данные будут удалены при +выходе, но UDAV не спросит об их сохранении. + + + &Import PNG + &Импорт PNG + + + Import data from PNG picture with specified color scheme. +Data will be deleted only at exit but UDAV will not ask it saving. + Импортировать данные из PNG рисунка с заданной цветовой схемой. +Данные будут удалены при выходе, но UDAV не спросит об их сохранении. + + + &Save data + Сохранить &данные + + + Save data to tab-separeted file. + Сохранить данные в текстовый файл с разделителем табуляцией. + + + &Export PNG + &Экспорт PNG + + + Export data to PNG picture. The colors defined by +specified color scheme. The same as in 'dens' command. + Экспортирует данные в PNG рисунок. Цвета определяются +указанной цветовой схемой. Рисунок аналогичен команде 'dens'. + + + Plot &data + &Отобразить данные + + + Plot data in new script window. You may select the kind +of plot, its style and so on. + Отобразить данные в новом окне. Вы можете +выбрать тип графика, его стиль и т.д. + + + Copy &data + Копировать &данные + + + Copy range of numbers to clipboard. + Копировать диапазон чисел в буфер обмена. + + + Paste &data + Вставить &данные + + + Paste range of numbers from clipboard. + Вставить диапазон чисел из буфера обмена. + + + &Navigate + Пере&ход + + + &First slice + &Первый срез + + + Go to the first data slice for 3D data. + Перейти к первому срезу 3D данных. + + + &Prev. slice + &Предыдущий срез + + + Go to the previous data slice for 3D data. + Перейти к предыдущему срезу 3D данных. + + + Go to the specified data slice for 3D data. + Перейти к указанному срезу 3D данных. + + + Go to slice + Перейти к срезу + + + Next slice + Следующий срез + + + Go to the next data slice for 3D data. + Перейти к следующему срезу 3D данных. + + + Last slice + Последний срез + + + Go to the last data slice for 3D data. + Перейти к последнему срезу 3D данных. + + + &Sizes + &Размеры + + + &Create new + &Создать новые + + + Recreate the data with new sizes and fill it by zeros (Ctrl+N). + Создает заново данные нового размера и заполняет их нулями (Ctrl+N). + + + &Resize + &Изменить размер + + + Resize (interpolate) the data to specified sizes (Ctrl+R). + Изменяет размер (интерполирует) данных в указанному (Ctrl+R). + + + &Squeeze + С&жать + + + Keep only each n-th element of the data array. + Сохраняет каждый n-ый элемент массива данных. + + + Cro&p + О&брезать + + + Crop the data edges. Useful to cut off the zero-filled area. + Обрезает края данных. Полезно для удаления заполненных нулями областей. + + + &Transpose + &Транспонировать + + + Transpose data dimensions, like x<->y or x<->z and so on. + Транспонирует массив данных, типа x<->y или x<->z и т.д. + + + Re&arrange + По&менять размеры + + + Rearrange data sizes without changing data values. + Меняет размеры данных без изменения самого массива данных. + + + &Modify + &Изменить + + + By &formula + По &формуле + + + Change data values according to formula depended on 'x', 'y' and 'z' +variables. A set of special function is availible also. + Изменяет данные по формуле, зависяещей от переменных 'x', 'y' и 'z'. +Поддерживаются также многие специальные функции. + + + Fill in &range + &Распределить + + + Fill data equidistantly from one value to another. + Распределить равномерно данные от одного значения до другого. + + + &Normalize + &Нормировать + + + Normalize data so that its minimal +and maximal values be in specified range. + Нормирует данные так, что их максимальное и +минимальное значения равны заданным. + + + Norm. s&lices + Норм. по &срезам + + + Normalize each data slice perpendicular to some direction +so that its minimal and maximal values be in specified range. + Нормирует данные по срезам перпендикулярно +заданному направлению так, что их максимальное +и минимальное значения равны заданным. + + + &Smooth data + С&гладить + + + Smooth data by one of 4 methods along specified direction(s). + Сглаживает данные одним из 4-х методов вдоль заданного направления(ий). + + + &Operators + &Опраторы + + + &Cum. sum + &Суммировать + + + Summate data values along specified direction(s). + Суммирует данные вдоль указанного направления(ий). + + + &Integrate + &Интегрировать + + + Integrate data values along specified direction(s). + Интегрирует данные по заданному направлению(ям). + + + &Differentiate + &Дифференцировать + + + Differentiate data values along specified direction(s). + Дифференцирует данные по заданному направлению(ям). + + + &Laplace + &Лаплас + + + Double differentiate data values along specified direction(s). + Дважды дифференцирует данные по заданному направлению(ям). + + + &Swap + &Поменять местами + + + Swap left and right data part along specified direction(s). +This operation is useful for data after Fourier transform. + Меняет местами левую и правую часть данных вдоль указанного направления(ий). +Операция полезна для данных после Фурье преобразования. + + + &Mirror + &Отразить + + + Mirror left and right data part along specified direction(s). +This operation do like index change from 'i' to 'n-i'. + Отражает данные относительно указанного направления(ий). +Действует как замена индекса 'i' на 'n-i'. + + + &Algebraic + &Алгебраические + + + &Add + &Добавить + + + Add a number to all data values. + Добавляет число к элементам массива данных. + + + &Subtract + &Вычесть + + + Subtract a number to all data values. + Вычитает из элементов массива данных число. + + + &Multiply + &Умножить + + + Multiply all data values by a number. + Умножает элементы массива данных на число. + + + &Divide + &Разделить + + + Divide all data values by a number. + Делит элементы массива данных на число. + + + A&nother data + &Новые данные + + + &Sum of + &Сумма по + + + M&in of + М&инимум по + + + M&ax of + М&аксимум по + + + Momentum along &x + Момент вдоль &x + + + Momentum along &y + Момент вдоль &y + + + Momentum along &z + Момент вдоль &z + + + &Histogram + &Гистограмма + + + + DataOpenDialog + + UDAV - Open data file + UDAV - Открыть файл данных + + + Data name + Имя данных + + + Auto detect data sizes + Автом. определение размеров + + + Set data sizes manually + Задать размеры вручную + + + Nx + Nx + + + Ny + Ny + + + Nz + Nz + + + Matrix with sizes from file + Матрица с размерами из файла + + + 3D data with sizes from file + 3D данные с размерами из файла + + + Cancel + Отмена + + + OK + OK + + + Auto detect data sizes (%1 x %2 x %3) + Определить размер автоматически (%1 x %2 x %3) + + + default + по умолчанию + + + UDAV - Insert filename + UDAV - Вставить имя файла + + + MGL files (*.mgl) + Файлы MGL (*.mgl) + + + Template + Шаблон + + + + FilesDialog + + UDAV - Set script arguments + UDAV - Аргументы программы + + + String for %1 + Строка для %1 + + + String for %2 + Строка для %2 + + + String for %3 + Строка для %3 + + + String for %4 + Строка для %4 + + + String for %5 + Строка для %5 + + + String for %6 + Строка для %6 + + + String for %7 + Строка для %7 + + + String for %8 + Строка для %8 + + + String for %9 + Строка для %9 + + + Cancel + Отмена + + + OK + OK + + + UDAV - Set template parameters + UDAV - Параметры шаблона + + + + FindDialog + + UDAV - Find + UDAV - Найти + + + Find &what: + &Что найти: + + + Replace &by: + З&аменить на: + + + Match &case + Учитывать &регистр + + + Search &backward + Искать на&зад + + + &Find + &Найти + + + &Replace + &Заменить + + + Close + Закрыть + + + + GraphWindow + + Printing... + Печатаю... + + + Printing completed + Печать завершена + + + Printing aborted + Печать прервана + + + Drawing time %1 ms + Время рисования %1 мсек + + + Frame %1 of %2 + Кадр %1 из %2 + + + Graphics + График + + + &Graphics + &График + + + &Alpha + &Прозрачность + + + Switch on/off transparency for the graphics (Alt+T). + Включить/выключить прозрачность графика (Alt+T). + + + &Light + &Освещение + + + Switch on/off lightning for the graphics (Alt+L). + Включить/выключить освещение графика (Alt+L). + + + &Grid + &Сетка + + + Switch on/off grid drawing for absolute coordinates (Alt+G). + Включить/выключить сетку абсолютных координат (Alt+G). + + + &Rotate by mouse + &Вращать мышкой + + + Switch on/off mouse handling of the graphics +(rotation, shifting, zooming and perspective). + Включить/выключить изменение графика мышью +(вращение, сдвиг, приближение и перспектива). + + + &Zoom by mouse + &Приближение мышью + + + Switch on/off mouse zoom of selected region. + Включить/выключить приближение выбранного региона. + + + Res&tore + В&осстановить + + + Restore default graphics rotation, zoom and perspective (Alt+Space). + Восстановить вращение, масштаб и перспективу по умолчанию (Alt+Space). + + + Re&draw + Пе&рерисовать + + + Execute script and redraw graphics (F5). + Выполнить код и перерисовать график (F5). + + + &Adjust size + &Подобрать размер + + + Change canvas size to fill whole region (F6). + Изменить размер рисунка так, чтобы он заполнял всю область (F6). + + + Re&load + Пере&грузить + + + Restore status for 'once' command and reload data (F9). + Восстановить статус команды 'once' и перегрузить данные (F9). + + + &Stop + &Остановить + + + Stop script execution (F7). + Остановить выполенение кода (F7). + + + &Copy plot + &Копировать график + + + Copy graphics to clipboard (Ctrl+Shift+C). + Копировать график в буфер обмена (Ctrl+Shift+C). + + + Set value of \theta angle. + Установить значение угла \theta. + + + Set value of \phi angle. + Установить значение угла \phi. + + + &Export as ... + &Экспорт в ... + + + bitmap EPS + растровый EPS + + + vector EPS + векторный EPS + + + Zoom/move + Масштаб/сдвиг + + + Zoom graphics + Приближение графика + + + Move &left + Сдвиг в&лево + + + Move graphics left by 1/3 of its width. + Сдвиг графика влево на 1/3 его ширины. + + + Move &up + Сдвиг &вверх + + + Move graphics up by 1/3 of its height. + Сдвиг графика вверх на 1/3 его высоты. + + + Zoom &in + &Приблизить + + + Zoom in graphics. + Приблизить график. + + + Zoom &out + &Отдалить + + + Zoom out graphics. + Отдалить график. + + + Move &down + Сдвиг в&низ + + + Move graphics up down 1/3 of its height. + Сдвиг графика вниз на 1/3 его высоты. + + + Move &right + Сдвиг вп&раво + + + Move graphics right by 1/3 of its width. + Сдвиг графика вправо на 1/3 его ширины. + + + &Animation + &Анимация + + + Animation + Анимация + + + &Next slide + &Следующий кадр + + + Show next slide (Alt+Right). + Показать следующий кадр (Alt+Right). + + + &Prev slide + &Предыдущий кадр + + + Show previous slide (Alt+Left). + Показать предыдущий кадр (Alt+Left). + + + &Slideshow + &Запустить + + + Run slideshow (Ctrl+F5). If no parameter specified +then the dialog with slideshow options will appear. + Запустить анимацию (Ctrl+F5). Если параметры не были указаны, +то показывается диалог с параметрами анимации. + + + Se&tup show + &Настроить анимацию + + + Switch on/off transparency for the graphics (Ctrl+T). + Включить/выключить прозрачность графика (Ctrl+T). + + + Switch on/off lightning for the graphics (Ctrl+L). + Включить/выключить освещение графика (Ctrl+L). + + + Switch on/off grid drawing for absolute coordinates (Ctrl+G). + Включить/выключить рисование сетки абсолютных координат (Ctrl+G). + + + Restore default graphics rotation, zoom and perspective (Ctrl+Space). + Восстановить вращение, масштаб и перспективу по умолчанию (Ctrl+Space). + + + &Copy click coor. + &Копировать коор. + + + Copy coordinates of last mouse click to clipboard. + Копировать в буфер обмена координаты последнего щелчка мыши. + + + Show next slide (Meta+Right). + Показать следующий кадр (Meta+Right). + + + Show previous slide (Meta+Left). + Показать предыдущий кадр (Meta+Left). + + + Set value of \theta angle. +You can use keys (Shift+Meta+Up or Shift+Meta+Down). + Изменить значение угла \theta. +Можно использовать клавиши (Shift+Meta+Up или Shift+Meta+Down). + + + Set value of \phi angle. +You can use keys (Shift+Meta+Left or Shift+Meta+Right). + Изменить значение угла \phi. +Можно использовать клавиши (Shift+Meta+Left или Shift+Meta+Right). + + + Rotate + Вращать + + + Rotate up + Вращать вверх + + + Increase \theta angle by 10 degrees. + Увеличить угол \theta на 10 градусов. + + + Rotate down + Вращать вниз + + + Decrease \theta angle by 10 degrees. + Уменьшить угол \theta на 10 градусов. + + + Rotate left + Вращать влево + + + Increase \phi angle by 10 degrees. + Увеличить угол \phi на 10 градусов. + + + Rotate right + Вращать вправо + + + Decrease \phi angle by 10 degrees. + Уменьшить угол \phi на 10 градусов. + + + + HelpPanel + + Backward + Назад + + + Forward + Вперед + + + &Examples + &Примеры + + + Help + Помощь + + + mgl_en + mgl_ru + + + + HelpWindow + + Backward + Назад + + + Forward + Вперед + + + &Examples + &Примеры + + + Help + Помощь + + + mgl_en + mgl_ru + + + + HintDialog + + UDAV - Hint + UDAV - Советы + + + &Show at startup + Показывать при з&апуске + + + &Prev + &Предыдущий + + + &Next + &Следующий + + + &Close + &Закрыть + + + + InfoDialog + + Select kind of plot + Выберите тип графика + + + Data preview for current slice. + Просмотр для текущего среза. + + + 1D plot + 1D график + + + 2D plot + 2D график + + + Kind of plots: lines for 1D, density for 2D. + Тип графика: линии для 1D, график плотности для 2D. + + + Preview + Просмотр + + + Short information about the data. + Краткая информация о данных. + + + Information + Информация + + + + MGLThread + + In line + В линии + + + -- wrong argument(s): + -- неправильный аргумент(ы): + + + -- wrong command: + -- неправильная команда: + + + -- string too long: + -- строка слишком длинная: + + + -- unbalanced ' : + -- не хватает ' : + + + + MainWindow + + untitled - UDAV + без имени - UDAV + + + Messages and warnings + Сообщения и предупреждения + + + Calculator + Калькулятор + + + &Open file + &Открыть файл + + + Open and execute/show script or data from file (Ctrl+O). +You may switch off automatic exection in UDAV properties. + Открыть и выполнить/показать код или данные из файла (Ctrl+O). +Вы можете выключить автоматическое выполнение в настройках UDAV. + + + &Save script + &Сохранить код + + + Save script to a file (Ctrl+S) + Сохранить код в файл (Ctrl+S) + + + Show calculator which evaluate and help to type textual formulas. +Textual formulas may contain data variables too. + Показывает калькулятор, который вычисляет и помогает набрать текстовые формулы. +Текстовые формулы могут содержать также и определенные в коде данные. + + + Show info + Окно сообщений + + + Canvas + График + + + Help + Помощь + + + Info + Информация + + + Script + Код + + + Ready + Готово + + + &File + &Файл + + + &New script + &Новый код + + + Create new empty script window (Ctrl+N). + Создать новое пустое окно для кода (Ctrl+N). + + + Save &As ... + Сохранить &как ... + + + &Print script + Печатать &код + + + Print &graphics + &Печатать график + + + Open printer dialog and print graphics (Ctrl+P) + Открыть диалог принтера и напечатать график (Ctrl+P) + + + Recent files + Последние файлы + + + &Quit + В&ыход + + + &Settings + &Настройки + + + Properties + Настройки UDAV + + + Show dialog for UDAV properties. + Показать диалог настроек программы UDAV. + + + Set ar&guments + &Аргументы кода + + + &Help + &Справка + + + MGL &help + MGL &справка + + + Show help on MGL commands (F1). + Показывает справку по текущей команде MGL (F1). + + + &Examples + &Примеры + + + Show examples of MGL usage (Shift+F1). + Показывает примеры использования MGL (Shift+F1). + + + H&ints + С&оветы + + + Show hints of MGL usage. + Показывает советы по использованию MGL. + + + &About + О &программе + + + About &Qt + О библиотеке &Qt + + + UDAV + + + + Do you want to save the changes to the document? + Вы хотите сохранить изменения в коде? + + + Not recognized + Не распознано + + + UDAV v. 0. + + + + +(c) Alexey Balakin, 2008 +http://udav.sf.net/ + +(c) Алексей Балакин, 2008 +http://udav.sf.net/ + + + UDAV - about + UDAV - о программе + + + About Qt + О библиотеке Qt + + + - UDAV + + + + UDAV - save current + UDAV - сохранить текущий код + + + Couldn't change to folder + Не могу перейти в папку + + + UDAV - Open file + UDAV - Открыть файл + + + MGL scripts (*.mgl) +HDF5 files (*.hdf *.h5) +Text files (*.txt) +Data files (*.dat) +All files (*.*) + MGL код (*.mgl) +HDF5 файлы (*.hdf *.h5) +Текст (*.txt) +Файлы данных (*.dat) +Все файлы (*.*) + + + Loading aborted + Загрузка прервана + + + UDAV - save file + UDAV - сохранить файл + + + MGL scripts (*.mgl) +HDF5 files (*.hdf *.h5) +All files (*.*) + MGL код (*.mgl) +HDF5 файлы (*.hdf *.h5) +Все файлы (*.*) + + + Saving aborted + Сохранение прервано + + + untitled* - UDAV + без имени* - UDAV + + + * - UDAV + + + + + MemPanel + + Create new data array + Создать новый массив данных + + + Edit selected data array + Редактировать выбранный массив данных + + + Delete selected data array + Удалить выбранный массив данных + + + Properties of selected data array + Свойства выбранного массива данных + + + Update list of data arrays + Обновить список массивов данных + + + Delete ALL data arrays + Удалить ВСЕ массивы данных + + + Name + Имя + + + Sizes + Размеры + + + Memory + Память + + + UDAV - New variable + UDAV - Новая переменная + + + Enter name for new variable + Введите имя для новой переменной + + + UDAV - delete all data + UDAV - Удалить все данные + + + Do you want to delete all data? + Вы хотите удалить все данные? + + + - UDAV preview + - UDAV просмотр + + + + MemoryWindow + + New + Новый + + + Edit + Правка + + + Delete + Удалить + + + Info + Информация + + + Update + Обновить + + + Delete All + Удалить все + + + Name + Имя + + + Sizes + Размеры + + + Memory + Память + + + UDAV - New variable + UDAV - Новая переменная + + + Enter name for new variable + Введите имя для новой переменной + + + UDAV - delete all data + UDAV - Удалить все данные + + + Do you want to delete all data? + Вы хотите удалить все данные? + + + - UDAV preview + - UDAV просмотр + + + + NewCmdDialog + + Argument + Аргумент + + + Value + Значение + + + Add style + Добавить стиль + + + Add data + Добавить данные + + + Options + Опции + + + Cancel + Отмена + + + OK + OK + + + 1D plots + 1D графики + + + 2D plots + 2D графики + + + 3D plots + 3D графики + + + Dual plots + Парные графики + + + Vector plots + Векторные графики + + + Other plots + Прочие графики + + + Text and legend + Текст и легенда + + + Create data and I/O + Создание данных и I/O + + + Data handling + Обработка данных + + + Data extraction + Выделение данных + + + Axis and colorbar + Оси координат + + + General setup + Настройка графика + + + Axis setup + Настройка осей + + + Scale and rotate + Положение и поворот + + + Program flow + Условия и циклы + + + Nonlinear fitting + Подбор функции + + + Primitives + Примитивы + + + New command + Новая команда + + + Select first the proper kind of arguments + Сначала выберите тип аргументов + + + There is no 'fmt' argument for this command + Нет аргумента 'fmt' для данной команды + + + You should specify required argument + Вы должны ввести все обязательные аргументы + + + You should put text inside ' ' for argument + Вы должны вводить текст внутри ' ' + + + You should specify all optional arguments before + Вы должны ввести все опциональные аргументы перед + + + Groups of MGL commands + Группы команд MGL + + + MGL commands for selected group + Команды MGL для выбранной группы + + + Short description of selected command + Краткое описание выбранной команды + + + Kind of command argument order. The notation is: + * Capital arguments are data (like, Ydat); + * Argument in '' are strings (like, 'fmt'); + * Other arguments are numbers (like, zval); + * Arguments in [] are optional arguments. + Тип аргументов команды. Используются обозначения: + * Заглавными обозначены данные (например, Ydat); + * Аргументы в '' означают строки (например, 'fmt'); + * Прочие аргументы -- числа (например, zval); + * Аргументы в [] опциональны (могут не указываться). + + + Command arguments. Bold ones are required arguments. +Other are optional arguments but its order is required. +You can use '' for default format. See help at right +for default values. + Аргументы команды. Жирным обозначены обязательные аргументы. +Все прочие аргументы опциональны, но их порядок должен соблюдаться. +Можно использовать '' для формата по умолчанию. Справка справа дает +подробное описание команды и значения аргументов по умолчанию. + + + Here you can select the plot style. +The result will be placed in 'fmt' argument. + Здесь можно выбрать стиль графика. +Результат будет помещен в аргумент 'fmt'. + + + Here you can specify command options. +Options are used for additional plot tunning. + Здесь можно выбрать опции команд. +Опции используются для дополнительной +настройки вида графика. + + + mgl_en + mgl_ru + + + + OptionDialog + + UDAV - Add options + UDAV - Добавить опцию + + + X-range + Диапазон по X + + + Y-range + Диапазон по Y + + + Z-range + Диапазон по Z + + + C-range + Диапазон по C + + + Alpha + Прозрачность + + + Ambient + Фоновое освещение + + + Mesh num + Число линий сетки + + + Font size + Размер шрифта + + + Cutting + Обрезание + + + Legend + Легенда + + + Cancel + Отмена + + + OK + OK + + + UDAV - command options + UDAV - опции команд + + + Both fields in xrange must be filled + Оба поля в xrange должны быть заполнены + + + Both fields in yrange must be filled + Оба поля в yrange должны быть заполнены + + + Both fields in zrange must be filled + Оба поля в zrange должны быть заполнены + + + Both fields in crange must be filled + Оба поля в crange должны быть заполнены + + + on + вкл + + + off + выкл + + + + PlotPanel + + &Graphics + &График + + + Printing... + Печатаю... + + + Printing completed + Печать завершена + + + Printing aborted + Печать прервана + + + Drawing time %1 ms + Время рисования %1 мсек + + + Frame %1 of %2 + Кадр %1 из %2 + + + &Alpha + &Прозрачность + + + Switch on/off transparency for the graphics (Ctrl+T). + Включить/выключить прозрачность графика (Ctrl+T). + + + &Light + &Освещение + + + Switch on/off lightning for the graphics (Ctrl+L). + Включить/выключить освещение графика (Ctrl+L). + + + &Grid + &Сетка + + + Switch on/off grid drawing for absolute coordinates (Ctrl+G). + Включить/выключить рисование сетки абсолютных координат (Ctrl+G). + + + &Rotate by mouse + &Вращать мышкой + + + Switch on/off mouse handling of the graphics +(rotation, shifting, zooming and perspective). + Включить/выключить изменение графика мышью +(вращение, сдвиг, приближение и перспектива). + + + &Zoom by mouse + &Приближение мышью + + + Switch on/off mouse zoom of selected region. + Включить/выключить приближение выбранного региона. + + + Res&tore + В&осстановить + + + Restore default graphics rotation, zoom and perspective (Ctrl+Space). + Восстановить вращение, масштаб и перспективу по умолчанию (Ctrl+Space). + + + Re&draw + Пе&рерисовать + + + Execute script and redraw graphics (F5). + Выполнить код и перерисовать график (F5). + + + &Adjust size + &Подобрать размер + + + Change canvas size to fill whole region (F6). + Изменить размер рисунка так, чтобы он заполнял всю область (F6). + + + Re&load + Пере&грузить + + + Restore status for 'once' command and reload data (F9). + Восстановить статус команды 'once' и перегрузить данные (F9). + + + &Stop + &Остановить + + + Stop script execution (F7). + Остановить выполенение кода (F7). + + + &Copy plot + &Копировать график + + + Copy graphics to clipboard (Ctrl+Shift+C). + Копировать график в буфер обмена (Ctrl+Shift+C). + + + &Copy click coor. + &Копировать коор. + + + Copy coordinates of last mouse click to clipboard. + Копировать в буфер обмена координаты последнего щелчка мыши. + + + Set value of \theta angle. +You can use keys (Shift+Meta+Up or Shift+Meta+Down). + Изменить значение угла \theta. +Можно использовать клавиши (Shift+Meta+Up или Shift+Meta+Down). + + + Set value of \phi angle. +You can use keys (Shift+Meta+Left or Shift+Meta+Right). + Изменить значение угла \phi. +Можно использовать клавиши (Shift+Meta+Left или Shift+Meta+Right). + + + &Export as ... + &Экспорт в ... + + + PNG + + + + solid PNG + + + + JPEG + + + + GIF + + + + bitmap EPS + растровый EPS + + + vector EPS + векторный EPS + + + SVG + + + + C++ + + + + IDTF + + + + Zoom/move + Масштаб/сдвиг + + + Move &left + Сдвиг в&лево + + + Move graphics left by 1/3 of its width. + Сдвиг графика влево на 1/3 его ширины. + + + Move &up + Сдвиг &вверх + + + Move graphics up by 1/3 of its height. + Сдвиг графика вверх на 1/3 его высоты. + + + Zoom &in + &Приблизить + + + Zoom in graphics. + Приблизить график. + + + Zoom &out + &Отдалить + + + Zoom out graphics. + Отдалить график. + + + Move &down + Сдвиг в&низ + + + Move graphics up down 1/3 of its height. + Сдвиг графика вниз на 1/3 его высоты. + + + Move &right + Сдвиг вп&раво + + + Move graphics right by 1/3 of its width. + Сдвиг графика вправо на 1/3 его ширины. + + + Rotate + Вращать + + + Rotate up + Вращать вверх + + + Increase \theta angle by 10 degrees. + Увеличить угол \theta на 10 градусов. + + + Rotate down + Вращать вниз + + + Decrease \theta angle by 10 degrees. + Уменьшить угол \theta на 10 градусов. + + + Rotate left + Вращать влево + + + Increase \phi angle by 10 degrees. + Увеличить угол \phi на 10 градусов. + + + Rotate right + Вращать вправо + + + Decrease \phi angle by 10 degrees. + Уменьшить угол \phi на 10 градусов. + + + &Animation + &Анимация + + + &Next slide + &Следующий кадр + + + Show next slide (Meta+Right). + Показать следующий кадр (Meta+Right). + + + &Prev slide + &Предыдущий кадр + + + Show previous slide (Meta+Left). + Показать предыдущий кадр (Meta+Left). + + + &Slideshow + &Запустить + + + Run slideshow (Ctrl+F5). If no parameter specified +then the dialog with slideshow options will appear. + Запустить анимацию (Ctrl+F5). Если параметры не были указаны, +то показывается диалог с параметрами анимации. + + + Se&tup show + &Настроить анимацию + + + + PropDialog + + UDAV - Properties + UDAV - Настройки + + + Select font + Выбрать шрифт + + + Current font + Текущий шрифт + + + Change font + Изменить шрифт + + + Setup colors for: + Настроить цвета для: + + + Comments + Коментарии + + + Strings + Строки + + + Keywords + Команды + + + Options + Опции + + + Suffixes + Суффиксы + + + Numbers + Числа + + + AutoKey + Созд.данных + + + FlowKey + Упр.команды + + + Path for help files + Путь к файлам справки + + + Path for user MathGL font files + Путь к шрифтам MathGL + + + Language for UDAV + Язык для UDAV + + + Russian + Русский + + + Automatically execute script after loading + Автоматически выполнять после загрузки + + + Place editor at top + Поместить редактор сверху + + + Load script to new window + Загружать скрипт в новое окно + + + Automatical save before redrawing (F5) + Автоматически сохранять перед перерисовкой (F5) + + + Cancel + Отмена + + + OK + OK + + + UDAV - Insert filename + UDAV - Вставить имя файла + + + You have to restart UDAV for applying the cahnges. + Вы должны перезапустить UDAV для применения изменений. + + + English + + + + Image size + Размер рисунка + + + Font files (*.vfm) + Файлы шрифтов (*.vfm) + + + Disable face drawing (faster) for mouse rotation/shift/zoom. + Не рисовать грани (быстрее) при вращении мышью. + + + Automatically save before redrawing (F5) + Автоматически сохранять перед перерисовкой (F5) + + + Enable keywords completition + Включить дополнение ключевых слов + + + + QMGLCanvas + + No filename. Please save script first. + Нет имени файла. Сохраните сначала код. + + + UDAV + + + + Not initialized! + Не инициализировано! + + + + QObject + + none or default + нет или по-умолчанию + + + w - white + w - белый + + + b - blue + b - синий + + + g - lime + g - ярко-зеленый + + + r - red + r - красный + + + c - cyan + c - голубой + + + m - magenta + m - малиновый + + + y - yellow + y - желтый + + + l - springgreen + l - сине-зеленый + + + e - lawngreen + e - желто-зеленый + + + n - skyblue + n - небесно-голубой + + + u - blueviolet + u - сине-фиолетовый + + + q - orange + q - оранжевый + + + p - deeppink + p - фиолетовый + + + h - gray + h - серый + + + k - black + k - черный + + + W - lightgray + W - светло-серый + + + B - navy + B - темно синий + + + G - green + G - зеленый + + + R - maroon + R - темно красный + + + C - teal + C - темно голубой + + + M - purple + M -purple + M - пурпурный + + + Y - olive + Y - оливковый + + + L - seagreen + L - темно сине-зеленый + + + E - darklawn + E - темно желто-зеленый + + + N - darkskyblue + N - темно небесно-голубой + + + U - indigo + U - индиго + + + Q - brown + Q - коричневый + + + P - darkpink + P - темно фиолетовый + + + H - darkgray + H - темно серый + + + none + нет + + + arrow + стрелка + + + back arrow + обратная стрелка + + + stop + стоп + + + size + размер + + + triangle + треугольник + + + square + квадрат + + + rhomb + ромб + + + circle + окружность + + + solid + сплошная + + + dash + пунктир + + + dash dot + пунктир-точка + + + small dash + мелкий пунктир + + + small dash dot + мелкий пунктир-точка + + + dots + точки + + + dot + точка + + + cross + крест + + + skew cross + косой крест + + + asterix + звездочка + + + triangle down + треугольник вниз + + + triangle up + треугольник вверх + + + filled square + закрашенный квадрат + + + filled rhomb + закрашенный ромб + + + filled triangle down + закрашенный треугольник вниз + + + filled triangle up + закрашенный треугольник вверх + + + filled circle + круг + + + long dash + длинный пунктир + + + plus + плюс + + + triangle left + треугольник влево + + + triangle right + треугольник вправо + + + circled dot + точка в окружности + + + Y-sign + знак Y + + + squared plus + плюс в квадрате + + + squared cross + косой крест в квадрате + + + solid square + закрашенный квадрат + + + solid rhomb + закрашенный ромб + + + solid triangle down + закрашенный треугольник вниз + + + solid triangle up + закрашенный треугольник вверх + + + solid triangle left + закрашенный треугольник влево + + + solid triangle right + закрашенный треугольник вправо + + + solid circle + круг + + + + ScriptWindow + + +(c) Alexey Balakin, 2008 +http://udav.sf.net/ + +(c) Алексей Балакин, 2008 +http://udav.sf.net/ + + + UDAV - about + UDAV - о программе + + + File/Edit Operations + Файл/Правка + + + &File + &Файл + + + &New script + &Новый код + + + Create new empty script window (Ctrl+N). + Создать новое пустое окно для кода (Ctrl+N). + + + &Open file + &Открыть файл + + + Open and execute/show script or data from file (Ctrl+O). +You may switch off automatic exection in UDAV properties. + Открыть и выполнить/показать код или данные из файла (Ctrl+O). +Вы можете выключить автоматическое выполнение в настройках UDAV. + + + &Save script + &Сохранить файл + + + Save script to a file (Ctrl+S) + Сохранить код в файл (Ctrl+S) + + + Save &As ... + Сохранить &как ... + + + &Print script + Печатать &код + + + Print &graphics + &Печатать график + + + Open printer dialog and print graphics (Ctrl+P) + Открыть диалог принтера и напечатать график (Ctrl+P) + + + Recent files + Последние файлы + + + &Quit + В&ыход + + + &Edit + &Правка + + + &Undo + &Отменить + + + Undo editor change (Ctrl+Z). + Отменить изменения в редакторе (Ctrl+Z). + + + &Redo + &Вернуть + + + Redo editor change (Ctrl+Shift+Z). + Вернуть изменения в редакторе (Ctrl+Shift+Z). + + + Clear all + Очистить все + + + Cu&t text + В&ырезать + + + Cut selected text to clipboard (Ctrl+X). + Вырезать выделенный текст в буфер обмена (Ctrl+X). + + + &Copy + &Копировать + + + Copy selected text or data to clipboard (Ctrl+C). + Копировать выделенный текст в буфер обмена (Ctrl+C). + + + &Paste + &Вставить + + + Paste text or data from clipboard (Ctrl+V). + Вставить текст или данные из буфера обмена (Ctrl+V). + + + Select &all + Выделить вс&е + + + &Find/Replace + &Найти/заменить + + + Show dialog for text finding (Ctrl+F). + Показать диалог поиска текста (Ctrl+F). + + + Find next + Найти текст + + + Insert + Вставить + + + New command + Новая команда + + + Show dialog for new command and put it into the script. + Показать диалог вставки новой команды. + + + Fitted formula + Найденная формула + + + Insert last fitted formula with found coefficients. + Вставить последнюю найденную формулу в текст. + + + Plot style + Стиль графика + + + Show dialog for styles and put it into the script. +Styles define the plot view (color scheme, marks, dashing and so on). + Показать диалог стиля графика и вставить его в код. +Стиль определяет вид графика (цвет, маркеры, пунктир и пр). + + + Command options + Опции команды + + + Show dialog for options and put it into the script. +Options are used for additional setup the plot. + Показать диалог выбора опций команды. Опции используются +для дополнительной настройки выбранного графика. + + + Numeric value + Численное значение + + + Replace expression by its numerical value. + Заменить выделенное выражение его числовым значением. + + + File path + Путь файла + + + Select and insert file name. + Выбрать и вставить путь файла. + + + Folder path + Путь папки + + + Select and insert folder name. + Выбрать и вставить путь папки. + + + Graphics setup + Настройка графика + + + Show dialog for plot setup and put code into the script. +This dialog setup axis, labels, lighting and other general things. + Показать диалог настройки графика и вставить ее в код. +Диалог позволяет настроить оси, подписи, освещение и пр. + + + Properties + Настройки UDAV + + + Show dialog for UDAV properties. + Показать диалог настроек программы UDAV. + + + Set ar&guments + &Аргументы кода + + + Calculator + Калькулятор + + + Show calculator which evaluate and help to type textual formulas. +Textual formulas may contain data variables too. + Показывает калькулятор, который вычисляет и помогает набрать текстовые формулы. +Текстовые формулы могут содержать также и определенные в коде данные. + + + Show info + Окно сообщений + + + &Window + &Окна + + + Tile + Плиткой + + + Cascade + Каскадом + + + Close all + Закрыть все + + + UDAV Help + Справка по UDAV + + + &Help + &Справка + + + MGL &help + MGL &справка + + + Show help on MGL commands (F1). + Показывает справку по текущей команде MGL (F1). + + + &Examples + &Примеры + + + Show examples of MGL usage (Shift+F1). + Показывает примеры использования MGL (Shift+F1). + + + H&ints + С&оветы + + + Show hints of MGL usage. + Показывает советы по использованию MGL. + + + &About + О &программе + + + untitled - UDAV + без имени - UDAV + + + UDAV - save current + UDAV - сохранить текущий код + + + Do you want to save the changes to the document? + Вы хотите сохранить изменения в коде? + + + UDAV - Open file + UDAV - Открыть файл + + + MGL scripts (*.mgl) +HDF5 files (*.hdf *.h5) +Text files (*.txt) +Data files (*.dat) +All files (*.*) + MGL код (*.mgl) +HDF5 файлы (*.hdf *.h5) +Текст (*.txt) +Файлы данных (*.dat) +Все файлы (*.*) + + + Loading aborted + Загрузка прервана + + + UDAV - open file + UDAV - открыть файл + + + Couldn't open file + Не могу открыть файл + + + Loaded document + Загружен документ + + + Could not write to %1 + Не могу записать в %1 + + + File %1 saved + Файл %1 сохранен + + + UDAV - save file + UDAV - сохранить файл + + + MGL scripts (*.mgl) +HDF5 files (*.hdf *.h5) +All files (*.*) + MGL код (*.mgl) +HDF5 файлы (*.hdf *.h5) +Все файлы (*.*) + + + Saving aborted + Сохранение прервано + + + untitled* - UDAV + без имени* - UDAV + + + UDAV - Insert filename + UDAV - Вставить имя файла + + + Messages and warnings + Сообщения и предупреждения + + + Ready + Готово + + + Printing... + Печатаю... + + + Printing completed + Печать завершена + + + Printing aborted + Печать прервана + + + UDAV - find text + UDAV - поиск текста + + + No string occurrence is found + Строка не найдена + + + Not recognized + Не распознано + + + Loaded document %1 + Загружен документ %1 + + + &Data + &Данные + + + File Operations + Работа с файлами + + + &Load data + &Загрузить данные + + + Load data from file. Data will be deleted only +at exit but UDAV will not ask to save it. + Загрузить данные из файла. Данные будут удалены при +выходе, но UDAV не спросит об их сохранении. + + + &Import PNG + &Импорт PNG + + + Import data from PNG picture with specified color scheme. +Data will be deleted only at exit but UDAV will not ask it saving. + Импортировать данные из PNG рисунка с заданной цветовой схемой. +Данные будут удалены при выходе, но UDAV не спросит об их сохранении. + + + &Save data + Сохранить &данные + + + Save data to tab-separeted file. + Сохранить данные в текстовый файл с разделителем табуляцией. + + + &Export PNG + &Экспорт PNG + + + Export data to PNG picture. The colors defined by +specified color scheme. The same as in 'dens' command. + Экспортирует данные в PNG рисунок. Цвета определяются +указанной цветовой схемой. Рисунок аналогичен команде 'dens'. + + + Plot &data + &Отобразить данные + + + Plot data in new script window. You may select the kind +of plot, its style and so on. + Отобразить данные в новом окне. Вы можете +выбрать тип графика, его стиль и т.д. + + + Resize data + Размеры данных + + + &Sizes + &Размеры + + + &Create new + &Создать новые + + + Recreate the data with new sizes and fill it by zeros (Ctrl+N). + Создает заново данные нового размера и заполняет их нулями (Ctrl+N). + + + &Resize + &Изменить размер + + + Resize (interpolate) the data to specified sizes (Ctrl+R). + Изменяет размер (интерполирует) данных в указанному (Ctrl+R). + + + &Squeeze + С&жать + + + Keep only each n-th element of the data array. + Сохраняет каждый n-ый элемент массива данных. + + + Cro&p + О&брезать + + + Crop the data edges. Useful to cut off the zero-filled area. + Обрезает края данных. Полезно для удаления заполненных нулями областей. + + + &Transpose + &Транспонировать + + + Transpose data dimensions, like x<->y or x<->z and so on. + Транспонирует массив данных, типа x<->y или x<->z и т.д. + + + Re&arrange + По&менять размеры + + + Rearrange data sizes without changing data values. + Меняет размеры данных без изменения самого массива данных. + + + Modify data + Изменить данные + + + &Modify + &Изменить + + + By &formula + По &формуле + + + Change data values according to formula depended on 'x', 'y' and 'z' +variables. A set of special function is availible also. + Изменяет данные по формуле, зависяещей от переменных 'x', 'y' и 'z'. +Поддерживаются также многие специальные функции. + + + Fill in &range + &Распределить + + + Fill data equidistantly from one value to another. + Распределить равномерно данные от одного значения до другого. + + + &Normalize + &Нормировать + + + Normalize data so that its minimal +and maximal values be in specified range. + Нормирует данные так, что их максимальное и +минимальное значения равны заданным. + + + Norm. s&lices + Норм. по &срезам + + + Normalize each data slice perpendicular to some direction +so that its minimal and maximal values be in specified range. + Нормирует данные по срезам перпендикулярно +заданному направлению так, что их максимальное +и минимальное значения равны заданным. + + + &Smooth data + С&гладить + + + Smooth data by one of 4 methods along specified direction(s). + Сглаживает данные одним из 4-х методов вдоль заданного направления(ий). + + + &Operators + &Опраторы + + + &Cum. sum + &Суммировать + + + Summate data values along specified direction(s). + Суммирует данные вдоль указанного направления(ий). + + + &Integrate + &Интегрировать + + + Integrate data values along specified direction(s). + Интегрирует данные по заданному направлению(ям). + + + &Differentiate + &Дифференцировать + + + Differentiate data values along specified direction(s). + Дифференцирует данные по заданному направлению(ям). + + + &Laplace + &Лаплас + + + Double differentiate data values along specified direction(s). + Дважды дифференцирует данные по заданному направлению(ям). + + + &Swap + &Поменять местами + + + Swap left and right data part along specified direction(s). +This operation is useful for data after Fourier transform. + Меняет местами левую и правую часть данных вдоль указанного направления(ий). +Операция полезна для данных после Фурье преобразования. + + + &Mirror + &Отразить + + + Mirror left and right data part along specified direction(s). +This operation do like index change from 'i' to 'n-i'. + Отражает данные относительно указанного направления(ий). +Действует как замена индекса 'i' на 'n-i'. + + + &Algebraic + &Алгебраические + + + &Add + &Добавить + + + Add a number to all data values. + Добавляет число к элементам массива данных. + + + &Subtract + &Вычесть + + + Subtract a number to all data values. + Вычитает из элементов массива данных число. + + + &Multiply + &Умножить + + + Multiply all data values by a number. + Умножает элементы массива данных на число. + + + &Divide + &Разделить + + + Divide all data values by a number. + Делит элементы массива данных на число. + + + A&nother data + &Новые данные + + + &Sum of + &Сумма по + + + M&in of + М&инимум по + + + M&ax of + М&аксимум по + + + Momentum along &x + Момент вдоль &x + + + Momentum along &y + Момент вдоль &y + + + Momentum along &z + Момент вдоль &z + + + &Histogram + &Гистограмма + + + Navigate data + Переход к срезам + + + &Navigate + Пере&ход + + + &First slice + &Первый срез + + + Go to the first data slice for 3D data. + Перейти к первому срезу 3D данных. + + + &Prev. slice + &Предыдущий срез + + + Go to the previous data slice for 3D data. + Перейти к предыдущему срезу 3D данных. + + + Go to the specified data slice for 3D data. + Перейти к указанному срезу 3D данных. + + + Go to slice + Перейти к срезу + + + Next slice + Следующий срез + + + Go to the next data slice for 3D data. + Перейти к следующему срезу 3D данных. + + + Last slice + Последний срез + + + Go to the last data slice for 3D data. + Перейти к последнему срезу 3D данных. + + + About Qt + О библиотеке Qt + + + About &Qt + О библиотеке &Qt + + + Couldn't change to folder + Не могу перейти в папку + + + Couldn't open file + Не могу открыть файл + + + &Copy text + &Копировать текст + + + &Paste text + &Вставить текст + + + File name + Имя файла + + + + SetupDialog + + UDAV - Setup plot + UDAV - Настройка графика + + + X axis + Ось X + + + Y axis + Ось Y + + + Z axis + Ось Z + + + C axis + Ось C + + + Minimal + Минимум + + + Maximal + Максимум + + + Origin + Начало осей + + + Label + Подпись + + + at position + в позиции + + + at minimum + минимума + + + at center + по центру + + + at maximum + максимума + + + Ticks + Метки + + + SubTicks + Под-метки + + + Start + Начало меток + + + Template + Шаблон + + + AlphaDef + Базовая прозрачность + + + Ambient + Фоновый свет + + + BaseWidth + Базовая ширина + + + MeshNum + Число линий сетки + + + AxialDir + Ось вращения + + + Font + Стиль текста + + + FontSize + Размер текста + + + Alpha on + Прозрачность + + + Light on + Освещение + + + No text rotation + Запрет вращения текста + + + General settings + Общие настройки + + + State + Состояние + + + Color + Цвет + + + Brightness + Яркость + + + Light settings + Настройки освещения + + + Template name + Имя шаблона + + + Save + Сохранить + + + Cancel + Отмена + + + To script + В код + + + UDAV - Save template + UDAV - Сохранить шаблон + + + Could not write to file + Не могу записать в файл + + + Template saved + Шаблон сохранен + + + Light position should be filled. Ignore it. + Положение источника должно быть заполнено. Игнорирую. + + + ID + + + + X pos + + + + Y pos + + + + Z pos + + + + on + вкл + + + + StyleDialog + + UDAV - Insert style/scheme + UDAV - Вставить стиль/схему + + + Arrow at start + Стрелка в начале + + + Dashing + Пунктир + + + Arrow at end + Стрелка в конце + + + Color + Цвет + + + Marks + Маркер + + + Line width + Толщина + + + Line style + Стиль линии + + + Color order + Порядок цветов + + + Saturation + Насыщенность + + + Colors along coordinates + Цвет вдоль координат + + + Wire or mesh plot + Сетчатый график + + + Axial direction + Ось вращения + + + Text on contours + Текст на контурах + + + none + нет + + + under + под + + + above + над + + + Color scheme + Цветовая схема + + + Bold style + Жирный + + + Italic style + Курсив + + + Wire style + Контур + + + Underline + Подчеркнутый + + + Overline + Надчеркнутый + + + Text color + Цвет текста + + + Text align + Выравнивание + + + left + влево + + + at center + по центру + + + right + вправо + + + Font style + Стиль текста + + + Resulting string + Результат + + + Cancel + Отмена + + + OK + OK + + + + TableWindow + + - UDAV variable + - UDAV переменная + + + - UDAV preview + - UDAV просмотр + + + UDAV - Import PNG + UDAV - Импорт PNG + + + Data files (*.dat) +All files (*.*) + Файлы данных (*.dat) +Все файлы (*.*) + + + UDAV - Export to PNG + UDAV - Экспорт в PNG + + + Enter color scheme for picture. +Note that data will be normalized in range [0,1]. + Введите цветовую схему рисунка. +Данные будут нормированы в [0,1]. + + + PNG files (*.png) +All files (*.*) + PNG файлы (*.png) +Все файлы (*.*) + + + Enter color scheme for picture + Введите цветовую схему рисунка + + + UDAV - Save data + UDAV - Сохранить данные + + + UDAV - Load data + UDAV - Загрузить данные + + + UDAV - Fill data + UDAV - Заполнить данные + + + Enter formula for data filling. +Note that variables x,y,z supposed to be in range [0,1]. + Введите формулу для данных. +Переменные x,y,z меняются в интервале [0,1]. + + + Enter range for data and direction of filling + Введите диапазон и направление заполнения + + + From + От + + + To + До + + + Direction + Направление + + + UDAV - Normalize data + UDAV - Нормировать данные + + + Enter range for final data + Введите диапазон результата + + + Symmetrical? + Симметрично? + + + UDAV - Normalize by slice + UDAV - Нормировать по срезам + + + UDAV - Clear data + UDAV - Очистить данные + + + Enter new data sizes + Введите новые размеры + + + X-size + Размер по X + + + Y-size + Размер по Y + + + Z-size + Размер по Z + + + UDAV - Resize data + UDAV - Изменить размер данных + + + UDAV - Squeeze data + UDAV - Сжать данные + + + Enter step of saved points. For example, '1' save all, '2' save each 2nd point, '3' save each 3d and so on. + Введите шаг сохраняемых точек. Например, '1' сохранить все, '2' каждую вторую точку, '3' каждую третью и т.д. + + + X-direction + X направление + + + Y-direction + Y направление + + + Z-direction + Z направление + + + UDAV - Crop data + UDAV - Обрезать данные + + + Enter range of saved date. + Введите интервал сохраняемых данных. + + + UDAV - Rearrange data + Не знаю хорошего русского термина + UDAV - Поменять размеры данных + + + UDAV - Transpose data + UDAV - Транспонировать данные + + + Enter new order of dimensions. +For example, 'yx' or 'yxz' for transpose x-y, 'zyx' for transposing x-z and so on. + Введите новый порядок размерностей. +Например, 'yx' или 'yxz' для транспонирования x-y, 'zyx' для транспонирования x-z и т.д. + + + UDAV - Smooth data + UDAV - Сгладить данные + + + Enter direction(s) for smoothing. +Optionally you may enter the kind of smoothing by 3 or by 5 points. For example 'xy3' - smooth only in x and y directions and use 3-points scheme. + Введите направление(я) сглаживания. +Можно также ввести тип сглаживания по 3 или по 5 точкам. Например 'xy3' - сгладит только в x и y направлениях по 3-точечной схеме. + + + UDAV - Summarize data + UDAV - Суммировать данные + + + Enter direction(s) for cumulative summation. +For example 'xy' - summate along x and y directions. + Введите направление(я) для суммирования. +Например 'xy' - суммировать вдоль x и y направлений. + + + UDAV - Integrate data + UDAV - Интегрировать данные + + + Enter direction(s) for integration. +For example 'xy' - integrate along x and y directions. + Введите направление(я) для инткгрирования. +Например 'xy' - интегрировать вдоль x и y направлений. + + + UDAV - Differentiate data + UDAV - Дифференцировать данные + + + Enter direction(s) for differentiation. +For example 'xy' - differentiate along x and y directions. + Введите направление(я) для дифференцирования. +Например 'xy' - дифференцировать вдоль x и y направлений. + + + UDAV - Laplace transform + UDAV - Преобразование Лапласа + + + Enter direction(s) for laplace transform. +For example 'xy' - do transform along x and y directions. + Введите направление(я) для преобразования Лапласа. +Например 'xy' - преобразовать вдоль x и y направлений. + + + UDAV - Swap data + UDAV - Поменять местами + + + Enter direction(s) for swapping (exchange left and right parts). +For example 'xy' - swap along x and y directions. Useful for Fourier spectrum. + Введите направление(я) для обмена левой и правой частями данных. +Например 'xy' - меняет вдоль x и y направлений. Полезно для Фурье спектров. + + + UDAV - Mirror data + UDAV - Отразить данные + + + Enter direction(s) for mirroring. +For example 'xy' - mirror along x and y directions. + Введите направление(я) для отражения. +Например 'xy' - отразить по x и y направлениям. + + + UDAV - Sum along ... + UDAV - Сумма по ... + + + Specify direction(s) of summation + Введите направление(я) суммирования + + + UDAV - Max along ... + UDAV - Максимум по ... + + + Specify direction(s) of maximal values + Введите направление(я) поиска максимумов + + + UDAV - Min along ... + UDAV - Минимум по ... + + + Specify direction(s) of minimal values + Введите направление(я) поиска минимумов + + + UDAV - Momentum along 'x' + UDAV - Момент по 'x' + + + Specify which momentum evaluate. +The momentum is res_i = sum_jk how(x_i,y_j,z_k) a_jk/ sum_jk a_jk. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_i = Σ_jk how(x_i,y_j,z_k) a_jk/ Σ_jk a_jk. +Координаты x, y, z находятся в диапазоне [0,1]. + + + Specify which momentum evaluate. +The momentum is res_j = sum_ik how(x_i,y_j,z_k) a_ik/ sum_ik a_ik. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_j = Σ_ik how(x_i,y_j,z_k) a_ik/ Σ_ik a_ik. +Координаты x, y, z находятся в диапазоне [0,1]. + + + Specify which momentum evaluate. +The momentum is res_k = sum_ij how(x_i,y_j,z_k) a_ij/ sum_ij a_ij. +Coordinates x, y, z are data indexes normalized in range [0,1]. + Укажите какой момент вычислять. +Момент равен res_k = Σ_ij how(x_i,y_j,z_k) a_ij/ Σ_ij a_ij. +Координаты x, y, z находятся в диапазоне [0,1]. + + + UDAV - Momentum along 'y' + UDAV - Момент по 'y' + + + UDAV - Momentum along 'z' + UDAV - Момент по 'z' + + + UDAV - Make histogram + UDAV - Найти гистограмму + + + Number of points + Число точек + + + Put in variable + Поместить в переменную + + + Cancel + Отмена + + + OK + OK + + + UDAV - Change data + UDAV - Изменить данные + + + Enter number for adding to data elements: + Введите число для добавления к элементам массива: + + + Enter number for subtraction from data elements: + Введите число для вычитания из элементов массива: + + + Enter number for division of data elements: + Введите число для деления элементов массива: + + + Enter number for multiplication of data elements: + Введите число для умножения элементов массива: + + + UDAV - Go to slice + UDAV - Перейти к срезу + + + Enter slice id: + Введите номер среза: + + + NOTE: All fields must be filled! + Все поля должны быть заполнены! + + + Enter the name for new variable + Введите имя новой переменной + + + + TextPanel + + &Edit + &Правка + + + UDAV - Insert filename + UDAV - Вставить имя файла + + + Printing... + Печатаю... + + + Printing completed + Печать завершена + + + Printing aborted + Печать прервана + + + UDAV - find text + UDAV - поиск текста + + + No string occurrence is found + Строка не найдена + + + Loaded document %1 + Загружен документ %1 + + + Could not write to %1 + Не могу записать в %1 + + + File %1 saved + Файл %1 сохранен + + + UDAV - open file + UDAV - открыть файл + + + Couldn't open file + Не могу открыть файл + + + Loaded document + Загружен документ + + + &Undo + &Отменить + + + Undo editor change (Ctrl+Z). + Отменить изменения в редакторе (Ctrl+Z). + + + &Redo + &Вернуть + + + Redo editor change (Ctrl+Shift+Z). + Вернуть изменения в редакторе (Ctrl+Shift+Z). + + + Clear all + Очистить все + + + Cu&t text + В&ырезать + + + Cut selected text to clipboard (Ctrl+X). + Вырезать выделенный текст в буфер обмена (Ctrl+X). + + + &Copy text + &Копировать текст + + + Copy selected text or data to clipboard (Ctrl+C). + Копировать выделенный текст в буфер обмена (Ctrl+C). + + + &Paste text + &Вставить текст + + + Paste text or data from clipboard (Ctrl+V). + Вставить текст или данные из буфера обмена (Ctrl+V). + + + Select &all + Выделить вс&е + + + &Find/Replace + &Найти/заменить + + + Show dialog for text finding (Ctrl+F). + Показать диалог поиска текста (Ctrl+F). + + + Find next + Найти текст + + + Insert + Вставить + + + New command + Новая команда + + + Show dialog for new command and put it into the script. + Показать диалог вставки новой команды. + + + Fitted formula + Найденная формула + + + Insert last fitted formula with found coefficients. + Вставить последнюю найденную формулу в текст. + + + Plot style + Стиль графика + + + Show dialog for styles and put it into the script. +Styles define the plot view (color scheme, marks, dashing and so on). + Показать диалог стиля графика и вставить его в код. +Стиль определяет вид графика (цвет, маркеры, пунктир и пр). + + + Command options + Опции команды + + + Show dialog for options and put it into the script. +Options are used for additional setup the plot. + Показать диалог выбора опций команды. Опции используются +для дополнительной настройки выбранного графика. + + + Numeric value + Численное значение + + + Replace expression by its numerical value. + Заменить выделенное выражение его числовым значением. + + + File name + Имя файла + + + Select and insert file name. + Выбрать и вставить путь файла. + + + Folder path + Путь папки + + + Select and insert folder name. + Выбрать и вставить путь папки. + + + Graphics setup + Настройка графика + + + Show dialog for plot setup and put code into the script. +This dialog setup axis, labels, lighting and other general things. + Показать диалог настройки графика и вставить ее в код. +Диалог позволяет настроить оси, подписи, освещение и пр. + + + diff --git a/udav/udav_wnd.cpp b/udav/udav_wnd.cpp new file mode 100644 index 0000000..5d5f7dc --- /dev/null +++ b/udav/udav_wnd.cpp @@ -0,0 +1,745 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifdef WIN32 +#include +#include +#else +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//----------------------------------------------------------------------------- +#if !defined(WIN32) && !defined(__APPLE__) +#include +#endif +//----------------------------------------------------------------------------- +#include +#include "udav_wnd.h" +#include "text_pnl.h" +#include "plot_pnl.h" +#include "prop_dlg.h" +#include "qmglsyntax.h" +//----------------------------------------------------------------------------- +extern bool mglAutoExecute; +PropDialog *propDlg=0; +int MainWindow::num_wnd=0; +QStringList recentFiles; +int MaxRecentFiles=5; +bool editPosBottom = false; +bool mglAutoSave = false; +bool mglHighlight = true; +bool mglAutoPure = true; +bool mglCompleter = true; +bool loadInNewWnd = false; +QString pathHelp; +extern mglParse parser; +extern QColor mglColorScheme[10]; +extern QString defFontFamily; +extern int defFontSize; +extern QString pathFont; +extern int defWidth, defHeight; +//----------------------------------------------------------------------------- +QWidget *createCalcDlg(QWidget *p, QTextEdit *e); +QDialog *createArgsDlg(QWidget *p); +QWidget *createMemPanel(QWidget *p); +QWidget *createHlpPanel(QWidget *p); +void showHelpMGL(QWidget *hlp, QString s); +void addDataPanel(QWidget *p, QWidget *w, QString name) +{ + MainWindow *wnd = dynamic_cast(p); + if(wnd) wnd->addPanel(w, name); +} +//----------------------------------------------------------------------------- +#ifndef UDAV_DIR +#ifdef WIN32 +#define UDAV_DIR "" +#else +#define UDAV_DIR "/usr/local/share/udav/" +#endif +#endif +//----------------------------------------------------------------------------- +int mgl_cmd_cmp(const void *a, const void *b); +void udavLoadDefCommands(); +void udavShowHint(QWidget *); +void mgl_ask_qt(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +int main(int argc, char **argv) +{ +// QCoreApplication::setAttribute(Qt::AA_X11InitThreads); +#if !defined(WIN32) && !defined(__APPLE__) + // try to fix possible multi-threading errors + // must be placed before ANY window creation + XInitThreads(); +#endif + mgl_ask_func = mgl_ask_qt; + QApplication a(argc, argv); + QTranslator translator; +//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QString lang=""; + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + pathHelp = settings.value("/helpPath", MGL_DOC_DIR).toString(); +#if defined(WIN32) + if(pathHelp.isEmpty()) pathHelp = a.applicationDirPath()+"\\"; +#endif + pathFont = settings.value("/userFont", "").toString(); + lang = settings.value("/udavLang", "").toString(); + bool showHint = settings.value("/showHint", true).toBool(); + mglCompleter = settings.value("/completer", true).toBool(); + settings.endGroup(); + if(pathHelp.isEmpty()) pathHelp=MGL_DOC_DIR; + + if(!lang.isEmpty()) + { + if(!translator.load("udav_"+lang, UDAV_DIR)) + translator.load("udav_"+lang, pathHelp); + a.installTranslator(&translator); + } + + udavLoadDefCommands(); + parser.AllowSetSize(true); + MainWindow *mw = new MainWindow(); + if(argc>1) + { + QTextCodec *codec = QTextCodec::codecForLocale(); + mw->load(codec->toUnicode(argv[1]), true); + } + mw->show(); + a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); + if(showHint) udavShowHint(mw); + return a.exec(); +} +//----------------------------------------------------------------------------- +// +// mgl addon +// +//----------------------------------------------------------------------------- +/*mglCommand udav_base_cmd[] = { + {L"fplot",L"Plot curve by formula",L"fplot 'func' ['stl'='' num=100]", mgls_fplot, mglc_fplot}, + {L"fsurf",L"Plot surface by formula",L"fsurf 'func' ['stl'='' numx=100 numy=100]", mgls_fsurf, mglc_fsurf}, + {L"fgets",L"Print string from file",L"fgets x y {z} 'fname' [pos=0 'stl'='' size=-1.4]", mgls_fgets, mglc_fgets}, +{L"",0,0,0,0}}; +//----------------------------------------------------------------------------- +void udavAddCommands(const mglCommand *cmd) // NOTE it work but I don't how I can use it +{ + int i, mp, mc; + // determine the number of symbols + for(i=0;parser.Cmd[i].name[0];i++){}; mp = i; + for(i=0;cmd[i].name[0];i++){}; mc = i; + mglCommand *buf = new mglCommand[mp+mc+1]; + memcpy(buf, parser.Cmd, mp*sizeof(mglCommand)); + memcpy(buf+mp, cmd, (mc+1)*sizeof(mglCommand)); + qsort(buf, mp+mc, sizeof(mglCommand), mgl_cmd_cmp); + if(parser.Cmd!=mgls_base_cmd) delete []parser.Cmd; + parser.Cmd = buf; +}*/ +//----------------------------------------------------------------------------- +void udavLoadDefCommands() {} //{ udavAddCommands(udav_base_cmd); } +//----------------------------------------------------------------------------- +// +// Class MainWindow +// +//----------------------------------------------------------------------------- +MainWindow::MainWindow(QWidget *wp) : QMainWindow(wp) +{ + QAction *a; + setWindowTitle(tr("untitled - UDAV")); + setAttribute(Qt::WA_DeleteOnClose); + + split = new QSplitter(this); + ltab = new QTabWidget(split); + ltab->setMovable(true); ltab->setTabPosition(QTabWidget::South); +// ltab->setTabsClosable(true); + rtab = new QTabWidget(split); + rtab->setMovable(true); rtab->setTabPosition(QTabWidget::South); + + messWnd = new QDockWidget(tr("Messages and warnings"),this); + mess = new TextEdit(this); messWnd->setWidget(mess); + messWnd->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + addDockWidget(Qt::BottomDockWidgetArea, messWnd); + messWnd->resize(size().width(), 0); new MessSyntax(mess); + connect(mess,SIGNAL(cursorPositionChanged()),this,SLOT(messClicked())); + connect(mess,SIGNAL(selectionChanged()),this,SLOT(messClicked())); + + calcWnd = new QDockWidget(tr("Calculator"),this); + + aload = a = new QAction(QPixmap(":/xpm/document-open.png"), tr("Open file"), this); + connect(a, SIGNAL(triggered()), this, SLOT(choose())); + a->setToolTip(tr("Open and execute/show script or data from file (Ctrl+O).\nYou may switch off automatic exection in UDAV properties.")); + a->setShortcut(Qt::CTRL+Qt::Key_O); + + asave = a = new QAction(QPixmap(":/xpm/document-save.png"), tr("Save script"), this); + connect(a, SIGNAL(triggered()), this, SLOT(save())); + a->setToolTip(tr("Save script to a file (Ctrl+S)")); + a->setShortcut(Qt::CTRL+Qt::Key_S); + + acalc = a = new QAction(QPixmap(":/xpm/accessories-calculator.png"), tr("Calculator"), this); + a->setShortcut(Qt::Key_F4); a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), calcWnd, SLOT(setVisible(bool))); + connect(calcWnd, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(tr("Show calculator which evaluate and help to type textual formulas.\nTextual formulas may contain data variables too.")); + a->setChecked(false); calcWnd->setVisible(false); + + ainfo = a = new QAction(tr("Show info"), this); + a->setShortcut(Qt::Key_F2); a->setCheckable(true); + connect(a, SIGNAL(toggled(bool)), messWnd, SLOT(setVisible(bool))); + connect(messWnd, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); + a->setChecked(false); messWnd->setVisible(false); + + graph = new PlotPanel(this); + rtab->addTab(graph,QPixmap(":/xpm/x-office-presentation.png"),tr("Canvas")); + // connect(info,SIGNAL(addPanel(QWidget*)),this,SLOT(addPanel(QWidget*))); + info = createMemPanel(this); + rtab->addTab(info,QPixmap(":/xpm/system-file-manager.png"),tr("Info")); + hlp = createHlpPanel(this); + rtab->addTab(hlp,QPixmap(":/xpm/help-contents.png"),tr("Help")); + edit = new TextPanel(this); edit->graph = graph; + graph->textMGL = edit->edit; + connect(graph->mgl,SIGNAL(showWarn(QString)),mess,SLOT(setText(QString))); + connect(graph,SIGNAL(clearWarn()),mess,SLOT(clear())); + ltab->addTab(edit,QPixmap(":/xpm/text-x-generic.png"),tr("Script")); + + calcWnd->setWidget(createCalcDlg(this, edit->edit)); + calcWnd->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); + addDockWidget(Qt::BottomDockWidgetArea, calcWnd); + calcWnd->resize(size().width(), 200); + + makeMenu(); + setCentralWidget(split); + setWindowIcon(QIcon(":/udav.png")); + readSettings(); + if(!propDlg) propDlg = new PropDialog; + + connect(graph, SIGNAL(save()), this, SLOT(save())); + connect(graph, SIGNAL(setStatus(const QString &)), this, SLOT(setStatus(const QString &))); + connect(graph, SIGNAL(animPutText(const QString &)), edit, SLOT(animPutText(const QString &))); + connect(graph,SIGNAL(giveFocus()),edit->edit,SLOT(setFocus())); + connect(graph->mgl, SIGNAL(objChanged(int)), edit, SLOT(setCursorPosition(int))); +// connect(graph->mgl, SIGNAL(posChanged(QString)), statusBar(), SLOT(showMessage(QString))); + connect(graph->mgl, SIGNAL(refreshData()), this, SLOT(refresh())); + connect(graph->mgl, SIGNAL(refreshData()), edit, SLOT(refreshData())); + connect(graph->mgl,SIGNAL(doubleClick(int)),edit,SLOT(newCmd(int))); + + connect(mess, SIGNAL(textChanged()), this, SLOT(warnChanged())); +// connect(mdi, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(subActivated(QMdiSubWindow *))); + connect(propDlg, SIGNAL(sizeChanged(int,int)), graph->mgl, SLOT(imgSize(int,int))); +// connect(propDlg, SIGNAL(propUpdated()), edit->edit, SLOT(update())); // TODO: update qmglsyntax + connect(edit->edit,SIGNAL(textChanged()), this, SLOT(setAsterix())); + connect(edit->edit, SIGNAL(cursorPositionChanged()), this, SLOT(editPosChanged())); + connect(edit,SIGNAL(setCurrentFile(QString)),this,SLOT(setCurrentFile(QString))); + connect(edit,SIGNAL(setStatus(QString)),this,SLOT(setStatus(QString))); + + setStatus(tr("Ready")); + num_wnd++; + edit->setAcceptDrops(false); // for disabling default action by 'edit' + setAcceptDrops(true); +} +//----------------------------------------------------------------------------- +void MainWindow::makeMenu() +{ + QAction *a; + QMenu *o; + + // file menu + { + o = menuBar()->addMenu(tr("File")); + a = new QAction(QPixmap(":/xpm/document-new.png"), tr("New script"), this); + connect(a, SIGNAL(triggered()), this, SLOT(newDoc())); + a->setToolTip(tr("Create new empty script window (Ctrl+N).")); + a->setShortcut(Qt::CTRL+Qt::Key_N); o->addAction(a); + + o->addAction(aload); + o->addAction(asave); + + a = new QAction(tr("Save as ..."), this); + connect(a, SIGNAL(triggered()), this, SLOT(saveAs())); + o->addAction(a); + + o->addSeparator(); + o->addAction(tr("Print script"), edit, SLOT(printText())); + a = new QAction(QPixmap(":/xpm/document-print.png"), tr("Print graphics"), this); + connect(a, SIGNAL(triggered()), graph->mgl, SLOT(print())); + a->setToolTip(tr("Open printer dialog and print graphics (Ctrl+P)")); + a->setShortcut(Qt::CTRL+Qt::Key_P); o->addAction(a); + o->addSeparator(); + fileMenu = o->addMenu(tr("Recent files")); + o->addSeparator(); + o->addAction(tr("Quit"), qApp, SLOT(closeAllWindows())); + } + + menuBar()->addMenu(edit->menu); + menuBar()->addMenu(graph->menu); + + // settings menu + { + o = menuBar()->addMenu(tr("Settings")); + a = new QAction(QPixmap(":/xpm/preferences-system.png"), tr("Properties"), this); + connect(a, SIGNAL(triggered()), this, SLOT(properties())); + a->setToolTip(tr("Show dialog for UDAV properties.")); o->addAction(a); + o->addAction(tr("Set arguments"), createArgsDlg(this), SLOT(exec())); + + o->addAction(acalc); + o->addAction(ainfo); + } + + menuBar()->addSeparator(); + o = menuBar()->addMenu(tr("Help")); + a = new QAction(QPixmap(":/xpm/help-contents.png"), tr("MGL help"), this); + connect(a, SIGNAL(triggered()), this, SLOT(showHelp())); + a->setToolTip(tr("Show help on MGL commands (F1).")); + a->setShortcut(Qt::Key_F1); o->addAction(a); + a = new QAction(QPixmap(":/xpm/help-faq.png"), tr("Hints"), this); + connect(a, SIGNAL(triggered()), this, SLOT(showHint())); + a->setToolTip(tr("Show hints of MGL usage.")); o->addAction(a); + o->addAction(tr("About"), this, SLOT(about())); + o->addAction(tr("About Qt"), this, SLOT(aboutQt())); +} +//----------------------------------------------------------------------------- +void MainWindow::closeEvent(QCloseEvent* ce) +{ + bool ok=true; + writeSettings(); + if(edit->isModified()) + switch(QMessageBox::information(this, tr("UDAV"), + tr("Do you want to save the changes to the document?"), + QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel)) + { + case QMessageBox::Yes: save(); break; + case QMessageBox::No: break; + default: ok=false; break; + } + if(ok) + { + num_wnd--; + ce->accept(); + if(num_wnd==0) QApplication::quit(); + } + else ce->ignore(); +} +//----------------------------------------------------------------------------- +void MainWindow::dropEvent(QDropEvent * de) +{ + // Linux Qt send "text/plain" mime data in drop event + // Windows version send "text/uri-list" + QTextCodec *codec = QTextCodec::codecForLocale(); + QString filename; + if ( de->mimeData()->hasFormat("text/plain") ) + { + // Under linux just convert the text from the local encodig to Qt's unicode + filename = codec->toUnicode(de->mimeData()->data("text/plain")); + if (filename.indexOf("file:") == 0) + load(filename.remove("file://").trimmed(), false); + }else + if ( de->mimeData()->hasUrls() ) + { + // Under win - parse the dropped data and find the path to local file + QList UrlList; + QFileInfo finfo; + UrlList = de->mimeData()->urls(); + if ( UrlList.size() > 0) // if at least one QUrl is present in list + { + filename = UrlList[0].toLocalFile(); // convert first QUrl to local path + finfo.setFile( filename ); + if ( finfo.isFile() ) + { + load(filename, false); + } + } + } +} +//----------------------------------------------------------------------------- +void MainWindow::dragEnterEvent(QDragEnterEvent *event) +{ + QTextCodec *codec = QTextCodec::codecForLocale(); + QString filename = codec->toUnicode(event->mimeData()->data("text/plain")); + /*if ( event->provides("text/plain") ) + { + QTextCodec *codec = QTextCodec::codecForLocale(); + QString instring = codec->toUnicode(event->mimeData()->data("text/plain")); + if ( instring.indexOf("file://") >= 0) + { + event->acceptProposedAction(); + setStatus(instring); + } + } + else */ + if(event->mimeData()->hasUrls()) + { + QList UrlList; + QFileInfo finfo; + UrlList = event->mimeData()->urls(); + if ( UrlList.size() > 0) // if at least one QUrl is present in list + { + filename = UrlList[0].toLocalFile(); // convert first QUrl to local path + finfo.setFile(filename); + if ( finfo.isFile() ) + { + event->acceptProposedAction(); + setStatus(filename); + } + } + } +} +//----------------------------------------------------------------------------- +void MainWindow::showHelp() +{ + QString s = edit->selection(), dlm(" #;:\t"); + int i, n = s.length(); + for(i=0;iselection(), dlm(" #;:\t"); + n = text.length(); + for(i=0;isetOrientation(bottom ? Qt::Vertical : Qt::Horizontal); } +//----------------------------------------------------------------------------- +void MainWindow::properties() { propDlg->exec(); } +//----------------------------------------------------------------------------- +void MainWindow::messClicked() +{ + QString m = mess->toPlainText(), q; + int p = mess->textCursor().blockNumber(); + for(;p>=0;p--) + { + q = m.section('\n',p,p); + if(q.contains("in line ")) + { + QString s = q.section(' ',-1); + int n = s.toInt()-1; if(n<0) return; + edit->moveCursor(QTextCursor::Start); + for(int i=0;imoveCursor(QTextCursor::NextBlock); + break; + } + } + edit->setFocus(); +} +//----------------------------------------------------------------------------- +void MainWindow::warnChanged() +{ + if(mess->toPlainText().isEmpty()) + { messWnd->hide(); ainfo->setChecked(false); } + else + { messWnd->show(); ainfo->setChecked(true); } +} +//----------------------------------------------------------------------------- +void MainWindow::about() +{ + QString s = tr("UDAV v. 2.")+QString::number(MGL_VER2)+ + tr("\n(c) Alexey Balakin, 2007-2014\nhttp://mathgl.sf.net/"); + QMessageBox::about(this, tr("UDAV - about"), s); +} +//----------------------------------------------------------------------------- +void MainWindow::aboutQt() +{ QMessageBox::aboutQt(this, tr("About Qt")); } +//----------------------------------------------------------------------------- +void MainWindow::writeSettings() +{ + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + settings.setValue("/animDelay", animDelay); + settings.setValue("/geometry/size", size()); +// settings.setValue("/geometry/dock", messWnd->size()); + settings.setValue("/geometry/split_e/w1", split->sizes().at(0)); + settings.setValue("/geometry/split_e/w2", split->sizes().at(1)); + + settings.setValue("/recentFiles", recentFiles); + settings.setValue("/recentFilesMax", MaxRecentFiles); + settings.setValue("/helpPath", pathHelp); + settings.setValue("/userFont", pathFont); + settings.setValue("/colComment",mglColorScheme[0].name()); + settings.setValue("/colString", mglColorScheme[1].name()); + settings.setValue("/colKeyword",mglColorScheme[2].name()); + settings.setValue("/colOption", mglColorScheme[3].name()); + settings.setValue("/colSuffix", mglColorScheme[4].name()); + settings.setValue("/colNumber", mglColorScheme[5].name()); + settings.setValue("/colACKeyword", mglColorScheme[6].name()); + settings.setValue("/colFCKeyword", mglColorScheme[7].name()); + settings.setValue("/colReserved", mglColorScheme[8].name()); + settings.setValue("/colCurrLine", mglColorScheme[9].name()); + settings.setValue("/autoExec", mglAutoExecute); + settings.setValue("/autoSave", mglAutoSave); + settings.setValue("/highlight", mglHighlight); + settings.setValue("/autoPure", mglAutoPure); + settings.setValue("/editAtTop", editPosBottom); + settings.setValue("/fontFamily", defFontFamily); + settings.setValue("/fontSize", defFontSize); + settings.setValue("/loadInNewWnd", loadInNewWnd); + settings.setValue("/completer", mglCompleter); + settings.endGroup(); +} +//----------------------------------------------------------------------------- +void MainWindow::readSettings() +{ + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + pathHelp = settings.value("/helpPath", MGL_DOC_DIR).toString(); + if(pathHelp.isEmpty()) pathHelp=MGL_DOC_DIR; + MaxRecentFiles = settings.value("/recentFilesMax", 5).toInt(); + animDelay = settings.value("/animDelay", 500).toInt(); + resize(settings.value("/geometry/size", QSize(880,720)).toSize()); + QList le; + le.append(settings.value("/geometry/split_e/w1", 230).toInt()); + le.append(settings.value("/geometry/split_e/w2", 604).toInt()); + split->setSizes(le); + + pathFont = settings.value("/userFont", "").toString(); + mglColorScheme[0] = QColor(settings.value("/colComment","#007F00").toString()); + mglColorScheme[1] = QColor(settings.value("/colString", "#FF0000").toString()); + mglColorScheme[2] = QColor(settings.value("/colKeyword","#00007F").toString()); + mglColorScheme[3] = QColor(settings.value("/colOption", "#7F0000").toString()); + mglColorScheme[4] = QColor(settings.value("/colSuffix", "#7F0000").toString()); + mglColorScheme[5] = QColor(settings.value("/colNumber", "#0000FF").toString()); + mglColorScheme[6] = QColor(settings.value("/colACKeyword","#7F007F").toString()); + mglColorScheme[7] = QColor(settings.value("/colFCKeyword","#007F7F").toString()); + mglColorScheme[8] = QColor(settings.value("/colReserved", "#0000FF").toString()); + mglColorScheme[9] = QColor(settings.value("/colCurrLine", "#FFFFCC").toString()); + mglAutoSave = settings.value("/autoSave", false).toBool(); + mglHighlight = settings.value("/highlight", true).toBool(); + mglAutoPure = settings.value("/autoPure", true).toBool(); + mglAutoExecute = settings.value("/autoExec", true).toBool(); + editPosBottom = settings.value("/editAtTop", false).toBool(); + mglCompleter = settings.value("/completer", true).toBool(); + loadInNewWnd = settings.value("/loadInNewWnd", false).toBool(); + defFontFamily = settings.value("/fontFamily", "Georgia").toString(); + defFontSize = settings.value("/fontSize", 10).toInt(); + edit->setEditorFont(); setEditPos(editPosBottom); + graph->setMGLFont(pathFont); + + defWidth = settings.value("/defWidth", 640).toInt(); + defHeight = settings.value("/defHeight", 480).toInt(); + graph->mgl->setSize(defWidth, defHeight); + + recentFiles = settings.value("/recentFiles").toStringList(); + settings.endGroup(); + updateRecentFileItems(); +} +//----------------------------------------------------------------------------- +void MainWindow::setStatus(const QString &txt) +{ statusBar()->showMessage(txt, 5000); } +//----------------------------------------------------------------------------- +void MainWindow::setCurrentFile(const QString &fileName) +{ + filename = fileName; + mgl_set_plotid(graph->mgl->getGraph(), fileName.toStdString().c_str()); + edit->setModified(false); + if(filename.isEmpty()) + setWindowTitle(tr("untitled - UDAV")); + else + { + setWindowTitle(QFileInfo(filename).fileName()+tr(" - UDAV")); + int i = recentFiles.indexOf(filename); + if(i>=0) recentFiles.removeAt(i); + recentFiles.push_front(filename); + updateRecentFileItems(); + if(chdir(qPrintable(QFileInfo(filename).path()))) + QMessageBox::warning(this, tr("UDAV - save current"), + tr("Couldn't change to folder ")+QFileInfo(filename).path()); + } +} +//----------------------------------------------------------------------------- +void MainWindow::openRecentFile() +{ + QAction *a = qobject_cast(sender()); + if(!a) return; + if(edit->isModified()) + switch(QMessageBox::information(this, tr("UDAV - save current"), + tr("Do you want to save the changes to the document?"), + QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel)) + { + case QMessageBox::Yes: save(); break; + case QMessageBox::No: break; + default: return; + } + QString fn = recentFiles[a->data().toInt()]; + if(!fn.isEmpty()) load(fn); +} +//----------------------------------------------------------------------------- +void MainWindow::updateRecentFileItems() +{ + foreach(QWidget *w, QApplication::topLevelWidgets()) + { + MainWindow *wnd = qobject_cast(w); + if(wnd) wnd->updateRecent(); + } +} +//----------------------------------------------------------------------------- +void MainWindow::updateRecent() +{ + QAction *a; + fileMenu->clear(); qApp->processEvents(); + for(int i=0; iaddAction(text, this, SLOT(openRecentFile())); + a->setData(i); + } +} +//----------------------------------------------------------------------------- +void MainWindow::newDoc() +{ + MainWindow *ed = new MainWindow; + ed->show(); ed->activateWindow(); +} +//----------------------------------------------------------------------------- +void MainWindow::choose() +{ + if(edit->isModified()) + switch(QMessageBox::information(this, tr("UDAV - save current"), + tr("Do you want to save the changes to the document?"), + QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel)) + { + case QMessageBox::Yes: save(); break; + case QMessageBox::No: break; + default: return; + } + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + QString fn = QFileDialog::getOpenFileName(this, + tr("UDAV - Open file"), + settings.value("/filePath", MGL_DOC_DIR).toString(), + tr("MGL scripts (*.mgl)\nHDF5 files (*.hdf *.h5)\nText files (*.txt)\nData files (*.dat)\nAll files (*.*)")); + settings.endGroup(); + if(!fn.isEmpty()) load(fn); + else setStatus(tr("Loading aborted")); +} +//----------------------------------------------------------------------------- +void MainWindow::load(const QString &fileName, bool noNewWnd) +{ + // save current path + QFileInfo fi(fileName); filename = fileName; + QSettings settings("udav","UDAV"); + settings.setPath(QSettings::IniFormat, QSettings::UserScope, "UDAV"); + settings.beginGroup("/UDAV"); + settings.setValue("/filePath", fi.absolutePath()); + settings.endGroup(); + // open new window if it is required + if(loadInNewWnd && !noNewWnd) + { + MainWindow *mw = new MainWindow; + mw->edit->load(fileName); + mw->show(); //ed->activateWindow(); + } + else edit->load(fileName); +} +//----------------------------------------------------------------------------- +void MainWindow::save() +{ + if(filename.isEmpty()) saveAs(); + else edit->save(filename); +} +//----------------------------------------------------------------------------- +void MainWindow::saveAs() +{ + QString fn; + fn = QFileDialog::getSaveFileName(this, tr("UDAV - save file"), "", + tr("MGL scripts (*.mgl)\nHDF5 files (*.hdf *.h5)\nAll files (*.*)")); + if(fn.isEmpty()) + { setStatus(tr("Saving aborted")); return; } + else + { + int nn=fn.length(); + if(fn[nn-4]!='.' && fn[nn-3]!='.') fn = fn + ".mgl"; + filename = fn; save(); + } +} +//----------------------------------------------------------------------------- +void MainWindow::setAsterix() +{ + if(edit->isModified()) + { + if(filename.isEmpty()) + setWindowTitle(tr("untitled* - UDAV")); + else + setWindowTitle(QFileInfo(filename).fileName()+tr("* - UDAV")); + } + else + { + if(filename.isEmpty()) + setWindowTitle(tr("untitled - UDAV")); + else + setWindowTitle(QFileInfo(filename).fileName()+tr(" - UDAV")); + } +} +//----------------------------------------------------------------------------- +void updateDataItems() +{ + foreach (QWidget *w, QApplication::topLevelWidgets()) + if(w->inherits("MainWindow")) ((MainWindow *)w)->refresh(); +} +//----------------------------------------------------------------------------- +void MainWindow::addPanel(QWidget *w, QString name) +{ + ltab->addTab(w,QPixmap(":/xpm/x-office-spreadsheet.png"),name); + ltab->setCurrentWidget(w); +} +//----------------------------------------------------------------------------- +MainWindow *findMain(QWidget *wnd) +{ + MainWindow *mw=0; + QObject *w=wnd; + + while(w) + { + mw = dynamic_cast(w); + if(mw) break; else w = w->parent(); + } + return mw; +} +//----------------------------------------------------------------------------- +void raisePanel(QWidget *w) +{ + MainWindow *mw=findMain(w); + if(mw) mw->rtab->setCurrentWidget(w); +} +//----------------------------------------------------------------------------- diff --git a/udav/udav_wnd.h b/udav/udav_wnd.h new file mode 100644 index 0000000..1091d7d --- /dev/null +++ b/udav/udav_wnd.h @@ -0,0 +1,118 @@ +/*************************************************************************** + * Copyright (C) 2008 by Alexey Balakin * + * mathgl.abalakin@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef UDAV_WND_H +#define UDAV_WND_H +//----------------------------------------------------------------------------- +#include +//----------------------------------------------------------------------------- +#ifndef MGL_DOC_DIR +#ifdef WIN32 +#define MGL_DOC_DIR "" +#else +#define MGL_DOC_DIR "/usr/local/share/doc/mathgl/" +#endif +#endif +//----------------------------------------------------------------------------- +class QSplitter; +class QTabWidget; +class QMenu; +class QDockWidget; +class QTextEdit; +class TextPanel; +class PlotPanel; +//----------------------------------------------------------------------------- +extern int MaxRecentFiles; +extern int animDelay; +void udavShowHint(QWidget *); +void refreshMemPanel(QWidget *p); +void showExMGL(QWidget *hlp); +//----------------------------------------------------------------------------- +class MainWindow : public QMainWindow +{ +friend void raisePanel(QWidget *w); +Q_OBJECT +public: + QAction *ainfo, *acalc, *asave, *aload; + TextPanel *edit; + PlotPanel *graph; + QWidget *info; + QWidget *hlp; + MainWindow(QWidget *wp=0); + void load(const QString &fileName, bool noNewWnd=false); + void writeSettings(); + +public slots: + void setEditPos(bool bottom); + void editPosChanged(); + void refresh() { refreshMemPanel(info); } + void addPanel(QWidget *w, QString name); + +signals: + void gotoLine(int n,int i); + +protected: + void closeEvent ( QCloseEvent* ); + void dropEvent ( QDropEvent* ); + void dragEnterEvent( QDragEnterEvent* ); + +private slots: + void newDoc(); + void choose(); + void save(); + void saveAs(); + + void about(); + void aboutQt(); + void openRecentFile(); + void showHelp(); + + void messClicked(); + void properties(); + void setAsterix(); + void warnChanged(); + void showHint() { udavShowHint(this); } +// void showExamples() { showExMGL(hlp); } + + void setCurrentFile(const QString &); + void setStatus(const QString &txt); +// void animParse(const QString &txt); + +private: + static int num_wnd; + QTabWidget *ltab, *rtab; + QSplitter *split; + QTextEdit *mess; ///< messages and warnings + QString filename; + QMenu *fileMenu; + QDockWidget *messWnd, *calcWnd; + + void makeMenu(); + void makeDataMenu(); + void readSettings(); + QWidget *setupInfo(QWidget *par); + void updateRecentFileItems(); + void updateRecent(); +}; +//----------------------------------------------------------------------------- +MainWindow *findMain(QWidget *w); +void raisePanel(QWidget *w); +//----------------------------------------------------------------------------- +#endif +//----------------------------------------------------------------------------- diff --git a/udav/xpm/accessories-calculator.png b/udav/xpm/accessories-calculator.png new file mode 100644 index 0000000..9248971 Binary files /dev/null and b/udav/xpm/accessories-calculator.png differ diff --git a/udav/xpm/alpha.png b/udav/xpm/alpha.png new file mode 100644 index 0000000..fdb8836 Binary files /dev/null and b/udav/xpm/alpha.png differ diff --git a/udav/xpm/arrow_a.xpm b/udav/xpm/arrow_a.xpm new file mode 100644 index 0000000..457c0aa --- /dev/null +++ b/udav/xpm/arrow_a.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_a_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ... ", +" .... ", +" ..... ", +" ...... ", +" ...............", +" ...... ", +" ..... ", +" .... ", +" ... ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_d.xpm b/udav/xpm/arrow_d.xpm new file mode 100644 index 0000000..834f703 --- /dev/null +++ b/udav/xpm/arrow_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . ", +" ... ", +" ..... ", +" ....... ", +" ...............", +" ....... ", +" ..... ", +" ... ", +" . ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_i.xpm b/udav/xpm/arrow_i.xpm new file mode 100644 index 0000000..a8c617e --- /dev/null +++ b/udav/xpm/arrow_i.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_i_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ...............", +" .. ", +" .. ", +" .. ", +" .. ", +" .. ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_k.xpm b/udav/xpm/arrow_k.xpm new file mode 100644 index 0000000..840d325 --- /dev/null +++ b/udav/xpm/arrow_k.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_k_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" .. ... ", +" .. .... ", +" .. ..... ", +" ........ ", +" ...............", +" ........ ", +" .. ..... ", +" .. .... ", +" .. ... ", +" .. ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_n.xpm b/udav/xpm/arrow_n.xpm new file mode 100644 index 0000000..305238b --- /dev/null +++ b/udav/xpm/arrow_n.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_n_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ..............", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_o.xpm b/udav/xpm/arrow_o.xpm new file mode 100644 index 0000000..6f4b583 --- /dev/null +++ b/udav/xpm/arrow_o.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_o_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" .... ", +" ...... ", +" ........ ", +" ........ ", +" ..............", +" ........ ", +" ........ ", +" ....... ", +" .... ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_s.xpm b/udav/xpm/arrow_s.xpm new file mode 100644 index 0000000..ddeeb7f --- /dev/null +++ b/udav/xpm/arrow_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ........ ", +" ........ ", +" ........ ", +" ........ ", +" ..............", +" ........ ", +" ........ ", +" ........ ", +" ........ ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_t.xpm b/udav/xpm/arrow_t.xpm new file mode 100644 index 0000000..71ff9dc --- /dev/null +++ b/udav/xpm/arrow_t.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_t_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" ...............", +" ........ ", +" ...... ", +" .... ", +" .. ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/arrow_v.xpm b/udav/xpm/arrow_v.xpm new file mode 100644 index 0000000..038a3e5 --- /dev/null +++ b/udav/xpm/arrow_v.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * arrow_v_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ... ", +" .... ", +" ..... ", +" ...... ", +" ...........", +" ...... ", +" ..... ", +" .... ", +" ... ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/cons.xpm b/udav/xpm/cons.xpm new file mode 100644 index 0000000..b22b0f4 --- /dev/null +++ b/udav/xpm/cons.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * cons_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #0000FF", +"@ c #FF0000", +" ", +" .............. ", +" . . ", +" . . . . . . .. ", +" . . ", +" . . . . . . .. ", +" .............. ", +" ", +" +++++++++++++ ", +" +++++++++ ", +" +++++ ", +" + ", +" @@@@@@@@@@@@@@ ", +" @ @ @ @ @ @ @@ ", +" @@@@@@@@@@@@@@ ", +" "}; diff --git a/udav/xpm/crop.xpm b/udav/xpm/crop.xpm new file mode 100644 index 0000000..e18a730 --- /dev/null +++ b/udav/xpm/crop.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * crop_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . ", +" ", +" . ", +" ", +" . . ...... ", +" . . ", +" . . ", +" . . ", +" . . ", +" ...... . . ", +" ", +" . ", +" ", +" . ", +" "}; diff --git a/udav/xpm/dash_d.xpm b/udav/xpm/dash_d.xpm new file mode 100644 index 0000000..6892ce6 --- /dev/null +++ b/udav/xpm/dash_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +". . . . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_e.xpm b/udav/xpm/dash_e.xpm new file mode 100644 index 0000000..13eaf63 --- /dev/null +++ b/udav/xpm/dash_e.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_e_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +". . . . . . . . ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_i.xpm b/udav/xpm/dash_i.xpm new file mode 100644 index 0000000..2ad1f1c --- /dev/null +++ b/udav/xpm/dash_i.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_i_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".. . .. . .. . .", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_j.xpm b/udav/xpm/dash_j.xpm new file mode 100644 index 0000000..70a9cc4 --- /dev/null +++ b/udav/xpm/dash_j.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_j_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... . .... .", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_l.xpm b/udav/xpm/dash_l.xpm new file mode 100644 index 0000000..4346c08 --- /dev/null +++ b/udav/xpm/dash_l.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_l_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".... .... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_m.xpm b/udav/xpm/dash_m.xpm new file mode 100644 index 0000000..7cd2b39 --- /dev/null +++ b/udav/xpm/dash_m.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_m_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +".. .. .. .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dash_s.xpm b/udav/xpm/dash_s.xpm new file mode 100644 index 0000000..4edb6c5 --- /dev/null +++ b/udav/xpm/dash_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * dash_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +"................", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/dialog-information.png b/udav/xpm/dialog-information.png new file mode 100644 index 0000000..8851b99 Binary files /dev/null and b/udav/xpm/dialog-information.png differ diff --git a/udav/xpm/diff.xpm b/udav/xpm/diff.xpm new file mode 100644 index 0000000..b90448a --- /dev/null +++ b/udav/xpm/diff.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * diff_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .. ", +" . . . ", +" . . ", +" .... . ", +" . . . .. ", +" . . . . . ", +" .. . . ", +" . .... ", +" . . . ", +" . . . . .", +" . .. . ", +" . .", +" ", +" "}; diff --git a/udav/xpm/diff2.xpm b/udav/xpm/diff2.xpm new file mode 100644 index 0000000..7a2d7eb --- /dev/null +++ b/udav/xpm/diff2.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * diff2_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ", +" ", +" . ", +" .. ", +" .+.. ", +" +. ..+ ", +" . .. ", +" .+ +.. ", +" +. ..+ ", +" . .. ", +" .+ +.. ", +" ............ ", +" ", +" "}; diff --git a/udav/xpm/document-export.png b/udav/xpm/document-export.png new file mode 100644 index 0000000..eb82440 Binary files /dev/null and b/udav/xpm/document-export.png differ diff --git a/udav/xpm/document-import.png b/udav/xpm/document-import.png new file mode 100644 index 0000000..0b4e816 Binary files /dev/null and b/udav/xpm/document-import.png differ diff --git a/udav/xpm/document-new.png b/udav/xpm/document-new.png new file mode 100644 index 0000000..4c3efdd Binary files /dev/null and b/udav/xpm/document-new.png differ diff --git a/udav/xpm/document-open.png b/udav/xpm/document-open.png new file mode 100644 index 0000000..ab94046 Binary files /dev/null and b/udav/xpm/document-open.png differ diff --git a/udav/xpm/document-print.png b/udav/xpm/document-print.png new file mode 100644 index 0000000..35c37bd Binary files /dev/null and b/udav/xpm/document-print.png differ diff --git a/udav/xpm/document-properties.png b/udav/xpm/document-properties.png new file mode 100644 index 0000000..ab0e8ea Binary files /dev/null and b/udav/xpm/document-properties.png differ diff --git a/udav/xpm/document-save.png b/udav/xpm/document-save.png new file mode 100644 index 0000000..22ff495 Binary files /dev/null and b/udav/xpm/document-save.png differ diff --git a/udav/xpm/edit-copy.png b/udav/xpm/edit-copy.png new file mode 100644 index 0000000..8dd48c4 Binary files /dev/null and b/udav/xpm/edit-copy.png differ diff --git a/udav/xpm/edit-cut.png b/udav/xpm/edit-cut.png new file mode 100644 index 0000000..dc9eb9a Binary files /dev/null and b/udav/xpm/edit-cut.png differ diff --git a/udav/xpm/edit-delete.png b/udav/xpm/edit-delete.png new file mode 100644 index 0000000..184f762 Binary files /dev/null and b/udav/xpm/edit-delete.png differ diff --git a/udav/xpm/edit-find.png b/udav/xpm/edit-find.png new file mode 100644 index 0000000..d072d3c Binary files /dev/null and b/udav/xpm/edit-find.png differ diff --git a/udav/xpm/edit-paste.png b/udav/xpm/edit-paste.png new file mode 100644 index 0000000..24588a3 Binary files /dev/null and b/udav/xpm/edit-paste.png differ diff --git a/udav/xpm/edit-redo.png b/udav/xpm/edit-redo.png new file mode 100644 index 0000000..c3b0df0 Binary files /dev/null and b/udav/xpm/edit-redo.png differ diff --git a/udav/xpm/edit-select-all.png b/udav/xpm/edit-select-all.png new file mode 100644 index 0000000..f4b0b19 Binary files /dev/null and b/udav/xpm/edit-select-all.png differ diff --git a/udav/xpm/edit-undo.png b/udav/xpm/edit-undo.png new file mode 100644 index 0000000..8b0fef9 Binary files /dev/null and b/udav/xpm/edit-undo.png differ diff --git a/udav/xpm/film-b.png b/udav/xpm/film-b.png new file mode 100644 index 0000000..edccf1b Binary files /dev/null and b/udav/xpm/film-b.png differ diff --git a/udav/xpm/folder.png b/udav/xpm/folder.png new file mode 100644 index 0000000..65bd0bb Binary files /dev/null and b/udav/xpm/folder.png differ diff --git a/udav/xpm/format-indent-more.png b/udav/xpm/format-indent-more.png new file mode 100644 index 0000000..00309ea Binary files /dev/null and b/udav/xpm/format-indent-more.png differ diff --git a/udav/xpm/func.xpm b/udav/xpm/func.xpm new file mode 100644 index 0000000..e62cfe7 --- /dev/null +++ b/udav/xpm/func.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * func_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . . . ", +" . . . ", +" . . . ", +" ... . . . . ", +" . . . . . ", +" . . .. . ", +" . . .. . ", +" . . . . . ", +" . . . . . ", +" . . ", +" . . ", +" ", +" "}; diff --git a/udav/xpm/go-down.png b/udav/xpm/go-down.png new file mode 100644 index 0000000..3dd7fcc Binary files /dev/null and b/udav/xpm/go-down.png differ diff --git a/udav/xpm/go-first.png b/udav/xpm/go-first.png new file mode 100644 index 0000000..9c15c09 Binary files /dev/null and b/udav/xpm/go-first.png differ diff --git a/udav/xpm/go-last.png b/udav/xpm/go-last.png new file mode 100644 index 0000000..6e904ef Binary files /dev/null and b/udav/xpm/go-last.png differ diff --git a/udav/xpm/go-next-b.png b/udav/xpm/go-next-b.png new file mode 100644 index 0000000..1f48daf Binary files /dev/null and b/udav/xpm/go-next-b.png differ diff --git a/udav/xpm/go-next.png b/udav/xpm/go-next.png new file mode 100644 index 0000000..6ef8de7 Binary files /dev/null and b/udav/xpm/go-next.png differ diff --git a/udav/xpm/go-previous-b.png b/udav/xpm/go-previous-b.png new file mode 100644 index 0000000..7c8443a Binary files /dev/null and b/udav/xpm/go-previous-b.png differ diff --git a/udav/xpm/go-previous.png b/udav/xpm/go-previous.png new file mode 100644 index 0000000..659cd90 Binary files /dev/null and b/udav/xpm/go-previous.png differ diff --git a/udav/xpm/go-up.png b/udav/xpm/go-up.png new file mode 100644 index 0000000..fa9a7d7 Binary files /dev/null and b/udav/xpm/go-up.png differ diff --git a/udav/xpm/help-contents.png b/udav/xpm/help-contents.png new file mode 100644 index 0000000..b3ae2c3 Binary files /dev/null and b/udav/xpm/help-contents.png differ diff --git a/udav/xpm/help-faq.png b/udav/xpm/help-faq.png new file mode 100644 index 0000000..f6bc721 Binary files /dev/null and b/udav/xpm/help-faq.png differ diff --git a/udav/xpm/insert.xpm b/udav/xpm/insert.xpm new file mode 100644 index 0000000..e0143f1 --- /dev/null +++ b/udav/xpm/insert.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * insert_xpm[] = { +"16 16 4 1", +" c None", +". c #0000FF", +"# c #000000", +"w c #FFFFFF", +" ", +" ", +". ############ ", +".. #wwwwwwwwww# ", +"...#w########w# ", +"....wwwwwwwwww# ", +".....########w# ", +"......wwwwwwww# ", +".......######w# ", +"........wwwwww# ", +".......######w# ", +"......wwwwwwww# ", +".....########w# ", +"....wwwwwwwwww# ", +"...############ ", +".. "}; diff --git a/udav/xpm/integr.xpm b/udav/xpm/integr.xpm new file mode 100644 index 0000000..ddccb22 --- /dev/null +++ b/udav/xpm/integr.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * integr_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #808080", +" ", +" ", +" ", +" . ", +" . ", +" . . ", +" . . ", +" . . ", +" . ... . . ", +" . . . . ", +" . . . . ", +" . ... . . ", +" . + ", +" ", +" ", +" "}; diff --git a/udav/xpm/mark_.xpm b/udav/xpm/mark_.xpm new file mode 100644 index 0000000..b372f5a --- /dev/null +++ b/udav/xpm/mark_.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark__xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .. ", +" .. ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/mark_a.xpm b/udav/xpm/mark_a.xpm new file mode 100644 index 0000000..29f34cb --- /dev/null +++ b/udav/xpm/mark_a.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_a_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" ... ", +" .............. ", +" ... ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" ", +" "}; diff --git a/udav/xpm/mark_cf.xpm b/udav/xpm/mark_cf.xpm new file mode 100644 index 0000000..f743a31 --- /dev/null +++ b/udav/xpm/mark_cf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_cf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ...... ", +" .. .. ", +" . . ", +" . . ", +" . . ", +". .", +". .", +". .. .", +". .. .", +". .", +". .", +" . . ", +" . . ", +" . . ", +" .. .. ", +" ...... "}; diff --git a/udav/xpm/mark_d.xpm b/udav/xpm/mark_d.xpm new file mode 100644 index 0000000..678d75e --- /dev/null +++ b/udav/xpm/mark_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +". .", +". .", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .. "}; diff --git a/udav/xpm/mark_df.xpm b/udav/xpm/mark_df.xpm new file mode 100644 index 0000000..582d420 --- /dev/null +++ b/udav/xpm/mark_df.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_df_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .... ", +" ...... ", +" ........ ", +" .......... ", +" ............ ", +" .............. ", +"................", +"................", +" .............. ", +" ............ ", +" .......... ", +" ........ ", +" ...... ", +" .... ", +" .. "}; diff --git a/udav/xpm/mark_l.xpm b/udav/xpm/mark_l.xpm new file mode 100644 index 0000000..9edd3e0 --- /dev/null +++ b/udav/xpm/mark_l.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_l_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .. . ", +" . . ", +" .. . ", +" . . ", +" .. . ", +" . . ", +". . ", +". . ", +" . . ", +" .. . ", +" . . ", +" .. . ", +" . . ", +" .. . ", +" .. "}; diff --git a/udav/xpm/mark_lf.xpm b/udav/xpm/mark_lf.xpm new file mode 100644 index 0000000..2585eb4 --- /dev/null +++ b/udav/xpm/mark_lf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_lf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .... ", +" ..... ", +" ....... ", +" ........ ", +" .......... ", +" ........... ", +"............ ", +"............ ", +" ........... ", +" .......... ", +" ........ ", +" ....... ", +" ..... ", +" .... ", +" .. "}; diff --git a/udav/xpm/mark_n.xpm b/udav/xpm/mark_n.xpm new file mode 100644 index 0000000..efb363e --- /dev/null +++ b/udav/xpm/mark_n.xpm @@ -0,0 +1,20 @@ +/* XPM */ +static const char * mark_n_xpm[] = { +"16 16 1 1", +" c None", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/mark_o.xpm b/udav/xpm/mark_o.xpm new file mode 100644 index 0000000..3154cdc --- /dev/null +++ b/udav/xpm/mark_o.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_o_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ...... ", +" .. .. ", +" . . ", +" . . ", +" . . ", +". .", +". .", +". .", +". .", +". .", +". .", +" . . ", +" . . ", +" . . ", +" .. .. ", +" ...... "}; diff --git a/udav/xpm/mark_of.xpm b/udav/xpm/mark_of.xpm new file mode 100644 index 0000000..3eeaf38 --- /dev/null +++ b/udav/xpm/mark_of.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_of_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" .............. ", +"................", +"................", +"................", +"................", +"................", +"................", +" .............. ", +" .............. ", +" ............ ", +" .......... ", +" ...... "}; diff --git a/udav/xpm/mark_p.xpm b/udav/xpm/mark_p.xpm new file mode 100644 index 0000000..3f40cfb --- /dev/null +++ b/udav/xpm/mark_p.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_p_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +"................", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . "}; diff --git a/udav/xpm/mark_pf.xpm b/udav/xpm/mark_pf.xpm new file mode 100644 index 0000000..ea9cdac --- /dev/null +++ b/udav/xpm/mark_pf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_pf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +"................", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +"................", +". . .", +". . .", +". . .", +". . .", +". . .", +". . .", +"................"}; diff --git a/udav/xpm/mark_r.xpm b/udav/xpm/mark_r.xpm new file mode 100644 index 0000000..8459014 --- /dev/null +++ b/udav/xpm/mark_r.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_r_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" . .. ", +" . . ", +" . .. ", +" . . ", +" . .. ", +" . . ", +" . .", +" . .", +" . . ", +" . .. ", +" . . ", +" . .. ", +" . . ", +" . .. ", +" .. "}; diff --git a/udav/xpm/mark_rf.xpm b/udav/xpm/mark_rf.xpm new file mode 100644 index 0000000..cedcd01 --- /dev/null +++ b/udav/xpm/mark_rf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_rf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .... ", +" ..... ", +" ....... ", +" ........ ", +" .......... ", +" ........... ", +" ............", +" ............", +" ........... ", +" .......... ", +" ........ ", +" ....... ", +" ..... ", +" .... ", +" .. "}; diff --git a/udav/xpm/mark_s.xpm b/udav/xpm/mark_s.xpm new file mode 100644 index 0000000..1a4c012 --- /dev/null +++ b/udav/xpm/mark_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +"................", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +". .", +"................"}; diff --git a/udav/xpm/mark_sf.xpm b/udav/xpm/mark_sf.xpm new file mode 100644 index 0000000..5a89f1d --- /dev/null +++ b/udav/xpm/mark_sf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_sf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................", +"................"}; diff --git a/udav/xpm/mark_t.xpm b/udav/xpm/mark_t.xpm new file mode 100644 index 0000000..1e6b398 --- /dev/null +++ b/udav/xpm/mark_t.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_t_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +". .", +"................", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/mark_tf.xpm b/udav/xpm/mark_tf.xpm new file mode 100644 index 0000000..48f61c1 --- /dev/null +++ b/udav/xpm/mark_tf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_tf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" .. ", +" .... ", +" ...... ", +" ...... ", +" ........ ", +" .......... ", +" .......... ", +" ............ ", +" .............. ", +" .............. ", +"................", +"................", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/mark_v.xpm b/udav/xpm/mark_v.xpm new file mode 100644 index 0000000..9f03771 --- /dev/null +++ b/udav/xpm/mark_v.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_v_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +"................", +". .", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .. "}; diff --git a/udav/xpm/mark_vf.xpm b/udav/xpm/mark_vf.xpm new file mode 100644 index 0000000..39d7e99 --- /dev/null +++ b/udav/xpm/mark_vf.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_vf_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +"................", +"................", +" .............. ", +" .............. ", +" ............ ", +" .......... ", +" .......... ", +" ........ ", +" ...... ", +" ...... ", +" .... ", +" .. "}; diff --git a/udav/xpm/mark_x.xpm b/udav/xpm/mark_x.xpm new file mode 100644 index 0000000..8d7ee78 --- /dev/null +++ b/udav/xpm/mark_x.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_x_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +". .", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" .. ", +" .. ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +" . . ", +". ."}; diff --git a/udav/xpm/mark_y.xpm b/udav/xpm/mark_y.xpm new file mode 100644 index 0000000..b5135fd --- /dev/null +++ b/udav/xpm/mark_y.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * mark_y_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" . . ", +" . . ", +" . . ", +" . . ", +" ... ", +" . ", +" . ", +" . ", +" . ", +" . ", +" . ", +" ", +" ", +" "}; diff --git a/udav/xpm/media-seek-backward.png b/udav/xpm/media-seek-backward.png new file mode 100644 index 0000000..ffcac31 Binary files /dev/null and b/udav/xpm/media-seek-backward.png differ diff --git a/udav/xpm/media-seek-forward.png b/udav/xpm/media-seek-forward.png new file mode 100644 index 0000000..4d7e2cd Binary files /dev/null and b/udav/xpm/media-seek-forward.png differ diff --git a/udav/xpm/none.xpm b/udav/xpm/none.xpm new file mode 100644 index 0000000..e81575f --- /dev/null +++ b/udav/xpm/none.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * none_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +"................", +".. ..", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +". .. .", +". .. .", +". . . .", +". . . .", +". . . .", +". . . .", +". . . .", +".. ..", +"................"}; diff --git a/udav/xpm/object-rotate-right.png b/udav/xpm/object-rotate-right.png new file mode 100644 index 0000000..49e5727 Binary files /dev/null and b/udav/xpm/object-rotate-right.png differ diff --git a/udav/xpm/oper.xpm b/udav/xpm/oper.xpm new file mode 100644 index 0000000..ca6a51d --- /dev/null +++ b/udav/xpm/oper.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . ", +" . ", +" ..... ..... ", +" . ", +" . ", +" ", +" ", +" ", +" . . ", +" . . . . ", +" . ... ", +" . ... ", +" . . . . ", +" . . ", +" "}; diff --git a/udav/xpm/oper_a.xpm b/udav/xpm/oper_a.xpm new file mode 100644 index 0000000..afa1a80 --- /dev/null +++ b/udav/xpm/oper_a.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_a_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" . ", +" . ", +" . ...... ", +" ....... ", +" . ...... ", +" . ", +" . ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/oper_d.xpm b/udav/xpm/oper_d.xpm new file mode 100644 index 0000000..2b89d5e --- /dev/null +++ b/udav/xpm/oper_d.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_d_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . ", +" . ", +" . ", +" . ...... ", +" . ", +" . ...... ", +" . ", +" . ", +" . ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/oper_m.xpm b/udav/xpm/oper_m.xpm new file mode 100644 index 0000000..f2f8db1 --- /dev/null +++ b/udav/xpm/oper_m.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * oper_m_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ", +" ", +" . . ", +" +. .+ ", +" +.+ ...... ", +" ...... ", +" +.+ ...... ", +" +. .+ ", +" . . ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/oper_s.xpm b/udav/xpm/oper_s.xpm new file mode 100644 index 0000000..6bda134 --- /dev/null +++ b/udav/xpm/oper_s.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * oper_s_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ", +" ", +" ...... ", +" ....... ", +" ...... ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/option.xpm b/udav/xpm/option.xpm new file mode 100644 index 0000000..d7dd6d6 --- /dev/null +++ b/udav/xpm/option.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * option_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F0000", +" ", +" ", +" ", +" .. ", +" .++. ", +" .++. ", +" .. ", +" ", +" ", +" .. ", +" .++. ", +" .++. ", +" .+. ++ ++ ++ ", +" . ++ ++ ++ ", +" . ", +" "}; diff --git a/udav/xpm/plot.xpm b/udav/xpm/plot.xpm new file mode 100644 index 0000000..e6e79c1 --- /dev/null +++ b/udav/xpm/plot.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * plot_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #0000FF", +"@ c #FF0000", +" ", +" . ", +" .. + ", +" . ++ ", +" . + ", +" .. + ", +" . + ", +" . + ", +" .. @@@+ ", +" . @ +@ @ ", +" .@@ + @ @ ", +" .. + @@@ ", +" . ++ ", +" .++ . . . ", +" .............. ", +" "}; diff --git a/udav/xpm/preferences-system.png b/udav/xpm/preferences-system.png new file mode 100644 index 0000000..9460dfc Binary files /dev/null and b/udav/xpm/preferences-system.png differ diff --git a/udav/xpm/preview.xpm b/udav/xpm/preview.xpm new file mode 100644 index 0000000..0446109 --- /dev/null +++ b/udav/xpm/preview.xpm @@ -0,0 +1,193 @@ +/* XPM */ +static const char *preview_xpm[] = { +"16 16 174 2", +" c None", +". c #EA6E0E", +"+ c #F67F06", +"@ c #E3BB18", +"# c #A4E757", +"$ c #56E6A3", +"% c #25DAD6", +"& c #11E5EB", +"* c #2AF5D0", +"= c #72F588", +"- c #B0EC4B", +"; c #C7DC34", +"> c #C3E336", +", c #98F563", +"' c #3FF6BC", +") c #07D5F5", +"! c #0E9EEA", +"~ c #F44C0A", +"{ c #FC0E00", +"] c #FB1900", +"^ c #FF5B00", +"/ c #F7C407", +"( c #B5FD49", +"_ c #4BFFB3", +": c #0BF6F3", +"< c #05D9F9", +"[ c #0CD2F2", +"} c #14DEEB", +"| c #1BF0E3", +"1 c #20FEDE", +"2 c #27FFD7", +"3 c #2BFDD3", +"4 c #3BEEC3", +"5 c #F14F0A", +"6 c #FC1400", +"7 c #FB1700", +"8 c #FF5000", +"9 c #FBBA03", +"0 c #B8FD46", +"a c #39FCC5", +"b c #01CAFE", +"c c #0088FF", +"d c #0075FF", +"e c #008FFF", +"f c #01CCFE", +"g c #22FCDC", +"h c #73FF8B", +"i c #BAFC44", +"j c #D3E228", +"k c #F47B0A", +"l c #FF8C00", +"m c #F4BA0A", +"n c #CBE733", +"o c #7DFC81", +"p c #2BEDD3", +"q c #03C1FB", +"r c #0090FF", +"s c #0082FF", +"t c #009DFF", +"u c #08D4F7", +"v c #3AFAC4", +"w c #98FF66", +"x c #E7EF18", +"y c #FEBC01", +"z c #F4920A", +"A c #F4AD0B", +"B c #D4F62A", +"C c #63FD9B", +"D c #16D9E9", +"E c #0296FD", +"F c #0063FF", +"G c #0059FF", +"H c #0076FF", +"I c #00B6FF", +"J c #1AF2E4", +"K c #6EFF90", +"L c #C8FD36", +"M c #F9E306", +"N c #FFB900", +"O c #FFA800", +"P c #F4AF0B", +"Q c #EFBD0D", +"R c #A0FF5E", +"S c #1BF3E3", +"T c #009CFF", +"U c #0056FF", +"V c #0041FF", +"W c #005DFF", +"X c #00A0FF", +"Y c #0EEEF0", +"Z c #5FFF9F", +"` c #B7FF47", +" . c #F1FA0D", +".. c #F9E606", +"+. c #F0E70E", +"@. c #D4F42A", +"#. c #9CF05F", +"$. c #F4AA0A", +"%. c #DFF01F", +"&. c #8DFD71", +"*. c #4CF4B2", +"=. c #2DDFD1", +"-. c #21D5DE", +";. c #1CDFE2", +">. c #20F4DE", +",. c #3BFFC3", +"'. c #79FF85", +"). c #80FF7E", +"!. c #72FE8C", +"~. c #51FAAD", +"{. c #28EFD6", +"]. c #14CDEA", +"^. c #F4760A", +"/. c #FF6B00", +"(. c #FD6D00", +"_. c #F87A05", +":. c #F1910C", +"<. c #E9B615", +"[. c #D8DF26", +"}. c #B2FC4C", +"|. c #70FF8E", +"1. c #2DFED1", +"2. c #0BE3F3", +"3. c #04B9FB", +"4. c #0099FE", +"5. c #0085FF", +"6. c #007EFF", +"7. c #0A84F4", +"8. c #F1480A", +"9. c #EA0500", +"0. c #C50000", +"a. c #B30000", +"b. c #BB0100", +"c. c #DA0600", +"d. c #FA3500", +"e. c #FCB403", +"f. c #ACFD52", +"g. c #24F8DA", +"h. c #00A5FF", +"i. c #0036FF", +"j. c #0046FF", +"k. c #007FFF", +"l. c #11C0EA", +"m. c #F4440A", +"n. c #E10100", +"o. c #B20000", +"p. c #990000", +"q. c #9B0000", +"r. c #B90000", +"s. c #EB0500", +"t. c #FF6700", +"u. c #E9E716", +"v. c #75FF89", +"w. c #1EE7E0", +"x. c #09B9F6", +"y. c #06ACF8", +"z. c #11C6ED", +"A. c #38F0C6", +"B. c #8FF26F", +"C. c #E9630E", +"D. c #F43606", +"E. c #E92406", +"F. c #E02006", +"G. c #DE2006", +"H. c #F43706", +"I. c #F56806", +"J. c #F5A106", +"K. c #EBCC11", +"L. c #CED92D", +"M. c #B9DB41", +"N. c #B9DD43", +"O. c #C8D933", +"P. c #E3CE18", +"Q. c #E8AB10", +" ", +" ", +" ", +". + @ # $ % & * = - ; > , ' ) ! ", +"~ { ] ^ / ( _ : < [ } | 1 2 3 4 ", +"5 6 7 8 9 0 a b c d e f g h i j ", +"k l m n o p q r s t u v w x y z ", +"A B C D E F G H I J K L M N O P ", +"Q R S T U V W X Y Z ` ...+.@.#.", +"$.%.&.*.=.-.;.>.,.Z '.).!.~.{.].", +"^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.", +"8.9.0.a.b.c.d.e.f.g.h.U i.j.k.l.", +"m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.", +"C.D.E.F.G.E.H.I.J.K.L.M.N.O.P.Q.", +" ", +" "}; diff --git a/udav/xpm/process-stop.png b/udav/xpm/process-stop.png new file mode 100644 index 0000000..ab6808f Binary files /dev/null and b/udav/xpm/process-stop.png differ diff --git a/udav/xpm/size.xpm b/udav/xpm/size.xpm new file mode 100644 index 0000000..3a1d846 --- /dev/null +++ b/udav/xpm/size.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * size_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .............. ", +" . . . ", +" . ... . ", +" . . . ", +" . . . ", +" . . . . . ", +" .............. ", +" . . . . . ", +" . . . ", +" . . . ", +" . . . ", +" . ... . ", +" . . . ", +" .............. "}; diff --git a/udav/xpm/smth.xpm b/udav/xpm/smth.xpm new file mode 100644 index 0000000..a2b9d46 --- /dev/null +++ b/udav/xpm/smth.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * smth_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" ", +" ", +" ", +" ", +" . ", +" . ", +" . . . ", +" . . .. ", +" +++. . . ", +" +. ++ +++. ", +" . .++ ++ ", +" . . . .+ ", +" . . . . ", +" . ", +" . ", +" "}; diff --git a/udav/xpm/squize.xpm b/udav/xpm/squize.xpm new file mode 100644 index 0000000..fa68e6a --- /dev/null +++ b/udav/xpm/squize.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * squize_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #7F7F7F", +" ", +" ", +" ...... ", +" . . ", +" . . ", +" . . . . ", +" +. . . .+ ", +"...... ......", +" +. . . .+ ", +" . . . . ", +" . . ", +" . . ", +" . . ", +" ...... ", +" ", +" "}; diff --git a/udav/xpm/style.xpm b/udav/xpm/style.xpm new file mode 100644 index 0000000..9125d5f --- /dev/null +++ b/udav/xpm/style.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static const char * style_xpm[] = { +"16 16 3 1", +" c None", +". c #FF0000", +"q c #7F0000", +" ", +" ", +" ", +" qqq qqq ", +" q.q q.q ", +" q.q q.q ", +" q.q q.q ", +" q q ", +" q q ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/udav/xpm/sum.xpm b/udav/xpm/sum.xpm new file mode 100644 index 0000000..fc017ac --- /dev/null +++ b/udav/xpm/sum.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * sum_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" .......... ", +" . . ", +" . . ", +" . ", +" . ", +" . ", +" .. ", +" . ", +" . ", +" . ", +" . . ", +" . . ", +" .......... ", +" "}; diff --git a/udav/xpm/swap.xpm b/udav/xpm/swap.xpm new file mode 100644 index 0000000..6ad367c --- /dev/null +++ b/udav/xpm/swap.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * swap_xpm[] = { +"16 16 4 1", +" c None", +". c #0000FF", +"+ c #000000", +"@ c #FF0000", +" ", +" . .. ", +" . . ", +" . . ", +" . . ", +" ...... ", +" + + ", +" + + ", +" + + ", +" + + + + ", +" ++ @@@ ++ ", +" +++ @ @ +++ ", +" @ @ ", +" @ @ ", +" @@@ @@@ ", +" "}; diff --git a/udav/xpm/system-file-manager.png b/udav/xpm/system-file-manager.png new file mode 100644 index 0000000..60cade4 Binary files /dev/null and b/udav/xpm/system-file-manager.png differ diff --git a/udav/xpm/table.xpm b/udav/xpm/table.xpm new file mode 100644 index 0000000..43b33a4 --- /dev/null +++ b/udav/xpm/table.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static const char * table_xpm[] = { +"16 16 4 1", +" c None", +"# c #000000", +"o c #777777", +". c #FFFFFF", +" ", +" ###############", +" #ooo#oooo#oooo#", +" #ooo#oooo#oooo#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" #ooo#....#....#", +" #ooo#....#....#", +" ###############", +" ", +" "}; + diff --git a/udav/xpm/text-x-generic.png b/udav/xpm/text-x-generic.png new file mode 100644 index 0000000..2d7f2d6 Binary files /dev/null and b/udav/xpm/text-x-generic.png differ diff --git a/udav/xpm/tran.xpm b/udav/xpm/tran.xpm new file mode 100644 index 0000000..29fa1ee --- /dev/null +++ b/udav/xpm/tran.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * tran_xpm[] = { +"16 16 4 1", +" c None", +". c #000000", +"+ c #FF0000", +"@ c #0000FF", +" ", +" ", +" ......++++++++ ", +" . . + ", +" . . ..+ + + ++ ", +" . . + ", +" . . ..+ + + ++ ", +" .++++.++++++++ ", +" . . .. ", +" . . @ ", +" . . .. @@@ ", +" . . @ ", +" . . .. @ ", +" . . @@ ", +" . . .. @@@ ", +" ...... "}; diff --git a/udav/xpm/udav.png b/udav/xpm/udav.png new file mode 100644 index 0000000..76ba7d9 Binary files /dev/null and b/udav/xpm/udav.png differ diff --git a/udav/xpm/update.xpm b/udav/xpm/update.xpm new file mode 100644 index 0000000..5ee1dd6 --- /dev/null +++ b/udav/xpm/update.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char *update_xpm[] = { +"16 16 2 1", +" c None", +". c #00007F", +" ", +" ", +" .... ", +" . . ", +" . ..... ", +" . ... ", +" . ", +" ", +" ", +" . ", +" ... . ", +" ..... . ", +" . . ", +" .... ", +" ", +" "}; diff --git a/udav/xpm/view-refresh.png b/udav/xpm/view-refresh.png new file mode 100644 index 0000000..3fd71d6 Binary files /dev/null and b/udav/xpm/view-refresh.png differ diff --git a/udav/xpm/weather-clear.png b/udav/xpm/weather-clear.png new file mode 100644 index 0000000..7dc15ea Binary files /dev/null and b/udav/xpm/weather-clear.png differ diff --git a/udav/xpm/window.xpm b/udav/xpm/window.xpm new file mode 100644 index 0000000..28ac182 --- /dev/null +++ b/udav/xpm/window.xpm @@ -0,0 +1,29 @@ +/* XPM */ +static const char * window_xpm[] = { +"16 16 10 1", +" c None", +". c #000000", +"+ c #333377", +"@ c #FFFFFF", +"# c #777777", +"$ c #00007F", +"% c #4444FF", +"& c #FF0000", +"* c #007F00", +"= c #7F0000", +" ", +" ", +".............. ", +".++++++++++++. ", +".@@@@@#@@@@@@. ", +".@$.............", +".@@.%%%%%%%%%%%.", +".@$.@@@@@#@@@@@.", +".@@.@$$@@#@@@@@.", +".@$.@@@@@#@@@@@.", +".@@.@$&*@#@@@@@.", +"....@@@@@#@@@@@.", +" .@$&=@#@@@@@.", +" .@@@@@#@@@@@.", +" .............", +" "}; diff --git a/udav/xpm/wire.xpm b/udav/xpm/wire.xpm new file mode 100644 index 0000000..b67d50b --- /dev/null +++ b/udav/xpm/wire.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static const char * wire_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" . . ", +" . . ", +" . . ", +" ............ ", +" . . ", +" . . ", +" . . ", +" . . ", +" ............ ", +" . . ", +" . . ", +" . . ", +" "}; diff --git a/udav/xpm/x-office-presentation.png b/udav/xpm/x-office-presentation.png new file mode 100644 index 0000000..f7ea302 Binary files /dev/null and b/udav/xpm/x-office-presentation.png differ diff --git a/udav/xpm/x-office-spreadsheet.png b/udav/xpm/x-office-spreadsheet.png new file mode 100644 index 0000000..a6b1268 Binary files /dev/null and b/udav/xpm/x-office-spreadsheet.png differ diff --git a/udav/xpm/zoom-fit-best.png b/udav/xpm/zoom-fit-best.png new file mode 100644 index 0000000..eb28409 Binary files /dev/null and b/udav/xpm/zoom-fit-best.png differ diff --git a/udav/xpm/zoom-in.png b/udav/xpm/zoom-in.png new file mode 100644 index 0000000..31ac736 Binary files /dev/null and b/udav/xpm/zoom-in.png differ diff --git a/udav/xpm/zoom-original.png b/udav/xpm/zoom-original.png new file mode 100644 index 0000000..8e35414 Binary files /dev/null and b/udav/xpm/zoom-original.png differ diff --git a/udav/xpm/zoom-out.png b/udav/xpm/zoom-out.png new file mode 100644 index 0000000..df5be3c Binary files /dev/null and b/udav/xpm/zoom-out.png differ diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000..7b4e6b9 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,33 @@ + +add_executable(mglconv mglconv.cpp) +target_link_libraries(mglconv mgl) +install( + TARGETS mglconv + RUNTIME DESTINATION bin +) + +add_executable(mgl.cgi mglcgi.cpp) +target_link_libraries(mgl.cgi mgl) +install( + TARGETS mgl.cgi +# should be /usr/lib/cgi-bin/ + RUNTIME DESTINATION ${MGL_CGI_PATH} +) + +if(enable-qt) + add_executable(mglview mglview.cpp) + if(enable-qt5) + include(../cmake-qt5.txt) + target_link_libraries(mglview mgl-qt5) + qt5_use_modules(mglview Core Widgets Gui PrintSupport) + else(enable-qt5) + include(../cmake-qt4.txt) + target_link_libraries(mglview mgl-qt4) + target_link_libraries(mglview ${QT_LIBRARIES}) + endif(enable-qt5) + + install( + TARGETS mglview + RUNTIME DESTINATION bin + ) +endif(enable-qt) diff --git a/utils/make_forth.cpp b/utils/make_forth.cpp new file mode 100644 index 0000000..2504bc6 --- /dev/null +++ b/utils/make_forth.cpp @@ -0,0 +1,168 @@ +#include +#include + +const char *files[]={"../include/mgl2/base_cf.h","../include/mgl2/data_cf.h", "../include/mgl2/datac_cf.h", "../include/mgl2/cont.h", "../include/mgl2/fit.h", "../include/mgl2/plot.h", "../include/mgl2/surf.h", "../include/mgl2/volume.h", "../include/mgl2/vect.h", "../include/mgl2/prim.h", "../include/mgl2/other.h", "../include/mgl2/canvas_cf.h", "../include/mgl2/addon.h", ""}; + +const char *head="\\ Mathgl library wrapper\n\ +\\ Copyright (C) 2008-2013, Sergey Plis, Alexey Balakin\n\\\n\ +\\ This program is free software; you can redistribute it and/or modify\n\ +\\ it under the terms of the GNU General Public License as published by\n\ +\\ the Free Software Foundation; either version 2 of the License, or\n\ +\\ (at your option) any later version.\n\\\n\ +\\ This program is distributed in the hope that it will be useful,\n\ +\\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +\\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +\\ GNU General Public License for more details.\n\n\ +Module mathgl\n\ +library libmgl libmgl.so\n\ +library libmgl-glut libmgl-glut.so\n\ +library libmgl-fltk libmgl-fltk.so\n\ +library libmgl-qt libmgl-qt.so\n\ +library libmgl-wx libmgl-wx.so\n\ +legacy off\n\n\ +libmgl mgl_create_graph_gl\t\t(ptr)\tmgl_create_graph_gl\n\ +libmgl-glut mgl_create_graph_glut\tptr ptr ptr\t(ptr)\tmgl_create_graph_glut\n\ +libmgl-fltk mgl_create_graph_fltk\tptr ptr ptr\t(ptr)\tmgl_create_graph_fltk\n\ +libmgl-fltk mgl_fltk_run\t\t(void)\tmgl_fltk_run\n\ +libmgl-qt mgl_create_graph_qt\tptr ptr ptr\t(ptr)\tmgl_create_graph_qt\n\ +libmgl-qt mgl_qt_run\t\t\t(void)\tmgl_qt_run\n"; + +const char *parse_name(char *name, char *fnc) +{ + static char res[1024]; memset(res,0,1024); + char *ptr,*arg[20],nul=0; // TODO check if 20 arguments is enough + unsigned i; + for(i=0;name[i]!='(';i++) res[i]=name[i]; + memcpy(fnc,res,i); fnc[i]=0; // copy name for later + res[i]='\t'; i++; + for(int j=1;j<=(25-i)/4;j++) res[i+j-1]='\t'; + +/* static char res[1024]; + char *ptr,*arg[20],nul=0; // TODO check if 20 arguments is enough + unsigned i; + for(i=0;name[i]!='(';i++) res[i]=name[i]; + memcpy(fnc,res,i); fnc[i]=0; // copy name for later + res[i]='\t'; res[i+1]=0; i++;*/ + + while(name[i]<=' ') i++; + for(int j=0;j<20;j++) arg[j]=&nul; + for(int j=0;j<20;j++) + { + arg[j]= name[i]<=' ' ? name+i+1 : name+i; + ptr=strchr(name+i,','); + if(!ptr) break; + *ptr=0; i=ptr-name+1; + } + ptr=strchr(name+i,')'); if(ptr) *ptr=0; + for(int j=19;j>=0;j--) + { + if(arg[j][0]==0) continue; + if(!strncmp(arg[j],"HMGL ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"HADT ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"HCDT ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"HMDT ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"HMPR ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"HMEX ",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"const float *",13)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"const double *",14)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"mreal *",7)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"double *",8)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"char *",6)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"int *",5)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"long *",6)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"const char *",12)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"const wchar_t *",15)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"char ",5)) strcat(res, "char "); + else if(!strncmp(arg[j],"long ",5)) strcat(res, "int "); // TODO check + else if(!strncmp(arg[j],"uint32_t ",9)) strcat(res, "int "); // TODO check + else if(!strncmp(arg[j],"int ",4)) strcat(res, "int "); + else if(!strncmp(arg[j],"mreal ",6)) strcat(res, "sf "); // TODO check + else if(!strncmp(arg[j],"double ",7)) strcat(res, "double "); + else if(!strncmp(arg[j],"gsl_vector *",12)) strcat(res, "ptr "); + else if(!strncmp(arg[j],"gsl_matrix *",12)) strcat(res, "ptr "); + else sprintf(res, " !!! %s;", arg[j]); // NOTE should be never here + } + return res; +} + +bool parse_file(const char *fname, FILE *out) +{ + if(!fname || fname[0]==0) return false; + FILE *fp=fopen(fname,"rt"); + if(!fp) return false; + + char buf[1024], *ptr, fnc[128]=""; + while(!feof(fp)) + { + fgets(buf,1024,fp); + // first filter unwanted strings + if(buf[0]==0 || buf[0]=='\n' || buf[1]=='\n') continue; + if(buf[0]=='#' || buf[0]=='}') continue; + if(!strncmp(buf, "extern",6)) continue; + if(!strncmp(buf, "class",5)) continue; + if(!strncmp(buf, "struct",6)) continue; + if(!strncmp(buf, "typedef",7)) continue; + if(strstr(buf, "void *")) continue; + if(strstr(buf, "_(")) continue; + if(strstr(buf, "FILE")) continue; + if(strstr(buf, "TODO")) continue; + if(strstr(buf, "//")) continue; + if(strstr(buf, "...)")) continue; + + // TODO following 5 lines enable later + if(strstr(buf, "* const *")) continue; + if(strstr(buf, "uint64_t")) continue; + if(strstr(buf, "dual")) continue; + if(strstr(buf, "HADT")) continue; + if(strstr(buf, "HAEX")) continue; + + // now filter comments + if(buf[0]=='/' && buf[1]=='*') + { + do fgets(buf,1024,fp); while(!strstr(buf,"*/")); + continue; + } + ptr = strchr(buf,';'); if(ptr) *ptr=' '; + for(unsigned i=strlen(buf)-1;buf[i]<=' ';i--) buf[i]=0; + if(buf[0]=='/' && buf[1]=='/') + fprintf(out,"%s\n",buf); + else if(!strncmp(buf,"void MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(void)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"int MGL_EXPORT",14)) + fprintf(out,"libmgl %s\t(int)\t%s\n",parse_name(buf+15,fnc),fnc); + else if(!strncmp(buf,"double MGL_EXPORT",17)) + fprintf(out,"libmgl %s\t(double)\t%s\n",parse_name(buf+18,fnc),fnc); + else if(!strncmp(buf,"mreal MGL_EXPORT",16)) + fprintf(out,"libmgl %s\t(sf)\t%s\n",parse_name(buf+17,fnc),fnc); + else if(!strncmp(buf,"long MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(int)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"HMDT MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"HMGL MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"MGL_EXPORT const char *",23)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+24,fnc),fnc); + else if(!strncmp(buf,"MGL_EXPORT mreal *",18)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+19,fnc),fnc); + else if(!strncmp(buf,"MGL_EXPORT const unsigned char *",32)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+33,fnc),fnc); + else if(!strncmp(buf,"HMPR MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"HMEX MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+16,fnc),fnc); + else if(!strncmp(buf,"HADT MGL_EXPORT",15)) + fprintf(out,"libmgl %s\t(ptr)\t%s\n",parse_name(buf+16,fnc),fnc); + else fprintf(out,"!!!!\t%s\n",buf); // NOTE should be never here! + } + fclose(fp); + return true; +} + +int main() +{ + FILE *fout = fopen("../include/mgl2/mgl.fs","wt"); + fprintf(fout,"%s\n",head); + for(int i=0;parse_file(files[i],fout);i++); + fclose(fout); + return 0; +} diff --git a/utils/make_pas.cpp b/utils/make_pas.cpp new file mode 100644 index 0000000..b1ad6f2 --- /dev/null +++ b/utils/make_pas.cpp @@ -0,0 +1,473 @@ +#include +#include + +const char *files[] = +{ + "../include/mgl2/base_cf.h", + "../include/mgl2/data_cf.h", + "../include/mgl2/datac_cf.h", + "../include/mgl2/cont.h", + "../include/mgl2/fit.h", + "../include/mgl2/plot.h", + "../include/mgl2/surf.h", + "../include/mgl2/volume.h", + "../include/mgl2/vect.h", + "../include/mgl2/prim.h", + "../include/mgl2/other.h", + "../include/mgl2/canvas_cf.h", + "../include/mgl2/addon.h", + "" }; + +const char *head = + "//**************************************************************************\n\ +// mgl_pas.pas is part of Math Graphic Library *\n\ +// Copyright (C) 2008-2013 Mikhail Barg, Alexey Balakin *\n\ +// *\n\ +// This program is free software; you can redistribute it and/or modify *\n\ +// it under the terms of the GNU Library General Public License as *\n\ +// published by the Free Software Foundation; either version 2 of the *\n\ +// License, or (at your option) any later version. *\n\ +// *\n\ +// This program is distributed in the hope that it will be useful, *\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of *\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\n\ +// GNU General Public License for more details. *\n\ +// *\n\ +// You should have received a copy of the GNU Library General Public *\n\ +// License along with this program; if not, write to the *\n\ +// Free Software Foundation, Inc., *\n\ +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *\n\ +//**************************************************************************\n\n\ +unit mgl_pas;\n\n\ +{$IFDEF FPC}\n\ +{$MODE DELPHI }\n\ +{$PACKENUM 4} (* use 4-byte enums *)\n\ +{$PACKRECORDS C} (* C/C++-compatible record packing *)\n\ +{$ELSE}\n\ +{$MINENUMSIZE 4} (* use 4-byte enums *)\n\ +{$ENDIF}\n\n\ +{$IFDEF DARWIN}\n\ +{$linklib libmgl}\n\ +{$ENDIF}\n\n\ +interface\n\n\ +uses\n\ +{$IFDEF MSWINDOWS}\n\ +Windows, Graphics,\n\ +{$ENDIF}\n\ +Math;\n\n\ +const MGL_VER2 = 2.2;\n\ +//* This define enables double precision in MathGL */\n\ +MGL_USE_DOUBLE = 1;\n\n\ +const\n\ +{$IFDEF MSWINDOWS}\n\ +//win - .dll\n\ +libmgl = 'libmgl.dll';\n\ +libmglglut = 'libmgl-glut.dll';\n\ +libmglfltk = 'libmgl-fltk.dll';\n\ +libmglqt = 'libmgl-qt.dll';\n\ +{$ELSE}\n\ +{$IFDEF LINUX}\n\ +//linux - .so\n\ +libmgl = 'libmgl.so';\n\ +libmglglut = 'libmgl-glut.so';\n\ +libmglfltk = 'libmgl-fltk.so';\n\ +libmglqt = 'libmgl-qt.so';\n\ +{$ELSE}\n\ +{$IFDEF DARWIN}\n\ +//darwin - .dylib\n\ +libmgl = 'libmgl.dylib';\n\ +libmglglut = 'libmgl-glut.dylib';\n\ +libmglfltk = 'libmgl-fltk.dylib';\n\ +libmglqt = 'libmgl-qt.dylib';\n\ +{$ELSE}\n\ +// other platforms?\n\n\ +{$ENDIF}\n\ +{$ENDIF}\n\ +{$ENDIF}\n\n\ +{$IF (MGL_USE_DOUBLE = 0)}\n\ +type mreal = double;\n\ +{$ELSE}\n\ +type mreal = real;\n\ +{$IFEND}\n\ +{$IFDEF FPC}\n\ +{$ELSE}\n\ +type QWord = Int64;\n\ +{$ENDIF}\n\n\ +Pmreal = ^mreal;\n\n\ +type TNGLDraw = record\n\ +end;\n\ +type TMGLGraph = record\n\ +end;\n\ +type TMGLData = record\n\ +end;\n\ +type TMGLParse = record\n\ +end;\n\ +type TMGLFormula = record\n\ +end;\n\ +type TMGLFormulaC = record\n\ +end;\n\ +type TMGLDataC = record\n\ +end;\n\ +type HMDR = ^TNGLDraw;\n\ +type HMGL = ^TMGLGraph;\n\ +type HMDT = ^TMGLData;\n\ +type HMPR = ^TMGLParse;\n\ +type PPChar = ^PChar;\n\ +type HMEX = ^TMGLFormula;\n\ +type HAEX = ^TMGLFormulaC;\n\ +type HADT = ^TMGLDataC;\n\n\ +type Preal = ^single;\n\ +type Pdouble = ^double;\n\ +type Pint = ^integer;\n\ +type dual = record\n\ +re, im: mreal;\n\ +end;\n\ +type Pdual = ^dual;\n\ +type TGSLVector = record\n\ +end;\n\ +type TGSLMatrix = record\n\ +end;\n\ +type PGSLVector = ^TGSLVector;\n\ +type PGSLMatrix = ^TGSLMatrix;\n\n\ +type TMglDrawFunction = function (gr: HMGL; p: pointer): integer; cdecl;\n\ +function mgl_create_graph_gl(): HMGL; cdecl; external libmgl;\n\ +function mgl_create_graph_glut(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglglut;\n\ +function mgl_create_graph_fltk(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglfltk;\n\ +procedure mgl_fltk_run(); cdecl; external libmglfltk;\n\ +function mgl_create_graph_qt(draw: TMglDrawFunction; const title: PChar; par: pointer): HMGL; cdecl; external libmglqt;\n\ +procedure mgl_qt_run(); cdecl; external libmglqt;\n"; + + +const char *footer = +"\n\ +\n\ +{$IFDEF MSWINDOWS}\n\ +//*****************************************************************************/\n\ +// Delphi - specific\n\ +//*****************************************************************************/\n\ +procedure mgl_begin();\n\ +procedure mgl_end();\n\ +\n\ +procedure mgl_draw_on_canvas(gr: HMGL; width, height: integer; canvas: TCanvas; switchXY: boolean = false);\n\ +\n\ +implementation\n\ +\n\ +var _FPUCW: word;\n\ +\n\ +procedure mgl_begin();\n\ + begin\n\ + _FPUCW := Get8087CW(); // backup current FPU CW\n\ + Set8087CW(_FPUCW or $3F); // masking all FPU exceptions\n\ + end;\n\ +\n\ +procedure mgl_end();\n\ + begin\n\ + Set8087CW(_FPUCW); // restore old FPU CW\n\ + end;\n\ +\n\ +procedure mgl_draw_on_canvas(gr: HMGL; width, height: integer; canvas: TCanvas; switchXY: boolean = false);\n\ + var i, j: integer;\n\ + bytes: PByte;\n\ + col: TColor;\n\ + begin\n\ + bytes := mgl_get_rgb(gr);\n\ +\n\ + if (not switchXY) then\n\ + for j := 0 to height - 1 do\n\ + for i := 0 to width - 1 do\n\ + begin\n\ + col := 0;\n\ + col := col or (bytes^);\n\ + inc(bytes);\n\ + col := col or (bytes^) shl 8;\n\ + inc(bytes);\n\ + col := col or (bytes^) shl 16;\n\ + inc(bytes);\n\ + canvas.Pixels[i, j] := col;\n\ + end\n\ + else\n\ + for j := height - 1 downto 0 do\n\ + for i := 0 to width - 1 do\n\ + begin\n\ + col := 0;\n\ + col := col or (bytes^);\n\ + inc(bytes);\n\ + col := col or (bytes^) shl 8;\n\ + inc(bytes);\n\ + col := col or (bytes^) shl 16;\n\ + inc(bytes);\n\ + canvas.Pixels[j, i] := col;\n\ + end;\n\ + end;\n\ +\n\ +{$ENDIF}\n\ +end.\n"; + + +bool processArgument(char *dest, const char *arg, const char *prefix, const char *format) +{ + const int prefixLen = strlen(prefix); + if ( strncmp(arg, prefix, prefixLen) == 0 ) + { + char argname[32]; + strcpy(argname, arg + prefixLen); + if (strcmp(argname, "to") == 0) + { + int argNameLen = strlen(argname); + argname[argNameLen] = '_'; + argname[argNameLen + 1] = 0; + } + sprintf(dest, format, argname); + return true; + } + return false; +} + +const char *parse_name(char *name, bool &needOverload) +{ + const int MAX_ARG = 20; // TODO check if 20 arguments is enough + static char res[1024]; + char *ptr, *arg[MAX_ARG], nul = 0; + unsigned i, j; + needOverload = false; + for ( i = 0; name[i] != '('; ++i ) + { + res[i] = name[i]; + } + +// res[i] = 0; +// printf("'%s'\n", res); + + //TODO: special case, invent some general way to handle overloads, i.e. functions with same names. Still would require re-doing whole parser.. + if (strncmp(res, " mgl_expi", i - 1) == 0) + { + needOverload = true; + } + res[i] = '('; + res[i + 1] = 0; + ++i; + while ( name[i] <= ' ' ) + { + ++i; + } + for ( j = 0; j < MAX_ARG; ++j ) + { + arg[j] = &nul; + } + for ( j = 0; j < MAX_ARG; ++j ) + { + arg[j] = (name[i] <= ' ' ? name + i + 1 : name + i); + ptr = strchr(name + i, ','); + if ( !ptr ) + { + break; + } + *ptr = 0; + i = ptr - name + 1; + } + ptr = strchr(name + i, ')'); + if ( ptr ) + { + *ptr = 0; + } + if ( arg[0][0] == 0 ) + { + strcat(res, " "); + } + for ( j = 0; j < MAX_ARG; ++j ) + { + if ( arg[j][0] == 0 ) + { + break; + } + ptr = res + strlen(res); + if ( processArgument(ptr, arg[j], "HMGL ", "%s: HMGL;") + || processArgument(ptr, arg[j], "HCDT ", "const %s: HMDT;") + || processArgument(ptr, arg[j], "HMDT ", "%s: HMDT;") + || processArgument(ptr, arg[j], "HADT ", "%s: HADT;") + || processArgument(ptr, arg[j], "HAEX ", "%s: HAEX;") + || processArgument(ptr, arg[j], "HMPR ", "%s: HMPR;") + || processArgument(ptr, arg[j], "HMEX ", "%s: HMEX;") + || processArgument(ptr, arg[j], "const float *", "const %s: Preal;") + || processArgument(ptr, arg[j], "const double *", "const %s: Pdouble;") + || processArgument(ptr, arg[j], "mreal *", "%s: Pmreal;") + || processArgument(ptr, arg[j], "double *", "%s: Pdouble;") + || processArgument(ptr, arg[j], "char *", "%s: PChar;") + || processArgument(ptr, arg[j], "int *", "%s: Pint;") + || processArgument(ptr, arg[j], "long *", "%s: Pint;") + || processArgument(ptr, arg[j], "const char *", "const %s: PChar;") + || processArgument(ptr, arg[j], "const wchar_t *", "const %s: PWideChar;") + || processArgument(ptr, arg[j], "char ", "%s: char;") + || processArgument(ptr, arg[j], "long ", "%s: integer;") + || processArgument(ptr, arg[j], "uint32_t ", "%s: LongWord;") + || processArgument(ptr, arg[j], "uint64_t ", "%s: QWord;") + || processArgument(ptr, arg[j], "int ", "%s: integer;") + || processArgument(ptr, arg[j], "mreal ", "%s: mreal;") + || processArgument(ptr, arg[j], "const dual *", "const %s: Pdual;") + || processArgument(ptr, arg[j], "dual *", "%s: Pdual;") + || processArgument(ptr, arg[j], "dual ", "%s: dual;") + || processArgument(ptr, arg[j], "double ", "%s: double;") + || processArgument(ptr, arg[j], "gsl_vector *", "%s: PGSLVector;") + || processArgument(ptr, arg[j], "gsl_matrix *", "%s: PGSLMatrix;") + ) + { + //already procedded in processArgument + } + else + { + sprintf(ptr, " !!! %s;", arg[j]); + } + } + + i = strlen(res); + res[i - 1] = ')'; + return res; +} + +bool processDeclaration(FILE *out, char *declaration, const char *prefix, const char *format) +{ + const int prefixLen = strlen(prefix); + if ( strncmp(declaration, prefix, prefixLen) == 0 ) + { + bool needOverload = false; + fprintf(out, format, parse_name(declaration + prefixLen, needOverload)); + if (needOverload) + { + fprintf(out, "overload;\n"); + } + return true; + } + return false; +} + +bool parse_file(const char *fname, FILE *out) +{ + if ( !fname || fname[0] == 0 ) + { + return false; + } + FILE *fp = fopen(fname, "rt"); + if ( !fp ) + { + return false; + } + + fprintf(out, "{== %s ==}\n", fname); + + char buf[1024], *ptr; + while ( !feof(fp) ) + { + fgets(buf, 1024, fp); + // first filter unwanted strings + if ( buf[0] == 0 || buf[0] == '\n' || buf[1] == '\n' ) + { + continue; + } + if ( buf[0] == '#' || buf[0] == '}' ) + { + continue; + } + if ( !strncmp(buf, "extern", 6) ) + { + continue; + } + if ( !strncmp(buf, "class", 5) ) + { + continue; + } + if ( !strncmp(buf, "struct", 6) ) + { + continue; + } + if ( !strncmp(buf, "typedef", 7) ) + { + continue; + } + if ( strstr(buf, "void *") ) + { + continue; + } + if ( strstr(buf, "_(") ) + { + continue; + } + if ( strstr(buf, "FILE") ) + { + continue; + } + if ( strstr(buf, "TODO") ) + { + continue; + } + if ( strstr(buf, "...)") ) + { + continue; + } + + // TODO enable later + if ( strstr(buf, "* const *") ) + { + continue; + } + + // now filter comments + if ( buf[0] == '/' && buf[1] == '*' ) + { + do + { + fgets(buf, 1024, fp); + } + while ( !strstr(buf, "*/") ); + continue; + } + ptr = strchr(buf, ';'); + if ( ptr ) + { + *ptr = ' '; + } + for ( unsigned i = strlen(buf) - 1; buf[i] <= ' '; i-- ) + { + buf[i] = 0; + } + if ( buf[0] == '/' && buf[1] == '/' ) + { + fprintf(out, "%s\n", buf); + } + else if ( processDeclaration(out, buf, "void MGL_EXPORT", "procedure %s; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "int MGL_EXPORT", "function %s: integer; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "double MGL_EXPORT", "function %s: double; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "mreal MGL_EXPORT", "function %s: mreal; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "long MGL_EXPORT", "function %s: integer; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "dual MGL_EXPORT", "function %s: dual; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "MGL_EXPORT dual *", "function %s: PDual; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HMDT MGL_EXPORT", "function %s: HMDT; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HMGL MGL_EXPORT", "function %s: HMGL; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "MGL_EXPORT const char *", "function %s: PChar; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "MGL_EXPORT mreal *", "function %s: Pmreal; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "MGL_EXPORT const unsigned char *", "function %s: PByte; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HMPR MGL_EXPORT", "function %s: HMPR; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HMEX MGL_EXPORT", "function %s: HMEX; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HADT MGL_EXPORT", "function %s: HADT; cdecl; external libmgl;\n") + || processDeclaration(out, buf, "HAEX MGL_EXPORT", "function %s: HAEX; cdecl; external libmgl;\n") + ) + { + //already processed by processDeclaration + } + else + { + fprintf(out, "!!!!\t%s\n", buf); // NOTE should be never here! + } + } + fclose(fp); + return true; +} + +int main() +{ + FILE *fout = fopen("../include/mgl2/mgl_pas.pas", "wt"); + fprintf(fout, "%s\n", head); + for ( int i = 0; parse_file(files[i], fout); i++ ) {} + fprintf(fout, "%s\n", footer); + fclose(fout); + return 0; +} diff --git a/utils/mgl_test.html b/utils/mgl_test.html new file mode 100644 index 0000000..24edd50 --- /dev/null +++ b/utils/mgl_test.html @@ -0,0 +1,14 @@ + + + + + MathGL - library for scientific graphics + + + +

Enter script below

+
+
+

+ + diff --git a/utils/mglcgi.cpp b/utils/mglcgi.cpp new file mode 100644 index 0000000..bf333cc --- /dev/null +++ b/utils/mglcgi.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * mglcgi.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include "mgl2/mgl.h" +//----------------------------------------------------------------------------- +int mgl_hex(char ch) +{ + int res=-1; + if(ch>='0' && ch<='9') res = ch-'0'; + if(ch>='a' && ch<='f') res = ch-'a'+10; + if(ch>='A' && ch<='F') res = ch-'A'+10; + return res; +} +//----------------------------------------------------------------------------- +/// Parse CGI string buf and return usual string as val for given name. +/// The size of val should be the same as size of buf. +void mgl_get_value(const char *buf, const char *name, char *val) +{ + const char *pos = strstr(buf,name); + memset(val,0,strlen(buf)+1); + if(pos && (pos==buf || pos[-1]=='&')) + { + pos+=4; // shift for "mgl=" + register size_t i,j,l=strlen(pos); + for(i=j=0;i\n"); + printf("\n"); + printf("MathGL - library for scientific graphics\n\n"); + gr.WriteSVG("-"); fflush(stdout); + printf("\n");*/ + + printf("Content-Type: image/png\n\n"); gr.WritePNG("-"); + if(alloc) delete []buf; + return 0; +} +//----------------------------------------------------------------------------- diff --git a/utils/mglconv.cpp b/utils/mglconv.cpp new file mode 100644 index 0000000..4af827a --- /dev/null +++ b/utils/mglconv.cpp @@ -0,0 +1,134 @@ +/*************************************************************************** + * mglconv.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include "mgl2/mgl.h" +void mgl_error_print(const char *Message, void *par); +void mgl_ask_gets(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + mglGraph gr; + mglParse p(true); + char ch, buf[2048], iname[256]="", oname[256]=""; + std::vector var; + + register size_t i, n; + while(1) + { + ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:ho:L:C:A:"); + if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg); + else if(ch=='L') setlocale(LC_CTYPE, optarg); + else if(ch=='A') + { + std::wstring str; + for(i=0;optarg[i];i++) str.push_back(optarg[i]); + var.push_back(str); + } + else if(ch=='C') + { + double v1,v2,dv=1,v; + int res=sscanf(optarg,"%lg:%lg:%lg",&v1,&v2,&dv); + if(res<3) dv=1; + wchar_t num[64]; + for(v=v1;v<=v2;v+=dv) + { + mglprintf(num,64,L"%g",v); + var.push_back(num); + } + } + else if(ch=='h' || (ch==-1 && optind>=argc)) + { + printf("mglconv convert mgl script to bitmap png file.\nCurrent version is 2.%g\n",MGL_VER2); + printf("Usage:\tmglconv [parameter(s)] scriptfile\n"); + printf( + "\t-1 str set str as argument $1 for script\n" + "\t... ...\n" + "\t-9 str set str as argument $9 for script\n" + "\t-L loc set locale to loc\n" + "\t-o name set output file name\n" + "\t- get script from standard input\n" + "\t-A val add animation value val\n" + "\t-C n1:n2:dn add animation value in range [n1,n2] with step dn\n" + "\t-C n1:n2 add animation value in range [n1,n2] with step 1\n" + "\t- get script from standard input\n" + "\t-h print this message\n" ); + ch = 'h'; break; + } + else if(ch=='o') strncpy(oname, optarg,256); + else if(ch==-1 && optind1) // there is animation + { + if(gif) gr.StartGIF(oname); + for(i=0;i * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include + +#include "mgl2/mgl.h" +#include "mgl2/qt.h" +//----------------------------------------------------------------------------- +std::wstring str; +mglParse p(true); +void mgl_error_print(const char *Message, void *par); +void mgl_ask_fltk(const wchar_t *quest, wchar_t *res); +void mgl_ask_qt(const wchar_t *quest, wchar_t *res); +void mgl_ask_gets(const wchar_t *quest, wchar_t *res); +//----------------------------------------------------------------------------- +int show(mglGraph *gr) +{ + p.Execute(gr,str.c_str()); + printf("%s\n",gr->Message()); + return 0; +} +//----------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + char ch, iname[256]=""; + + while(1) + { + ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:ho:L:"); + if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg); + else if(ch=='L') setlocale(LC_CTYPE, optarg); + else if(ch=='h' || (ch==-1 && optind>=argc)) + { + printf("mglconv convert mgl script to bitmap png file.\nCurrent version is 2.%g\n",MGL_VER2); + printf("Usage:\tmglview [parameter(s)] scriptfile\n"); + printf( + "\t-1 str set str as argument $1 for script\n" + "\t... ...\n" + "\t-9 str set str as argument $9 for script\n" + "\t-L loc set locale to loc\n" + "\t- get script from standard input\n" + "\t-h print this message\n" ); + ch = 'h'; break; + } + else if(ch==-1 && optind * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +//#include +//----------------------------------------------------------------------------- +#ifdef USE_GETTEXT +#include +#else +// Workaround for gcc 4.2 +#ifndef _LIBINTL_H +#define gettext(x) (x) +#endif +#endif +//----------------------------------------------------------------------------- +#include "mgl2/canvas_wnd.h" +#include "mgl2/fltk.h" +//----------------------------------------------------------------------------- +#include "xpm/alpha_on.xpm" +#include "xpm/light_on.xpm" +#include "xpm/zoom_on.xpm" +#include "xpm/show_on.xpm" +#include "xpm/rotate_on.xpm" +#include "xpm/show_sl.xpm" +#include "xpm/next_sl.xpm" +#include "xpm/prev_sl.xpm" +#include "xpm/left_1.xpm" +#include "xpm/right_1.xpm" +#include "xpm/down_1.xpm" +#include "xpm/norm_1.xpm" +#include "xpm/zoom_1.xpm" +#include "xpm/up_1.xpm" +#include "xpm/alpha.xpm" +#include "xpm/light.xpm" +#include "xpm/zoom_in.xpm" +#include "xpm/zoom_out.xpm" +#include "xpm/rotate.xpm" +#include "xpm/ok.xpm" +#include "xpm/wire.xpm" +//----------------------------------------------------------------------------- +Fl_Pixmap xpm_a1(alpha_xpm), xpm_a2(alpha_on_xpm); +Fl_Pixmap xpm_l1(light_on_xpm), xpm_l2(light_xpm); +Fl_Pixmap xpm_z1(zoom_in_xpm), xpm_z2(zoom_on_xpm); +Fl_Pixmap xpm_s1(show_sl_xpm), xpm_s2(show_on_xpm); +Fl_Pixmap xpm_r1(rotate_xpm), xpm_r2(rotate_on_xpm); +Fl_Pixmap xpm_wire(wire_xpm); +//----------------------------------------------------------------------------- +/// Class allows the window creation for displaying plot bitmap with the help of FLTK library +/** NOTE!!! All frames are saved in memory. So animation with many frames require a lot memory and CPU time (for example, for mouse rotation).*/ +class mglCanvasFL : public mglCanvasWnd +{ +public: +using mglCanvasWnd::Window; + Fl_Window *Wnd; ///< Pointer to window + Fl_MGLView *mgl; ///< Pointer to MGL widget with buttons + + mglCanvasFL(); + ~mglCanvasFL(); + + /// Create a window for plotting. Now implemeted only for GLUT. + void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title, + void *par=NULL, void (*reload)(void *p)=NULL, bool maximize=false); + /// Switch on/off transparency (do not overwrite switches in user drawing function) + void ToggleAlpha(); + /// Switch on/off lighting (do not overwrite switches in user drawing function) + void ToggleLight(); + void ToggleRotate(); ///< Switch on/off rotation by mouse + void ToggleZoom(); ///< Switch on/off zooming by mouse + void ToggleNo(); ///< Switch off all zooming and rotation + void Update(); ///< Update picture by calling user drawing function + void Adjust(); ///< Adjust size of bitmap to window size + void GotoFrame(int d); ///< Show arbitrary frame (use relative step) + void Animation(); ///< Run animation (I'm too lasy to change it) +}; +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ask_fltk(const wchar_t *quest, wchar_t *res) +{ + static char buf[1024]; *res=0; +#if FL_MINOR_VERSION>=3 + fl_utf8fromwc(buf, 1024, quest, mgl_wcslen(quest)+1); + const char *str = fl_input("%s",buf,""); + if(str) fl_utf8towc(str, strlen(str)+1, res, 1024); +#else + wcstombs(buf,quest,mgl_wcslen(quest)+1); + const char *str = fl_input("%s",buf,""); + MGL_TO_WCS(str,wcscpy(res,str)); +#endif +} +//----------------------------------------------------------------------------- +// +// class Fl_MathGL +// +//----------------------------------------------------------------------------- +Fl_MathGL::Fl_MathGL(int xx, int yy, int ww, int hh, const char *lbl) : Fl_Widget(xx,yy,ww,hh,lbl) +{ + gr = new mglCanvas; + tet=phi=x1=y1=0; x2=y2=1; + zoom = rotate = false; + flag=x0=y0=xe=ye=0; + tet_val = phi_val = 0; + draw_par = 0; draw_func = 0; draw_cl = 0; +} +//----------------------------------------------------------------------------- +Fl_MathGL::~Fl_MathGL() { if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); } +//----------------------------------------------------------------------------- +void Fl_MathGL::set_graph(HMGL GR) +{ + mglCanvas *gg = dynamic_cast(GR); + if(!gg) return; + if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); + gr=gg; mgl_use_graph(gg,1); +} +//----------------------------------------------------------------------------- +void Fl_MathGL::draw() +{ + // TODO: add active points drawing here (from Qt) + const unsigned char *g = mgl_get_rgb(gr); + int i, ww=mgl_get_width(gr), hh=mgl_get_height(gr); + if(g) fl_draw_image(g, x(), y(), ww, hh, 3); + if(flag&4) + { + char str[5]="0.0"; + fl_color(192,192,192); + for(i=1;i<10;i++) + { + str[2] = '0'+10-i; fl_draw(str,30,30+i*hh/10); + fl_line(30,30+i*hh/10,30+ww,30+i*hh/10); + str[2] = '0'+i; fl_draw(str,30+i*ww/10,30+hh); + fl_line(30+i*ww/10,30,30+i*ww/10,30+hh); + } +// if(*MouseBuf) fl_draw(MouseBuf,30,50); + } +} +//----------------------------------------------------------------------------- +void Fl_MathGL::update() +{ + if(draw_func || draw_cl) + { + mgl_reset_frames(gr); + if(mgl_get_flag(gr,MGL_CLF_ON_UPD)) mgl_set_def_param(gr); + mgl_set_alpha(gr,flag&1); mgl_set_light(gr,flag&2); + if(tet_val) tet = tet_val->value(); + if(phi_val) phi = phi_val->value(); + mgl_zoom(gr,x1,y1,x2,y2); mgl_view(gr,phi,0,tet); + setlocale(LC_NUMERIC, "C"); + // use frames for quickly redrawing while adding/changing primitives + if(mgl_is_frames(gr)) mgl_new_frame(gr); + if(draw_func) draw_func(gr, draw_par); // drawing itself + else if(draw_cl) { mglGraph g(gr); draw_cl->Draw(&g); } + if(mgl_is_frames(gr)) mgl_end_frame(gr); + setlocale(LC_NUMERIC, ""); + const char *buf = mgl_get_mess(gr); + if(*buf) fl_message("%s",buf); + } + if(mgl_get_width(gr)!=w() || mgl_get_height(gr)!=h()) + size(mgl_get_width(gr), mgl_get_height(gr)); + redraw(); Fl::flush(); +} +//----------------------------------------------------------------------------- +void Fl_MathGL::resize(int xx, int yy, int ww, int hh) +{ Fl_Widget::resize(xx,yy,ww,hh); } +//----------------------------------------------------------------------------- +int Fl_MathGL::handle(int code) +{ + if(popup && code==FL_PUSH && Fl::event_button()==FL_RIGHT_MOUSE) + { + const Fl_Menu_Item *m = popup->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0); + if(m) m->do_callback(wpar, vpar); + } + else if(!zoom && !rotate && code==FL_PUSH && Fl::event_button()==FL_LEFT_MOUSE) + { + mglCanvasWnd *g=dynamic_cast(gr); + if(g && g->ClickFunc) g->ClickFunc(draw_par); + if(mgl_get_flag(gr,MGL_SHOW_POS)) + { + mglPoint p = gr->CalcXYZ(Fl::event_x()-x(), Fl::event_y()-y()); + if(g) g->LastMousePos = p; + char s[128]; + snprintf(s,128,"x=%g, y=%g, z=%g",p.x,p.y,p.z); + draw(); fl_color(FL_BLACK); fl_draw(s,40,70); + } + } + else if((!rotate && !zoom) || Fl::event_button()!=FL_LEFT_MOUSE) + { + if(code==FL_FOCUS || code==FL_UNFOCUS) return 1; + if(code==FL_KEYUP) + { + int key=Fl::event_key(); + if(!strchr(" .,wasdrfx",key)) return 0; + if(key==' ') { update(); return 1; } + if(key=='w') + { + tet += 10; + if(tet_val) tet_val->value(tet); + update(); return 1; + } + if(key=='s') + { + tet -= 10; + if(tet_val) tet_val->value(tet); + update(); return 1; + } + if(key=='a') + { + phi += 10; + if(phi_val) phi_val->value(phi); + update(); return 1; + } + if(key=='d') + { + phi -= 10; + if(phi_val) phi_val->value(phi); + update(); return 1; + } + if(key=='x') + { + mglCanvasFL *g=dynamic_cast(gr); + if(g && g->mgl->FMGL==this) + { g->Wnd->hide(); return 1; } + else return 0; +// exit(0); + } + if(key==',') + { + mglCanvasFL *g=dynamic_cast(gr); + if(g && g->mgl->FMGL==this) + { g->PrevFrame(); return 1; } + else return 0; + } + if(key=='.') + { + mglCanvasFL *g=dynamic_cast(gr); + if(g && g->mgl->FMGL==this) + { g->NextFrame(); return 1; } + else return 0; + } + if(key=='r') + { flag = (flag&2) + ((~(flag&1))&1); update(); return 1; } + if(key=='f') + { flag = (flag&1) + ((~(flag&2))&2); update(); return 1; } + } + return 0; + } + else if(code==FL_PUSH) { xe=x0=Fl::event_x(); ye=y0=Fl::event_y(); } + else if(code==FL_DRAG) + { + xe=Fl::event_x(); ye=Fl::event_y(); + mreal ff = 240./sqrt(mreal(w()*h())); + if(rotate) + { + phi += (x0-xe)*ff; + tet += (y0-ye)*ff; + if(phi>180) phi-=360; if(phi<-180) phi+=360; + if(tet>180) tet-=360; if(tet<-180) tet+=360; + if(tet_val) tet_val->value(tet); + if(phi_val) phi_val->value(phi); + x0 = xe; y0 = ye; + update(); + } + redraw(); + } + else if(code==FL_RELEASE) + { + if(zoom) + { + int w1=w(),h1=h(); + mreal _x1,_x2,_y1,_y2; + _x1 = x1+(x2-x1)*(x0-x())/mreal(w1); + _y1 = y2-(y2-y1)*(ye-y())/mreal(h1); + _x2 = x1+(x2-x1)*(xe-x())/mreal(w1); + _y2 = y2-(y2-y1)*(y0-y())/mreal(h1); + x1=_x1; x2=_x2; y1=_y1; y2=_y2; + if(x1>x2) { _x1=x1; x1=x2; x2=_x1; } + if(y1>y2) { _x1=y1; y1=y2; y2=_x1; } + update(); + } + else + { + if(tet_val) tet_val->value(tet); + if(phi_val) phi_val->value(phi); + } + redraw(); + } + return 1; +} +//----------------------------------------------------------------------------- +// +// class Fl_MGLView +// +//----------------------------------------------------------------------------- +void Fl_MGLView::toggle(int &val, Fl_Button *b, const char *txt) +{ + val = 1-val; b->value(val); + if(menu && txt && *txt) + { + Fl_Menu_Item *m = (Fl_Menu_Item *)menu->find_item(gettext(txt)); + if(m && val) m->set(); + if(m && !val) m->clear(); + } + update(); +} +//----------------------------------------------------------------------------- +void Fl_MGLView::setoff(int &val, Fl_Button *b, const char *txt) +{ + val = 0; b->value(val); + if(menu && txt && *txt) + { + Fl_Menu_Item *m = (Fl_Menu_Item *)menu->find_item(gettext(txt)); + if(m && val) m->set(); + if(m && !val) m->clear(); + } + //update(); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_grid_cb(Fl_Widget*, void* v) +{ if(v) ((Fl_MGLView*)v)->toggle_grid(); } +//------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_alpha_cb(Fl_Widget*, void* v) // alpha?xpm_a2:xpm_a1 +{ if(v) ((Fl_MGLView*)v)->toggle_alpha(); } +void mglCanvasFL::ToggleAlpha() { Fl::lock(); mgl->toggle_alpha(); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_light_cb(Fl_Widget*, void* v) // light?xpm_l2:xpm_l1 +{ if(v) ((Fl_MGLView*)v)->toggle_light(); } +void mglCanvasFL::ToggleLight() { Fl::lock(); mgl->toggle_light(); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_norm_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + e->setoff_rotate(); e->setoff_zoom(); + e->FMGL->tet_val->value(0); e->FMGL->phi_val->value(0); + e->FMGL->set_zoom(0,0,1,1); + e->update(); +} +void mglCanvasFL::ToggleNo() { Fl::lock(); mgl_norm_cb(0,mgl); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_zoom_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + e->setoff_rotate(); e->toggle_zoom(); +} +void mglCanvasFL::ToggleZoom() { Fl::lock(); mgl_zoom_cb(0,mgl); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_rotate_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + e->setoff_zoom(); e->toggle_rotate(); +} +void mglCanvasFL::ToggleRotate() { Fl::lock(); mgl_rotate_cb(0,mgl); Fl::unlock(); } +//----------------------------------------------------------------------------- +void Fl_MGLView::update() +{ + FMGL->set_state(zoom_bt->value(), rotate_bt->value()); + FMGL->set_flag(alpha + 2*light + 4*grid); + FMGL->update(); +} +void MGL_NO_EXPORT mgl_draw_cb(Fl_Widget*, void* v) +{ if(v) ((Fl_MGLView*)v)->update(); } +void mglCanvasFL::Update() { Fl::lock(); mgl->update(); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_png_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.png", 0); + if(!fname || !fname[0]) return; + mgl_write_png(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_bps_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.eps", 0); + if(!fname || !fname[0]) return; + mgl_write_bps(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_pngn_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.png", 0); + if(!fname || !fname[0]) return; + mgl_write_png_solid(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_jpeg_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.jpg", 0); + if(!fname || !fname[0]) return; + mgl_write_jpg(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_svg_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.svg", 0); + if(!fname || !fname[0]) return; + mgl_write_svg(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_eps_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.eps", 0); + if(!fname || !fname[0]) return; + mgl_write_eps(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_prc_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.prc", 0); + if(!fname || !fname[0]) return; + mgl_write_prc(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0,1); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_tex_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.tex", 0); + if(!fname || !fname[0]) return; + mgl_write_tex(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_obj_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.obj", 0); + if(!fname || !fname[0]) return; + mgl_write_obj(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0,1); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_off_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.off", 0); + if(!fname || !fname[0]) return; + mgl_write_off(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_export_stl_cb(Fl_Widget*, void* v) +{ + char *fname = fl_file_chooser(gettext("Save File As?"), "*.stl", 0); + if(!fname || !fname[0]) return; + mgl_write_stl(((Fl_MGLView*)v)->FMGL->get_graph(),fname,0); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_su_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (y2-y1)/3; y1 -= d; y2 -= d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sd_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (y2-y1)/3; y1 += d; y2 += d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sr_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (x2-x1)/3; x1 -= d; x2 -= d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sl_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (x2-x1)/3; x1 += d; x2 += d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sz_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (y2-y1)/4; y1 += d; y2 -= d; + d = (x2-x1)/4; x1 += d; x2 -= d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_so_cb(Fl_Widget*, void* v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; if(!e) return; + mreal x1,x2,y1,y2,d; + e->FMGL->get_zoom(&x1,&y1,&x2,&y2); + d = (y2-y1)/2; y1 -= d; y2 += d; + d = (x2-x1)/2; x1 -= d; x2 += d; + e->FMGL->set_zoom(x1,y1,x2,y2); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_adjust_cb(Fl_Widget*, void*v) +{ Fl_MGLView *e = (Fl_MGLView*)v; if(e) e->adjust(); } +void mglCanvasFL::Adjust() { Fl::lock(); mgl_adjust_cb(0,mgl); Fl::unlock(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_oncemore_cb(Fl_Widget*, void*v) +{ Fl_MGLView *e = (Fl_MGLView*)v; if(e && e->reload) e->reload(e->par); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_quit_cb(Fl_Widget*, void*) { Fl::first_window()->hide(); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_snext_cb(Fl_Widget*, void* v) +{ Fl_MGLView *e = (Fl_MGLView*)v; if(e && e->next) e->next(e->par); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sprev_cb(Fl_Widget*, void* v) +{ Fl_MGLView *e = (Fl_MGLView*)v; if(e && e->prev) e->prev(e->par); } +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_time_cb(void *v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; + if(!e || !e->is_sshow() || !e->next || !e->delay) return; + e->next(e->par); + Fl::repeat_timeout(e->delay(e->par), mgl_time_cb, v); +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_sshow_cb(Fl_Widget *, void *v) +{ + Fl_MGLView *e = (Fl_MGLView*)v; + if(!e || !e->delay || !e->next) return; + e->toggle_sshow(); + if(e->is_sshow()) Fl::add_timeout(e->delay(e->par), mgl_time_cb, v); +} +void mglCanvasFL::Animation() { Fl::lock(); mgl_sshow_cb(0,mgl); Fl::unlock(); } +void MGL_NO_EXPORT mgl_no_cb(Fl_Widget *, void *) {} +//----------------------------------------------------------------------------- +Fl_Menu_Item pop_graph[20] = { + { gettext("Export"), 0, mgl_no_cb, 0, FL_SUBMENU,0,0,0,0}, + { gettext("... as PNG"), 0, mgl_export_png_cb,0,0,0,0,0,0 }, + { gettext("... as PNG (solid)"), 0, mgl_export_pngn_cb,0,0,0,0,0,0 }, + { gettext("... as JPEG"), 0, mgl_export_jpeg_cb,0,0,0,0,0,0 }, + { gettext("... as SVG"), 0, mgl_export_svg_cb,0,0,0,0,0,0 }, + { gettext("... as vector EPS"), 0, mgl_export_eps_cb,0,0,0,0,0,0 }, + { gettext("... as bitmap EPS"), 0, mgl_export_bps_cb, 0, FL_MENU_DIVIDER,0,0,0,0 }, + { gettext("... as TeX"), 0, mgl_export_tex_cb,0,0,0,0,0,0 }, + { gettext("... as OBJ"), 0, mgl_export_obj_cb,0,0,0,0,0,0 }, + { gettext("... as PRC"), 0, mgl_export_prc_cb,0,0,0,0,0,0 }, + { gettext("... as OFF"), 0, mgl_export_off_cb,0,0,0,0,0,0 }, + { gettext("... as STL"), 0, mgl_export_stl_cb,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0 }, + { gettext("Copy graphics"), 0, 0, 0, FL_MENU_INACTIVE|FL_MENU_DIVIDER,0,0,0,0}, + { gettext("Normal view"), 0, mgl_norm_cb,0,0,0,0,0,0 }, + { gettext("Redraw plot"), 0, mgl_draw_cb,0,0,0,0,0,0 }, + { gettext("Adjust size"), 0, mgl_adjust_cb,0,0,0,0,0,0 }, + { gettext("Reload data"), 0, mgl_oncemore_cb,0,0,0,0,0,0 }, + { 0,0,0,0,0,0,0,0,0 } +}; +//----------------------------------------------------------------------------- +Fl_MGLView::Fl_MGLView(int xx, int yy, int ww, int hh, const char *lbl) : Fl_Window(xx,yy,ww,hh,lbl) +{ + grid = alpha = light = sshow = 0; menu = 0; + next = prev = reload = NULL; delay = NULL; + + Fl_Button *o; + Fl_Group *g = new Fl_Group(0,30,435,30); + + alpha_bt = new Fl_Button(0, 1, 25, 25); alpha_bt->type(FL_TOGGLE_BUTTON); + alpha_bt->image(xpm_a1); alpha_bt->callback(mgl_alpha_cb,this); + alpha_bt->tooltip(gettext("Switch on/off transparency in the picture")); +// alpha_bt->box(FL_PLASTIC_UP_BOX); alpha_bt->down_box(FL_PLASTIC_DOWN_BOX); + light_bt = new Fl_Button(25, 1, 25, 25); light_bt->type(FL_TOGGLE_BUTTON); + light_bt->image(xpm_l1); light_bt->callback(mgl_light_cb,this); + light_bt->tooltip(gettext("Switch on/off lightning in the picture")); +// light_bt->box(FL_PLASTIC_UP_BOX); light_bt->down_box(FL_PLASTIC_DOWN_BOX); + grid_bt = new Fl_Button(50, 1, 25, 25); grid_bt->type(FL_TOGGLE_BUTTON); + grid_bt->image(xpm_wire); grid_bt->callback(mgl_grid_cb,this); + grid_bt->tooltip(gettext("Switch on/off grid drawing")); + // grid_bt->box(FL_PLASTIC_UP_BOX); grid_bt->down_box(FL_PLASTIC_DOWN_BOX); + + rotate_bt = new Fl_Button(80, 1, 25, 25);rotate_bt->type(FL_TOGGLE_BUTTON); + rotate_bt->image(xpm_r1); rotate_bt->callback(mgl_rotate_cb,this); + rotate_bt->tooltip(gettext("Rotate picture by holding left mouse button")); +// rotate_bt->box(FL_PLASTIC_UP_BOX); rotate_bt->down_box(FL_PLASTIC_DOWN_BOX); + zoom_bt = new Fl_Button(105, 1, 25, 25); zoom_bt->type(FL_TOGGLE_BUTTON); + zoom_bt->image(xpm_z1); zoom_bt->callback(mgl_zoom_cb,this); + zoom_bt->tooltip(gettext("Zoom in selected region of the picture")); +// zoom_bt->box(FL_PLASTIC_UP_BOX); zoom_bt->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(130, 1, 25, 25); o->tooltip(gettext("Return picture to normal zoom")); + o->image(new Fl_Pixmap(zoom_out_xpm)); o->callback(mgl_norm_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(160, 1, 25, 25); o->tooltip(gettext("Refresh the picture")); + o->image(new Fl_Pixmap(ok_xpm)); o->callback(mgl_draw_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + Fl_Counter *tet, *phi; + tet = new Fl_Counter(195, 1, 90, 25, 0); tet->callback(mgl_draw_cb,this); + phi = new Fl_Counter(290, 1, 90, 25, 0); phi->callback(mgl_draw_cb,this); + tet->lstep(10); tet->step(1); tet->range(-180,180); + tet->tooltip(gettext("Theta angle (tilt z-axis)")); + phi->lstep(10); phi->step(1); phi->range(-180,180); + phi->tooltip(gettext("Phi angle (rotate in x*y plane)")); +// tet->box(FL_PLASTIC_UP_BOX); phi->box(FL_PLASTIC_UP_BOX); + g->end(); g->resizable(0); + + g = new Fl_Group(0,30,30,260); + o = new Fl_Button(1, 30, 25, 25); o->tooltip(gettext("Shift the picture up")); + o->image(new Fl_Pixmap(up_1_xpm)); o->callback(mgl_su_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 55, 25, 25); o->tooltip(gettext("Shift the picture left")); + o->image(new Fl_Pixmap(left_1_xpm)); o->callback(mgl_sl_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 80, 25, 25); o->tooltip(gettext("Zoom in the picture")); + o->image(new Fl_Pixmap(zoom_1_xpm)); o->callback(mgl_sz_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 105, 25, 25); o->tooltip(gettext("Zoom out the picture")); + o->image(new Fl_Pixmap(norm_1_xpm)); o->callback(mgl_so_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 130, 25, 25); o->tooltip(gettext("Shift the picture right")); + o->image(new Fl_Pixmap(right_1_xpm)); o->callback(mgl_sr_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 155, 25, 25); o->tooltip(gettext("Shift the picture down")); + o->image(new Fl_Pixmap(down_1_xpm)); o->callback(mgl_sd_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + o = new Fl_Button(1, 185, 25, 25); o->tooltip(gettext("Show previous frame in slideshow")); + o->image(new Fl_Pixmap(prev_sl_xpm)); o->callback(mgl_sprev_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + anim_bt = new Fl_Button(1, 210, 25, 25); anim_bt->type(FL_TOGGLE_BUTTON); + anim_bt->image(xpm_s1); anim_bt->callback(mgl_sshow_cb,this); + anim_bt->tooltip(gettext("Run/Stop slideshow (graphics animation)")); +// anim_bt->box(FL_PLASTIC_UP_BOX); anim_bt->down_box(FL_PLASTIC_DOWN_BOX); + o = new Fl_Button(1, 235, 25, 25); o->tooltip(gettext("Show next frame in slideshow")); + o->image(new Fl_Pixmap(next_sl_xpm)); o->callback(mgl_snext_cb,this); +// o->box(FL_PLASTIC_UP_BOX); o->down_box(FL_PLASTIC_DOWN_BOX); + + g->end(); g->resizable(0); + + scroll = new Fl_Scroll(30, 30, 800, 600); + //scroll->begin(); + FMGL = new Fl_MathGL(30, 30, 800, 600); + FMGL->tet_val = tet; + FMGL->phi_val = phi; + FMGL->set_popup(pop_graph,FMGL,this); + scroll->end(); + resizable(scroll); end(); +} +Fl_MGLView::~Fl_MGLView() {} +//----------------------------------------------------------------------------- +// +// class mglCanvasFL +// +//----------------------------------------------------------------------------- +mglCanvasFL::mglCanvasFL() : mglCanvasWnd() { Wnd=0; } +mglCanvasFL::~mglCanvasFL() { if(Wnd) delete Wnd; } +//----------------------------------------------------------------------------- +void mglCanvasFL::GotoFrame(int d) +{ + int f = GetCurFig()+d; + if(f>=GetNumFig()) f = 0; + if(f<0) f = GetNumFig()-1; + if(GetNumFig()>0 && d) { SetCurFig(f); mgl->FMGL->redraw(); } +} +//----------------------------------------------------------------------------- +void MGL_NO_EXPORT mgl_fl_next(void *v) { ((mglCanvasWnd*)v)->NextFrame(); } ///< Callback function for next frame +void MGL_NO_EXPORT mgl_fl_prev(void *v) { ((mglCanvasWnd*)v)->PrevFrame(); } ///< Callback function for prev frame +void MGL_NO_EXPORT mgl_fl_reload(void *v) { ((mglCanvasWnd*)v)->ReLoad(); } ///< Callback function for reloading +mreal MGL_NO_EXPORT mgl_fl_delay(void *v) { return ((mglCanvasWnd*)v)->GetDelay(); } ///< Callback function for delay +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_makemenu_fltk(Fl_Menu_ *m, Fl_MGLView *w) +{ + m->add("Graphics/Alpha", "^t", mgl_alpha_cb, w, FL_MENU_TOGGLE); + m->add("Graphics/Light", "^l", mgl_light_cb, w, FL_MENU_TOGGLE); + m->add("Graphics/Grid", "^g", mgl_grid_cb, w, FL_MENU_TOGGLE|FL_MENU_DIVIDER); + + m->add("Graphics/Restore", "^ ", mgl_norm_cb, w); + m->add("Graphics/Redraw", "f5", mgl_draw_cb, w); + m->add("Graphics/Adjust size", "f6", mgl_adjust_cb, w); + m->add("Graphics/Reload data", "f9", mgl_oncemore_cb, w); + //TODO m->add("Graphics/Stop", "f7", mgl_stop_cb, w); + //TODO m->add("Graphics/Copy graphics","+^c", mgl_copyimg_cb, w); + + m->add("Graphics/Export/as PNG", "#p", mgl_export_png_cb, w); + m->add("Graphics/Export/as solid PNG", "#f", mgl_export_pngn_cb, w); + m->add("Graphics/Export/as JPEG", "#j", mgl_export_jpeg_cb, w); + m->add("Graphics/Export/as SVG", "#s", mgl_export_svg_cb, w); + m->add("Graphics/Export/as vector EPS", "#e", mgl_export_eps_cb, w); + m->add("Graphics/Export/as bitmap EPS", "", mgl_export_bps_cb, w); + + m->add("Graphics/Animation/Slideshow", "^f5", mgl_sshow_cb, w, FL_MENU_TOGGLE); + m->add("Graphics/Animation/Next frame", "#<", mgl_snext_cb, w); + m->add("Graphics/Animation/Prev frame", "#>", mgl_sprev_cb, w); + //TODO m->add("Graphics/Animation/Setup", "", mgl_ssetup_cb, w); +} +//----------------------------------------------------------------------------- +void mglCanvasFL::Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title, void *par, void (*reload)(void *p), bool maximize) +{ + Fl::lock(); + SetDrawFunc(draw, par, reload); + if(Wnd) { Wnd->label(title); Wnd->show(); return; } + + Wnd = new Fl_Double_Window(830,660,title); + + mgl = new Fl_MGLView(0,30,830,630); mgl->par = this; + + mgl->menu = new Fl_Menu_Bar(0, 0, 830, 30); + mgl_makemenu_fltk(mgl->menu, mgl); + + mgl->next = mgl_fl_next; mgl->reload = mgl_fl_reload; + mgl->prev = mgl_fl_prev; mgl->delay= mgl_fl_delay; + mgl->FMGL->set_graph(this); + mgl->FMGL->set_draw(draw, par); + + Wnd->end(); + Wnd->resizable(mgl); //w->graph); + + if(maximize) + { + int x,y,w,h; + Fl::screen_xywh(x,y,w,h); + Wnd->resize(x,y,w,h); + Adjust(); + } + + char *tmp[1]; tmp[0]=new char[1]; tmp[0][0]=0; + Wnd->show(argv ? argc:0, argv ? argv:tmp); + delete []tmp[0]; +} +//----------------------------------------------------------------------------- +HMGL MGL_EXPORT mgl_create_graph_fltk(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)) +{ + mglCanvasFL *g = new mglCanvasFL; + g->Window(0,0,draw,title,par,load); + return g; +} +int MGL_EXPORT mgl_fltk_run() { return Fl::run(); } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_graph_fltk_(const char *title, int l) +{ + char *s = new char[l+1]; memcpy(s,title,l); s[l]=0; + uintptr_t t = uintptr_t(mgl_create_graph_fltk(0,s,0,0)); + delete []s; return t; +} +int MGL_EXPORT mgl_fltk_run_() { return mgl_fltk_run(); } +//----------------------------------------------------------------------------- +MGL_NO_EXPORT void *mgl_fltk_tmp(void *) +{ mgl_fltk_run(); return 0; } +//----------------------------------------------------------------------------- +int MGL_EXPORT mgl_fltk_thr() // NOTE: Qt couldn't be running in non-primary thread +{ +#if MGL_HAVE_PTHREAD + static pthread_t thr; + pthread_create(&thr,0,mgl_fltk_tmp,0); + pthread_detach(thr); +#endif + return 0; // stupid, but I don't want keep result returned by Fl::Run() +} +//----------------------------------------------------------------------------- diff --git a/widgets/glut.cpp b/widgets/glut.cpp new file mode 100644 index 0000000..2ecd8c0 --- /dev/null +++ b/widgets/glut.cpp @@ -0,0 +1,270 @@ +/*************************************************************************** + * glut.cpp is part of Math Graphic Library + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#define GLUT_NO_LIB_PRAGMA +#define GLUT_NO_WARNING_DISABLE + +#ifdef __APPLE__ + #include + #include +#else + #if defined(_MSC_VER) || defined(__BORLANDC__) + #include + #include + #include "glut.h" + #else + #include + #include + #endif +#endif + +#include "mgl2/opengl.h" +#include "mgl2/glut.h" + +void _mgl_key_up(unsigned char ch,int ,int ); +//----------------------------------------------------------------------------- +/// Class allows the window creation under OpenGL with the help of GLUT library +class mglCanvasGLUT : public mglCanvasGL +{ +friend void _mgl_display(); +friend void _mgl_key_up(unsigned char ch,int ,int ); +friend void _mgl_timer(int); +public: + mglCanvasGLUT(); + virtual ~mglCanvasGLUT(); + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ��������� ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /// Create a window for plotting. Now implemeted only for GLUT. + void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), + const char *title,void *par=NULL, + void (*reload)(void *p)=NULL, bool maximize=false); + void Window(int argc, char **argv, int (*draw)(mglGraph *gr), + const char *title, bool maximize=false) + { Window(argc,argv,draw?mgl_draw_graph:0,title,(void*)draw,0,maximize); } + /// Create a window for plotting based on class mglDraw. + void Window(int argc, char **argv, const char *title, mglDraw *draw, bool maximize=false) + { Window(argc, argv, draw?mgl_draw_class:0, title, draw, mgl_reload_class, maximize); } + /// Switch on/off transparency (do not overwrite switches in user drawing function) + void ToggleAlpha() { _mgl_key_up('r',0,0); } + /// Switch on/off lighting (do not overwrite switches in user drawing function) + void ToggleLight() { _mgl_key_up('f',0,0); } + void ToggleNo() { _mgl_key_up('n',0,0); } ///< Switch off all zooming and rotation + void Update() { _mgl_key_up(' ',0,0); } ///< Update picture by calling user drawing function + void ReLoad() { _mgl_key_up('[',0,0); } ///< Reload user data and update picture + void NextFrame() { _mgl_key_up('.',0,0); } ///< Show next frame (if one) + void PrevFrame() { _mgl_key_up(',',0,0); } ///< Show previous frame (if one) + void Animation() { _mgl_key_up('m',0,0); } ///< Run slideshow (animation) of frames +private: + void (*LoadFunc)(void *par); + void *FuncPar; ///< Parameters for drawing function mglCanvas::DrawFunc. + /// Drawing function for window procedure. It should return the number of frames. + int (*DrawFunc)(mglBase *gr, void *par); + int NumFig; ///< Number of figures in the list. If 0 then no list and mglCanvas::DrawFunc will called for each drawing. + int curr_fig; ///< Current figure in the list. + int tt; ///< Temporal variable +} *_mgl_glwnd; +//----------------------------------------------------------------------------- +void _mgl_timer(int) +{ + if(!_mgl_glwnd) return; + if(_mgl_glwnd->tt) + { + _mgl_glwnd->curr_fig++; + if(_mgl_glwnd->curr_fig > _mgl_glwnd->NumFig) + _mgl_glwnd->curr_fig = 1; + glutPostRedisplay(); + } + glutTimerFunc(int(_mgl_glwnd->Delay*1000),_mgl_timer,0); +} +//----------------------------------------------------------------------------- +void _mgl_key_up(unsigned char ch,int ,int ) +{ + if(!_mgl_glwnd) return; + static bool Alpha=false; + static bool Light=false; + static mreal rL=3,tL=0,pL=0; + + if(ch=='h') + { + printf("Use 'a', 'd', 'w', 's', 'q', 'e' for changing view angles\n"); + printf("Use 'j', 'l', 'i', 'k' for changing light angles\n"); + printf("Use 'u', 'o' for changing distance to light\n"); + printf("Use 'r' for switching transparency\n"); + printf("Use 'f' for switching lightning\n"); + printf("Use 'T' for exporting to TIFF file\n"); + printf("Use 'J' for exporting to JPEG file\n"); + printf("Use 'P' for exporting to PNG file\n"); + printf("Use ',', '.' for show other frames\n"); + printf("Use 'm' for view movie\n"); + printf("Use 'h' for view this text\n"); + printf("Use 'x' for exit\n"); + + } + if(ch=='w') _mgl_glwnd->View(-10,0,0); + if(ch=='s') _mgl_glwnd->View(10,0,0); + if(ch=='a') _mgl_glwnd->View(0,0,-10); + if(ch=='d') _mgl_glwnd->View(0,0,10); + if(ch=='q') _mgl_glwnd->View(0,-10,0); + if(ch=='e') _mgl_glwnd->View(0,10,0); + if(ch=='n') _mgl_glwnd->Restore(); + if(ch==',') + _mgl_glwnd->curr_fig = _mgl_glwnd->curr_fig == 0 ? _mgl_glwnd->NumFig-1 : _mgl_glwnd->curr_fig-1; + if(ch=='.') + _mgl_glwnd->curr_fig = _mgl_glwnd->curr_fig == _mgl_glwnd->NumFig-1 ? 0 : _mgl_glwnd->curr_fig+1; + if(ch=='r') Alpha = !Alpha; + if(ch=='f') Light = !Light; + if(ch=='u') rL += 0.1; + if(ch=='o') rL -= 0.1; + if(ch=='i') tL += M_PI*0.1; + if(ch=='k') tL -= M_PI*0.1; + if(ch=='l') pL += 2*M_PI*0.1; + if(ch=='j') pL -= 2*M_PI*0.1; + if(ch=='[' && _mgl_glwnd->LoadFunc) + { + glDeleteLists(1,_mgl_glwnd->NumFig); + _mgl_glwnd->LoadFunc(_mgl_glwnd->FuncPar); + if(_mgl_glwnd->DrawFunc) + (_mgl_glwnd->DrawFunc)(_mgl_glwnd,_mgl_glwnd->FuncPar); + _mgl_glwnd->Finish(); + } + if(ch=='P') + { + char str[128]; + snprintf(str,128,"%s_%d.png",_mgl_glwnd->PlotId.c_str(),_mgl_glwnd->curr_fig); + mgl_write_png(_mgl_glwnd, str, "Math GL"); + } + if(ch=='J') + { + char str[128]; + snprintf(str,128,"%s_%d.jpg",_mgl_glwnd->PlotId.c_str(),_mgl_glwnd->curr_fig); + mgl_write_jpg(_mgl_glwnd, str, "Math GL"); + } + if(ch=='E') + { + char str[128]; + snprintf(str,128,"%s_%d.eps",_mgl_glwnd->PlotId.c_str(),_mgl_glwnd->curr_fig); + mgl_write_eps(_mgl_glwnd, str, "Math GL"); + } + if(ch==' ') _mgl_glwnd->Clf(); + if(ch=='m') _mgl_glwnd->tt = 1-_mgl_glwnd->tt; + rL = rL<0 ? 0 : (rL>5 ? 5 : rL); + _mgl_glwnd->AddLight(0,mglPoint(rL*cos(pL)*sin(tL), rL*sin(pL)*sin(tL), rL*cos(tL)),false); + _mgl_glwnd->Alpha(Alpha); + _mgl_glwnd->Light(Light); +// glEnable(GL_BLEND); + if(strchr("ijkl",ch)) + printf("Light: %g, %g, %g\n",rL*cos(pL)*sin(tL), rL*sin(pL)*sin(tL), rL*cos(tL)); + + if(ch=='x') exit(0); + else glutPostRedisplay(); +} +//----------------------------------------------------------------------------- +void _mgl_display() +{ + if(!_mgl_glwnd) return; +// glEnable(GL_LINE_SMOOTH); +// _mgl_glwnd->CurFrameId = 1; +// if(_mgl_glwnd->get(MGL_CLF_ON_UPD)) + _mgl_glwnd->Clf(); +// _mgl_glwnd->gl_clf(); + _mgl_glwnd->InPlot(0,1,0,1,false); + if(_mgl_glwnd->NumFig>0) + { + _mgl_glwnd->GetFrame(_mgl_glwnd->curr_fig); + _mgl_glwnd->Finish(); +// glCallList(_mgl_glwnd->curr_fig); + } + else + { + if(_mgl_glwnd->DrawFunc) + (_mgl_glwnd->DrawFunc)(_mgl_glwnd,_mgl_glwnd->FuncPar); + _mgl_glwnd->Finish(); + } + glFinish(); +} +//----------------------------------------------------------------------------- +mglCanvasGLUT::~mglCanvasGLUT() { _mgl_glwnd = 0; } +//----------------------------------------------------------------------------- +void mglCanvasGLUT::Window(int argc, char **argv,int (*draw)(mglBase *gr, void *p),const char *title, void *par, void (*reload)(void *p), bool /*maximize*/) +{ + NumFig=0; curr_fig=1; tt=0; + _mgl_glwnd = this; + CurFrameId = 1; + + char *tmp[1]; tmp[0]=new char[1]; tmp[0][0]=0; + glutInit(&argc, argv ? argv:tmp); + delete []tmp[0]; + glutInitDisplayMode(GLUT_RGB); + glutInitWindowSize(600, 600); + glutCreateWindow("MathGL"); + + AddLight(0,mglPoint(0,0,3),false); + if(draw) + { + NumFig = draw(this,par)-1; Finish(); + DrawFunc = draw; FuncPar = par; + } + else + { NumFig = 0; DrawFunc=0; FuncPar=0; } + LoadFunc = reload; + glutSetWindowTitle(title); + + glutDisplayFunc(_mgl_display); + glutKeyboardUpFunc(_mgl_key_up); + glutTimerFunc(int(1000*Delay),_mgl_timer,0); + + // TODO Add window maximazing at start up ??? + + glutMainLoop(); + if(NumFig>0) glDeleteLists(1,NumFig); +} +//----------------------------------------------------------------------------- +HMGL MGL_EXPORT mgl_create_graph_glut(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)) +{ + mglCanvasGLUT *g = new mglCanvasGLUT; + g->Window(0,0,draw,title,par, load); + return g; +} +//----------------------------------------------------------------------------- +mglCanvasGLUT::mglCanvasGLUT() : mglCanvasGL() {} +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_glut_toggle_alpha(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->ToggleAlpha(); } +void MGL_EXPORT mgl_glut_toggle_light(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->ToggleLight(); } +void MGL_EXPORT mgl_glut_toggle_no(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->ToggleNo(); } +void MGL_EXPORT mgl_glut_update(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->Update(); } +void MGL_EXPORT mgl_glut_reload(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->ReLoad(); } +void MGL_EXPORT mgl_glut_next_frame(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->NextFrame(); } +void MGL_EXPORT mgl_glut_prev_frame(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->PrevFrame(); } +void MGL_EXPORT mgl_glut_animation(HMGL gr) +{ mglCanvasGLUT *g = dynamic_cast(gr); + if(g) g->Animation(); } +//----------------------------------------------------------------------------- diff --git a/widgets/qt.cpp b/widgets/qt.cpp new file mode 100644 index 0000000..6d6cc11 --- /dev/null +++ b/widgets/qt.cpp @@ -0,0 +1,1198 @@ +/*************************************************************************** + * qt.cpp is part of Math Graphic Library * + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mgl2/canvas_wnd.h" +#include "mgl2/qmathgl.h" +#include "mgl2/qt.h" +//----------------------------------------------------------------------------- +#define MGL_MAX_LINES (INT_MAX-1000) +#if !defined(WIN32) && !defined(__APPLE__) +#include +#endif +//----------------------------------------------------------------------------- +/// Base class for windows containing MathGL graphics +class mglCanvasQT : public mglCanvasWnd +{ +public: +using mglCanvasWnd::Window; + int sshow; ///< Current state of animation switch (toggle button) + QMathGL *QMGL; ///< Control which draw graphics + QMainWindow *Wnd; ///< Pointer to window + + mglCanvasQT(); + + /// Create a window for plotting. Now implemeted only for GLUT. + void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p),const char *title, + void *par=NULL, void (*reload)(void *p)=NULL, bool maximize=false); + /// Switch on/off transparency (do not overwrite switches in user drawing function) + void ToggleAlpha(); + /// Switch on/off lighting (do not overwrite switches in user drawing function) + void ToggleLight(); + void ToggleRotate();///< Switch on/off rotation by mouse + void ToggleZoom(); ///< Switch on/off zooming by mouse + void ToggleNo(); ///< Switch off all zooming and rotation + void Update(); ///< Update picture by calling user drawing function + void Adjust(); ///< Adjust size of bitmap to window size + void GotoFrame(int d); ///< Show arbitrary frame (use relative step) + void Animation(); ///< Run slideshow (animation) of frames + +protected: + QScrollArea *scroll; ///< Scrolling area + QMenu *popup; ///< Popup menu + QSpinBox *tet, *phi; ///< Spin box for angles +}; +//----------------------------------------------------------------------------- +void MGL_EXPORT mgl_ask_qt(const wchar_t *quest, wchar_t *res) +{ QInputDialog::getText(QApplication::activeWindow(), "MathGL", + QString::fromWCharArray(quest)).toWCharArray(res); } +//----------------------------------------------------------------------------- +// +// class QMathGL +// +//----------------------------------------------------------------------------- +QMathGL::QMathGL(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) +{ + autoResize = false; draw_par = 0; draw_func = 0; + gr = new mglCanvas; appName = "MathGL"; + popup = 0; grBuf = 0; draw = 0; + phi = tet = per = 0; + x1 = y1 = ax1 = ay1 = 0; x2 = y2 = ax2 = ay2 = 1; + alpha = light = zoom = rotate = grid = viewYZ = custZoom = custDraw = false; + resize(600, 400); mgl_set_flag(gr, true, MGL_CLF_ON_UPD); + timer = new QTimer(this); + enableWheel = enableMouse = true; +// resize(graph->GetWidth(), graph->GetHeight()); +// mglConvertFromGraph(pic, graph, &grBuf); + connect(timer, SIGNAL(timeout()), this, SLOT(nextSlide())); +} +//----------------------------------------------------------------------------- +QMathGL::~QMathGL() +{ + if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); + if(grBuf) delete []grBuf; + if(draw) delete draw; +} +//----------------------------------------------------------------------------- +void QMathGL::setDraw(int (*func)(mglBase *gr, void *par), void *par) +{ + if(draw) delete draw; draw = 0; + draw_func = func; draw_par = par; + emit usePrimChanged(draw_func || draw); +} +//----------------------------------------------------------------------------- +void QMathGL::setDraw(mglDraw *dr) +{ + if(draw) delete draw; + draw = dr; draw_func = 0; + emit usePrimChanged(draw_func || draw); +} +//----------------------------------------------------------------------------- +double QMathGL::getRatio() { return double(mgl_get_width(gr))/mgl_get_height(gr); } +//----------------------------------------------------------------------------- +void QMathGL::setGraph(HMGL GR) ///< Set grapher object +{ + mglCanvas *gg = dynamic_cast(GR); + if(!gg) return; + if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); + gr=gg; mgl_use_graph(gg,1); +} +//----------------------------------------------------------------------------- +void QMathGL::paintEvent(QPaintEvent *) +{ + QPainter paint; + paint.begin(this); + paint.drawPixmap(0,0,pic); + if(zoom) paint.drawRect(x0,y0,xe-x0,ye-y0); + if(mgl_get_flag(gr,MGL_SHOW_POS) && !mousePos.isEmpty()) + paint.drawText(0,12,mousePos); + if(grid) + { + long i, d, h=pic.height(), w=pic.width(); + paint.setPen(QColor(192,192,192)); + for(i=1;i<10;i++) + { + paint.drawText(0,i*h/10,QString::number(1-i*0.1)); + paint.drawLine(0,i*h/10,w,i*h/10); + paint.drawText(i*w/10,h,QString::number(i*0.1)); + paint.drawLine(i*w/10,0,i*w/10,h); + } + paint.setPen(QColor(0,0,0)); + d = (h>w?w:h)/100; + if(mgl_is_frames(gr)) + for(i=0;i<(long)gr->Act.size();i++) + { + const mglActivePos &p=gr->Act[i]; + QRect rf(p.x-d/2,p.y-d/2-1,d,d); + paint.drawRect(rf); + paint.fillRect(rf,QBrush(QColor(127,255,63))); + } + } + paint.end(); +} +//----------------------------------------------------------------------------- +void QMathGL::resizeEvent(QResizeEvent *ev) +{ + if(autoResize && ev->size().width()>0 && ev->size().height()>0) + { mgl_set_size(gr, ev->size().width(), ev->size().height()); update(); } +// else resize(graph->GetWidth(), graph->GetHeight()); +} +//----------------------------------------------------------------------------- +void QMathGL::setPer(int p) +{ + if(per!=p && p>=0 && p<100) + { per = 100*p; emit perChanged(p); refresh(); } +} +//----------------------------------------------------------------------------- +void QMathGL::setPhi(int p) +{ if(phi!=p) { phi = p; emit phiChanged(p); refresh(); } } +//----------------------------------------------------------------------------- +void QMathGL::setTet(int t) +{ if(tet!=t) { tet = t; emit tetChanged(t); refresh(); } } +//----------------------------------------------------------------------------- +void QMathGL::setAlpha(bool a) +{ if(alpha!=a) { alpha = a; emit alphaChanged(a); update(); } } +//----------------------------------------------------------------------------- +void QMathGL::setLight(bool l) +{ if(light!=l) { light = l; emit lightChanged(l); update(); } } +//----------------------------------------------------------------------------- +void QMathGL::setGrid(bool g) +{ if(grid!=g) { grid = g; emit gridChanged(g); refresh(); } } +//----------------------------------------------------------------------------- +void QMathGL::setViewYZ(bool a) +{ if(viewYZ!=a) { viewYZ = a; emit viewYZChanged(a); refresh(); } } +//----------------------------------------------------------------------------- +void QMathGL::setRotate(bool r) +{ + if(rotate!=r) + { zoom=false; rotate=r; refresh(); emit rotateChanged(r); } +} +//----------------------------------------------------------------------------- +void QMathGL::setZoom(bool z) +{ + if(zoom!=z) + { zoom=z; rotate=false; refresh(); + emit zoomChanged(z); emit rotateChanged(false); } +} +//----------------------------------------------------------------------------- +void QMathGL::setCustZoom(bool z) { custZoom = z; } +//----------------------------------------------------------------------------- +void QMathGL::setCustDraw(bool z) { custDraw = z; } +//----------------------------------------------------------------------------- +void QMathGL::shiftDown() +{ mreal d=(y2-y1)/4; y1+=d; y2+=d; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::shiftUp() +{ mreal d=(y2-y1)/4; y1-=d; y2-=d; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::shiftRight() +{ mreal d=(x2-x1)/4; x1-=d; x2-=d; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::shiftLeft() +{ mreal d=(x2-x1)/4; x1+=d; x2+=d; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::zoomIn() +{ + mreal d,c; + d = (y2-y1)/4; c = (y2+y1)/2; y1 = c-d; y2 = c+d; + d = (x2-x1)/4; c = (x2+x1)/2; x1 = c-d; x2 = c+d; + refresh(); +} +//----------------------------------------------------------------------------- +void QMathGL::zoomOut() +{ + mreal d,c; + d = (y2-y1); c = (y2+y1)/2; y1 = c-d; y2 = c+d; + d = (x2-x1); c = (x2+x1)/2; x1 = c-d; x2 = c+d; + refresh(); +} +//----------------------------------------------------------------------------- +void QMathGL::restore() +{ + setPhi(0); setTet(0); setPer(0); + x1=y1=0; x2=y2=1; zoom=rotate=false; + emit zoomChanged(false); emit rotateChanged(false); + if(ax1!=0 || ay1!=0 || ax2!=1 || ay2!=1) + { + ax1=ay1=0; ax2=ay2=1; + mgl_zoom_axis(gr,0,0,0,0,1,1,1,1); + update(); + } + else refresh(); +} +//----------------------------------------------------------------------------- +void QMathGL::stop() { gr->Stop=true; } //{ thr->terminate(); } +void QMathGL::update() +{ +/* if(!thr->isRunning()) + { + thr->gr = gr; thr->text = text; + thr->line = line; thr->start(); + } + if(rotate) thr->wait(); + else while(thr->isRunning()) qApp->processEvents(); + if(warnMGL) warnMGL->setText(thr->warn);*/ + + if(draw_func || draw) + { + mgl_reset_frames(gr); // remove previous frames + if(mgl_get_flag(gr,MGL_CLF_ON_UPD)) mgl_set_def_param(gr); + mgl_set_alpha(gr,alpha); mgl_set_light(gr,light); + if(!isHidden()) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + setlocale(LC_NUMERIC, "C"); + // use frames for quickly redrawing while adding/changing primitives + if(custDraw) emit customDraw(x1,y1,x2,y2,true); + if(mgl_is_frames(gr)) mgl_new_frame(gr); + if(draw_func) draw_func(gr, draw_par); + else if(draw) { mglGraph g(gr); draw->Draw(&g); } + if(mgl_is_frames(gr)) mgl_end_frame(gr); + setlocale(LC_NUMERIC, ""); + if(!isHidden()) QApplication::restoreOverrideCursor(); + emit refreshData(); + emit showWarn(mgl_get_mess(gr)); + mousePos=""; + } + refresh(); +} +//----------------------------------------------------------------------------- +void QMathGL::draw_thr() +{ + mgl_clf(gr); + mglCanvasWnd *g = dynamic_cast(gr); + int c = g?g->GetCurFig():mgl_get_num_frame(gr)-1; + mgl_get_frame(gr, c); + mglParse pr; + long i, n=primitives.count('\n'); + mglGraph gg(gr); + setlocale(LC_NUMERIC, "C"); + gg.Push(); gg.SubPlot(1,1,0,"#"); + mglPoint ox1=gr->Min, ox2=gr->Max; + gg.SetRanges(mglPoint(-1,-1,-1),mglPoint(1,1,1)); + for(i=0;idraw_thr(); return 0; } +void QMathGL::refresh() +{ + if(mgl_is_frames(gr) && mgl_get_num_frame(gr)>0) + { + if(draw_func || draw) + { +/*#if MGL_HAVE_PTHREAD // TODO add qthread here later + pthread_t tmp; + pthread_create(&tmp, 0, mgl_qt_thr, this); + pthread_join(tmp, 0); +#else*/ + draw_thr(); +/*#endif*/ + } + if(custZoom) emit customZoom(x1,y1,x2,y2,tet,phi,per); + else + { mgl_zoom(gr,x1,y1,x2,y2); + mgl_perspective(gr,per); + if(viewYZ) mgl_view(gr,0,phi,tet); + else mgl_view(gr,phi,0,tet); + } + } + mglConvertFromGraph(pic, gr, &grBuf); + if(pic.size()!=size()) setSize(pic.width(), pic.height()); + repaint(); +} +//----------------------------------------------------------------------------- +void QMathGL::mousePressEvent(QMouseEvent *ev) +{ + if(!zoom && !rotate && ev->button()&Qt::LeftButton) + { + mglPoint p = gr->CalcXYZ(ev->x(), ev->y()); + mglCanvasWnd *g=dynamic_cast(gr); + if(g) g->LastMousePos = p; + if(g && g->ClickFunc) g->ClickFunc(draw_par); + emit mouseClick(p.x,p.y,p.z); + int id = mgl_get_obj_id(gr,ev->x(),ev->y()); + if(idCalcXYZ(ev->x(), ev->y(), true); + if(mgl_isnan(p.x)) mousePos = ""; + else mousePos.sprintf("x=%g, y=%g, z=%g",p.x,p.y,p.z); + emit posChanged(mousePos); + repaint(); + } + xe=x0=ev->x(); ye=y0=ev->y(); ev->accept(); +} +//----------------------------------------------------------------------------- +void QMathGL::mouseReleaseEvent(QMouseEvent *ev) +{ + if(ev->button()&Qt::LeftButton && enableMouse) + { + if(zoom) + { + int w1=width(),h1=height(); + mreal _x1,_x2,_y1,_y2; + _x1 = x1+(x2-x1)*(x0-x())/mreal(w1); _y1 = y2-(y2-y1)*(ye-y())/mreal(h1); + _x2 = x1+(x2-x1)*(xe-x())/mreal(w1); _y2 = y2-(y2-y1)*(y0-y())/mreal(h1); + x1=_x1; x2=_x2; y1=_y1; y2=_y2; + if(x1>x2) { _x1=x1; x1=x2; x2=_x1; } + if(y1>y2) { _x1=y1; y1=y2; y2=_x1; } + x0 = xe; y0 = ye; + if(custDraw) + { + emit customDraw(x1,y1,x2,y2,false); + update(); + } + else refresh(); + } + } + if(ev->button()&Qt::RightButton && popup && !rotate) // popup menu + popup->popup(QCursor::pos()); + ev->accept(); +} +//----------------------------------------------------------------------------- +void QMathGL::mouseMoveEvent(QMouseEvent *ev) +{ + if(!enableMouse) { ev->ignore(); return; } + xe=ev->x(); ye=ev->y(); + if(rotate) + { + if(ev->buttons()&Qt::LeftButton) // rotate + { + mreal ff = 240/sqrt(mreal(width()*height())); + phi += int((x0-xe)*ff); + tet -= int((y0-ye)*ff); + if(phi>180) phi-=360; if(phi<-180) phi+=360; + if(tet>180) tet-=360; if(tet<-180) tet+=360; + emit tetChanged(int(tet)); emit phiChanged(int(phi)); + refresh(); + } + if(ev->buttons()&Qt::RightButton) // zoom and perspective + { + mreal ff = 2.*(y0-ye)/width(), gg = 0.5*(xe-x0)/height(); + mreal cx = (x1+x2)/2, cy = (y1+y2)/2; + x1 = cx+(x1-cx)*exp(-ff); x2 = cx+(x2-cx)*exp(-ff); + y1 = cy+(y1-cy)*exp(-ff); y2 = cy+(y2-cy)*exp(-ff); + per = per + gg; + if(per<0) per = 0; if(per>=1) per = 0.9999; + if(gg) emit perChanged(int(per)); + refresh(); + } + if(ev->buttons()&Qt::MidButton) // shift + { + mreal ff = 1./sqrt(mreal(width()*height())); + mreal dx = (x0-xe)*ff*(x2-x1), dy = (y0-ye)*ff*(y2-y1); + x1 += dx; x2 += dx; y1 -= dy; y2 -= dy; + } + x0 = xe; y0 = ye; + refresh(); + } + else if(zoom) refresh(); + else if(ev->buttons()&Qt::MidButton) // shift axis + { + mreal ff = 1./sqrt(mreal(width()*height())); + mreal dx = (x0-xe)*ff*(ax2-ax1), dy = (y0-ye)*ff*(ay2-ay1); + ax1 += dx; ax2 += dx; ay1 -= dy; ay2 -= dy; + mgl_zoom_axis(gr,ax1,ay1,0,0,ax2,ay2,0,0); + update(); x0 = xe; y0 = ye; + } + else if(ev->buttons()&Qt::LeftButton) // move primitives + { + long h=pic.height(), w=pic.width(), d=(h>w?w:h)/100; + long pos = mgl_is_active(gr,x0,y0,d); + long id = long(mgl_get_obj_id(gr,x0,y0))-MGL_MAX_LINES; + if(grid && pos>=0) // this active point + { + const mglActivePos &p = gr->Act[pos]; + id = long(p.id)-MGL_MAX_LINES; + if(id>=0) // this is our primitive + { + // try "attract" mouse + register size_t i; + register int tt; + for(i=0;i<=10;i++) + { + tt = i*(w/10); if(abs(xe-tt)<2*d) xe = tt; + tt = i*(h/10); if(abs(ye-tt)<2*d) ye = tt; + } + for(i=0;iAct.size();i++) + { + const mglActivePos &q = gr->Act[i]; + if(abs(xe-q.x)<2*d && abs(ye-q.y)<2*d) { xe=q.x; ye=q.y; } + } + // now move point + QString tst = primitives.section('\n',id,id), cmd=tst.section(' ',0,0), res; + float dx = 2*(xe-x0)/float(w), dy = 2*(y0-ye)/float(h); + float xx=tst.section(' ',1,1).toFloat(), yy=tst.section(' ',2,2).toFloat(); + if(p.n==0) + res = cmd+" "+QString::number(xx+dx)+" "+QString::number(yy+dy)+" "+tst.section(' ',3); + else if(cmd=="rect") + { + float x_=tst.section(' ',3,3).toFloat(), y_=tst.section(' ',4,4).toFloat(); + if(p.n==1) { xx+=dx; y_+=dy; } + if(p.n==2) { x_+=dx; yy+=dy; } + if(p.n==3) { x_+=dx; y_+=dy; } + res = "rect "+QString::number(xx)+" "+QString::number(yy)+" "+ + QString::number(x_)+" "+QString::number(y_)+" "+tst.section(' ',5); + } + else if(p.n==1) + { + xx=tst.section(' ',3,3).toFloat(); yy=tst.section(' ',4,4).toFloat(); + res = tst.section(' ',0,2)+" "+QString::number(xx+dx)+" "+QString::number(yy+dy)+" "+tst.section(' ',5); + } + else if(cmd=="rhomb" || cmd=="ellipse") + { + float x_=tst.section(' ',3,3).toFloat()-xx, y_=tst.section(' ',4,4).toFloat()-yy, dr=0; + if(x_*x_+y_*y_>0) + { + dr = (dx*x_+dy*y_)/(x_*x_+y_*y_); + dr = hypot(dx-dr*x_,dy-dr*y_); + } + else dr = hypot(dx,dy); + res = tst.section(' ',0,4)+" "+QString::number(tst.section(' ',5,5).toFloat()+dr)+" "+tst.section(' ',6); + } + else if(p.n==2) + { + xx=tst.section(' ',5,5).toFloat(); yy=tst.section(' ',6,6).toFloat(); + res = tst.section(' ',0,4)+" "+QString::number(xx+dx)+" "+QString::number(yy+dy)+" "+tst.section(' ',7); + } + else if(p.n==3) + { + xx=tst.section(' ',7,7).toFloat(); yy=tst.section(' ',8,8).toFloat(); + if(cmd=="curve") { dx*=-1; dy*=-1; } + res = tst.section(' ',0,6)+" "+QString::number(xx+dx)+" "+QString::number(yy+dy)+" "+tst.section(' ',9); + } + if(id>0) res = primitives.section('\n',0,id-1) + "\n" + res; + primitives = res + "\n" + primitives.section('\n',id+1); + refresh(); x0 = xe; y0 = ye; + } + } + else if(id>=0) // this is primitive + { + QString tst = primitives.section('\n',id,id), cmd=tst.section(' ',0,0), res; + float dx = 2*(xe-x0)/float(w), dy = 2*(y0-ye)/float(h); + float x1=tst.section(' ',1,1).toFloat(), y1=tst.section(' ',2,2).toFloat(),x2,y2; + if(cmd=="ball" || cmd=="text") + res = cmd+" "+QString::number(x1+dx)+" "+QString::number(y1+dy)+" "+tst.section(' ',3); + else if(cmd=="curve") + { + x2=tst.section(' ',5,5).toFloat(); y2=tst.section(' ',6,6).toFloat(); + res = cmd+" "+QString::number(x1+dx)+" "+QString::number(y1+dy)+" "+tst.section(' ',3,4)+ + " "+QString::number(x2+dx)+" "+QString::number(y2+dy)+" "+tst.section(' ',7); + } + else + { + x2=tst.section(' ',3,3).toFloat(); y2=tst.section(' ',4,4).toFloat(); + res = cmd+" "+QString::number(x1+dx)+" "+QString::number(y1+dy)+" "+ + QString::number(x2+dx)+" "+QString::number(y2+dy)+" "+tst.section(' ',5); + } + if(id>0) res = primitives.section('\n',0,id-1) + "\n" + res; + primitives = res + "\n" + primitives.section('\n',id+1); + refresh(); x0 = xe; y0 = ye; + } + } + ev->accept(); +} +//----------------------------------------------------------------------------- +void QMathGL::mouseDoubleClickEvent(QMouseEvent *ev) +{ + long h=pic.height(), w=pic.width(), d=(h>w?w:h)/100; + long pos = mgl_is_active(gr,x0,y0,d); + long id = long(mgl_get_obj_id(gr,x0,y0)); + if(grid && pos>=0) // this active point -> delete primitive + { + const mglActivePos &p = gr->Act[pos]; + id = long(p.id)-MGL_MAX_LINES; + QString res; + if(id>0) res = primitives.section('\n',0,id-1) + "\n"; + if(id>=0) primitives = res + primitives.section('\n',id+1); + refresh(); x0 = xe; y0 = ye; + } + else if(id>=MGL_MAX_LINES) // option for primitives + emit askStyle(id-MGL_MAX_LINES); + else emit doubleClick(id); + ev->accept(); +} +//----------------------------------------------------------------------------- +void QMathGL::setStyle(int id, QString stl) +{ + QString tst = primitives.section('\n',id,id), res; + res = tst.section(' ',0,-2) + " " + stl; + if(id>0) res = primitives.section('\n',0,id-1) + "\n" + res; + primitives = res + "\n" + primitives.section('\n',id+1); + refresh(); x0 = xe; y0 = ye; +} +//----------------------------------------------------------------------------- +void QMathGL::wheelEvent(QWheelEvent *ev) +{ + if(!enableWheel) { ev->ignore(); return; } + if(rotate) // zoom + { + mreal d,c,f=exp(0.001*ev->delta())/2; + d = (y2-y1)*f; c = (y2+y1)/2; y1 = c-d; y2 = c+d; + d = (x2-x1)*f; c = (x2+x1)/2; x1 = c-d; x2 = c+d; + refresh(); ev->accept(); + } + else // zoom axis + { + mreal d,c,f=exp(0.001*ev->delta())/2; + d = (ay2-ay1)*f; c = (ay2+ay1)/2; ay1 = c-d; ay2 = c+d; + d = (ax2-ax1)*f; c = (ax2+ax1)/2; ax1 = c-d; ax2 = c+d; + mgl_zoom_axis(gr,ax1,ay1,0,0,ax2,ay2,0,0); + update(); ev->accept(); + } +} +//----------------------------------------------------------------------------- +void QMathGL::imgSize(int w, int h) +{ if(w>0 && h>0) { mgl_set_size(gr,w,h); update(); } } +//----------------------------------------------------------------------------- +QString setExtension(QString &fname, const char *ext) +{ + QString oname; + if(fname.right(4)!="."+QString(ext)) oname = fname+"."+QString(ext); + return oname; +} +//----------------------------------------------------------------------------- +void QMathGL::exportGIF(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else mgl_write_gif(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); +} +//----------------------------------------------------------------------------- +void QMathGL::exportPNG(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else mgl_write_png(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); +} +//----------------------------------------------------------------------------- +void QMathGL::exportPNGs(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else mgl_write_png_solid(gr,setExtension(fname,"png").toStdString().c_str(), appName.toStdString().c_str()); +} +//----------------------------------------------------------------------------- +void QMathGL::exportJPG(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else mgl_write_jpg(gr,setExtension(fname,"jpg").toStdString().c_str(), appName.toStdString().c_str()); +} +//----------------------------------------------------------------------------- +void QMathGL::exportBPS(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_bps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportEPS(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_eps(gr,setExtension(fname,"eps").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportSVG(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_svg(gr,setExtension(fname,"svg").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportXYZ(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_xyz(gr,setExtension(fname,"xyz").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportTEX(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_tex(gr,setExtension(fname,"tex").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportOFF(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_off(gr,setExtension(fname,"off").toStdString().c_str(), appName.toStdString().c_str(),0); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportOBJ(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_obj(gr,setExtension(fname,"obj").toStdString().c_str(), appName.toStdString().c_str(),1); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportSTL(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_stl(gr,setExtension(fname,"stl").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +/*void QMathGL::exportX3D(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_x3d(gr,setExtension(fname,"x3d").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +}*/ +//----------------------------------------------------------------------------- +void QMathGL::exportTGA(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_tga(gr,setExtension(fname,"tga").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportPRC(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_write_prc(gr,setExtension(fname,"prc").toStdString().c_str(), appName.toStdString().c_str(),1); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void QMathGL::exportMGLD(QString fname) +{ + if(fname.isEmpty()) fname = mgl_get_plotid(gr); + if(fname.isEmpty()) QMessageBox::critical(this, appName, tr("No filename."),QMessageBox::Ok,0,0); + else + { + setlocale(LC_NUMERIC, "C"); + mgl_export_mgld(gr,setExtension(fname,"mgld").toStdString().c_str(), appName.toStdString().c_str()); + setlocale(LC_NUMERIC, ""); + } +} +//----------------------------------------------------------------------------- +void mglConvertFromGraph(QPixmap &pic, mglCanvas *gr, uchar **buf) +{ + const uchar *bb = mgl_get_rgb(gr); + register long i,w=mgl_get_width(gr), h=mgl_get_height(gr); + if(*buf) delete [](*buf); + *buf = new uchar[4*w*h]; + for(i=0;isetPixmap(pic, QClipboard::Clipboard); } +//----------------------------------------------------------------------------- +void QMathGL::copyClickCoor() +{ QApplication::clipboard()->setText(mousePos); } +//----------------------------------------------------------------------------- +void QMathGL::setMGLFont(QString path) +{ if(path.isEmpty()) mgl_restore_font(gr); + else mgl_load_font(gr,path.toStdString().c_str(),0); } +//----------------------------------------------------------------------------- +void QMathGL::setSize(int w, int h) +{ + resize(w, h); + if(w!=pic.width() || h!=pic.height()) // update only when image size is changed + { mgl_set_size(gr,w,h); update(); } +} +//----------------------------------------------------------------------------- +void QMathGL::about() +{ + QString s = tr("MathGL v. 2.") + QString::number(MGL_VER2) + tr("\n(c) Alexey Balakin, 2007\nhttp://mathgl.sourceforge.net/"); + QMessageBox::about(this, tr("MathGL - about"), s); +} +//----------------------------------------------------------------------------- +void QMathGL::aboutQt() { QMessageBox::aboutQt(this, tr("About Qt")); } +//----------------------------------------------------------------------------- +void QMathGL::print() +{ + QPrinter *printer = new QPrinter; + printer->setOrientation(getRatio()>1 ? QPrinter::Landscape : QPrinter::Portrait); + QPrintDialog printDlg(printer, this); + if (printDlg.exec() == QDialog::Accepted) + { + QRectF r = printer->pageRect(QPrinter::Inch); + int d1 = int(pic.width()/r.width()), d2 = int(pic.height()/r.height()); + int dpi = printer->resolution(); + if(dpisetResolution(dpi); + + QPainter p; + if(!p.begin(printer)) return; // paint on printer + p.drawPixmap(0,0,pic); + } + delete printer; +} +//----------------------------------------------------------------------------- +void QMathGL::nextSlide() +{ + mglCanvasWnd *g = dynamic_cast(gr); + if(g && g->GetNumFig()>1) g->NextFrame(); + emit frameChanged(+1); +} +void QMathGL::prevSlide() +{ + mglCanvasWnd *g = dynamic_cast(gr); + if(g && g->GetNumFig()>1) g->PrevFrame(); + emit frameChanged(-1); +} +//----------------------------------------------------------------------------- +void QMathGL::animation(bool st) +{ + if(st) timer->stop(); + else timer->start(int(mgl_wnd_get_delay(gr)*1000)); +} +//----------------------------------------------------------------------------- +void QMathGL::adjust() +{ + mgl_set_size(gr, parentWidget()->width()-3, parentWidget()->height()-3); + setSize(parentWidget()->width()-3, parentWidget()->height()-3); + update(); +} +//----------------------------------------------------------------------------- +void QMathGL::addMark() +{ primitives += "ball 0 0 'r*'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addLine() +{ primitives += "line -0.2 0 0.2 0 'r2'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addRect() +{ primitives += "rect -0.2 -0.2 0.2 0.2 'r'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addCurve() +{ primitives += "curve -0.2 0 0 0.5 0.2 0 0 0.5 'r2'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addRhomb() +{ primitives += "rhomb -0.2 0 0.2 0 0.1 'r'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addEllipse() +{ primitives += "ellipse -0.2 0 0.2 0 0.1 'r'\n"; refresh(); } +//----------------------------------------------------------------------------- +void QMathGL::addText(QString txt) +{ + if(txt.isEmpty()) + txt = QInputDialog::getText(QApplication::activeWindow(), "MathGL", tr("Enter text")); + if(!txt.isEmpty()) + { primitives += "text 0 0 '"+txt+"' ''\n"; refresh(); } +} +//----------------------------------------------------------------------------- +// +// class mglCanvasQT +// +//----------------------------------------------------------------------------- +mglCanvasQT::mglCanvasQT() : mglCanvasWnd() +{ Wnd = 0; } +//----------------------------------------------------------------------------- +void mglCanvasQT::GotoFrame(int d) +{ + int f = GetCurFig()+d; + if(f>=GetNumFig()) f = 0; + if(f<0) f = GetNumFig()-1; + if(GetNumFig()>0 && d) { SetCurFig(f); QMGL->refresh(); } +} +//----------------------------------------------------------------------------- +void mglCanvasQT::Animation() { QMGL->animation(true); } +//----------------------------------------------------------------------------- +void mglCanvasQT::ToggleAlpha() { QMGL->setAlpha(!QMGL->getAlpha()); } +//----------------------------------------------------------------------------- +void mglCanvasQT::ToggleLight() { QMGL->setLight(!QMGL->getLight()); } +//----------------------------------------------------------------------------- +void mglCanvasQT::ToggleNo() { QMGL->restore(); } +//----------------------------------------------------------------------------- +void mglCanvasQT::ToggleZoom() { QMGL->setZoom(!QMGL->getZoom()); } +//----------------------------------------------------------------------------- +void mglCanvasQT::ToggleRotate(){ QMGL->setRotate(!QMGL->getRotate());} +//----------------------------------------------------------------------------- +void mglCanvasQT::Update() { SetCurFig(0); QMGL->update(); } +//----------------------------------------------------------------------------- +void mglCanvasQT::Adjust() { QMGL->adjust(); } +//----------------------------------------------------------------------------- +void mglCanvasQT::Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title, void *par, void (*reload)(void *p), bool maximize) +{ + SetDrawFunc(draw, par, reload); + if(Wnd) + { + Wnd->setWindowTitle(title); + if(maximize) + { Wnd->showMaximized(); } + else Wnd->show(); + return; + } + + if(!qApp) + { +#if !defined(WIN32) && !defined(__APPLE__) + // try to fix possible multi-threading errors + // must be placed before ANY window creation + XInitThreads(); +#endif + QApplication *a; + if(!argv) + { + static char tmp[2][1]; + tmp[0][0]=tmp[1][0]=0; + static int aa=1; + a = new QApplication(aa, (char **)tmp); + } + else a = new QApplication(argc, argv); + a->connect(a, SIGNAL(lastWindowClosed()), a, SLOT(quit())); + } + + Wnd = new QMainWindow; Wnd->resize(850,680); + Wnd->setWindowTitle(title); + scroll = new QScrollArea(Wnd); + + QMGL = new QMathGL(Wnd); + popup = mglMakeMenu(Wnd, QMGL, tet, phi); + QMGL->setPopup(popup); QMGL->setGraph(this); + QMGL->setDraw(draw, par); + QMGL->appName = title; + qApp->processEvents(); + scroll->setWidget(QMGL); + Wnd->setCentralWidget(scroll); + QMGL->refresh(); + if(!maximize) Wnd->show(); + else Wnd->showMaximized(); +} +//----------------------------------------------------------------------------- +#include "xpm/fileprint.xpm" +#include "xpm/copy.xpm" +#include "xpm/left_1.xpm" +#include "xpm/right_1.xpm" +#include "xpm/down_1.xpm" +#include "xpm/norm_1.xpm" +#include "xpm/zoom_1.xpm" +#include "xpm/up_1.xpm" +#include "xpm/alpha.xpm" +#include "xpm/light.xpm" +#include "xpm/zoom_in.xpm" +#include "xpm/zoom_out.xpm" +#include "xpm/rotate.xpm" +#include "xpm/ok.xpm" +#include "xpm/show_sl.xpm" +#include "xpm/next_sl.xpm" +#include "xpm/prev_sl.xpm" +#include "xpm/text.xpm" +#include "xpm/line.xpm" +#include "xpm/curve.xpm" +#include "xpm/mark_o.xpm" +#include "xpm/mark_s.xpm" +#include "xpm/mark_a.xpm" +#include "xpm/mark_d.xpm" +//----------------------------------------------------------------------------- +#define TR QObject::tr +QMenu *mglMakeMenu(QMainWindow *Wnd, QMathGL *QMGL, QSpinBox *&tet, QSpinBox *&phi) +{ + QAction *a; + QMenu *o, *oo; + QToolBar *bb; + + QMenu *popup = new QMenu(Wnd); + // file menu + { + o = Wnd->menuBar()->addMenu(TR("&File")); + oo = new QMenu(TR("&Export as 2D ..."),Wnd); + oo->addAction(TR("PNG"), QMGL, SLOT(exportPNG()),Qt::ALT+Qt::Key_P); + oo->addAction(TR("solid PNG"), QMGL, SLOT(exportPNGs()),Qt::ALT+Qt::Key_F); + oo->addAction(TR("JPEG"), QMGL, SLOT(exportJPG()),Qt::ALT+Qt::Key_J); + oo->addAction(TR("bitmap EPS"), QMGL, SLOT(exportBPS())); + oo->addAction(TR("vector EPS"), QMGL, SLOT(exportEPS()),Qt::ALT+Qt::Key_E); + oo->addAction(TR("SVG"), QMGL, SLOT(exportSVG()),Qt::ALT+Qt::Key_S); + oo->addAction(TR("LaTeX"), QMGL, SLOT(exportTEX()),Qt::ALT+Qt::Key_L); + o->addMenu(oo); popup->addMenu(oo); + oo = new QMenu(TR("&Export as 3D ..."),Wnd); + oo->addAction(TR("MGLD"), QMGL, SLOT(exportMGLD()),Qt::ALT+Qt::Key_M); + oo->addAction(TR("PRC"), QMGL, SLOT(exportPRC()),Qt::ALT+Qt::Key_D); + oo->addAction(TR("OBJ"), QMGL, SLOT(exportOBJ()),Qt::ALT+Qt::Key_O); + oo->addAction(TR("STL"), QMGL, SLOT(exportSTL())); + oo->addAction(TR("XYZ"), QMGL, SLOT(exportXYZ())); +// oo->addAction(TR("X3D"), QMGL, SLOT(exportX3D()),Qt::ALT+Qt::Key_X); + o->addMenu(oo); popup->addMenu(oo); + + o->addSeparator(); + a = new QAction(QPixmap(fileprint), TR("Print &graphics"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(print())); + a->setToolTip(TR("Open printer dialog and print graphics\t(CTRl+P)")); + a->setShortcut(Qt::CTRL+Qt::Key_P); o->addAction(a); + o->addSeparator(); + o->addAction(TR("&Close"), Wnd, SLOT(close()), Qt::CTRL+Qt::Key_W); + } + // graphics menu + { + bb = new QToolBar(TR("Graphics"),Wnd); + Wnd->addToolBar(Qt::TopToolBarArea, bb); + o = Wnd->menuBar()->addMenu(TR("&Graphics")); + a = new QAction(QPixmap(alpha_xpm), TR("&Alpha"), Wnd); + a->setShortcut(Qt::ALT+Qt::Key_T); a->setCheckable(true); + Wnd->connect(a, SIGNAL(toggled(bool)), QMGL, SLOT(setAlpha(bool))); + Wnd->connect(QMGL, SIGNAL(alphaChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(TR("Switch on/off TRansparency for the graphics (Alt+T).")); + o->addAction(a); bb->addAction(a); + a = new QAction(QPixmap(light_xpm), TR("&Light"), Wnd); + a->setShortcut(Qt::ALT+Qt::Key_L); a->setCheckable(true); + Wnd->connect(a, SIGNAL(toggled(bool)), QMGL, SLOT(setLight(bool))); + Wnd->connect(QMGL, SIGNAL(lightChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(TR("Switch on/off lightning for the graphics (Alt+L).")); + o->addAction(a); bb->addAction(a); + a = new QAction(QPixmap(rotate_xpm), TR("&Rotate by mouse"), Wnd); + a->setCheckable(true); + Wnd->connect(a, SIGNAL(toggled(bool)), QMGL, SLOT(setRotate(bool))); + Wnd->connect(QMGL, SIGNAL(rotateChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(TR("Switch on/off mouse handling of the graphics\n(rotation, shifting, zooming and perspective).")); + bb->addAction(a); + a = new QAction(QPixmap(zoom_in_xpm), TR("&Zoom by mouse"), Wnd); + a->setCheckable(true); + Wnd->connect(a, SIGNAL(toggled(bool)), QMGL, SLOT(setZoom(bool))); + Wnd->connect(QMGL, SIGNAL(zoomChanged(bool)), a, SLOT(setChecked(bool))); + a->setToolTip(TR("Switch on/off mouse zoom of selected region.")); + bb->addAction(a); + o->addSeparator(); + a = new QAction(QPixmap(zoom_out_xpm), TR("Res&tore"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(restore())); + a->setToolTip(TR("Restore default graphics rotation, zoom and perspective (Alt+Space).")); + a->setShortcut(Qt::ALT+Qt::Key_Space); + o->addAction(a); bb->addAction(a); popup->addAction(a); + bb->addSeparator(); + a = new QAction(QPixmap(ok_xpm), TR("Re&draw"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(update())); + a->setToolTip(TR("Execute script and redraw graphics (F5).")); + a->setShortcut(Qt::Key_F5); + o->addAction(a); bb->addAction(a); popup->addAction(a); + a = new QAction(TR("&Adjust size"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(adjust())); + a->setToolTip(TR("Change canvas size to fill whole region (F6).")); + a->setShortcut(Qt::Key_F6); o->addAction(a); + a = new QAction(QPixmap(copy_xpm), TR("&Copy plot"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(copy())); + a->setToolTip(TR("Copy graphics to clipboard (CTRl+Shift+G).")); + a->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_G); + o->addAction(a); bb->addAction(a); popup->addAction(a); + + bb->addSeparator(); + oo = new QMenu(TR("Primitives ..."),Wnd); + a = new QAction(QPixmap(line_xpm), TR("Add line"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addLine())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add line which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(curve_xpm), TR("Add curve"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addCurve())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add curve which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(mark_s_xpm), TR("Add rect"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addRect())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add rectangle which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(mark_d_xpm), TR("Add rhombus"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addRhomb())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add rhombus which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(mark_o_xpm), TR("Add ellipse"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addEllipse())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add ellipse which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(mark_a_xpm), TR("Add mark"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addMark())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add marker which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(text_xpm), TR("Add text"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(addText())); + Wnd->connect(QMGL, SIGNAL(usePrimChanged(bool)), a, SLOT(setVisible(bool))); + a->setToolTip(TR("Add text which properties can be changed later by mouse.")); + bb->addAction(a); oo->addAction(a); + o->addMenu(oo); + + bb->addSeparator(); + tet = new QSpinBox(Wnd); tet->setWrapping(true); + bb->addWidget(tet); tet->setRange(-180, 180); tet->setSingleStep(10); + Wnd->connect(tet, SIGNAL(valueChanged(int)), QMGL, SLOT(setTet(int))); + Wnd->connect(QMGL, SIGNAL(tetChanged(int)), tet, SLOT(setValue(int))); + tet->setToolTip(TR("Set value of \\theta angle.")); + bb->addSeparator(); + phi = new QSpinBox(Wnd); phi->setWrapping(true); + bb->addWidget(phi); phi->setRange(-180, 180); phi->setSingleStep(10); + Wnd->connect(phi, SIGNAL(valueChanged(int)), QMGL, SLOT(setPhi(int))); + Wnd->connect(QMGL, SIGNAL(phiChanged(int)), phi, SLOT(setValue(int))); + phi->setToolTip(TR("Set value of \\phi angle.")); +// bb->addSeparator(); + } + // zooming menu + { + oo = o->addMenu(TR("Zoom/move")); + bb = new QToolBar(TR("Zoom graphics"),Wnd); + Wnd->addToolBar(Qt::LeftToolBarArea, bb); + a = new QAction(QPixmap(left_1_xpm), TR("Move &left"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(shiftLeft())); + a->setToolTip(TR("Move graphics left by 1/3 of its width.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(up_1_xpm), TR("Move &up"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(shiftUp())); + a->setToolTip(TR("Move graphics up by 1/3 of its height.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(zoom_1_xpm), TR("Zoom &in"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(zoomIn())); + a->setToolTip(TR("Zoom in graphics.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(norm_1_xpm), TR("Zoom &out"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(zoomOut())); + a->setToolTip(TR("Zoom out graphics.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(down_1_xpm), TR("Move &down"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(shiftDown())); + a->setToolTip(TR("Move graphics up down 1/3 of its height.")); + bb->addAction(a); oo->addAction(a); + a = new QAction(QPixmap(right_1_xpm), TR("Move &right"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(shiftRight())); + a->setToolTip(TR("Move graphics right by 1/3 of its width.")); + bb->addAction(a); oo->addAction(a); + } + // animation menu + { + o = Wnd->menuBar()->addMenu(TR("&Animation")); + bb = new QToolBar(TR("Animation"),Wnd); + Wnd->addToolBar(Qt::LeftToolBarArea, bb); + a = new QAction(QPixmap(next_sl_xpm), TR("&Next slide"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(nextSlide())); + a->setToolTip(TR("Show next slide (Ctrl+.).")); + a->setShortcut(Qt::CTRL+Qt::Key_Period); o->addAction(a); bb->addAction(a); + a = new QAction(QPixmap(show_sl_xpm), TR("&Slideshow"), Wnd); + a->setCheckable(true); + Wnd->connect(a, SIGNAL(toggled(bool)), QMGL, SLOT(animation(bool))); + a->setToolTip(TR("Run slideshow (CTRl+F5).")); + a->setShortcut(Qt::CTRL+Qt::Key_F5); o->addAction(a); bb->addAction(a); + a = new QAction(QPixmap(prev_sl_xpm), TR("&Prev slide"), Wnd); + Wnd->connect(a, SIGNAL(triggered()), QMGL, SLOT(prevSlide())); + a->setToolTip(TR("Show previous slide (Ctrl+,).")); + a->setShortcut(Qt::CTRL+Qt::Key_Comma); o->addAction(a); bb->addAction(a); + } + + Wnd->menuBar()->addSeparator(); + o = Wnd->menuBar()->addMenu(TR("&Help")); + o->addAction(TR("About"), QMGL, SLOT(about())); + o->addAction(TR("About &Qt"), QMGL, SLOT(aboutQt())); + return popup; +} +//----------------------------------------------------------------------------- +HMGL MGL_EXPORT mgl_create_graph_qt(int (*draw)(HMGL gr, void *p), const char *title, void *par, void (*load)(void *p)) +{ + mglCanvasQT *g = new mglCanvasQT; + g->Window(0,0,draw,title,par,load); + return g; +} +int MGL_EXPORT mgl_qt_run() { return (qApp)?qApp->exec():-1; } +//----------------------------------------------------------------------------- +uintptr_t MGL_EXPORT mgl_create_graph_qt_(const char *title, int l) +{ + char *s = new char[l+1]; memcpy(s,title,l); s[l]=0; + uintptr_t t = uintptr_t(mgl_create_graph_qt(0,s,0,0)); + delete []s; return t; +} +int MGL_EXPORT mgl_qt_run_() { return mgl_qt_run(); } +//----------------------------------------------------------------------------- diff --git a/widgets/qt4/CMakeLists.txt b/widgets/qt4/CMakeLists.txt new file mode 100644 index 0000000..10cf8ef --- /dev/null +++ b/widgets/qt4/CMakeLists.txt @@ -0,0 +1,72 @@ +include(GenerateExportHeader) +add_compiler_export_flags() +function(libmglqt mglqt) + add_library(mgl-${mglqt} SHARED ${MGL_QT_FILES}) + add_library(mgl-${mglqt}-static STATIC ${MGL_QT_FILES}) + set_target_properties(mgl-${mglqt} PROPERTIES SOVERSION ${MathGL_SOVERSION}) + set_target_properties(mgl-${mglqt} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-${mglqt} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") + set_target_properties(mgl-${mglqt}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-${mglqt}-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) + target_link_libraries(mgl-${mglqt} mgl) + target_link_libraries(mgl-${mglqt} ${QT_LIBRARIES}) + + if(enable-mgl2) + set_target_properties(mgl-${mglqt} PROPERTIES OUTPUT_NAME "mgl2-${mglqt}") + set_target_properties(mgl-${mglqt}-static PROPERTIES OUTPUT_NAME "mgl2-${mglqt}") + else(enable-mgl2) + set_target_properties(mgl-${mglqt}-static PROPERTIES OUTPUT_NAME "mgl-${mglqt}") + endif(enable-mgl2) + + install( + TARGETS mgl-${mglqt} mgl-${mglqt}-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} + ) +endfunction(libmglqt mglqt) + +if(enable-qt4) + include(../../cmake-qt4.txt) + qt4_wrap_cpp(MGL_MOC_FILES ../../include/mgl2/qmathgl.h) + set(MGL_QT_FILES ../qt.cpp ${MGL_MOC_FILES} ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h) + libmglqt(qt4) + if(NOT enable-qt5asqt) + libmglqt(qt) + endif(NOT enable-qt5asqt) + + if(MGL_HAVE_FLTK AND NOT enable-qt5) + include_directories(${FLTK_INCLUDE_DIR}) + + set(MGL_WND_SRC ${MGL_QT_FILES} ../fltk.cpp ../../include/mgl2/fltk.h) + + add_library(mgl-wnd SHARED ${MGL_WND_SRC}) + add_library(mgl-wnd-static STATIC ${MGL_WND_SRC}) + + set_target_properties(mgl-wnd PROPERTIES SOVERSION ${MathGL_SOVERSION}) + set_target_properties(mgl-wnd PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-wnd PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") + set_target_properties(mgl-wnd-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-wnd-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) + + if(enable-mgl2) + set_target_properties(mgl-wnd PROPERTIES OUTPUT_NAME "mgl2-wnd") + set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl2-wnd") + else(enable-mgl2) + set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl-wnd") + endif(enable-mgl2) + + target_link_libraries(mgl-wnd mgl) + target_link_libraries(mgl-wnd ${QT_LIBRARIES}) + target_link_libraries(mgl-wnd ${FLTK_LIBRARIES}) + + install( + TARGETS mgl-wnd mgl-wnd-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} + ) + endif(MGL_HAVE_FLTK AND NOT enable-qt5) +else(enable-qt4) + set(MGL_HAVE_QT4 0) +endif(enable-qt4) diff --git a/widgets/qt5/CMakeLists.txt b/widgets/qt5/CMakeLists.txt new file mode 100644 index 0000000..1bd58bf --- /dev/null +++ b/widgets/qt5/CMakeLists.txt @@ -0,0 +1,73 @@ +include(GenerateExportHeader) +add_compiler_export_flags() + +function(libmglqt mglqt) + add_library(mgl-${mglqt} SHARED ${MGL_QT_FILES}) + add_library(mgl-${mglqt}-static STATIC ${MGL_QT_FILES}) + set_target_properties(mgl-${mglqt} PROPERTIES SOVERSION ${MathGL_SOVERSION}) + set_target_properties(mgl-${mglqt} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-${mglqt} PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") + set_target_properties(mgl-${mglqt}-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-${mglqt}-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) + target_link_libraries(mgl-${mglqt} mgl) + qt5_use_modules(mgl-${mglqt} Core Widgets Gui PrintSupport) + qt5_use_modules(mgl-${mglqt}-static Core Widgets Gui PrintSupport) + if(enable-mgl2) + set_target_properties(mgl-${mglqt} PROPERTIES OUTPUT_NAME "mgl2-${mglqt}") + set_target_properties(mgl-${mglqt}-static PROPERTIES OUTPUT_NAME "mgl2-${mglqt}") + else(enable-mgl2) + set_target_properties(mgl-${mglqt}-static PROPERTIES OUTPUT_NAME "mgl-${mglqt}") + endif(enable-mgl2) + install( + TARGETS mgl-${mglqt} mgl-${mglqt}-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} + ) +endfunction(libmglqt mglqt) + +if(enable-qt5) + include(../../cmake-qt5.txt) + qt5_wrap_cpp(MGL_MOC_FILES ../../include/mgl2/qmathgl.h) + set(MGL_QT_FILES ../qt.cpp ${MGL_MOC_FILES} ../../include/mgl2/qt.h ../../include/mgl2/qmathgl.h) + libmglqt(qt5) + if(enable-qt5asqt) + libmglqt(qt) + endif(enable-qt5asqt) + + if(MGL_HAVE_FLTK) + include_directories(${FLTK_INCLUDE_DIR}) + + set(MGL_WND_SRC ${MGL_QT_FILES} ../fltk.cpp ../../include/mgl2/fltk.h) + + add_library(mgl-wnd SHARED ${MGL_WND_SRC}) + add_library(mgl-wnd-static STATIC ${MGL_WND_SRC}) + + set_target_properties(mgl-wnd PROPERTIES SOVERSION ${MathGL_SOVERSION}) + set_target_properties(mgl-wnd PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-wnd PROPERTIES DEFINE_SYMBOL "mgl_EXPORTS") + set_target_properties(mgl-wnd-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + set_target_properties(mgl-wnd-static PROPERTIES COMPILE_FLAGS -DMGL_STATIC_DEFINE) + + if(enable-mgl2) + set_target_properties(mgl-wnd PROPERTIES OUTPUT_NAME "mgl2-wnd") + set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl2-wnd") + else(enable-mgl2) + set_target_properties(mgl-wnd-static PROPERTIES OUTPUT_NAME "mgl-wnd") + endif(enable-mgl2) + + target_link_libraries(mgl-wnd mgl) + qt5_use_modules(mgl-wnd Core Widgets Gui PrintSupport) + qt5_use_modules(mgl-wnd-static Core Widgets Gui PrintSupport) + target_link_libraries(mgl-wnd ${FLTK_LIBRARIES}) + + install( + TARGETS mgl-wnd mgl-wnd-static + RUNTIME DESTINATION bin + ARCHIVE DESTINATION ${MGL_LIB_INSTALL_DIR} + LIBRARY DESTINATION ${MGL_LIB_INSTALL_DIR} + ) + endif(MGL_HAVE_FLTK) +else(enable-qt5) + set(MGL_HAVE_QT5 0) +endif(enable-qt5) diff --git a/widgets/wx.cpp b/widgets/wx.cpp new file mode 100644 index 0000000..3989a47 --- /dev/null +++ b/widgets/wx.cpp @@ -0,0 +1,422 @@ +/*************************************************************************** + * wx.cpp is part of Math Graphic Library * + * Copyright (C) 2007-2014 Alexey Balakin * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +//----------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include + +#include "mgl2/canvas_wnd.h" +#include "mgl2/wx.h" +//----------------------------------------------------------------------------- +class MGL_EXPORT mglCanvasWX : public mglCanvasWnd +{ +friend class wxMathGL; +public: + int sshow; ///< Current state of animation switch (toggle button) + wxMathGL *WMGL; ///< Control which draw graphics + wxWindow *Wnd; ///< Pointer to window + + mglCanvasWX(); + virtual ~mglCanvasWX(); + + /// Create a window for plotting. Now implemeted only for GLUT. + void Window(int argc, char **argv, int (*draw)(mglBase *gr, void *p), const char *title, + void *par=NULL, void (*reload)(void *p)=NULL, bool maximize=false); + /// Switch on/off transparency (do not overwrite switches in user drawing function) + void ToggleAlpha(); + /// Switch on/off lighting (do not overwrite switches in user drawing function) + void ToggleLight(); + void ToggleRotate(); ///< Switch on/off rotation by mouse + void ToggleZoom(); ///< Switch on/off zooming by mouse + void ToggleNo(); ///< Switch off all zooming and rotation + void Update(); ///< Update picture by calling user drawing function + void Adjust(); ///< Adjust size of bitmap to window size + void GotoFrame(int d); ///< Show arbitrary frame (use relative step) + void Animation(); ///< Run animation (I'm too lasy to change it) + +protected: + wxScrolledWindow *scroll; ///< Scrolling area + wxMenu *popup; ///< Popup menu +// wxSpinCtrl *tet, *phi; ///< Spin box for angles // TODO + + void MakeMenu(); ///< Create menu, toolbar and popup menu +}; +//----------------------------------------------------------------------------- +const wxString ScriptName(L"default"); +enum +{ + TIMER_ID=1000, + LAST_ID +}; +BEGIN_EVENT_TABLE(wxMathGL, wxWindow) + EVT_TIMER (TIMER_ID, wxMathGL::OnNextSlide) + EVT_PAINT (wxMathGL::OnPaint) + EVT_SIZE (wxMathGL::OnSize) + EVT_LEFT_DOWN (wxMathGL::OnMouseLeftDown) + EVT_RIGHT_DOWN (wxMathGL::OnMouseDown) + EVT_MIDDLE_DOWN (wxMathGL::OnMouseDown) + EVT_LEFT_UP (wxMathGL::OnMouseLeftUp) + EVT_RIGHT_UP (wxMathGL::OnMouseRightUp) + EVT_MOTION (wxMathGL::OnMouseMove) +END_EVENT_TABLE() +//----------------------------------------------------------------------------- +// +// class wxMathGL +// +//----------------------------------------------------------------------------- +wxMathGL::wxMathGL(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxWindow(parent,id,pos,size,style,name) +{ + AutoResize = false; draw_par = 0; draw_func = 0; + gr = new mglCanvas; popup = 0; + phi = tet = per = 0; + x1 = y1 = 0; x2 = y2 = 1; + alpha = light = zoom = rotate = false; +// SetSize(600, 400); + timer = new wxTimer(this,TIMER_ID); +} +//----------------------------------------------------------------------------- +wxMathGL::~wxMathGL() { if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); } +//----------------------------------------------------------------------------- +double wxMathGL::GetRatio() { return double(mgl_get_width(gr))/mgl_get_height(gr); } +//----------------------------------------------------------------------------- +void wxMathGL::SetGraph(HMGL GR) +{ + mglCanvas *gg = dynamic_cast(GR); + if(!gg) return; + if(mgl_use_graph(gr,-1)<1) mgl_delete_graph(gr); + gr=gg; mgl_use_graph(gg,1); +} +//----------------------------------------------------------------------------- +void wxMathGL::OnPaint(wxPaintEvent& ) +{ + wxPaintDC dc(this); + dc.DrawBitmap(pic,0,0); +// if(zoom) dc.DrawRectangle(x0,y0,xe-x0,ye-y0); + if(mgl_get_flag(gr,MGL_SHOW_POS) && !MousePos.IsEmpty()) + dc.DrawText(MousePos,0,12); + // TODO: add grid drawing here (from Qt) + // TODO: add active points drawing here (from Qt) +} +//----------------------------------------------------------------------------- +void wxMathGL::OnSize(wxSizeEvent& event) +{ + wxSize ev = event.GetSize(); + if(mgl_get_width(gr)==ev.GetWidth() && mgl_get_height(gr)==ev.GetHeight()) + return; + if(AutoResize && ev.GetWidth()>0 && ev.GetHeight()>0) + { mgl_set_size(gr, ev.GetWidth(), ev.GetHeight()); Update(); } + else SetSize(mgl_get_width(gr), mgl_get_height(gr)); +} +//----------------------------------------------------------------------------- +void wxMathGL::OnNextSlide(wxTimerEvent& ) { NextSlide(); } +//----------------------------------------------------------------------------- +void wxMathGL::SetPer(int p) +{ if(100*per!=p && p>=0 && p<100) { per = 0.01*p; Repaint(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetPhi(int p) +{ if(phi!=p) { phi = p; Repaint(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetTet(int t) +{ if(tet!=t) { tet = t; Repaint(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetAlpha(bool a) +{ if(alpha!=a) { alpha = a; Update(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetLight(bool l) +{ if(light!=l) { light = l; Update(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetZoom(bool z) +{ if(zoom!=z) { zoom=z; rotate=false; Repaint(); } } +//----------------------------------------------------------------------------- +void wxMathGL::SetRotate(bool r) +{ if(rotate!=r) { zoom=false; rotate=r; Repaint(); } } +//----------------------------------------------------------------------------- +void wxMathGL::ShiftDown() +{ mreal d=(y2-y1)/3; y1+=d; y2+=d; Repaint(); } +//----------------------------------------------------------------------------- +void wxMathGL::ShiftUp() +{ mreal d=(y2-y1)/3; y1-=d; y2-=d; Repaint(); } +//----------------------------------------------------------------------------- +void wxMathGL::ShiftRight() +{ mreal d=(x2-x1)/3; x1-=d; x2-=d; Repaint(); } +//----------------------------------------------------------------------------- +void wxMathGL::ShiftLeft() +{ mreal d=(x2-x1)/3; x1+=d; x2+=d; Repaint(); } +//----------------------------------------------------------------------------- +void wxMathGL::Restore() +{ + SetPhi(0); SetTet(0); SetPer(0); + x1=y1=0; x2=y2=1; zoom=rotate=false; + Repaint(); +} +//----------------------------------------------------------------------------- +void wxMathGL::ZoomIn() +{ + mreal d; + d = (y2-y1)/4; y1 += d; y2 -= d; + d = (x2-x1)/4; x1 += d; x2 -= d; + Repaint(); +} +//----------------------------------------------------------------------------- +void wxMathGL::ZoomOut() +{ + mreal d; + d = (y2-y1)/2; y1 -= d; y2 += d; + d = (x2-x1)/2; x1 -= d; x2 += d; + Repaint(); +} +//----------------------------------------------------------------------------- +void wxMathGL::Update() +{ + if(draw_func || draw_cl) + { + if(mgl_get_flag(gr,MGL_CLF_ON_UPD)) mgl_set_def_param(gr); + mgl_reset_frames(gr); + mgl_set_alpha(gr,alpha); mgl_set_light(gr,light); + if(draw_func) draw_func(gr, draw_par); // drawing itself + else if(draw_cl) { mglGraph g(gr); draw_cl->Draw(&g); } + const char *buf = mgl_get_mess(gr); + if(*buf) + { + wxMessageDialog dlg(this, wxString(buf,wxConvLocal), appName, wxOK); + dlg.ShowModal(); + } + } + MousePos.Empty(); Repaint(); +} +//----------------------------------------------------------------------------- +wxBitmap MGL_EXPORT ConvertFromGraph(HMGL gr) +{ + const unsigned char *bb = mgl_get_rgb(gr); + int w=mgl_get_width(gr), h=mgl_get_height(gr); + unsigned char *tmp = (unsigned char *)malloc(3*w*h); + memcpy(tmp,bb,3*w*h); + wxImage img(w, h); img.SetData(tmp); + return wxBitmap(img); +} +//----------------------------------------------------------------------------- +void wxMathGL::Repaint() +{ + mgl_zoom(gr,x1,y1,x2,y2); mgl_view(gr,phi,0,tet); mgl_perspective(gr, per); + pic = ConvertFromGraph(gr); + wxSize sz=GetSize(); + if(pic.GetWidth()!=sz.GetWidth() || pic.GetHeight()!=sz.GetHeight()) + SetSize(pic.GetWidth(), pic.GetHeight()); + Refresh(); +} +//----------------------------------------------------------------------------- +void wxMathGL::OnMouseLeftDown(wxMouseEvent &ev) +{ + long x=ev.GetX(), y=ev.GetY(); + if(!zoom && !rotate) + { + mglPoint p = gr->CalcXYZ(x, y); + MousePos.Printf(wxT("x=%g, y=%g, z=%g"),p.x,p.y,p.z); + Refresh(); +// emit mouseClick(p.x,p.y,p.z); + } + xe=x0=x; ye=y0=y; ev.Skip(); +} +//----------------------------------------------------------------------------- +void wxMathGL::OnMouseDown(wxMouseEvent &ev) +{ xe=x0=ev.GetX(); ye=y0=ev.GetY(); ev.Skip(); } +//----------------------------------------------------------------------------- +void wxMathGL::OnMouseLeftUp(wxMouseEvent &) +{ + if(zoom) + { + int w1=GetSize().GetWidth(),h1=GetSize().GetHeight(); + mreal _x1,_x2,_y1,_y2; + _x1 = x1+(x2-x1)*(x0-GetPosition().x)/mreal(w1); + _y1 = y2-(y2-y1)*(ye-GetPosition().y)/mreal(h1); + _x2 = x1+(x2-x1)*(xe-GetPosition().x)/mreal(w1); + _y2 = y2-(y2-y1)*(y0-GetPosition().y)/mreal(h1); + x1=_x1; x2=_x2; y1=_y1; y2=_y2; + if(x1>x2) { _x1=x1; x1=x2; x2=_x1; } + if(y1>y2) { _x1=y1; y1=y2; y2=_x1; } + x0 = xe; y0 = ye; + Update(); + } +} +//----------------------------------------------------------------------------- +void wxMathGL::OnMouseRightUp(wxMouseEvent &ev) +{ if(popup && !rotate) PopupMenu(popup, ev.GetPosition()); } +//----------------------------------------------------------------------------- +void wxMathGL::OnMouseMove(wxMouseEvent &ev) +{ + long w=GetSize().GetWidth(), h=GetSize().GetHeight(); + xe=ev.GetX(); ye=ev.GetY(); + if(rotate) + { + if(ev.ButtonDown(wxMOUSE_BTN_LEFT)) // rotate + { + mreal ff = 240/sqrt(mreal(w*h)); + phi += int((x0-xe)*ff); + tet += int((y0-ye)*ff); + if(phi>180) phi-=360; if(phi<-180) phi+=360; + if(tet>180) tet-=360; if(tet<-180) tet+=360; +// Update(); + } + if(ev.ButtonDown(wxMOUSE_BTN_RIGHT)) // zoom and perspective + { + mreal ff = 2.*(y0-ye)/w, gg = 0.5*(xe-x0)/h; + mreal cx = (x1+x2)/2, cy = (y1+y2)/2; + x1 = cx+(x1-cx)*exp(-ff); x2 = cx+(x2-cx)*exp(-ff); + y1 = cy+(y1-cy)*exp(-ff); y2 = cy+(y2-cy)*exp(-ff); + per = per + gg; + if(per<0) per = 0; if(per>=1) per = 0.9999; +// Update(); + } + if(ev.ButtonDown(wxMOUSE_BTN_MIDDLE)) // shift + { + mreal ff = 1./sqrt(mreal(w*h)); + mreal dx = (x0-xe)*ff*(x2-x1), dy = (y0-ye)*ff*(y2-y1); + x1 += dx; x2 += dx; y1 -= dy; y2 -= dy; + } + x0 = xe; y0 = ye; + Update(); + } +// if(zoom) Update(); + if(zoom) Refresh(0); +} +//----------------------------------------------------------------------------- +wxString mglSetExtension(wxString &fname, const char *ext) +{ + wxString oname; + if(fname.Right(4)!=wxChar('.')+wxString(ext,*wxConvCurrent)) + oname = fname+wxChar('.')+wxString(ext,*wxConvCurrent); + return oname; +} +//----------------------------------------------------------------------------- +// NOTE: this is replacement for wxString::char_str() which is for v.2.8 or later +const char *mglw_str(const wxString &str) +{ + static char *buf=0; + if(buf) delete []buf; + long i, n=str.Len(); + buf = new char[n+1]; buf[n]=0; + for(i=0;iOpen()) + { + wxTheClipboard->SetData( new wxBitmapDataObject(pic) ); + wxTheClipboard->Close(); + } +} +//----------------------------------------------------------------------------- +void wxMathGL::SetSize(int w, int h) +{ mgl_set_size(gr,w,h); wxWindow::SetSize(w, h); Update(); } +//----------------------------------------------------------------------------- +void wxMathGL::Adjust() +{ + wxSize sz=GetSize(); + mgl_set_size(gr,sz.GetWidth(),sz.GetHeight()); + Repaint(); +} +//----------------------------------------------------------------------------- +void wxMathGL::NextSlide() +{ + mglCanvasWnd *g = dynamic_cast(gr); + if(g && g->GetNumFig()>1) g->NextFrame(); +} +//----------------------------------------------------------------------------- +void wxMathGL::PrevSlide() +{ + mglCanvasWnd *g = dynamic_cast(gr); + if(g && g->GetNumFig()>1) g->PrevFrame(); +} +//----------------------------------------------------------------------------- +void wxMathGL::Animation(bool st) +{ + if(st) timer->Start(int(mgl_wnd_get_delay(gr)*1000)); + else timer->Stop(); +} +//----------------------------------------------------------------------------- +void wxMathGL::About() +{ + wxString s = wxT("MathGL v. 2.") + wxString::Format(wxT("%g"),MGL_VER2) + + wxT("\n(c) Alexey Balakin, 2007\nhttp://mathgl.sourceforge.net/"); + wxMessageBox(s, wxT("MathGL - about"), wxOK|wxICON_INFORMATION, this); +} +//-----------------------------------------------------------------------------